Commit ae633c19 authored by dt's avatar dt

Add BuildConfiguration classes

Each project has it's own BuildConfiguarion * classes, they'll get a
decent type safe interface and the setValue/value stuff will be removed.
parent 4ef64b8d
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** 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.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#include "cmakebuildconfiguration.h"
CMakeBuildConfiguration::CMakeBuildConfiguration(const QString &name)
: BuildConfiguration(name)
{
}
CMakeBuildConfiguration::CMakeBuildConfiguration(const QString &name, BuildConfiguration *source)
: BuildConfiguration(name, source)
{
}
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** 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.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#ifndef CMAKEBUILDCONFIGURATION_H
#define CMAKEBUILDCONFIGURATION_H
#include <projectexplorer/buildconfiguration.h>
class CMakeBuildConfiguration : public ProjectExplorer::BuildConfiguration
{
public:
CMakeBuildConfiguration(const QString &name);
CMakeBuildConfiguration(const QString &name, BuildConfiguration *source);
};
#endif // CMAKEBUILDCONFIGURATION_H
......@@ -34,6 +34,7 @@
#include "makestep.h"
#include "cmakeopenprojectwizard.h"
#include "cmakebuildenvironmentwidget.h"
#include "cmakebuildconfiguration.h"
#include <projectexplorer/projectexplorerconstants.h>
#include <cpptools/cppmodelmanagerinterface.h>
......@@ -103,7 +104,7 @@ bool CMakeBuildConfigurationFactory::create(const QString &type) const
&ok);
if (!ok || buildConfigurationName.isEmpty())
return false;
BuildConfiguration *bc = new BuildConfiguration(buildConfigurationName);
BuildConfiguration *bc = new CMakeBuildConfiguration(buildConfigurationName);
MakeStep *makeStep = new MakeStep(m_project, bc);
bc->insertBuildStep(0, makeStep);
......@@ -132,6 +133,14 @@ bool CMakeBuildConfigurationFactory::create(const QString &type) const
return true;
}
bool CMakeBuildConfigurationFactory::clone(const QString &name, ProjectExplorer::BuildConfiguration *source) const
{
CMakeBuildConfiguration *old = static_cast<CMakeBuildConfiguration *>(source);
CMakeBuildConfiguration *bc = new CMakeBuildConfiguration(name, old);
m_project->addBuildConfiguration(bc);
return true;
}
/*!
\class CMakeProject
*/
......@@ -649,7 +658,7 @@ bool CMakeProject::restoreSettingsImpl(ProjectExplorer::PersistentSettingsReader
if (copw.exec() != QDialog::Accepted)
return false;
ProjectExplorer::BuildConfiguration *bc = new ProjectExplorer::BuildConfiguration("all");
CMakeBuildConfiguration *bc = new CMakeBuildConfiguration("all");
addBuildConfiguration(bc);
bc->setValue("msvcVersion", copw.msvcVersion());
if (!copw.buildDirectory().isEmpty())
......
......@@ -74,6 +74,7 @@ public:
QString displayNameForType(const QString &type) const;
bool create(const QString &type) const;
bool clone(const QString &name, ProjectExplorer::BuildConfiguration *source) const;
private:
CMakeProject *m_project;
......
......@@ -10,7 +10,8 @@ HEADERS = cmakeproject.h \
makestep.h \
cmakerunconfiguration.h \
cmakeopenprojectwizard.h \
cmakebuildenvironmentwidget.h
cmakebuildenvironmentwidget.h \
cmakebuildconfiguration.h
SOURCES = cmakeproject.cpp \
cmakeprojectplugin.cpp \
cmakeprojectmanager.cpp \
......@@ -18,7 +19,8 @@ SOURCES = cmakeproject.cpp \
makestep.cpp \
cmakerunconfiguration.cpp \
cmakeopenprojectwizard.cpp \
cmakebuildenvironmentwidget.cpp
cmakebuildenvironmentwidget.cpp \
cmakebuildconfiguration.cpp
RESOURCES += cmakeproject.qrc
FORMS +=
......
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** 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.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#include "genericbuildconfiguration.h"
using namespace GenericProjectManager;
using namespace GenericProjectManager::Internal;
using ProjectExplorer::BuildConfiguration;
GenericBuildConfiguration::GenericBuildConfiguration(const QString &name)
: BuildConfiguration(name)
{
}
GenericBuildConfiguration::GenericBuildConfiguration(const QString &name, GenericBuildConfiguration *source)
: BuildConfiguration(name, source)
{
}
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** 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.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#ifndef GENERICBUILDCONFIGURATION_H
#define GENERICBUILDCONFIGURATION_H
#include <projectexplorer/buildconfiguration.h>
namespace GenericProjectManager {
namespace Internal {
class GenericBuildConfiguration : public ProjectExplorer::BuildConfiguration
{
public:
GenericBuildConfiguration(const QString &name);
GenericBuildConfiguration(const QString &name, GenericBuildConfiguration *source);
};
} // namespace GenericProjectManager
} // namespace Internal
#endif // GENERICBUILDCONFIGURATION_H
......@@ -30,6 +30,7 @@
#include "genericproject.h"
#include "genericprojectconstants.h"
#include "genericmakestep.h"
#include "genericbuildconfiguration.h"
#include <projectexplorer/toolchain.h>
#include <projectexplorer/projectexplorerconstants.h>
......@@ -145,7 +146,7 @@ bool GenericBuildConfigurationFactory::create(const QString &type) const
&ok);
if (!ok || buildConfigurationName.isEmpty())
return false;
BuildConfiguration *bc = new BuildConfiguration(buildConfigurationName);
GenericBuildConfiguration *bc = new GenericBuildConfiguration(buildConfigurationName);
m_project->addBuildConfiguration(bc); // also makes the name unique...
GenericMakeStep *makeStep = new GenericMakeStep(m_project, bc);
......@@ -154,6 +155,14 @@ bool GenericBuildConfigurationFactory::create(const QString &type) const
return true;
}
bool GenericBuildConfigurationFactory::clone(const QString &name, BuildConfiguration *source) const
{
// TODO
GenericBuildConfiguration *bc = new GenericBuildConfiguration(name, static_cast<GenericBuildConfiguration *>(source));
m_project->addBuildConfiguration(bc);
return true;
}
////////////////////////////////////////////////////////////////////////////////////
// GenericProject
////////////////////////////////////////////////////////////////////////////////////
......@@ -518,7 +527,7 @@ bool GenericProject::restoreSettingsImpl(ProjectExplorer::PersistentSettingsRead
Project::restoreSettingsImpl(reader);
if (buildConfigurations().isEmpty()) {
ProjectExplorer::BuildConfiguration *bc = new BuildConfiguration("all");
GenericBuildConfiguration *bc = new GenericBuildConfiguration("all");
addBuildConfiguration(bc);
GenericMakeStep *makeStep = new GenericMakeStep(this, bc);
......
......@@ -67,6 +67,7 @@ public:
QString displayNameForType(const QString &type) const;
bool create(const QString &type) const;
bool clone(const QString &name, ProjectExplorer::BuildConfiguration *source) const;
private:
GenericProject *m_project;
......
......@@ -10,7 +10,8 @@ HEADERS = genericproject.h \
genericprojectwizard.h \
genericprojectfileseditor.h \
pkgconfigtool.h \
genericmakestep.h
genericmakestep.h \
genericbuildconfiguration.h
SOURCES = genericproject.cpp \
genericprojectplugin.cpp \
genericprojectmanager.cpp \
......@@ -18,8 +19,8 @@ SOURCES = genericproject.cpp \
genericprojectwizard.cpp \
genericprojectfileseditor.cpp \
pkgconfigtool.cpp \
genericmakestep.cpp
genericmakestep.cpp \
genericbuildconfiguration.cpp
RESOURCES += genericproject.qrc
FORMS += genericmakestep.ui
OTHER_FILES += GenericProjectManager.pluginspec
......@@ -50,13 +50,14 @@ class PROJECTEXPLORER_EXPORT BuildConfiguration : public QObject
Q_OBJECT
public:
BuildConfiguration(const QString &name);
BuildConfiguration(const QString &name, BuildConfiguration *source);
~BuildConfiguration();
// ctors are protected
virtual ~BuildConfiguration();
QString name() const;
QString displayName() const;
void setDisplayName(const QString &name);
// TODO remove those
QVariant value(const QString &key) const;
void setValue(const QString &key, QVariant value);
......@@ -73,6 +74,10 @@ public:
void removeCleanStep(int position);
void moveCleanStepUp(int position);
protected:
BuildConfiguration(const QString &name);
BuildConfiguration(const QString &name, BuildConfiguration *source);
private:
void setName(const QString &name);
......@@ -101,6 +106,14 @@ public:
// returns true if build configuration(s) actually have been added
virtual bool create(const QString &type) const = 0;
// clones a given BuildConfiguration
virtual bool clone(const QString &name, BuildConfiguration *source) const = 0;
// TODO All those methods make the internal name (and display name) unique,
// but in different ways
//virtual bool restore(const QString &name);
// to come:
// restore
// clone
......
......@@ -356,7 +356,10 @@ void BuildSettingsWidget::cloneConfiguration(const QString &sourceConfiguration)
newBuildConfiguration = Project::makeUnique(newBuildConfiguration, buildConfigurationNames);
m_project->copyBuildConfiguration(sourceConfiguration, newBuildConfiguration);
BuildConfiguration *sourceBc = m_project->buildConfiguration(sourceConfiguration);
m_project->buildConfigurationFactory()->clone(newBuildConfiguration, sourceBc);
m_project->setDisplayNameFor(m_project->buildConfiguration(newBuildConfiguration), newDisplayName);
m_buildConfiguration = newBuildConfiguration;
......
......@@ -109,17 +109,6 @@ void Project::removeBuildConfiguration(BuildConfiguration *configuration)
delete configuration;
}
void Project::copyBuildConfiguration(const QString &source, const QString &dest)
{
BuildConfiguration *sourceConfiguration = buildConfiguration(source);
if (!sourceConfiguration)
return;
m_buildConfigurationValues.push_back(new BuildConfiguration(dest, sourceConfiguration));
emit addedBuildConfiguration(this, dest);
}
QList<BuildConfiguration *> Project::buildConfigurations() const
{
return m_buildConfigurationValues;
......
......@@ -86,7 +86,7 @@ public:
// Build configuration
void addBuildConfiguration(BuildConfiguration *configuration);
void removeBuildConfiguration(BuildConfiguration *configuration);
void copyBuildConfiguration(const QString &source, const QString &dest);
BuildConfiguration *buildConfiguration(const QString & name) const;
QList<BuildConfiguration *> buildConfigurations() const;
// remove and add "QString uniqueConfigurationDisplayName(const QString &proposedName) const" instead
......
......@@ -853,7 +853,6 @@ Project *SessionManager::projectForFile(const QString &fileName) const
foreach (Project *p, projectList)
if (p != currentProject && projectContainsFile(p, fileName))
return p;
return 0;
}
......
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** 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.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#include "qt4buildconfiguration.h"
using namespace Qt4ProjectManager;
using namespace Qt4ProjectManager::Internal;
using ProjectExplorer::BuildConfiguration;
Qt4BuildConfiguration::Qt4BuildConfiguration(const QString &name)
: BuildConfiguration(name)
{
}
Qt4BuildConfiguration::Qt4BuildConfiguration(const QString &name, Qt4BuildConfiguration *source)
: BuildConfiguration(name, source)
{
}
Qt4BuildConfiguration::~Qt4BuildConfiguration()
{
}
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** 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.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#ifndef QT4BUILDCONFIGURATION_H
#define QT4BUILDCONFIGURATION_H
#include <projectexplorer/buildconfiguration.h>
namespace Qt4ProjectManager {
namespace Internal {
class Qt4BuildConfiguration : public ProjectExplorer::BuildConfiguration
{
public:
Qt4BuildConfiguration(const QString &name);
// copy ctor
Qt4BuildConfiguration(const QString &name, Qt4BuildConfiguration *source);
~Qt4BuildConfiguration();
};
} // namespace Qt4ProjectManager
} // namespace Internal
#endif // QT4BUILDCONFIGURATION_H
......@@ -41,6 +41,7 @@
#include "qt4projectmanagerconstants.h"
#include "projectloadwizard.h"
#include "qtversionmanager.h"
#include "qt4buildconfiguration.h"
#ifdef QTCREATOR_WITH_S60
#include "qt-s60/gccetoolchain.h"
......@@ -295,6 +296,14 @@ bool Qt4BuildConfigurationFactory::create(const QString &type) const
return true;
}
bool Qt4BuildConfigurationFactory::clone(const QString &name, BuildConfiguration *source) const
{
Qt4BuildConfiguration *oldbc = static_cast<Qt4BuildConfiguration *>(source);
Qt4BuildConfiguration *newbc = new Qt4BuildConfiguration(name, oldbc);
m_project->addBuildConfiguration(newbc);
return true;
}
/*!
\class Qt4Project
......@@ -443,7 +452,7 @@ void Qt4Project::addQt4BuildConfiguration(QString buildConfigurationName, QtVers
bool debug = qmakeBuildConfiguration & QtVersion::DebugBuild;
// Add the buildconfiguration
ProjectExplorer::BuildConfiguration *bc = new ProjectExplorer::BuildConfiguration(buildConfigurationName);
Qt4BuildConfiguration *bc = new Qt4BuildConfiguration(buildConfigurationName);
addBuildConfiguration(bc);
QMakeStep *qmakeStep = new QMakeStep(this, bc);
......
......@@ -131,6 +131,7 @@ public:
QString displayNameForType(const QString &type) const;
bool create(const QString &type) const;
bool clone(const QString &name, ProjectExplorer::BuildConfiguration *source) const;
void update();
......
......@@ -165,8 +165,7 @@ void Qt4ProjectConfigWidget::init(const QString &buildConfiguration)
void Qt4ProjectConfigWidget::changeConfigName(const QString &newName)
{
m_pro->setDisplayNameFor(
m_pro->buildConfiguration(m_buildConfiguration), newName);
m_pro->setDisplayNameFor(m_pro->buildConfiguration(m_buildConfiguration), newName);
}
void Qt4ProjectConfigWidget::setupQtVersionsComboBox()
......
......@@ -39,7 +39,8 @@ HEADERS += qt4projectmanagerplugin.h \
qtuicodemodelsupport.h \
externaleditors.h \
gettingstartedwelcomepagewidget.h \
gettingstartedwelcomepage.h
gettingstartedwelcomepage.h \
qt4buildconfiguration.h
SOURCES += qt4projectmanagerplugin.cpp \
qt4projectmanager.cpp \
qt4project.cpp \
......@@ -74,7 +75,8 @@ SOURCES += qt4projectmanagerplugin.cpp \
qtuicodemodelsupport.cpp \
externaleditors.cpp \
gettingstartedwelcomepagewidget.cpp \
gettingstartedwelcomepage.cpp
gettingstartedwelcomepage.cpp \
qt4buildconfiguration.cpp
FORMS += makestep.ui \
qmakestep.ui \
qt4projectconfigwidget.ui \
......
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