From c4ba51ca36e2f37d9c86daafe8487534b140113f Mon Sep 17 00:00:00 2001 From: Tobias Hunger <tobias.hunger@nokia.com> Date: Mon, 11 Jul 2011 09:38:16 +0000 Subject: [PATCH] Abi: Abi widget shows nicer info Fix the abi widget to not show unrelated abis on the disabled custom abi comboboxes. Task-number: QTCREATORBUG-5370 Change-Id: I22360be781159507999c845d2278eac1ef252174 Reviewed-on: http://codereview.qt.nokia.com/1407 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Tobias Hunger <tobias.hunger@nokia.com> --- src/plugins/projectexplorer/abiwidget.cpp | 49 ++++++++++++++--------- src/plugins/projectexplorer/abiwidget.h | 2 + 2 files changed, 32 insertions(+), 19 deletions(-) diff --git a/src/plugins/projectexplorer/abiwidget.cpp b/src/plugins/projectexplorer/abiwidget.cpp index 2be1b9801ad..796b0823f55 100644 --- a/src/plugins/projectexplorer/abiwidget.cpp +++ b/src/plugins/projectexplorer/abiwidget.cpp @@ -151,6 +151,7 @@ void AbiWidget::setAbis(const QList<Abi> &abiList, const Abi ¤t) d->m_abi->addItem(tr("<custom>"), QLatin1String("custom")); d->m_abi->setCurrentIndex(0); + for (int i = 0; i < abiList.count(); ++i) { const QString abiString = abiList.at(i).toString(); d->m_abi->addItem(abiString, abiString); @@ -159,27 +160,12 @@ void AbiWidget::setAbis(const QList<Abi> &abiList, const Abi ¤t) } if (d->m_abi->currentIndex() == 0) { - if (!current.isValid() && !abiList.isEmpty()) { + if (!current.isValid() && !abiList.isEmpty()) d->m_abi->setCurrentIndex(1); // default to the first Abi if none is selected. - } else { - d->m_architectureComboBox->setCurrentIndex(static_cast<int>(current.architecture())); - d->m_osComboBox->setCurrentIndex(static_cast<int>(current.os())); - osChanged(); - for (int i = 0; i < d->m_osFlavorComboBox->count(); ++i) { - if (d->m_osFlavorComboBox->itemData(i).toInt() == current.osFlavor()) { - d->m_osFlavorComboBox->setCurrentIndex(i); - break; - } - } - d->m_binaryFormatComboBox->setCurrentIndex(static_cast<int>(current.binaryFormat())); - for (int i = 0; i < d->m_wordWidthComboBox->count(); ++i) { - if (d->m_wordWidthComboBox->itemData(i).toInt() == current.wordWidth()) { - d->m_wordWidthComboBox->setCurrentIndex(i); - break; - } - } - } + else + setCustomAbi(current); } + modeChanged(); blockSignals(false); } @@ -218,6 +204,31 @@ void AbiWidget::modeChanged() d->m_osFlavorComboBox->setEnabled(customMode); d->m_binaryFormatComboBox->setEnabled(customMode); d->m_wordWidthComboBox->setEnabled(customMode); + + if (!customMode) { + Abi current(d->m_abi->itemData(d->m_abi->currentIndex()).toString()); + setCustomAbi(current); + } +} + +void AbiWidget::setCustomAbi(const Abi ¤t) +{ + d->m_architectureComboBox->setCurrentIndex(static_cast<int>(current.architecture())); + d->m_osComboBox->setCurrentIndex(static_cast<int>(current.os())); + osChanged(); + for (int i = 0; i < d->m_osFlavorComboBox->count(); ++i) { + if (d->m_osFlavorComboBox->itemData(i).toInt() == current.osFlavor()) { + d->m_osFlavorComboBox->setCurrentIndex(i); + break; + } + } + d->m_binaryFormatComboBox->setCurrentIndex(static_cast<int>(current.binaryFormat())); + for (int i = 0; i < d->m_wordWidthComboBox->count(); ++i) { + if (d->m_wordWidthComboBox->itemData(i).toInt() == current.wordWidth()) { + d->m_wordWidthComboBox->setCurrentIndex(i); + break; + } + } } } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/abiwidget.h b/src/plugins/projectexplorer/abiwidget.h index 1b8a9350f01..2ca76e2d8d1 100644 --- a/src/plugins/projectexplorer/abiwidget.h +++ b/src/plugins/projectexplorer/abiwidget.h @@ -68,6 +68,8 @@ private slots: void modeChanged(); private: + void setCustomAbi(const Abi &a); + Internal::AbiWidgetPrivate *const d; }; -- GitLab