forked from qt-creator/qt-creator
Use project id uniformly as project context
The possibly intented flexibility e.g. to have different project types
share the same idea of a common context was never used, in all cases
we had a 1:1 relation ship between project ids and ids that were used
as context. This led to oversights like the one fixed in 60fb35a2.
This patch here uses the project id unconditionally as context and
drops all context ids. If we'll ever have the situation where the
original flexibility was needed, Project::projectContext() could be
made virtual and overridden were needed.
Also, the context was never modified for any given project, so the
updating machinery is not needed.
Change-Id: I3f7fac0ed5e4704e126558987c48577f26082dfd
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -73,7 +73,6 @@ AutotoolsProject::AutotoolsProject(const Utils::FileName &fileName) :
|
||||
m_cppCodeModelUpdater(new CppTools::CppProjectUpdater(this))
|
||||
{
|
||||
setId(Constants::AUTOTOOLS_PROJECT_ID);
|
||||
setProjectContext(Core::Context(Constants::PROJECT_CONTEXT));
|
||||
setProjectLanguages(Core::Context(ProjectExplorer::Constants::CXX_LANGUAGE_ID));
|
||||
setDisplayName(projectDirectory().fileName());
|
||||
}
|
||||
|
||||
@@ -39,6 +39,5 @@ namespace Constants {
|
||||
|
||||
//Project
|
||||
const char AUTOTOOLS_PROJECT_ID[] = "AutotoolsProjectManager.AutotoolsProject";
|
||||
const char PROJECT_CONTEXT[] = "AutotoolsProject.ProjectContext";
|
||||
} // namespace Constants
|
||||
} // namespace AutotoolsProjectManager
|
||||
|
||||
@@ -84,8 +84,6 @@ CMakeProject::CMakeProject(const FileName &fileName) : Project(Constants::CMAKEM
|
||||
m_cppCodeModelUpdater(new CppTools::CppProjectUpdater(this))
|
||||
{
|
||||
setId(CMakeProjectManager::Constants::CMAKEPROJECT_ID);
|
||||
|
||||
setProjectContext(Core::Context(CMakeProjectManager::Constants::PROJECTCONTEXT));
|
||||
setProjectLanguages(Core::Context(ProjectExplorer::Constants::CXX_LANGUAGE_ID));
|
||||
setDisplayName(projectDirectory().fileName());
|
||||
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
namespace CMakeProjectManager {
|
||||
namespace Constants {
|
||||
|
||||
const char PROJECTCONTEXT[] = "CMakeProject.ProjectContext";
|
||||
const char CMAKEMIMETYPE[] = "text/x-cmake";
|
||||
const char CMAKEPROJECTMIMETYPE[] = "text/x-cmake-project";
|
||||
const char CMAKE_EDITOR_ID[] = "CMakeProject.CMakeEditor";
|
||||
|
||||
@@ -62,7 +62,7 @@ CMakeManager::CMakeManager() :
|
||||
Core::ActionContainer *msubproject =
|
||||
Core::ActionManager::actionContainer(ProjectExplorer::Constants::M_SUBPROJECTCONTEXT);
|
||||
|
||||
const Core::Context projectContext(CMakeProjectManager::Constants::PROJECTCONTEXT);
|
||||
const Core::Context projectContext(CMakeProjectManager::Constants::CMAKEPROJECT_ID);
|
||||
const Core::Context globalContext(Core::Constants::C_GLOBAL);
|
||||
|
||||
Core::Command *command = Core::ActionManager::registerAction(m_runCMakeAction,
|
||||
|
||||
@@ -58,7 +58,7 @@ using namespace ProjectExplorer;
|
||||
bool CMakeProjectPlugin::initialize(const QStringList & /*arguments*/, QString *errorMessage)
|
||||
{
|
||||
Q_UNUSED(errorMessage)
|
||||
const Context projectContext(Constants::PROJECTCONTEXT);
|
||||
const Context projectContext(CMakeProjectManager::Constants::CMAKEPROJECT_ID);
|
||||
|
||||
Core::FileIconProvider::registerIconOverlayForSuffix(Constants::FILEOVERLAY_CMAKE, "cmake");
|
||||
Core::FileIconProvider::registerIconOverlayForFilename(Constants::FILEOVERLAY_CMAKE, "CMakeLists.txt");
|
||||
|
||||
@@ -166,7 +166,6 @@ GenericProject::GenericProject(const Utils::FileName &fileName) :
|
||||
m_cppCodeModelUpdater(new CppTools::CppProjectUpdater(this))
|
||||
{
|
||||
setId(Constants::GENERICPROJECT_ID);
|
||||
setProjectContext(Context(GenericProjectManager::Constants::PROJECTCONTEXT));
|
||||
setProjectLanguages(Context(ProjectExplorer::Constants::CXX_LANGUAGE_ID));
|
||||
setDisplayName(fileName.toFileInfo().completeBaseName());
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
namespace GenericProjectManager {
|
||||
namespace Constants {
|
||||
|
||||
const char PROJECTCONTEXT[] = "GenericProject.ProjectContext";
|
||||
const char GENERICMIMETYPE[] = "text/x-generic-project"; // ### FIXME
|
||||
|
||||
// Contexts
|
||||
|
||||
@@ -73,7 +73,7 @@ bool GenericProjectPlugin::initialize(const QStringList &, QString *errorMessage
|
||||
|
||||
auto editFilesAction = new QAction(tr("Edit Files..."), this);
|
||||
Command *command = ActionManager::registerAction(editFilesAction,
|
||||
"GenericProjectManager.EditFiles", Context(Constants::PROJECTCONTEXT));
|
||||
"GenericProjectManager.EditFiles", Context(Constants::GENERICPROJECT_ID));
|
||||
command->setAttribute(Command::CA_Hide);
|
||||
mproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_FILES);
|
||||
|
||||
|
||||
@@ -167,7 +167,6 @@ public:
|
||||
QList<Target *> m_targets;
|
||||
Target *m_activeTarget = nullptr;
|
||||
EditorConfiguration m_editorConfiguration;
|
||||
Core::Context m_projectContext;
|
||||
Core::Context m_projectLanguages;
|
||||
QVariantMap m_pluginSettings;
|
||||
std::unique_ptr<Internal::UserFileAccessor> m_accessor;
|
||||
@@ -743,14 +742,6 @@ bool Project::isKnownFile(const Utils::FileName &filename) const
|
||||
return (it == end) ? false : (*it)->filePath() != filename;
|
||||
}
|
||||
|
||||
void Project::setProjectContext(Core::Context context)
|
||||
{
|
||||
if (d->m_projectContext == context)
|
||||
return;
|
||||
d->m_projectContext = context;
|
||||
emit projectContextUpdated();
|
||||
}
|
||||
|
||||
void Project::setProjectLanguages(Core::Context language)
|
||||
{
|
||||
if (d->m_projectLanguages == language)
|
||||
@@ -791,7 +782,7 @@ void Project::projectLoaded()
|
||||
|
||||
Core::Context Project::projectContext() const
|
||||
{
|
||||
return d->m_projectContext;
|
||||
return Core::Context(d->m_id);
|
||||
}
|
||||
|
||||
Core::Context Project::projectLanguages() const
|
||||
|
||||
@@ -210,7 +210,6 @@ signals:
|
||||
void settingsLoaded();
|
||||
void aboutToSaveSettings();
|
||||
|
||||
void projectContextUpdated();
|
||||
void projectLanguagesUpdated();
|
||||
|
||||
void parsingStarted();
|
||||
@@ -233,7 +232,6 @@ protected:
|
||||
|
||||
void setId(Core::Id id);
|
||||
void setRootProjectNode(ProjectNode *root); // takes ownership!
|
||||
void setProjectContext(Core::Context context);
|
||||
void setProjectLanguages(Core::Context language);
|
||||
void addProjectLanguage(Core::Id id);
|
||||
void removeProjectLanguage(Core::Id id);
|
||||
|
||||
@@ -189,8 +189,6 @@ void ProjectTree::setCurrent(Node *node, Project *project)
|
||||
const bool changedProject = project != m_currentProject;
|
||||
if (changedProject) {
|
||||
if (m_currentProject) {
|
||||
disconnect(m_currentProject, &Project::projectContextUpdated,
|
||||
this, &ProjectTree::updateContext);
|
||||
disconnect(m_currentProject, &Project::projectLanguagesUpdated,
|
||||
this, &ProjectTree::updateContext);
|
||||
}
|
||||
@@ -198,8 +196,6 @@ void ProjectTree::setCurrent(Node *node, Project *project)
|
||||
m_currentProject = project;
|
||||
|
||||
if (m_currentProject) {
|
||||
connect(m_currentProject, &Project::projectContextUpdated,
|
||||
this, &ProjectTree::updateContext);
|
||||
connect(m_currentProject, &Project::projectLanguagesUpdated,
|
||||
this, &ProjectTree::updateContext);
|
||||
}
|
||||
|
||||
@@ -74,7 +74,6 @@ const char InterpreterKey[] = "PythonEditor.RunConfiguation.Interpreter";
|
||||
const char MainScriptKey[] = "PythonEditor.RunConfiguation.MainScript";
|
||||
const char PythonMimeType[] = "text/x-python-project"; // ### FIXME
|
||||
const char PythonProjectId[] = "PythonProject";
|
||||
const char PythonProjectContext[] = "PythonProjectContext";
|
||||
|
||||
class PythonRunConfiguration;
|
||||
class PythonProjectFile;
|
||||
@@ -287,7 +286,6 @@ PythonProject::PythonProject(const FileName &fileName) :
|
||||
Project(Constants::C_PY_MIMETYPE, fileName, [this]() { refresh(); })
|
||||
{
|
||||
setId(PythonProjectId);
|
||||
setProjectContext(Context(PythonProjectContext));
|
||||
setProjectLanguages(Context(ProjectExplorer::Constants::CXX_LANGUAGE_ID));
|
||||
setDisplayName(fileName.toFileInfo().completeBaseName());
|
||||
}
|
||||
|
||||
@@ -131,8 +131,6 @@ QbsProject::QbsProject(const FileName &fileName) :
|
||||
m_parsingDelay.setInterval(1000); // delay parsing by 1s.
|
||||
|
||||
setId(Constants::PROJECT_ID);
|
||||
|
||||
setProjectContext(Context(Constants::PROJECT_ID));
|
||||
setProjectLanguages(Context(ProjectExplorer::Constants::CXX_LANGUAGE_ID));
|
||||
|
||||
rebuildProjectTree();
|
||||
|
||||
@@ -166,7 +166,6 @@ QmakeProject::QmakeProject(const FileName &fileName) :
|
||||
{
|
||||
s_projects.append(this);
|
||||
setId(Constants::QMAKEPROJECT_ID);
|
||||
setProjectContext(Core::Context(QmakeProjectManager::Constants::PROJECT_ID));
|
||||
setProjectLanguages(Core::Context(ProjectExplorer::Constants::CXX_LANGUAGE_ID));
|
||||
setRequiredKitPredicate(QtSupport::QtKitInformation::qtVersionPredicate());
|
||||
setDisplayName(fileName.toFileInfo().completeBaseName());
|
||||
|
||||
@@ -34,7 +34,6 @@ namespace Constants {
|
||||
const char M_CONTEXT[] = "ProFileEditor.ContextMenu";
|
||||
|
||||
// Kinds
|
||||
const char PROJECT_ID[] = "Qt4.Qt4Project";
|
||||
const char PROFILE_EDITOR_ID[] = "Qt4.proFileEditor";
|
||||
const char PROFILE_EDITOR_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("OpenWith::Editors", ".pro File Editor");
|
||||
const char PROFILE_MIMETYPE[] = "application/vnd.qt.qmakeprofile";
|
||||
|
||||
@@ -79,7 +79,7 @@ bool QmakeProjectManagerPlugin::initialize(const QStringList &arguments, QString
|
||||
{
|
||||
Q_UNUSED(arguments)
|
||||
Q_UNUSED(errorMessage)
|
||||
const Context projectContext(QmakeProjectManager::Constants::PROJECT_ID);
|
||||
const Context projectContext(QmakeProjectManager::Constants::QMAKEPROJECT_ID);
|
||||
Context projecTreeContext(ProjectExplorer::Constants::C_PROJECT_TREE);
|
||||
|
||||
//create and register objects
|
||||
|
||||
@@ -131,7 +131,7 @@ void FilesSelectionWizardPage::initializePage()
|
||||
|
||||
SimpleProjectWizard::SimpleProjectWizard()
|
||||
{
|
||||
setSupportedProjectTypes({Constants::PROJECT_ID});
|
||||
setSupportedProjectTypes({Constants::QMAKEPROJECT_ID});
|
||||
setIcon(QIcon(QLatin1String(":/qmakeprojectmanager/images/qmakeprojectmanager.png")));
|
||||
setDisplayName(tr("Import as qmake Project (Limited Functionality)"));
|
||||
setId("Z.DummyProFile");
|
||||
|
||||
@@ -59,7 +59,6 @@ QmlProject::QmlProject(const Utils::FileName &fileName) :
|
||||
[this]() { refreshProjectFile(); })
|
||||
{
|
||||
setId(QmlProjectManager::Constants::QML_PROJECT_ID);
|
||||
setProjectContext(Context(QmlProjectManager::Constants::PROJECTCONTEXT));
|
||||
setProjectLanguages(Context(ProjectExplorer::Constants::QMLJS_LANGUAGE_ID));
|
||||
setDisplayName(fileName.toFileInfo().completeBaseName());
|
||||
}
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
namespace QmlProjectManager {
|
||||
namespace Constants {
|
||||
|
||||
const char PROJECTCONTEXT[] = "QmlProject.ProjectContext";
|
||||
const char * const QMLPROJECT_MIMETYPE = QmlJSTools::Constants::QMLPROJECT_MIMETYPE;
|
||||
|
||||
} // namespace Constants
|
||||
|
||||
Reference in New Issue
Block a user