diff --git a/src/plugins/bineditor/bineditorplugin.cpp b/src/plugins/bineditor/bineditorplugin.cpp index 9a26c4a1cbe..8c22297295a 100644 --- a/src/plugins/bineditor/bineditorplugin.cpp +++ b/src/plugins/bineditor/bineditorplugin.cpp @@ -426,13 +426,6 @@ QString BinEditorFactory::displayName() const return tr(Constants::C_BINEDITOR_DISPLAY_NAME); } -Core::IDocument *BinEditorFactory::open(const QString &fileName) -{ - Core::EditorManager *em = Core::EditorManager::instance(); - Core::IEditor *iface = em->openEditor(fileName, id()); - return iface ? iface->document() : 0; -} - Core::IEditor *BinEditorFactory::createEditor(QWidget *parent) { BinEditor *editor = new BinEditor(parent); diff --git a/src/plugins/bineditor/bineditorplugin.h b/src/plugins/bineditor/bineditorplugin.h index b4fd4050892..ea68086e3b7 100644 --- a/src/plugins/bineditor/bineditorplugin.h +++ b/src/plugins/bineditor/bineditorplugin.h @@ -109,7 +109,6 @@ public: Core::IEditor *createEditor(QWidget *parent); Core::Id id() const; QString displayName() const; - Core::IDocument *open(const QString &fileName); private: const QStringList m_mimeTypes; diff --git a/src/plugins/cmakeprojectmanager/cmakeeditorfactory.cpp b/src/plugins/cmakeprojectmanager/cmakeeditorfactory.cpp index 86756f86579..c48d41c0d0e 100644 --- a/src/plugins/cmakeprojectmanager/cmakeeditorfactory.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeeditorfactory.cpp @@ -84,12 +84,6 @@ QString CMakeEditorFactory::displayName() const return tr(CMakeProjectManager::Constants::CMAKE_EDITOR_DISPLAY_NAME); } -Core::IDocument *CMakeEditorFactory::open(const QString &fileName) -{ - Core::IEditor *iface = Core::EditorManager::instance()->openEditor(fileName, id()); - return iface ? iface->document() : 0; -} - Core::IEditor *CMakeEditorFactory::createEditor(QWidget *parent) { CMakeEditorWidget *rc = new CMakeEditorWidget(parent, this, m_actionHandler); diff --git a/src/plugins/cmakeprojectmanager/cmakeeditorfactory.h b/src/plugins/cmakeprojectmanager/cmakeeditorfactory.h index a58a4115d16..3c542aec5cd 100644 --- a/src/plugins/cmakeprojectmanager/cmakeeditorfactory.h +++ b/src/plugins/cmakeprojectmanager/cmakeeditorfactory.h @@ -57,7 +57,6 @@ public: QStringList mimeTypes() const; Core::Id id() const; QString displayName() const; - Core::IDocument *open(const QString &fileName); Core::IEditor *createEditor(QWidget *parent); private: diff --git a/src/plugins/coreplugin/coreplugin.pro b/src/plugins/coreplugin/coreplugin.pro index c32ec82c721..7f607f06062 100644 --- a/src/plugins/coreplugin/coreplugin.pro +++ b/src/plugins/coreplugin/coreplugin.pro @@ -94,7 +94,8 @@ SOURCES += mainwindow.cpp \ featureprovider.cpp \ idocument.cpp \ textdocument.cpp \ - documentmanager.cpp + documentmanager.cpp \ + ieditorfactory.cpp HEADERS += mainwindow.h \ editmode.h \ diff --git a/src/plugins/coreplugin/editormanager/ieditorfactory.h b/src/plugins/coreplugin/editormanager/ieditorfactory.h index 97e4860fc5b..4bfd2f67da9 100644 --- a/src/plugins/coreplugin/editormanager/ieditorfactory.h +++ b/src/plugins/coreplugin/editormanager/ieditorfactory.h @@ -47,6 +47,7 @@ public: IEditorFactory(QObject *parent = 0) : IDocumentFactory(parent) {} virtual IEditor *createEditor(QWidget *parent) = 0; + virtual IDocument *open(const QString &fileName); }; } // namespace Core diff --git a/src/plugins/coreplugin/ieditorfactory.cpp b/src/plugins/coreplugin/ieditorfactory.cpp new file mode 100644 index 00000000000..33c840f7fb1 --- /dev/null +++ b/src/plugins/coreplugin/ieditorfactory.cpp @@ -0,0 +1,42 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +**************************************************************************/ + +#include "ieditorfactory.h" + +#include "ieditor.h" +#include "editormanager.h" + +Core::IDocument *Core::IEditorFactory::open(const QString &fileName) +{ + Core::IEditor *iface = Core::EditorManager::instance()->openEditor(fileName, id()); + return iface ? iface->document() : 0; +} diff --git a/src/plugins/cppeditor/cppplugin.cpp b/src/plugins/cppeditor/cppplugin.cpp index bfc49aafdfe..efa3a23476f 100644 --- a/src/plugins/cppeditor/cppplugin.cpp +++ b/src/plugins/cppeditor/cppplugin.cpp @@ -108,12 +108,6 @@ QString CppEditorFactory::displayName() const return tr(CppEditor::Constants::CPPEDITOR_DISPLAY_NAME); } -Core::IDocument *CppEditorFactory::open(const QString &fileName) -{ - Core::IEditor *iface = Core::EditorManager::instance()->openEditor(fileName, id()); - return iface ? iface->document() : 0; -} - Core::IEditor *CppEditorFactory::createEditor(QWidget *parent) { CPPEditorWidget *editor = new CPPEditorWidget(parent); diff --git a/src/plugins/cppeditor/cppplugin.h b/src/plugins/cppeditor/cppplugin.h index 652c942d767..6591035a946 100644 --- a/src/plugins/cppeditor/cppplugin.h +++ b/src/plugins/cppeditor/cppplugin.h @@ -121,7 +121,6 @@ public: Core::IEditor *createEditor(QWidget *parent); Core::Id id() const; QString displayName() const; - Core::IDocument *open(const QString &fileName); private: CppPlugin *m_owner; diff --git a/src/plugins/genericprojectmanager/genericprojectfileseditor.cpp b/src/plugins/genericprojectmanager/genericprojectfileseditor.cpp index 68694545204..dc376212bd8 100644 --- a/src/plugins/genericprojectmanager/genericprojectfileseditor.cpp +++ b/src/plugins/genericprojectmanager/genericprojectfileseditor.cpp @@ -79,16 +79,6 @@ QString ProjectFilesFactory::displayName() const return tr(Constants::FILES_EDITOR_DISPLAY_NAME); } -Core::IDocument *ProjectFilesFactory::open(const QString &fileName) -{ - Core::EditorManager *editorManager = Core::EditorManager::instance(); - - if (Core::IEditor *editor = editorManager->openEditor(fileName, id())) - return editor->document(); - - return 0; -} - //////////////////////////////////////////////////////////////////////////////////////// // ProjectFilesEditable //////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/plugins/genericprojectmanager/genericprojectfileseditor.h b/src/plugins/genericprojectmanager/genericprojectfileseditor.h index a00005e31f8..bdc8fd9e1c9 100644 --- a/src/plugins/genericprojectmanager/genericprojectfileseditor.h +++ b/src/plugins/genericprojectmanager/genericprojectfileseditor.h @@ -62,7 +62,6 @@ public: virtual QStringList mimeTypes() const; virtual Core::Id id() const; virtual QString displayName() const; - virtual Core::IDocument *open(const QString &fileName); private: TextEditor::TextEditorActionHandler *m_actionHandler; diff --git a/src/plugins/glsleditor/glsleditorfactory.cpp b/src/plugins/glsleditor/glsleditorfactory.cpp index 397e3922411..ceb9a0038bf 100644 --- a/src/plugins/glsleditor/glsleditorfactory.cpp +++ b/src/plugins/glsleditor/glsleditorfactory.cpp @@ -75,16 +75,6 @@ QString GLSLEditorFactory::displayName() const return tr(C_GLSLEDITOR_DISPLAY_NAME); } -Core::IDocument *GLSLEditorFactory::open(const QString &fileName) -{ - Core::IEditor *iface = Core::EditorManager::instance()->openEditor(fileName, id()); - if (!iface) { - qWarning() << "QmlEditorFactory::open: openEditor failed for " << fileName; - return 0; - } - return iface->document(); -} - Core::IEditor *GLSLEditorFactory::createEditor(QWidget *parent) { GLSLEditor::GLSLTextEditorWidget *rc = new GLSLEditor::GLSLTextEditorWidget(parent); diff --git a/src/plugins/glsleditor/glsleditorfactory.h b/src/plugins/glsleditor/glsleditorfactory.h index 3cfad99e31c..2e556875ba6 100644 --- a/src/plugins/glsleditor/glsleditorfactory.h +++ b/src/plugins/glsleditor/glsleditorfactory.h @@ -51,7 +51,6 @@ public: QStringList mimeTypes() const; Core::Id id() const; QString displayName() const; - Core::IDocument *open(const QString &fileName); Core::IEditor *createEditor(QWidget *parent); private slots: diff --git a/src/plugins/qmljseditor/qmljseditorfactory.cpp b/src/plugins/qmljseditor/qmljseditorfactory.cpp index 42dfcabab6b..441c9866832 100644 --- a/src/plugins/qmljseditor/qmljseditorfactory.cpp +++ b/src/plugins/qmljseditor/qmljseditorfactory.cpp @@ -77,17 +77,6 @@ QString QmlJSEditorFactory::displayName() const return tr(C_QMLJSEDITOR_DISPLAY_NAME); } - -Core::IDocument *QmlJSEditorFactory::open(const QString &fileName) -{ - Core::IEditor *iface = Core::EditorManager::instance()->openEditor(fileName, id()); - if (!iface) { - qWarning() << "QmlEditorFactory::open: openEditor failed for " << fileName; - return 0; - } - return iface->document(); -} - Core::IEditor *QmlJSEditorFactory::createEditor(QWidget *parent) { QmlJSEditor::QmlJSTextEditorWidget *rc = new QmlJSEditor::QmlJSTextEditorWidget(parent); diff --git a/src/plugins/qmljseditor/qmljseditorfactory.h b/src/plugins/qmljseditor/qmljseditorfactory.h index 92a5b60cee5..3d7f6506987 100644 --- a/src/plugins/qmljseditor/qmljseditorfactory.h +++ b/src/plugins/qmljseditor/qmljseditorfactory.h @@ -51,7 +51,6 @@ public: QStringList mimeTypes() const; Core::Id id() const; QString displayName() const; - Core::IDocument *open(const QString &fileName); Core::IEditor *createEditor(QWidget *parent); private: diff --git a/src/plugins/qt4projectmanager/profileeditorfactory.cpp b/src/plugins/qt4projectmanager/profileeditorfactory.cpp index 20dea318966..38a5fc2f93b 100644 --- a/src/plugins/qt4projectmanager/profileeditorfactory.cpp +++ b/src/plugins/qt4projectmanager/profileeditorfactory.cpp @@ -78,12 +78,6 @@ QString ProFileEditorFactory::displayName() const return tr(Qt4ProjectManager::Constants::PROFILE_EDITOR_DISPLAY_NAME); } -Core::IDocument *ProFileEditorFactory::open(const QString &fileName) -{ - Core::IEditor *iface = Core::EditorManager::instance()->openEditor(fileName, id()); - return iface ? iface->document() : 0; -} - Core::IEditor *ProFileEditorFactory::createEditor(QWidget *parent) { ProFileEditorWidget *editor = new ProFileEditorWidget(parent, this, m_actionHandler); diff --git a/src/plugins/qt4projectmanager/profileeditorfactory.h b/src/plugins/qt4projectmanager/profileeditorfactory.h index 5c9d3ff604f..ff463afdfcf 100644 --- a/src/plugins/qt4projectmanager/profileeditorfactory.h +++ b/src/plugins/qt4projectmanager/profileeditorfactory.h @@ -59,7 +59,6 @@ public: QStringList mimeTypes() const; Core::Id id() const; QString displayName() const; - Core::IDocument *open(const QString &fileName); Core::IEditor *createEditor(QWidget *parent); Qt4Manager *qt4ProjectManager() const { return m_manager; } diff --git a/src/plugins/resourceeditor/resourceeditorfactory.cpp b/src/plugins/resourceeditor/resourceeditorfactory.cpp index 30f25de2e40..f416c26a07d 100644 --- a/src/plugins/resourceeditor/resourceeditorfactory.cpp +++ b/src/plugins/resourceeditor/resourceeditorfactory.cpp @@ -64,16 +64,6 @@ QString ResourceEditorFactory::displayName() const return tr(C_RESOURCEEDITOR_DISPLAY_NAME); } -Core::IDocument *ResourceEditorFactory::open(const QString &fileName) -{ - Core::IEditor *iface = Core::EditorManager::instance()->openEditor(fileName, id()); - if (!iface) { - qWarning() << "ResourceEditorFactory::open: openEditor failed for " << fileName; - return 0; - } - return iface->document(); -} - Core::IEditor *ResourceEditorFactory::createEditor(QWidget *parent) { Core::Context context(ResourceEditor::Constants::C_RESOURCEEDITOR); diff --git a/src/plugins/resourceeditor/resourceeditorfactory.h b/src/plugins/resourceeditor/resourceeditorfactory.h index 54dc1b5cfdb..c2ddd476984 100644 --- a/src/plugins/resourceeditor/resourceeditorfactory.h +++ b/src/plugins/resourceeditor/resourceeditorfactory.h @@ -55,7 +55,6 @@ public: // IEditorFactory Core::Id id() const; QString displayName() const; - Core::IDocument *open(const QString &fileName); Core::IEditor *createEditor(QWidget *parent); private: diff --git a/src/plugins/texteditor/plaintexteditorfactory.cpp b/src/plugins/texteditor/plaintexteditorfactory.cpp index 308819e11bf..2820a11cef6 100644 --- a/src/plugins/texteditor/plaintexteditorfactory.cpp +++ b/src/plugins/texteditor/plaintexteditorfactory.cpp @@ -75,12 +75,6 @@ QString PlainTextEditorFactory::displayName() const return tr(Core::Constants::K_DEFAULT_TEXT_EDITOR_DISPLAY_NAME); } -Core::IDocument *PlainTextEditorFactory::open(const QString &fileName) -{ - Core::IEditor *iface = Core::EditorManager::instance()->openEditor(fileName, id()); - return iface ? iface->document() : 0; -} - Core::IEditor *PlainTextEditorFactory::createEditor(QWidget *parent) { PlainTextEditorWidget *rc = new PlainTextEditorWidget(parent); diff --git a/src/plugins/texteditor/plaintexteditorfactory.h b/src/plugins/texteditor/plaintexteditorfactory.h index f70111b8f0f..e8b37698f34 100644 --- a/src/plugins/texteditor/plaintexteditorfactory.h +++ b/src/plugins/texteditor/plaintexteditorfactory.h @@ -54,8 +54,6 @@ public: //Core::IEditorFactory Core::Id id() const; QString displayName() const; - - Core::IDocument *open(const QString &fileName); Core::IEditor *createEditor(QWidget *parent); TextEditor::TextEditorActionHandler *actionHandler() const { return m_actionHandler; } diff --git a/src/plugins/vcsbase/basevcseditorfactory.cpp b/src/plugins/vcsbase/basevcseditorfactory.cpp index a74d1390f7e..753e01e9214 100644 --- a/src/plugins/vcsbase/basevcseditorfactory.cpp +++ b/src/plugins/vcsbase/basevcseditorfactory.cpp @@ -99,12 +99,6 @@ QString BaseVcsEditorFactory::displayName() const return d->m_displayName; } -Core::IDocument *BaseVcsEditorFactory::open(const QString &fileName) -{ - Core::IEditor *iface = Core::EditorManager::instance()->openEditor(fileName, id()); - return iface ? iface->document() : 0; -} - Core::IEditor *BaseVcsEditorFactory::createEditor(QWidget *parent) { VcsBaseEditorWidget *vcsEditor = createVcsBaseEditor(d->m_type, parent); diff --git a/src/plugins/vcsbase/basevcseditorfactory.h b/src/plugins/vcsbase/basevcseditorfactory.h index 10739978e54..05c659f9b3e 100644 --- a/src/plugins/vcsbase/basevcseditorfactory.h +++ b/src/plugins/vcsbase/basevcseditorfactory.h @@ -57,8 +57,6 @@ public: Core::Id id() const; QString displayName() const; - - Core::IDocument *open(const QString &fileName); Core::IEditor *createEditor(QWidget *parent); private: diff --git a/src/plugins/vcsbase/basevcssubmiteditorfactory.cpp b/src/plugins/vcsbase/basevcssubmiteditorfactory.cpp index 57d566f04ce..f96f10acc1c 100644 --- a/src/plugins/vcsbase/basevcssubmiteditorfactory.cpp +++ b/src/plugins/vcsbase/basevcssubmiteditorfactory.cpp @@ -91,11 +91,4 @@ QStringList BaseVcsSubmitEditorFactory::mimeTypes() const return d->m_mimeTypes; } -Core::IDocument *BaseVcsSubmitEditorFactory::open(const QString &fileName) -{ - if (Core::IEditor *iface = Core::EditorManager::instance()->openEditor(fileName, id())) - return iface->document(); - return 0; -} - } // namespace VcsBase diff --git a/src/plugins/vcsbase/basevcssubmiteditorfactory.h b/src/plugins/vcsbase/basevcssubmiteditorfactory.h index 3e3c3fe7eb6..eef09373214 100644 --- a/src/plugins/vcsbase/basevcssubmiteditorfactory.h +++ b/src/plugins/vcsbase/basevcssubmiteditorfactory.h @@ -62,7 +62,6 @@ public: Core::Id id() const; QString displayName() const; QStringList mimeTypes() const; - Core::IDocument *open(const QString &fileName); private: virtual VcsBaseSubmitEditor