summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Hunger <tobias.hunger@qt.io>2017-03-29 11:11:49 +0200
committerTobias Hunger <tobias.hunger@qt.io>2017-03-29 11:03:34 +0000
commit348aa12eaa477f416b9ba32924a3312fdf26f1bd (patch)
tree01c08be4f42c248c62d821b95dcd5fea1730e4b9
parentdf64242ab2d25854686d406f8bdc392795c79de1 (diff)
downloadqt-creator-348aa12eaa477f416b9ba32924a3312fdf26f1bd.tar.gz
ProjectExplorer: Provide ProjectDocument and use it in all projects
Change-Id: I6e054ebf1043bd1f6748f1567f35c68394bd6528 Reviewed-by: hjk <hjk@qt.io>
-rw-r--r--src/plugins/autotoolsprojectmanager/autotoolsproject.cpp3
-rw-r--r--src/plugins/autotoolsprojectmanager/autotoolsprojectfile.cpp43
-rw-r--r--src/plugins/autotoolsprojectmanager/autotoolsprojectfile.h52
-rw-r--r--src/plugins/autotoolsprojectmanager/autotoolsprojectmanager.pro2
-rw-r--r--src/plugins/autotoolsprojectmanager/autotoolsprojectmanager.qbs2
-rw-r--r--src/plugins/cmakeprojectmanager/cmakeproject.cpp4
-rw-r--r--src/plugins/genericprojectmanager/genericproject.cpp53
-rw-r--r--src/plugins/genericprojectmanager/genericproject.h22
-rw-r--r--src/plugins/nim/project/nimproject.cpp4
-rw-r--r--src/plugins/projectexplorer/project.cpp36
-rw-r--r--src/plugins/projectexplorer/project.h25
-rw-r--r--src/plugins/pythoneditor/pythoneditorplugin.cpp34
-rw-r--r--src/plugins/qbsprojectmanager/qbsproject.cpp8
-rw-r--r--src/plugins/qbsprojectmanager/qbsprojectfile.cpp61
-rw-r--r--src/plugins/qbsprojectmanager/qbsprojectfile.h48
-rw-r--r--src/plugins/qbsprojectmanager/qbsprojectmanager.pro2
-rw-r--r--src/plugins/qbsprojectmanager/qbsprojectmanager.qbs2
-rw-r--r--src/plugins/qmakeprojectmanager/qmakeproject.cpp35
-rw-r--r--src/plugins/qmlprojectmanager/qmlproject.cpp5
-rw-r--r--src/plugins/qmlprojectmanager/qmlprojectfile.cpp63
-rw-r--r--src/plugins/qmlprojectmanager/qmlprojectfile.h49
-rw-r--r--src/plugins/qmlprojectmanager/qmlprojectmanager.pro2
-rw-r--r--src/plugins/qmlprojectmanager/qmlprojectmanager.qbs1
23 files changed, 80 insertions, 476 deletions
diff --git a/src/plugins/autotoolsprojectmanager/autotoolsproject.cpp b/src/plugins/autotoolsprojectmanager/autotoolsproject.cpp
index d7d389ed3a..e8b36cbf87 100644
--- a/src/plugins/autotoolsprojectmanager/autotoolsproject.cpp
+++ b/src/plugins/autotoolsprojectmanager/autotoolsproject.cpp
@@ -29,7 +29,6 @@
#include "autotoolsbuildconfiguration.h"
#include "autotoolsprojectconstants.h"
#include "autotoolsprojectnode.h"
-#include "autotoolsprojectfile.h"
#include "autotoolsopenprojectwizard.h"
#include "makestep.h"
#include "makefileparserthread.h"
@@ -73,7 +72,7 @@ AutotoolsProject::AutotoolsProject(const Utils::FileName &fileName) :
m_cppCodeModelUpdater(new CppTools::CppProjectUpdater(this))
{
setId(Constants::AUTOTOOLS_PROJECT_ID);
- setDocument(new AutotoolsProjectFile(fileName));
+ setDocument(new ProjectExplorer::ProjectDocument(Constants::MAKEFILE_MIMETYPE, fileName));
setProjectContext(Core::Context(Constants::PROJECT_CONTEXT));
setProjectLanguages(Core::Context(ProjectExplorer::Constants::CXX_LANGUAGE_ID));
}
diff --git a/src/plugins/autotoolsprojectmanager/autotoolsprojectfile.cpp b/src/plugins/autotoolsprojectmanager/autotoolsprojectfile.cpp
deleted file mode 100644
index 49a3d1e6ff..0000000000
--- a/src/plugins/autotoolsprojectmanager/autotoolsprojectfile.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 Openismus GmbH.
-** Author: Peter Penz (ppenz@openismus.com)
-** Author: Patricia Santana Cruz (patriciasantanacruz@gmail.com)
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt Creator.
-**
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-****************************************************************************/
-
-#include "autotoolsprojectfile.h"
-#include "autotoolsproject.h"
-#include "autotoolsprojectconstants.h"
-
-namespace AutotoolsProjectManager {
-namespace Internal {
-
-AutotoolsProjectFile::AutotoolsProjectFile(const Utils::FileName &fileName)
-{
- setId("Autotools.ProjectFile");
- setMimeType(QLatin1String(Constants::MAKEFILE_MIMETYPE));
- setFilePath(fileName);
-}
-
-} // namespace Internal
-} // namespace AutotoolsProjectManager
diff --git a/src/plugins/autotoolsprojectmanager/autotoolsprojectfile.h b/src/plugins/autotoolsprojectmanager/autotoolsprojectfile.h
deleted file mode 100644
index 8c41e19bd5..0000000000
--- a/src/plugins/autotoolsprojectmanager/autotoolsprojectfile.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 Openismus GmbH.
-** Author: Peter Penz (ppenz@openismus.com)
-** Author: Patricia Santana Cruz (patriciasantanacruz@gmail.com)
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt Creator.
-**
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-****************************************************************************/
-
-#pragma once
-
-#include <coreplugin/idocument.h>
-
-namespace AutotoolsProjectManager {
-namespace Internal {
-
-/**
- * @brief Implementation of the Core::IDocument interface.
- *
- * Is used in AutotoolsProject and describes the root
- * of a project. In the context of autotools the implementation
- * is mostly empty, as the modification of a project is
- * done by several Makefile.am files and the configure.ac file.
- *
- * @see AutotoolsProject
- */
-class AutotoolsProjectFile : public Core::IDocument
-{
-public:
- AutotoolsProjectFile(const Utils::FileName &fileName);
-};
-
-} // namespace Internal
-} // namespace AutotoolsProjectManager
diff --git a/src/plugins/autotoolsprojectmanager/autotoolsprojectmanager.pro b/src/plugins/autotoolsprojectmanager/autotoolsprojectmanager.pro
index 3e30bf328c..a58d556dda 100644
--- a/src/plugins/autotoolsprojectmanager/autotoolsprojectmanager.pro
+++ b/src/plugins/autotoolsprojectmanager/autotoolsprojectmanager.pro
@@ -2,7 +2,6 @@ include(../../qtcreatorplugin.pri)
HEADERS = autotoolsprojectplugin.h\
autotoolsopenprojectwizard.h\
- autotoolsprojectfile.h\
autotoolsprojectnode.h\
autotoolsproject.h\
autotoolsbuildsettingswidget.h\
@@ -16,7 +15,6 @@ HEADERS = autotoolsprojectplugin.h\
makefileparser.h
SOURCES = autotoolsprojectplugin.cpp\
autotoolsopenprojectwizard.cpp\
- autotoolsprojectfile.cpp\
autotoolsprojectnode.cpp\
autotoolsproject.cpp\
autotoolsbuildsettingswidget.cpp\
diff --git a/src/plugins/autotoolsprojectmanager/autotoolsprojectmanager.qbs b/src/plugins/autotoolsprojectmanager/autotoolsprojectmanager.qbs
index 8c76c5d41f..02ab46557c 100644
--- a/src/plugins/autotoolsprojectmanager/autotoolsprojectmanager.qbs
+++ b/src/plugins/autotoolsprojectmanager/autotoolsprojectmanager.qbs
@@ -25,8 +25,6 @@ QtcPlugin {
"autotoolsproject.cpp",
"autotoolsproject.h",
"autotoolsprojectconstants.h",
- "autotoolsprojectfile.cpp",
- "autotoolsprojectfile.h",
"autotoolsprojectnode.cpp",
"autotoolsprojectnode.h",
"autotoolsprojectplugin.cpp",
diff --git a/src/plugins/cmakeprojectmanager/cmakeproject.cpp b/src/plugins/cmakeprojectmanager/cmakeproject.cpp
index 85ddff7615..f850ee0af0 100644
--- a/src/plugins/cmakeprojectmanager/cmakeproject.cpp
+++ b/src/plugins/cmakeprojectmanager/cmakeproject.cpp
@@ -77,9 +77,7 @@ CMakeProject::CMakeProject(const FileName &fileName)
: m_cppCodeModelUpdater(new CppTools::CppProjectUpdater(this))
{
setId(CMakeProjectManager::Constants::CMAKEPROJECT_ID);
- auto doc = new TextEditor::TextDocument;
- doc->setFilePath(fileName);
- setDocument(doc);
+ setDocument(new ProjectDocument(CMakeProjectManager::Constants::CMAKEMIMETYPE, fileName));
setProjectContext(Core::Context(CMakeProjectManager::Constants::PROJECTCONTEXT));
setProjectLanguages(Core::Context(ProjectExplorer::Constants::CXX_LANGUAGE_ID));
diff --git a/src/plugins/genericprojectmanager/genericproject.cpp b/src/plugins/genericprojectmanager/genericproject.cpp
index 8d70582f50..b991793e76 100644
--- a/src/plugins/genericprojectmanager/genericproject.cpp
+++ b/src/plugins/genericprojectmanager/genericproject.cpp
@@ -69,7 +69,8 @@ GenericProject::GenericProject(const Utils::FileName &fileName)
: m_cppCodeModelUpdater(new CppTools::CppProjectUpdater(this))
{
setId(Constants::GENERICPROJECT_ID);
- setDocument(new GenericProjectFile(this, fileName, GenericProject::Everything));
+ setDocument(new ProjectDocument(Constants::GENERICMIMETYPE, fileName,
+ [this]() { refresh(Everything); }));
setProjectContext(Context(GenericProjectManager::Constants::PROJECTCONTEXT));
setProjectLanguages(Context(ProjectExplorer::Constants::CXX_LANGUAGE_ID));
@@ -82,14 +83,15 @@ GenericProject::GenericProject(const Utils::FileName &fileName)
m_includesFileName = QFileInfo(dir, projectName + ".includes").absoluteFilePath();
m_configFileName = QFileInfo(dir, projectName + ".config").absoluteFilePath();
- m_filesIDocument = new GenericProjectFile(this, FileName::fromString(m_filesFileName), GenericProject::Files);
- m_includesIDocument = new GenericProjectFile(this, FileName::fromString(m_includesFileName), GenericProject::Configuration);
- m_configIDocument = new GenericProjectFile(this, FileName::fromString(m_configFileName), GenericProject::Configuration);
-
- DocumentManager::addDocument(document());
- DocumentManager::addDocument(m_filesIDocument);
- DocumentManager::addDocument(m_includesIDocument);
- DocumentManager::addDocument(m_configIDocument);
+ m_filesIDocument
+ = new ProjectDocument(Constants::GENERICMIMETYPE, FileName::fromString(m_filesFileName),
+ [this]() { refresh(Files); });
+ m_includesIDocument
+ = new ProjectDocument(Constants::GENERICMIMETYPE, FileName::fromString(m_includesFileName),
+ [this]() { refresh(Configuration); });
+ m_configIDocument
+ = new ProjectDocument(Constants::GENERICMIMETYPE, FileName::fromString(m_configFileName),
+ [this]() { refresh(Configuration); });
}
GenericProject::~GenericProject()
@@ -441,38 +443,5 @@ Project::RestoreResult GenericProject::fromMap(const QVariantMap &map, QString *
return RestoreResult::Ok;
}
-////////////////////////////////////////////////////////////////////////////////////
-//
-// GenericProjectFile
-//
-////////////////////////////////////////////////////////////////////////////////////
-
-GenericProjectFile::GenericProjectFile(GenericProject *parent, const Utils::FileName &fileName,
- GenericProject::RefreshOptions options) :
- m_project(parent),
- m_options(options)
-{
- setId("Generic.ProjectFile");
- setMimeType(Constants::GENERICMIMETYPE);
- setFilePath(fileName);
-}
-
-IDocument::ReloadBehavior GenericProjectFile::reloadBehavior(ChangeTrigger state, ChangeType type) const
-{
- Q_UNUSED(state);
- Q_UNUSED(type);
- return BehaviorSilent;
-}
-
-bool GenericProjectFile::reload(QString *errorString, ReloadFlag flag, ChangeType type)
-{
- Q_UNUSED(errorString);
- Q_UNUSED(flag);
- if (type == TypePermissions)
- return true;
- m_project->refresh(m_options);
- return true;
-}
-
} // namespace Internal
} // namespace GenericProjectManager
diff --git a/src/plugins/genericprojectmanager/genericproject.h b/src/plugins/genericprojectmanager/genericproject.h
index a2d163328d..c5edbed21c 100644
--- a/src/plugins/genericprojectmanager/genericproject.h
+++ b/src/plugins/genericprojectmanager/genericproject.h
@@ -41,8 +41,6 @@ namespace CppTools { class CppProjectUpdater; }
namespace GenericProjectManager {
namespace Internal {
-class GenericProjectFile;
-
class GenericProject : public ProjectExplorer::Project
{
Q_OBJECT
@@ -91,9 +89,9 @@ private:
QString m_filesFileName;
QString m_includesFileName;
QString m_configFileName;
- GenericProjectFile *m_filesIDocument;
- GenericProjectFile *m_includesIDocument;
- GenericProjectFile *m_configIDocument;
+ ProjectExplorer::ProjectDocument *m_filesIDocument;
+ ProjectExplorer::ProjectDocument *m_includesIDocument;
+ ProjectExplorer::ProjectDocument *m_configIDocument;
QStringList m_rawFileList;
QStringList m_files;
QHash<QString, QString> m_rawListEntries;
@@ -105,19 +103,5 @@ private:
ProjectExplorer::Target *m_activeTarget = nullptr;
};
-class GenericProjectFile : public Core::IDocument
-{
-public:
- GenericProjectFile(GenericProject *parent, const Utils::FileName &fileName,
- GenericProject::RefreshOptions options);
-
- ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const override;
- bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override;
-
-private:
- GenericProject *m_project;
- GenericProject::RefreshOptions m_options;
-};
-
} // namespace Internal
} // namespace GenericProjectManager
diff --git a/src/plugins/nim/project/nimproject.cpp b/src/plugins/nim/project/nimproject.cpp
index 35795954eb..483edfc7be 100644
--- a/src/plugins/nim/project/nimproject.cpp
+++ b/src/plugins/nim/project/nimproject.cpp
@@ -57,9 +57,7 @@ const int MIN_TIME_BETWEEN_PROJECT_SCANS = 4500;
NimProject::NimProject(const FileName &fileName)
{
setId(Constants::C_NIMPROJECT_ID);
- auto doc = new TextEditor::TextDocument;
- doc->setFilePath(fileName);
- setDocument(doc);
+ setDocument(new ProjectDocument(Constants::C_NIM_MIMETYPE, fileName));
m_projectScanTimer.setSingleShot(true);
connect(&m_projectScanTimer, &QTimer::timeout, this, &NimProject::collectProjectFiles);
diff --git a/src/plugins/projectexplorer/project.cpp b/src/plugins/projectexplorer/project.cpp
index cf01c42801..38be84ad80 100644
--- a/src/plugins/projectexplorer/project.cpp
+++ b/src/plugins/projectexplorer/project.cpp
@@ -37,6 +37,7 @@
#include "settingsaccessor.h"
#include <coreplugin/idocument.h>
+#include <coreplugin/documentmanager.h>
#include <coreplugin/icontext.h>
#include <coreplugin/icore.h>
#include <coreplugin/iversioncontrol.h>
@@ -84,6 +85,41 @@ const char PLUGIN_SETTINGS_KEY[] = "ProjectExplorer.Project.PluginSettings";
namespace ProjectExplorer {
+// --------------------------------------------------------------------
+// ProjectDocument:
+// --------------------------------------------------------------------
+
+ProjectDocument::ProjectDocument(const QString &mimeType, const Utils::FileName &fileName,
+ const ProjectDocument::ProjectCallback &callback) :
+ m_callback(callback)
+{
+ setFilePath(fileName);
+ setMimeType(mimeType);
+ if (m_callback)
+ Core::DocumentManager::addDocument(this);
+}
+
+Core::IDocument::ReloadBehavior
+ProjectDocument::reloadBehavior(Core::IDocument::ChangeTrigger state,
+ Core::IDocument::ChangeType type) const
+{
+ Q_UNUSED(state);
+ Q_UNUSED(type);
+ return BehaviorSilent;
+}
+
+bool ProjectDocument::reload(QString *errorString, Core::IDocument::ReloadFlag flag,
+ Core::IDocument::ChangeType type)
+{
+ Q_UNUSED(errorString);
+ Q_UNUSED(flag);
+ Q_UNUSED(type);
+
+ if (m_callback)
+ m_callback();
+ return true;
+}
+
// -------------------------------------------------------------------------
// Project
// -------------------------------------------------------------------------
diff --git a/src/plugins/projectexplorer/project.h b/src/plugins/projectexplorer/project.h
index 87af5aaa5f..a54828e54d 100644
--- a/src/plugins/projectexplorer/project.h
+++ b/src/plugins/projectexplorer/project.h
@@ -30,6 +30,7 @@
#include "kit.h"
#include <coreplugin/id.h>
+#include <coreplugin/idocument.h>
#include <utils/fileutils.h>
@@ -38,11 +39,7 @@
#include <functional>
-namespace Core {
-class IDocument;
-class Context;
-}
-
+namespace Core { class Context; }
namespace Utils { class MacroExpander; }
namespace ProjectExplorer {
@@ -58,6 +55,24 @@ class ProjectPrivate;
class Session;
class Target;
+// Auto-registers with the DocumentManager if a callback is set!
+class PROJECTEXPLORER_EXPORT ProjectDocument : public Core::IDocument
+{
+public:
+ using ProjectCallback = std::function<void()>;
+
+ ProjectDocument(const QString &mimeType, const Utils::FileName &fileName,
+ const ProjectCallback &callback = {});
+
+ Core::IDocument::ReloadBehavior reloadBehavior(Core::IDocument::ChangeTrigger state,
+ Core::IDocument::ChangeType type) const final;
+ bool reload(QString *errorString, Core::IDocument::ReloadFlag flag,
+ Core::IDocument::ChangeType type) final;
+
+private:
+ ProjectCallback m_callback;
+};
+
// Documentation inside.
class PROJECTEXPLORER_EXPORT Project : public QObject
{
diff --git a/src/plugins/pythoneditor/pythoneditorplugin.cpp b/src/plugins/pythoneditor/pythoneditorplugin.cpp
index 967c5f58a6..7dbe7953ff 100644
--- a/src/plugins/pythoneditor/pythoneditorplugin.cpp
+++ b/src/plugins/pythoneditor/pythoneditorplugin.cpp
@@ -116,37 +116,6 @@ private:
QHash<QString, QString> m_rawListEntries;
};
-class PythonProjectFile : public Core::IDocument
-{
-public:
- PythonProjectFile(PythonProject *parent, const FileName &fileName) : m_project(parent)
- {
- setId("Generic.ProjectFile");
- setMimeType(PythonMimeType);
- setFilePath(fileName);
- }
-
- ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const override
- {
- Q_UNUSED(state)
- Q_UNUSED(type)
- return BehaviorSilent;
- }
-
- bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override
- {
- Q_UNUSED(errorString)
- Q_UNUSED(flag)
- if (type == TypePermissions)
- return true;
- m_project->refresh();
- return true;
- }
-
-private:
- PythonProject *m_project;
-};
-
class PythonProjectNode : public ProjectNode
{
public:
@@ -409,8 +378,7 @@ private:
PythonProject::PythonProject(const FileName &fileName)
{
setId(PythonProjectId);
- setDocument(new PythonProjectFile(this, fileName));
- DocumentManager::addDocument(document());
+ setDocument(new ProjectDocument(Constants::C_PY_MIMETYPE, fileName, [this]() { refresh(); }));
setProjectContext(Context(PythonProjectContext));
setProjectLanguages(Context(ProjectExplorer::Constants::CXX_LANGUAGE_ID));
diff --git a/src/plugins/qbsprojectmanager/qbsproject.cpp b/src/plugins/qbsprojectmanager/qbsproject.cpp
index 56c326896e..145d78b71b 100644
--- a/src/plugins/qbsprojectmanager/qbsproject.cpp
+++ b/src/plugins/qbsprojectmanager/qbsproject.cpp
@@ -28,7 +28,6 @@
#include "qbsbuildconfiguration.h"
#include "qbslogsink.h"
#include "qbspmlogging.h"
-#include "qbsprojectfile.h"
#include "qbsprojectparser.h"
#include "qbsprojectmanagerconstants.h"
#include "qbsnodes.h"
@@ -128,8 +127,7 @@ QbsProject::QbsProject(const FileName &fileName) :
m_parsingDelay.setInterval(1000); // delay parsing by 1s.
setId(Constants::PROJECT_ID);
- setDocument(new QbsProjectFile(this, fileName));
- DocumentManager::addDocument(document());
+ setDocument(new ProjectDocument(Constants::MIME_TYPE, fileName, [this]() { delayParsing(); }));
setProjectContext(Context(Constants::PROJECT_ID));
setProjectLanguages(Context(ProjectExplorer::Constants::CXX_LANGUAGE_ID));
@@ -710,9 +708,9 @@ void QbsProject::updateDocuments(const QSet<QString> &files)
}
QSet<IDocument *> toAdd;
foreach (const QString &f, filesToAdd)
- toAdd.insert(new QbsProjectFile(this, FileName::fromString(f)));
+ toAdd.insert(new ProjectDocument(Constants::MIME_TYPE, FileName::fromString(f),
+ [this]() { delayParsing(); }));
- DocumentManager::addDocuments(toAdd.toList());
m_qbsDocuments.unite(toAdd);
}
diff --git a/src/plugins/qbsprojectmanager/qbsprojectfile.cpp b/src/plugins/qbsprojectmanager/qbsprojectfile.cpp
deleted file mode 100644
index 59dbff968f..0000000000
--- a/src/plugins/qbsprojectmanager/qbsprojectfile.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt Creator.
-**
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-****************************************************************************/
-
-#include "qbsprojectfile.h"
-
-#include "qbsproject.h"
-#include "qbsprojectmanagerconstants.h"
-
-namespace QbsProjectManager {
-namespace Internal {
-
-QbsProjectFile::QbsProjectFile(QbsProject *parent, const Utils::FileName &fileName) : Core::IDocument(parent),
- m_project(parent)
-{
- setId("Qbs.ProjectFile");
- setMimeType(Constants::MIME_TYPE);
- setFilePath(fileName);
-}
-
-Core::IDocument::ReloadBehavior QbsProjectFile::reloadBehavior(ChangeTrigger state, ChangeType type) const
-{
- Q_UNUSED(state);
- Q_UNUSED(type);
- return BehaviorSilent;
-}
-
-bool QbsProjectFile::reload(QString *errorString, ReloadFlag flag, ChangeType type)
-{
- Q_UNUSED(errorString)
- Q_UNUSED(flag)
- if (type == TypePermissions)
- return true;
- m_project->delayParsing();
- return true;
-}
-
-} // namespace Internal
-} // namespace QbsProjectManager
-
diff --git a/src/plugins/qbsprojectmanager/qbsprojectfile.h b/src/plugins/qbsprojectmanager/qbsprojectfile.h
deleted file mode 100644
index b0879fcee2..0000000000
--- a/src/plugins/qbsprojectmanager/qbsprojectfile.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt Creator.
-**
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-****************************************************************************/
-
-#pragma once
-
-#include <coreplugin/idocument.h>
-
-namespace QbsProjectManager {
-namespace Internal {
-
-class QbsProject;
-
-class QbsProjectFile : public Core::IDocument
-{
-public:
- QbsProjectFile(QbsProject *parent, const Utils::FileName &fileName);
-
- ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const override;
- bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override;
-
-private:
- QbsProject *m_project;
-};
-
-} // namespace Internal
-} // namespace QbsProjectManager
diff --git a/src/plugins/qbsprojectmanager/qbsprojectmanager.pro b/src/plugins/qbsprojectmanager/qbsprojectmanager.pro
index de973943d6..465bad1d2c 100644
--- a/src/plugins/qbsprojectmanager/qbsprojectmanager.pro
+++ b/src/plugins/qbsprojectmanager/qbsprojectmanager.pro
@@ -34,7 +34,6 @@ HEADERS = \
qbspmlogging.h \
qbsprofilessettingspage.h \
qbsproject.h \
- qbsprojectfile.h \
qbsprojectmanager.h \
qbsprojectmanager_global.h \
qbsprojectmanagerconstants.h \
@@ -59,7 +58,6 @@ SOURCES = \
qbspmlogging.cpp \
qbsprofilessettingspage.cpp \
qbsproject.cpp \
- qbsprojectfile.cpp \
qbsprojectmanager.cpp \
qbsprojectmanagerplugin.cpp \
qbsprojectmanagersettings.cpp \
diff --git a/src/plugins/qbsprojectmanager/qbsprojectmanager.qbs b/src/plugins/qbsprojectmanager/qbsprojectmanager.qbs
index 8bbbfaf766..120a3cae3b 100644
--- a/src/plugins/qbsprojectmanager/qbsprojectmanager.qbs
+++ b/src/plugins/qbsprojectmanager/qbsprojectmanager.qbs
@@ -94,8 +94,6 @@ QtcPlugin {
"qbsprofilessettingswidget.ui",
"qbsproject.cpp",
"qbsproject.h",
- "qbsprojectfile.cpp",
- "qbsprojectfile.h",
"qbsprojectmanager.cpp",
"qbsprojectmanager.h",
"qbsprojectmanager.qrc",
diff --git a/src/plugins/qmakeprojectmanager/qmakeproject.cpp b/src/plugins/qmakeprojectmanager/qmakeproject.cpp
index f6a5d8a5d6..3ca2d9ea8a 100644
--- a/src/plugins/qmakeprojectmanager/qmakeproject.cpp
+++ b/src/plugins/qmakeprojectmanager/qmakeproject.cpp
@@ -74,15 +74,6 @@ using namespace Utils;
namespace QmakeProjectManager {
namespace Internal {
-class QmakeProjectFile : public Core::IDocument
-{
-public:
- explicit QmakeProjectFile(const FileName &fileName);
-
- ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const override;
- bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override;
-};
-
/// Watches folders for QmakePriFile nodes
/// use one file system watcher to watch all folders
/// such minimizing system ressouce usage
@@ -156,30 +147,6 @@ QDebug operator<<(QDebug d, const QmakeProjectFiles &f)
return d;
}
-// ----------- QmakeProjectFile
-
-QmakeProjectFile::QmakeProjectFile(const FileName &fileName)
-{
- setId("Qmake.ProFile");
- setMimeType(QmakeProjectManager::Constants::PROFILE_MIMETYPE);
- setFilePath(fileName);
-}
-
-Core::IDocument::ReloadBehavior QmakeProjectFile::reloadBehavior(ChangeTrigger state, ChangeType type) const
-{
- Q_UNUSED(state)
- Q_UNUSED(type)
- return BehaviorSilent;
-}
-
-bool QmakeProjectFile::reload(QString *errorString, ReloadFlag flag, ChangeType type)
-{
- Q_UNUSED(errorString)
- Q_UNUSED(flag)
- Q_UNUSED(type)
- return true;
-}
-
static QList<QmakeProject *> s_projects;
} // namespace Internal
@@ -196,7 +163,7 @@ QmakeProject::QmakeProject(const FileName &fileName) :
{
s_projects.append(this);
setId(Constants::QMAKEPROJECT_ID);
- setDocument(new QmakeProjectFile(fileName));
+ setDocument(new ProjectDocument(QmakeProjectManager::Constants::PROFILE_MIMETYPE, fileName));
setProjectContext(Core::Context(QmakeProjectManager::Constants::PROJECT_ID));
setProjectLanguages(Core::Context(ProjectExplorer::Constants::CXX_LANGUAGE_ID));
setRequiredKitPredicate(QtSupport::QtKitInformation::qtVersionPredicate());
diff --git a/src/plugins/qmlprojectmanager/qmlproject.cpp b/src/plugins/qmlprojectmanager/qmlproject.cpp
index 43fbe6ab56..096fca8a2f 100644
--- a/src/plugins/qmlprojectmanager/qmlproject.cpp
+++ b/src/plugins/qmlprojectmanager/qmlproject.cpp
@@ -24,7 +24,6 @@
****************************************************************************/
#include "qmlproject.h"
-#include "qmlprojectfile.h"
#include "fileformat/qmlprojectfileformat.h"
#include "fileformat/qmlprojectitem.h"
#include "qmlprojectrunconfiguration.h"
@@ -59,8 +58,8 @@ QmlProject::QmlProject(const Utils::FileName &fileName) :
m_defaultImport(UnknownImport)
{
setId("QmlProjectManager.QmlProject");
- setDocument(new Internal::QmlProjectFile(this, fileName));
- DocumentManager::addDocument(document(), true);
+ setDocument(new ProjectDocument(QString::fromLatin1(Constants::QMLPROJECT_MIMETYPE), fileName,
+ [this]() { refreshProjectFile(); }));
setProjectContext(Context(QmlProjectManager::Constants::PROJECTCONTEXT));
setProjectLanguages(Context(ProjectExplorer::Constants::QMLJS_LANGUAGE_ID));
diff --git a/src/plugins/qmlprojectmanager/qmlprojectfile.cpp b/src/plugins/qmlprojectmanager/qmlprojectfile.cpp
deleted file mode 100644
index 3794f1d11a..0000000000
--- a/src/plugins/qmlprojectmanager/qmlprojectfile.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt Creator.
-**
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-****************************************************************************/
-
-#include "qmlprojectfile.h"
-#include "qmlproject.h"
-#include "qmlprojectconstants.h"
-#include <utils/qtcassert.h>
-
-namespace QmlProjectManager {
-namespace Internal {
-
-QmlProjectFile::QmlProjectFile(QmlProject *parent, const Utils::FileName &fileName) :
- m_project(parent)
-{
- QTC_CHECK(m_project);
- QTC_CHECK(!fileName.isEmpty());
- setId("Qml.ProjectFile");
- setMimeType(QLatin1String(Constants::QMLPROJECT_MIMETYPE));
- setFilePath(fileName);
-}
-
-Core::IDocument::ReloadBehavior QmlProjectFile::reloadBehavior(ChangeTrigger state, ChangeType type) const
-{
- Q_UNUSED(state)
- Q_UNUSED(type)
- return BehaviorSilent;
-}
-
-bool QmlProjectFile::reload(QString *errorString, ReloadFlag flag, ChangeType type)
-{
- Q_UNUSED(errorString)
- Q_UNUSED(flag)
-
- if (type == TypeContents)
- m_project->refreshProjectFile();
-
- return true;
-}
-
-} // namespace Internal
-} // namespace QmlProjectManager
diff --git a/src/plugins/qmlprojectmanager/qmlprojectfile.h b/src/plugins/qmlprojectmanager/qmlprojectfile.h
deleted file mode 100644
index 90805fa018..0000000000
--- a/src/plugins/qmlprojectmanager/qmlprojectfile.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt Creator.
-**
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-****************************************************************************/
-
-#pragma once
-
-#include <coreplugin/idocument.h>
-
-namespace QmlProjectManager {
-
-class QmlProject;
-
-namespace Internal {
-
-class QmlProjectFile : public Core::IDocument
-{
-public:
- QmlProjectFile(QmlProject *parent, const Utils::FileName &fileName);
-
- ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const override;
- bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override;
-
-private:
- QmlProject *m_project;
-};
-
-} // namespace Internal
-} // namespace QmlProjectManager
diff --git a/src/plugins/qmlprojectmanager/qmlprojectmanager.pro b/src/plugins/qmlprojectmanager/qmlprojectmanager.pro
index a28281a17d..2a12d7a631 100644
--- a/src/plugins/qmlprojectmanager/qmlprojectmanager.pro
+++ b/src/plugins/qmlprojectmanager/qmlprojectmanager.pro
@@ -9,7 +9,6 @@ HEADERS += qmlproject.h \
qmlprojectplugin.h \
qmlprojectconstants.h \
qmlprojectnodes.h \
- qmlprojectfile.h \
qmlprojectrunconfiguration.h \
qmlprojectrunconfigurationfactory.h \
qmlprojectmanager_global.h \
@@ -20,7 +19,6 @@ SOURCES += qmlproject.cpp \
qmlprojectenvironmentaspect.cpp \
qmlprojectplugin.cpp \
qmlprojectnodes.cpp \
- qmlprojectfile.cpp \
qmlprojectrunconfiguration.cpp \
qmlprojectrunconfigurationfactory.cpp \
qmlprojectrunconfigurationwidget.cpp
diff --git a/src/plugins/qmlprojectmanager/qmlprojectmanager.qbs b/src/plugins/qmlprojectmanager/qmlprojectmanager.qbs
index a033afb338..b6dcdcd5f5 100644
--- a/src/plugins/qmlprojectmanager/qmlprojectmanager.qbs
+++ b/src/plugins/qmlprojectmanager/qmlprojectmanager.qbs
@@ -18,7 +18,6 @@ QtcPlugin {
"qmlproject.qrc",
"qmlprojectconstants.h",
"qmlprojectenvironmentaspect.cpp", "qmlprojectenvironmentaspect.h",
- "qmlprojectfile.cpp", "qmlprojectfile.h",
"qmlprojectmanager_global.h",
"qmlprojectmanagerconstants.h",
"qmlprojectnodes.cpp", "qmlprojectnodes.h",