summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authorhjk <hjk121@nokiamail.com>2014-05-07 16:25:04 +0200
committerhjk <hjk121@nokiamail.com>2014-05-13 11:48:30 +0200
commit6e584b5b4953b996ef07c4625adf178c59de24f7 (patch)
tree2af702c76bf5323c331154b553aacbe5523592f5 /src/plugins
parent226c1abc89888fa2f272d92c466725fd6dad65db (diff)
downloadqt-creator-6e584b5b4953b996ef07c4625adf178c59de24f7.tar.gz
DocumentModel: Make interface static
Move item model implementation to private, adjust user code. Change-Id: Ifbe94e7c7b9b1e8be1b4c531958dbd7a9413af13 Reviewed-by: Eike Ziller <eike.ziller@digia.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/clangcodemodel/indexer.cpp2
-rw-r--r--src/plugins/cmakeprojectmanager/cmakeproject.cpp2
-rw-r--r--src/plugins/coreplugin/documentmanager.cpp2
-rw-r--r--src/plugins/coreplugin/editormanager/documentmodel.cpp146
-rw-r--r--src/plugins/coreplugin/editormanager/documentmodel.h68
-rw-r--r--src/plugins/coreplugin/editormanager/editormanager.cpp85
-rw-r--r--src/plugins/coreplugin/editormanager/editormanager.h1
-rw-r--r--src/plugins/coreplugin/editormanager/editorview.cpp5
-rw-r--r--src/plugins/coreplugin/editormanager/openeditorsview.cpp10
-rw-r--r--src/plugins/coreplugin/editormanager/openeditorswindow.cpp18
-rw-r--r--src/plugins/coreplugin/editormanager/openeditorswindow.h8
-rw-r--r--src/plugins/coreplugin/editortoolbar.cpp23
-rw-r--r--src/plugins/coreplugin/locator/opendocumentsfilter.cpp2
-rw-r--r--src/plugins/cppeditor/cppeditor.cpp4
-rw-r--r--src/plugins/cppeditor/fileandtokenactions_test.cpp8
-rw-r--r--src/plugins/cpptools/cpplocatorfilter_test.cpp4
-rw-r--r--src/plugins/cpptools/cppmodelmanager_test.cpp20
-rw-r--r--src/plugins/debugger/debuggerplugin.cpp2
-rw-r--r--src/plugins/debugger/debuggertooltipmanager.cpp6
-rw-r--r--src/plugins/debugger/disassembleragent.cpp2
-rw-r--r--src/plugins/debugger/qml/qmlengine.cpp4
-rw-r--r--src/plugins/debugger/qml/qmlinspectoradapter.cpp7
-rw-r--r--src/plugins/debugger/qml/qmlv8debuggerclient.cpp6
-rw-r--r--src/plugins/designer/gotoslot_test.cpp2
-rw-r--r--src/plugins/diffeditor/diffeditormanager.cpp4
-rw-r--r--src/plugins/fakevim/fakevimplugin.cpp6
-rw-r--r--src/plugins/git/gitclient.cpp7
-rw-r--r--src/plugins/git/gitplugin.cpp2
-rw-r--r--src/plugins/projectexplorer/editorconfiguration.cpp8
-rw-r--r--src/plugins/qmakeprojectmanager/qmakenodes.cpp4
-rw-r--r--src/plugins/qmldesigner/shortcutmanager.cpp2
-rw-r--r--src/plugins/qmljseditor/qmljsfindreferences.cpp3
-rw-r--r--src/plugins/qmljstools/qmljsmodelmanager.cpp5
-rw-r--r--src/plugins/qnx/bardescriptorfilenodemanager.cpp2
-rw-r--r--src/plugins/texteditor/basetextmark.cpp3
-rw-r--r--src/plugins/texteditor/findinopenfiles.cpp4
-rw-r--r--src/plugins/texteditor/itexteditor.cpp4
-rw-r--r--src/plugins/texteditor/refactoringchanges.cpp2
-rw-r--r--src/plugins/vcsbase/vcsbaseclient.cpp4
-rw-r--r--src/plugins/vcsbase/vcsbaseeditor.cpp6
-rw-r--r--src/plugins/vcsbase/vcsbaseplugin.cpp2
41 files changed, 259 insertions, 246 deletions
diff --git a/src/plugins/clangcodemodel/indexer.cpp b/src/plugins/clangcodemodel/indexer.cpp
index efad786afc..ba140d1277 100644
--- a/src/plugins/clangcodemodel/indexer.cpp
+++ b/src/plugins/clangcodemodel/indexer.cpp
@@ -716,7 +716,7 @@ void IndexerPrivate::runCore(const QHash<QString, FileData> & /*headers*/,
QHash<ProjectPart::Ptr, QList<IndexerPrivate::FileData> > parts;
typedef QHash<ProjectPart::Ptr, QList<IndexerPrivate::FileData> >::Iterator PartIter;
- QList<Core::IDocument *> docs = Core::EditorManager::documentModel()->openedDocuments();
+ QList<Core::IDocument *> docs = Core::DocumentModel::openedDocuments();
QSet<QString> openDocs;
foreach (Core::IDocument *doc, docs)
openDocs.insert(doc->filePath());
diff --git a/src/plugins/cmakeprojectmanager/cmakeproject.cpp b/src/plugins/cmakeprojectmanager/cmakeproject.cpp
index 4625dc5b7b..81476f5274 100644
--- a/src/plugins/cmakeprojectmanager/cmakeproject.cpp
+++ b/src/plugins/cmakeprojectmanager/cmakeproject.cpp
@@ -197,7 +197,7 @@ bool CMakeProject::parseCMakeLists()
}
CMakeBuildConfiguration *activeBC = static_cast<CMakeBuildConfiguration *>(activeTarget()->activeBuildConfiguration());
- foreach (Core::IDocument *document, Core::EditorManager::documentModel()->openedDocuments())
+ foreach (Core::IDocument *document, Core::DocumentModel::openedDocuments())
if (isProjectFile(document->filePath()))
document->infoBar()->removeInfo("CMakeEditor.RunCMake");
diff --git a/src/plugins/coreplugin/documentmanager.cpp b/src/plugins/coreplugin/documentmanager.cpp
index b1877e04d5..09217d99a9 100644
--- a/src/plugins/coreplugin/documentmanager.cpp
+++ b/src/plugins/coreplugin/documentmanager.cpp
@@ -1434,7 +1434,7 @@ void DocumentManager::executeOpenWithMenuAction(QAction *action)
if (entry.editorFactory) {
// close any open editors that have this file open, but have a different type.
QList<IEditor *> editorsOpenForFile
- = EditorManager::documentModel()->editorsForFilePath(entry.fileName);
+ = DocumentModel::editorsForFilePath(entry.fileName);
if (!editorsOpenForFile.isEmpty()) {
foreach (IEditor *openEditor, editorsOpenForFile) {
if (entry.editorFactory->id() == openEditor->document()->id())
diff --git a/src/plugins/coreplugin/editormanager/documentmodel.cpp b/src/plugins/coreplugin/editormanager/documentmodel.cpp
index 8199c307d3..1ea36e1ebb 100644
--- a/src/plugins/coreplugin/editormanager/documentmodel.cpp
+++ b/src/plugins/coreplugin/editormanager/documentmodel.cpp
@@ -39,11 +39,31 @@
namespace Core {
-struct DocumentModelPrivate
+class DocumentModelPrivate : public QAbstractItemModel
{
+ Q_OBJECT
+
+public:
DocumentModelPrivate();
~DocumentModelPrivate();
+ int columnCount(const QModelIndex &parent = QModelIndex()) const;
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
+ QModelIndex parent(const QModelIndex &/*index*/) const { return QModelIndex(); }
+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const;
+
+ void addEntry(DocumentModel::Entry *entry);
+ void removeDocument(int idx);
+
+ int indexOfFilePath(const QString &filePath) const;
+ int indexOfDocument(IDocument *document) const;
+
+private slots:
+ friend class DocumentModel;
+ void itemChanged();
+
+private:
const QIcon m_lockedIcon;
const QIcon m_unlockedIcon;
@@ -62,36 +82,49 @@ DocumentModelPrivate::~DocumentModelPrivate()
qDeleteAll(m_documents);
}
+static DocumentModelPrivate *d;
+
DocumentModel::Entry::Entry() :
document(0)
{
}
-DocumentModel::DocumentModel(QObject *parent) :
- QAbstractItemModel(parent), d(new DocumentModelPrivate)
+DocumentModel::DocumentModel()
{
}
-DocumentModel::~DocumentModel()
+void DocumentModel::init()
+{
+ d = new DocumentModelPrivate;
+}
+
+void DocumentModel::destroy()
{
delete d;
}
-QIcon DocumentModel::lockedIcon() const
+QIcon DocumentModel::lockedIcon()
{
return d->m_lockedIcon;
}
-QIcon DocumentModel::unlockedIcon() const
+QIcon DocumentModel::unlockedIcon()
{
return d->m_unlockedIcon;
}
-QString DocumentModel::Entry::fileName() const {
+QAbstractItemModel *DocumentModel::model()
+{
+ return d;
+}
+
+QString DocumentModel::Entry::fileName() const
+{
return document ? document->filePath() : m_fileName;
}
-QString DocumentModel::Entry::displayName() const {
+QString DocumentModel::Entry::displayName() const
+{
return document ? document->displayName() : m_displayName;
}
@@ -100,22 +133,22 @@ Id DocumentModel::Entry::id() const
return m_id;
}
-int DocumentModel::columnCount(const QModelIndex &parent) const
+int DocumentModelPrivate::columnCount(const QModelIndex &parent) const
{
if (!parent.isValid())
return 2;
return 0;
}
-int DocumentModel::rowCount(const QModelIndex &parent) const
+int DocumentModelPrivate::rowCount(const QModelIndex &parent) const
{
if (!parent.isValid())
- return d->m_documents.count() + 1/*<no document>*/;
+ return m_documents.count() + 1/*<no document>*/;
return 0;
}
// TODO remove
-QList<IEditor *> DocumentModel::oneEditorForEachOpenedDocument() const
+QList<IEditor *> DocumentModel::oneEditorForEachOpenedDocument()
{
QList<IEditor *> result;
QMapIterator<IDocument *, QList<IEditor *> > it(d->m_editors);
@@ -138,7 +171,7 @@ void DocumentModel::addEditor(IEditor *editor, bool *isNewDocument)
Entry *entry = new Entry;
entry->document = editor->document();
entry->m_id = editor->document()->id();
- addEntry(entry);
+ d->addEntry(entry);
}
}
@@ -148,10 +181,10 @@ void DocumentModel::addRestoredDocument(const QString &fileName, const QString &
entry->m_fileName = fileName;
entry->m_displayName = displayName;
entry->m_id = id;
- addEntry(entry);
+ d->addEntry(entry);
}
-DocumentModel::Entry *DocumentModel::firstRestoredDocument() const
+DocumentModel::Entry *DocumentModel::firstRestoredDocument()
{
for (int i = 0; i < d->m_documents.count(); ++i)
if (!d->m_documents.at(i)->document)
@@ -159,16 +192,16 @@ DocumentModel::Entry *DocumentModel::firstRestoredDocument() const
return 0;
}
-void DocumentModel::addEntry(Entry *entry)
+void DocumentModelPrivate::addEntry(DocumentModel::Entry *entry)
{
QString fileName = entry->fileName();
// replace a non-loaded entry (aka 'restored') if possible
int previousIndex = indexOfFilePath(fileName);
if (previousIndex >= 0) {
- if (entry->document && d->m_documents.at(previousIndex)->document == 0) {
- Entry *previousEntry = d->m_documents.at(previousIndex);
- d->m_documents[previousIndex] = entry;
+ if (entry->document && m_documents.at(previousIndex)->document == 0) {
+ DocumentModel::Entry *previousEntry = m_documents.at(previousIndex);
+ m_documents[previousIndex] = entry;
delete previousEntry;
connect(entry->document, SIGNAL(changed()), this, SLOT(itemChanged()));
} else {
@@ -179,19 +212,24 @@ void DocumentModel::addEntry(Entry *entry)
int index;
QString displayName = entry->displayName();
- for (index = 0; index < d->m_documents.count(); ++index) {
- if (displayName < d->m_documents.at(index)->displayName())
+ for (index = 0; index < m_documents.count(); ++index) {
+ if (displayName < m_documents.at(index)->displayName())
break;
}
int row = index + 1/*<no document>*/;
beginInsertRows(QModelIndex(), row, row);
- d->m_documents.insert(index, entry);
+ m_documents.insert(index, entry);
if (entry->document)
connect(entry->document, SIGNAL(changed()), this, SLOT(itemChanged()));
endInsertRows();
}
-int DocumentModel::indexOfFilePath(const QString &filePath) const
+int DocumentModel::indexOfFilePath(const QString &filePath)
+{
+ return d->indexOfFilePath(filePath);
+}
+
+int DocumentModelPrivate::indexOfFilePath(const QString &filePath) const
{
if (filePath.isEmpty())
return -1;
@@ -207,7 +245,7 @@ void DocumentModel::removeEntry(DocumentModel::Entry *entry)
{
QTC_ASSERT(!entry->document, return); // we wouldn't know what to do with the associated editors
int index = d->m_documents.indexOf(entry);
- removeDocument(index);
+ d->removeDocument(index);
}
void DocumentModel::removeEditor(IEditor *editor, bool *lastOneForDocument)
@@ -222,7 +260,7 @@ void DocumentModel::removeEditor(IEditor *editor, bool *lastOneForDocument)
if (lastOneForDocument)
*lastOneForDocument = true;
d->m_editors.remove(document);
- removeDocument(indexOfDocument(document));
+ d->removeDocument(indexOfDocument(document));
}
}
@@ -230,10 +268,10 @@ void DocumentModel::removeDocument(const QString &fileName)
{
int index = indexOfFilePath(fileName);
QTC_ASSERT(!d->m_documents.at(index)->document, return); // we wouldn't know what to do with the associated editors
- removeDocument(index);
+ d->removeDocument(index);
}
-void DocumentModel::removeDocument(int idx)
+void DocumentModelPrivate::removeDocument(int idx)
{
if (idx < 0)
return;
@@ -252,19 +290,24 @@ void DocumentModel::removeAllRestoredDocuments()
for (int i = d->m_documents.count()-1; i >= 0; --i) {
if (!d->m_documents.at(i)->document) {
int row = i + 1/*<no document>*/;
- beginRemoveRows(QModelIndex(), row, row);
+ d->beginRemoveRows(QModelIndex(), row, row);
delete d->m_documents.takeAt(i);
- endRemoveRows();
+ d->endRemoveRows();
}
}
}
-QList<IEditor *> DocumentModel::editorsForDocument(IDocument *document) const
+QList<IEditor *> DocumentModel::editorsForDocument(IDocument *document)
{
return d->m_editors.value(document);
}
-QList<IEditor *> DocumentModel::editorsForDocuments(const QList<IDocument *> &documents) const
+QList<IEditor *> DocumentModel::editorsForOpenedDocuments()
+{
+ return editorsForDocuments(openedDocuments());
+}
+
+QList<IEditor *> DocumentModel::editorsForDocuments(const QList<IDocument *> &documents)
{
QList<IEditor *> result;
foreach (IDocument *document, documents)
@@ -272,15 +315,20 @@ QList<IEditor *> DocumentModel::editorsForDocuments(const QList<IDocument *> &do
return result;
}
-int DocumentModel::indexOfDocument(IDocument *document) const
+int DocumentModel::indexOfDocument(IDocument *document)
{
- for (int i = 0; i < d->m_documents.count(); ++i)
- if (d->m_documents.at(i)->document == document)
+ return d->indexOfDocument(document);
+}
+
+int DocumentModelPrivate::indexOfDocument(IDocument *document) const
+{
+ for (int i = 0; i < m_documents.count(); ++i)
+ if (m_documents.at(i)->document == document)
return i;
return -1;
}
-DocumentModel::Entry *DocumentModel::entryForDocument(IDocument *document) const
+DocumentModel::Entry *DocumentModel::entryForDocument(IDocument *document)
{
int index = indexOfDocument(document);
if (index < 0)
@@ -288,12 +336,12 @@ DocumentModel::Entry *DocumentModel::entryForDocument(IDocument *document) const
return d->m_documents.at(index);
}
-QList<IDocument *> DocumentModel::openedDocuments() const
+QList<IDocument *> DocumentModel::openedDocuments()
{
return d->m_editors.keys();
}
-IDocument *DocumentModel::documentForFilePath(const QString &filePath) const
+IDocument *DocumentModel::documentForFilePath(const QString &filePath)
{
int index = indexOfFilePath(filePath);
if (index < 0)
@@ -301,7 +349,7 @@ IDocument *DocumentModel::documentForFilePath(const QString &filePath) const
return d->m_documents.at(index)->document;
}
-QList<IEditor *> DocumentModel::editorsForFilePath(const QString &filePath) const
+QList<IEditor *> DocumentModel::editorsForFilePath(const QString &filePath)
{
IDocument *document = documentForFilePath(filePath);
if (document)
@@ -309,15 +357,15 @@ QList<IEditor *> DocumentModel::editorsForFilePath(const QString &filePath) cons
return QList<IEditor *>();
}
-QModelIndex DocumentModel::index(int row, int column, const QModelIndex &parent) const
+QModelIndex DocumentModelPrivate::index(int row, int column, const QModelIndex &parent) const
{
Q_UNUSED(parent)
- if (column < 0 || column > 1 || row < 0 || row >= d->m_documents.count() + 1/*<no document>*/)
+ if (column < 0 || column > 1 || row < 0 || row >= m_documents.count() + 1/*<no document>*/)
return QModelIndex();
return createIndex(row, column);
}
-DocumentModel::Entry *DocumentModel::documentAtRow(int row) const
+DocumentModel::Entry *DocumentModel::documentAtRow(int row)
{
int entryIndex = row - 1/*<no document>*/;
if (entryIndex < 0)
@@ -325,12 +373,12 @@ DocumentModel::Entry *DocumentModel::documentAtRow(int row) const
return d->m_documents[entryIndex];
}
-int DocumentModel::documentCount() const
+int DocumentModel::documentCount()
{
return d->m_documents.count();
}
-QVariant DocumentModel::data(const QModelIndex &index, int role) const
+QVariant DocumentModelPrivate::data(const QModelIndex &index, int role) const
{
if (!index.isValid() || (index.column() != 0 && role < Qt::UserRole))
return QVariant();
@@ -346,7 +394,7 @@ QVariant DocumentModel::data(const QModelIndex &index, int role) const
return QVariant();
}
}
- const Entry *e = d->m_documents.at(entryIndex);
+ const DocumentModel::Entry *e = m_documents.at(entryIndex);
switch (role) {
case Qt::DisplayRole:
return (e->document && e->document->isModified())
@@ -362,7 +410,7 @@ QVariant DocumentModel::data(const QModelIndex &index, int role) const
} else {
showLock = !QFileInfo(e->m_fileName).isWritable();
}
- return showLock ? d->m_lockedIcon : QIcon();
+ return showLock ? m_lockedIcon : QIcon();
}
case Qt::ToolTipRole:
return e->fileName().isEmpty()
@@ -374,14 +422,14 @@ QVariant DocumentModel::data(const QModelIndex &index, int role) const
return QVariant();
}
-int DocumentModel::rowOfDocument(IDocument *document) const
+int DocumentModel::rowOfDocument(IDocument *document)
{
if (!document)
return 0 /*<no document>*/;
return indexOfDocument(document) + 1/*<no document>*/;
}
-void DocumentModel::itemChanged()
+void DocumentModelPrivate::itemChanged()
{
IDocument *document = qobject_cast<IDocument *>(sender());
@@ -392,9 +440,11 @@ void DocumentModel::itemChanged()
emit dataChanged(mindex, mindex);
}
-QList<DocumentModel::Entry *> DocumentModel::documents() const
+QList<DocumentModel::Entry *> DocumentModel::documents()
{
return d->m_documents;
}
} // namespace Core
+
+#include "documentmodel.moc"
diff --git a/src/plugins/coreplugin/editormanager/documentmodel.h b/src/plugins/coreplugin/editormanager/documentmodel.h
index 5889c73602..09e8c8969c 100644
--- a/src/plugins/coreplugin/editormanager/documentmodel.h
+++ b/src/plugins/coreplugin/editormanager/documentmodel.h
@@ -39,26 +39,19 @@ QT_FORWARD_DECLARE_CLASS(QIcon)
namespace Core {
-struct DocumentModelPrivate;
class IEditor;
class IDocument;
-class CORE_EXPORT DocumentModel : public QAbstractItemModel
+class CORE_EXPORT DocumentModel
{
- Q_OBJECT
-
public:
- explicit DocumentModel(QObject *parent);
- virtual ~DocumentModel();
+ static void init();
+ static void destroy();
- QIcon lockedIcon() const;
- QIcon unlockedIcon() const;
+ static QIcon lockedIcon();
+ static QIcon unlockedIcon();
- int columnCount(const QModelIndex &parent = QModelIndex()) const;
- QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
- QModelIndex parent(const QModelIndex &/*index*/) const { return QModelIndex(); }
- int rowCount(const QModelIndex &parent = QModelIndex()) const;
- QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const;
+ static QAbstractItemModel *model();
struct CORE_EXPORT Entry {
Entry();
@@ -71,39 +64,34 @@ public:
Id m_id;
};
- Entry *documentAtRow(int row) const;
- int rowOfDocument(IDocument *document) const;
+ static Entry *documentAtRow(int row);
+ static int rowOfDocument(IDocument *document);
- int documentCount() const;
- QList<Entry *> documents() const;
- int indexOfDocument(IDocument *document) const;
- int indexOfFilePath(const QString &filePath) const;
- Entry *entryForDocument(IDocument *document) const;
- QList<IDocument *> openedDocuments() const;
+ static int documentCount();
+ static QList<Entry *> documents();
+ static int indexOfDocument(IDocument *document);
+ static int indexOfFilePath(const QString &filePath);
+ static Entry *entryForDocument(IDocument *document);
+ static QList<IDocument *> openedDocuments();
- IDocument *documentForFilePath(const QString &filePath) const;
- QList<IEditor *> editorsForFilePath(const QString &filePath) const;
- QList<IEditor *> editorsForDocument(IDocument *document) const;
- QList<IEditor *> editorsForDocuments(const QList<IDocument *> &documents) const;
- QList<IEditor *> oneEditorForEachOpenedDocument() const;
+ static IDocument *documentForFilePath(const QString &filePath);
+ static QList<IEditor *> editorsForFilePath(const QString &filePath);
+ static QList<IEditor *> editorsForDocument(IDocument *document);
+ static QList<IEditor *> editorsForDocuments(const QList<IDocument *> &documents);
+ static QList<IEditor *> oneEditorForEachOpenedDocument();
+ static QList<IEditor *> editorsForOpenedDocuments();
// editor manager related functions, nobody else should call it
- void addEditor(IEditor *editor, bool *isNewDocument);
- void addRestoredDocument(const QString &fileName, const QString &displayName, const Id &id);
- Entry *firstRestoredDocument() const;
- void removeEditor(IEditor *editor, bool *lastOneForDocument);
- void removeDocument(const QString &fileName);
- void removeEntry(Entry *entry);
- void removeAllRestoredDocuments();
-
-private slots:
- void itemChanged();
+ static void addEditor(IEditor *editor, bool *isNewDocument);
+ static void addRestoredDocument(const QString &fileName, const QString &displayName, const Id &id);
+ static Entry *firstRestoredDocument();
+ static void removeEditor(IEditor *editor, bool *lastOneForDocument);
+ static void removeDocument(const QString &fileName);
+ static void removeEntry(Entry *entry);
+ static void removeAllRestoredDocuments();
private:
- void addEntry(Entry *entry);
- void removeDocument(int idx);
-
- DocumentModelPrivate *d;
+ DocumentModel();
};
} // namespace Core
diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp
index d1b872ae53..129054b342 100644
--- a/src/plugins/coreplugin/editormanager/editormanager.cpp
+++ b/src/plugins/coreplugin/editormanager/editormanager.cpp
@@ -203,8 +203,6 @@ public:
QMap<QString, QVariant> m_editorStates;
Internal::OpenEditorsViewFactory *m_openEditorsFactory;
- DocumentModel *m_documentModel;
-
IDocument::ReloadSetting m_reloadSetting;
QString m_titleAddition;
@@ -244,12 +242,13 @@ EditorManagerPrivate::EditorManagerPrivate(QWidget *parent) :
m_autoSaveEnabled(true),
m_autoSaveInterval(5)
{
- m_documentModel = new DocumentModel(parent);
+ DocumentModel::init();
}
EditorManagerPrivate::~EditorManagerPrivate()
{
// clearNavigationHistory();
+ DocumentModel::destroy();
}
static EditorManager *m_instance = 0;
@@ -503,7 +502,7 @@ EditorToolBar *EditorManager::createToolBar(QWidget *parent)
void EditorManager::removeEditor(IEditor *editor)
{
bool lastOneForDocument = false;
- d->m_documentModel->removeEditor(editor, &lastOneForDocument);
+ DocumentModel::removeEditor(editor, &lastOneForDocument);
if (lastOneForDocument)
DocumentManager::removeDocument(editor->document());
ICore::removeContextObject(editor);
@@ -639,7 +638,7 @@ void EditorManager::emptyView(Core::Internal::EditorView *view)
QList<IEditor *> editors = view->editors();
foreach (IEditor *editor, editors) {
- if (d->m_documentModel->editorsForDocument(editor->document()).size() == 1) {
+ if (DocumentModel::editorsForDocument(editor->document()).size() == 1) {
// it's the only editor for that file
// so we need to keep it around (--> in the editor model)
if (currentEditor() == editor) {
@@ -720,16 +719,16 @@ void EditorManager::closeView(Core::Internal::EditorView *view)
bool EditorManager::closeAllEditors(bool askAboutModifiedEditors)
{
- d->m_documentModel->removeAllRestoredDocuments();
- if (closeDocuments(d->m_documentModel->openedDocuments(), askAboutModifiedEditors))
+ DocumentModel::removeAllRestoredDocuments();
+ if (closeDocuments(DocumentModel::openedDocuments(), askAboutModifiedEditors))
return true;
return false;
}
void EditorManager::closeAllEditorsExceptVisible()
{
- d->m_documentModel->removeAllRestoredDocuments();
- QList<IDocument *> documentsToClose = d->m_documentModel->openedDocuments();
+ DocumentModel::removeAllRestoredDocuments();
+ QList<IDocument *> documentsToClose = DocumentModel::openedDocuments();
foreach (IEditor *editor, visibleEditors())
documentsToClose.removeAll(editor->document());
closeDocuments(documentsToClose, true);
@@ -737,8 +736,8 @@ void EditorManager::closeAllEditorsExceptVisible()
void EditorManager::closeOtherEditors(IDocument *document)
{
- d->m_documentModel->removeAllRestoredDocuments();
- QList<IDocument *> documentsToClose = d->m_documentModel->openedDocuments();
+ DocumentModel::removeAllRestoredDocuments();
+ QList<IDocument *> documentsToClose = DocumentModel::openedDocuments();
documentsToClose.removeAll(document);
closeDocuments(documentsToClose, true);
}
@@ -799,8 +798,8 @@ void EditorManager::addSaveAndCloseEditorActions(QMenu *contextMenu, DocumentMod
: tr("Close Other Editors"));
d->m_closeCurrentEditorContextAction->setEnabled(entry != 0);
d->m_closeOtherEditorsContextAction->setEnabled(entry != 0);
- d->m_closeAllEditorsContextAction->setEnabled(!d->m_documentModel->documents().isEmpty());
- d->m_closeAllEditorsExceptVisibleContextAction->setEnabled(visibleDocumentsCount() < d->m_documentModel->documents().count());
+ d->m_closeAllEditorsContextAction->setEnabled(!DocumentModel::documents().isEmpty());
+ d->m_closeAllEditorsExceptVisibleContextAction->setEnabled(visibleDocumentsCount() < DocumentModel::documents().count());
contextMenu->addAction(d->m_closeCurrentEditorContextAction);
contextMenu->addAction(d->m_closeAllEditorsContextAction);
contextMenu->addAction(d->m_closeOtherEditorsContextAction);
@@ -944,7 +943,7 @@ void EditorManager::closeEditorFromContextMenu()
{
IDocument *document = d->m_contextMenuEntry ? d->m_contextMenuEntry->document : 0;
if (document)
- closeEditors(d->m_documentModel->editorsForDocument(document));
+ closeEditors(DocumentModel::editorsForDocument(document));
}
void EditorManager::closeOtherEditorsFromContextMenu()
@@ -1042,9 +1041,9 @@ void EditorManager::closeEditor(DocumentModel::Entry *entry)
if (!entry)
return;
if (entry->document)
- closeEditors(d->m_documentModel->editorsForDocument(entry->document));
+ closeEditors(DocumentModel::editorsForDocument(entry->document));
else
- d->m_documentModel->removeEntry(entry);
+ DocumentModel::removeEntry(entry);
}
bool EditorManager::closeEditors(const QList<IEditor*> &editorsToClose, bool askAboutModifiedEditors)
@@ -1070,7 +1069,7 @@ bool EditorManager::closeEditors(const QList<IEditor*> &editorsToClose, bool ask
}
}
if (editorAccepted) {
- acceptedEditors += d->m_documentModel->editorsForDocument(editor->document()).toSet();
+ acceptedEditors += DocumentModel::editorsForDocument(editor->document()).toSet();
acceptedDocuments.insert(editor->document());
}
}
@@ -1087,7 +1086,7 @@ bool EditorManager::closeEditors(const QList<IEditor*> &editorsToClose, bool ask
if (!list.isEmpty()) {
closingFailed = true;
acceptedDocuments.subtract(list.toSet());
- QSet<IEditor*> skipSet = d->m_documentModel->editorsForDocuments(list).toSet();
+ QSet<IEditor*> skipSet = DocumentModel::editorsForDocuments(list).toSet();
acceptedEditors = acceptedEditors.subtract(skipSet);
}
}
@@ -1135,12 +1134,12 @@ bool EditorManager::closeEditors(const QList<IEditor*> &editorsToClose, bool ask
if (newCurrent) {
activateEditor(view, newCurrent, flags);
} else {
- DocumentModel::Entry *entry = d->m_documentModel->firstRestoredDocument();
+ DocumentModel::Entry *entry = DocumentModel::firstRestoredDocument();
if (entry) {
activateEditorForEntry(view, entry, flags);
} else {
// no "restored" ones, so any entry left should have a document
- const QList<DocumentModel::Entry *> documents = d->m_documentModel->documents();
+ const QList<DocumentModel::Entry *> documents = DocumentModel::documents();
if (!documents.isEmpty()) {
IDocument *document = documents.last()->document;
if (document)
@@ -1173,8 +1172,7 @@ bool EditorManager::closeEditors(const QList<IEditor*> &editorsToClose, bool ask
Core::IEditor *EditorManager::pickUnusedEditor(EditorView **foundView)
{
- foreach (IEditor *editor,
- d->m_documentModel->editorsForDocuments(d->m_documentModel->openedDocuments())) {
+ foreach (IEditor *editor, DocumentModel::editorsForOpenedDocuments()) {
EditorView *view = viewForEditor(editor);
if (!view || view->currentEditor() != editor) {
if (foundView)
@@ -1206,7 +1204,7 @@ void EditorManager::activateEditorForEntry(Internal::EditorView *view, DocumentM
}
if (!openEditor(view, entry->fileName(), entry->id(), flags))
- d->m_documentModel->removeEntry(entry);
+ DocumentModel::removeEntry(entry);
}
void EditorManager::activateView(EditorView *view)
@@ -1312,7 +1310,7 @@ Core::IEditor *EditorManager::activateEditorForDocument(Core::Internal::EditorVi
Q_ASSERT(view);
IEditor *editor = view->editorForDocument(document);
if (!editor) {
- const QList<IEditor*> editors = d->m_documentModel->editorsForDocument(document);
+ const QList<IEditor*> editors = DocumentModel::editorsForDocument(document);
if (editors.isEmpty())
return 0;
editor = editors.first();
@@ -1433,7 +1431,7 @@ void EditorManager::addEditor(IEditor *editor)
ICore::addContextObject(editor);
bool isNewDocument = false;
- d->m_documentModel->addEditor(editor, &isNewDocument);
+ DocumentModel::addEditor(editor, &isNewDocument);
if (isNewDocument) {
const bool isTemporary = editor->document()->isTemporary();
const bool addWatcher = !isTemporary;
@@ -1591,7 +1589,7 @@ IEditor *EditorManager::openEditor(Core::Internal::EditorView *view, const QStri
if (newEditor)
*newEditor = false;
- const QList<IEditor *> editors = d->m_documentModel->editorsForFilePath(fn);
+ const QList<IEditor *> editors = DocumentModel::editorsForFilePath(fn);
if (!editors.isEmpty()) {
IEditor *editor = editors.first();
editor = activateEditor(view, editor, flags);
@@ -1688,7 +1686,7 @@ IEditor *EditorManager::openEditorWithContents(const Id &editorId,
if (base.contains(dollar)) {
int i = 1;
QSet<QString> docnames;
- foreach (DocumentModel::Entry *entry, d->m_documentModel->documents()) {
+ foreach (DocumentModel::Entry *entry, DocumentModel::documents()) {
QString name = entry->fileName();
if (name.isEmpty())
name = entry->displayName();
@@ -1786,7 +1784,7 @@ void EditorManager::autoSave()
{
QStringList errors;
// FIXME: the saving should be staggered
- foreach (IDocument *document, d->m_documentModel->openedDocuments()) {
+ foreach (IDocument *document, DocumentModel::openedDocuments()) {
if (!document->isModified() || !document->shouldAutoSave())
continue;
if (document->filePath().isEmpty()) // FIXME: save them to a dedicated directory
@@ -1836,7 +1834,7 @@ bool EditorManager::saveDocumentAs(IDocument *documentParam)
if (absoluteFilePath != document->filePath()) {
// close existing editors for the new file name
- IDocument *otherDocument = d->m_documentModel->documentForFilePath(absoluteFilePath);
+ IDocument *otherDocument = DocumentModel::documentForFilePath(absoluteFilePath);
if (otherDocument)
closeDocuments(QList<IDocument *>() << otherDocument, false);
}
@@ -1862,7 +1860,7 @@ void EditorManager::addDocumentToRecentFiles(IDocument *document)
{
if (document->isTemporary())
return;
- DocumentModel::Entry *entry = d->m_documentModel->entryForDocument(document);
+ DocumentModel::Entry *entry = DocumentModel::entryForDocument(document);
if (!entry)
return;
DocumentManager::addToRecentFiles(document->filePath(), entry->id());
@@ -1875,7 +1873,7 @@ void EditorManager::gotoNextDocHistory()
dialog->selectNextEditor();
} else {
EditorView *view = currentEditorView();
- dialog->setEditors(d->m_globalHistory, view, d->m_documentModel);
+ dialog->setEditors(d->m_globalHistory, view);
dialog->selectNextEditor();
showPopupOrSelectDocument();
}
@@ -1888,7 +1886,7 @@ void EditorManager::gotoPreviousDocHistory()
dialog->selectPreviousEditor();
} else {
EditorView *view = currentEditorView();
- dialog->setEditors(d->m_globalHistory, view, d->m_documentModel);
+ dialog->setEditors(d->m_globalHistory, view);
dialog->selectPreviousEditor();
showPopupOrSelectDocument();
}
@@ -2021,7 +2019,7 @@ void EditorManager::setupSaveActions(IDocument *document, QAction *saveAction, Q
void EditorManager::updateActions()
{
IDocument *curDocument = currentDocument();
- int openedCount = d->m_documentModel->documentCount();
+ const int openedCount = DocumentModel::documentCount();
if (curDocument) {
if (HostOsInfo::isMacHost())
@@ -2045,10 +2043,10 @@ void EditorManager::updateActions()
d->m_closeOtherEditorsAction->setEnabled(openedCount > 1);
d->m_closeOtherEditorsAction->setText((openedCount > 1 ? tr("Close All Except %1").arg(quotedName) : tr("Close Others")));
- d->m_closeAllEditorsExceptVisibleAction->setEnabled(visibleDocumentsCount() < d->m_documentModel->documents().count());
+ d->m_closeAllEditorsExceptVisibleAction->setEnabled(visibleDocumentsCount() < openedCount);
- d->m_gotoNextDocHistoryAction->setEnabled(d->m_documentModel->rowCount() != 0);
- d->m_gotoPreviousDocHistoryAction->setEnabled(d->m_documentModel->rowCount() != 0);
+ d->m_gotoNextDocHistoryAction->setEnabled(openedCount != 0);
+ d->m_gotoPreviousDocHistoryAction->setEnabled(openedCount != 0);
EditorView *view = currentEditorView();
d->m_goBackAction->setEnabled(view ? view->canGoBack() : false);
d->m_goForwardAction->setEnabled(view ? view->canGoForward() : false);
@@ -2121,14 +2119,9 @@ int EditorManager::visibleDocumentsCount()
return visibleDocuments.count();
}
-DocumentModel *EditorManager::documentModel()
-{
- return d->m_documentModel;
-}
-
bool EditorManager::closeDocuments(const QList<IDocument *> &document, bool askAboutModifiedEditors)
{
- return m_instance->closeEditors(d->m_documentModel->editorsForDocuments(document), askAboutModifiedEditors);
+ return m_instance->closeEditors(DocumentModel::editorsForDocuments(document), askAboutModifiedEditors);
}
void EditorManager::addCurrentPositionToNavigationHistory(IEditor *editor, const QByteArray &saveState)
@@ -2200,10 +2193,10 @@ QByteArray EditorManager::saveState()
stream << QByteArray("EditorManagerV4");
// TODO: In case of split views it's not possible to restore these for all correctly with this
- QList<IDocument *> documents = d->m_documentModel->openedDocuments();
+ QList<IDocument *> documents = DocumentModel::openedDocuments();
foreach (IDocument *document, documents) {
if (!document->filePath().isEmpty() && !document->isTemporary()) {
- IEditor *editor = d->m_documentModel->editorsForDocument(document).first();
+ IEditor *editor = DocumentModel::editorsForDocument(document).first();
QByteArray state = editor->saveState();
if (!state.isEmpty())
d->m_editorStates.insert(document->filePath(), QVariant(state));
@@ -2212,7 +2205,7 @@ QByteArray EditorManager::saveState()
stream << d->m_editorStates;
- QList<DocumentModel::Entry *> entries = d->m_documentModel->documents();
+ QList<DocumentModel::Entry *> entries = DocumentModel::documents();
int entriesCount = 0;
foreach (DocumentModel::Entry *entry, entries) {
// The editor may be 0 if it was not loaded yet: In that case it is not temporary
@@ -2270,7 +2263,7 @@ bool EditorManager::restoreState(const QByteArray &state)
if (rfi.exists() && fi.lastModified() < rfi.lastModified())
openEditor(fileName, id, DoNotMakeVisible);
else
- d->m_documentModel->addRestoredDocument(fileName, displayName, id);
+ DocumentModel::addRestoredDocument(fileName, displayName, id);
}
}
diff --git a/src/plugins/coreplugin/editormanager/editormanager.h b/src/plugins/coreplugin/editormanager/editormanager.h
index fdae4ea1e6..d75d8effb0 100644
--- a/src/plugins/coreplugin/editormanager/editormanager.h
+++ b/src/plugins/coreplugin/editormanager/editormanager.h
@@ -132,7 +132,6 @@ public:
static IEditor *activateEditorForDocument(IDocument *document, OpenEditorFlags flags = 0);
static IEditor *activateEditorForDocument(Internal::EditorView *view, IDocument *document, OpenEditorFlags flags = 0);
- static DocumentModel *documentModel();
static bool closeDocuments(const QList<IDocument *> &documents, bool askAboutModifiedEditors = true);
static void closeEditor(DocumentModel::Entry *entry);
static void closeOtherEditors(IDocument *document);
diff --git a/src/plugins/coreplugin/editormanager/editorview.cpp b/src/plugins/coreplugin/editormanager/editorview.cpp
index c530f54f4c..833dcd02ca 100644
--- a/src/plugins/coreplugin/editormanager/editorview.cpp
+++ b/src/plugins/coreplugin/editormanager/editorview.cpp
@@ -302,8 +302,7 @@ IEditor *EditorView::currentEditor() const
void EditorView::listSelectionActivated(int index)
{
- EditorManager::activateEditorForEntry(
- this, EditorManager::documentModel()->documentAtRow(index));
+ EditorManager::activateEditorForEntry(this, DocumentModel::documentAtRow(index));
}
void EditorView::splitHorizontally()
@@ -802,7 +801,7 @@ void SplitterOrView::restoreState(const QByteArray &state)
| Core::EditorManager::DoNotChangeCurrentEditor);
if (!e) {
- DocumentModel::Entry *entry = EditorManager::documentModel()->firstRestoredDocument();
+ DocumentModel::Entry *entry = DocumentModel::firstRestoredDocument();
if (entry)
EditorManager::activateEditorForEntry(view(), entry, Core::EditorManager::IgnoreNavigationHistory
| Core::EditorManager::DoNotChangeCurrentEditor);
diff --git a/src/plugins/coreplugin/editormanager/openeditorsview.cpp b/src/plugins/coreplugin/editormanager/openeditorsview.cpp
index a57f5cef7a..23c7459022 100644
--- a/src/plugins/coreplugin/editormanager/openeditorsview.cpp
+++ b/src/plugins/coreplugin/editormanager/openeditorsview.cpp
@@ -97,7 +97,7 @@ OpenEditorsWidget::OpenEditorsWidget()
setFrameStyle(QFrame::NoFrame);
setAttribute(Qt::WA_MacShowFocusRect, false);
m_model = new ProxyModel(this);
- m_model->setSourceModel(EditorManager::documentModel());
+ m_model->setSourceModel(DocumentModel::model());
setModel(m_model);
setSelectionMode(QAbstractItemView::SingleSelection);
setSelectionBehavior(QAbstractItemView::SelectRows);
@@ -128,7 +128,7 @@ OpenEditorsWidget::~OpenEditorsWidget()
void OpenEditorsWidget::updateCurrentItem(Core::IEditor *editor)
{
IDocument *document = editor ? editor->document() : 0;
- QModelIndex index = m_model->index(EditorManager::documentModel()->indexOfDocument(document), 0);
+ QModelIndex index = m_model->index(DocumentModel::indexOfDocument(document), 0);
if (!index.isValid()) {
clearSelection();
return;
@@ -189,13 +189,13 @@ void OpenEditorsWidget::activateEditor(const QModelIndex &index)
{
selectionModel()->select(index, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
EditorManager::activateEditorForEntry(
- EditorManager::documentModel()->documentAtRow(m_model->mapToSource(index).row()));
+ DocumentModel::documentAtRow(m_model->mapToSource(index).row()));
}
void OpenEditorsWidget::closeEditor(const QModelIndex &index)
{
EditorManager::closeEditor(
- EditorManager::documentModel()->documentAtRow(m_model->mapToSource(index).row()));
+ DocumentModel::documentAtRow(m_model->mapToSource(index).row()));
// work around selection changes
updateCurrentItem(EditorManager::currentEditor());
}
@@ -204,7 +204,7 @@ void OpenEditorsWidget::contextMenuRequested(QPoint pos)
{
QMenu contextMenu;
QModelIndex editorIndex = indexAt(pos);
- DocumentModel::Entry *entry = EditorManager::documentModel()->documentAtRow(
+ DocumentModel::Entry *entry = DocumentModel::documentAtRow(
m_model->mapToSource(editorIndex).row());
EditorManager::addSaveAndCloseEditorActions(&contextMenu, entry);
contextMenu.addSeparator();
diff --git a/src/plugins/coreplugin/editormanager/openeditorswindow.cpp b/src/plugins/coreplugin/editormanager/openeditorswindow.cpp
index f9ca07f748..48fa7e4562 100644
--- a/src/plugins/coreplugin/editormanager/openeditorswindow.cpp
+++ b/src/plugins/coreplugin/editormanager/openeditorswindow.cpp
@@ -194,18 +194,18 @@ void OpenEditorsWindow::centerOnItem(int selectedIndex)
}
}
-void OpenEditorsWindow::setEditors(const QList<EditLocation> &globalHistory, EditorView *view, DocumentModel *model)
+void OpenEditorsWindow::setEditors(const QList<EditLocation> &globalHistory, EditorView *view)
{
m_editorList->clear();
QSet<IDocument*> documentsDone;
- addHistoryItems(view->editorHistory(), view, model, documentsDone);
+ addHistoryItems(view->editorHistory(), view, documentsDone);
// add missing editors from the global history
- addHistoryItems(globalHistory, view, model, documentsDone);
+ addHistoryItems(globalHistory, view, documentsDone);
// add purely restored editors which are not initialised yet
- addRestoredItems(model);
+ addRestoredItems();
}
@@ -219,7 +219,7 @@ void OpenEditorsWindow::selectEditor(QTreeWidgetItem *item)
} else {
if (!EditorManager::openEditor(
item->toolTip(0), item->data(0, Qt::UserRole+2).value<Core::Id>())) {
- EditorManager::documentModel()->removeDocument(item->toolTip(0));
+ DocumentModel::removeDocument(item->toolTip(0));
delete item;
}
}
@@ -239,7 +239,7 @@ void OpenEditorsWindow::ensureCurrentVisible()
void OpenEditorsWindow::addHistoryItems(const QList<EditLocation> &history, EditorView *view,
- DocumentModel *model, QSet<IDocument *> &documentsDone)
+ QSet<IDocument *> &documentsDone)
{
foreach (const EditLocation &hi, history) {
if (hi.document.isNull() || documentsDone.contains(hi.document))
@@ -251,7 +251,7 @@ void OpenEditorsWindow::addHistoryItems(const QList<EditLocation> &history, Edit
if (hi.document->isModified())
title += tr("*");
item->setIcon(0, !hi.document->filePath().isEmpty() && hi.document->isFileReadOnly()
- ? model->lockedIcon() : m_emptyIcon);
+ ? DocumentModel::lockedIcon() : m_emptyIcon);
item->setText(0, title);
item->setToolTip(0, hi.document->filePath());
item->setData(0, Qt::UserRole, QVariant::fromValue(hi.document.data()));
@@ -265,9 +265,9 @@ void OpenEditorsWindow::addHistoryItems(const QList<EditLocation> &history, Edit
}
}
-void OpenEditorsWindow::addRestoredItems(DocumentModel *model)
+void OpenEditorsWindow::addRestoredItems()
{
- foreach (DocumentModel::Entry *entry, model->documents()) {
+ foreach (DocumentModel::Entry *entry, DocumentModel::documents()) {
if (entry->document)
continue;
QTreeWidgetItem *item = new QTreeWidgetItem();
diff --git a/src/plugins/coreplugin/editormanager/openeditorswindow.h b/src/plugins/coreplugin/editormanager/openeditorswindow.h
index e74badb706..478d9eaabc 100644
--- a/src/plugins/coreplugin/editormanager/openeditorswindow.h
+++ b/src/plugins/coreplugin/editormanager/openeditorswindow.h
@@ -45,7 +45,6 @@ namespace Core {
class IDocument;
class IEditor;
-class DocumentModel;
namespace Internal {
@@ -60,7 +59,7 @@ public:
explicit OpenEditorsWindow(QWidget *parent = 0);
- void setEditors(const QList<EditLocation> &globalHistory, EditorView *view, DocumentModel *model);
+ void setEditors(const QList<EditLocation> &globalHistory, EditorView *view);
bool eventFilter(QObject *src, QEvent *e);
void focusInEvent(QFocusEvent *);
@@ -76,9 +75,8 @@ private slots:
void selectEditor(QTreeWidgetItem *item);
private:
- void addHistoryItems(const QList<EditLocation> &history, EditorView *view,
- DocumentModel *model, QSet<IDocument*> &documentsDone);
- void addRestoredItems(DocumentModel *model);
+ void addHistoryItems(const QList<EditLocation> &history, EditorView *view, QSet<IDocument*> &documentsDone);
+ void addRestoredItems();
void ensureCurrentVisible();
bool isCentering();
void centerOnItem(int selectedIndex);
diff --git a/src/plugins/coreplugin/editortoolbar.cpp b/src/plugins/coreplugin/editortoolbar.cpp
index 3d647a9f89..fabdbfa5e5 100644
--- a/src/plugins/coreplugin/editortoolbar.cpp
+++ b/src/plugins/coreplugin/editortoolbar.cpp
@@ -54,10 +54,10 @@ enum {
namespace Core {
-struct EditorToolBarPrivate {
+struct EditorToolBarPrivate
+{
explicit EditorToolBarPrivate(QWidget *parent, EditorToolBar *q);
- Core::DocumentModel *m_editorsListModel;
QComboBox *m_editorList;
QToolButton *m_closeEditorButton;
QToolButton *m_lockButton;
@@ -115,7 +115,6 @@ EditorToolBar::EditorToolBar(QWidget *parent) :
d->m_lockButton->setAutoRaise(true);
d->m_lockButton->setEnabled(false);
- d->m_editorsListModel = EditorManager::documentModel();
connect(d->m_goBackAction, SIGNAL(triggered()), this, SIGNAL(goBackClicked()));
connect(d->m_goForwardAction, SIGNAL(triggered()), this, SIGNAL(goForwardClicked()));
@@ -123,7 +122,7 @@ EditorToolBar::EditorToolBar(QWidget *parent) :
d->m_editorList->setProperty("notelideasterisk", true);
d->m_editorList->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
d->m_editorList->setMinimumContentsLength(20);
- d->m_editorList->setModel(d->m_editorsListModel);
+ d->m_editorList->setModel(DocumentModel::model());
d->m_editorList->setMaxVisibleItems(40);
d->m_editorList->setContextMenuPolicy(Qt::CustomContextMenu);
@@ -291,7 +290,7 @@ void EditorToolBar::setToolbarCreationFlags(ToolbarCreationFlags flags)
void EditorToolBar::setCurrentEditor(IEditor *editor)
{
IDocument *document = editor ? editor->document() : 0;
- d->m_editorList->setCurrentIndex(d->m_editorsListModel->rowOfDocument(document));
+ d->m_editorList->setCurrentIndex(DocumentModel::rowOfDocument(document));
// If we never added the toolbar from the editor, we will never change
// the editor, so there's no need to update the toolbar either.
@@ -304,17 +303,17 @@ void EditorToolBar::setCurrentEditor(IEditor *editor)
void EditorToolBar::updateEditorListSelection(IEditor *newSelection)
{
if (newSelection)
- d->m_editorList->setCurrentIndex(d->m_editorsListModel->rowOfDocument(newSelection->document()));
+ d->m_editorList->setCurrentIndex(DocumentModel::rowOfDocument(newSelection->document()));
}
void EditorToolBar::changeActiveEditor(int row)
{
- EditorManager::activateEditorForEntry(d->m_editorsListModel->documentAtRow(row));
+ EditorManager::activateEditorForEntry(DocumentModel::documentAtRow(row));
}
void EditorToolBar::listContextMenu(QPoint pos)
{
- DocumentModel::Entry *entry = EditorManager::documentModel()->documentAtRow(
+ DocumentModel::Entry *entry = DocumentModel::documentAtRow(
d->m_editorList->currentIndex());
QString fileName = entry ? entry->fileName() : QString();
QString shortFileName = entry ? QFileInfo(fileName).fileName() : QString();
@@ -362,7 +361,7 @@ void EditorToolBar::checkDocumentStatus()
{
IDocument *document = qobject_cast<IDocument *>(sender());
QTC_ASSERT(document, return);
- DocumentModel::Entry *entry = EditorManager::documentModel()->documentAtRow(
+ DocumentModel::Entry *entry = DocumentModel::documentAtRow(
d->m_editorList->currentIndex());
if (entry && entry->document && entry->document == document)
@@ -381,18 +380,18 @@ void EditorToolBar::updateDocumentStatus(IDocument *document)
return;
}
- d->m_editorList->setCurrentIndex(d->m_editorsListModel->rowOfDocument(document));
+ d->m_editorList->setCurrentIndex(DocumentModel::rowOfDocument(document));
if (document->filePath().isEmpty()) {
d->m_lockButton->setIcon(QIcon());
d->m_lockButton->setEnabled(false);
d->m_lockButton->setToolTip(QString());
} else if (document->isFileReadOnly()) {
- d->m_lockButton->setIcon(QIcon(d->m_editorsListModel->lockedIcon()));
+ d->m_lockButton->setIcon(DocumentModel::lockedIcon());
d->m_lockButton->setEnabled(true);
d->m_lockButton->setToolTip(tr("Make Writable"));
} else {
- d->m_lockButton->setIcon(QIcon(d->m_editorsListModel->unlockedIcon()));
+ d->m_lockButton->setIcon(DocumentModel::unlockedIcon());
d->m_lockButton->setEnabled(false);
d->m_lockButton->setToolTip(tr("File is writable"));
}
diff --git a/src/plugins/coreplugin/locator/opendocumentsfilter.cpp b/src/plugins/coreplugin/locator/opendocumentsfilter.cpp
index f6f3bb9756..fe1c5ca003 100644
--- a/src/plugins/coreplugin/locator/opendocumentsfilter.cpp
+++ b/src/plugins/coreplugin/locator/opendocumentsfilter.cpp
@@ -91,7 +91,7 @@ QList<LocatorFilterEntry> OpenDocumentsFilter::matchesFor(QFutureInterface<Core:
void OpenDocumentsFilter::refreshInternally()
{
m_editors.clear();
- foreach (DocumentModel::Entry *e, EditorManager::documentModel()->documents()) {
+ foreach (DocumentModel::Entry *e, DocumentModel::documents()) {
DocumentModel::Entry entry;
// create copy with only the information relevant to use
// to avoid model deleting entries behind our back
diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp
index cc7e8e82d4..98888ef4df 100644
--- a/src/plugins/cppeditor/cppeditor.cpp
+++ b/src/plugins/cppeditor/cppeditor.cpp
@@ -1700,7 +1700,7 @@ void CPPEditorWidget::onFunctionDeclDefLinkFound(QSharedPointer<FunctionDeclDefL
{
abortDeclDefLink();
m_declDefLink = link;
- Core::IDocument *targetDocument = Core::EditorManager::documentModel()->documentForFilePath(
+ Core::IDocument *targetDocument = Core::DocumentModel::documentForFilePath(
m_declDefLink->targetFile->fileName());
if (baseTextDocument() != targetDocument) {
if (TextEditor::ITextEditorDocument *textEditorDocument = qobject_cast<TextEditor::ITextEditorDocument *>(targetDocument))
@@ -1749,7 +1749,7 @@ void CPPEditorWidget::abortDeclDefLink()
if (!m_declDefLink)
return;
- Core::IDocument *targetDocument = Core::EditorManager::documentModel()->documentForFilePath(
+ Core::IDocument *targetDocument = Core::DocumentModel::documentForFilePath(
m_declDefLink->targetFile->fileName());
if (baseTextDocument() != targetDocument) {
if (TextEditor::ITextEditorDocument *textEditorDocument = qobject_cast<TextEditor::ITextEditorDocument *>(targetDocument))
diff --git a/src/plugins/cppeditor/fileandtokenactions_test.cpp b/src/plugins/cppeditor/fileandtokenactions_test.cpp
index a5e6601a32..2cc10c1359 100644
--- a/src/plugins/cppeditor/fileandtokenactions_test.cpp
+++ b/src/plugins/cppeditor/fileandtokenactions_test.cpp
@@ -183,12 +183,12 @@ TestActionsTestCase::TestActionsTestCase(const Actions &tokenActions, const Acti
undoAllChangesAndCloseAllEditors();
// Open editor
- QCOMPARE(EditorManager::documentModel()->openedDocuments().size(), 0);
+ QCOMPARE(DocumentModel::openedDocuments().size(), 0);
CPPEditor *editor;
CPPEditorWidget *editorWidget;
QVERIFY(openCppEditor(filePath, &editor, &editorWidget));
- QCOMPARE(EditorManager::documentModel()->openedDocuments().size(), 1);
+ QCOMPARE(DocumentModel::openedDocuments().size(), 1);
QVERIFY(m_modelManager->isCppEditor(editor));
QVERIFY(m_modelManager->workingCopy().contains(filePath));
@@ -268,7 +268,7 @@ void TestActionsTestCase::undoChangesInDocument(BaseTextDocument *editorDocument
void TestActionsTestCase::undoChangesInAllEditorWidgets()
{
- foreach (IDocument *document, EditorManager::documentModel()->openedDocuments()) {
+ foreach (IDocument *document, DocumentModel::openedDocuments()) {
BaseTextDocument *baseTextDocument = qobject_cast<BaseTextDocument *>(document);
undoChangesInDocument(baseTextDocument);
}
@@ -309,7 +309,7 @@ void TestActionsTestCase::undoAllChangesAndCloseAllEditors()
undoChangesInAllEditorWidgets();
EditorManager::closeAllEditors(/*askAboutModifiedEditors =*/ false);
QApplication::processEvents();
- QCOMPARE(EditorManager::documentModel()->openedDocuments().size(), 0);
+ QCOMPARE(DocumentModel::openedDocuments().size(), 0);
}
void TestActionsTestCase::configureAllProjects(const QList<QPointer<ProjectExplorer::Project> >
diff --git a/src/plugins/cpptools/cpplocatorfilter_test.cpp b/src/plugins/cpptools/cpplocatorfilter_test.cpp
index 175ba94ea8..b5da11f00f 100644
--- a/src/plugins/cpptools/cpplocatorfilter_test.cpp
+++ b/src/plugins/cpptools/cpplocatorfilter_test.cpp
@@ -113,7 +113,7 @@ public:
private:
void doBeforeLocatorRun()
{
- QVERIFY(EditorManager::documentModel()->openedDocuments().isEmpty());
+ QVERIFY(DocumentModel::openedDocuments().isEmpty());
QVERIFY(garbageCollectGlobalSnapshot());
m_editor = EditorManager::openEditor(m_fileName);
@@ -126,7 +126,7 @@ private:
{
QVERIFY(closeEditorWithoutGarbageCollectorInvocation(m_editor));
QCoreApplication::processEvents();
- QVERIFY(EditorManager::documentModel()->openedDocuments().isEmpty());
+ QVERIFY(DocumentModel::openedDocuments().isEmpty());
QVERIFY(garbageCollectGlobalSnapshot());
}
diff --git a/src/plugins/cpptools/cppmodelmanager_test.cpp b/src/plugins/cpptools/cppmodelmanager_test.cpp
index 7f2b7765c8..04f6651095 100644
--- a/src/plugins/cpptools/cppmodelmanager_test.cpp
+++ b/src/plugins/cpptools/cppmodelmanager_test.cpp
@@ -710,10 +710,10 @@ void CppToolsPlugin::test_modelmanager_gc_if_last_cppeditor_closed()
helper.resetRefreshedSourceFiles();
// Open a file in the editor
- QCOMPARE(Core::EditorManager::documentModel()->openedDocuments().size(), 0);
+ QCOMPARE(Core::DocumentModel::openedDocuments().size(), 0);
Core::IEditor *editor = Core::EditorManager::openEditor(file);
QVERIFY(editor);
- QCOMPARE(Core::EditorManager::documentModel()->openedDocuments().size(), 1);
+ QCOMPARE(Core::DocumentModel::openedDocuments().size(), 1);
QVERIFY(mm->isCppEditor(editor));
QVERIFY(mm->workingCopy().contains(file));
@@ -741,10 +741,10 @@ void CppToolsPlugin::test_modelmanager_dont_gc_opened_files()
helper.resetRefreshedSourceFiles();
// Open a file in the editor
- QCOMPARE(Core::EditorManager::documentModel()->openedDocuments().size(), 0);
+ QCOMPARE(Core::DocumentModel::openedDocuments().size(), 0);
Core::IEditor *editor = Core::EditorManager::openEditor(file);
QVERIFY(editor);
- QCOMPARE(Core::EditorManager::documentModel()->openedDocuments().size(), 1);
+ QCOMPARE(Core::DocumentModel::openedDocuments().size(), 1);
QVERIFY(mm->isCppEditor(editor));
// Wait until the file is refreshed and check whether it is in the working copy
@@ -832,7 +832,7 @@ void CppToolsPlugin::test_modelmanager_defines_per_project()
QCOMPARE(mm->snapshot().size(), 4);
// Open a file in the editor
- QCOMPARE(Core::EditorManager::documentModel()->openedDocuments().size(), 0);
+ QCOMPARE(Core::DocumentModel::openedDocuments().size(), 0);
struct Data {
QString firstDeclarationName;
@@ -849,7 +849,7 @@ void CppToolsPlugin::test_modelmanager_defines_per_project()
Core::IEditor *editor = Core::EditorManager::openEditor(fileName);
EditorCloser closer(editor);
QVERIFY(editor);
- QCOMPARE(Core::EditorManager::documentModel()->openedDocuments().size(), 1);
+ QCOMPARE(Core::DocumentModel::openedDocuments().size(), 1);
QVERIFY(mm->isCppEditor(editor));
CppEditorSupport *sup = mm->cppEditorSupport(
@@ -903,7 +903,7 @@ void CppToolsPlugin::test_modelmanager_defines_per_project_pch()
QCOMPARE(mm->snapshot().size(), 4);
// Open a file in the editor
- QCOMPARE(Core::EditorManager::documentModel()->openedDocuments().size(), 0);
+ QCOMPARE(Core::DocumentModel::openedDocuments().size(), 0);
struct Data {
QString firstDeclarationName;
@@ -920,7 +920,7 @@ void CppToolsPlugin::test_modelmanager_defines_per_project_pch()
Core::IEditor *editor = Core::EditorManager::openEditor(fileName);
EditorCloser closer(editor);
QVERIFY(editor);
- QCOMPARE(Core::EditorManager::documentModel()->openedDocuments().size(), 1);
+ QCOMPARE(Core::DocumentModel::openedDocuments().size(), 1);
QVERIFY(mm->isCppEditor(editor));
CppEditorSupport *sup = mm->cppEditorSupport(
@@ -972,7 +972,7 @@ void CppToolsPlugin::test_modelmanager_defines_per_editor()
QCOMPARE(mm->snapshot().size(), 4);
// Open a file in the editor
- QCOMPARE(Core::EditorManager::documentModel()->openedDocuments().size(), 0);
+ QCOMPARE(Core::DocumentModel::openedDocuments().size(), 0);
struct Data {
QString editorDefines;
@@ -989,7 +989,7 @@ void CppToolsPlugin::test_modelmanager_defines_per_editor()
Core::IEditor *editor = Core::EditorManager::openEditor(main1File);
EditorCloser closer(editor);
QVERIFY(editor);
- QCOMPARE(Core::EditorManager::documentModel()->openedDocuments().size(), 1);
+ QCOMPARE(Core::DocumentModel::openedDocuments().size(), 1);
QVERIFY(mm->isCppEditor(editor));
CppEditorSupport *sup = mm->cppEditorSupport(
diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp
index c7f109a708..72f25eb550 100644
--- a/src/plugins/debugger/debuggerplugin.cpp
+++ b/src/plugins/debugger/debuggerplugin.cpp
@@ -2144,7 +2144,7 @@ void DebuggerPluginPrivate::cleanupViews()
return;
QList<IDocument *> toClose;
- foreach (IDocument *document, EditorManager::documentModel()->openedDocuments()) {
+ foreach (IDocument *document, DocumentModel::openedDocuments()) {
if (document->property(Constants::OPENED_BY_DEBUGGER).toBool()) {
bool keepIt = true;
if (document->property(Constants::OPENED_WITH_DISASSEMBLY).toBool())
diff --git a/src/plugins/debugger/debuggertooltipmanager.cpp b/src/plugins/debugger/debuggertooltipmanager.cpp
index 1e8c3d7266..9d4ea2bae7 100644
--- a/src/plugins/debugger/debuggertooltipmanager.cpp
+++ b/src/plugins/debugger/debuggertooltipmanager.cpp
@@ -1380,8 +1380,7 @@ void DebuggerToolTipManager::debugModeEntered()
this, SLOT(slotUpdateVisibleToolTips()));
connect(em, SIGNAL(editorOpened(Core::IEditor*)),
this, SLOT(slotEditorOpened(Core::IEditor*)));
- DocumentModel *documentModel = EditorManager::documentModel();
- foreach (IEditor *e, documentModel->editorsForDocuments(documentModel->openedDocuments()))
+ foreach (IEditor *e, DocumentModel::editorsForOpenedDocuments())
slotEditorOpened(e);
// Position tooltips delayed once all the editor placeholder layouting is done.
if (!d->m_tooltips.isEmpty())
@@ -1400,8 +1399,7 @@ void DebuggerToolTipManager::leavingDebugMode()
hide();
if (QWidget *topLevel = ICore::mainWindow()->topLevelWidget())
topLevel->removeEventFilter(this);
- DocumentModel *documentModel = EditorManager::documentModel();
- foreach (IEditor *e, documentModel->editorsForDocuments(documentModel->openedDocuments())) {
+ foreach (IEditor *e, DocumentModel::editorsForOpenedDocuments()) {
DebuggerToolTipEditor toolTipEditor = DebuggerToolTipEditor(e);
if (toolTipEditor.isValid()) {
toolTipEditor.widget->verticalScrollBar()->disconnect(this);
diff --git a/src/plugins/debugger/disassembleragent.cpp b/src/plugins/debugger/disassembleragent.cpp
index ebcec8cca6..da900611c7 100644
--- a/src/plugins/debugger/disassembleragent.cpp
+++ b/src/plugins/debugger/disassembleragent.cpp
@@ -249,7 +249,7 @@ void DisassemblerAgentPrivate::configureMimeType()
MimeType mtype = MimeDatabase::findByType(mimeType);
if (mtype) {
- foreach (IEditor *editor, EditorManager::documentModel()->editorsForDocument(document))
+ foreach (IEditor *editor, DocumentModel::editorsForDocument(document))
if (PlainTextEditorWidget *widget = qobject_cast<PlainTextEditorWidget *>(editor->widget()))
widget->configure(mtype);
} else {
diff --git a/src/plugins/debugger/qml/qmlengine.cpp b/src/plugins/debugger/qml/qmlengine.cpp
index 95c5724e7e..63707d00d6 100644
--- a/src/plugins/debugger/qml/qmlengine.cpp
+++ b/src/plugins/debugger/qml/qmlengine.cpp
@@ -542,7 +542,7 @@ void QmlEngine::gotoLocation(const Location &location)
QString titlePattern = tr("JS Source for %1").arg(fileName);
//Check if there are open documents with the same title
- foreach (Core::IDocument *document, Core::EditorManager::documentModel()->openedDocuments()) {
+ foreach (Core::IDocument *document, Core::DocumentModel::openedDocuments()) {
if (document->displayName() == titlePattern) {
Core::EditorManager::activateEditorForDocument(document);
return;
@@ -1310,7 +1310,7 @@ void QmlEngine::updateScriptSource(const QString &fileName, int lineOffset, int
//update open editors
QString titlePattern = tr("JS Source for %1").arg(fileName);
//Check if there are open editors with the same title
- foreach (Core::IDocument *doc, Core::EditorManager::documentModel()->openedDocuments()) {
+ foreach (Core::IDocument *doc, Core::DocumentModel::openedDocuments()) {
if (doc->displayName() == titlePattern) {
updateDocument(doc, document);
break;
diff --git a/src/plugins/debugger/qml/qmlinspectoradapter.cpp b/src/plugins/debugger/qml/qmlinspectoradapter.cpp
index b2cb9ccee2..914b7b388f 100644
--- a/src/plugins/debugger/qml/qmlinspectoradapter.cpp
+++ b/src/plugins/debugger/qml/qmlinspectoradapter.cpp
@@ -354,7 +354,7 @@ void QmlInspectorAdapter::updatePendingPreviewDocuments(QmlJS::Document::Ptr doc
return;
QList<Core::IEditor *> editors
- = Core::EditorManager::documentModel()->editorsForFilePath(doc->fileName());
+ = Core::DocumentModel::editorsForFilePath(doc->fileName());
if (editors.isEmpty())
return;
@@ -456,9 +456,8 @@ void QmlInspectorAdapter::initializePreviews()
}
// initial update
- Core::DocumentModel *documentModel = Core::EditorManager::documentModel();
- foreach (Core::IDocument *document, documentModel->openedDocuments()) {
- QList<Core::IEditor *> editors = documentModel->editorsForDocument(document);
+ foreach (Core::IDocument *document, Core::DocumentModel::openedDocuments()) {
+ QList<Core::IEditor *> editors = Core::DocumentModel::editorsForDocument(document);
createPreviewForEditor(editors.takeFirst());
QmlLiveTextPreview *preview
= m_textPreviews.value(document->filePath());
diff --git a/src/plugins/debugger/qml/qmlv8debuggerclient.cpp b/src/plugins/debugger/qml/qmlv8debuggerclient.cpp
index 803727c8df..1316793217 100644
--- a/src/plugins/debugger/qml/qmlv8debuggerclient.cpp
+++ b/src/plugins/debugger/qml/qmlv8debuggerclient.cpp
@@ -1777,7 +1777,7 @@ void QmlV8DebuggerClient::highlightExceptionCode(int lineNumber,
const QString &filePath,
const QString &errorMessage)
{
- QList<IEditor *> editors = EditorManager::documentModel()->editorsForFilePath(filePath);
+ QList<IEditor *> editors = DocumentModel::editorsForFilePath(filePath);
// set up the format for the errors
QTextCharFormat errorFormat;
@@ -1816,11 +1816,9 @@ void QmlV8DebuggerClient::highlightExceptionCode(int lineNumber,
void QmlV8DebuggerClient::clearExceptionSelection()
{
- DocumentModel *documentModel = EditorManager::documentModel();
- QList<IEditor *> openedEditors = documentModel->editorsForDocuments(documentModel->openedDocuments());
QList<QTextEdit::ExtraSelection> selections;
- foreach (IEditor *editor, openedEditors) {
+ foreach (IEditor *editor, DocumentModel::editorsForOpenedDocuments()) {
TextEditor::BaseTextEditorWidget *ed = qobject_cast<TextEditor::BaseTextEditorWidget *>(editor->widget());
if (!ed)
continue;
diff --git a/src/plugins/designer/gotoslot_test.cpp b/src/plugins/designer/gotoslot_test.cpp
index af3bed23bf..4579bee607 100644
--- a/src/plugins/designer/gotoslot_test.cpp
+++ b/src/plugins/designer/gotoslot_test.cpp
@@ -172,7 +172,7 @@ public:
const QString cppFile = files.at(0);
const QString hFile = files.at(1);
- QCOMPARE(EditorManager::documentModel()->openedDocuments().size(), files.size());
+ QCOMPARE(DocumentModel::openedDocuments().size(), files.size());
waitForFilesInGlobalSnapshot(QStringList() << cppFile << hFile);
// Execute "Go To Slot"
diff --git a/src/plugins/diffeditor/diffeditormanager.cpp b/src/plugins/diffeditor/diffeditormanager.cpp
index f9485ae5f3..4a5815b781 100644
--- a/src/plugins/diffeditor/diffeditormanager.cpp
+++ b/src/plugins/diffeditor/diffeditormanager.cpp
@@ -32,6 +32,7 @@
#include "diffeditorconstants.h"
#include "diffeditordocument.h"
#include <coreplugin/editormanager/editormanager.h>
+#include <coreplugin/editormanager/documentmodel.h>
#include <coreplugin/id.h>
#include <utils/qtcassert.h>
@@ -70,11 +71,10 @@ void DiffEditorManager::slotEditorsClosed(const QList<Core::IEditor *> &editors)
editorsForDocument[document]++;
}
}
- Core::DocumentModel *documentModel = Core::EditorManager::documentModel();
QMapIterator<Core::IDocument *, int> it(editorsForDocument);
while (it.hasNext()) {
it.next();
- if (documentModel->editorsForDocument(it.key()).count() == 0) { // no other editors use that document
+ if (Core::DocumentModel::editorsForDocument(it.key()).count() == 0) { // no other editors use that document
DiffEditorDocument *document
= qobject_cast<DiffEditorDocument *>(it.key());
if (document) {
diff --git a/src/plugins/fakevim/fakevimplugin.cpp b/src/plugins/fakevim/fakevimplugin.cpp
index 2dc0323cb7..9f35c5ba04 100644
--- a/src/plugins/fakevim/fakevimplugin.cpp
+++ b/src/plugins/fakevim/fakevimplugin.cpp
@@ -2149,17 +2149,17 @@ int FakeVimPluginPrivate::currentFile() const
IEditor *editor = EditorManager::currentEditor();
if (!editor)
return -1;
- return EditorManager::documentModel()->indexOfDocument(editor->document());
+ return DocumentModel::indexOfDocument(editor->document());
}
void FakeVimPluginPrivate::switchToFile(int n)
{
- int size = EditorManager::documentModel()->documentCount();
+ int size = DocumentModel::documentCount();
QTC_ASSERT(size, return);
n = n % size;
if (n < 0)
n += size;
- EditorManager::activateEditorForEntry(EditorManager::documentModel()->documents().at(n));
+ EditorManager::activateEditorForEntry(DocumentModel::documents().at(n));
}
ExCommandMap &FakeVimExCommandsPage::exCommandMap()
diff --git a/src/plugins/git/gitclient.cpp b/src/plugins/git/gitclient.cpp
index 7e48fbaf63..68250f9032 100644
--- a/src/plugins/git/gitclient.cpp
+++ b/src/plugins/git/gitclient.cpp
@@ -157,8 +157,7 @@ GitDiffSwitcher::GitDiffSwitcher(Core::IDocument *parentDocument, GitClient *git
m_gitClient(gitClient),
m_signalMapper(new QSignalMapper(this))
{
- Core::DocumentModel *documentModel = Core::EditorManager::documentModel();
- QList<Core::IEditor *> editors = documentModel->editorsForDocument(m_document);
+ QList<Core::IEditor *> editors = Core::DocumentModel::editorsForDocument(m_document);
for (int i = 0; i < editors.count(); i++)
attachAction(editors.at(i));
@@ -938,9 +937,9 @@ private:
Core::IEditor *locateEditor(const char *property, const QString &entry)
{
- foreach (Core::IDocument *document, Core::EditorManager::documentModel()->openedDocuments())
+ foreach (Core::IDocument *document, Core::DocumentModel::openedDocuments())
if (document->property(property).toString() == entry)
- return Core::EditorManager::documentModel()->editorsForDocument(document).first();
+ return Core::DocumentModel::editorsForDocument(document).first();
return 0;
}
diff --git a/src/plugins/git/gitplugin.cpp b/src/plugins/git/gitplugin.cpp
index 494e38a898..f8ad1435bb 100644
--- a/src/plugins/git/gitplugin.cpp
+++ b/src/plugins/git/gitplugin.cpp
@@ -1275,7 +1275,7 @@ void GitPlugin::updateSubmodules()
// If the file is modified in an editor, make sure it is saved.
static bool ensureFileSaved(const QString &fileName)
{
- Core::IDocument *document = Core::EditorManager::documentModel()->documentForFilePath(fileName);
+ Core::IDocument *document = Core::DocumentModel::documentForFilePath(fileName);
return Core::DocumentManager::saveModifiedDocument(document);
}
diff --git a/src/plugins/projectexplorer/editorconfiguration.cpp b/src/plugins/projectexplorer/editorconfiguration.cpp
index a3d3932fe7..eea1b04b19 100644
--- a/src/plugins/projectexplorer/editorconfiguration.cpp
+++ b/src/plugins/projectexplorer/editorconfiguration.cpp
@@ -272,9 +272,7 @@ void EditorConfiguration::setUseGlobalSettings(bool use)
d->m_useGlobal = use;
d->m_defaultCodeStyle->setCurrentDelegate(d->m_useGlobal
? TextEditorSettings::codeStyle() : 0);
- QList<Core::IEditor *> opened = Core::EditorManager::documentModel()->editorsForDocuments(
- Core::EditorManager::documentModel()->openedDocuments());
- foreach (Core::IEditor *editor, opened) {
+ foreach (Core::IEditor *editor, Core::DocumentModel::editorsForOpenedDocuments()) {
if (BaseTextEditorWidget *baseTextEditor = qobject_cast<BaseTextEditorWidget *>(editor->widget())) {
Project *project = SessionManager::projectForFile(editor->document()->filePath());
if (project && project->editorConfiguration() == this)
@@ -386,9 +384,7 @@ void EditorConfiguration::slotAboutToRemoveProject(ProjectExplorer::Project *pro
if (project->editorConfiguration() != this)
return;
- Core::DocumentModel *model = Core::EditorManager::documentModel();
- QList<Core::IEditor *> editors = model->editorsForDocuments(model->openedDocuments());
- foreach (Core::IEditor *editor, editors) {
+ foreach (Core::IEditor *editor, Core::DocumentModel::editorsForOpenedDocuments()) {
if (TextEditor::ITextEditor *textEditor = qobject_cast<TextEditor::ITextEditor*>(editor)) {
Core::IDocument *document = editor->document();
if (document) {
diff --git a/src/plugins/qmakeprojectmanager/qmakenodes.cpp b/src/plugins/qmakeprojectmanager/qmakenodes.cpp
index 606c474450..7011ff819b 100644
--- a/src/plugins/qmakeprojectmanager/qmakenodes.cpp
+++ b/src/plugins/qmakeprojectmanager/qmakenodes.cpp
@@ -1083,7 +1083,7 @@ bool QmakePriFileNode::priFileWritable(const QString &path)
bool QmakePriFileNode::saveModifiedEditors()
{
Core::IDocument *document
- = Core::EditorManager::documentModel()->documentForFilePath(m_projectFilePath);
+ = Core::DocumentModel::documentForFilePath(m_projectFilePath);
if (!document || !document->isModified())
return true;
@@ -1250,7 +1250,7 @@ void QmakePriFileNode::save(const QStringList &lines)
// We manually tell each editor to reload it's file.
// (The .pro files are notified by the file system watcher.)
QStringList errorStrings;
- Core::IDocument *document = Core::EditorManager::documentModel()->documentForFilePath(m_projectFilePath);
+ Core::IDocument *document = Core::DocumentModel::documentForFilePath(m_projectFilePath);
if (document) {
QString errorString;
if (!document->reload(&errorString, Core::IDocument::FlagReload, Core::IDocument::TypeContents))
diff --git a/src/plugins/qmldesigner/shortcutmanager.cpp b/src/plugins/qmldesigner/shortcutmanager.cpp
index a9142a924a..12d51600fb 100644
--- a/src/plugins/qmldesigner/shortcutmanager.cpp
+++ b/src/plugins/qmldesigner/shortcutmanager.cpp
@@ -171,7 +171,7 @@ void ShortCutManager::registerActions(const Core::Context &qmlDesignerMainContex
void ShortCutManager::updateActions(Core::IEditor* currentEditor)
{
- int openedCount = Core::EditorManager::documentModel()->documentCount();
+ int openedCount = Core::DocumentModel::documentCount();
m_saveAction.setEnabled(currentEditor != 0 && currentEditor->document()->isModified());
m_saveAsAction.setEnabled(currentEditor != 0 && currentEditor->document()->isSaveAsAllowed());
diff --git a/src/plugins/qmljseditor/qmljsfindreferences.cpp b/src/plugins/qmljseditor/qmljsfindreferences.cpp
index cbbb44a5d9..42c43f7918 100644
--- a/src/plugins/qmljseditor/qmljsfindreferences.cpp
+++ b/src/plugins/qmljseditor/qmljsfindreferences.cpp
@@ -999,9 +999,8 @@ void FindReferences::onReplaceButtonClicked(const QString &text, const QList<Cor
// files that are opened in an editor are changed, but not saved
QStringList changedOnDisk;
QStringList changedUnsavedEditors;
- DocumentModel *documentModel = EditorManager::documentModel();
foreach (const QString &fileName, fileNames) {
- if (documentModel->documentForFilePath(fileName))
+ if (DocumentModel::documentForFilePath(fileName))
changedOnDisk += fileName;
else
changedUnsavedEditors += fileName;
diff --git a/src/plugins/qmljstools/qmljsmodelmanager.cpp b/src/plugins/qmljstools/qmljsmodelmanager.cpp
index b6c22d78a0..73613b8b48 100644
--- a/src/plugins/qmljstools/qmljsmodelmanager.cpp
+++ b/src/plugins/qmljstools/qmljsmodelmanager.cpp
@@ -249,12 +249,11 @@ void ModelManager::writeMessageInternal(const QString &msg) const
ModelManagerInterface::WorkingCopy ModelManager::workingCopyInternal() const
{
WorkingCopy workingCopy;
- DocumentModel *documentModel = EditorManager::documentModel();
- foreach (IDocument *document, documentModel->openedDocuments()) {
+ foreach (IDocument *document, DocumentModel::openedDocuments()) {
const QString key = document->filePath();
if (TextEditor::BaseTextDocument *textDocument = qobject_cast<TextEditor::BaseTextDocument *>(document)) {
// TODO the language should be a property on the document, not the editor
- if (documentModel->editorsForDocument(document).first()->context().contains(ProjectExplorer::Constants::LANG_QMLJS))
+ if (DocumentModel::editorsForDocument(document).first()->context().contains(ProjectExplorer::Constants::LANG_QMLJS))
workingCopy.insert(key, textDocument->plainText(), textDocument->document()->revision());
}
}
diff --git a/src/plugins/qnx/bardescriptorfilenodemanager.cpp b/src/plugins/qnx/bardescriptorfilenodemanager.cpp
index a0ca3eb6a4..9688f1f9b6 100644
--- a/src/plugins/qnx/bardescriptorfilenodemanager.cpp
+++ b/src/plugins/qnx/bardescriptorfilenodemanager.cpp
@@ -143,7 +143,7 @@ void BarDescriptorFileNodeManager::updateBarDescriptorNodes(ProjectExplorer::Pro
if (existingNode) {
if (existingNode->path() != package.appDescriptorPath()) {
// Reload the new bar-descriptor document in the existing editor (if there is one)
- Core::IDocument *oldDocument = Core::EditorManager::documentModel()->documentForFilePath(existingNode->path());
+ Core::IDocument *oldDocument = Core::DocumentModel::documentForFilePath(existingNode->path());
if (oldDocument) {
QString errorMessage;
diff --git a/src/plugins/texteditor/basetextmark.cpp b/src/plugins/texteditor/basetextmark.cpp
index 538a849d6e..12e947414f 100644
--- a/src/plugins/texteditor/basetextmark.cpp
+++ b/src/plugins/texteditor/basetextmark.cpp
@@ -59,9 +59,8 @@ BaseTextMarkRegistry::BaseTextMarkRegistry(QObject *parent)
void BaseTextMarkRegistry::add(BaseTextMark *mark)
{
m_marks[FileName::fromString(mark->fileName())].insert(mark);
- DocumentModel *documentModel = EditorManager::documentModel();
ITextEditorDocument *document
- = qobject_cast<ITextEditorDocument*>(documentModel->documentForFilePath(mark->fileName()));
+ = qobject_cast<ITextEditorDocument*>(DocumentModel::documentForFilePath(mark->fileName()));
if (!document)
return;
document->markableInterface()->addMark(mark);
diff --git a/src/plugins/texteditor/findinopenfiles.cpp b/src/plugins/texteditor/findinopenfiles.cpp
index 84e76b35ca..23d83433f3 100644
--- a/src/plugins/texteditor/findinopenfiles.cpp
+++ b/src/plugins/texteditor/findinopenfiles.cpp
@@ -68,7 +68,7 @@ Utils::FileIterator *FindInOpenFiles::files(const QStringList &nameFilters,
QStringList fileNames;
QList<QTextCodec *> codecs;
foreach (Core::DocumentModel::Entry *entry,
- Core::EditorManager::documentModel()->documents()) {
+ Core::DocumentModel::documents()) {
QString fileName = entry->fileName();
if (!fileName.isEmpty()) {
fileNames.append(fileName);
@@ -100,7 +100,7 @@ QString FindInOpenFiles::toolTip() const
bool FindInOpenFiles::isEnabled() const
{
- return Core::EditorManager::documentModel()->documentCount() > 0;
+ return Core::DocumentModel::documentCount() > 0;
}
void FindInOpenFiles::writeSettings(QSettings *settings)
diff --git a/src/plugins/texteditor/itexteditor.cpp b/src/plugins/texteditor/itexteditor.cpp
index ddcdc57cff..e6df633d79 100644
--- a/src/plugins/texteditor/itexteditor.cpp
+++ b/src/plugins/texteditor/itexteditor.cpp
@@ -58,7 +58,7 @@ ITextEditorDocument::ITextEditorDocument(QObject *parent)
QMap<QString, QString> ITextEditorDocument::openedTextDocumentContents()
{
QMap<QString, QString> workingCopy;
- foreach (Core::IDocument *document, Core::EditorManager::documentModel()->openedDocuments()) {
+ foreach (Core::IDocument *document, Core::DocumentModel::openedDocuments()) {
ITextEditorDocument *textEditorDocument = qobject_cast<ITextEditorDocument *>(document);
if (!textEditorDocument)
continue;
@@ -71,7 +71,7 @@ QMap<QString, QString> ITextEditorDocument::openedTextDocumentContents()
QMap<QString, QTextCodec *> ITextEditorDocument::openedTextDocumentEncodings()
{
QMap<QString, QTextCodec *> workingCopy;
- foreach (Core::IDocument *document, Core::EditorManager::documentModel()->openedDocuments()) {
+ foreach (Core::IDocument *document, Core::DocumentModel::openedDocuments()) {
ITextEditorDocument *textEditorDocument = qobject_cast<ITextEditorDocument *>(document);
if (!textEditorDocument)
continue;
diff --git a/src/plugins/texteditor/refactoringchanges.cpp b/src/plugins/texteditor/refactoringchanges.cpp
index 0c23d0ade8..1ba237d71e 100644
--- a/src/plugins/texteditor/refactoringchanges.cpp
+++ b/src/plugins/texteditor/refactoringchanges.cpp
@@ -177,7 +177,7 @@ RefactoringFile::RefactoringFile(const QString &fileName, const QSharedPointer<R
, m_editorCursorPosition(-1)
, m_appliedOnce(false)
{
- QList<Core::IEditor *> editors = Core::EditorManager::documentModel()->editorsForFilePath(fileName);
+ QList<Core::IEditor *> editors = Core::DocumentModel::editorsForFilePath(fileName);
if (!editors.isEmpty())
m_editor = qobject_cast<TextEditor::BaseTextEditorWidget *>(editors.first()->widget());
}
diff --git a/src/plugins/vcsbase/vcsbaseclient.cpp b/src/plugins/vcsbase/vcsbaseclient.cpp
index 59f61a68ff..460c9d20a0 100644
--- a/src/plugins/vcsbase/vcsbaseclient.cpp
+++ b/src/plugins/vcsbase/vcsbaseclient.cpp
@@ -67,9 +67,9 @@ Q_DECLARE_METATYPE(QVariant)
inline Core::IEditor *locateEditor(const char *property, const QString &entry)
{
- foreach (Core::IDocument *document, Core::EditorManager::documentModel()->openedDocuments())
+ foreach (Core::IDocument *document, Core::DocumentModel::openedDocuments())
if (document->property(property).toString() == entry)
- return Core::EditorManager::documentModel()->editorsForDocument(document).first();
+ return Core::DocumentModel::editorsForDocument(document).first();
return 0;
}
diff --git a/src/plugins/vcsbase/vcsbaseeditor.cpp b/src/plugins/vcsbase/vcsbaseeditor.cpp
index 897f457346..92c90b3bf9 100644
--- a/src/plugins/vcsbase/vcsbaseeditor.cpp
+++ b/src/plugins/vcsbase/vcsbaseeditor.cpp
@@ -1201,7 +1201,7 @@ const VcsBaseEditorParameters *VcsBaseEditorWidget::findType(const VcsBaseEditor
// Find the codec used for a file querying the editor.
static QTextCodec *findFileCodec(const QString &source)
{
- Core::IDocument *document = Core::EditorManager::documentModel()->documentForFilePath(source);
+ Core::IDocument *document = Core::DocumentModel::documentForFilePath(source);
if (Core::TextDocument *textDocument = qobject_cast<Core::TextDocument *>(document))
return const_cast<QTextCodec *>(textDocument->codec());
return 0;
@@ -1555,10 +1555,10 @@ void VcsBaseEditorWidget::tagEditor(Core::IEditor *e, const QString &tag)
Core::IEditor* VcsBaseEditorWidget::locateEditorByTag(const QString &tag)
{
- foreach (Core::IDocument *document, Core::EditorManager::documentModel()->openedDocuments()) {
+ foreach (Core::IDocument *document, Core::DocumentModel::openedDocuments()) {
const QVariant tagPropertyValue = document->property(tagPropertyC);
if (tagPropertyValue.type() == QVariant::String && tagPropertyValue.toString() == tag)
- return Core::EditorManager::documentModel()->editorsForDocument(document).first();
+ return Core::DocumentModel::editorsForDocument(document).first();
}
return 0;
}
diff --git a/src/plugins/vcsbase/vcsbaseplugin.cpp b/src/plugins/vcsbase/vcsbaseplugin.cpp
index 2dded5fc95..8448d6838f 100644
--- a/src/plugins/vcsbase/vcsbaseplugin.cpp
+++ b/src/plugins/vcsbase/vcsbaseplugin.cpp
@@ -220,7 +220,7 @@ StateListener::StateListener(QObject *parent) :
static inline QString displayNameOfEditor(const QString &fileName)
{
- Core::IDocument *document = Core::EditorManager::documentModel()->documentForFilePath(fileName);
+ Core::IDocument *document = Core::DocumentModel::documentForFilePath(fileName);
if (document)
return document->displayName();
return QString();