Commit 0fa60aa3 authored by dt's avatar dt

Use QFlags<> for QmakeBuildConfig that removes a few casts.

parent 0d648636
......@@ -2171,6 +2171,7 @@ BuildConfigDialog::BuildConfigDialog(Project *project, QWidget *parent)
descriptiveText->setWordWrap(true);
vlayout->addWidget(descriptiveText);
m_configCombo = new QComboBox;
RunConfiguration *activeRun = m_project->activeRunConfiguration();
foreach (BuildConfiguration *config, m_project->buildConfigurations()) {
if (activeRun->isEnabled(config)) {
......
......@@ -361,6 +361,8 @@ void RunConfigurationComboBox::addedRunConfiguration(ProjectExplorer::Project *p
void RunConfigurationComboBox::removedRunConfiguration(ProjectExplorer::Project *p, const QString &name)
{
Q_UNUSED(p)
Q_UNUSED(name)
rebuildTree();
}
......
......@@ -63,7 +63,7 @@ ProjectLoadWizard::ProjectLoadWizard(Qt4Project *project, QWidget *parent, Qt::W
m_temporaryVersion = true;
}
QPair<QtVersion::QmakeBuildConfig, QStringList> result =
QPair<QtVersion::QmakeBuildConfigs, QStringList> result =
QtVersionManager::scanMakeFile(directory, m_importVersion->defaultBuildConfig());
m_importBuildConfig = result.first;
m_additionalArguments = Qt4Project::removeSpecFromArgumentList(result.second);
......@@ -126,11 +126,11 @@ void ProjectLoadWizard::done(int result)
if (m_importBuildConfig & QtVersion::BuildAll) {
// Also create the other configuration
QtVersion::QmakeBuildConfig otherBuildConfiguration = m_importBuildConfig;
QtVersion::QmakeBuildConfigs otherBuildConfiguration = m_importBuildConfig;
if (debug)
otherBuildConfiguration = QtVersion::QmakeBuildConfig(otherBuildConfiguration & ~ QtVersion::DebugBuild);
otherBuildConfiguration = otherBuildConfiguration & ~ QtVersion::DebugBuild;
else
otherBuildConfiguration = QtVersion::QmakeBuildConfig(otherBuildConfiguration | QtVersion::DebugBuild);
otherBuildConfiguration = otherBuildConfiguration | QtVersion::DebugBuild;
m_project->addQt4BuildConfiguration(debug ? "Release" : "Debug", m_importVersion, otherBuildConfiguration, m_additionalArguments);
}
......@@ -144,7 +144,7 @@ void ProjectLoadWizard::done(int result)
if (defaultVersion && defaultVersion->isValid() && (defaultVersion->defaultBuildConfig() & QtVersion::BuildAll))
buildAll = true;
if (buildAll) {
m_project->addQt4BuildConfiguration("Debug", 0, QtVersion::QmakeBuildConfig(QtVersion::BuildAll | QtVersion::DebugBuild), m_additionalArguments);
m_project->addQt4BuildConfiguration("Debug", 0, QtVersion::BuildAll | QtVersion::DebugBuild, m_additionalArguments);
m_project->addQt4BuildConfiguration("Release", 0, QtVersion::BuildAll, m_additionalArguments);
} else {
m_project->addQt4BuildConfiguration("Debug", 0, QtVersion::DebugBuild, m_additionalArguments);
......@@ -162,7 +162,7 @@ int ProjectLoadWizard::nextId() const
return -1;
}
void ProjectLoadWizard::setupImportPage(QtVersion *version, QtVersion::QmakeBuildConfig buildConfig, QStringList addtionalArguments)
void ProjectLoadWizard::setupImportPage(QtVersion *version, QtVersion::QmakeBuildConfigs buildConfig, QStringList addtionalArguments)
{
resize(605, 490);
// Import Page
......
......@@ -57,13 +57,13 @@ public:
void execDialog();
private:
void setupImportPage(QtVersion *version, QtVersion::QmakeBuildConfig buildConfig, QStringList addtionalArguments);
void setupImportPage(QtVersion *version, QtVersion::QmakeBuildConfigs buildConfig, QStringList addtionalArguments);
Qt4Project *m_project;
// Only used for imported stuff
QtVersion *m_importVersion;
QtVersion::QmakeBuildConfig m_importBuildConfig;
QtVersion::QmakeBuildConfigs m_importBuildConfig;
QStringList m_additionalArguments;
// Those that we might add
bool m_temporaryVersion;
......
......@@ -77,8 +77,8 @@ QStringList QMakeStep::arguments(const QString &buildConfiguration)
if (bc->value("buildConfiguration").isValid()) {
QStringList configarguments;
QtVersion::QmakeBuildConfig defaultBuildConfiguration = m_pro->qtVersion(bc)->defaultBuildConfig();
QtVersion::QmakeBuildConfig projectBuildConfiguration = QtVersion::QmakeBuildConfig(bc->value("buildConfiguration").toInt());
QtVersion::QmakeBuildConfigs defaultBuildConfiguration = m_pro->qtVersion(bc)->defaultBuildConfig();
QtVersion::QmakeBuildConfigs projectBuildConfiguration = QtVersion::QmakeBuildConfig(bc->value("buildConfiguration").toInt());
if ((defaultBuildConfiguration & QtVersion::BuildAll) && !(projectBuildConfiguration & QtVersion::BuildAll))
configarguments << "CONFIG-=debug_and_release";
if (!(defaultBuildConfiguration & QtVersion::BuildAll) && (projectBuildConfiguration & QtVersion::BuildAll))
......@@ -271,12 +271,12 @@ void QMakeStepConfigWidget::qmakeArgumentsLineEditTextEdited()
void QMakeStepConfigWidget::buildConfigurationChanged()
{
ProjectExplorer::BuildConfiguration *bc = m_step->project()->buildConfiguration(m_buildConfiguration);
QtVersion::QmakeBuildConfig buildConfiguration = QtVersion::QmakeBuildConfig(bc->value("buildConfiguration").toInt());
QtVersion::QmakeBuildConfigs buildConfiguration = QtVersion::QmakeBuildConfig(bc->value("buildConfiguration").toInt());
if (m_ui.buildConfigurationComboBox->currentIndex() == 0) {
// debug
buildConfiguration = QtVersion::QmakeBuildConfig(buildConfiguration | QtVersion::DebugBuild);
buildConfiguration = buildConfiguration | QtVersion::DebugBuild;
} else {
buildConfiguration = QtVersion::QmakeBuildConfig(buildConfiguration & ~QtVersion::DebugBuild);
buildConfiguration = buildConfiguration & ~QtVersion::DebugBuild;
}
bc->setValue("buildConfiguration", int(buildConfiguration));
static_cast<Qt4Project *>(m_step->project())->invalidateCachedTargetInformation();
......
......@@ -272,9 +272,9 @@ void S60DeviceRunConfiguration::updateTarget()
reader->setQtVersion(qtVersion);
// Find out what flags we pass on to qmake, this code is duplicated in the qmake step
QtVersion::QmakeBuildConfig defaultBuildConfiguration = qtVersion->defaultBuildConfig();
QtVersion::QmakeBuildConfig projectBuildConfiguration = QtVersion::QmakeBuildConfig(pro->activeBuildConfiguration()
->value("buildConfiguration").toInt());
QtVersion::QmakeBuildConfigs defaultBuildConfiguration = qtVersion->defaultBuildConfig();
QtVersion::QmakeBuildConfigs projectBuildConfiguration = pro->activeBuildConfiguration()
->value("buildConfiguration").toInt();
QStringList addedUserConfigArguments;
QStringList removedUserConfigArguments;
if ((defaultBuildConfiguration & QtVersion::BuildAll) && !(projectBuildConfiguration & QtVersion::BuildAll))
......
......@@ -127,8 +127,8 @@ void S60EmulatorRunConfiguration::updateTarget()
reader->setQtVersion(qtVersion);
// Find out what flags we pass on to qmake, this code is duplicated in the qmake step
QtVersion::QmakeBuildConfig defaultBuildConfiguration = qtVersion->defaultBuildConfig();
QtVersion::QmakeBuildConfig projectBuildConfiguration = QtVersion::QmakeBuildConfig(pro->activeBuildConfiguration()
QtVersion::QmakeBuildConfigs defaultBuildConfiguration = qtVersion->defaultBuildConfig();
QtVersion::QmakeBuildConfigs projectBuildConfiguration = QtVersion::QmakeBuildConfig(pro->activeBuildConfiguration()
->value("buildConfiguration").toInt());
QStringList addedUserConfigArguments;
QStringList removedUserConfigArguments;
......
......@@ -289,10 +289,10 @@ bool Qt4BuildConfigurationFactory::create(const QString &type) const
m_project->addQt4BuildConfiguration(tr("%1 Debug").arg(buildConfigurationName),
version,
(QtVersion::QmakeBuildConfig)(version->defaultBuildConfig() | QtVersion::DebugBuild));
(version->defaultBuildConfig() | QtVersion::DebugBuild));
m_project->addQt4BuildConfiguration(tr("%1 Release").arg(buildConfigurationName),
version,
(QtVersion::QmakeBuildConfig)(version->defaultBuildConfig() & ~QtVersion::DebugBuild));
(version->defaultBuildConfig() & ~QtVersion::DebugBuild));
return true;
}
......@@ -437,7 +437,7 @@ ProjectExplorer::IBuildConfigurationFactory *Qt4Project::buildConfigurationFacto
}
void Qt4Project::addQt4BuildConfiguration(QString buildConfigurationName, QtVersion *qtversion,
QtVersion::QmakeBuildConfig qmakeBuildConfiguration,
QtVersion::QmakeBuildConfigs qmakeBuildConfiguration,
QStringList additionalArguments)
{
QMakeStep *qmake = qmakeStep();
......@@ -851,7 +851,7 @@ void Qt4Project::addDefaultBuild()
bc->setValue("buildConfiguration", v);
} else if (!bc->value("buildConfiguration").isValid()) {
if (QtVersion *version = qtVersion(bc))
bc->setValue("buildConfiguration", version->defaultBuildConfig());
bc->setValue("buildConfiguration", int(version->defaultBuildConfig()));
else
bc->setValue("buildConfiguration", int(QtVersion::BuildAll & QtVersion::DebugBuild));
}
......@@ -1299,7 +1299,7 @@ bool Qt4Project::compareBuildConfigurationToImportFrom(BuildConfiguration *confi
QtVersion *version = qtVersion(configuration);
if (version->qmakeCommand() == qmakePath) {
// same qtversion
QPair<QtVersion::QmakeBuildConfig, QStringList> result =
QPair<QtVersion::QmakeBuildConfigs, QStringList> result =
QtVersionManager::scanMakeFile(workingDirectory, version->defaultBuildConfig());
if (QtVersion::QmakeBuildConfig(configuration->value("buildConfiguration").toInt()) == result.first) {
// The QMake Build Configuration are the same,
......
......@@ -163,7 +163,7 @@ public:
void addQt4BuildConfiguration(QString buildConfigurationName,
QtVersion *qtversion,
QtVersion::QmakeBuildConfig qmakeBuildConfiguration,
QtVersion::QmakeBuildConfigs qmakeBuildConfiguration,
QStringList additionalArguments = QStringList());
QList<Core::IFile *> dependencies(); //NBS remove
......
......@@ -285,9 +285,9 @@ void Qt4ProjectConfigWidget::importLabelClicked()
vm->addVersion(version);
}
QPair<QtVersion::QmakeBuildConfig, QStringList> result =
QPair<QtVersion::QmakeBuildConfigs, QStringList> result =
QtVersionManager::scanMakeFile(directory, version->defaultBuildConfig());
QtVersion::QmakeBuildConfig qmakeBuildConfig = result.first;
QtVersion::QmakeBuildConfigs qmakeBuildConfig = result.first;
QStringList additionalArguments = Qt4Project::removeSpecFromArgumentList(result.second);
QString parsedSpec = Qt4Project::extractSpecFromArgumentList(result.second, directory, version);
QString versionSpec = version->mkspec();
......
......@@ -568,8 +568,8 @@ void Qt4RunConfiguration::updateTarget()
reader->setQtVersion(pro->qtVersion(pro->activeBuildConfiguration()));
// Find out what flags we pass on to qmake, this code is duplicated in the qmake step
QtVersion::QmakeBuildConfig defaultBuildConfiguration = pro->qtVersion(pro->activeBuildConfiguration())->defaultBuildConfig();
QtVersion::QmakeBuildConfig projectBuildConfiguration = QtVersion::QmakeBuildConfig(pro->activeBuildConfiguration()->value("buildConfiguration").toInt());
QtVersion::QmakeBuildConfigs defaultBuildConfiguration = pro->qtVersion(pro->activeBuildConfiguration())->defaultBuildConfig();
QtVersion::QmakeBuildConfigs projectBuildConfiguration = QtVersion::QmakeBuildConfig(pro->activeBuildConfiguration()->value("buildConfiguration").toInt());
QStringList addedUserConfigArguments;
QStringList removedUserConfigArguments;
if ((defaultBuildConfiguration & QtVersion::BuildAll) && !(projectBuildConfiguration & QtVersion::BuildAll))
......
......@@ -671,11 +671,11 @@ void dumpQMakeAssignments(const QList<QMakeAssignment> &list)
}
}
QPair<QtVersion::QmakeBuildConfig, QStringList> QtVersionManager::scanMakeFile(const QString &directory, QtVersion::QmakeBuildConfig defaultBuildConfig)
QPair<QtVersion::QmakeBuildConfigs, QStringList> QtVersionManager::scanMakeFile(const QString &directory, QtVersion::QmakeBuildConfigs defaultBuildConfig)
{
if (debug)
qDebug()<<"ScanMakeFile, the gory details:";
QtVersion::QmakeBuildConfig result = QtVersion::NoBuild;
QtVersion::QmakeBuildConfigs result = QtVersion::NoBuild;
QStringList result2;
QString line = findQMakeLine(directory);
......@@ -829,9 +829,9 @@ void QtVersionManager::parseParts(const QStringList &parts, QList<QMakeAssignmen
}
/// This function extracts all the CONFIG+=debug, CONFIG+=release
QtVersion::QmakeBuildConfig QtVersionManager::qmakeBuildConfigFromCmdArgs(QList<QMakeAssignment> *assignments, QtVersion::QmakeBuildConfig defaultBuildConfig)
QtVersion::QmakeBuildConfigs QtVersionManager::qmakeBuildConfigFromCmdArgs(QList<QMakeAssignment> *assignments, QtVersion::QmakeBuildConfigs defaultBuildConfig)
{
QtVersion::QmakeBuildConfig result = defaultBuildConfig;
QtVersion::QmakeBuildConfigs result = defaultBuildConfig;
QList<QMakeAssignment> oldAssignments = *assignments;
assignments->clear();
foreach(QMakeAssignment qa, oldAssignments) {
......@@ -841,19 +841,19 @@ QtVersion::QmakeBuildConfig QtVersionManager::qmakeBuildConfigFromCmdArgs(QList<
foreach(const QString &value, values) {
if (value == "debug") {
if (qa.op == "+=")
result = QtVersion::QmakeBuildConfig(result | QtVersion::DebugBuild);
result = result | QtVersion::DebugBuild;
else
result = QtVersion::QmakeBuildConfig(result & ~QtVersion::DebugBuild);
result = result & ~QtVersion::DebugBuild;
} else if (value == "release") {
if (qa.op == "+=")
result = QtVersion::QmakeBuildConfig(result & ~QtVersion::DebugBuild);
result = result & ~QtVersion::DebugBuild;
else
result = QtVersion::QmakeBuildConfig(result | QtVersion::DebugBuild);
result = result | QtVersion::DebugBuild;
} else if (value == "debug_and_release") {
if (qa.op == "+=")
result = QtVersion::QmakeBuildConfig(result | QtVersion::BuildAll);
result = result | QtVersion::BuildAll;
else
result = QtVersion::QmakeBuildConfig(result & ~QtVersion::BuildAll);
result = result & ~QtVersion::BuildAll;
} else {
newValues.append(value);
}
......@@ -1294,14 +1294,15 @@ bool QtVersion::isValid() const
|| name() == QString::null) && !m_notInstalled);
}
QtVersion::QmakeBuildConfig QtVersion::defaultBuildConfig() const
QtVersion::QmakeBuildConfigs QtVersion::defaultBuildConfig() const
{
updateToolChainAndMkspec();
QtVersion::QmakeBuildConfig result = QtVersion::QmakeBuildConfig(0);
QtVersion::QmakeBuildConfigs result = QtVersion::QmakeBuildConfig(0);
if (m_defaultConfigIsDebugAndRelease)
result = QtVersion::BuildAll;
if (m_defaultConfigIsDebug)
result = QtVersion::QmakeBuildConfig(result | QtVersion::DebugBuild);
result = result | QtVersion::DebugBuild;
return result;
}
......
......@@ -132,10 +132,10 @@ public:
BuildAll = 8
};
QmakeBuildConfig defaultBuildConfig() const;
Q_DECLARE_FLAGS(QmakeBuildConfigs, QmakeBuildConfig)
QmakeBuildConfigs defaultBuildConfig() const;
QString toHtml() const;
private:
QList<QSharedPointer<ProjectExplorer::ToolChain> > toolChains() const;
static int getUniqueId();
......@@ -178,6 +178,8 @@ private:
mutable QString m_linguistCommand;
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QtVersion::QmakeBuildConfigs)
struct QMakeAssignment
{
QString variable;
......@@ -207,7 +209,7 @@ public:
void removeVersion(QtVersion *version);
// Static Methods
static QPair<QtVersion::QmakeBuildConfig, QStringList> scanMakeFile(const QString &directory, QtVersion::QmakeBuildConfig defaultBuildConfig);
static QPair<QtVersion::QmakeBuildConfigs, QStringList> scanMakeFile(const QString &directory, QtVersion::QmakeBuildConfigs defaultBuildConfig);
static QString findQMakeBinaryFromMakefile(const QString &directory);
signals:
void defaultQtVersionChanged();
......@@ -221,7 +223,7 @@ private:
static QString trimLine(const QString line);
static QStringList splitLine(const QString &line);
static void parseParts(const QStringList &parts, QList<QMakeAssignment> *assignments, QList<QMakeAssignment> *afterAssignments, QStringList *additionalArguments);
static QtVersion::QmakeBuildConfig qmakeBuildConfigFromCmdArgs(QList<QMakeAssignment> *assignments, QtVersion::QmakeBuildConfig defaultBuildConfig);
static QtVersion::QmakeBuildConfigs qmakeBuildConfigFromCmdArgs(QList<QMakeAssignment> *assignments, QtVersion::QmakeBuildConfigs defaultBuildConfig);
// Used by QtOptionsPage
void setNewQtVersions(QList<QtVersion *> newVersions, int newDefaultVersion);
// Used by QtVersion
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment