summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Hunger <tobias.hunger@digia.com>2013-11-04 15:44:40 +0100
committerTobias Hunger <tobias.hunger@digia.com>2013-11-12 15:38:20 +0100
commita6c825449baf46ba12f77dff9eb37dc978096a81 (patch)
tree9772b0398a1c4f12b2d517305971b0be1db3a6b3
parentbdf38d90b051e94db33354f9192dfee9165712e2 (diff)
downloadqt-creator-a6c825449baf46ba12f77dff9eb37dc978096a81.tar.gz
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 <daniel.teske@digia.com>
-rw-r--r--src/plugins/projectexplorer/abiwidget.cpp46
-rw-r--r--src/plugins/projectexplorer/abiwidget.h1
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<int>(Abi::UnknownArchitecture); ++i)
d->m_architectureComboBox->addItem(Abi::toString(static_cast<Abi::Architecture>(i)), i);
d->m_architectureComboBox->setCurrentIndex(static_cast<int>(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<int>(Abi::UnknownFormat); ++i)
d->m_binaryFormatComboBox->addItem(Abi::toString(static_cast<Abi::BinaryFormat>(i)), i);
d->m_binaryFormatComboBox->setCurrentIndex(static_cast<int>(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<Abi> &abiList, const Abi &current)
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<Abi> &abiList, const Abi &current)
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<Abi::Architecture>(d->m_architectureComboBox->currentIndex()),
- static_cast<Abi::OS>(d->m_osComboBox->currentIndex()),
- static_cast<Abi::OSFlavor>(d->m_osFlavorComboBox->itemData(d->m_osFlavorComboBox->currentIndex()).toInt()),
- static_cast<Abi::BinaryFormat>(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<int>(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<Abi::Architecture>(d->m_architectureComboBox->currentIndex()),
+ static_cast<Abi::OS>(d->m_osComboBox->currentIndex()),
+ static_cast<Abi::OSFlavor>(d->m_osFlavorComboBox->itemData(d->m_osFlavorComboBox->currentIndex()).toInt()),
+ static_cast<Abi::BinaryFormat>(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 &current)
{
+ bool blocked = blockSignals(true);
d->m_architectureComboBox->setCurrentIndex(static_cast<int>(current.architecture()));
d->m_osComboBox->setCurrentIndex(static_cast<int>(current.os()));
osChanged();
@@ -230,6 +238,10 @@ void AbiWidget::setCustomAbi(const Abi &current)
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);