diff options
83 files changed, 215 insertions, 283 deletions
diff --git a/src/plugins/analyzerbase/analyzerutils.cpp b/src/plugins/analyzerbase/analyzerutils.cpp index d57eb6a2a4..8b966f291c 100644 --- a/src/plugins/analyzerbase/analyzerutils.cpp +++ b/src/plugins/analyzerbase/analyzerutils.cpp @@ -73,10 +73,7 @@ static void moveCursorToEndOfName(QTextCursor *tc) // We cannot depend on this since CppEditor plugin code is internal and requires building the implementation files ourselves CPlusPlus::Symbol *AnalyzerUtils::findSymbolUnderCursor() { - EditorManager *editorManager = EditorManager::instance(); - if (!editorManager) - return 0; - IEditor *editor = editorManager->currentEditor(); + IEditor *editor = EditorManager::currentEditor(); if (!editor) return 0; TextEditor::ITextEditor *textEditor = qobject_cast<TextEditor::ITextEditor *>(editor); diff --git a/src/plugins/bazaar/bazaarplugin.cpp b/src/plugins/bazaar/bazaarplugin.cpp index a110b3063c..9683152a35 100644 --- a/src/plugins/bazaar/bazaarplugin.cpp +++ b/src/plugins/bazaar/bazaarplugin.cpp @@ -569,9 +569,9 @@ void BazaarPlugin::showCommitWidget(const QList<VcsBase::VcsBaseClient::StatusIt return; } - Core::IEditor *editor = Core::ICore::editorManager()->openEditor(m_changeLog->fileName(), - Constants::COMMIT_ID, - Core::EditorManager::ModeSwitch); + Core::IEditor *editor = Core::EditorManager::openEditor(m_changeLog->fileName(), + Constants::COMMIT_ID, + Core::EditorManager::ModeSwitch); if (!editor) { outputWindow->appendError(tr("Unable to create an editor for the commit.")); return; diff --git a/src/plugins/bookmarks/bookmarkmanager.cpp b/src/plugins/bookmarks/bookmarkmanager.cpp index ade3717c58..5a4f974a4f 100644 --- a/src/plugins/bookmarks/bookmarkmanager.cpp +++ b/src/plugins/bookmarks/bookmarkmanager.cpp @@ -594,10 +594,7 @@ void BookmarkManager::prev() TextEditor::ITextEditor *BookmarkManager::currentTextEditor() const { - Core::EditorManager *em = Core::EditorManager::instance(); - Core::IEditor *currEditor = em->currentEditor(); - if (!currEditor) - return 0; + Core::IEditor *currEditor = EditorManager::currentEditor(); return qobject_cast<TextEditor::ITextEditor *>(currEditor); } diff --git a/src/plugins/classview/classviewmanager.cpp b/src/plugins/classview/classviewmanager.cpp index d2bedb4f42..b9a0d1b41b 100644 --- a/src/plugins/classview/classviewmanager.cpp +++ b/src/plugins/classview/classviewmanager.cpp @@ -309,8 +309,7 @@ void Manager::gotoLocations(const QList<QVariant> &list) bool currentPositionAvailable = false; // what is open now? - Core::IEditor *editor = Core::EditorManager::instance()->currentEditor(); - if (editor) { + if (Core::IEditor *editor = Core::EditorManager::currentEditor()) { // get current file name Core::IDocument *document = editor->document(); if (document) diff --git a/src/plugins/coreplugin/basefilewizard.cpp b/src/plugins/coreplugin/basefilewizard.cpp index eec673a570..28d560075d 100644 --- a/src/plugins/coreplugin/basefilewizard.cpp +++ b/src/plugins/coreplugin/basefilewizard.cpp @@ -654,10 +654,9 @@ bool BaseFileWizard::postGenerateFiles(const QWizard *, const GeneratedFiles &l, bool BaseFileWizard::postGenerateOpenEditors(const GeneratedFiles &l, QString *errorMessage) { - Core::EditorManager *em = Core::EditorManager::instance(); foreach(const Core::GeneratedFile &file, l) { if (file.attributes() & Core::GeneratedFile::OpenEditorAttribute) { - if (!em->openEditor(file.path(), file.editorId(), Core::EditorManager::ModeSwitch )) { + if (!Core::EditorManager::openEditor(file.path(), file.editorId(), Core::EditorManager::ModeSwitch )) { if (errorMessage) *errorMessage = tr("Failed to open an editor for '%1'.").arg(QDir::toNativeSeparators(file.path())); return false; diff --git a/src/plugins/coreplugin/documentmanager.cpp b/src/plugins/coreplugin/documentmanager.cpp index 9828859f9f..39efc8f328 100644 --- a/src/plugins/coreplugin/documentmanager.cpp +++ b/src/plugins/coreplugin/documentmanager.cpp @@ -1095,9 +1095,9 @@ void DocumentManager::syncWithEditor(Core::IContext *context) if (!context) return; - Core::IEditor *editor = Core::EditorManager::instance()->currentEditor(); - if (editor && (editor->widget() == context->widget()) && - !editor->isTemporary()) + Core::IEditor *editor = Core::EditorManager::currentEditor(); + if (editor && editor->widget() == context->widget() + && !editor->isTemporary()) setCurrentFile(editor->document()->fileName()); } @@ -1333,8 +1333,8 @@ void DocumentManager::populateOpenWithMenu(QMenu *menu, const QString &fileName) bool anyMatches = false; if (const MimeType mt = ICore::mimeDatabase()->findByFile(QFileInfo(fileName))) { - const EditorFactoryList factories = ICore::editorManager()->editorFactories(mt, false); - const ExternalEditorList externalEditors = ICore::editorManager()->externalEditors(mt, false); + const EditorFactoryList factories = EditorManager::editorFactories(mt, false); + const ExternalEditorList externalEditors = EditorManager::externalEditors(mt, false); anyMatches = !factories.empty() || !externalEditors.empty(); if (anyMatches) { // Add all suitable editors @@ -1363,11 +1363,11 @@ void DocumentManager::populateOpenWithMenu(QMenu *menu, const QString &fileName) void DocumentManager::executeOpenWithMenuAction(QAction *action) { QTC_ASSERT(action, return); - EditorManager *em = EditorManager::instance(); const QVariant data = action->data(); OpenWithEntry entry = qVariantValue<OpenWithEntry>(data); if (entry.editorFactory) { // close any open editors that have this file open, but have a different type. + EditorManager *em = EditorManager::instance(); QList<IEditor *> editorsOpenForFile = em->editorsForFileName(entry.fileName); if (!editorsOpenForFile.isEmpty()) { foreach (IEditor *openEditor, editorsOpenForFile) { @@ -1378,11 +1378,11 @@ void DocumentManager::executeOpenWithMenuAction(QAction *action) return; } - em->openEditor(entry.fileName, entry.editorFactory->id(), EditorManager::ModeSwitch); + EditorManager::openEditor(entry.fileName, entry.editorFactory->id(), EditorManager::ModeSwitch); return; } if (entry.externalEditor) - em->openExternalEditor(entry.fileName, entry.externalEditor->id()); + EditorManager::openExternalEditor(entry.fileName, entry.externalEditor->id()); } void DocumentManager::slotExecuteOpenWithMenuAction(QAction *action) diff --git a/src/plugins/coreplugin/editmode.cpp b/src/plugins/coreplugin/editmode.cpp index 9461f9aa18..071e700dc0 100644 --- a/src/plugins/coreplugin/editmode.cpp +++ b/src/plugins/coreplugin/editmode.cpp @@ -111,6 +111,6 @@ void EditMode::grabEditorManager(Core::IMode *mode) if (mode != this) return; - if (m_editorManager->currentEditor()) - m_editorManager->currentEditor()->widget()->setFocus(); + if (EditorManager::currentEditor()) + EditorManager::currentEditor()->widget()->setFocus(); } diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp index 4a9a631d97..dc9c82b465 100644 --- a/src/plugins/coreplugin/editormanager/editormanager.cpp +++ b/src/plugins/coreplugin/editormanager/editormanager.cpp @@ -634,9 +634,9 @@ QList<IEditor *> EditorManager::editorsForDocument(IDocument *document) const return found; } -IEditor *EditorManager::currentEditor() const +IEditor *EditorManager::currentEditor() { - return d->m_currentEditor; + return m_instance->d->m_currentEditor; } void EditorManager::emptyView(Core::Internal::EditorView *view) @@ -1047,12 +1047,12 @@ Core::IEditor *EditorManager::placeEditor(Core::Internal::EditorView *view, Core void EditorManager::activateEditor(Core::IEditor *editor, OpenEditorFlags flags) { - SplitterOrView *splitterOrView = d->m_splitter->findView(editor); + SplitterOrView *splitterOrView = m_instance->d->m_splitter->findView(editor); EditorView *view = (splitterOrView ? splitterOrView->view() : 0); // TODO an IEditor doesn't have to belong to a view, which makes this method a bit funny if (!view) - view = currentEditorView(); - activateEditor(view, editor, flags); + view = m_instance->currentEditorView(); + m_instance->activateEditor(view, editor, flags); } Core::IEditor *EditorManager::activateEditor(Core::Internal::EditorView *view, Core::IEditor *editor, OpenEditorFlags flags) @@ -1124,7 +1124,7 @@ static void mimeTypeFactoryRecursion(const MimeDatabase *db, } EditorManager::EditorFactoryList - EditorManager::editorFactories(const MimeType &mimeType, bool bestMatchOnly) const + EditorManager::editorFactories(const MimeType &mimeType, bool bestMatchOnly) { EditorFactoryList rc; const EditorFactoryList allFactories = pluginManager()->getObjects<IEditorFactory>(); @@ -1135,7 +1135,7 @@ EditorManager::EditorFactoryList } EditorManager::ExternalEditorList - EditorManager::externalEditors(const MimeType &mimeType, bool bestMatchOnly) const + EditorManager::externalEditors(const MimeType &mimeType, bool bestMatchOnly) { ExternalEditorList rc; const ExternalEditorList allEditors = pluginManager()->getObjects<IExternalEditor>(); @@ -1187,11 +1187,11 @@ IEditor *EditorManager::createEditor(const Id &editorId, const QString &fileName return 0; } - IEditor *editor = factories.front()->createEditor(this); + IEditor *editor = factories.front()->createEditor(m_instance); if (editor) - connect(editor, SIGNAL(changed()), this, SLOT(handleEditorStateChange())); + connect(editor, SIGNAL(changed()), m_instance, SLOT(handleEditorStateChange())); if (editor) - emit editorCreated(editor, fileName); + emit m_instance->editorCreated(editor, fileName); return editor; } @@ -1257,7 +1257,7 @@ Core::Id EditorManager::getOpenWithEditorId(const QString &fileName, IEditor *EditorManager::openEditor(const QString &fileName, const Id &editorId, OpenEditorFlags flags, bool *newEditor) { - return openEditor(currentEditorView(), fileName, editorId, flags, newEditor); + return m_instance->openEditor(m_instance->currentEditorView(), fileName, editorId, flags, newEditor); } int extractLineNumber(QString *fileName) @@ -1408,7 +1408,7 @@ IEditor *EditorManager::openEditorWithContents(const Id &editorId, if (base.contains(dollar)) { int i = 1; QSet<QString> docnames; - foreach (IEditor *editor, openedEditors()) { + foreach (IEditor *editor, m_instance->openedEditors()) { QString name = editor->document()->fileName(); if (name.isEmpty()) { name = editor->displayName(); @@ -1445,7 +1445,7 @@ IEditor *EditorManager::openEditorWithContents(const Id &editorId, title = edt->displayName(); edt->setDisplayName(title); - addEditor(edt); + m_instance->addEditor(edt); QApplication::restoreOverrideCursor(); return edt; } diff --git a/src/plugins/coreplugin/editormanager/editormanager.h b/src/plugins/coreplugin/editormanager/editormanager.h index 295e9926e2..aa2e869901 100644 --- a/src/plugins/coreplugin/editormanager/editormanager.h +++ b/src/plugins/coreplugin/editormanager/editormanager.h @@ -117,12 +117,12 @@ public: }; Q_DECLARE_FLAGS(OpenEditorFlags, OpenEditorFlag) - IEditor *openEditor(const QString &fileName, const Id &editorId = Id(), + static IEditor *openEditor(const QString &fileName, const Id &editorId = Id(), OpenEditorFlags flags = 0, bool *newEditor = 0); - IEditor *openEditorWithContents(const Id &editorId, + static IEditor *openEditorWithContents(const Id &editorId, QString *titlePattern = 0, const QString &contents = QString()); - bool openExternalEditor(const QString &fileName, const Id &editorId); + static bool openExternalEditor(const QString &fileName, const Id &editorId); QStringList getOpenFileNames() const; Id getOpenWithEditorId(const QString &fileName, bool *isExternalEditor = 0) const; @@ -131,11 +131,11 @@ public: QList<IEditor *> editorsForFileName(const QString &filename) const; QList<IEditor *> editorsForDocument(IDocument *document) const; - IEditor *currentEditor() const; + static IEditor *currentEditor(); QList<IEditor *> visibleEditors() const; QList<IEditor*> openedEditors() const; - void activateEditor(IEditor *editor, OpenEditorFlags flags = 0); + static void activateEditor(IEditor *editor, OpenEditorFlags flags = 0); void activateEditorForIndex(const QModelIndex &index, OpenEditorFlags = 0); IEditor *activateEditorForDocument(Internal::EditorView *view, IDocument *document, OpenEditorFlags flags = 0); @@ -170,8 +170,8 @@ public: void hideEditorStatusBar(const QString &id); - EditorFactoryList editorFactories(const MimeType &mimeType, bool bestMatchOnly = true) const; - ExternalEditorList externalEditors(const MimeType &mimeType, bool bestMatchOnly = true) const; + static EditorFactoryList editorFactories(const MimeType &mimeType, bool bestMatchOnly = true); + static ExternalEditorList externalEditors(const MimeType &mimeType, bool bestMatchOnly = true); void setReloadSetting(IDocument::ReloadSetting behavior); IDocument::ReloadSetting reloadSetting() const; @@ -238,7 +238,7 @@ public slots: private: QList<IDocument *> documentsForEditors(QList<IEditor *> editors) const; - IEditor *createEditor(const Id &id = Id(), const QString &fileName = QString()); + static IEditor *createEditor(const Id &id = Id(), const QString &fileName = QString()); void addEditor(IEditor *editor, bool isDuplicate = false); void removeEditor(IEditor *editor); diff --git a/src/plugins/coreplugin/editormanager/editorview.cpp b/src/plugins/coreplugin/editormanager/editorview.cpp index 1e628d09da..c58ad38e1f 100644 --- a/src/plugins/coreplugin/editormanager/editorview.cpp +++ b/src/plugins/coreplugin/editormanager/editorview.cpp @@ -798,7 +798,6 @@ QByteArray SplitterOrView::saveState() const << static_cast<SplitterOrView*>(m_splitter->widget(1))->saveState(); } else { IEditor* e = editor(); - EditorManager *em = ICore::editorManager(); // don't save state of temporary or ad-hoc editors if (e && (e->isTemporary() || e->document()->fileName().isEmpty())) { @@ -814,7 +813,7 @@ QByteArray SplitterOrView::saveState() const if (!e) { stream << QByteArray("empty"); - } else if (e == em->currentEditor()) { + } else if (e == EditorManager::currentEditor()) { stream << QByteArray("currenteditor") << e->document()->fileName() << e->id().toString() << e->saveState(); } else { diff --git a/src/plugins/coreplugin/editormanager/ieditorfactory.cpp b/src/plugins/coreplugin/editormanager/ieditorfactory.cpp index 33c840f7fb..fb07a0d0cc 100644 --- a/src/plugins/coreplugin/editormanager/ieditorfactory.cpp +++ b/src/plugins/coreplugin/editormanager/ieditorfactory.cpp @@ -37,6 +37,6 @@ Core::IDocument *Core::IEditorFactory::open(const QString &fileName) { - Core::IEditor *iface = Core::EditorManager::instance()->openEditor(fileName, id()); + Core::IEditor *iface = Core::EditorManager::openEditor(fileName, id()); return iface ? iface->document() : 0; } diff --git a/src/plugins/coreplugin/editormanager/openeditorsview.cpp b/src/plugins/coreplugin/editormanager/openeditorsview.cpp index b30112bc3d..3b03f0c60a 100644 --- a/src/plugins/coreplugin/editormanager/openeditorsview.cpp +++ b/src/plugins/coreplugin/editormanager/openeditorsview.cpp @@ -199,7 +199,7 @@ void OpenEditorsWidget::closeEditor(const QModelIndex &index) { EditorManager::instance()->closeEditor(index); // work around selection changes - updateCurrentItem(EditorManager::instance()->currentEditor()); + updateCurrentItem(EditorManager::currentEditor()); } void OpenEditorsWidget::contextMenuRequested(QPoint pos) diff --git a/src/plugins/coreplugin/editormanager/openeditorswindow.cpp b/src/plugins/coreplugin/editormanager/openeditorswindow.cpp index 57572671a4..d30ad969bc 100644 --- a/src/plugins/coreplugin/editormanager/openeditorswindow.cpp +++ b/src/plugins/coreplugin/editormanager/openeditorswindow.cpp @@ -284,7 +284,7 @@ void OpenEditorsWindow::selectEditor(QTreeWidgetItem *item) EditorView *view = item->data(0, Qt::UserRole+1).value<EditorView*>(); EditorManager::instance()->activateEditorForDocument(view, document, EditorManager::ModeSwitch); } else { - if (!EditorManager::instance()->openEditor( + if (!EditorManager::openEditor( item->toolTip(0), item->data(0, Qt::UserRole+2).value<Core::Id>(), Core::EditorManager::ModeSwitch)) { EditorManager::instance()->openedEditorsModel()->removeEditor(item->toolTip(0)); diff --git a/src/plugins/coreplugin/editortoolbar.cpp b/src/plugins/coreplugin/editortoolbar.cpp index ea8103e5d1..b7ab352f31 100644 --- a/src/plugins/coreplugin/editortoolbar.cpp +++ b/src/plugins/coreplugin/editortoolbar.cpp @@ -245,15 +245,12 @@ void EditorToolBar::setCloseSplitIcon(const QIcon &icon) void EditorToolBar::closeEditor() { - if (!currentEditor()) + IEditor *current = EditorManager::currentEditor(); + if (!current) return; - if (d->m_isStandalone) { - EditorManager *em = ICore::editorManager(); - if (IEditor *editor = currentEditor()) { - em->closeEditor(editor); - } - } + if (d->m_isStandalone) + EditorManager::instance()->closeEditor(current); emit closeClicked(); } @@ -349,8 +346,8 @@ void EditorToolBar::listContextMenu(QPoint pos) void EditorToolBar::makeEditorWritable() { - if (currentEditor()) - ICore::editorManager()->makeFileWritable(currentEditor()->document()); + if (IEditor *current = EditorManager::currentEditor()) + EditorManager::instance()->makeFileWritable(current->document()); } void EditorToolBar::setCanGoBack(bool canGoBack) @@ -372,15 +369,10 @@ void EditorToolBar::updateActionShortcuts() d->m_closeSplitButton->setToolTip(am->command(Constants::REMOVE_CURRENT_SPLIT)->stringWithAppendedShortcut(tr("Remove Split"))); } -IEditor *EditorToolBar::currentEditor() const -{ - return ICore::editorManager()->currentEditor(); -} - void EditorToolBar::checkEditorStatus() { IEditor *editor = qobject_cast<IEditor *>(sender()); - IEditor *current = currentEditor(); + IEditor *current = EditorManager::currentEditor(); if (current == editor) updateEditorStatus(editor); @@ -413,13 +405,13 @@ void EditorToolBar::updateEditorStatus(IEditor *editor) d->m_lockButton->setEnabled(false); d->m_lockButton->setToolTip(tr("File is writable")); } - if (editor == currentEditor()) + IEditor *current = EditorManager::currentEditor(); + if (editor == current) d->m_editorList->setToolTip( - currentEditor()->document()->fileName().isEmpty() - ? currentEditor()->displayName() + current->document()->fileName().isEmpty() + ? current->displayName() : QDir::toNativeSeparators(editor->document()->fileName()) ); - } void EditorToolBar::setNavigationVisible(bool isVisible) diff --git a/src/plugins/coreplugin/editortoolbar.h b/src/plugins/coreplugin/editortoolbar.h index 68fa6d3958..41ce6e4018 100644 --- a/src/plugins/coreplugin/editortoolbar.h +++ b/src/plugins/coreplugin/editortoolbar.h @@ -107,7 +107,6 @@ private slots: private: void updateToolBar(QWidget *toolBar); - IEditor *currentEditor() const; EditorToolBarPrivate *d; }; diff --git a/src/plugins/coreplugin/externaltool.cpp b/src/plugins/coreplugin/externaltool.cpp index 51bba893fb..cef137f5d7 100644 --- a/src/plugins/coreplugin/externaltool.cpp +++ b/src/plugins/coreplugin/externaltool.cpp @@ -600,7 +600,7 @@ void ExternalToolRunner::run() return; } if (m_tool->modifiesCurrentDocument()) { - if (IEditor *editor = EditorManager::instance()->currentEditor()) { + if (IEditor *editor = EditorManager::currentEditor()) { m_expectedFileName = editor->document()->fileName(); bool cancelled = false; DocumentManager::saveModifiedDocuments(QList<IDocument *>() << editor->document(), &cancelled); diff --git a/src/plugins/coreplugin/mainwindow.cpp b/src/plugins/coreplugin/mainwindow.cpp index 6e11b3775e..9ba82290db 100644 --- a/src/plugins/coreplugin/mainwindow.cpp +++ b/src/plugins/coreplugin/mainwindow.cpp @@ -919,7 +919,7 @@ void MainWindow::openFiles(const QStringList &fileNames, ICore::OpenFilesFlags f emFlags = EditorManager::ModeSwitch; if (flags & ICore::CanContainLineNumbers) emFlags |= EditorManager::CanContainLineNumber; - Core::IEditor *editor = editorManager()->openEditor(absoluteFilePath, Id(), emFlags); + Core::IEditor *editor = EditorManager::openEditor(absoluteFilePath, Id(), emFlags); if (!editor && (flags & ICore::StopOnLoadFail)) return; } @@ -931,7 +931,7 @@ void MainWindow::setFocusToEditor() bool focusWasMovedToEditor = false; // give focus to the editor if we have one - if (IEditor *editor = m_editorManager->currentEditor()) { + if (IEditor *editor = EditorManager::currentEditor()) { if (qApp->focusWidget() != editor->widget()->focusWidget()) { QWidget *w = editor->widget()->focusWidget(); if (!w) @@ -1055,9 +1055,9 @@ void MainWindow::openFileWith() if (!editorId.isValid()) continue; if (isExternal) { - editorManager()->openExternalEditor(fileName, editorId); + EditorManager::openExternalEditor(fileName, editorId); } else { - editorManager()->openEditor(fileName, editorId, Core::EditorManager::ModeSwitch); + EditorManager::openEditor(fileName, editorId, Core::EditorManager::ModeSwitch); } } } @@ -1352,7 +1352,7 @@ void MainWindow::openRecentFile() { if (const QAction *action = qobject_cast<const QAction*>(sender())) { const DocumentManager::RecentFile file = action->data().value<DocumentManager::RecentFile>(); - editorManager()->openEditor(file.first, file.second, Core::EditorManager::ModeSwitch); + EditorManager::openEditor(file.first, file.second, EditorManager::ModeSwitch); } } diff --git a/src/plugins/coreplugin/mimetypesettings.cpp b/src/plugins/coreplugin/mimetypesettings.cpp index ad3d833f4b..5d7294b4d5 100644 --- a/src/plugins/coreplugin/mimetypesettings.cpp +++ b/src/plugins/coreplugin/mimetypesettings.cpp @@ -141,12 +141,12 @@ void MimeTypeSettingsModel::load() foreach (const MimeType &mimeType, m_mimeTypes) { QString value; const QList<IEditorFactory *> factories = - ICore::editorManager()->editorFactories(mimeType); + EditorManager::editorFactories(mimeType); if (!factories.isEmpty()) { value = factories.front()->displayName(); } else { const QList<IExternalEditor *> externalEditors = - ICore::editorManager()->externalEditors(mimeType); + EditorManager::externalEditors(mimeType); if (!externalEditors.isEmpty()) value = externalEditors.front()->displayName(); else diff --git a/src/plugins/coreplugin/outputpanemanager.cpp b/src/plugins/coreplugin/outputpanemanager.cpp index f1fbd6f447..91305c1162 100644 --- a/src/plugins/coreplugin/outputpanemanager.cpp +++ b/src/plugins/coreplugin/outputpanemanager.cpp @@ -386,7 +386,7 @@ void OutputPaneManager::slotHide() m_buttons.value(idx)->setChecked(false); if (m_pageMap.value(idx)) m_pageMap.value(idx)->visibilityChanged(false); - if (IEditor *editor = Core::EditorManager::instance()->currentEditor()) { + if (IEditor *editor = Core::EditorManager::currentEditor()) { QWidget *w = editor->widget()->focusWidget(); if (!w) w = editor->widget(); diff --git a/src/plugins/cpaster/cpasterplugin.cpp b/src/plugins/cpaster/cpasterplugin.cpp index 20e5b85d26..0f3e93607f 100644 --- a/src/plugins/cpaster/cpasterplugin.cpp +++ b/src/plugins/cpaster/cpasterplugin.cpp @@ -206,7 +206,7 @@ void CodepasterPlugin::postEditor() { QString data; QString mimeType; - if (IEditor* editor = EditorManager::instance()->currentEditor()) { + if (IEditor *editor = EditorManager::currentEditor()) { if (ITextEditor *textEditor = qobject_cast<ITextEditor *>(editor)) { data = textEditor->selectedText(); if (data.isEmpty()) @@ -365,7 +365,7 @@ void CodepasterPlugin::finishFetch(const QString &titleDescription, const QString fileName = saver.fileName(); m_fetchedSnippets.push_back(fileName); // Open editor with title. - Core::IEditor* editor = EditorManager::instance()->openEditor(fileName, Core::Id(), EditorManager::ModeSwitch); + Core::IEditor *editor = EditorManager::openEditor(fileName, Core::Id(), EditorManager::ModeSwitch); QTC_ASSERT(editor, return); editor->setDisplayName(titleDescription); } diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp index 6974ee1a14..594e16f9f0 100644 --- a/src/plugins/cppeditor/cppeditor.cpp +++ b/src/plugins/cppeditor/cppeditor.cpp @@ -688,7 +688,7 @@ void CPPEditorWidget::onDocumentUpdated(Document::Ptr doc) return; if (! m_initialized || - (Core::EditorManager::instance()->currentEditor() == editor() + (Core::EditorManager::currentEditor() == editor() && (!m_lastSemanticInfo.doc || !m_lastSemanticInfo.doc->translationUnit()->ast() || m_lastSemanticInfo.doc->fileName() != editorDocument()->fileName()))) { @@ -1869,7 +1869,7 @@ void CPPEditorWidget::updateSemanticInfo(const SemanticInfo &semanticInfo) m_highlighter.cancel(); if (! semanticHighlighterDisabled && semanticInfo.doc) { - if (Core::EditorManager::instance()->currentEditor() == editor()) { + if (Core::EditorManager::currentEditor() == editor()) { if (m_highlightingSupport) { m_highlighter = m_highlightingSupport->highlightingFuture(semanticInfo.doc, semanticInfo.snapshot); m_highlightRevision = semanticInfo.revision; @@ -2224,7 +2224,7 @@ void CPPEditorWidget::updateFunctionDeclDefLink() void CPPEditorWidget::updateFunctionDeclDefLinkNow() { - if (Core::EditorManager::instance()->currentEditor() != editor()) + if (Core::EditorManager::currentEditor() != editor()) return; if (m_declDefLink) { // update the change marker diff --git a/src/plugins/cppeditor/cppplugin.cpp b/src/plugins/cppeditor/cppplugin.cpp index 780435d371..26bcf2ca09 100644 --- a/src/plugins/cppeditor/cppplugin.cpp +++ b/src/plugins/cppeditor/cppplugin.cpp @@ -339,24 +339,21 @@ ExtensionSystem::IPlugin::ShutdownFlag CppPlugin::aboutToShutdown() void CppPlugin::switchDeclarationDefinition() { - Core::EditorManager *em = Core::EditorManager::instance(); - CPPEditorWidget *editor = qobject_cast<CPPEditorWidget*>(em->currentEditor()->widget()); + CPPEditorWidget *editor = qobject_cast<CPPEditorWidget*>(Core::EditorManager::currentEditor()->widget()); if (editor) editor->switchDeclarationDefinition(); } void CppPlugin::renameSymbolUnderCursor() { - Core::EditorManager *em = Core::EditorManager::instance(); - CPPEditorWidget *editor = qobject_cast<CPPEditorWidget*>(em->currentEditor()->widget()); + CPPEditorWidget *editor = qobject_cast<CPPEditorWidget*>(Core::EditorManager::currentEditor()->widget()); if (editor) editor->renameSymbolUnderCursor(); } void CppPlugin::findUsages() { - Core::EditorManager *em = Core::EditorManager::instance(); - CPPEditorWidget *editor = qobject_cast<CPPEditorWidget*>(em->currentEditor()->widget()); + CPPEditorWidget *editor = qobject_cast<CPPEditorWidget*>(Core::EditorManager::currentEditor()->widget()); if (editor) editor->findUsages(); } @@ -393,8 +390,7 @@ void CppPlugin::currentEditorChanged(Core::IEditor *editor) void CppPlugin::openTypeHierarchy() { - Core::EditorManager *em = Core::EditorManager::instance(); - CPPEditorWidget *editor = qobject_cast<CPPEditorWidget*>(em->currentEditor()->widget()); + CPPEditorWidget *editor = qobject_cast<CPPEditorWidget*>(Core::EditorManager::currentEditor()->widget()); if (editor) { Core::NavigationWidget *navigation = Core::NavigationWidget::instance(); navigation->activateSubWidget(Core::Id(Constants::TYPE_HIERARCHY_ID)); diff --git a/src/plugins/cppeditor/cpptypehierarchy.cpp b/src/plugins/cppeditor/cpptypehierarchy.cpp index 66f7da9061..be7f4718ab 100644 --- a/src/plugins/cppeditor/cpptypehierarchy.cpp +++ b/src/plugins/cppeditor/cpptypehierarchy.cpp @@ -248,8 +248,7 @@ void CppTypeHierarchyWidget::onItemClicked(const QModelIndex &index) // CppTypeHierarchyStackedWidget CppTypeHierarchyStackedWidget::CppTypeHierarchyStackedWidget(QWidget *parent) : QStackedWidget(parent), - m_typeHiearchyWidgetInstance( - new CppTypeHierarchyWidget(Core::EditorManager::instance()->currentEditor())) + m_typeHiearchyWidgetInstance(new CppTypeHierarchyWidget(Core::EditorManager::currentEditor())) { addWidget(m_typeHiearchyWidgetInstance); diff --git a/src/plugins/cpptools/cppfilesettingspage.cpp b/src/plugins/cpptools/cppfilesettingspage.cpp index c279f8cd0f..6ab00042a6 100644 --- a/src/plugins/cpptools/cppfilesettingspage.cpp +++ b/src/plugins/cpptools/cppfilesettingspage.cpp @@ -315,8 +315,8 @@ void CppFileSettingsWidget::slotEdit() setLicenseTemplatePath(path); } // Edit (now) existing file with C++ - Core::EditorManager::instance()->openEditor(path, CppEditor::Constants::CPPEDITOR_ID, - Core::EditorManager::ModeSwitch); + Core::EditorManager::openEditor(path, CppEditor::Constants::CPPEDITOR_ID, + Core::EditorManager::ModeSwitch); } // --------------- CppFileSettingsPage diff --git a/src/plugins/cpptools/cppfindreferences.cpp b/src/plugins/cpptools/cppfindreferences.cpp index 2c47a6b371..d1332f0e0d 100644 --- a/src/plugins/cpptools/cppfindreferences.cpp +++ b/src/plugins/cpptools/cppfindreferences.cpp @@ -519,8 +519,8 @@ void CppFindReferences::openEditor(const Find::SearchResultItem &item) Core::Id(), Core::EditorManager::ModeSwitch); } else { - Core::EditorManager::instance()->openEditor(QDir::fromNativeSeparators(item.text), - Core::Id(), Core::EditorManager::ModeSwitch); + Core::EditorManager::openEditor(QDir::fromNativeSeparators(item.text), + Core::Id(), Core::EditorManager::ModeSwitch); } } diff --git a/src/plugins/cpptools/cpptoolsplugin.cpp b/src/plugins/cpptools/cpptoolsplugin.cpp index f75a0207a4..f33f40e5bf 100644 --- a/src/plugins/cpptools/cpptoolsplugin.cpp +++ b/src/plugins/cpptools/cpptoolsplugin.cpp @@ -159,11 +159,10 @@ ExtensionSystem::IPlugin::ShutdownFlag CppToolsPlugin::aboutToShutdown() void CppToolsPlugin::switchHeaderSource() { - Core::EditorManager *editorManager = Core::EditorManager::instance(); - Core::IEditor *editor = editorManager->currentEditor(); + Core::IEditor *editor = Core::EditorManager::currentEditor(); QString otherFile = correspondingHeaderOrSource(editor->document()->fileName()); if (!otherFile.isEmpty()) - editorManager->openEditor(otherFile); + Core::EditorManager::openEditor(otherFile); } static QStringList findFilesInProject(const QString &name, diff --git a/src/plugins/cvs/cvsplugin.cpp b/src/plugins/cvs/cvsplugin.cpp index 41a962c534..8428483917 100644 --- a/src/plugins/cvs/cvsplugin.cpp +++ b/src/plugins/cvs/cvsplugin.cpp @@ -611,7 +611,7 @@ void CvsPlugin::cvsDiff(const CvsDiffParameters &p) const QString tag = VcsBaseEditorWidget::editorTag(DiffOutput, p.workingDir, p.files); if (IEditor *existingEditor = VcsBaseEditorWidget::locateEditorByTag(tag)) { existingEditor->createNew(output); - EditorManager::instance()->activateEditor(existingEditor, EditorManager::ModeSwitch); + EditorManager::activateEditor(existingEditor, EditorManager::ModeSwitch); setDiffBaseDirectory(existingEditor, p.workingDir); return; } @@ -635,8 +635,8 @@ void CvsPlugin::cvsDiff(const CvsDiffParameters &p) CvsSubmitEditor *CvsPlugin::openCVSSubmitEditor(const QString &fileName) { - IEditor *editor = EditorManager::instance()->openEditor(fileName, Constants::CVSCOMMITEDITOR_ID, - EditorManager::ModeSwitch); + IEditor *editor = EditorManager::openEditor(fileName, Constants::CVSCOMMITEDITOR_ID, + EditorManager::ModeSwitch); CvsSubmitEditor *submitEditor = qobject_cast<CvsSubmitEditor*>(editor); QTC_CHECK(submitEditor); submitEditor->registerActions(m_submitUndoAction, m_submitRedoAction, m_submitCurrentLogAction, m_submitDiffAction); @@ -883,7 +883,7 @@ void CvsPlugin::filelog(const QString &workingDir, const QString tag = VcsBaseEditorWidget::editorTag(LogOutput, workingDir, files); if (Core::IEditor *editor = VcsBaseEditorWidget::locateEditorByTag(tag)) { editor->createNew(response.stdOut); - Core::EditorManager::instance()->activateEditor(editor, Core::EditorManager::ModeSwitch); + Core::EditorManager::activateEditor(editor, Core::EditorManager::ModeSwitch); } else { const QString title = QString::fromLatin1("cvs log %1").arg(id); Core::IEditor *newEditor = showOutputInEditor(title, response.stdOut, LogOutput, source, codec); @@ -1026,7 +1026,7 @@ void CvsPlugin::annotate(const QString &workingDir, const QString &file, if (IEditor *editor = VcsBaseEditorWidget::locateEditorByTag(tag)) { editor->createNew(response.stdOut); VcsBaseEditorWidget::gotoLineOfEditor(editor, lineNumber); - EditorManager::instance()->activateEditor(editor, EditorManager::ModeSwitch); + EditorManager::activateEditor(editor, EditorManager::ModeSwitch); } else { const QString title = QString::fromLatin1("cvs annotate %1").arg(id); IEditor *newEditor = showOutputInEditor(title, response.stdOut, AnnotateOutput, source, codec); @@ -1221,7 +1221,7 @@ bool CvsPlugin::describe(const QString &repositoryPath, const QString commitId = entries.front().revisions.front().commitId; if (IEditor *editor = VcsBaseEditorWidget::locateEditorByTag(commitId)) { editor->createNew(output); - EditorManager::instance()->activateEditor(editor, EditorManager::ModeSwitch); + EditorManager::activateEditor(editor, EditorManager::ModeSwitch); setDiffBaseDirectory(editor, repositoryPath); } else { const QString title = QString::fromLatin1("cvs describe %1").arg(commitId); @@ -1236,7 +1236,7 @@ void CvsPlugin::submitCurrentLog() { m_submitActionTriggered = true; EditorManager::instance()->closeEditors(QList<IEditor*>() - << EditorManager::instance()->currentEditor()); + << EditorManager::currentEditor()); } // Run CVS. At this point, file arguments must be relative to @@ -1293,7 +1293,7 @@ IEditor *CvsPlugin::showOutputInEditor(const QString& title, const QString &outp qDebug() << "CVSPlugin::showOutputInEditor" << title << id.name() << "source=" << source << "Size= " << output.size() << " Type=" << editorType << debugCodec(codec); QString s = title; - IEditor *editor = EditorManager::instance()->openEditorWithContents(id, &s, output); + IEditor *editor = EditorManager::openEditorWithContents(id, &s, output); connect(editor, SIGNAL(annotateRevisionRequested(QString,QString,int)), this, SLOT(vcsAnnotate(QString,QString,int))); CvsEditor *e = qobject_cast<CvsEditor*>(editor->widget()); @@ -1307,7 +1307,7 @@ IEditor *CvsPlugin::showOutputInEditor(const QString& title, const QString &outp if (codec) e->setCodec(codec); IEditor *ie = e->editor(); - EditorManager::instance()->activateEditor(ie, EditorManager::ModeSwitch); + EditorManager::activateEditor(ie, EditorManager::ModeSwitch); return ie; } diff --git a/src/plugins/debugger/debuggerengine.cpp b/src/plugins/debugger/debuggerengine.cpp index e838dbed96..017aa11f57 100644 --- a/src/plugins/debugger/debuggerengine.cpp +++ b/src/plugins/debugger/debuggerengine.cpp @@ -639,11 +639,10 @@ void DebuggerEngine::gotoLocation(const Location &loc) const QString file = loc.fileName(); const int line = loc.lineNumber(); - EditorManager *editorManager = EditorManager::instance(); - QList<IEditor *> editors = editorManager->editorsForFileName(file); + QList<IEditor *> editors = EditorManager::instance()->editorsForFileName(file); IEditor *editor = 0; if (editors.isEmpty()) { - editor = editorManager->openEditor(file, Core::Id(), + editor = EditorManager::openEditor(file, Core::Id(), EditorManager::IgnoreNavigationHistory); if (editor) { editors.append(editor); @@ -665,7 +664,7 @@ void DebuggerEngine::gotoLocation(const Location &loc) // FIXME: Breaks with split views. if (!d->m_memoryAgent.hasVisibleEditor() || loc.needsRaise()) - editorManager->activateEditor(editor); + EditorManager::activateEditor(editor); //qDebug() << "MEMORY: " << d->m_memoryAgent.hasVisibleEditor(); } diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index 74a6489b3f..7d9e700aa6 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -573,10 +573,7 @@ public: static TextEditor::ITextEditor *currentTextEditor() { - if (const Core::EditorManager *editorManager = Core::EditorManager::instance()) - if (Core::IEditor *editor = editorManager->currentEditor()) - return qobject_cast<TextEditor::ITextEditor*>(editor); - return 0; + return qobject_cast<TextEditor::ITextEditor *>(Core::EditorManager::currentEditor()); } static bool currentTextEditorPosition(ContextData *data) @@ -1033,10 +1030,7 @@ public slots: void handleAddToWatchWindow() { // Requires a selection, but that's the only case we want anyway. - EditorManager *editorManager = EditorManager::instance(); - if (!editorManager) - return; - IEditor *editor = editorManager->currentEditor(); + IEditor *editor = EditorManager::currentEditor(); if (!editor) return; ITextEditor *textEditor = qobject_cast<ITextEditor*>(editor); @@ -2192,7 +2186,7 @@ void DebuggerPluginPrivate::cleanupViews() // if they are not modified and not current editor. if (editor->property(Constants::OPENED_WITH_DISASSEMBLY).toBool() || (!editor->document()->isModified() - && editor != editorManager->currentEditor())) { + && editor != EditorManager::currentEditor())) { toClose.append(editor); } else { editor->setProperty(Constants::OPENED_BY_DEBUGGER, false); @@ -2470,9 +2464,9 @@ void DebuggerPluginPrivate::onModeChanged(IMode *mode) return; } - EditorManager *editorManager = EditorManager::instance(); - if (editorManager->currentEditor()) - editorManager->currentEditor()->widget()->setFocus(); + if (IEditor *editor = EditorManager::currentEditor()) + editor->widget()->setFocus(); + m_toolTipManager->debugModeEntered(); } @@ -2611,12 +2605,10 @@ void DebuggerPluginPrivate::openTextEditor(const QString &titlePattern0, if (m_shuttingDown) return; QString titlePattern = titlePattern0; - EditorManager *editorManager = EditorManager::instance(); - QTC_ASSERT(editorManager, return); - IEditor *editor = editorManager->openEditorWithContents( + IEditor *editor = EditorManager::openEditorWithContents( CC::K_DEFAULT_TEXT_EDITOR_ID, &titlePattern, contents); QTC_ASSERT(editor, return); - editorManager->activateEditor(editor, EditorManager::IgnoreNavigationHistory); + EditorManager::activateEditor(editor, EditorManager::IgnoreNavigationHistory); } diff --git a/src/plugins/debugger/debuggertooltipmanager.cpp b/src/plugins/debugger/debuggertooltipmanager.cpp index 63a819f84b..ccbd610ea3 100644 --- a/src/plugins/debugger/debuggertooltipmanager.cpp +++ b/src/plugins/debugger/debuggertooltipmanager.cpp @@ -236,7 +236,7 @@ DebuggerToolTipEditor::DebuggerToolTipEditor(IEditor *ie) : DebuggerToolTipEditor DebuggerToolTipEditor::currentToolTipEditor() { - if (IEditor *ie = EditorManager::instance()->currentEditor()) + if (IEditor *ie = EditorManager::currentEditor()) return DebuggerToolTipEditor(ie); return DebuggerToolTipEditor(); } diff --git a/src/plugins/debugger/disassembleragent.cpp b/src/plugins/debugger/disassembleragent.cpp index d8b6327f12..ed141a11a5 100644 --- a/src/plugins/debugger/disassembleragent.cpp +++ b/src/plugins/debugger/disassembleragent.cpp @@ -305,11 +305,10 @@ void DisassemblerAgent::setContentsToEditor(const DisassemblerLines &contents) using namespace Core; using namespace TextEditor; - EditorManager *editorManager = EditorManager::instance(); if (!d->editor) { QString titlePattern = QLatin1String("Disassembler"); d->editor = qobject_cast<ITextEditor *>( - editorManager->openEditorWithContents( + EditorManager::openEditorWithContents( Core::Constants::K_DEFAULT_TEXT_EDITOR_ID, &titlePattern)); QTC_ASSERT(d->editor, return); @@ -323,7 +322,7 @@ void DisassemblerAgent::setContentsToEditor(const DisassemblerLines &contents) baseTextEdit->setRequestMarkEnabled(true); } - editorManager->activateEditor(d->editor); + EditorManager::activateEditor(d->editor); QPlainTextEdit *plainTextEdit = qobject_cast<QPlainTextEdit *>(d->editor->widget()); diff --git a/src/plugins/debugger/memoryagent.cpp b/src/plugins/debugger/memoryagent.cpp index f9fa8a97c4..480bfbdb7e 100644 --- a/src/plugins/debugger/memoryagent.cpp +++ b/src/plugins/debugger/memoryagent.cpp @@ -192,10 +192,9 @@ bool MemoryAgent::doCreateBinEditor(quint64 addr, unsigned flags, } // Editor: Register tracking not supported. QTC_ASSERT(!(flags & DebuggerEngine::MemoryTrackRegister), return false); - EditorManager *editorManager = EditorManager::instance(); if (!title.endsWith(QLatin1Char('$'))) title.append(QLatin1String(" $")); - IEditor *editor = editorManager->openEditorWithContents( + IEditor *editor = EditorManager::openEditorWithContents( Core::Constants::K_DEFAULT_BINARY_EDITOR_ID, &title); if (!editor) return false; @@ -208,7 +207,7 @@ bool MemoryAgent::doCreateBinEditor(quint64 addr, unsigned flags, MemoryView::setBinEditorRange(editorBinEditor, addr, MemoryAgent::DataRange, MemoryAgent::BinBlockSize); MemoryView::setBinEditorMarkup(editorBinEditor, ml); m_editors << editor; - editorManager->activateEditor(editor); + EditorManager::activateEditor(editor); return true; } diff --git a/src/plugins/debugger/qml/qmlengine.cpp b/src/plugins/debugger/qml/qmlengine.cpp index 65447ace2b..589aa8465e 100644 --- a/src/plugins/debugger/qml/qmlengine.cpp +++ b/src/plugins/debugger/qml/qmlengine.cpp @@ -559,7 +559,7 @@ void QmlEngine::gotoLocation(const Location &location) } } if (!editor) { - editor = editorManager->openEditorWithContents(QmlJSEditor::Constants::C_QMLJSEDITOR_ID, + editor = Core::EditorManager::openEditorWithContents(QmlJSEditor::Constants::C_QMLJSEDITOR_ID, &titlePattern); if (editor) { editor->setProperty(Constants::OPENED_BY_DEBUGGER, true); @@ -567,7 +567,7 @@ void QmlEngine::gotoLocation(const Location &location) updateEditor(editor, m_sourceDocuments.value(fileName)); } - editorManager->activateEditor(editor); + Core::EditorManager::activateEditor(editor); } else { DebuggerEngine::gotoLocation(location); diff --git a/src/plugins/debugger/sourceagent.cpp b/src/plugins/debugger/sourceagent.cpp index fea3e3ad98..6f38c80dc8 100644 --- a/src/plugins/debugger/sourceagent.cpp +++ b/src/plugins/debugger/sourceagent.cpp @@ -131,12 +131,11 @@ void SourceAgent::setContent(const QString &filePath, const QString &content) d->path = filePath; - EditorManager *editorManager = EditorManager::instance(); if (!d->editor) { QString titlePattern = d->producer + QLatin1String(": ") + QFileInfo(filePath).fileName(); d->editor = qobject_cast<ITextEditor *>( - editorManager->openEditorWithContents( + EditorManager::openEditorWithContents( CppEditor::Constants::CPPEDITOR_ID, &titlePattern, content)); QTC_ASSERT(d->editor, return); @@ -148,7 +147,7 @@ void SourceAgent::setContent(const QString &filePath, const QString &content) baseTextEdit->setRequestMarkEnabled(true); } - editorManager->activateEditor(d->editor); + EditorManager::activateEditor(d->editor); QPlainTextEdit *plainTextEdit = qobject_cast<QPlainTextEdit *>(d->editor->widget()); @@ -178,8 +177,7 @@ void SourceAgent::updateLocationMarker() QTextBlock block = tc.document()->findBlockByNumber(lineNumber - 1); tc.setPosition(block.position()); plainTextEdit->setTextCursor(tc); - EditorManager *editorManager = EditorManager::instance(); - editorManager->activateEditor(d->editor); + EditorManager::activateEditor(d->editor); } } diff --git a/src/plugins/designer/formeditorfactory.cpp b/src/plugins/designer/formeditorfactory.cpp index a1862399a0..4af841fd94 100644 --- a/src/plugins/designer/formeditorfactory.cpp +++ b/src/plugins/designer/formeditorfactory.cpp @@ -74,7 +74,7 @@ QString FormEditorFactory::displayName() const Core::IDocument *FormEditorFactory::open(const QString &fileName) { - Core::IEditor *iface = Core::EditorManager::instance()->openEditor(fileName, id()); + Core::IEditor *iface = Core::EditorManager::openEditor(fileName, id()); if (!iface) return 0; if (qobject_cast<FormWindowEditor *>(iface)) { diff --git a/src/plugins/designer/formeditorw.cpp b/src/plugins/designer/formeditorw.cpp index ad591dba6f..97dad56c45 100644 --- a/src/plugins/designer/formeditorw.cpp +++ b/src/plugins/designer/formeditorw.cpp @@ -906,8 +906,8 @@ void FormEditorW::print() // Find out current existing editor file static QString currentFile() { - if (Core::IEditor *editor = Core::EditorManager::instance()->currentEditor()) - if (const Core::IDocument *document= editor->document()) { + if (Core::IEditor *editor = Core::EditorManager::currentEditor()) + if (const Core::IDocument *document = editor->document()) { const QString fileName = document->fileName(); if (!fileName.isEmpty() && QFileInfo(fileName).isFile()) return fileName; @@ -954,7 +954,7 @@ void FormEditorW::switchSourceForm() { const QString fileToOpen = otherFile(); if (!fileToOpen.isEmpty()) - Core::ICore::editorManager()->openEditor(fileToOpen, Core::Id(), Core::EditorManager::ModeSwitch); + Core::EditorManager::openEditor(fileToOpen, Core::Id(), Core::EditorManager::ModeSwitch); } } // namespace Internal diff --git a/src/plugins/fakevim/fakevimplugin.cpp b/src/plugins/fakevim/fakevimplugin.cpp index 14e1899a81..511e3aa13e 100644 --- a/src/plugins/fakevim/fakevimplugin.cpp +++ b/src/plugins/fakevim/fakevimplugin.cpp @@ -1023,7 +1023,7 @@ void FakeVimPluginPrivate::userActionTriggered() if (!key) return; QString cmd = userCommandMap().value(key); - IEditor *editor = ICore::editorManager()->currentEditor(); + IEditor *editor = EditorManager::currentEditor(); FakeVimHandler *handler = m_editorToHandler[editor]; if (handler) handler->handleInput(cmd); @@ -1257,11 +1257,9 @@ void FakeVimPluginPrivate::windowCommand(int key) void FakeVimPluginPrivate::moveSomewhere(DistFunction f) { - EditorManager *editorManager = ICore::editorManager(); - IEditor *editor = editorManager->currentEditor(); + IEditor *editor = EditorManager::currentEditor(); QWidget *w = editor->widget(); - QPlainTextEdit *pe = - qobject_cast<QPlainTextEdit *>(editor->widget()); + QPlainTextEdit *pe = qobject_cast<QPlainTextEdit *>(w); QTC_ASSERT(pe, return); QRect rc = pe->cursorRect(); QRect cursorRect(w->mapToGlobal(rc.topLeft()), @@ -1271,8 +1269,7 @@ void FakeVimPluginPrivate::moveSomewhere(DistFunction f) IEditor *bestEditor = 0; int bestValue = 1 << 30; - QList<IEditor*> editors = editorManager->visibleEditors(); - foreach (IEditor *editor, editors) { + foreach (IEditor *editor, EditorManager::instance()->visibleEditors()) { QWidget *w = editor->widget(); QRect editorRect(w->mapToGlobal(w->geometry().topLeft()), w->mapToGlobal(w->geometry().bottomRight())); @@ -1290,7 +1287,7 @@ void FakeVimPluginPrivate::moveSomewhere(DistFunction f) // FIME: This is know to fail as the EditorManager will fall back to // the current editor's view. Needs additional public API there. if (bestEditor) - editorManager->activateEditor(bestEditor); + EditorManager::activateEditor(bestEditor); } void FakeVimPluginPrivate::find(bool reverse) @@ -1707,9 +1704,8 @@ void FakeVimPluginPrivate::changeSelection int FakeVimPluginPrivate::currentFile() const { - EditorManager *editorManager = ICore::editorManager(); - OpenEditorsModel *model = editorManager->openedEditorsModel(); - IEditor *editor = editorManager->currentEditor(); + OpenEditorsModel *model = EditorManager::instance()->openedEditorsModel(); + IEditor *editor = EditorManager::currentEditor(); return model->indexOf(editor).row(); } diff --git a/src/plugins/git/gerrit/gerritplugin.cpp b/src/plugins/git/gerrit/gerritplugin.cpp index c52a6f5a16..3b88a1b6f1 100644 --- a/src/plugins/git/gerrit/gerritplugin.cpp +++ b/src/plugins/git/gerrit/gerritplugin.cpp @@ -222,7 +222,7 @@ void FetchContext::processFinished(int exitCode, QProcess::ExitStatus es) m_progress.reportFinished(); QString title = QString(QLatin1String("Gerrit patch %1/%2")) .arg(m_change->number).arg(m_change->currentPatchSet.patchSetNumber); - Core::IEditor *editor = Core::EditorManager::instance()->openEditor( + Core::IEditor *editor = Core::EditorManager::openEditor( m_patchFileName, Git::Constants::GIT_DIFF_EDITOR_ID); VcsBase::VcsBaseEditorWidget *vcsEditor = VcsBase::VcsBaseEditorWidget::getVcsBaseEditor(editor); vcsEditor->setDiffBaseDirectory(m_repository); diff --git a/src/plugins/git/gitclient.cpp b/src/plugins/git/gitclient.cpp index c9842b221f..a73d817a0c 100644 --- a/src/plugins/git/gitclient.cpp +++ b/src/plugins/git/gitclient.cpp @@ -402,7 +402,7 @@ VcsBase::VcsBaseEditorWidget *GitClient::findExistingVCSEditor(const char *regis return 0; // Exists already - Core::EditorManager::instance()->activateEditor(outputEditor, Core::EditorManager::ModeSwitch); + Core::EditorManager::activateEditor(outputEditor, Core::EditorManager::ModeSwitch); outputEditor->createNew(m_msgWait); rc = VcsBase::VcsBaseEditorWidget::getVcsBaseEditor(outputEditor); @@ -427,7 +427,7 @@ VcsBase::VcsBaseEditorWidget *GitClient::createVcsEditor(const Core::Id &id, QTC_CHECK(!findExistingVCSEditor(registerDynamicProperty, dynamicPropertyValue)); // Create new, set wait message, set up with source and codec - Core::IEditor *outputEditor = Core::ICore::editorManager()->openEditorWithContents(id, &title, m_msgWait); + Core::IEditor *outputEditor = Core::EditorManager::openEditorWithContents(id, &title, m_msgWait); outputEditor->document()->setProperty(registerDynamicProperty, dynamicPropertyValue); rc = VcsBase::VcsBaseEditorWidget::getVcsBaseEditor(outputEditor); connect(rc, SIGNAL(annotateRevisionRequested(QString,QString,int)), @@ -444,7 +444,7 @@ VcsBase::VcsBaseEditorWidget *GitClient::createVcsEditor(const Core::Id &id, } rc->setForceReadOnly(true); - Core::ICore::editorManager()->activateEditor(outputEditor, Core::EditorManager::ModeSwitch); + Core::EditorManager::activateEditor(outputEditor, Core::EditorManager::ModeSwitch); if (configWidget) rc->setConfigurationWidget(configWidget); diff --git a/src/plugins/git/gitplugin.cpp b/src/plugins/git/gitplugin.cpp index 5f0b1568aa..a2902220c1 100644 --- a/src/plugins/git/gitplugin.cpp +++ b/src/plugins/git/gitplugin.cpp @@ -713,8 +713,8 @@ void GitPlugin::startCommit(bool amend) Core::IEditor *GitPlugin::openSubmitEditor(const QString &fileName, const CommitData &cd, bool amend) { - Core::IEditor *editor = Core::ICore::editorManager()->openEditor(fileName, Constants::GITSUBMITEDITOR_ID, - Core::EditorManager::ModeSwitch); + Core::IEditor *editor = Core::EditorManager::openEditor(fileName, Constants::GITSUBMITEDITOR_ID, + Core::EditorManager::ModeSwitch); GitSubmitEditor *submitEditor = qobject_cast<GitSubmitEditor*>(editor); QTC_ASSERT(submitEditor, return 0); // The actions are for some reason enabled by the context switching @@ -735,7 +735,7 @@ void GitPlugin::submitCurrentLog() // Close the submit editor m_submitActionTriggered = true; QList<Core::IEditor*> editors; - editors.push_back(Core::ICore::editorManager()->currentEditor()); + editors.push_back(Core::EditorManager::currentEditor()); Core::ICore::editorManager()->closeEditors(editors); } diff --git a/src/plugins/help/helpplugin.cpp b/src/plugins/help/helpplugin.cpp index 55d9c3aa67..fcea273847 100644 --- a/src/plugins/help/helpplugin.cpp +++ b/src/plugins/help/helpplugin.cpp @@ -832,7 +832,7 @@ HelpViewer *HelpPlugin::viewerForContextMode() switch (contextHelpOption()) { case Help::Constants::SideBySideIfPossible: { // side by side if possible - if (IEditor *editor = EditorManager::instance()->currentEditor()) { + if (IEditor *editor = EditorManager::currentEditor()) { if (!placeHolder || !placeHolder->isVisible()) { if (!editor->widget()) break; diff --git a/src/plugins/imageviewer/imagevieweractionhandler.cpp b/src/plugins/imageviewer/imagevieweractionhandler.cpp index 18fe4a9d4a..3dc7653ba7 100644 --- a/src/plugins/imageviewer/imagevieweractionhandler.cpp +++ b/src/plugins/imageviewer/imagevieweractionhandler.cpp @@ -58,8 +58,7 @@ ImageViewerActionHandler::ImageViewerActionHandler(QObject *parent) : void ImageViewerActionHandler::actionTriggered(int supportedAction) { - Core::EditorManager *editorManager = Core::EditorManager::instance(); - Core::IEditor *editor = editorManager->currentEditor(); + Core::IEditor *editor = Core::EditorManager::currentEditor(); ImageViewer *viewer = qobject_cast<ImageViewer *>(editor); if (!viewer) return; diff --git a/src/plugins/locator/basefilefilter.cpp b/src/plugins/locator/basefilefilter.cpp index 24d52c542b..46359f6c10 100644 --- a/src/plugins/locator/basefilefilter.cpp +++ b/src/plugins/locator/basefilefilter.cpp @@ -99,8 +99,7 @@ QList<FilterEntry> BaseFileFilter::matchesFor(QFutureInterface<Locator::FilterEn void BaseFileFilter::accept(Locator::FilterEntry selection) const { - Core::EditorManager *em = Core::EditorManager::instance(); - em->openEditor(selection.internalData.toString(), Id(), Core::EditorManager::ModeSwitch); + EditorManager::openEditor(selection.internalData.toString(), Id(), EditorManager::ModeSwitch); } void BaseFileFilter::generateFileNames() diff --git a/src/plugins/locator/filesystemfilter.cpp b/src/plugins/locator/filesystemfilter.cpp index c148e95373..04c715386a 100644 --- a/src/plugins/locator/filesystemfilter.cpp +++ b/src/plugins/locator/filesystemfilter.cpp @@ -59,7 +59,7 @@ QList<FilterEntry> FileSystemFilter::matchesFor(QFutureInterface<Locator::Filter if (filePath.startsWith(QLatin1String("~/"))) { directory.replace(0, 1, QDir::homePath()); } else { - IEditor *editor = m_editorManager->currentEditor(); + IEditor *editor = EditorManager::currentEditor(); if (editor && !editor->document()->fileName().isEmpty()) { QFileInfo info(editor->document()->fileName()); directory.prepend(info.absolutePath() + QLatin1Char('/')); @@ -109,8 +109,8 @@ void FileSystemFilter::accept(FilterEntry selection) const m_locatorWidget->show(value, value.length()); return; } - m_editorManager->openEditor(selection.internalData.toString(), Id(), - Core::EditorManager::ModeSwitch); + EditorManager::openEditor(selection.internalData.toString(), Id(), + EditorManager::ModeSwitch); } bool FileSystemFilter::openConfigDialog(QWidget *parent, bool &needsRefresh) diff --git a/src/plugins/locator/opendocumentsfilter.cpp b/src/plugins/locator/opendocumentsfilter.cpp index 40c84081a9..d8196c798f 100644 --- a/src/plugins/locator/opendocumentsfilter.cpp +++ b/src/plugins/locator/opendocumentsfilter.cpp @@ -102,5 +102,5 @@ void OpenDocumentsFilter::refresh(QFutureInterface<void> &future) void OpenDocumentsFilter::accept(FilterEntry selection) const { - m_editorManager->openEditor(selection.internalData.toString(), Core::Id(), Core::EditorManager::ModeSwitch); + EditorManager::openEditor(selection.internalData.toString(), Id(), EditorManager::ModeSwitch); } diff --git a/src/plugins/macros/findmacrohandler.cpp b/src/plugins/macros/findmacrohandler.cpp index 369e4539e9..a151e77316 100644 --- a/src/plugins/macros/findmacrohandler.cpp +++ b/src/plugins/macros/findmacrohandler.cpp @@ -75,7 +75,7 @@ bool FindMacroHandler::canExecuteEvent(const MacroEvent ¯oEvent) bool FindMacroHandler::executeEvent(const MacroEvent ¯oEvent) { - Core::IEditor *editor = Core::EditorManager::instance()->currentEditor(); + Core::IEditor *editor = Core::EditorManager::currentEditor(); if (!editor) return false; @@ -228,7 +228,7 @@ void FindMacroHandler::changeEditor(Core::IEditor *editor) void FindMacroHandler::startRecording(Macros::Macro* macro) { IMacroHandler::startRecording(macro); - const Core::EditorManager *editorManager = Core::EditorManager::instance(); - if (editorManager->currentEditor()) - changeEditor(editorManager->currentEditor()); + Core::IEditor *current = Core::EditorManager::currentEditor(); + if (current) + changeEditor(current); } diff --git a/src/plugins/macros/macrolocatorfilter.cpp b/src/plugins/macros/macrolocatorfilter.cpp index a29933bd32..7f7b29eeae 100644 --- a/src/plugins/macros/macrolocatorfilter.cpp +++ b/src/plugins/macros/macrolocatorfilter.cpp @@ -78,7 +78,7 @@ QList<Locator::FilterEntry> MacroLocatorFilter::matchesFor(QFutureInterface<Loca void MacroLocatorFilter::accept(Locator::FilterEntry selection) const { // Give the focus back to the editor - Core::IEditor *editor = Core::EditorManager::instance()->currentEditor(); + Core::IEditor *editor = Core::EditorManager::currentEditor(); if (editor) editor->widget()->setFocus(Qt::OtherFocusReason); diff --git a/src/plugins/macros/macromanager.cpp b/src/plugins/macros/macromanager.cpp index 7c1293c488..3318277fa4 100644 --- a/src/plugins/macros/macromanager.cpp +++ b/src/plugins/macros/macromanager.cpp @@ -226,9 +226,8 @@ bool MacroManager::MacroManagerPrivate::executeMacro(Macro *macro) // Set the focus back to the editor // TODO: is it really needed?? - const Core::EditorManager *editorManager = Core::EditorManager::instance(); - if (editorManager->currentEditor()) - editorManager->currentEditor()->widget()->setFocus(Qt::OtherFocusReason); + if (Core::IEditor *current = Core::EditorManager::currentEditor()) + current->widget()->setFocus(Qt::OtherFocusReason); return !error; } diff --git a/src/plugins/madde/maemopackagecreationwidget.cpp b/src/plugins/madde/maemopackagecreationwidget.cpp index 7721e1839d..4cdc563cb0 100644 --- a/src/plugins/madde/maemopackagecreationwidget.cpp +++ b/src/plugins/madde/maemopackagecreationwidget.cpp @@ -276,7 +276,7 @@ void MaemoPackageCreationWidget::editSpecFile() void MaemoPackageCreationWidget::editFile(const QString &filePath) { - Core::EditorManager::instance()->openEditor(filePath, Core::Id(), + Core::EditorManager::openEditor(filePath, Core::Id(), Core::EditorManager::ModeSwitch); } diff --git a/src/plugins/mercurial/mercurialplugin.cpp b/src/plugins/mercurial/mercurialplugin.cpp index 20187dd958..5847e79678 100644 --- a/src/plugins/mercurial/mercurialplugin.cpp +++ b/src/plugins/mercurial/mercurialplugin.cpp @@ -582,9 +582,9 @@ void MercurialPlugin::showCommitWidget(const QList<VcsBaseClient::StatusItem> &s return; } - Core::IEditor *editor = core->editorManager()->openEditor(changeLog->fileName(), - Constants::COMMIT_ID, - Core::EditorManager::ModeSwitch); + Core::IEditor *editor = Core::EditorManager::openEditor(changeLog->fileName(), + Constants::COMMIT_ID, + Core::EditorManager::ModeSwitch); if (!editor) { outputWindow->appendError(tr("Unable to create an editor for the commit.")); return; diff --git a/src/plugins/perforce/perforceplugin.cpp b/src/plugins/perforce/perforceplugin.cpp index a368bea40f..14f2532b3e 100644 --- a/src/plugins/perforce/perforceplugin.cpp +++ b/src/plugins/perforce/perforceplugin.cpp @@ -678,8 +678,7 @@ void PerforcePlugin::startSubmitProject() Core::IEditor *PerforcePlugin::openPerforceSubmitEditor(const QString &fileName, const QStringList &depotFileNames) { - Core::EditorManager *editorManager = Core::EditorManager::instance(); - Core::IEditor *editor = editorManager->openEditor(fileName, Constants::PERFORCE_SUBMIT_EDITOR_ID, + Core::IEditor *editor = Core::EditorManager::openEditor(fileName, Constants::PERFORCE_SUBMIT_EDITOR_ID, Core::EditorManager::ModeSwitch); PerforceSubmitEditor *submitEditor = static_cast<PerforceSubmitEditor*>(editor); submitEditor->restrictToProjectFiles(depotFileNames); @@ -1198,7 +1197,7 @@ Core::IEditor *PerforcePlugin::showOutputInEditor(const QString &title, const QS qDebug() << "PerforcePlugin::showOutputInEditor" << title << id.name() << "Size= " << output.size() << " Type=" << editorType << debugCodec(codec); QString s = title; - Core::IEditor *editor = Core::EditorManager::instance()->openEditorWithContents(id, &s, output); + Core::IEditor *editor = Core::EditorManager::openEditorWithContents(id, &s, output); connect(editor, SIGNAL(annotateRevisionRequested(QString,QString,int)), this, SLOT(vcsAnnotate(QString,QString,int))); PerforceEditor *e = qobject_cast<PerforceEditor*>(editor->widget()); @@ -1211,7 +1210,7 @@ Core::IEditor *PerforcePlugin::showOutputInEditor(const QString &title, const QS if (codec) e->setCodec(codec); Core::IEditor *ie = e->editor(); - Core::EditorManager::instance()->activateEditor(ie, Core::EditorManager::ModeSwitch); + Core::EditorManager::activateEditor(ie, Core::EditorManager::ModeSwitch); return ie; } @@ -1294,7 +1293,7 @@ void PerforcePlugin::p4Diff(const PerforceDiffParameters &p) if (existingEditor) { existingEditor->createNew(result.stdOut); - Core::EditorManager::instance()->activateEditor(existingEditor, Core::EditorManager::ModeSwitch); + Core::EditorManager::activateEditor(existingEditor, Core::EditorManager::ModeSwitch); return; } // Create new editor @@ -1329,7 +1328,7 @@ void PerforcePlugin::submitCurrentLog() { m_submitActionTriggered = true; Core::EditorManager *em = Core::EditorManager::instance(); - em->closeEditors(QList<Core::IEditor*>() << em->currentEditor()); + em->closeEditors(QList<Core::IEditor*>() << Core::EditorManager::currentEditor()); } void PerforcePlugin::cleanCommitMessageFile() diff --git a/src/plugins/projectexplorer/foldernavigationwidget.cpp b/src/plugins/projectexplorer/foldernavigationwidget.cpp index c4fb459e18..8f5dc94899 100644 --- a/src/plugins/projectexplorer/foldernavigationwidget.cpp +++ b/src/plugins/projectexplorer/foldernavigationwidget.cpp @@ -270,8 +270,7 @@ void FolderNavigationWidget::openItem(const QModelIndex &srcIndex) return; } // Open file. - Core::EditorManager *editorManager = Core::EditorManager::instance(); - editorManager->openEditor(m_fileSystemModel->filePath(srcIndex), Core::Id(), Core::EditorManager::ModeSwitch); + Core::EditorManager::openEditor(m_fileSystemModel->filePath(srcIndex), Core::Id(), Core::EditorManager::ModeSwitch); } void FolderNavigationWidget::setCurrentTitle(QString dirName, const QString &fullPath) diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index 92f46f15e1..acdd2fdf82 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -1044,7 +1044,7 @@ void ProjectExplorerPlugin::loadAction() // for your special convenience, we preselect a pro file if it is // the current file - if (Core::IEditor *editor = Core::EditorManager::instance()->currentEditor()) { + if (Core::IEditor *editor = Core::EditorManager::currentEditor()) { if (const Core::IDocument *document= editor->document()) { const QString fn = document->fileName(); const bool isProject = d->m_profileMimeTypes.contains(document->mimeType()); @@ -2708,8 +2708,7 @@ void ProjectExplorerPlugin::removeProject() void ProjectExplorerPlugin::openFile() { QTC_ASSERT(d->m_currentNode, return); - Core::EditorManager *em = Core::EditorManager::instance(); - em->openEditor(d->m_currentNode->path(), Core::Id(), Core::EditorManager::ModeSwitch); + Core::EditorManager::openEditor(d->m_currentNode->path(), Core::Id(), Core::EditorManager::ModeSwitch); } void ProjectExplorerPlugin::searchOnFileSystem() diff --git a/src/plugins/projectexplorer/projecttreewidget.cpp b/src/plugins/projectexplorer/projecttreewidget.cpp index 077060147f..6d34939e0a 100644 --- a/src/plugins/projectexplorer/projecttreewidget.cpp +++ b/src/plugins/projectexplorer/projecttreewidget.cpp @@ -360,10 +360,8 @@ void ProjectTreeWidget::initView() void ProjectTreeWidget::openItem(const QModelIndex &mainIndex) { Node *node = m_model->nodeForIndex(mainIndex); - if (node->nodeType() == FileNodeType) { - Core::EditorManager *editorManager = Core::EditorManager::instance(); - editorManager->openEditor(node->path(), Core::Id(), Core::EditorManager::ModeSwitch); - } + if (node->nodeType() == FileNodeType) + Core::EditorManager::openEditor(node->path(), Core::Id(), Core::EditorManager::ModeSwitch); } void ProjectTreeWidget::setProjectFilter(bool filter) diff --git a/src/plugins/qmldesigner/components/integration/designdocumentcontroller.cpp b/src/plugins/qmldesigner/components/integration/designdocumentcontroller.cpp index 3225c04c79..e3c16c1e5d 100644 --- a/src/plugins/qmldesigner/components/integration/designdocumentcontroller.cpp +++ b/src/plugins/qmldesigner/components/integration/designdocumentcontroller.cpp @@ -332,7 +332,7 @@ void DesignDocumentController::setCrumbleBarInfo(const CrumbleBarInfo &crumbleBa DesignDocumentControllerPrivate::pushCrumblePath = false; while (!compareCrumbleBarInfo(d->formEditorView->crumblePath()->dataForLastIndex().value<CrumbleBarInfo>(), crumbleBarInfo)) d->formEditorView->crumblePath()->popElement(); - Core::EditorManager::instance()->openEditor(crumbleBarInfo.fileName); + Core::EditorManager::openEditor(crumbleBarInfo.fileName); DesignDocumentControllerPrivate::pushCrumblePath = true; Internal::DesignModeWidget::instance()->currentDesignDocumentController()->changeToSubComponent(crumbleBarInfo.modelNode); DesignDocumentControllerPrivate::clearCrumblePath = true; @@ -525,7 +525,7 @@ void DesignDocumentController::changeToSubComponent(const ModelNode &componentNo void DesignDocumentController::changeToExternalSubComponent(const QString &fileName) { DesignDocumentControllerPrivate::clearCrumblePath = false; - Core::EditorManager::instance()->openEditor(fileName); + Core::EditorManager::openEditor(fileName); DesignDocumentControllerPrivate::clearCrumblePath = true; } diff --git a/src/plugins/qmldesigner/components/navigator/navigatorview.cpp b/src/plugins/qmldesigner/components/navigator/navigatorview.cpp index 27f9d4b0d0..328b392d81 100644 --- a/src/plugins/qmldesigner/components/navigator/navigatorview.cpp +++ b/src/plugins/qmldesigner/components/navigator/navigatorview.cpp @@ -273,7 +273,7 @@ void NavigatorView::changeToComponent(const QModelIndex &index) if (index.isValid() && m_treeModel->data(index, Qt::UserRole).isValid()) { ModelNode doubleClickNode = m_treeModel->nodeForIndex(index); if (doubleClickNode.metaInfo().isComponent()) - Core::EditorManager::instance()->openEditor(doubleClickNode.metaInfo().componentFileName()); + Core::EditorManager::openEditor(doubleClickNode.metaInfo().componentFileName()); } } diff --git a/src/plugins/qmldesigner/designmodewidget.cpp b/src/plugins/qmldesigner/designmodewidget.cpp index f066e13df7..db756f7941 100644 --- a/src/plugins/qmldesigner/designmodewidget.cpp +++ b/src/plugins/qmldesigner/designmodewidget.cpp @@ -842,9 +842,7 @@ void DesignModeWidget::onGoBackClicked() if (m_navigatorHistoryCounter > 0) { --m_navigatorHistoryCounter; m_keepNavigatorHistory = true; - - Core::EditorManager::instance()->openEditor(m_navigatorHistory.at(m_navigatorHistoryCounter)); - + Core::EditorManager::openEditor(m_navigatorHistory.at(m_navigatorHistoryCounter)); m_keepNavigatorHistory = false; } } @@ -854,9 +852,7 @@ void DesignModeWidget::onGoForwardClicked() if (m_navigatorHistoryCounter < (m_navigatorHistory.size() - 1)) { ++m_navigatorHistoryCounter; m_keepNavigatorHistory = true; - - Core::EditorManager::instance()->openEditor(m_navigatorHistory.at(m_navigatorHistoryCounter)); - + Core::EditorManager::openEditor(m_navigatorHistory.at(m_navigatorHistoryCounter)); m_keepNavigatorHistory = false; } } diff --git a/src/plugins/qmldesigner/qmldesignerplugin.cpp b/src/plugins/qmldesigner/qmldesignerplugin.cpp index d71f9f7088..e58ec74ee2 100644 --- a/src/plugins/qmldesigner/qmldesignerplugin.cpp +++ b/src/plugins/qmldesigner/qmldesignerplugin.cpp @@ -301,7 +301,7 @@ void BauhausPlugin::contextChanged(Core::IContext *context, const Core::Context foreach (int additionalContext, additionalContexts) { if (m_context->context().contains(additionalContext)) { m_isActive = true; - m_mainWidget->showEditor(m_editorManager->currentEditor()); + m_mainWidget->showEditor(Core::EditorManager::currentEditor()); return; } } @@ -371,10 +371,8 @@ BauhausPlugin *BauhausPlugin::pluginInstance() void BauhausPlugin::switchTextDesign() { - Core::EditorManager *editorManager = Core::EditorManager::instance(); - Core::IEditor *editor = editorManager->currentEditor(); - if (Core::ModeManager::currentMode()->id() == Core::Constants::MODE_EDIT) { + Core::IEditor *editor = Core::EditorManager::currentEditor(); if (editor->id() == QmlJSEditor::Constants::C_QMLJSEDITOR_ID) { Core::ModeManager::activateMode(Core::Constants::MODE_DESIGN); m_mainWidget->setFocus(); diff --git a/src/plugins/qmljseditor/qmljseditor.cpp b/src/plugins/qmljseditor/qmljseditor.cpp index 8ca6136ab8..f1ecea1988 100644 --- a/src/plugins/qmljseditor/qmljseditor.cpp +++ b/src/plugins/qmljseditor/qmljseditor.cpp @@ -1321,8 +1321,7 @@ void QmlJSTextEditorWidget::updateSemanticInfo() return; // Save time by not doing it for non-active editors. - Core::EditorManager *editorManager = Core::EditorManager::instance(); - if (editorManager->currentEditor() != editor()) + if (Core::EditorManager::currentEditor() != editor()) return; m_updateSemanticInfoTimer->start(); @@ -1378,8 +1377,7 @@ void QmlJSTextEditorWidget::acceptNewSemanticInfo(const SemanticInfo &semanticIn appendExtraSelectionsForMessages(&selections, m_semanticInfo.staticAnalysisMessages, document()); setExtraSelections(CodeWarningsSelection, selections); - Core::EditorManager *editorManager = Core::EditorManager::instance(); - if (editorManager->currentEditor() == editor()) + if (Core::EditorManager::currentEditor() == editor()) m_semanticHighlighter->rerun(m_semanticInfo.scopeChain()); emit semanticInfoUpdated(); diff --git a/src/plugins/qmljseditor/qmljseditorplugin.cpp b/src/plugins/qmljseditor/qmljseditorplugin.cpp index 5faae4381f..46b8ecb455 100644 --- a/src/plugins/qmljseditor/qmljseditorplugin.cpp +++ b/src/plugins/qmljseditor/qmljseditorplugin.cpp @@ -294,22 +294,19 @@ Utils::JsonSchemaManager *QmlJSEditorPlugin::jsonManager() const void QmlJSEditorPlugin::findUsages() { - Core::EditorManager *em = Core::EditorManager::instance(); - if (QmlJSTextEditorWidget *editor = qobject_cast<QmlJSTextEditorWidget*>(em->currentEditor()->widget())) + if (QmlJSTextEditorWidget *editor = qobject_cast<QmlJSTextEditorWidget*>(Core::EditorManager::currentEditor()->widget())) editor->findUsages(); } void QmlJSEditorPlugin::renameUsages() { - Core::EditorManager *em = Core::EditorManager::instance(); - if (QmlJSTextEditorWidget *editor = qobject_cast<QmlJSTextEditorWidget*>(em->currentEditor()->widget())) + if (QmlJSTextEditorWidget *editor = qobject_cast<QmlJSTextEditorWidget*>(Core::EditorManager::currentEditor()->widget())) editor->renameUsages(); } void QmlJSEditorPlugin::reformatFile() { - Core::EditorManager *em = Core::EditorManager::instance(); - if (QmlJSTextEditorWidget *editor = qobject_cast<QmlJSTextEditorWidget*>(em->currentEditor()->widget())) { + if (QmlJSTextEditorWidget *editor = qobject_cast<QmlJSTextEditorWidget*>(Core::EditorManager::currentEditor()->widget())) { QTC_ASSERT(!editor->isSemanticInfoOutdated(), return); const QString &newText = QmlJS::reformat(editor->semanticInfo().document); @@ -322,9 +319,7 @@ void QmlJSEditorPlugin::reformatFile() void QmlJSEditorPlugin::showContextPane() { - Core::EditorManager *em = Core::EditorManager::instance(); - - if (QmlJSTextEditorWidget *editor = qobject_cast<QmlJSTextEditorWidget*>(em->currentEditor()->widget())) + if (QmlJSTextEditorWidget *editor = qobject_cast<QmlJSTextEditorWidget*>(Core::EditorManager::currentEditor()->widget())) editor->showContextPane(); } diff --git a/src/plugins/qmljseditor/qmljsfindreferences.cpp b/src/plugins/qmljseditor/qmljsfindreferences.cpp index 83ef3e4b91..55b62fa96d 100644 --- a/src/plugins/qmljseditor/qmljsfindreferences.cpp +++ b/src/plugins/qmljseditor/qmljsfindreferences.cpp @@ -975,8 +975,8 @@ void FindReferences::openEditor(const Find::SearchResultItem &item) item.lineNumber, item.textMarkPos, Core::Id(), Core::EditorManager::ModeSwitch); } else { - Core::EditorManager::instance()->openEditor(QDir::fromNativeSeparators(item.text), - Core::Id(), Core::EditorManager::ModeSwitch); + Core::EditorManager::openEditor(QDir::fromNativeSeparators(item.text), + Core::Id(), Core::EditorManager::ModeSwitch); } } diff --git a/src/plugins/qmlprofiler/qmlprofilertool.cpp b/src/plugins/qmlprofiler/qmlprofilertool.cpp index 0e871545d8..8cef7cf673 100644 --- a/src/plugins/qmlprofiler/qmlprofilertool.cpp +++ b/src/plugins/qmlprofiler/qmlprofilertool.cpp @@ -491,12 +491,11 @@ void QmlProfilerTool::gotoSourceLocation(const QString &fileUrl, int lineNumber, if (!fileInfo.exists() || !fileInfo.isReadable()) return; - EditorManager *editorManager = EditorManager::instance(); - IEditor *editor = editorManager->openEditor(projectFileName); + IEditor *editor = EditorManager::openEditor(projectFileName); TextEditor::ITextEditor *textEditor = qobject_cast<TextEditor::ITextEditor*>(editor); if (textEditor) { - editorManager->addCurrentPositionToNavigationHistory(); + EditorManager::instance()->addCurrentPositionToNavigationHistory(); // textEditor counts columns starting with 0, but the ASTs store the // location starting with 1, therefore the -1 in the call to gotoLine textEditor->gotoLine(lineNumber, columnNumber - 1); diff --git a/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp b/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp index 2cc2b17743..9a3dc44895 100644 --- a/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp +++ b/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp @@ -330,7 +330,7 @@ void QmlProjectRunConfiguration::updateEnabled() { bool qmlFileFound = false; if (mainScriptSource() == FileInEditor) { - Core::IEditor *editor = Core::EditorManager::instance()->currentEditor(); + Core::IEditor *editor = Core::EditorManager::currentEditor(); Core::MimeDatabase *db = ICore::mimeDatabase(); if (editor) { m_currentFileFilename = editor->document()->fileName(); diff --git a/src/plugins/qt4projectmanager/qt4projectmanager.cpp b/src/plugins/qt4projectmanager/qt4projectmanager.cpp index c60906f066..67161d2597 100644 --- a/src/plugins/qt4projectmanager/qt4projectmanager.cpp +++ b/src/plugins/qt4projectmanager/qt4projectmanager.cpp @@ -318,8 +318,8 @@ void Qt4Manager::setContextFile(ProjectExplorer::FileNode *file) void Qt4Manager::addLibrary() { - Core::EditorManager *em = Core::EditorManager::instance(); - ProFileEditorWidget *editor = qobject_cast<ProFileEditorWidget*>(em->currentEditor()->widget()); + ProFileEditorWidget *editor = + qobject_cast<ProFileEditorWidget*>(Core::EditorManager::currentEditor()->widget()); if (editor) addLibrary(editor->editorDocument()->fileName(), editor); } @@ -341,9 +341,8 @@ void Qt4Manager::addLibrary(const QString &fileName, ProFileEditorWidget *editor if (editor) { editable = editor->editor(); } else { - Core::EditorManager *em = Core::EditorManager::instance(); editable = qobject_cast<TextEditor::BaseTextEditor *> - (em->openEditor(fileName, Qt4ProjectManager::Constants::PROFILE_EDITOR_ID)); + (Core::EditorManager::openEditor(fileName, Qt4ProjectManager::Constants::PROFILE_EDITOR_ID)); } if (!editable) return; diff --git a/src/plugins/qt4projectmanager/wizards/abstractmobileappwizard.cpp b/src/plugins/qt4projectmanager/wizards/abstractmobileappwizard.cpp index a0c4884b40..152a8f5ba4 100644 --- a/src/plugins/qt4projectmanager/wizards/abstractmobileappwizard.cpp +++ b/src/plugins/qt4projectmanager/wizards/abstractmobileappwizard.cpp @@ -282,7 +282,7 @@ bool AbstractMobileAppWizard::postGenerateFiles(const QWizard *w, if (success) { const QString fileToOpen = fileToOpenPostGeneration(); if (!fileToOpen.isEmpty()) { - Core::EditorManager::instance()->openEditor(fileToOpen, Core::Id(), Core::EditorManager::ModeSwitch); + Core::EditorManager::openEditor(fileToOpen, Core::Id(), Core::EditorManager::ModeSwitch); ProjectExplorer::ProjectExplorerPlugin::instance()->setCurrentFile(0, fileToOpen); } } diff --git a/src/plugins/remotelinux/remotelinuxdeployconfigurationwidget.cpp b/src/plugins/remotelinux/remotelinuxdeployconfigurationwidget.cpp index f415a9d9d9..818221ffcc 100644 --- a/src/plugins/remotelinux/remotelinuxdeployconfigurationwidget.cpp +++ b/src/plugins/remotelinux/remotelinuxdeployconfigurationwidget.cpp @@ -203,7 +203,7 @@ void RemoteLinuxDeployConfigurationWidget::openProjectFile() return; const DeployableFilesPerProFile * const proFileInfo = d->deployConfiguration->deploymentInfo()->modelAt(row); - Core::EditorManager::instance()->openEditor(proFileInfo->proFilePath(), Core::Id(), + Core::EditorManager::openEditor(proFileInfo->proFilePath(), Core::Id(), Core::EditorManager::ModeSwitch); } diff --git a/src/plugins/resourceeditor/resourceeditorplugin.cpp b/src/plugins/resourceeditor/resourceeditorplugin.cpp index a9d2e2ece4..931350429b 100644 --- a/src/plugins/resourceeditor/resourceeditorplugin.cpp +++ b/src/plugins/resourceeditor/resourceeditorplugin.cpp @@ -127,7 +127,7 @@ void ResourceEditorPlugin::onUndoStackChanged(ResourceEditorW const *editor, ResourceEditorW * ResourceEditorPlugin::currentEditor() const { ResourceEditorW * const focusEditor = qobject_cast<ResourceEditorW *>( - Core::EditorManager::instance()->currentEditor()); + Core::EditorManager::currentEditor()); QTC_ASSERT(focusEditor, return 0); return focusEditor; } diff --git a/src/plugins/subversion/subversionplugin.cpp b/src/plugins/subversion/subversionplugin.cpp index 9369fdc514..db10a657f7 100644 --- a/src/plugins/subversion/subversionplugin.cpp +++ b/src/plugins/subversion/subversionplugin.cpp @@ -611,7 +611,7 @@ void SubversionPlugin::svnDiff(const Subversion::Internal::SubversionDiffParamet // Show in the same editor if diff has been executed before if (Core::IEditor *existingEditor = VcsBase::VcsBaseEditorWidget::locateEditorByTag(tag)) { existingEditor->createNew(response.stdOut); - Core::EditorManager::instance()->activateEditor(existingEditor, Core::EditorManager::ModeSwitch); + Core::EditorManager::activateEditor(existingEditor, Core::EditorManager::ModeSwitch); setDiffBaseDirectory(existingEditor, p.workingDir); return; } @@ -635,9 +635,9 @@ void SubversionPlugin::svnDiff(const Subversion::Internal::SubversionDiffParamet SubversionSubmitEditor *SubversionPlugin::openSubversionSubmitEditor(const QString &fileName) { - Core::IEditor *editor = Core::EditorManager::instance()->openEditor(fileName, - Constants::SUBVERSIONCOMMITEDITOR_ID, - Core::EditorManager::ModeSwitch); + Core::IEditor *editor = Core::EditorManager::openEditor(fileName, + Constants::SUBVERSIONCOMMITEDITOR_ID, + Core::EditorManager::ModeSwitch); SubversionSubmitEditor *submitEditor = qobject_cast<SubversionSubmitEditor*>(editor); QTC_CHECK(submitEditor); submitEditor->registerActions(m_submitUndoAction, m_submitRedoAction, m_submitCurrentLogAction, m_submitDiffAction); @@ -923,7 +923,7 @@ void SubversionPlugin::filelog(const QString &workingDir, const QString tag = VcsBase::VcsBaseEditorWidget::editorTag(VcsBase::LogOutput, workingDir, files); if (Core::IEditor *editor = VcsBase::VcsBaseEditorWidget::locateEditorByTag(tag)) { editor->createNew(response.stdOut); - Core::EditorManager::instance()->activateEditor(editor, Core::EditorManager::ModeSwitch); + Core::EditorManager::activateEditor(editor, Core::EditorManager::ModeSwitch); } else { const QString title = QString::fromLatin1("svn log %1").arg(id); const QString source = VcsBase::VcsBaseEditorWidget::getSource(workingDir, files); @@ -1001,7 +1001,7 @@ void SubversionPlugin::vcsAnnotate(const QString &workingDir, const QString &fil if (Core::IEditor *editor = VcsBase::VcsBaseEditorWidget::locateEditorByTag(tag)) { editor->createNew(response.stdOut); VcsBase::VcsBaseEditorWidget::gotoLineOfEditor(editor, lineNumber); - Core::EditorManager::instance()->activateEditor(editor, Core::EditorManager::ModeSwitch); + Core::EditorManager::activateEditor(editor, Core::EditorManager::ModeSwitch); } else { const QString title = QString::fromLatin1("svn annotate %1").arg(id); Core::IEditor *newEditor = showOutputInEditor(title, response.stdOut, VcsBase::AnnotateOutput, source, codec); @@ -1066,7 +1066,7 @@ void SubversionPlugin::describe(const QString &source, const QString &changeNr) const QString tag = VcsBase::VcsBaseEditorWidget::editorTag(VcsBase::DiffOutput, source, QStringList(), changeNr); if (Core::IEditor *editor = VcsBase::VcsBaseEditorWidget::locateEditorByTag(tag)) { editor->createNew(description); - Core::EditorManager::instance()->activateEditor(editor, Core::EditorManager::ModeSwitch); + Core::EditorManager::activateEditor(editor, Core::EditorManager::ModeSwitch); } else { const QString title = QString::fromLatin1("svn describe %1#%2").arg(fi.fileName(), changeNr); Core::IEditor *newEditor = showOutputInEditor(title, description, VcsBase::DiffOutput, source, codec); @@ -1096,7 +1096,7 @@ void SubversionPlugin::submitCurrentLog() { m_submitActionTriggered = true; Core::EditorManager::instance()->closeEditors(QList<Core::IEditor*>() - << Core::EditorManager::instance()->currentEditor()); + << Core::EditorManager::currentEditor()); } SubversionResponse @@ -1172,7 +1172,7 @@ Core::IEditor *SubversionPlugin::showOutputInEditor(const QString &title, const qDebug() << "SubversionPlugin::showOutputInEditor" << title << id.name() << "Size= " << output.size() << " Type=" << editorType << debugCodec(codec); QString s = title; - Core::IEditor *editor = Core::EditorManager::instance()->openEditorWithContents(id, &s, output); + Core::IEditor *editor = Core::EditorManager::openEditorWithContents(id, &s, output); connect(editor, SIGNAL(annotateRevisionRequested(QString,QString,int)), this, SLOT(annotateVersion(QString,QString,int))); SubversionEditor *e = qobject_cast<SubversionEditor*>(editor->widget()); @@ -1186,7 +1186,7 @@ Core::IEditor *SubversionPlugin::showOutputInEditor(const QString &title, const if (codec) e->setCodec(codec); Core::IEditor *ie = e->editor(); - Core::EditorManager::instance()->activateEditor(ie, Core::EditorManager::ModeSwitch); + Core::EditorManager::activateEditor(ie, Core::EditorManager::ModeSwitch); return ie; } diff --git a/src/plugins/texteditor/basefilefind.cpp b/src/plugins/texteditor/basefilefind.cpp index b33e8f6217..accd0327de 100644 --- a/src/plugins/texteditor/basefilefind.cpp +++ b/src/plugins/texteditor/basefilefind.cpp @@ -292,8 +292,8 @@ void BaseFileFind::openEditor(const Find::SearchResultItem &item) Core::Id(), Core::EditorManager::ModeSwitch); } else { - openedEditor = Core::EditorManager::instance()->openEditor(QDir::fromNativeSeparators(item.text), - Core::Id(), Core::EditorManager::ModeSwitch); + openedEditor = Core::EditorManager::openEditor(QDir::fromNativeSeparators(item.text), + Core::Id(), Core::EditorManager::ModeSwitch); } if (m_currentFindSupport) m_currentFindSupport->clearResults(); diff --git a/src/plugins/texteditor/basetextdocument.cpp b/src/plugins/texteditor/basetextdocument.cpp index 6b3477322d..31fd84d2bb 100644 --- a/src/plugins/texteditor/basetextdocument.cpp +++ b/src/plugins/texteditor/basetextdocument.cpp @@ -211,7 +211,7 @@ bool BaseTextDocument::save(QString *errorString, const QString &fileName, bool int undos = d->m_document->availableUndoSteps(); // When saving the current editor, make sure to maintain the cursor position for undo - Core::IEditor *currentEditor = Core::EditorManager::instance()->currentEditor(); + Core::IEditor *currentEditor = Core::EditorManager::currentEditor(); if (BaseTextEditor *editable = qobject_cast<BaseTextEditor*>(currentEditor)) { if (editable->document() == this) { editorWidget = editable->editorWidget(); diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp index 57653edb20..82ec47065a 100644 --- a/src/plugins/texteditor/basetexteditor.cpp +++ b/src/plugins/texteditor/basetexteditor.cpp @@ -170,7 +170,7 @@ Core::IEditor *BaseTextEditorWidget::openEditorAt(const QString &fileName, int l Core::EditorManager *editorManager = Core::EditorManager::instance(); editorManager->cutForwardNavigationHistory(); editorManager->addCurrentPositionToNavigationHistory(); - Core::IEditor *editor = editorManager->openEditor(fileName, editorKind, + Core::IEditor *editor = Core::EditorManager::openEditor(fileName, editorKind, flags, newEditor); TextEditor::ITextEditor *texteditor = qobject_cast<TextEditor::ITextEditor *>(editor); if (texteditor && line != -1) { diff --git a/src/plugins/texteditor/findincurrentfile.cpp b/src/plugins/texteditor/findincurrentfile.cpp index df35d9db76..434fc70f9f 100644 --- a/src/plugins/texteditor/findincurrentfile.cpp +++ b/src/plugins/texteditor/findincurrentfile.cpp @@ -47,7 +47,7 @@ FindInCurrentFile::FindInCurrentFile() { connect(Core::ICore::editorManager(), SIGNAL(currentEditorChanged(Core::IEditor*)), this, SLOT(handleFileChange(Core::IEditor*))); - handleFileChange(Core::ICore::editorManager()->currentEditor()); + handleFileChange(Core::EditorManager::currentEditor()); } QString FindInCurrentFile::id() const diff --git a/src/plugins/texteditor/linenumberfilter.cpp b/src/plugins/texteditor/linenumberfilter.cpp index b43b5d8300..1e431dda5e 100644 --- a/src/plugins/texteditor/linenumberfilter.cpp +++ b/src/plugins/texteditor/linenumberfilter.cpp @@ -75,8 +75,5 @@ void LineNumberFilter::accept(FilterEntry selection) const ITextEditor *LineNumberFilter::currentTextEditor() const { - Core::EditorManager *editorManager = Core::EditorManager::instance(); - if (!editorManager->currentEditor()) - return 0; - return qobject_cast<TextEditor::ITextEditor*>(editorManager->currentEditor()); + return qobject_cast<TextEditor::ITextEditor *>(EditorManager::currentEditor()); } diff --git a/src/plugins/texteditor/outlinefactory.cpp b/src/plugins/texteditor/outlinefactory.cpp index 3c9e2981e8..eee5a4298b 100644 --- a/src/plugins/texteditor/outlinefactory.cpp +++ b/src/plugins/texteditor/outlinefactory.cpp @@ -79,7 +79,7 @@ OutlineWidgetStack::OutlineWidgetStack(OutlineFactory *factory) : Core::EditorManager *editorManager = Core::EditorManager::instance(); connect(editorManager, SIGNAL(currentEditorChanged(Core::IEditor*)), this, SLOT(updateCurrentEditor(Core::IEditor*))); - updateCurrentEditor(editorManager->currentEditor()); + updateCurrentEditor(Core::EditorManager::currentEditor()); } OutlineWidgetStack::~OutlineWidgetStack() diff --git a/src/plugins/texteditor/texteditorplugin.cpp b/src/plugins/texteditor/texteditorplugin.cpp index 001b48948a..b4eec0dcfd 100644 --- a/src/plugins/texteditor/texteditorplugin.cpp +++ b/src/plugins/texteditor/texteditorplugin.cpp @@ -145,8 +145,7 @@ void ScratchFileWizard::runWizard(const QString &, QWidget *, const QString &, c file.setAutoRemove(false); QTC_ASSERT(file.open(), return; ); file.close(); - Core::EditorManager *em = Core::EditorManager::instance(); - em->openEditor(file.fileName(), Core::Id(), Core::EditorManager::ModeSwitch); + Core::EditorManager::openEditor(file.fileName(), Core::Id(), Core::EditorManager::ModeSwitch); } // ExtensionSystem::PluginInterface @@ -272,14 +271,14 @@ void TextEditorPlugin::initializeEditor(PlainTextEditorWidget *editor) void TextEditorPlugin::invokeCompletion() { - Core::IEditor *iface = Core::EditorManager::instance()->currentEditor(); + Core::IEditor *iface = Core::EditorManager::currentEditor(); if (BaseTextEditorWidget *w = qobject_cast<BaseTextEditorWidget *>(iface->widget())) w->invokeAssist(Completion); } void TextEditorPlugin::invokeQuickFix() { - Core::IEditor *iface = Core::EditorManager::instance()->currentEditor(); + Core::IEditor *iface = Core::EditorManager::currentEditor(); if (BaseTextEditorWidget *w = qobject_cast<BaseTextEditorWidget *>(iface->widget())) w->invokeAssist(QuickFix); } @@ -302,7 +301,7 @@ void TextEditorPlugin::updateVariable(const QByteArray &variable) << kCurrentDocumentFontSize; if (variables.contains(variable)) { QString value; - Core::IEditor *iface = Core::EditorManager::instance()->currentEditor(); + Core::IEditor *iface = Core::EditorManager::currentEditor(); ITextEditor *editor = qobject_cast<ITextEditor *>(iface); if (editor) { if (variable == kCurrentDocumentSelection) { @@ -326,7 +325,7 @@ void TextEditorPlugin::updateVariable(const QByteArray &variable) void TextEditorPlugin::updateCurrentSelection(const QString &text) { - Core::IEditor *iface = Core::EditorManager::instance()->currentEditor(); + Core::IEditor *iface = Core::EditorManager::currentEditor(); ITextEditor *editor = qobject_cast<ITextEditor *>(iface); if (editor) { int pos = editor->position(); diff --git a/src/plugins/todo/todoitemsprovider.cpp b/src/plugins/todo/todoitemsprovider.cpp index 99476eeb15..5ea59fc7b7 100644 --- a/src/plugins/todo/todoitemsprovider.cpp +++ b/src/plugins/todo/todoitemsprovider.cpp @@ -167,7 +167,7 @@ void TodoItemsProvider::setupCurrentEditorBinding() { Core::EditorManager *editorManager = Core::EditorManager::instance(); - m_currentEditor = editorManager->currentEditor(); + m_currentEditor = Core::EditorManager::currentEditor(); connect(editorManager, SIGNAL(currentEditorChanged(Core::IEditor*)), SLOT(currentEditorChanged(Core::IEditor*))); } diff --git a/src/plugins/todo/todoplugin.cpp b/src/plugins/todo/todoplugin.cpp index 6d3187e9c3..48c0d0fca1 100755 --- a/src/plugins/todo/todoplugin.cpp +++ b/src/plugins/todo/todoplugin.cpp @@ -100,7 +100,7 @@ void TodoPlugin::scanningScopeChanged(ScanningScope scanningScope) void TodoPlugin::todoItemClicked(const TodoItem &item) { if (QFileInfo(item.file).exists()) { - Core::IEditor *editor = Core::EditorManager::instance()->openEditor(item.file); + Core::IEditor *editor = Core::EditorManager::openEditor(item.file); editor->gotoLine(item.line); } } diff --git a/src/plugins/vcsbase/cleandialog.cpp b/src/plugins/vcsbase/cleandialog.cpp index 4033cbb773..1a1e199fe1 100644 --- a/src/plugins/vcsbase/cleandialog.cpp +++ b/src/plugins/vcsbase/cleandialog.cpp @@ -275,7 +275,7 @@ void CleanDialog::slotDoubleClicked(const QModelIndex &index) if (const QStandardItem *item = d->m_filesModel->itemFromIndex(index)) if (!item->data(Internal::isDirectoryRole).toBool()) { const QString fname = item->data(Internal::fileNameRole).toString(); - Core::EditorManager::instance()->openEditor(fname, Core::Id(), Core::EditorManager::ModeSwitch); + Core::EditorManager::openEditor(fname, Core::Id(), Core::EditorManager::ModeSwitch); } } diff --git a/src/plugins/vcsbase/vcsbaseclient.cpp b/src/plugins/vcsbase/vcsbaseclient.cpp index 06313e932c..c3a6fa4a51 100644 --- a/src/plugins/vcsbase/vcsbaseclient.cpp +++ b/src/plugins/vcsbase/vcsbaseclient.cpp @@ -568,7 +568,7 @@ VcsBase::VcsBaseEditorWidget *VcsBaseClient::createVcsEditor(const QString &kind baseEditor = VcsBase::VcsBaseEditorWidget::getVcsBaseEditor(outputEditor); QTC_ASSERT(baseEditor, return 0); } else { - outputEditor = Core::ICore::editorManager()->openEditorWithContents(Core::Id(kind), &title, progressMsg); + outputEditor = Core::EditorManager::openEditorWithContents(Core::Id(kind), &title, progressMsg); outputEditor->document()->setProperty(registerDynamicProperty, dynamicPropertyValue); baseEditor = VcsBase::VcsBaseEditorWidget::getVcsBaseEditor(outputEditor); connect(baseEditor, SIGNAL(annotateRevisionRequested(QString,QString,int)), @@ -580,7 +580,7 @@ VcsBase::VcsBaseEditorWidget *VcsBaseClient::createVcsEditor(const QString &kind } baseEditor->setForceReadOnly(true); - Core::ICore::editorManager()->activateEditor(outputEditor, Core::EditorManager::ModeSwitch); + Core::EditorManager::activateEditor(outputEditor, Core::EditorManager::ModeSwitch); return baseEditor; } diff --git a/src/plugins/vcsbase/vcsbaseeditor.cpp b/src/plugins/vcsbase/vcsbaseeditor.cpp index d85ee59677..dce41dbd69 100644 --- a/src/plugins/vcsbase/vcsbaseeditor.cpp +++ b/src/plugins/vcsbase/vcsbaseeditor.cpp @@ -1095,8 +1095,7 @@ void VcsBaseEditorWidget::jumpToChangeFromDiff(QTextCursor cursor) if (!exists) return; - Core::EditorManager *em = Core::EditorManager::instance(); - Core::IEditor *ed = em->openEditor(fileName, Core::Id(), Core::EditorManager::ModeSwitch); + Core::IEditor *ed = Core::EditorManager::openEditor(fileName, Core::Id(), Core::EditorManager::ModeSwitch); if (TextEditor::ITextEditor *editor = qobject_cast<TextEditor::ITextEditor *>(ed)) editor->gotoLine(chunkStart + lineCount); } @@ -1256,7 +1255,7 @@ VcsBaseEditorWidget *VcsBaseEditorWidget::getVcsBaseEditor(const Core::IEditor * // Return line number of current editor if it matches. int VcsBaseEditorWidget::lineNumberOfCurrentEditor(const QString ¤tFile) { - Core::IEditor *ed = Core::EditorManager::instance()->currentEditor(); + Core::IEditor *ed = Core::EditorManager::currentEditor(); if (!ed) return -1; if (!currentFile.isEmpty()) { diff --git a/src/plugins/vcsbase/vcsbaseoutputwindow.cpp b/src/plugins/vcsbase/vcsbaseoutputwindow.cpp index cc03033bed..66c412028a 100644 --- a/src/plugins/vcsbase/vcsbaseoutputwindow.cpp +++ b/src/plugins/vcsbase/vcsbaseoutputwindow.cpp @@ -194,7 +194,7 @@ void OutputWindowPlainTextEdit::contextMenuEvent(QContextMenuEvent *event) } if (action == openAction) { const QString fileName = action->data().toString(); - Core::EditorManager::instance()->openEditor(fileName, Core::Id(), Core::EditorManager::ModeSwitch); + Core::EditorManager::openEditor(fileName, Core::Id(), Core::EditorManager::ModeSwitch); } } delete menu; diff --git a/src/plugins/vcsbase/vcsbaseplugin.cpp b/src/plugins/vcsbase/vcsbaseplugin.cpp index 3ed052efe8..93deb84d41 100644 --- a/src/plugins/vcsbase/vcsbaseplugin.cpp +++ b/src/plugins/vcsbase/vcsbaseplugin.cpp @@ -237,11 +237,11 @@ void StateListener::slotStateChanged() // temporary path prefix or does the file contains a hash, indicating a project // folder? State state; - Core::EditorManager *em = Core::ICore::editorManager(); - if (!em || !em->currentEditor() || !em->currentEditor()->document()) + Core::IEditor *currentEditor = Core::EditorManager::currentEditor(); + if (!currentEditor || !currentEditor->document()) state.currentFile.clear(); else - state.currentFile = em->currentEditor()->document()->fileName(); + state.currentFile = currentEditor->document()->fileName(); QScopedPointer<QFileInfo> currentFileInfo; // Instantiate QFileInfo only once if required. if (!state.currentFile.isEmpty()) { const bool isTempFile = state.currentFile.startsWith(QDir::tempPath()); diff --git a/src/plugins/vcsbase/vcsbasesubmiteditor.cpp b/src/plugins/vcsbase/vcsbasesubmiteditor.cpp index 41360a5458..c4e01a8be6 100644 --- a/src/plugins/vcsbase/vcsbasesubmiteditor.cpp +++ b/src/plugins/vcsbase/vcsbasesubmiteditor.cpp @@ -807,15 +807,16 @@ void VcsBaseSubmitEditor::filterUntrackedFilesOfProject(const QString &repositor // Helper to raise an already open submit editor to prevent opening twice. bool VcsBaseSubmitEditor::raiseSubmitEditor() { - Core::EditorManager *em = Core::EditorManager::instance(); // Nothing to do? - if (Core::IEditor *ce = em->currentEditor()) + if (Core::IEditor *ce = Core::EditorManager::currentEditor()) if (qobject_cast<VcsBaseSubmitEditor*>(ce)) return true; // Try to activate a hidden one + Core::EditorManager *em = Core::EditorManager::instance(); foreach (Core::IEditor *e, em->openedEditors()) { if (qobject_cast<VcsBaseSubmitEditor*>(e)) { - em->activateEditor(e, Core::EditorManager::IgnoreNavigationHistory | Core::EditorManager::ModeSwitch); + Core::EditorManager::activateEditor(e, + Core::EditorManager::IgnoreNavigationHistory | Core::EditorManager::ModeSwitch); return true; } } |