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)
|
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->addItem(Abi::toString(static_cast<Abi::Architecture>(i)), i);
|
||||||
d->m_architectureComboBox->setCurrentIndex(static_cast<int>(Abi::UnknownArchitecture));
|
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);
|
QLabel *separator1 = new QLabel(this);
|
||||||
separator1->setText(QLatin1String("-"));
|
separator1->setText(QLatin1String("-"));
|
||||||
@@ -105,8 +105,7 @@ AbiWidget::AbiWidget(QWidget *parent) :
|
|||||||
|
|
||||||
d->m_osFlavorComboBox = new QComboBox(this);
|
d->m_osFlavorComboBox = new QComboBox(this);
|
||||||
layout->addWidget(d->m_osFlavorComboBox);
|
layout->addWidget(d->m_osFlavorComboBox);
|
||||||
osChanged();
|
connect(d->m_osFlavorComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(customAbiChanged()));
|
||||||
connect(d->m_osFlavorComboBox, SIGNAL(currentIndexChanged(int)), this, SIGNAL(abiChanged()));
|
|
||||||
|
|
||||||
QLabel *separator3 = new QLabel(this);
|
QLabel *separator3 = new QLabel(this);
|
||||||
separator3->setText(QLatin1String("-"));
|
separator3->setText(QLatin1String("-"));
|
||||||
@@ -118,7 +117,7 @@ AbiWidget::AbiWidget(QWidget *parent) :
|
|||||||
for (int i = 0; i <= static_cast<int>(Abi::UnknownFormat); ++i)
|
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->addItem(Abi::toString(static_cast<Abi::BinaryFormat>(i)), i);
|
||||||
d->m_binaryFormatComboBox->setCurrentIndex(static_cast<int>(Abi::UnknownFormat));
|
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);
|
QLabel *separator4 = new QLabel(this);
|
||||||
separator4->setText(QLatin1String("-"));
|
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(64), 64);
|
||||||
d->m_wordWidthComboBox->addItem(Abi::toString(0), 0);
|
d->m_wordWidthComboBox->addItem(Abi::toString(0), 0);
|
||||||
d->m_wordWidthComboBox->setCurrentIndex(2);
|
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);
|
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);
|
d->m_abi->setCurrentIndex(0);
|
||||||
|
|
||||||
for (int i = 0; i < abiList.count(); ++i) {
|
for (int i = 0; i < abiList.count(); ++i) {
|
||||||
|
int index = i + 1;
|
||||||
const QString abiString = abiList.at(i).toString();
|
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)
|
if (abiList.at(i) == current)
|
||||||
d->m_abi->setCurrentIndex(i + 1);
|
d->m_abi->setCurrentIndex(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
d->m_abi->setVisible(!abiList.isEmpty());
|
d->m_abi->setVisible(!abiList.isEmpty());
|
||||||
@@ -173,14 +173,7 @@ void AbiWidget::setAbis(const QList<Abi> &abiList, const Abi ¤t)
|
|||||||
|
|
||||||
Abi AbiWidget::currentAbi() const
|
Abi AbiWidget::currentAbi() const
|
||||||
{
|
{
|
||||||
if (d->m_abi->currentIndex() > 0)
|
return Abi(d->m_abi->itemData(d->m_abi->currentIndex()).toString());
|
||||||
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());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AbiWidget::osChanged()
|
void AbiWidget::osChanged()
|
||||||
@@ -193,8 +186,7 @@ void AbiWidget::osChanged()
|
|||||||
d->m_osFlavorComboBox->addItem(Abi::toString(f), static_cast<int>(f));
|
d->m_osFlavorComboBox->addItem(Abi::toString(f), static_cast<int>(f));
|
||||||
d->m_osFlavorComboBox->setCurrentIndex(0); // default to generic flavor
|
d->m_osFlavorComboBox->setCurrentIndex(0); // default to generic flavor
|
||||||
d->m_osFlavorComboBox->blockSignals(blocked);
|
d->m_osFlavorComboBox->blockSignals(blocked);
|
||||||
|
customAbiChanged();
|
||||||
emit abiChanged();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AbiWidget::modeChanged()
|
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)
|
void AbiWidget::setCustomAbi(const Abi ¤t)
|
||||||
{
|
{
|
||||||
|
bool blocked = blockSignals(true);
|
||||||
d->m_architectureComboBox->setCurrentIndex(static_cast<int>(current.architecture()));
|
d->m_architectureComboBox->setCurrentIndex(static_cast<int>(current.architecture()));
|
||||||
d->m_osComboBox->setCurrentIndex(static_cast<int>(current.os()));
|
d->m_osComboBox->setCurrentIndex(static_cast<int>(current.os()));
|
||||||
osChanged();
|
osChanged();
|
||||||
@@ -230,6 +238,10 @@ void AbiWidget::setCustomAbi(const Abi ¤t)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
d->m_abi->setItemData(0, current.toString());
|
||||||
|
blockSignals(blocked);
|
||||||
|
|
||||||
|
emit abiChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace ProjectExplorer
|
} // namespace ProjectExplorer
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ signals:
|
|||||||
private slots:
|
private slots:
|
||||||
void osChanged();
|
void osChanged();
|
||||||
void modeChanged();
|
void modeChanged();
|
||||||
|
void customAbiChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setCustomAbi(const Abi &a);
|
void setCustomAbi(const Abi &a);
|
||||||
|
|||||||
Reference in New Issue
Block a user