Commit 68537ef0 authored by hjk's avatar hjk
Browse files

Core: Force use of static DocumentManager interface



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