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

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

View File

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

View File

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

View File

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

View File

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