forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -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 ¤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<Abi> &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<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 ¤t)
|
||||
{
|
||||
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 ¤t)
|
||||
break;
|
||||
}
|
||||
}
|
||||
d->m_abi->setItemData(0, current.toString());
|
||||
blockSignals(blocked);
|
||||
|
||||
emit abiChanged();
|
||||
}
|
||||
|
||||
} // namespace ProjectExplorer
|
||||
|
||||
Reference in New Issue
Block a user