From 90a85a9b1e9e24a558c260950ccc590279a324de Mon Sep 17 00:00:00 2001 From: dt Date: Tue, 15 Jun 2010 14:44:15 +0200 Subject: [PATCH] Fix parsing canceld on project load Task-Nr: QTCREATORBUG-1616 --- .../projectexplorer/doubletabwidget.cpp | 16 ++++++++-------- src/plugins/projectexplorer/doubletabwidget.h | 2 ++ src/plugins/projectexplorer/targetselector.cpp | 15 +++++++-------- .../projectexplorer/targetsettingspanel.cpp | 18 ++++++++++-------- 4 files changed, 27 insertions(+), 24 deletions(-) diff --git a/src/plugins/projectexplorer/doubletabwidget.cpp b/src/plugins/projectexplorer/doubletabwidget.cpp index 91c9c12bb0e..3f9ce39e0c0 100644 --- a/src/plugins/projectexplorer/doubletabwidget.cpp +++ b/src/plugins/projectexplorer/doubletabwidget.cpp @@ -86,6 +86,13 @@ void DoubleTabWidget::setCurrentIndex(int index) update(); } +int DoubleTabWidget::currentSubIndex() const +{ + if (m_currentIndex >= 0 && m_currentIndex < m_tabs.size()) + return m_tabs.at(m_currentIndex).currentSubTab; + return -1; +} + void DoubleTabWidget::setTitle(const QString &title) { m_title = title; @@ -104,10 +111,6 @@ void DoubleTabWidget::addTab(const QString &name, const QStringList &subTabs) tab.subTabs = subTabs; tab.currentSubTab = tab.subTabs.isEmpty() ? -1 : 0; m_tabs.append(tab); - if (m_currentIndex == -1) { - m_currentIndex = m_tabs.size()-1; - emit currentIndexChanged(m_currentIndex, m_tabs.at(m_currentIndex).currentSubTab); - } update(); } @@ -118,10 +121,7 @@ void DoubleTabWidget::insertTab(int index, const QString &name, const QStringLis tab.subTabs = subTabs; tab.currentSubTab = tab.subTabs.isEmpty() ? -1 : 0; m_tabs.insert(index, tab); - if (m_currentIndex == -1) { - m_currentIndex = index; - emit currentIndexChanged(m_currentIndex, m_tabs.at(m_currentIndex).currentSubTab); - } else if (m_currentIndex >= index) { + if (m_currentIndex >= index) { ++m_currentIndex; emit currentIndexChanged(m_currentIndex, m_tabs.at(m_currentIndex).currentSubTab); } diff --git a/src/plugins/projectexplorer/doubletabwidget.h b/src/plugins/projectexplorer/doubletabwidget.h index cebe0406a1c..704eb373c8b 100644 --- a/src/plugins/projectexplorer/doubletabwidget.h +++ b/src/plugins/projectexplorer/doubletabwidget.h @@ -30,6 +30,8 @@ public: int currentIndex() const; void setCurrentIndex(int index); + int currentSubIndex() const; + signals: void currentIndexChanged(int index, int subIndex); diff --git a/src/plugins/projectexplorer/targetselector.cpp b/src/plugins/projectexplorer/targetselector.cpp index 70601a8b035..dd920ec46ec 100644 --- a/src/plugins/projectexplorer/targetselector.cpp +++ b/src/plugins/projectexplorer/targetselector.cpp @@ -46,9 +46,7 @@ void TargetSelector::insertTarget(int index, const QString &name) m_targets.insert(index, target); - if (m_currentTargetIndex == -1) - setCurrentIndex(index); - else if (m_currentTargetIndex >= index) + if (m_currentTargetIndex >= index) setCurrentIndex(m_currentTargetIndex + 1); update(); } @@ -59,12 +57,13 @@ void TargetSelector::removeTarget(int index) m_targets.removeAt(index); - if (m_currentTargetIndex >= m_targets.count()) - setCurrentIndex(m_targets.count() - 1); - else if (m_currentTargetIndex >= index) - // force a signal since the target pointed to has changed: + if (m_currentTargetIndex >= m_targets.count()) { + setCurrentIndex(-1); + } else if (m_currentTargetIndex >= index) { + --m_currentTargetIndex; + // force a signal since the index has changed emit currentChanged(m_currentTargetIndex, m_targets.at(m_currentTargetIndex).currentSubIndex); - + } update(); } diff --git a/src/plugins/projectexplorer/targetsettingspanel.cpp b/src/plugins/projectexplorer/targetsettingspanel.cpp index 2887a886cd9..7bcd1b5db20 100644 --- a/src/plugins/projectexplorer/targetsettingspanel.cpp +++ b/src/plugins/projectexplorer/targetsettingspanel.cpp @@ -111,23 +111,25 @@ void TargetSettingsPanelWidget::setupUi() noTargetLayout->addStretch(10); m_centralWidget->addWidget(m_noTargetLabel); - connect(m_selector, SIGNAL(currentChanged(int,int)), - this, SLOT(currentTargetChanged(int,int))); - - // Save active target now as it will change when targets are added: - Target *activeTarget = m_project->activeTarget(); - foreach (Target *t, m_project->targets()) targetAdded(t); + // Now set the correct target + int index = m_targets.indexOf(m_project->activeTarget()); + m_selector->setCurrentIndex(index); + m_selector->setCurrentSubIndex(0); + + currentTargetChanged(index, 0); + + connect(m_selector, SIGNAL(currentChanged(int,int)), + this, SLOT(currentTargetChanged(int,int))); + connect(m_selector, SIGNAL(addButtonClicked()), this, SLOT(addTarget())); connect(m_selector, SIGNAL(removeButtonClicked()), this, SLOT(removeTarget())); updateTargetAddAndRemoveButtons(); - - activeTargetChanged(activeTarget); } void TargetSettingsPanelWidget::currentTargetChanged(int targetIndex, int subIndex)