forked from qt-creator/qt-creator
Configuration types for each Qt Version.
This commit is contained in:
@@ -81,6 +81,9 @@ public:
|
||||
// restore
|
||||
// clone
|
||||
virtual QList<BuildConfiguration *> createDefaultConfigurations() const = 0;
|
||||
|
||||
signals:
|
||||
void availableCreationTypesChanged();
|
||||
};
|
||||
|
||||
} // namespace ProjectExplorer
|
||||
|
||||
@@ -164,7 +164,9 @@ BuildSettingsWidget::BuildSettingsWidget(Project *project)
|
||||
m_subWidgets = new BuildSettingsSubWidgets(this);
|
||||
vbox->addWidget(m_subWidgets);
|
||||
|
||||
createAddButtonMenu();
|
||||
m_addButtonMenu = new QMenu(this);
|
||||
m_addButton->setMenu(m_addButtonMenu);
|
||||
updateAddButtonMenu();
|
||||
|
||||
m_buildConfiguration = m_project->activeBuildConfiguration()->name();
|
||||
|
||||
@@ -176,23 +178,24 @@ BuildSettingsWidget::BuildSettingsWidget(Project *project)
|
||||
|
||||
connect(m_project, SIGNAL(buildConfigurationDisplayNameChanged(const QString &)),
|
||||
this, SLOT(buildConfigurationDisplayNameChanged(const QString &)));
|
||||
if (m_project->buildConfigurationFactory())
|
||||
connect(m_project->buildConfigurationFactory(), SIGNAL(availableCreationTypesChanged()), SLOT(updateAddButtonMenu()));
|
||||
|
||||
updateBuildSettings();
|
||||
}
|
||||
|
||||
void BuildSettingsWidget::createAddButtonMenu()
|
||||
void BuildSettingsWidget::updateAddButtonMenu()
|
||||
{
|
||||
QMenu *addButtonMenu = new QMenu(this);
|
||||
addButtonMenu->addAction(tr("&Clone Selected"),
|
||||
m_addButtonMenu->clear();
|
||||
m_addButtonMenu->addAction(tr("&Clone Selected"),
|
||||
this, SLOT(cloneConfiguration()));
|
||||
IBuildConfigurationFactory *factory = m_project->buildConfigurationFactory();
|
||||
if (factory) {
|
||||
foreach (const QString &type, factory->availableCreationTypes()) {
|
||||
QAction *action = addButtonMenu->addAction(factory->displayNameForType(type), this, SLOT(createConfiguration()));
|
||||
QAction *action = m_addButtonMenu->addAction(factory->displayNameForType(type), this, SLOT(createConfiguration()));
|
||||
action->setData(type);
|
||||
}
|
||||
}
|
||||
m_addButton->setMenu(addButtonMenu);
|
||||
}
|
||||
|
||||
void BuildSettingsWidget::buildConfigurationDisplayNameChanged(const QString &buildConfiguration)
|
||||
|
||||
@@ -98,11 +98,11 @@ private slots:
|
||||
void createConfiguration();
|
||||
void cloneConfiguration();
|
||||
void deleteConfiguration();
|
||||
void updateAddButtonMenu();
|
||||
|
||||
private:
|
||||
void cloneConfiguration(const QString &toClone);
|
||||
void deleteConfiguration(const QString &toDelete);
|
||||
void createAddButtonMenu();
|
||||
|
||||
Project *m_project;
|
||||
QPushButton *m_addButton;
|
||||
@@ -110,6 +110,7 @@ private:
|
||||
QComboBox *m_buildConfigurationComboBox;
|
||||
BuildSettingsSubWidgets *m_subWidgets;
|
||||
QString m_buildConfiguration;
|
||||
QMenu *m_addButtonMenu;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -68,6 +68,10 @@ using namespace ProjectExplorer;
|
||||
|
||||
enum { debug = 0 };
|
||||
|
||||
namespace {
|
||||
const char * const KEY_QT_VERSION_ID = "QtVersionId";
|
||||
}
|
||||
|
||||
namespace Qt4ProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
@@ -234,25 +238,42 @@ Qt4BuildConfigurationFactory::Qt4BuildConfigurationFactory(Qt4Project *project)
|
||||
: IBuildConfigurationFactory(project),
|
||||
m_project(project)
|
||||
{
|
||||
update();
|
||||
}
|
||||
|
||||
Qt4BuildConfigurationFactory::~Qt4BuildConfigurationFactory()
|
||||
{
|
||||
}
|
||||
|
||||
void Qt4BuildConfigurationFactory::update()
|
||||
{
|
||||
|
||||
m_versions.clear();
|
||||
m_versions.insert(QLatin1String("DefaultQt"), VersionInfo(tr("Using Default Qt Version"), 0));
|
||||
QtVersionManager *vm = QtVersionManager::instance();
|
||||
foreach (const QtVersion *version, vm->versions()) {
|
||||
m_versions.insert(QString::fromLatin1("Qt%1").arg(version->uniqueId()),
|
||||
VersionInfo(tr("Using Qt Version \"%1\"").arg(version->name()), version->uniqueId()));
|
||||
}
|
||||
emit availableCreationTypesChanged();
|
||||
}
|
||||
|
||||
QStringList Qt4BuildConfigurationFactory::availableCreationTypes() const
|
||||
{
|
||||
return QStringList() << "DefaultQt";
|
||||
return m_versions.keys();
|
||||
}
|
||||
|
||||
QString Qt4BuildConfigurationFactory::displayNameForType(const QString &type) const
|
||||
{
|
||||
return tr("Using Default Qt Version");
|
||||
if (m_versions.contains(type))
|
||||
return m_versions.value(type).displayName;
|
||||
return QString();
|
||||
}
|
||||
|
||||
QList<BuildConfiguration *> Qt4BuildConfigurationFactory::create(const QString &type) const
|
||||
{
|
||||
QTC_ASSERT(type == "DefaultQt", return QList<BuildConfiguration*>());
|
||||
QTC_ASSERT(m_versions.contains(type), return QList<BuildConfiguration *>());
|
||||
const VersionInfo &info = m_versions.value(type);
|
||||
bool ok;
|
||||
QString buildConfigurationName = QInputDialog::getText(0,
|
||||
tr("New configuration"),
|
||||
@@ -263,6 +284,7 @@ QList<BuildConfiguration *> Qt4BuildConfigurationFactory::create(const QString &
|
||||
if (!ok || buildConfigurationName.isEmpty())
|
||||
return QList<BuildConfiguration *>();
|
||||
BuildConfiguration *bc = new BuildConfiguration(buildConfigurationName);
|
||||
bc->setValue(KEY_QT_VERSION_ID, info.versionId);
|
||||
return QList<BuildConfiguration *>() << bc;
|
||||
}
|
||||
|
||||
@@ -317,6 +339,7 @@ void Qt4Project::qtVersionsChanged()
|
||||
m_rootProjectNode->update();
|
||||
}
|
||||
}
|
||||
m_buildConfigurationFactory->update();
|
||||
}
|
||||
|
||||
void Qt4Project::updateFileList()
|
||||
@@ -891,13 +914,13 @@ int Qt4Project::qtVersionId(BuildConfiguration *configuration) const
|
||||
if (debug)
|
||||
qDebug()<<"Looking for qtVersion ID of "<<configuration->name();
|
||||
int id = 0;
|
||||
QVariant vid = configuration->value("QtVersionId");
|
||||
QVariant vid = configuration->value(KEY_QT_VERSION_ID);
|
||||
if (vid.isValid()) {
|
||||
id = vid.toInt();
|
||||
if (vm->version(id)->isValid()) {
|
||||
return id;
|
||||
} else {
|
||||
configuration->setValue("QtVersionId", 0);
|
||||
configuration->setValue(KEY_QT_VERSION_ID, 0);
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
@@ -911,7 +934,7 @@ int Qt4Project::qtVersionId(BuildConfiguration *configuration) const
|
||||
if (version->name() == vname) {
|
||||
if (debug)
|
||||
qDebug()<<"found name in versions";
|
||||
configuration->setValue("QtVersionId", version->uniqueId());
|
||||
configuration->setValue(KEY_QT_VERSION_ID, version->uniqueId());
|
||||
return version->uniqueId();
|
||||
}
|
||||
}
|
||||
@@ -920,13 +943,13 @@ int Qt4Project::qtVersionId(BuildConfiguration *configuration) const
|
||||
if (debug)
|
||||
qDebug()<<" using qtversion with id ="<<id;
|
||||
// Nothing found, reset to default
|
||||
configuration->setValue("QtVersionId", id);
|
||||
configuration->setValue(KEY_QT_VERSION_ID, id);
|
||||
return id;
|
||||
}
|
||||
|
||||
void Qt4Project::setQtVersion(BuildConfiguration *configuration, int id)
|
||||
{
|
||||
configuration->setValue("QtVersionId", id);
|
||||
configuration->setValue(KEY_QT_VERSION_ID, id);
|
||||
updateActiveRunConfiguration();
|
||||
}
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
#include <QtCore/QList>
|
||||
#include <QtCore/QStringList>
|
||||
#include <QtCore/QPointer>
|
||||
#include <QtCore/QMap>
|
||||
#include <QtGui/QDirModel>
|
||||
#include "qtextended_integration.h"
|
||||
|
||||
@@ -131,8 +132,19 @@ public:
|
||||
QList<ProjectExplorer::BuildConfiguration *> create(const QString &type) const;
|
||||
QList<ProjectExplorer::BuildConfiguration *> createDefaultConfigurations() const;
|
||||
|
||||
void update();
|
||||
|
||||
private:
|
||||
struct VersionInfo {
|
||||
VersionInfo() {}
|
||||
VersionInfo(const QString &d, int v)
|
||||
: displayName(d), versionId(v) { }
|
||||
QString displayName;
|
||||
int versionId;
|
||||
};
|
||||
|
||||
Qt4Project *m_project;
|
||||
QMap<QString, VersionInfo> m_versions;
|
||||
};
|
||||
|
||||
class Qt4Project : public ProjectExplorer::Project
|
||||
|
||||
Reference in New Issue
Block a user