Commit a6ad7737 authored by Tobias Hunger's avatar Tobias Hunger

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
parent 8bb87fcd
......@@ -46,9 +46,9 @@ FileWizardDialog::FileWizardDialog(QWidget *parent) :
connect(m_filePage, SIGNAL(activated()), button(QWizard::FinishButton), SLOT(animateClick()));
}
QString FileWizardDialog::name() const
QString FileWizardDialog::fileName() const
{
return m_filePage->name();
return m_filePage->fileName();
}
QString FileWizardDialog::path() const
......@@ -62,9 +62,9 @@ void FileWizardDialog::setPath(const QString &path)
}
void FileWizardDialog::setName(const QString &name)
void FileWizardDialog::setFileName(const QString &name)
{
m_filePage->setName(name);
m_filePage->setFileName(name);
}
} // namespace Utils
......@@ -49,12 +49,12 @@ class QTCREATOR_UTILS_EXPORT FileWizardDialog : public QWizard {
public:
explicit FileWizardDialog(QWidget *parent = 0);
QString name() const;
QString fileName() const;
QString path() const;
public slots:
void setPath(const QString &path);
void setName(const QString &name);
void setFileName(const QString &name);
private:
FileWizardPage *m_filePage;
......
......@@ -61,7 +61,7 @@ FileWizardPage::~FileWizardPage()
delete m_d;
}
QString FileWizardPage::name() const
QString FileWizardPage::fileName() const
{
return m_d->m_ui.nameLineEdit->text();
}
......@@ -76,7 +76,7 @@ void FileWizardPage::setPath(const QString &path)
m_d->m_ui.pathChooser->setPath(path);
}
void FileWizardPage::setName(const QString &name)
void FileWizardPage::setFileName(const QString &name)
{
m_d->m_ui.nameLineEdit->setText(name);
}
......@@ -98,7 +98,7 @@ bool FileWizardPage::isComplete() const
return m_d->m_complete;
}
void FileWizardPage::setNameLabel(const QString &label)
void FileWizardPage::setFileNameLabel(const QString &label)
{
m_d->m_ui.nameLabel->setText(label);
}
......
......@@ -50,17 +50,17 @@ class QTCREATOR_UTILS_EXPORT FileWizardPage : public QWizardPage
Q_OBJECT
Q_DISABLE_COPY(FileWizardPage)
Q_PROPERTY(QString path READ path WRITE setPath DESIGNABLE true)
Q_PROPERTY(QString name READ name WRITE setName DESIGNABLE true)
Q_PROPERTY(QString fileName READ fileName WRITE setFileName DESIGNABLE true)
public:
explicit FileWizardPage(QWidget *parent = 0);
virtual ~FileWizardPage();
QString name() const;
QString fileName() const;
QString path() const;
virtual bool isComplete() const;
void setNameLabel(const QString &label);
void setFileNameLabel(const QString &label);
void setPathLabel(const QString &label);
// Validate a base name entry field (potentially containing extension)
......@@ -72,7 +72,7 @@ signals:
public slots:
void setPath(const QString &path);
void setName(const QString &name);
void setFileName(const QString &name);
private slots:
void slotValidChanged();
......
......@@ -80,7 +80,7 @@ ProjectIntroPage::~ProjectIntroPage()
delete m_d;
}
QString ProjectIntroPage::name() const
QString ProjectIntroPage::projectName() const
{
return m_d->m_ui.nameLineEdit->text();
}
......@@ -95,7 +95,7 @@ void ProjectIntroPage::setPath(const QString &path)
m_d->m_ui.pathChooser->setPath(path);
}
void ProjectIntroPage::setName(const QString &name)
void ProjectIntroPage::setProjectName(const QString &name)
{
m_d->m_ui.nameLineEdit->setText(name);
m_d->m_ui.nameLineEdit->selectAll();
......
......@@ -57,13 +57,13 @@ class QTCREATOR_UTILS_EXPORT ProjectIntroPage : public QWizardPage
Q_DISABLE_COPY(ProjectIntroPage)
Q_PROPERTY(QString description READ description WRITE setPath DESIGNABLE true)
Q_PROPERTY(QString path READ path WRITE setPath DESIGNABLE true)
Q_PROPERTY(QString name READ name WRITE setName DESIGNABLE true)
Q_PROPERTY(QString projectName READ projectName WRITE setProjectName DESIGNABLE true)
Q_PROPERTY(bool useAsDefaultPath READ useAsDefaultPath WRITE setUseAsDefaultPath DESIGNABLE true)
public:
explicit ProjectIntroPage(QWidget *parent = 0);
virtual ~ProjectIntroPage();
QString name() const;
QString projectName() const;
QString path() const;
QString description() const;
bool useAsDefaultPath() const;
......@@ -81,7 +81,7 @@ signals:
public slots:
void setPath(const QString &path);
void setName(const QString &name);
void setProjectName(const QString &name);
void setDescription(const QString &description);
void setUseAsDefaultPath(bool u);
......
......@@ -33,7 +33,8 @@
namespace BINEditor {
namespace Constants {
const char * const C_BINEDITOR = "Binary Editor";
const char * const C_BINEDITOR_ID = "BinEditor.BinaryEditor";
const char * const C_BINEDITOR_DISPLAY_NAME = QT_TRANSLATE_NOOP("OpenWith::Editors", "Binary Editor");
const char * const C_BINEDITOR_MIMETYPE = "application/octet-stream";
} // namespace Constants
......
......@@ -303,8 +303,8 @@ public:
Core::UniqueIDManager *uidm = Core::UniqueIDManager::instance();
m_editor = parent;
m_file = new BinEditorFile(parent);
m_context << uidm->uniqueIdentifier(Core::Constants::K_DEFAULT_BINARY_EDITOR);
m_context << uidm->uniqueIdentifier(Constants::C_BINEDITOR);
m_context << uidm->uniqueIdentifier(Core::Constants::K_DEFAULT_BINARY_EDITOR_ID);
m_context << uidm->uniqueIdentifier(Constants::C_BINEDITOR_ID);
m_cursorPositionLabel = new Utils::LineColumnLabel;
QHBoxLayout *l = new QHBoxLayout;
......@@ -336,7 +336,7 @@ public:
return m_file->open(fileName);
}
Core::IFile *file() { return m_file; }
const char *kind() const { return Core::Constants::K_DEFAULT_BINARY_EDITOR; }
QString id() const { return QLatin1String(Core::Constants::K_DEFAULT_BINARY_EDITOR_ID); }
QString displayName() const { return m_displayName; }
void setDisplayName(const QString &title) { m_displayName = title; emit changed(); }
......@@ -371,21 +371,25 @@ private:
///////////////////////////////// BinEditorFactory //////////////////////////////////
BinEditorFactory::BinEditorFactory(BinEditorPlugin *owner) :
m_kind(QLatin1String(Core::Constants::K_DEFAULT_BINARY_EDITOR)),
m_mimeTypes(QLatin1String(BINEditor::Constants::C_BINEDITOR_MIMETYPE)),
m_owner(owner)
{
}
QString BinEditorFactory::kind() const
QString BinEditorFactory::id() const
{
return m_kind;
return QLatin1String(Core::Constants::K_DEFAULT_BINARY_EDITOR_ID);
}
QString BinEditorFactory::displayName() const
{
return tr(Constants::C_BINEDITOR_DISPLAY_NAME);
}
Core::IFile *BinEditorFactory::open(const QString &fileName)
{
Core::EditorManager *em = Core::EditorManager::instance();
Core::IEditor *iface = em->openEditor(fileName, kind());
Core::IEditor *iface = em->openEditor(fileName, id());
return iface ? iface->file() : 0;
}
......@@ -439,7 +443,7 @@ void BinEditorPlugin::initializeEditor(BinEditor *editor)
editor->setEditorInterface(editorInterface);
Core::UniqueIDManager *uidm = Core::UniqueIDManager::instance();
m_context << uidm->uniqueIdentifier(Constants::C_BINEDITOR);
m_context << uidm->uniqueIdentifier(Constants::C_BINEDITOR_ID);
if (!m_undoAction) {
m_undoAction = registerNewAction(QLatin1String(Core::Constants::UNDO),
this, SLOT(undoAction()),
......
......@@ -95,11 +95,11 @@ public:
virtual QStringList mimeTypes() const;
Core::IEditor *createEditor(QWidget *parent);
QString kind() const;
QString id() const;
QString displayName() const;
Core::IFile *open(const QString &fileName);
private:
const QString m_kind;
const QStringList m_mimeTypes;
BinEditorPlugin *m_owner;
};
......
......@@ -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");