ProjectExplorer: Provide ProjectDocument and use it in all projects

Change-Id: I6e054ebf1043bd1f6748f1567f35c68394bd6528
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Tobias Hunger
2017-03-29 11:11:49 +02:00
parent df64242ab2
commit 348aa12eaa
23 changed files with 80 additions and 476 deletions

View File

@@ -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