Commit b0c7bb0f authored by Tobias Hunger's avatar Tobias Hunger
Browse files

Project: Move ProjectDocument setup into Project class



Change-Id: I5c0ec79ddf066e37660fb9a6b24f9d882355d511
Reviewed-by: default avatarhjk <hjk@qt.io>
parent 6829e33d
......@@ -68,11 +68,11 @@ using namespace AutotoolsProjectManager::Internal;
using namespace ProjectExplorer;
AutotoolsProject::AutotoolsProject(const Utils::FileName &fileName) :
Project(Constants::MAKEFILE_MIMETYPE, fileName),
m_fileWatcher(new Utils::FileSystemWatcher(this)),
m_cppCodeModelUpdater(new CppTools::CppProjectUpdater(this))
{
setId(Constants::AUTOTOOLS_PROJECT_ID);
setDocument(new ProjectExplorer::ProjectDocument(Constants::MAKEFILE_MIMETYPE, fileName));
setProjectContext(Core::Context(Constants::PROJECT_CONTEXT));
setProjectLanguages(Core::Context(ProjectExplorer::Constants::CXX_LANGUAGE_ID));
}
......
......@@ -73,12 +73,10 @@ using namespace Internal;
/*!
\class CMakeProject
*/
CMakeProject::CMakeProject(const FileName &fileName)
: m_cppCodeModelUpdater(new CppTools::CppProjectUpdater(this))
CMakeProject::CMakeProject(const FileName &fileName) : Project(Constants::CMAKEMIMETYPE, fileName),
m_cppCodeModelUpdater(new CppTools::CppProjectUpdater(this))
{
setId(CMakeProjectManager::Constants::CMAKEPROJECT_ID);
setDocument(new ProjectDocument(CMakeProjectManager::Constants::CMAKEMIMETYPE, fileName));
setProjectContext(Core::Context(CMakeProjectManager::Constants::PROJECTCONTEXT));
setProjectLanguages(Core::Context(ProjectExplorer::Constants::CXX_LANGUAGE_ID));
......
......@@ -36,7 +36,9 @@
using namespace CppTools::Internal;
using namespace CppTools::Tests;
TestProject::TestProject(const QString &name, QObject *parent) : m_name (name)
TestProject::TestProject(const QString &name, QObject *parent) :
ProjectExplorer::Project("x-binary/foo", Utils::FileName()),
m_name(name)
{
setParent(parent);
setId(Core::Id::fromString(name));
......
......@@ -65,12 +65,11 @@ namespace Internal {
//
////////////////////////////////////////////////////////////////////////////////////
GenericProject::GenericProject(const Utils::FileName &fileName)
: m_cppCodeModelUpdater(new CppTools::CppProjectUpdater(this))
GenericProject::GenericProject(const Utils::FileName &fileName) :
Project(Constants::GENERICMIMETYPE, fileName, [this]() { refresh(Everything); }),
m_cppCodeModelUpdater(new CppTools::CppProjectUpdater(this))
{
setId(Constants::GENERICPROJECT_ID);
setDocument(new ProjectDocument(Constants::GENERICMIMETYPE, fileName,
[this]() { refresh(Everything); }));
setProjectContext(Context(GenericProjectManager::Constants::PROJECTCONTEXT));
setProjectLanguages(Context(ProjectExplorer::Constants::CXX_LANGUAGE_ID));
......
......@@ -54,10 +54,9 @@ namespace Nim {
const int MIN_TIME_BETWEEN_PROJECT_SCANS = 4500;
NimProject::NimProject(const FileName &fileName)
NimProject::NimProject(const FileName &fileName) : Project(Constants::C_NIM_MIMETYPE, fileName)
{
setId(Constants::C_NIMPROJECT_ID);
setDocument(new ProjectDocument(Constants::C_NIM_MIMETYPE, fileName));
m_projectScanTimer.setSingleShot(true);
connect(&m_projectScanTimer, &QTimer::timeout, this, &NimProject::collectProjectFiles);
......
......@@ -126,7 +126,9 @@ bool ProjectDocument::reload(QString *errorString, Core::IDocument::ReloadFlag f
class ProjectPrivate
{
public:
ProjectPrivate(Project *owner) : m_containerNode(owner) {}
ProjectPrivate(Project *owner, Core::IDocument *document) :
m_document(document), m_containerNode(owner)
{ }
~ProjectPrivate();
Core::Id m_id;
......@@ -158,7 +160,9 @@ ProjectPrivate::~ProjectPrivate()
delete m_accessor;
}
Project::Project() : d(new ProjectPrivate(this))
Project::Project(const QString &mimeType, const Utils::FileName &fileName,
const ProjectDocument::ProjectCallback &callback) :
d(new ProjectPrivate(this, new ProjectDocument(mimeType, fileName, callback)))
{
d->m_macroExpander.setDisplayName(tr("Project"));
d->m_macroExpander.registerVariable("Project:Name", tr("Project Name"),
......@@ -453,13 +457,6 @@ void Project::setId(Core::Id id)
d->m_id = id;
}
void Project::setDocument(Core::IDocument *doc)
{
QTC_ASSERT(doc, return);
QTC_ASSERT(!d->m_document, return);
d->m_document = doc;
}
void Project::setRootProjectNode(ProjectNode *root)
{
if (d->m_rootProjectNode == root)
......
......@@ -88,7 +88,8 @@ public:
EnabledRole
};
Project();
Project(const QString &mimeType, const Utils::FileName &fileName,
const ProjectDocument::ProjectCallback &callback = {});
~Project() override;
virtual QString displayName() const = 0;
......@@ -193,7 +194,6 @@ protected:
void setPreferredKitPredicate(const Kit::Predicate &predicate);
void setId(Core::Id id);
void setDocument(Core::IDocument *doc); // takes ownership!
void setRootProjectNode(ProjectNode *root); // takes ownership!
void setProjectContext(Core::Context context);
void setProjectLanguages(Core::Context language);
......
......@@ -375,11 +375,10 @@ private:
}
};
PythonProject::PythonProject(const FileName &fileName)
PythonProject::PythonProject(const FileName &fileName) :
Project(Constants::C_PY_MIMETYPE, fileName, [this]() { refresh(); })
{
setId(PythonProjectId);
setDocument(new ProjectDocument(Constants::C_PY_MIMETYPE, fileName, [this]() { refresh(); }));
setProjectContext(Context(PythonProjectContext));
setProjectLanguages(Context(ProjectExplorer::Constants::CXX_LANGUAGE_ID));
}
......
......@@ -116,6 +116,7 @@ private:
// --------------------------------------------------------------------
QbsProject::QbsProject(const FileName &fileName) :
Project(Constants::MIME_TYPE, fileName, [this]() { delayParsing(); }),
m_qbsProjectParser(0),
m_qbsUpdateFutureInterface(0),
m_parsingScheduled(false),
......@@ -127,7 +128,6 @@ QbsProject::QbsProject(const FileName &fileName) :
m_parsingDelay.setInterval(1000); // delay parsing by 1s.
setId(Constants::PROJECT_ID);
setDocument(new ProjectDocument(Constants::MIME_TYPE, fileName, [this]() { delayParsing(); }));
setProjectContext(Context(Constants::PROJECT_ID));
setProjectLanguages(Context(ProjectExplorer::Constants::CXX_LANGUAGE_ID));
......
......@@ -158,12 +158,12 @@ static QList<QmakeProject *> s_projects;
*/
QmakeProject::QmakeProject(const FileName &fileName) :
Project(QmakeProjectManager::Constants::PROFILE_MIMETYPE, fileName),
m_qmakeVfs(new QMakeVfs),
m_cppCodeModelUpdater(new CppTools::CppProjectUpdater(this))
{
s_projects.append(this);
setId(Constants::QMAKEPROJECT_ID);
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());
......
......@@ -55,12 +55,10 @@ using namespace ProjectExplorer;
namespace QmlProjectManager {
QmlProject::QmlProject(const Utils::FileName &fileName) :
Project(QString::fromLatin1(Constants::QMLPROJECT_MIMETYPE), fileName, [this]() { refreshProjectFile(); }),
m_defaultImport(UnknownImport)
{
setId("QmlProjectManager.QmlProject");
setDocument(new ProjectDocument(QString::fromLatin1(Constants::QMLPROJECT_MIMETYPE), fileName,
[this]() { refreshProjectFile(); }));
setProjectContext(Context(QmlProjectManager::Constants::PROJECTCONTEXT));
setProjectLanguages(Context(ProjectExplorer::Constants::QMLJS_LANGUAGE_ID));
}
......
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