forked from qt-creator/qt-creator
Core: Force use of static DocumentManager interface
Change-Id: Ieb2c0ecd3d34a3aad653c6eb5b00bc20d2c61986 Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
@@ -228,7 +228,7 @@ DocumentManager::~DocumentManager()
|
|||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
DocumentManager *DocumentManager::instance()
|
QObject *DocumentManager::instance()
|
||||||
{
|
{
|
||||||
return m_instance;
|
return m_instance;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ public:
|
|||||||
|
|
||||||
typedef QPair<QString, Id> RecentFile;
|
typedef QPair<QString, Id> RecentFile;
|
||||||
|
|
||||||
static DocumentManager *instance();
|
static QObject *instance();
|
||||||
|
|
||||||
// file pool to monitor
|
// file pool to monitor
|
||||||
static void addDocuments(const QList<IDocument *> &documents, bool addWatcher = true);
|
static void addDocuments(const QList<IDocument *> &documents, bool addWatcher = true);
|
||||||
@@ -154,7 +154,7 @@ private slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
explicit DocumentManager(QMainWindow *ew);
|
explicit DocumentManager(QMainWindow *ew);
|
||||||
virtual ~DocumentManager();
|
~DocumentManager();
|
||||||
|
|
||||||
friend class Core::Internal::MainWindow;
|
friend class Core::Internal::MainWindow;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -66,6 +66,11 @@
|
|||||||
|
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
|
|
||||||
|
using namespace Core;
|
||||||
|
|
||||||
|
namespace QbsProjectManager {
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
// Constants:
|
// Constants:
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@@ -77,12 +82,8 @@ static const char CONFIG_DEFINES[] = "defines";
|
|||||||
static const char CONFIG_INCLUDEPATHS[] = "includePaths";
|
static const char CONFIG_INCLUDEPATHS[] = "includePaths";
|
||||||
static const char CONFIG_FRAMEWORKPATHS[] = "frameworkPaths";
|
static const char CONFIG_FRAMEWORKPATHS[] = "frameworkPaths";
|
||||||
static const char CONFIG_PRECOMPILEDHEADER[] = "precompiledHeader";
|
static const char CONFIG_PRECOMPILEDHEADER[] = "precompiledHeader";
|
||||||
|
|
||||||
static const char CONFIGURATION_PATH[] = "<configuration>";
|
static const char CONFIGURATION_PATH[] = "<configuration>";
|
||||||
|
|
||||||
namespace QbsProjectManager {
|
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
// QbsProject:
|
// QbsProject:
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@@ -100,8 +101,8 @@ QbsProject::QbsProject(QbsManager *manager, const QString &fileName) :
|
|||||||
{
|
{
|
||||||
m_parsingDelay.setInterval(1000); // delay parsing by 1s.
|
m_parsingDelay.setInterval(1000); // delay parsing by 1s.
|
||||||
|
|
||||||
setProjectContext(Core::Context(Constants::PROJECT_ID));
|
setProjectContext(Context(Constants::PROJECT_ID));
|
||||||
setProjectLanguages(Core::Context(ProjectExplorer::Constants::LANG_CXX));
|
setProjectLanguages(Context(ProjectExplorer::Constants::LANG_CXX));
|
||||||
|
|
||||||
connect(this, SIGNAL(activeTargetChanged(ProjectExplorer::Target*)),
|
connect(this, SIGNAL(activeTargetChanged(ProjectExplorer::Target*)),
|
||||||
this, SLOT(changeActiveTarget(ProjectExplorer::Target*)));
|
this, SLOT(changeActiveTarget(ProjectExplorer::Target*)));
|
||||||
@@ -125,14 +126,14 @@ QString QbsProject::displayName() const
|
|||||||
return m_projectName;
|
return m_projectName;
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::Id QbsProject::id() const
|
Id QbsProject::id() const
|
||||||
{
|
{
|
||||||
return Core::Id(Constants::PROJECT_ID);
|
return Constants::PROJECT_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::IDocument *QbsProject::document() const
|
IDocument *QbsProject::document() const
|
||||||
{
|
{
|
||||||
foreach (Core::IDocument *doc, m_qbsDocuments) {
|
foreach (IDocument *doc, m_qbsDocuments) {
|
||||||
if (doc->filePath() == m_fileName)
|
if (doc->filePath() == m_fileName)
|
||||||
return doc;
|
return doc;
|
||||||
}
|
}
|
||||||
@@ -452,7 +453,7 @@ void QbsProject::prepareForParsing()
|
|||||||
m_currentProgressBase = 0;
|
m_currentProgressBase = 0;
|
||||||
m_qbsUpdateFutureInterface = new QFutureInterface<void>();
|
m_qbsUpdateFutureInterface = new QFutureInterface<void>();
|
||||||
m_qbsUpdateFutureInterface->setProgressRange(0, 0);
|
m_qbsUpdateFutureInterface->setProgressRange(0, 0);
|
||||||
Core::ICore::progressManager()->addTask(m_qbsUpdateFutureInterface->future(), tr("Evaluating"),
|
ICore::progressManager()->addTask(m_qbsUpdateFutureInterface->future(), tr("Evaluating"),
|
||||||
QLatin1String(Constants::QBS_EVALUATE));
|
QLatin1String(Constants::QBS_EVALUATE));
|
||||||
m_qbsUpdateFutureInterface->reportStarted();
|
m_qbsUpdateFutureInterface->reportStarted();
|
||||||
}
|
}
|
||||||
@@ -463,7 +464,7 @@ void QbsProject::updateDocuments(const QSet<QString> &files)
|
|||||||
QSet<QString> newFiles = files;
|
QSet<QString> newFiles = files;
|
||||||
QTC_ASSERT(!newFiles.isEmpty(), newFiles << m_fileName);
|
QTC_ASSERT(!newFiles.isEmpty(), newFiles << m_fileName);
|
||||||
QSet<QString> oldFiles;
|
QSet<QString> oldFiles;
|
||||||
foreach (Core::IDocument *doc, m_qbsDocuments)
|
foreach (IDocument *doc, m_qbsDocuments)
|
||||||
oldFiles.insert(doc->filePath());
|
oldFiles.insert(doc->filePath());
|
||||||
|
|
||||||
QSet<QString> filesToAdd = newFiles;
|
QSet<QString> filesToAdd = newFiles;
|
||||||
@@ -471,18 +472,18 @@ void QbsProject::updateDocuments(const QSet<QString> &files)
|
|||||||
QSet<QString> filesToRemove = oldFiles;
|
QSet<QString> filesToRemove = oldFiles;
|
||||||
filesToRemove.subtract(newFiles);
|
filesToRemove.subtract(newFiles);
|
||||||
|
|
||||||
QSet<Core::IDocument *> currentDocuments = m_qbsDocuments;
|
QSet<IDocument *> currentDocuments = m_qbsDocuments;
|
||||||
foreach (Core::IDocument *doc, currentDocuments) {
|
foreach (IDocument *doc, currentDocuments) {
|
||||||
if (filesToRemove.contains(doc->filePath())) {
|
if (filesToRemove.contains(doc->filePath())) {
|
||||||
m_qbsDocuments.remove(doc);
|
m_qbsDocuments.remove(doc);
|
||||||
delete doc;
|
delete doc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QSet<Core::IDocument *> toAdd;
|
QSet<IDocument *> toAdd;
|
||||||
foreach (const QString &f, filesToAdd)
|
foreach (const QString &f, filesToAdd)
|
||||||
toAdd.insert(new QbsProjectFile(this, f));
|
toAdd.insert(new QbsProjectFile(this, f));
|
||||||
|
|
||||||
Core::DocumentManager::instance()->addDocuments(toAdd.toList());
|
DocumentManager::addDocuments(toAdd.toList());
|
||||||
m_qbsDocuments.unite(toAdd);
|
m_qbsDocuments.unite(toAdd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -620,7 +621,7 @@ QString QbsProject::qbsBuildDir() const
|
|||||||
QString buildDir = Utils::Environment::systemEnvironment()
|
QString buildDir = Utils::Environment::systemEnvironment()
|
||||||
.value(QLatin1String("QBS_BUILD_DIR"));
|
.value(QLatin1String("QBS_BUILD_DIR"));
|
||||||
if (buildDir.isEmpty())
|
if (buildDir.isEmpty())
|
||||||
buildDir = Core::ICore::resourcePath() + QLatin1String("/qbs");
|
buildDir = ICore::resourcePath() + QLatin1String("/qbs");
|
||||||
return buildDir;
|
return buildDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,27 +38,29 @@
|
|||||||
#include <extensionsystem/pluginmanager.h>
|
#include <extensionsystem/pluginmanager.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
using namespace TextEditor;
|
using namespace Core;
|
||||||
using namespace TextEditor::Internal;
|
using namespace Utils;
|
||||||
|
|
||||||
|
namespace TextEditor {
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
BaseTextMarkRegistry::BaseTextMarkRegistry(QObject *parent)
|
BaseTextMarkRegistry::BaseTextMarkRegistry(QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
{
|
{
|
||||||
connect(Core::EditorManager::instance(), SIGNAL(editorOpened(Core::IEditor*)),
|
connect(EditorManager::instance(), SIGNAL(editorOpened(Core::IEditor*)),
|
||||||
SLOT(editorOpened(Core::IEditor*)));
|
SLOT(editorOpened(Core::IEditor*)));
|
||||||
|
|
||||||
Core::DocumentManager *dm = Core::DocumentManager::instance();
|
connect(DocumentManager::instance(), SIGNAL(allDocumentsRenamed(QString,QString)),
|
||||||
connect(dm, SIGNAL(allDocumentsRenamed(QString,QString)),
|
|
||||||
this, SLOT(allDocumentsRenamed(QString,QString)));
|
this, SLOT(allDocumentsRenamed(QString,QString)));
|
||||||
connect(dm, SIGNAL(documentRenamed(Core::IDocument*,QString,QString)),
|
connect(DocumentManager::instance(), SIGNAL(documentRenamed(Core::IDocument*,QString,QString)),
|
||||||
this, SLOT(documentRenamed(Core::IDocument*,QString,QString)));
|
this, SLOT(documentRenamed(Core::IDocument*,QString,QString)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseTextMarkRegistry::add(BaseTextMark *mark)
|
void BaseTextMarkRegistry::add(BaseTextMark *mark)
|
||||||
{
|
{
|
||||||
m_marks[Utils::FileName::fromString(mark->fileName())].insert(mark);
|
m_marks[FileName::fromString(mark->fileName())].insert(mark);
|
||||||
Core::DocumentModel *documentModel = Core::EditorManager::documentModel();
|
DocumentModel *documentModel = EditorManager::documentModel();
|
||||||
Core::IDocument *document = documentModel->documentForFilePath(mark->fileName());
|
IDocument *document = documentModel->documentForFilePath(mark->fileName());
|
||||||
if (!document)
|
if (!document)
|
||||||
return;
|
return;
|
||||||
// TODO: markableInterface should be moved to ITextEditorDocument
|
// TODO: markableInterface should be moved to ITextEditorDocument
|
||||||
@@ -70,7 +72,7 @@ void BaseTextMarkRegistry::add(BaseTextMark *mark)
|
|||||||
|
|
||||||
bool BaseTextMarkRegistry::remove(BaseTextMark *mark)
|
bool BaseTextMarkRegistry::remove(BaseTextMark *mark)
|
||||||
{
|
{
|
||||||
return m_marks[Utils::FileName::fromString(mark->fileName())].remove(mark);
|
return m_marks[FileName::fromString(mark->fileName())].remove(mark);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseTextMarkRegistry::editorOpened(Core::IEditor *editor)
|
void BaseTextMarkRegistry::editorOpened(Core::IEditor *editor)
|
||||||
@@ -78,24 +80,24 @@ void BaseTextMarkRegistry::editorOpened(Core::IEditor *editor)
|
|||||||
ITextEditor *textEditor = qobject_cast<ITextEditor *>(editor);
|
ITextEditor *textEditor = qobject_cast<ITextEditor *>(editor);
|
||||||
if (!textEditor)
|
if (!textEditor)
|
||||||
return;
|
return;
|
||||||
if (!m_marks.contains(Utils::FileName::fromString(editor->document()->filePath())))
|
if (!m_marks.contains(FileName::fromString(editor->document()->filePath())))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
foreach (BaseTextMark *mark, m_marks.value(Utils::FileName::fromString(editor->document()->filePath()))) {
|
foreach (BaseTextMark *mark, m_marks.value(FileName::fromString(editor->document()->filePath()))) {
|
||||||
ITextMarkable *markableInterface = textEditor->markableInterface();
|
ITextMarkable *markableInterface = textEditor->markableInterface();
|
||||||
markableInterface->addMark(mark);
|
markableInterface->addMark(mark);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseTextMarkRegistry::documentRenamed(Core::IDocument *document, const
|
void BaseTextMarkRegistry::documentRenamed(IDocument *document, const
|
||||||
QString &oldName, const QString &newName)
|
QString &oldName, const QString &newName)
|
||||||
{
|
{
|
||||||
TextEditor::BaseTextDocument *baseTextDocument
|
TextEditor::BaseTextDocument *baseTextDocument
|
||||||
= qobject_cast<TextEditor::BaseTextDocument *>(document);
|
= qobject_cast<TextEditor::BaseTextDocument *>(document);
|
||||||
if (!document)
|
if (!document)
|
||||||
return;
|
return;
|
||||||
Utils::FileName oldFileName = Utils::FileName::fromString(oldName);
|
FileName oldFileName = FileName::fromString(oldName);
|
||||||
Utils::FileName newFileName = Utils::FileName::fromString(newName);
|
FileName newFileName = FileName::fromString(newName);
|
||||||
if (!m_marks.contains(oldFileName))
|
if (!m_marks.contains(oldFileName))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -113,8 +115,8 @@ void BaseTextMarkRegistry::documentRenamed(Core::IDocument *document, const
|
|||||||
|
|
||||||
void BaseTextMarkRegistry::allDocumentsRenamed(const QString &oldName, const QString &newName)
|
void BaseTextMarkRegistry::allDocumentsRenamed(const QString &oldName, const QString &newName)
|
||||||
{
|
{
|
||||||
Utils::FileName oldFileName = Utils::FileName::fromString(oldName);
|
FileName oldFileName = FileName::fromString(oldName);
|
||||||
Utils::FileName newFileName = Utils::FileName::fromString(newName);
|
FileName newFileName = FileName::fromString(newName);
|
||||||
if (!m_marks.contains(oldFileName))
|
if (!m_marks.contains(oldFileName))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -127,6 +129,8 @@ void BaseTextMarkRegistry::allDocumentsRenamed(const QString &oldName, const QSt
|
|||||||
mark->updateFileName(newName);
|
mark->updateFileName(newName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace Internal
|
||||||
|
|
||||||
BaseTextMark::BaseTextMark(const QString &fileName, int lineNumber)
|
BaseTextMark::BaseTextMark(const QString &fileName, int lineNumber)
|
||||||
: ITextMark(lineNumber), m_fileName(fileName)
|
: ITextMark(lineNumber), m_fileName(fileName)
|
||||||
{
|
{
|
||||||
@@ -152,3 +156,5 @@ void BaseTextMark::updateFileName(const QString &fileName)
|
|||||||
{
|
{
|
||||||
m_fileName = fileName;
|
m_fileName = fileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace TextEditor
|
||||||
|
|||||||
Reference in New Issue
Block a user