Commit b1f2c6e3 authored by Daniel Teske's avatar Daniel Teske

ProjectWindow: Move handling of subTargetIndex to TargetSettingsPanel

The TargetSettingsPanelWidget wants to keep whether the Build or Run tab
is shown synchronized between projects. Moving the code to
TargetSettingsPanelWidget removes some of the special handling
ProjectWindow does.

Change-Id: Ic4e85b6458a1271ea2de4d8c5786e95d3a78fbbd
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent 0374a978
......@@ -226,8 +226,7 @@ void PanelsWidget::addPanelWidget(PropertiesPanel *panel, int row)
ProjectWindow::ProjectWindow(QWidget *parent)
: QWidget(parent),
m_currentWidget(0),
m_previousTargetSubIndex(-1)
m_currentWidget(0)
{
// Setup overall layout:
QVBoxLayout *viewLayout = new QVBoxLayout(this);
......@@ -386,19 +385,12 @@ void ProjectWindow::showProperties(int index, int subIndex)
// Set up custom panels again:
int pos = 0;
IProjectPanelFactory *fac = 0;
// remember previous sub index state of target settings page
if (TargetSettingsPanelWidget *previousPanelWidget
= qobject_cast<TargetSettingsPanelWidget*>(m_currentWidget)) {
m_previousTargetSubIndex = previousPanelWidget->currentSubIndex();
}
if (m_hasTarget.value(project) || project->requiresTargetPanel()) {
if (subIndex == 0) {
// Targets page
removeCurrentWidget();
TargetSettingsPanelWidget *panelWidget = new TargetSettingsPanelWidget(project);
if (m_previousTargetSubIndex >= 0)
panelWidget->setCurrentSubIndex(m_previousTargetSubIndex);
m_currentWidget = panelWidget;
m_centralWidget->addWidget(m_currentWidget);
m_centralWidget->setCurrentWidget(m_currentWidget);
......
......@@ -102,7 +102,6 @@ private:
QWidget *m_currentWidget;
QList<ProjectExplorer::Project *> m_tabIndexToProject;
QMap<ProjectExplorer::Project *, bool> m_hasTarget;
int m_previousTargetSubIndex;
};
} // namespace Internal
......
......@@ -67,6 +67,8 @@ using namespace Core;
namespace ProjectExplorer {
namespace Internal {
int TargetSettingsPanelWidget::s_targetSubIndex = -1;
///
// TargetSettingsWidget
///
......@@ -194,6 +196,7 @@ void TargetSettingsPanelWidget::setupUi()
// Now set the correct target
int index = m_targets.indexOf(m_project->activeTarget());
m_selector->setCurrentIndex(index);
m_selector->setCurrentSubIndex(s_targetSubIndex);
currentTargetChanged(index, m_selector->currentSubIndex());
connect(m_selector, SIGNAL(currentChanged(int,int)),
......@@ -231,6 +234,8 @@ void TargetSettingsPanelWidget::currentTargetChanged(int targetIndex, int subInd
return;
}
s_targetSubIndex = subIndex;
Target *target = m_targets.at(targetIndex);
// Target was not actually changed:
......
......@@ -103,6 +103,7 @@ private:
QAction *m_lastAction;
QAction *m_importAction;
int m_menuTargetIndex;
static int s_targetSubIndex;
};
} // namespace Internal
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment