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

@@ -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);
}

View File

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

View File

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

View File

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

View File

@@ -94,8 +94,6 @@ QtcPlugin {
"qbsprofilessettingswidget.ui",
"qbsproject.cpp",
"qbsproject.h",
"qbsprojectfile.cpp",
"qbsprojectfile.h",
"qbsprojectmanager.cpp",
"qbsprojectmanager.h",
"qbsprojectmanager.qrc",