2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2011-05-24 14:06:51 +00:00
|
|
|
**
|
2013-01-28 17:12:19 +01:00
|
|
|
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
2012-10-02 09:12:39 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
2011-05-24 14:06:51 +00:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2011-05-24 14:06:51 +00:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Digia. For licensing terms and
|
|
|
|
|
** conditions see http://qt.digia.com/licensing. For further information
|
|
|
|
|
** use the contact form at http://qt.digia.com/contact-us.
|
2011-05-24 14:06:51 +00:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
|
|
|
** General Public License version 2.1 as published by the Free Software
|
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
|
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2011-05-24 14:06:51 +00:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** In addition, as a special exception, Digia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
2011-05-24 14:06:51 +00:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2011-05-24 14:06:51 +00:00
|
|
|
|
|
|
|
|
#include "abiwidget.h"
|
2011-08-18 13:46:52 +02:00
|
|
|
#include "abi.h"
|
2011-05-24 14:06:51 +00:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QComboBox>
|
|
|
|
|
#include <QHBoxLayout>
|
|
|
|
|
#include <QLabel>
|
2011-05-24 14:06:51 +00:00
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
\class ProjectExplorer::AbiWidget
|
|
|
|
|
|
2013-06-05 14:29:24 +02:00
|
|
|
\brief The AbiWidget class is a widget to set an ABI.
|
2011-05-24 14:06:51 +00:00
|
|
|
|
|
|
|
|
\sa ProjectExplorer::Abi
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
namespace ProjectExplorer {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
// AbiWidgetPrivate:
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
class AbiWidgetPrivate
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QComboBox *m_abi;
|
|
|
|
|
|
|
|
|
|
QComboBox *m_architectureComboBox;
|
|
|
|
|
QComboBox *m_osComboBox;
|
|
|
|
|
QComboBox *m_osFlavorComboBox;
|
|
|
|
|
QComboBox *m_binaryFormatComboBox;
|
|
|
|
|
QComboBox *m_wordWidthComboBox;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
// AbiWidget
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
AbiWidget::AbiWidget(QWidget *parent) :
|
|
|
|
|
QWidget(parent),
|
|
|
|
|
d(new Internal::AbiWidgetPrivate)
|
|
|
|
|
{
|
|
|
|
|
QHBoxLayout *layout = new QHBoxLayout(this);
|
|
|
|
|
layout->setMargin(0);
|
|
|
|
|
layout->setSpacing(2);
|
|
|
|
|
|
|
|
|
|
d->m_abi = new QComboBox(this);
|
|
|
|
|
layout->addWidget(d->m_abi);
|
|
|
|
|
connect(d->m_abi, SIGNAL(currentIndexChanged(int)), this, SLOT(modeChanged()));
|
|
|
|
|
|
|
|
|
|
d->m_architectureComboBox = new QComboBox(this);
|
|
|
|
|
layout->addWidget(d->m_architectureComboBox);
|
|
|
|
|
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));
|
2013-11-04 15:44:40 +01:00
|
|
|
connect(d->m_architectureComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(customAbiChanged()));
|
2011-05-24 14:06:51 +00:00
|
|
|
|
|
|
|
|
QLabel *separator1 = new QLabel(this);
|
|
|
|
|
separator1->setText(QLatin1String("-"));
|
2013-10-16 16:22:11 +02:00
|
|
|
separator1->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
2011-05-24 14:06:51 +00:00
|
|
|
layout->addWidget(separator1);
|
|
|
|
|
|
|
|
|
|
d->m_osComboBox = new QComboBox(this);
|
|
|
|
|
layout->addWidget(d->m_osComboBox);
|
|
|
|
|
for (int i = 0; i <= static_cast<int>(Abi::UnknownOS); ++i)
|
|
|
|
|
d->m_osComboBox->addItem(Abi::toString(static_cast<Abi::OS>(i)), i);
|
|
|
|
|
d->m_osComboBox->setCurrentIndex(static_cast<int>(Abi::UnknownOS));
|
|
|
|
|
connect(d->m_osComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(osChanged()));
|
|
|
|
|
|
|
|
|
|
QLabel *separator2 = new QLabel(this);
|
|
|
|
|
separator2->setText(QLatin1String("-"));
|
2013-10-16 16:22:11 +02:00
|
|
|
separator2->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
2011-05-24 14:06:51 +00:00
|
|
|
layout->addWidget(separator2);
|
|
|
|
|
|
|
|
|
|
d->m_osFlavorComboBox = new QComboBox(this);
|
|
|
|
|
layout->addWidget(d->m_osFlavorComboBox);
|
2013-11-04 15:44:40 +01:00
|
|
|
connect(d->m_osFlavorComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(customAbiChanged()));
|
2011-05-24 14:06:51 +00:00
|
|
|
|
|
|
|
|
QLabel *separator3 = new QLabel(this);
|
|
|
|
|
separator3->setText(QLatin1String("-"));
|
2013-10-16 16:22:11 +02:00
|
|
|
separator3->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
2011-05-24 14:06:51 +00:00
|
|
|
layout->addWidget(separator3);
|
|
|
|
|
|
|
|
|
|
d->m_binaryFormatComboBox = new QComboBox(this);
|
|
|
|
|
layout->addWidget(d->m_binaryFormatComboBox);
|
|
|
|
|
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));
|
2013-11-04 15:44:40 +01:00
|
|
|
connect(d->m_binaryFormatComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(customAbiChanged()));
|
2011-05-24 14:06:51 +00:00
|
|
|
|
|
|
|
|
QLabel *separator4 = new QLabel(this);
|
|
|
|
|
separator4->setText(QLatin1String("-"));
|
2013-10-16 16:22:11 +02:00
|
|
|
separator4->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
2011-05-24 14:06:51 +00:00
|
|
|
layout->addWidget(separator4);
|
|
|
|
|
|
|
|
|
|
d->m_wordWidthComboBox = new QComboBox(this);
|
|
|
|
|
layout->addWidget(d->m_wordWidthComboBox);
|
|
|
|
|
|
|
|
|
|
d->m_wordWidthComboBox->addItem(Abi::toString(32), 32);
|
|
|
|
|
d->m_wordWidthComboBox->addItem(Abi::toString(64), 64);
|
|
|
|
|
d->m_wordWidthComboBox->addItem(Abi::toString(0), 0);
|
|
|
|
|
d->m_wordWidthComboBox->setCurrentIndex(2);
|
2013-11-04 15:44:40 +01:00
|
|
|
connect(d->m_wordWidthComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(customAbiChanged()));
|
2011-05-24 14:06:51 +00:00
|
|
|
|
|
|
|
|
layout->setStretchFactor(d->m_abi, 1);
|
|
|
|
|
|
|
|
|
|
setAbis(QList<Abi>(), Abi::hostAbi());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AbiWidget::~AbiWidget()
|
|
|
|
|
{
|
|
|
|
|
delete d;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AbiWidget::setAbis(const QList<Abi> &abiList, const Abi ¤t)
|
|
|
|
|
{
|
2013-11-04 15:30:56 +01:00
|
|
|
bool blocked = blockSignals(true);
|
2011-05-24 14:06:51 +00:00
|
|
|
d->m_abi->clear();
|
|
|
|
|
|
|
|
|
|
d->m_abi->addItem(tr("<custom>"), QLatin1String("custom"));
|
|
|
|
|
d->m_abi->setCurrentIndex(0);
|
2011-07-11 09:38:16 +00:00
|
|
|
|
2011-05-24 14:06:51 +00:00
|
|
|
for (int i = 0; i < abiList.count(); ++i) {
|
2013-11-04 15:44:40 +01:00
|
|
|
int index = i + 1;
|
2011-05-24 14:06:51 +00:00
|
|
|
const QString abiString = abiList.at(i).toString();
|
2013-11-04 15:44:40 +01:00
|
|
|
d->m_abi->insertItem(index, abiString, abiString);
|
2011-05-24 14:06:51 +00:00
|
|
|
if (abiList.at(i) == current)
|
2013-11-04 15:44:40 +01:00
|
|
|
d->m_abi->setCurrentIndex(index);
|
2011-05-24 14:06:51 +00:00
|
|
|
}
|
|
|
|
|
|
2013-01-08 21:49:43 +02:00
|
|
|
d->m_abi->setVisible(!abiList.isEmpty());
|
2011-05-24 14:06:51 +00:00
|
|
|
if (d->m_abi->currentIndex() == 0) {
|
2011-07-11 09:38:16 +00:00
|
|
|
if (!current.isValid() && !abiList.isEmpty())
|
2011-06-08 15:39:14 +00:00
|
|
|
d->m_abi->setCurrentIndex(1); // default to the first Abi if none is selected.
|
2011-07-11 09:38:16 +00:00
|
|
|
else
|
|
|
|
|
setCustomAbi(current);
|
2011-05-24 14:06:51 +00:00
|
|
|
}
|
2011-07-11 09:38:16 +00:00
|
|
|
modeChanged();
|
2011-05-24 14:06:51 +00:00
|
|
|
|
2013-11-04 15:30:56 +01:00
|
|
|
blockSignals(blocked);
|
2011-05-24 14:06:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Abi AbiWidget::currentAbi() const
|
|
|
|
|
{
|
2013-11-04 15:44:40 +01:00
|
|
|
return Abi(d->m_abi->itemData(d->m_abi->currentIndex()).toString());
|
2011-05-24 14:06:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AbiWidget::osChanged()
|
|
|
|
|
{
|
2013-11-04 15:30:56 +01:00
|
|
|
bool blocked = d->m_osFlavorComboBox->blockSignals(true);
|
2011-05-24 14:06:51 +00:00
|
|
|
d->m_osFlavorComboBox->clear();
|
|
|
|
|
Abi::OS os = static_cast<Abi::OS>(d->m_osComboBox->itemData(d->m_osComboBox->currentIndex()).toInt());
|
|
|
|
|
QList<Abi::OSFlavor> flavors = Abi::flavorsForOs(os);
|
|
|
|
|
foreach (Abi::OSFlavor f, flavors)
|
|
|
|
|
d->m_osFlavorComboBox->addItem(Abi::toString(f), static_cast<int>(f));
|
|
|
|
|
d->m_osFlavorComboBox->setCurrentIndex(0); // default to generic flavor
|
2013-11-04 15:30:56 +01:00
|
|
|
d->m_osFlavorComboBox->blockSignals(blocked);
|
2013-11-04 15:44:40 +01:00
|
|
|
customAbiChanged();
|
2011-05-24 14:06:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AbiWidget::modeChanged()
|
|
|
|
|
{
|
|
|
|
|
const bool customMode = (d->m_abi->currentIndex() == 0);
|
|
|
|
|
d->m_architectureComboBox->setEnabled(customMode);
|
|
|
|
|
d->m_osComboBox->setEnabled(customMode);
|
|
|
|
|
d->m_osFlavorComboBox->setEnabled(customMode);
|
|
|
|
|
d->m_binaryFormatComboBox->setEnabled(customMode);
|
|
|
|
|
d->m_wordWidthComboBox->setEnabled(customMode);
|
2011-07-11 09:38:16 +00:00
|
|
|
|
|
|
|
|
if (!customMode) {
|
|
|
|
|
Abi current(d->m_abi->itemData(d->m_abi->currentIndex()).toString());
|
|
|
|
|
setCustomAbi(current);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 15:44:40 +01:00
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-11 09:38:16 +00:00
|
|
|
void AbiWidget::setCustomAbi(const Abi ¤t)
|
|
|
|
|
{
|
2013-11-04 15:44:40 +01:00
|
|
|
bool blocked = blockSignals(true);
|
2011-07-11 09:38:16 +00:00
|
|
|
d->m_architectureComboBox->setCurrentIndex(static_cast<int>(current.architecture()));
|
|
|
|
|
d->m_osComboBox->setCurrentIndex(static_cast<int>(current.os()));
|
|
|
|
|
osChanged();
|
|
|
|
|
for (int i = 0; i < d->m_osFlavorComboBox->count(); ++i) {
|
|
|
|
|
if (d->m_osFlavorComboBox->itemData(i).toInt() == current.osFlavor()) {
|
|
|
|
|
d->m_osFlavorComboBox->setCurrentIndex(i);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
d->m_binaryFormatComboBox->setCurrentIndex(static_cast<int>(current.binaryFormat()));
|
|
|
|
|
for (int i = 0; i < d->m_wordWidthComboBox->count(); ++i) {
|
|
|
|
|
if (d->m_wordWidthComboBox->itemData(i).toInt() == current.wordWidth()) {
|
|
|
|
|
d->m_wordWidthComboBox->setCurrentIndex(i);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-11-04 15:44:40 +01:00
|
|
|
d->m_abi->setItemData(0, current.toString());
|
|
|
|
|
blockSignals(blocked);
|
|
|
|
|
|
|
|
|
|
emit abiChanged();
|
2011-05-24 14:06:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace ProjectExplorer
|