diff --git a/src/plugins/projectexplorer/abiwidget.cpp b/src/plugins/projectexplorer/abiwidget.cpp index ed2f8926dd0..7fa8f432cbb 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 0fc3e643872..cf665f1a555 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);