Commit 1738d08f authored by hjk's avatar hjk

projectexplorer: move project{Context,Language} from IProjectManager to Project

Reviewed-by: dt
parent 4a338a51
......@@ -99,6 +99,9 @@ CMakeProject::CMakeProject(CMakeManager *manager, const QString &fileName)
m_rootNode(new CMakeProjectNode(m_fileName)),
m_lastEditor(0)
{
setProjectContext(Core::Context(CMakeProjectManager::Constants::PROJECTCONTEXT));
setProjectLanguage(Core::Context(ProjectExplorer::Constants::LANG_CXX));
m_file = new CMakeFile(this, fileName);
connect(this, SIGNAL(addedTarget(ProjectExplorer::Target*)),
......
......@@ -63,9 +63,6 @@ using namespace CMakeProjectManager::Internal;
CMakeManager::CMakeManager(CMakeSettingsPage *cmakeSettingsPage)
: m_settingsPage(cmakeSettingsPage)
{
m_projectContext = Core::Context(CMakeProjectManager::Constants::PROJECTCONTEXT);
m_projectLanguage = Core::Context(ProjectExplorer::Constants::LANG_CXX);
ProjectExplorer::ProjectExplorerPlugin *projectExplorer = ProjectExplorer::ProjectExplorerPlugin::instance();
connect(projectExplorer, SIGNAL(aboutToShowContextMenu(ProjectExplorer::Project*, ProjectExplorer::Node*)),
this, SLOT(updateContextMenu(ProjectExplorer::Project*, ProjectExplorer::Node*)));
......@@ -79,14 +76,16 @@ CMakeManager::CMakeManager(CMakeSettingsPage *cmakeSettingsPage)
Core::ActionContainer *msubproject =
am->actionContainer(ProjectExplorer::Constants::M_SUBPROJECTCONTEXT);
const Core::Context projectContext(CMakeProjectManager::Constants::PROJECTCONTEXT);
m_runCMakeAction = new QAction(QIcon(), tr("Run CMake"), this);
Core::Command *command = am->registerAction(m_runCMakeAction, Constants::RUNCMAKE, m_projectContext);
Core::Command *command = am->registerAction(m_runCMakeAction, Constants::RUNCMAKE, projectContext);
command->setAttribute(Core::Command::CA_Hide);
mbuild->addAction(command, ProjectExplorer::Constants::G_BUILD_PROJECT);
connect(m_runCMakeAction, SIGNAL(triggered()), this, SLOT(runCMake()));
m_runCMakeActionContextMenu = new QAction(QIcon(), tr("Run CMake"), this);
command = am->registerAction(m_runCMakeActionContextMenu, Constants::RUNCMAKECONTEXTMENU, m_projectContext);
command = am->registerAction(m_runCMakeActionContextMenu, Constants::RUNCMAKECONTEXTMENU, projectContext);
command->setAttribute(Core::Command::CA_Hide);
mproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD);
msubproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD);
......@@ -133,16 +132,6 @@ void CMakeManager::runCMake(ProjectExplorer::Project *project)
}
}
Core::Context CMakeManager::projectContext() const
{
return m_projectContext;
}
Core::Context CMakeManager::projectLanguage() const
{
return m_projectLanguage;
}
ProjectExplorer::Project *CMakeManager::openProject(const QString &fileName)
{
// TODO check whether this project is already opened
......
......@@ -66,9 +66,6 @@ class CMakeManager : public ProjectExplorer::IProjectManager
public:
CMakeManager(CMakeSettingsPage *cmakeSettingsPage);
virtual Core::Context projectContext() const;
virtual Core::Context projectLanguage() const;
virtual ProjectExplorer::Project *openProject(const QString &fileName);
virtual QString mimeType() const;
......@@ -95,8 +92,6 @@ private:
void runCMake(ProjectExplorer::Project *project);
static QString qtVersionForQMake(const QString &qmakePath);
static QPair<QString, QString> findQtDir(const Utils::Environment &env);
Core::Context m_projectContext;
Core::Context m_projectLanguage;
CMakeSettingsPage *m_settingsPage;
QAction *m_runCMakeAction;
QAction *m_runCMakeActionContextMenu;
......
......@@ -47,6 +47,7 @@
#include <utils/pathchooser.h>
#include <utils/qtcassert.h>
#include <coreplugin/icore.h>
#include <coreplugin/icontext.h>
#include <QtCore/QDir>
#include <QtCore/QProcessEnvironment>
......@@ -72,6 +73,9 @@ GenericProject::GenericProject(Manager *manager, const QString &fileName)
m_fileName(fileName),
m_toolChain(0)
{
setProjectContext(Core::Context(GenericProjectManager::Constants::PROJECTCONTEXT));
setProjectLanguage(Core::Context(ProjectExplorer::Constants::LANG_CXX));
QFileInfo fileInfo(m_fileName);
QDir dir = fileInfo.dir();
......
......@@ -46,20 +46,7 @@
using namespace GenericProjectManager::Internal;
Manager::Manager()
{
m_projectContext = Core::Context(GenericProjectManager::Constants::PROJECTCONTEXT);
m_projectLanguage = Core::Context(ProjectExplorer::Constants::LANG_CXX);
}
Core::Context Manager::projectContext() const
{
return m_projectContext;
}
Core::Context Manager::projectLanguage() const
{
return m_projectLanguage;
}
{ }
QString Manager::mimeType() const
{
......
......@@ -35,7 +35,6 @@
#define GENERICPROJECTMANAGER_H
#include <projectexplorer/iprojectmanager.h>
#include <coreplugin/icontext.h>
namespace GenericProjectManager {
namespace Internal {
......@@ -49,9 +48,6 @@ class Manager : public ProjectExplorer::IProjectManager
public:
Manager();
virtual Core::Context projectContext() const;
virtual Core::Context projectLanguage() const;
virtual QString mimeType() const;
virtual ProjectExplorer::Project *openProject(const QString &fileName);
......@@ -61,8 +57,6 @@ public:
void unregisterProject(GenericProject *project);
private:
Core::Context m_projectContext;
Core::Context m_projectLanguage;
QList<GenericProject *> m_projects;
};
......
......@@ -53,9 +53,6 @@ class PROJECTEXPLORER_EXPORT IProjectManager
public:
IProjectManager() {}
virtual Core::Context projectContext() const = 0; //TODO move into project
virtual Core::Context projectLanguage() const = 0; //TODO move into project
virtual QString mimeType() const = 0;
virtual Project *openProject(const QString &fileName) = 0;
};
......
......@@ -42,6 +42,7 @@
#include "userfileaccessor.h"
#include <coreplugin/ifile.h>
#include <coreplugin/icontext.h>
#include <extensionsystem/pluginmanager.h>
#include <limits>
#include <utils/qtcassert.h>
......@@ -60,12 +61,15 @@ namespace ProjectExplorer {
// Project
// -------------------------------------------------------------------------
class ProjectPrivate {
class ProjectPrivate
{
public:
ProjectPrivate();
QList<Target *> m_targets;
Target *m_activeTarget;
EditorConfiguration *m_editorConfiguration;
Core::Context m_projectContext;
Core::Context m_projectLanguage;
};
ProjectPrivate::ProjectPrivate() :
......@@ -301,4 +305,24 @@ QString Project::generatedUiHeader(const QString & /* formFile */) const
return QString();
}
void Project::setProjectContext(Core::Context context)
{
d->m_projectContext = context;
}
void Project::setProjectLanguage(Core::Context language)
{
d->m_projectLanguage = language;
}
Core::Context Project::projectContext() const
{
return d->m_projectContext;
}
Core::Context Project::projectLanguage() const
{
return d->m_projectLanguage;
}
} // namespace ProjectExplorer
......@@ -42,6 +42,7 @@
namespace Core {
class IFile;
class Context;
}
namespace ProjectExplorer {
......@@ -51,7 +52,6 @@ class IProjectManager;
class EditorConfiguration;
class ProjectNode;
class Target;
class ITargetFactory;
class ProjectPrivate;
class PROJECTEXPLORER_EXPORT Project
......@@ -119,6 +119,9 @@ public:
QString projectDirectory() const;
static QString projectDirectory(const QString &proFile);
virtual Core::Context projectContext() const;
virtual Core::Context projectLanguage() const;
signals:
void fileListChanged();
......@@ -145,6 +148,9 @@ protected:
// Note: Do not forget to call your base class' fromMap method!
virtual bool fromMap(const QVariantMap &map);
virtual void setProjectContext(Core::Context context);
virtual void setProjectLanguage(Core::Context language);
private slots:
void changeEnvironment();
void changeBuildConfigurationEnabled();
......
......@@ -1502,12 +1502,12 @@ void ProjectExplorerPlugin::setCurrent(Project *project, QString filePath, Node
Core::Context newContext;
if (d->m_currentProject) {
oldContext.add(d->m_currentProject->projectManager()->projectContext());
oldContext.add(d->m_currentProject->projectManager()->projectLanguage());
oldContext.add(d->m_currentProject->projectContext());
oldContext.add(d->m_currentProject->projectLanguage());
}
if (project) {
newContext.add(project->projectManager()->projectContext());
newContext.add(project->projectManager()->projectLanguage());
newContext.add(project->projectContext());
newContext.add(project->projectLanguage());
}
core->updateAdditionalContexts(oldContext, newContext);
......
......@@ -37,6 +37,7 @@
#include "fileformat/qmlprojectitem.h"
#include "qmlprojectrunconfiguration.h"
#include "qmlprojecttarget.h"
#include "qmlprojectconstants.h"
#include <coreplugin/icore.h>
#include <coreplugin/messagemanager.h>
......@@ -58,6 +59,9 @@ QmlProject::QmlProject(Internal::Manager *manager, const QString &fileName)
m_modelManager(ExtensionSystem::PluginManager::instance()->getObject<QmlJS::ModelManagerInterface>()),
m_fileWatcher(new ProjectExplorer::FileWatcher(this))
{
setProjectContext(Core::Context(QmlProjectManager::Constants::PROJECTCONTEXT));
setProjectLanguage(Core::Context(QmlProjectManager::Constants::LANG_QML));
QFileInfo fileInfo(m_fileName);
m_projectName = fileInfo.completeBaseName();
......
......@@ -49,19 +49,8 @@ namespace Internal {
Manager::Manager()
{
m_projectContext = Core::Context(QmlProjectManager::Constants::PROJECTCONTEXT);
m_projectLanguage = Core::Context(QmlProjectManager::Constants::LANG_QML);
}
Manager::~Manager()
{ }
Core::Context Manager::projectContext() const
{ return m_projectContext; }
Core::Context Manager::projectLanguage() const
{ return m_projectLanguage; }
QString Manager::mimeType() const
{ return QLatin1String(Constants::QMLMIMETYPE); }
......
......@@ -49,10 +49,6 @@ class Manager: public ProjectExplorer::IProjectManager
public:
Manager();
virtual ~Manager();
virtual Core::Context projectContext() const;
virtual Core::Context projectLanguage() const;
virtual QString mimeType() const;
virtual ProjectExplorer::Project *openProject(const QString &fileName);
......@@ -63,8 +59,6 @@ public:
void unregisterProject(QmlProject *project);
private:
Core::Context m_projectContext;
Core::Context m_projectLanguage;
QList<QmlProject *> m_projects;
};
......
......@@ -46,6 +46,7 @@
#include "qmldumptool.h"
#include <coreplugin/icore.h>
#include <coreplugin/icontext.h>
#include <coreplugin/messagemanager.h>
#include <coreplugin/coreconstants.h>
#include <coreplugin/progressmanager/progressmanager.h>
......@@ -57,6 +58,7 @@
#include <projectexplorer/buildenvironmentwidget.h>
#include <projectexplorer/customexecutablerunconfiguration.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <utils/qtcassert.h>
#include <QtCore/QDebug>
......@@ -261,6 +263,9 @@ Qt4Project::Qt4Project(Qt4Manager *manager, const QString& fileName) :
m_asyncUpdateState(NoState),
m_cancelEvaluate(false)
{
setProjectContext(Core::Context(Qt4ProjectManager::Constants::PROJECT_ID));
setProjectLanguage(Core::Context(ProjectExplorer::Constants::LANG_CXX));
m_asyncUpdateTimer.setSingleShot(true);
m_asyncUpdateTimer.setInterval(3000);
connect(&m_asyncUpdateTimer, SIGNAL(timeout()), this, SLOT(asyncUpdate()));
......
......@@ -203,16 +203,6 @@ void Qt4Manager::uiEditorContentsChanged()
m_dirty = true;
}
Core::Context Qt4Manager::projectContext() const
{
return m_plugin->projectContext();
}
Core::Context Qt4Manager::projectLanguage() const
{
return Core::Context(ProjectExplorer::Constants::LANG_CXX);
}
QString Qt4Manager::mimeType() const
{
return QLatin1String(Qt4ProjectManager::Constants::PROFILE_MIMETYPE);
......
......@@ -78,10 +78,6 @@ public:
ProjectExplorer::ProjectExplorerPlugin *projectExplorer() const;
// ProjectExplorer::IProjectManager
Core::Context projectContext() const;
Core::Context projectLanguage() const;
virtual QString mimeType() const;
ProjectExplorer::Project *openProject(const QString &fileName);
......
......@@ -108,7 +108,7 @@ Qt4ProjectManagerPlugin::~Qt4ProjectManagerPlugin()
bool Qt4ProjectManagerPlugin::initialize(const QStringList &arguments, QString *errorMessage)
{
Q_UNUSED(arguments)
m_projectContext = Core::Context(Qt4ProjectManager::Constants::PROJECT_ID);
const Core::Context projectContext(Qt4ProjectManager::Constants::PROJECT_ID);
ProFileParser::initialize();
ProFileEvaluator::initialize();
......@@ -199,13 +199,13 @@ bool Qt4ProjectManagerPlugin::initialize(const QStringList &arguments, QString *
QIcon qmakeIcon(QLatin1String(":/qt4projectmanager/images/run_qmake.png"));
qmakeIcon.addFile(QLatin1String(":/qt4projectmanager/images/run_qmake_small.png"));
m_runQMakeAction = new QAction(qmakeIcon, tr("Run qmake"), this);
command = am->registerAction(m_runQMakeAction, Constants::RUNQMAKE, m_projectContext);
command = am->registerAction(m_runQMakeAction, Constants::RUNQMAKE, projectContext);
command->setAttribute(Core::Command::CA_Hide);
mbuild->addAction(command, ProjectExplorer::Constants::G_BUILD_PROJECT);
connect(m_runQMakeAction, SIGNAL(triggered()), m_qt4ProjectManager, SLOT(runQMake()));
m_runQMakeActionContextMenu = new QAction(qmakeIcon, tr("Run qmake"), this);
command = am->registerAction(m_runQMakeActionContextMenu, Constants::RUNQMAKECONTEXTMENU, m_projectContext);
command = am->registerAction(m_runQMakeActionContextMenu, Constants::RUNQMAKECONTEXTMENU, projectContext);
command->setAttribute(Core::Command::CA_Hide);
mproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD);
msubproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD);
......@@ -214,7 +214,7 @@ bool Qt4ProjectManagerPlugin::initialize(const QStringList &arguments, QString *
QIcon buildIcon(ProjectExplorer::Constants::ICON_BUILD);
buildIcon.addFile(ProjectExplorer::Constants::ICON_BUILD_SMALL);
m_buildSubProjectContextMenu = new QAction(buildIcon, tr("Build"), this);
command = am->registerAction(m_buildSubProjectContextMenu, Constants::BUILDSUBDIR, m_projectContext);
command = am->registerAction(m_buildSubProjectContextMenu, Constants::BUILDSUBDIR, projectContext);
command->setAttribute(Core::Command::CA_Hide);
msubproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD);
connect(m_buildSubProjectContextMenu, SIGNAL(triggered()), m_qt4ProjectManager, SLOT(buildSubDirContextMenu()));
......@@ -222,7 +222,7 @@ bool Qt4ProjectManagerPlugin::initialize(const QStringList &arguments, QString *
QIcon rebuildIcon(ProjectExplorer::Constants::ICON_REBUILD);
rebuildIcon.addFile(ProjectExplorer::Constants::ICON_REBUILD_SMALL);
m_rebuildSubProjectContextMenu = new QAction(rebuildIcon, tr("Rebuild"), this);
command = am->registerAction(m_rebuildSubProjectContextMenu, Constants::REBUILDSUBDIR, m_projectContext);
command = am->registerAction(m_rebuildSubProjectContextMenu, Constants::REBUILDSUBDIR, projectContext);
command->setAttribute(Core::Command::CA_Hide);
msubproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD);
connect(m_rebuildSubProjectContextMenu, SIGNAL(triggered()), m_qt4ProjectManager, SLOT(rebuildSubDirContextMenu()));
......@@ -230,7 +230,7 @@ bool Qt4ProjectManagerPlugin::initialize(const QStringList &arguments, QString *
QIcon cleanIcon(ProjectExplorer::Constants::ICON_CLEAN);
cleanIcon.addFile(ProjectExplorer::Constants::ICON_CLEAN_SMALL);
m_cleanSubProjectContextMenu = new QAction(cleanIcon, tr("Clean"), this);
command = am->registerAction(m_cleanSubProjectContextMenu, Constants::CLEANSUBDIR, m_projectContext);
command = am->registerAction(m_cleanSubProjectContextMenu, Constants::CLEANSUBDIR, projectContext);
command->setAttribute(Core::Command::CA_Hide);
msubproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD);
connect(m_cleanSubProjectContextMenu, SIGNAL(triggered()), m_qt4ProjectManager, SLOT(cleanSubDirContextMenu()));
......
......@@ -65,8 +65,6 @@ public:
bool initialize(const QStringList &arguments, QString *error_message);
void extensionsInitialized();
Core::Context projectContext() const { return m_projectContext; }
private slots:
void updateContextMenu(ProjectExplorer::Project *project,
ProjectExplorer::Node *node);
......
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