forked from qt-creator/qt-creator
Make method naming more consistent.
* Use id() for methods returning a string used to represent
some type of object.
* Use displayName() for strings that are meant to be user
visible.
* Quieten some warnings while touching the files anyway.
* Move Factories to their products in the plugins where that
was not done before.
Reviewed-by: dt
This commit is contained in:
@@ -28,8 +28,14 @@
|
||||
**************************************************************************/
|
||||
|
||||
#include "cmakebuildconfiguration.h"
|
||||
|
||||
#include "cmakeopenprojectwizard.h"
|
||||
#include "cmakeproject.h"
|
||||
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QtGui/QInputDialog>
|
||||
|
||||
using namespace CMakeProjectManager;
|
||||
using namespace Internal;
|
||||
@@ -202,3 +208,84 @@ void CMakeBuildConfiguration::setMsvcVersion(const QString &msvcVersion)
|
||||
emit msvcVersionChanged();
|
||||
}
|
||||
|
||||
/*!
|
||||
\class CMakeBuildConfigurationFactory
|
||||
*/
|
||||
|
||||
CMakeBuildConfigurationFactory::CMakeBuildConfigurationFactory(CMakeProject *project)
|
||||
: IBuildConfigurationFactory(project),
|
||||
m_project(project)
|
||||
{
|
||||
}
|
||||
|
||||
CMakeBuildConfigurationFactory::~CMakeBuildConfigurationFactory()
|
||||
{
|
||||
}
|
||||
|
||||
QStringList CMakeBuildConfigurationFactory::availableCreationIds() const
|
||||
{
|
||||
return QStringList() << "Create";
|
||||
}
|
||||
|
||||
QString CMakeBuildConfigurationFactory::displayNameForId(const QString &id) const
|
||||
{
|
||||
QTC_ASSERT(id == "Create", return QString());
|
||||
return tr("Create");
|
||||
}
|
||||
|
||||
ProjectExplorer::BuildConfiguration *CMakeBuildConfigurationFactory::create(const QString &id) const
|
||||
{
|
||||
QTC_ASSERT(id == "Create", return 0);
|
||||
|
||||
//TODO configuration name should be part of the cmakeopenprojectwizard
|
||||
bool ok;
|
||||
QString buildConfigurationName = QInputDialog::getText(0,
|
||||
tr("New configuration"),
|
||||
tr("New Configuration Name:"),
|
||||
QLineEdit::Normal,
|
||||
QString(),
|
||||
&ok);
|
||||
if (!ok || buildConfigurationName.isEmpty())
|
||||
return false;
|
||||
CMakeBuildConfiguration *bc = new CMakeBuildConfiguration(m_project);
|
||||
bc->setDisplayName(buildConfigurationName);
|
||||
|
||||
MakeStep *makeStep = new MakeStep(bc);
|
||||
bc->insertBuildStep(0, makeStep);
|
||||
|
||||
MakeStep *cleanMakeStep = new MakeStep(bc);
|
||||
bc->insertCleanStep(0, cleanMakeStep);
|
||||
cleanMakeStep->setClean(true);
|
||||
|
||||
CMakeOpenProjectWizard copw(m_project->projectManager(),
|
||||
m_project->sourceDirectory(),
|
||||
bc->buildDirectory(),
|
||||
bc->environment());
|
||||
if (copw.exec() != QDialog::Accepted) {
|
||||
delete bc;
|
||||
return false;
|
||||
}
|
||||
m_project->addBuildConfiguration(bc); // this also makes the name unique
|
||||
|
||||
bc->setBuildDirectory(copw.buildDirectory());
|
||||
bc->setMsvcVersion(copw.msvcVersion());
|
||||
m_project->parseCMakeLists();
|
||||
|
||||
// Default to all
|
||||
if (m_project->targets().contains("all"))
|
||||
makeStep->setBuildTarget("all", true);
|
||||
return bc;
|
||||
}
|
||||
|
||||
ProjectExplorer::BuildConfiguration *CMakeBuildConfigurationFactory::clone(ProjectExplorer::BuildConfiguration *source) const
|
||||
{
|
||||
CMakeBuildConfiguration *old = static_cast<CMakeBuildConfiguration *>(source);
|
||||
CMakeBuildConfiguration *bc = new CMakeBuildConfiguration(old);
|
||||
return bc;
|
||||
}
|
||||
|
||||
ProjectExplorer::BuildConfiguration *CMakeBuildConfigurationFactory::restore(const QVariantMap &map) const
|
||||
{
|
||||
CMakeBuildConfiguration *bc = new CMakeBuildConfiguration(m_project, map);
|
||||
return bc;
|
||||
}
|
||||
|
||||
@@ -82,6 +82,24 @@ private:
|
||||
QString m_msvcVersion;
|
||||
};
|
||||
|
||||
class CMakeBuildConfigurationFactory : public ProjectExplorer::IBuildConfigurationFactory
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CMakeBuildConfigurationFactory(CMakeProject *project);
|
||||
~CMakeBuildConfigurationFactory();
|
||||
|
||||
QStringList availableCreationIds() const;
|
||||
QString displayNameForId(const QString &id) const;
|
||||
|
||||
ProjectExplorer::BuildConfiguration *create(const QString &id) const;
|
||||
ProjectExplorer::BuildConfiguration *clone(ProjectExplorer::BuildConfiguration *source) const;
|
||||
ProjectExplorer::BuildConfiguration *restore(const QVariantMap &map) const;
|
||||
|
||||
private:
|
||||
CMakeProject *m_project;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace CMakeProjectManager
|
||||
|
||||
@@ -66,87 +66,6 @@ using ProjectExplorer::EnvironmentItem;
|
||||
// Open Questions
|
||||
// Who sets up the environment for cl.exe ? INCLUDEPATH and so on
|
||||
|
||||
/*!
|
||||
\class CMakeBuildConfigurationFactory
|
||||
*/
|
||||
|
||||
CMakeBuildConfigurationFactory::CMakeBuildConfigurationFactory(CMakeProject *project)
|
||||
: IBuildConfigurationFactory(project),
|
||||
m_project(project)
|
||||
{
|
||||
}
|
||||
|
||||
CMakeBuildConfigurationFactory::~CMakeBuildConfigurationFactory()
|
||||
{
|
||||
}
|
||||
|
||||
QStringList CMakeBuildConfigurationFactory::availableCreationTypes() const
|
||||
{
|
||||
return QStringList() << "Create";
|
||||
}
|
||||
|
||||
QString CMakeBuildConfigurationFactory::displayNameForType(const QString & /* type */) const
|
||||
{
|
||||
return tr("Create");
|
||||
}
|
||||
|
||||
BuildConfiguration *CMakeBuildConfigurationFactory::create(const QString &type) const
|
||||
{
|
||||
QTC_ASSERT(type == "Create", return false);
|
||||
|
||||
//TODO configuration name should be part of the cmakeopenprojectwizard
|
||||
bool ok;
|
||||
QString buildConfigurationName = QInputDialog::getText(0,
|
||||
tr("New configuration"),
|
||||
tr("New Configuration Name:"),
|
||||
QLineEdit::Normal,
|
||||
QString(),
|
||||
&ok);
|
||||
if (!ok || buildConfigurationName.isEmpty())
|
||||
return false;
|
||||
CMakeBuildConfiguration *bc = new CMakeBuildConfiguration(m_project);
|
||||
bc->setDisplayName(buildConfigurationName);
|
||||
|
||||
MakeStep *makeStep = new MakeStep(bc);
|
||||
bc->insertBuildStep(0, makeStep);
|
||||
|
||||
MakeStep *cleanMakeStep = new MakeStep(bc);
|
||||
bc->insertCleanStep(0, cleanMakeStep);
|
||||
cleanMakeStep->setClean(true);
|
||||
|
||||
CMakeOpenProjectWizard copw(m_project->projectManager(),
|
||||
m_project->sourceDirectory(),
|
||||
bc->buildDirectory(),
|
||||
bc->environment());
|
||||
if (copw.exec() != QDialog::Accepted) {
|
||||
delete bc;
|
||||
return false;
|
||||
}
|
||||
m_project->addBuildConfiguration(bc); // this also makes the name unique
|
||||
|
||||
bc->setBuildDirectory(copw.buildDirectory());
|
||||
bc->setMsvcVersion(copw.msvcVersion());
|
||||
m_project->parseCMakeLists();
|
||||
|
||||
// Default to all
|
||||
if (m_project->targets().contains("all"))
|
||||
makeStep->setBuildTarget("all", true);
|
||||
return bc;
|
||||
}
|
||||
|
||||
BuildConfiguration *CMakeBuildConfigurationFactory::clone(ProjectExplorer::BuildConfiguration *source) const
|
||||
{
|
||||
CMakeBuildConfiguration *old = static_cast<CMakeBuildConfiguration *>(source);
|
||||
CMakeBuildConfiguration *bc = new CMakeBuildConfiguration(old);
|
||||
return bc;
|
||||
}
|
||||
|
||||
BuildConfiguration *CMakeBuildConfigurationFactory::restore(const QMap<QString, QVariant> &map) const
|
||||
{
|
||||
CMakeBuildConfiguration *bc = new CMakeBuildConfiguration(m_project, map);
|
||||
return bc;
|
||||
}
|
||||
|
||||
/*!
|
||||
\class CMakeProject
|
||||
*/
|
||||
@@ -504,7 +423,7 @@ ProjectExplorer::FolderNode *CMakeProject::findOrCreateFolder(CMakeProjectNode *
|
||||
return parent;
|
||||
}
|
||||
|
||||
QString CMakeProject::name() const
|
||||
QString CMakeProject::displayName() const
|
||||
{
|
||||
return m_projectName;
|
||||
}
|
||||
|
||||
@@ -63,25 +63,6 @@ struct CMakeTarget
|
||||
void clear();
|
||||
};
|
||||
|
||||
class CMakeBuildConfigurationFactory : public ProjectExplorer::IBuildConfigurationFactory
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CMakeBuildConfigurationFactory(CMakeProject *project);
|
||||
~CMakeBuildConfigurationFactory();
|
||||
|
||||
QStringList availableCreationTypes() const;
|
||||
QString displayNameForType(const QString &type) const;
|
||||
|
||||
ProjectExplorer::BuildConfiguration *create(const QString &type) const;
|
||||
ProjectExplorer::BuildConfiguration *clone(ProjectExplorer::BuildConfiguration *source) const;
|
||||
ProjectExplorer::BuildConfiguration *restore(const QMap<QString, QVariant> &map) const;
|
||||
|
||||
private:
|
||||
CMakeProject *m_project;
|
||||
};
|
||||
|
||||
class CMakeProject : public ProjectExplorer::Project
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -93,7 +74,7 @@ public:
|
||||
|
||||
CMakeBuildConfiguration *activeCMakeBuildConfiguration() const;
|
||||
|
||||
virtual QString name() const;
|
||||
virtual QString displayName() const;
|
||||
virtual Core::IFile *file() const;
|
||||
virtual ProjectExplorer::IBuildConfigurationFactory *buildConfigurationFactory() const;
|
||||
virtual CMakeManager *projectManager() const;
|
||||
|
||||
@@ -244,7 +244,7 @@ QString CMakeSettingsPage::id() const
|
||||
return QLatin1String("CMake");
|
||||
}
|
||||
|
||||
QString CMakeSettingsPage::trName() const
|
||||
QString CMakeSettingsPage::displayName() const
|
||||
{
|
||||
return tr("CMake");
|
||||
}
|
||||
@@ -254,7 +254,7 @@ QString CMakeSettingsPage::category() const
|
||||
return QLatin1String("M.CMake");
|
||||
}
|
||||
|
||||
QString CMakeSettingsPage::trCategory() const
|
||||
QString CMakeSettingsPage::displayCategory() const
|
||||
{
|
||||
return tr("CMake");
|
||||
}
|
||||
|
||||
@@ -88,9 +88,9 @@ public:
|
||||
CMakeSettingsPage();
|
||||
virtual ~CMakeSettingsPage();
|
||||
virtual QString id() const;
|
||||
virtual QString trName() const;
|
||||
virtual QString displayName() const;
|
||||
virtual QString category() const;
|
||||
virtual QString trCategory() const;
|
||||
virtual QString displayCategory() const;
|
||||
|
||||
virtual QWidget *createPage(QWidget *parent);
|
||||
virtual void apply();
|
||||
|
||||
@@ -54,7 +54,7 @@ CMakeRunConfiguration::CMakeRunConfiguration(CMakeProject *pro, const QString &t
|
||||
, m_title(title)
|
||||
, m_baseEnvironmentBase(CMakeRunConfiguration::BuildEnvironmentBase)
|
||||
{
|
||||
setName(title);
|
||||
setDisplayName(title);
|
||||
|
||||
connect(pro, SIGNAL(environmentChanged()),
|
||||
this, SIGNAL(baseEnvironmentChanged()));
|
||||
@@ -70,7 +70,7 @@ CMakeProject *CMakeRunConfiguration::cmakeProject() const
|
||||
return static_cast<CMakeProject *>(project());
|
||||
}
|
||||
|
||||
QString CMakeRunConfiguration::type() const
|
||||
QString CMakeRunConfiguration::id() const
|
||||
{
|
||||
return Constants::CMAKERUNCONFIGURATION;
|
||||
}
|
||||
@@ -417,15 +417,15 @@ CMakeRunConfigurationFactory::~CMakeRunConfigurationFactory()
|
||||
}
|
||||
|
||||
// used to recreate the runConfigurations when restoring settings
|
||||
bool CMakeRunConfigurationFactory::canRestore(const QString &type) const
|
||||
bool CMakeRunConfigurationFactory::canRestore(const QString &id) const
|
||||
{
|
||||
if (type.startsWith(Constants::CMAKERUNCONFIGURATION))
|
||||
if (id.startsWith(Constants::CMAKERUNCONFIGURATION))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// used to show the list of possible additons to a project, returns a list of types
|
||||
QStringList CMakeRunConfigurationFactory::availableCreationTypes(ProjectExplorer::Project *project) const
|
||||
// used to show the list of possible additons to a project, returns a list of ids
|
||||
QStringList CMakeRunConfigurationFactory::availableCreationIds(ProjectExplorer::Project *project) const
|
||||
{
|
||||
CMakeProject *pro = qobject_cast<CMakeProject *>(project);
|
||||
if (!pro)
|
||||
@@ -437,28 +437,28 @@ QStringList CMakeRunConfigurationFactory::availableCreationTypes(ProjectExplorer
|
||||
return allTargets;
|
||||
}
|
||||
|
||||
// used to translate the types to names to display to the user
|
||||
QString CMakeRunConfigurationFactory::displayNameForType(const QString &type) const
|
||||
// used to translate the ids to names to display to the user
|
||||
QString CMakeRunConfigurationFactory::displayNameForId(const QString &id) const
|
||||
{
|
||||
Q_ASSERT(type.startsWith(Constants::CMAKERUNCONFIGURATION));
|
||||
Q_ASSERT(id.startsWith(Constants::CMAKERUNCONFIGURATION));
|
||||
|
||||
if (type == Constants::CMAKERUNCONFIGURATION)
|
||||
if (id == Constants::CMAKERUNCONFIGURATION)
|
||||
return "CMake"; // Doesn't happen
|
||||
else
|
||||
return type.mid(QString(Constants::CMAKERUNCONFIGURATION).length());
|
||||
return id.mid(QString(Constants::CMAKERUNCONFIGURATION).length());
|
||||
}
|
||||
|
||||
ProjectExplorer::RunConfiguration* CMakeRunConfigurationFactory::create(ProjectExplorer::Project *project, const QString &type)
|
||||
ProjectExplorer::RunConfiguration* CMakeRunConfigurationFactory::create(ProjectExplorer::Project *project, const QString &id)
|
||||
{
|
||||
CMakeProject *pro = qobject_cast<CMakeProject *>(project);
|
||||
Q_ASSERT(pro);
|
||||
if (type == Constants::CMAKERUNCONFIGURATION) {
|
||||
if (id == Constants::CMAKERUNCONFIGURATION) {
|
||||
// Restoring, filename will be added by restoreSettings
|
||||
ProjectExplorer::RunConfiguration* rc = new CMakeRunConfiguration(pro, QString::null, QString::null, QString::null);
|
||||
return rc;
|
||||
} else {
|
||||
// Adding new
|
||||
const QString title = type.mid(QString(Constants::CMAKERUNCONFIGURATION).length());
|
||||
const QString title = id.mid(QString(Constants::CMAKERUNCONFIGURATION).length());
|
||||
const CMakeTarget &ct = pro->targetForTitle(title);
|
||||
ProjectExplorer::RunConfiguration * rc = new CMakeRunConfiguration(pro, ct.executable, ct.workingDirectory, ct.title);
|
||||
return rc;
|
||||
|
||||
@@ -55,7 +55,7 @@ public:
|
||||
virtual ~CMakeRunConfiguration();
|
||||
CMakeProject *cmakeProject() const;
|
||||
|
||||
virtual QString type() const;
|
||||
virtual QString id() const;
|
||||
virtual QString executable() const;
|
||||
virtual RunMode runMode() const;
|
||||
virtual QString workingDirectory() const;
|
||||
@@ -137,12 +137,12 @@ public:
|
||||
CMakeRunConfigurationFactory();
|
||||
virtual ~CMakeRunConfigurationFactory();
|
||||
// used to recreate the runConfigurations when restoring settings
|
||||
virtual bool canRestore(const QString &type) const;
|
||||
virtual bool canRestore(const QString &id) const;
|
||||
// used to show the list of possible additons to a project, returns a list of types
|
||||
virtual QStringList availableCreationTypes(ProjectExplorer::Project *pro) const;
|
||||
virtual QStringList availableCreationIds(ProjectExplorer::Project *pro) const;
|
||||
// used to translate the types to names to display to the user
|
||||
virtual QString displayNameForType(const QString &type) const;
|
||||
virtual ProjectExplorer::RunConfiguration* create(ProjectExplorer::Project *project, const QString &type);
|
||||
virtual QString displayNameForId(const QString &id) const;
|
||||
virtual ProjectExplorer::RunConfiguration* create(ProjectExplorer::Project *project, const QString &id);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -132,7 +132,7 @@ void MakeStep::run(QFutureInterface<bool> &fi)
|
||||
m_futureInterface = 0;
|
||||
}
|
||||
|
||||
QString MakeStep::name()
|
||||
QString MakeStep::id()
|
||||
{
|
||||
return Constants::MAKESTEP;
|
||||
}
|
||||
@@ -298,14 +298,14 @@ QString MakeStepConfigWidget::summaryText() const
|
||||
// MakeStepFactory
|
||||
//
|
||||
|
||||
bool MakeStepFactory::canCreate(const QString &name) const
|
||||
bool MakeStepFactory::canCreate(const QString &id) const
|
||||
{
|
||||
return (Constants::MAKESTEP == name);
|
||||
return (Constants::MAKESTEP == id);
|
||||
}
|
||||
|
||||
BuildStep *MakeStepFactory::create(BuildConfiguration *bc, const QString &name) const
|
||||
BuildStep *MakeStepFactory::create(BuildConfiguration *bc, const QString &id) const
|
||||
{
|
||||
Q_ASSERT(name == Constants::MAKESTEP);
|
||||
Q_ASSERT(id == Constants::MAKESTEP);
|
||||
return new MakeStep(bc);
|
||||
}
|
||||
|
||||
@@ -314,13 +314,15 @@ BuildStep *MakeStepFactory::clone(BuildStep *bs, BuildConfiguration *bc) const
|
||||
return new MakeStep(static_cast<MakeStep *>(bs), bc);
|
||||
}
|
||||
|
||||
QStringList MakeStepFactory::canCreateForBuildConfiguration(BuildConfiguration * /* pro */) const
|
||||
QStringList MakeStepFactory::canCreateForBuildConfiguration(BuildConfiguration *bc) const
|
||||
{
|
||||
Q_UNUSED(bc);
|
||||
return QStringList();
|
||||
}
|
||||
|
||||
QString MakeStepFactory::displayNameForName(const QString & /* name */) const
|
||||
QString MakeStepFactory::displayNameForId(const QString &id) const
|
||||
{
|
||||
Q_UNUSED(id);
|
||||
return "Make";
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ public:
|
||||
|
||||
virtual void run(QFutureInterface<bool> &fi);
|
||||
|
||||
virtual QString name();
|
||||
virtual QString id();
|
||||
virtual QString displayName();
|
||||
virtual ProjectExplorer::BuildStepConfigWidget *createConfigWidget();
|
||||
virtual bool immutable() const;
|
||||
@@ -108,11 +108,11 @@ private:
|
||||
|
||||
class MakeStepFactory : public ProjectExplorer::IBuildStepFactory
|
||||
{
|
||||
virtual bool canCreate(const QString &name) const;
|
||||
virtual ProjectExplorer::BuildStep *create(ProjectExplorer::BuildConfiguration *bc, const QString &name) const;
|
||||
virtual bool canCreate(const QString &id) const;
|
||||
virtual ProjectExplorer::BuildStep *create(ProjectExplorer::BuildConfiguration *bc, const QString &id) const;
|
||||
virtual ProjectExplorer::BuildStep *clone(ProjectExplorer::BuildStep *bs, ProjectExplorer::BuildConfiguration *bc) const;
|
||||
virtual QStringList canCreateForBuildConfiguration(ProjectExplorer::BuildConfiguration *bc) const;
|
||||
virtual QString displayNameForName(const QString &name) const;
|
||||
virtual QString displayNameForId(const QString &id) const;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
Reference in New Issue
Block a user