From a6c825449baf46ba12f77dff9eb37dc978096a81 Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Mon, 4 Nov 2013 15:44:40 +0100 Subject: AbiWidget: Store the Abi in the combobox item data This simplifies the retrieval of the ABI a bit at the cost of making the handling of custom ABIs more tricky. The good thing as that we used to loose the custom ABI settings when we switched to a pre-defined ABI and that is no longer the case. Change-Id: I0ac38c3da221acbbdeebc82121ca0d5387ebc04d Reviewed-by: Daniel Teske --- src/plugins/projectexplorer/abiwidget.cpp | 46 +++++++++++++++++++------------ src/plugins/projectexplorer/abiwidget.h | 1 + 2 files changed, 30 insertions(+), 17 deletions(-) diff --git a/src/plugins/projectexplorer/abiwidget.cpp b/src/plugins/projectexplorer/abiwidget.cpp index ed2f8926dd..7fa8f432cb 100644 --- a/src/plugins/projectexplorer/abiwidget.cpp +++ b/src/plugins/projectexplorer/abiwidget.cpp @@ -84,7 +84,7 @@ AbiWidget::AbiWidget(QWidget *parent) : for (int i = 0; i <= static_cast(Abi::UnknownArchitecture); ++i) d->m_architectureComboBox->addItem(Abi::toString(static_cast(i)), i); d->m_architectureComboBox->setCurrentIndex(static_cast(Abi::UnknownArchitecture)); - connect(d->m_architectureComboBox, SIGNAL(currentIndexChanged(int)), this, SIGNAL(abiChanged())); + connect(d->m_architectureComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(customAbiChanged())); QLabel *separator1 = new QLabel(this); separator1->setText(QLatin1String("-")); @@ -105,8 +105,7 @@ AbiWidget::AbiWidget(QWidget *parent) : d->m_osFlavorComboBox = new QComboBox(this); layout->addWidget(d->m_osFlavorComboBox); - osChanged(); - connect(d->m_osFlavorComboBox, SIGNAL(currentIndexChanged(int)), this, SIGNAL(abiChanged())); + connect(d->m_osFlavorComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(customAbiChanged())); QLabel *separator3 = new QLabel(this); separator3->setText(QLatin1String("-")); @@ -118,7 +117,7 @@ AbiWidget::AbiWidget(QWidget *parent) : for (int i = 0; i <= static_cast(Abi::UnknownFormat); ++i) d->m_binaryFormatComboBox->addItem(Abi::toString(static_cast(i)), i); d->m_binaryFormatComboBox->setCurrentIndex(static_cast(Abi::UnknownFormat)); - connect(d->m_binaryFormatComboBox, SIGNAL(currentIndexChanged(int)), this, SIGNAL(abiChanged())); + connect(d->m_binaryFormatComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(customAbiChanged())); QLabel *separator4 = new QLabel(this); separator4->setText(QLatin1String("-")); @@ -132,7 +131,7 @@ AbiWidget::AbiWidget(QWidget *parent) : d->m_wordWidthComboBox->addItem(Abi::toString(64), 64); d->m_wordWidthComboBox->addItem(Abi::toString(0), 0); d->m_wordWidthComboBox->setCurrentIndex(2); - connect(d->m_wordWidthComboBox, SIGNAL(currentIndexChanged(int)), this, SIGNAL(abiChanged())); + connect(d->m_wordWidthComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(customAbiChanged())); layout->setStretchFactor(d->m_abi, 1); @@ -153,10 +152,11 @@ void AbiWidget::setAbis(const QList &abiList, const Abi ¤t) d->m_abi->setCurrentIndex(0); for (int i = 0; i < abiList.count(); ++i) { + int index = i + 1; const QString abiString = abiList.at(i).toString(); - d->m_abi->addItem(abiString, abiString); + d->m_abi->insertItem(index, abiString, abiString); if (abiList.at(i) == current) - d->m_abi->setCurrentIndex(i + 1); + d->m_abi->setCurrentIndex(index); } d->m_abi->setVisible(!abiList.isEmpty()); @@ -173,14 +173,7 @@ void AbiWidget::setAbis(const QList &abiList, const Abi ¤t) Abi AbiWidget::currentAbi() const { - if (d->m_abi->currentIndex() > 0) - return Abi(d->m_abi->itemData(d->m_abi->currentIndex()).toString()); - - return Abi(static_cast(d->m_architectureComboBox->currentIndex()), - static_cast(d->m_osComboBox->currentIndex()), - static_cast(d->m_osFlavorComboBox->itemData(d->m_osFlavorComboBox->currentIndex()).toInt()), - static_cast(d->m_binaryFormatComboBox->currentIndex()), - d->m_wordWidthComboBox->itemData(d->m_wordWidthComboBox->currentIndex()).toInt()); + return Abi(d->m_abi->itemData(d->m_abi->currentIndex()).toString()); } void AbiWidget::osChanged() @@ -193,8 +186,7 @@ void AbiWidget::osChanged() d->m_osFlavorComboBox->addItem(Abi::toString(f), static_cast(f)); d->m_osFlavorComboBox->setCurrentIndex(0); // default to generic flavor d->m_osFlavorComboBox->blockSignals(blocked); - - emit abiChanged(); + customAbiChanged(); } void AbiWidget::modeChanged() @@ -212,8 +204,24 @@ void AbiWidget::modeChanged() } } +void AbiWidget::customAbiChanged() +{ + if (signalsBlocked()) + return; + + Abi current(static_cast(d->m_architectureComboBox->currentIndex()), + static_cast(d->m_osComboBox->currentIndex()), + static_cast(d->m_osFlavorComboBox->itemData(d->m_osFlavorComboBox->currentIndex()).toInt()), + static_cast(d->m_binaryFormatComboBox->currentIndex()), + d->m_wordWidthComboBox->itemData(d->m_wordWidthComboBox->currentIndex()).toInt()); + d->m_abi->setItemData(0, current.toString()); + + emit abiChanged(); +} + void AbiWidget::setCustomAbi(const Abi ¤t) { + bool blocked = blockSignals(true); d->m_architectureComboBox->setCurrentIndex(static_cast(current.architecture())); d->m_osComboBox->setCurrentIndex(static_cast(current.os())); osChanged(); @@ -230,6 +238,10 @@ void AbiWidget::setCustomAbi(const Abi ¤t) break; } } + d->m_abi->setItemData(0, current.toString()); + blockSignals(blocked); + + emit abiChanged(); } } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/abiwidget.h b/src/plugins/projectexplorer/abiwidget.h index 0fc3e64387..cf665f1a55 100644 --- a/src/plugins/projectexplorer/abiwidget.h +++ b/src/plugins/projectexplorer/abiwidget.h @@ -62,6 +62,7 @@ signals: private slots: void osChanged(); void modeChanged(); + void customAbiChanged(); private: void setCustomAbi(const Abi &a); -- cgit v1.2.1