Commit 6e584b5b authored by hjk's avatar hjk

DocumentModel: Make interface static

Move item model implementation to private, adjust user code.

Change-Id: Ifbe94e7c7b9b1e8be1b4c531958dbd7a9413af13
Reviewed-by: default avatarEike Ziller <eike.ziller@digia.com>
parent 226c1abc
......@@ -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());
......
......@@ -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");
......
......@@ -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())
......
......@@ -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
......
......@@ -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);
......
......@@ -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);
......
......@@ -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();
......
......@@ -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();
......
......@@ -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);
......
......@@ -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"));
}
......
......@@ -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
......
......@@ -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))
......
......@@ -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> >
......
......@@ -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());
}
......
......@@ -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(
......
......@@ -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())
......
......@@ -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);
......
......@@ -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 {
......
......@@ -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;
......
......@@ -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());
......
......@@ -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;
......
......@@ -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"
......
......@@ -32,6 +32,7 @@
#include "diffeditorconstants.h"
#include "diffeditordocument.h"
#include <coreplugin/editormanager/editormanager.h>