diff --git a/src/plugins/android/androidmanifesteditorfactory.cpp b/src/plugins/android/androidmanifesteditorfactory.cpp index 965ca6af0d31929ca724b73405f08f935f4fc47b..2e11a8924e7e98f0c893cb9c291eb973b8f55402 100644 --- a/src/plugins/android/androidmanifesteditorfactory.cpp +++ b/src/plugins/android/androidmanifesteditorfactory.cpp @@ -44,21 +44,9 @@ AndroidManifestEditorFactory::AndroidManifestEditorFactory(QObject *parent) : Core::IEditorFactory(parent), m_actionHandler(new TextEditor::TextEditorActionHandler(Constants::ANDROID_MANIFEST_EDITOR_CONTEXT)) { -} - -QStringList AndroidManifestEditorFactory::mimeTypes() const -{ - return QStringList() << QLatin1String(Constants::ANDROID_MANIFEST_MIME_TYPE); -} - -Core::Id AndroidManifestEditorFactory::id() const -{ - return Constants::ANDROID_MANIFEST_EDITOR_ID; -} - -QString AndroidManifestEditorFactory::displayName() const -{ - return tr("Android Manifest editor"); + setId(Constants::ANDROID_MANIFEST_EDITOR_ID); + setDisplayName(tr("Android Manifest editor")); + addMimeType(Constants::ANDROID_MANIFEST_MIME_TYPE); } Core::IEditor *AndroidManifestEditorFactory::createEditor(QWidget *parent) diff --git a/src/plugins/android/androidmanifesteditorfactory.h b/src/plugins/android/androidmanifesteditorfactory.h index 1c1470c10895cac025e398473f22bf668db9e4da..3a1fa07844e633ef764230041112bfbb251184b7 100644 --- a/src/plugins/android/androidmanifesteditorfactory.h +++ b/src/plugins/android/androidmanifesteditorfactory.h @@ -40,14 +40,12 @@ namespace Internal { class AndroidManifestEditorFactory : public Core::IEditorFactory { Q_OBJECT + public: explicit AndroidManifestEditorFactory(QObject *parent = 0); - QStringList mimeTypes() const; - Core::Id id() const; - QString displayName() const; - Core::IEditor *createEditor(QWidget *parent); + private: TextEditor::TextEditorActionHandler *m_actionHandler; }; diff --git a/src/plugins/bineditor/bineditorplugin.cpp b/src/plugins/bineditor/bineditorplugin.cpp index dbd43cde0416858f7c5b5bf919db54564e030cc6..b9f9c87a641834aadaac7588ee010d8d7b88a71c 100644 --- a/src/plugins/bineditor/bineditorplugin.cpp +++ b/src/plugins/bineditor/bineditorplugin.cpp @@ -402,19 +402,11 @@ private: ///////////////////////////////// BinEditorFactory ////////////////////////////////// BinEditorFactory::BinEditorFactory(BinEditorPlugin *owner) : - m_mimeTypes(QLatin1String(Constants::C_BINEDITOR_MIMETYPE)), m_owner(owner) { -} - -Core::Id BinEditorFactory::id() const -{ - return Core::Id(Core::Constants::K_DEFAULT_BINARY_EDITOR_ID); -} - -QString BinEditorFactory::displayName() const -{ - return qApp->translate("OpenWith::Editors", Constants::C_BINEDITOR_DISPLAY_NAME); + setId(Core::Constants::K_DEFAULT_BINARY_EDITOR_ID); + setDisplayName(qApp->translate("OpenWith::Editors", Constants::C_BINEDITOR_DISPLAY_NAME)); + addMimeType(Constants::C_BINEDITOR_MIMETYPE); } Core::IEditor *BinEditorFactory::createEditor(QWidget *parent) @@ -426,10 +418,6 @@ Core::IEditor *BinEditorFactory::createEditor(QWidget *parent) return editor; } -QStringList BinEditorFactory::mimeTypes() const -{ - return m_mimeTypes; -} /*! \class BINEditor::BinEditorWidgetFactory diff --git a/src/plugins/bineditor/bineditorplugin.h b/src/plugins/bineditor/bineditorplugin.h index 0adf0f62b43c7d5230dd2656f1afa1cb9bcfde1a..46864d6bb0b70ae450e56a9cdbcf1da5d57d511b 100644 --- a/src/plugins/bineditor/bineditorplugin.h +++ b/src/plugins/bineditor/bineditorplugin.h @@ -102,13 +102,9 @@ class BinEditorFactory : public Core::IEditorFactory public: explicit BinEditorFactory(BinEditorPlugin *owner); - QStringList mimeTypes() const; Core::IEditor *createEditor(QWidget *parent); - Core::Id id() const; - QString displayName() const; private: - const QStringList m_mimeTypes; BinEditorPlugin *m_owner; }; diff --git a/src/plugins/cmakeprojectmanager/cmakeeditorfactory.cpp b/src/plugins/cmakeprojectmanager/cmakeeditorfactory.cpp index 8bebdfaade1b4fea308123d84e842024eadecb9b..ea14d89f9de425945ee76e4d5da684ebeb0a4e24 100644 --- a/src/plugins/cmakeprojectmanager/cmakeeditorfactory.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeeditorfactory.cpp @@ -43,12 +43,15 @@ using namespace CMakeProjectManager; using namespace CMakeProjectManager::Internal; CMakeEditorFactory::CMakeEditorFactory(CMakeManager *manager) - : m_mimeTypes(QStringList() << QLatin1String(CMakeProjectManager::Constants::CMAKEMIMETYPE)), - m_manager(manager) + : m_manager(manager) { using namespace Core; using namespace TextEditor; + setId(CMakeProjectManager::Constants::CMAKE_EDITOR_ID); + setDisplayName(tr(CMakeProjectManager::Constants::CMAKE_EDITOR_DISPLAY_NAME)); + addMimeType(CMakeProjectManager::Constants::CMAKEMIMETYPE); + m_actionHandler = new TextEditorActionHandler(Constants::C_CMAKEEDITOR, TextEditorActionHandler::UnCommentSelection @@ -67,24 +70,9 @@ CMakeEditorFactory::CMakeEditorFactory(CMakeManager *manager) contextMenu->addAction(cmd); } -Core::Id CMakeEditorFactory::id() const -{ - return Core::Id(CMakeProjectManager::Constants::CMAKE_EDITOR_ID); -} - -QString CMakeEditorFactory::displayName() const -{ - return tr(CMakeProjectManager::Constants::CMAKE_EDITOR_DISPLAY_NAME); -} - Core::IEditor *CMakeEditorFactory::createEditor(QWidget *parent) { CMakeEditorWidget *rc = new CMakeEditorWidget(parent, this, m_actionHandler); TextEditor::TextEditorSettings::instance()->initializeEditor(rc); return rc->editor(); } - -QStringList CMakeEditorFactory::mimeTypes() const -{ - return m_mimeTypes; -} diff --git a/src/plugins/cmakeprojectmanager/cmakeeditorfactory.h b/src/plugins/cmakeprojectmanager/cmakeeditorfactory.h index 279a99e10f4ae8ad4b4fad37f02bab3d0013dfc0..aafa5a4875f540c2d4e98076036362503fe2e267 100644 --- a/src/plugins/cmakeprojectmanager/cmakeeditorfactory.h +++ b/src/plugins/cmakeprojectmanager/cmakeeditorfactory.h @@ -34,11 +34,7 @@ #include <coreplugin/editormanager/ieditorfactory.h> -#include <QStringList> - -namespace TextEditor { -class TextEditorActionHandler; -} +namespace TextEditor { class TextEditorActionHandler; } namespace CMakeProjectManager { namespace Internal { @@ -49,11 +45,6 @@ class CMakeEditorFactory : public Core::IEditorFactory public: CMakeEditorFactory(CMakeManager *parent); - - // IEditorFactory - QStringList mimeTypes() const; - Core::Id id() const; - QString displayName() const; Core::IEditor *createEditor(QWidget *parent); private: diff --git a/src/plugins/coreplugin/idocumentfactory.h b/src/plugins/coreplugin/idocumentfactory.h index bf9bbb005563aba067f90b83492d0a5994142468..d9cbaa1311cb9908d2e2bfa749fa71508779d31a 100644 --- a/src/plugins/coreplugin/idocumentfactory.h +++ b/src/plugins/coreplugin/idocumentfactory.h @@ -30,18 +30,14 @@ #ifndef IDOCUMENTFACTORY_H #define IDOCUMENTFACTORY_H -#include "core_global.h" +#include "id.h" #include <QObject> - -QT_BEGIN_NAMESPACE -class QStringList; -QT_END_NAMESPACE +#include <QStringList> namespace Core { class IDocument; -class Id; class CORE_EXPORT IDocumentFactory : public QObject { @@ -50,10 +46,23 @@ class CORE_EXPORT IDocumentFactory : public QObject public: IDocumentFactory(QObject *parent = 0) : QObject(parent) {} - virtual QStringList mimeTypes() const = 0; - virtual Id id() const = 0; - virtual QString displayName() const = 0; virtual IDocument *open(const QString &fileName) = 0; + + Id id() const { return m_id; } + QStringList mimeTypes() const { return m_mimeTypes; } + QString displayName() const { return m_displayName; } + +protected: + void setId(Id id) { m_id = id; } + void setDisplayName(const QString &displayName) { m_displayName = displayName; } + void setMimeTypes(const QStringList &mimeTypes) { m_mimeTypes = mimeTypes; } + void addMimeType(const char *mimeType) { m_mimeTypes.append(QLatin1String(mimeType)); } + void addMimeType(const QString &mimeType) { m_mimeTypes.append(mimeType); } + +private: + Id m_id; + QStringList m_mimeTypes; + QString m_displayName; }; } // namespace Core diff --git a/src/plugins/cppeditor/cppeditorplugin.cpp b/src/plugins/cppeditor/cppeditorplugin.cpp index 3dd822b5f7bf4e621c3943759b6e9088b6c49133..8df51752aaf60822fcee8d1ee27be635ecee3702 100644 --- a/src/plugins/cppeditor/cppeditorplugin.cpp +++ b/src/plugins/cppeditor/cppeditorplugin.cpp @@ -68,10 +68,12 @@ enum { QUICKFIX_INTERVAL = 20 }; CppEditorFactory::CppEditorFactory(CppEditorPlugin *owner) : m_owner(owner) { - m_mimeTypes << QLatin1String(CppEditor::Constants::C_SOURCE_MIMETYPE) - << QLatin1String(CppEditor::Constants::C_HEADER_MIMETYPE) - << QLatin1String(CppEditor::Constants::CPP_SOURCE_MIMETYPE) - << QLatin1String(CppEditor::Constants::CPP_HEADER_MIMETYPE); + setId(CppEditor::Constants::CPPEDITOR_ID); + setDisplayName(qApp->translate("OpenWith::Editors", CppEditor::Constants::CPPEDITOR_DISPLAY_NAME)); + addMimeType(CppEditor::Constants::C_SOURCE_MIMETYPE); + addMimeType(CppEditor::Constants::C_HEADER_MIMETYPE); + addMimeType(CppEditor::Constants::CPP_SOURCE_MIMETYPE); + addMimeType(CppEditor::Constants::CPP_HEADER_MIMETYPE); if (!Utils::HostOsInfo::isMacHost() && !Utils::HostOsInfo::isWindowsHost()) { Core::FileIconProvider *iconProvider = Core::FileIconProvider::instance(); @@ -85,16 +87,6 @@ CppEditorFactory::CppEditorFactory(CppEditorPlugin *owner) : } } -Core::Id CppEditorFactory::id() const -{ - return Core::Id(CppEditor::Constants::CPPEDITOR_ID); -} - -QString CppEditorFactory::displayName() const -{ - return qApp->translate("OpenWith::Editors", CppEditor::Constants::CPPEDITOR_DISPLAY_NAME); -} - Core::IEditor *CppEditorFactory::createEditor(QWidget *parent) { CPPEditorWidget *editor = new CPPEditorWidget(parent); @@ -103,11 +95,6 @@ Core::IEditor *CppEditorFactory::createEditor(QWidget *parent) return editor->editor(); } -QStringList CppEditorFactory::mimeTypes() const -{ - return m_mimeTypes; -} - ///////////////////////////////// CppEditorPlugin ////////////////////////////////// CppEditorPlugin *CppEditorPlugin::m_instance = 0; diff --git a/src/plugins/cppeditor/cppeditorplugin.h b/src/plugins/cppeditor/cppeditorplugin.h index 356677038a919c4da9d537683ecaf99338e2e957..0fc9054fed30173add906fb7612dcf5303591f11 100644 --- a/src/plugins/cppeditor/cppeditorplugin.h +++ b/src/plugins/cppeditor/cppeditorplugin.h @@ -35,7 +35,6 @@ #include <extensionsystem/iplugin.h> #include <QtPlugin> -#include <QStringList> #include <QAction> namespace TextEditor { @@ -286,15 +285,10 @@ class CppEditorFactory : public Core::IEditorFactory public: CppEditorFactory(CppEditorPlugin *owner); - // IEditorFactory - QStringList mimeTypes() const; Core::IEditor *createEditor(QWidget *parent); - Core::Id id() const; - QString displayName() const; private: CppEditorPlugin *m_owner; - QStringList m_mimeTypes; }; } // namespace Internal diff --git a/src/plugins/designer/formeditorfactory.cpp b/src/plugins/designer/formeditorfactory.cpp index 6425eb33a1697b6d549b19e49c72a078c34f5d7b..9aa570f61b56ad8ec4637bfe0cb840dcb2c46622 100644 --- a/src/plugins/designer/formeditorfactory.cpp +++ b/src/plugins/designer/formeditorfactory.cpp @@ -48,24 +48,17 @@ namespace Designer { namespace Internal { FormEditorFactory::FormEditorFactory() - : Core::IEditorFactory(Core::ICore::instance()), - m_mimeTypes(QLatin1String(FORM_MIMETYPE)) + : Core::IEditorFactory(Core::ICore::instance()) { + setId(K_DESIGNER_XML_EDITOR_ID); + setDisplayName(qApp->translate("Designer", C_DESIGNER_XML_DISPLAY_NAME)); + addMimeType(FORM_MIMETYPE); + Core::FileIconProvider *iconProvider = Core::FileIconProvider::instance(); iconProvider->registerIconOverlayForSuffix(QIcon(QLatin1String(":/formeditor/images/qt_ui.png")), QLatin1String("ui")); } -Core::Id FormEditorFactory::id() const -{ - return Core::Id(K_DESIGNER_XML_EDITOR_ID); -} - -QString FormEditorFactory::displayName() const -{ - return qApp->translate("Designer", C_DESIGNER_XML_DISPLAY_NAME); -} - Core::IEditor *FormEditorFactory::createEditor(QWidget *parent) { const EditorData data = FormEditorW::instance()->createEditor(parent); @@ -78,11 +71,6 @@ Core::IEditor *FormEditorFactory::createEditor(QWidget *parent) return data.formWindowEditor; } -QStringList FormEditorFactory::mimeTypes() const -{ - return m_mimeTypes; -} - void FormEditorFactory::designerModeClicked() { Core::ModeManager::activateMode(Core::Constants::MODE_DESIGN); @@ -90,5 +78,3 @@ void FormEditorFactory::designerModeClicked() } // namespace Internal } // namespace Designer - - diff --git a/src/plugins/designer/formeditorfactory.h b/src/plugins/designer/formeditorfactory.h index d1183fbfc589439fec356be43d9bc02c85ce1505..a17446d18b6521ef828d94e37ef2dfab4f147df4 100644 --- a/src/plugins/designer/formeditorfactory.h +++ b/src/plugins/designer/formeditorfactory.h @@ -32,8 +32,6 @@ #include <coreplugin/editormanager/ieditorfactory.h> -#include <QStringList> - namespace Designer { namespace Internal { @@ -44,17 +42,10 @@ class FormEditorFactory : public Core::IEditorFactory public: FormEditorFactory(); - // IEditorFactory - QStringList mimeTypes() const; - Core::Id id() const; - QString displayName() const; Core::IEditor *createEditor(QWidget *parent); private slots: void designerModeClicked(); - -private: - const QStringList m_mimeTypes; }; } // namespace Internal diff --git a/src/plugins/diffeditor/diffeditorplugin.cpp b/src/plugins/diffeditor/diffeditorplugin.cpp index 191c6a88c168bf1639957f3aea54093b040201f3..6bbf6cfbefe8074efbcd860f24e4e93d744e9e9b 100644 --- a/src/plugins/diffeditor/diffeditorplugin.cpp +++ b/src/plugins/diffeditor/diffeditorplugin.cpp @@ -45,7 +45,6 @@ #include <coreplugin/editormanager/editormanager.h> namespace DiffEditor { - namespace Internal { DiffEditorPlugin::DiffEditorPlugin() diff --git a/src/plugins/genericprojectmanager/genericprojectfileseditor.cpp b/src/plugins/genericprojectmanager/genericprojectfileseditor.cpp index ef62b1e3b5023b68a0bf3827e3ffd578f8c84e81..739dd18bd2226f8d1d7a34d03c4567ed80b6e720 100644 --- a/src/plugins/genericprojectmanager/genericprojectfileseditor.cpp +++ b/src/plugins/genericprojectmanager/genericprojectfileseditor.cpp @@ -54,9 +54,11 @@ ProjectFilesFactory::ProjectFilesFactory(Manager *manager, TextEditorActionHandl : Core::IEditorFactory(manager), m_actionHandler(handler) { - m_mimeTypes.append(QLatin1String(Constants::FILES_MIMETYPE)); - m_mimeTypes.append(QLatin1String(Constants::INCLUDES_MIMETYPE)); - m_mimeTypes.append(QLatin1String(Constants::CONFIG_MIMETYPE)); + setId(Constants::FILES_EDITOR_ID); + setDisplayName(QCoreApplication::translate("OpenWith::Editors", ".files Editor")); + addMimeType(Constants::FILES_MIMETYPE); + addMimeType(Constants::INCLUDES_MIMETYPE); + addMimeType(Constants::CONFIG_MIMETYPE); } Core::IEditor *ProjectFilesFactory::createEditor(QWidget *parent) @@ -66,21 +68,6 @@ Core::IEditor *ProjectFilesFactory::createEditor(QWidget *parent) return ed->editor(); } -QStringList ProjectFilesFactory::mimeTypes() const -{ - return m_mimeTypes; -} - -Core::Id ProjectFilesFactory::id() const -{ - return Core::Id(Constants::FILES_EDITOR_ID); -} - -QString ProjectFilesFactory::displayName() const -{ - return QCoreApplication::translate("OpenWith::Editors", ".files Editor"); -} - //////////////////////////////////////////////////////////////////////////////////////// // // ProjectFilesEditable diff --git a/src/plugins/genericprojectmanager/genericprojectfileseditor.h b/src/plugins/genericprojectmanager/genericprojectfileseditor.h index e5fedd2b16a06f582d8c6bfa8deb32524b7b7a7c..75014f8060da25b2b73e83abead0ff854879eb1b 100644 --- a/src/plugins/genericprojectmanager/genericprojectfileseditor.h +++ b/src/plugins/genericprojectmanager/genericprojectfileseditor.h @@ -56,13 +56,8 @@ public: Core::IEditor *createEditor(QWidget *parent); - QStringList mimeTypes() const; - Core::Id id() const; - QString displayName() const; - private: TextEditor::TextEditorActionHandler *m_actionHandler; - QStringList m_mimeTypes; }; class ProjectFilesEditor : public TextEditor::BaseTextEditor diff --git a/src/plugins/glsleditor/glsleditorfactory.cpp b/src/plugins/glsleditor/glsleditorfactory.cpp index 09db817a9d558a01a0fcbd246c9c4d2a4ec879cf..5426911ebe6bdda77881ab87f5e3d5fd1271a594 100644 --- a/src/plugins/glsleditor/glsleditorfactory.cpp +++ b/src/plugins/glsleditor/glsleditorfactory.cpp @@ -37,14 +37,9 @@ #include <extensionsystem/pluginspec.h> #include <coreplugin/icore.h> -#include <coreplugin/editormanager/editormanager.h> #include <QCoreApplication> -#include <QFileInfo> -#include <QDebug> #include <QSettings> -#include <QMessageBox> -#include <QPushButton> using namespace GLSLEditor::Internal; using namespace GLSLEditor::Constants; @@ -52,23 +47,13 @@ using namespace GLSLEditor::Constants; GLSLEditorFactory::GLSLEditorFactory(QObject *parent) : Core::IEditorFactory(parent) { - m_mimeTypes - << QLatin1String(GLSLEditor::Constants::GLSL_MIMETYPE) - << QLatin1String(GLSLEditor::Constants::GLSL_MIMETYPE_VERT) - << QLatin1String(GLSLEditor::Constants::GLSL_MIMETYPE_FRAG) - << QLatin1String(GLSLEditor::Constants::GLSL_MIMETYPE_VERT_ES) - << QLatin1String(GLSLEditor::Constants::GLSL_MIMETYPE_FRAG_ES) - ; -} - -Core::Id GLSLEditorFactory::id() const -{ - return Core::Id(C_GLSLEDITOR_ID); -} - -QString GLSLEditorFactory::displayName() const -{ - return qApp->translate("OpenWith::Editors", C_GLSLEDITOR_DISPLAY_NAME); + setId(C_GLSLEDITOR_ID); + setDisplayName(qApp->translate("OpenWith::Editors", C_GLSLEDITOR_DISPLAY_NAME)); + addMimeType(GLSLEditor::Constants::GLSL_MIMETYPE); + addMimeType(GLSLEditor::Constants::GLSL_MIMETYPE_VERT); + addMimeType(GLSLEditor::Constants::GLSL_MIMETYPE_FRAG); + addMimeType(GLSLEditor::Constants::GLSL_MIMETYPE_VERT_ES); + addMimeType(GLSLEditor::Constants::GLSL_MIMETYPE_FRAG_ES); } Core::IEditor *GLSLEditorFactory::createEditor(QWidget *parent) @@ -78,11 +63,6 @@ Core::IEditor *GLSLEditorFactory::createEditor(QWidget *parent) return rc->editor(); } -QStringList GLSLEditorFactory::mimeTypes() const -{ - return m_mimeTypes; -} - void GLSLEditorFactory::updateEditorInfoBar(Core::IEditor *) { } diff --git a/src/plugins/glsleditor/glsleditorfactory.h b/src/plugins/glsleditor/glsleditorfactory.h index 34b68a3c9e610712d040dd04e859b3b5674b96a7..0932b3f556ee43be8a10db39be2c3c8c04ecd020 100644 --- a/src/plugins/glsleditor/glsleditorfactory.h +++ b/src/plugins/glsleditor/glsleditorfactory.h @@ -32,8 +32,6 @@ #include <coreplugin/editormanager/ieditorfactory.h> -#include <QStringList> - namespace GLSLEditor { namespace Internal { @@ -44,17 +42,10 @@ class GLSLEditorFactory : public Core::IEditorFactory public: GLSLEditorFactory(QObject *parent); - // IEditorFactory - QStringList mimeTypes() const; - Core::Id id() const; - QString displayName() const; Core::IEditor *createEditor(QWidget *parent); private slots: void updateEditorInfoBar(Core::IEditor *editor); - -private: - QStringList m_mimeTypes; }; } // namespace Internal diff --git a/src/plugins/imageviewer/imageviewerfactory.cpp b/src/plugins/imageviewer/imageviewerfactory.cpp index d925ea6cc944b4beb97a283d07ac452be33dc7f7..b77c468c1a6aed24e7c2f97bd2949d95656d64f7 100644 --- a/src/plugins/imageviewer/imageviewerfactory.cpp +++ b/src/plugins/imageviewer/imageviewerfactory.cpp @@ -43,7 +43,6 @@ namespace Internal { struct ImageViewerFactoryPrivate { - QStringList mimeTypes; QPointer<ImageViewerActionHandler> actionHandler; }; @@ -51,30 +50,33 @@ ImageViewerFactory::ImageViewerFactory(QObject *parent) : Core::IEditorFactory(parent), d(new ImageViewerFactoryPrivate) { + setId(Constants::IMAGEVIEWER_ID); + setDisplayName(qApp->translate("OpenWith::Editors", Constants::IMAGEVIEWER_DISPLAY_NAME)); + d->actionHandler = new ImageViewerActionHandler(this); - QMap<QByteArray, QString> possibleMimeTypes; - possibleMimeTypes.insert("bmp", QLatin1String("image/bmp")); - possibleMimeTypes.insert("gif", QLatin1String("image/gif")); - possibleMimeTypes.insert("ico", QLatin1String("image/x-icon")); - possibleMimeTypes.insert("jpeg", QLatin1String("image/jpeg")); - possibleMimeTypes.insert("jpg", QLatin1String("image/jpeg")); - possibleMimeTypes.insert("mng", QLatin1String("video/x-mng")); - possibleMimeTypes.insert("pbm", QLatin1String("image/x-portable-bitmap")); - possibleMimeTypes.insert("pgm", QLatin1String("image/x-portable-graymap")); - possibleMimeTypes.insert("png", QLatin1String("image/png")); - possibleMimeTypes.insert("ppm", QLatin1String("image/x-portable-pixmap")); - possibleMimeTypes.insert("svg", QLatin1String("image/svg+xml")); - possibleMimeTypes.insert("tif", QLatin1String("image/tiff")); - possibleMimeTypes.insert("tiff", QLatin1String("image/tiff")); - possibleMimeTypes.insert("xbm", QLatin1String("image/xbm")); - possibleMimeTypes.insert("xpm", QLatin1String("image/xpm")); + QMap<QByteArray, const char *> possibleMimeTypes; + possibleMimeTypes.insert("bmp", "image/bmp"); + possibleMimeTypes.insert("gif", "image/gif"); + possibleMimeTypes.insert("ico", "image/x-icon"); + possibleMimeTypes.insert("jpeg","image/jpeg"); + possibleMimeTypes.insert("jpg", "image/jpeg"); + possibleMimeTypes.insert("mng", "video/x-mng"); + possibleMimeTypes.insert("pbm", "image/x-portable-bitmap"); + possibleMimeTypes.insert("pgm", "image/x-portable-graymap"); + possibleMimeTypes.insert("png", "image/png"); + possibleMimeTypes.insert("ppm", "image/x-portable-pixmap"); + possibleMimeTypes.insert("svg", "image/svg+xml"); + possibleMimeTypes.insert("tif", "image/tiff"); + possibleMimeTypes.insert("tiff","image/tiff"); + possibleMimeTypes.insert("xbm", "image/xbm"); + possibleMimeTypes.insert("xpm", "image/xpm"); QList<QByteArray> supportedFormats = QImageReader::supportedImageFormats(); foreach (const QByteArray &format, supportedFormats) { - const QString &value = possibleMimeTypes.value(format); - if (!value.isEmpty()) - d->mimeTypes.append(value); + const char *value = possibleMimeTypes.value(format); + if (value) + addMimeType(value); } } @@ -88,21 +90,6 @@ Core::IEditor *ImageViewerFactory::createEditor(QWidget *parent) return new ImageViewer(parent); } -QStringList ImageViewerFactory::mimeTypes() const -{ - return d->mimeTypes; -} - -Core::Id ImageViewerFactory::id() const -{ - return Core::Id(Constants::IMAGEVIEWER_ID); -} - -QString ImageViewerFactory::displayName() const -{ - return qApp->translate("OpenWith::Editors", Constants::IMAGEVIEWER_DISPLAY_NAME); -} - void ImageViewerFactory::extensionsInitialized() { d->actionHandler->createActions(); diff --git a/src/plugins/imageviewer/imageviewerfactory.h b/src/plugins/imageviewer/imageviewerfactory.h index 77d372a265de4ff9605332ab733c013df4310078..a4200013ca5e2fd7134c930ae247460b4b0bd681 100644 --- a/src/plugins/imageviewer/imageviewerfactory.h +++ b/src/plugins/imageviewer/imageviewerfactory.h @@ -47,10 +47,6 @@ public: Core::IEditor *createEditor(QWidget *parent); - QStringList mimeTypes() const; - Core::Id id() const; - QString displayName() const; - void extensionsInitialized(); private: diff --git a/src/plugins/projectexplorer/pluginfilefactory.cpp b/src/plugins/projectexplorer/pluginfilefactory.cpp index 64353d644c4f37ff60a76a846de0442225b3224f..12721374433e0ccb3a1e65604e46f960c49268f4 100644 --- a/src/plugins/projectexplorer/pluginfilefactory.cpp +++ b/src/plugins/projectexplorer/pluginfilefactory.cpp @@ -49,24 +49,11 @@ using namespace ProjectExplorer::Internal; */ ProjectFileFactory::ProjectFileFactory(IProjectManager *manager) - : m_mimeTypes(manager->mimeType()), - m_manager(manager) + : m_manager(manager) { -} - -QStringList ProjectFileFactory::mimeTypes() const -{ - return m_mimeTypes; -} - -Core::Id ProjectFileFactory::id() const -{ - return Core::Id(Constants::FILE_FACTORY_ID); -} - -QString ProjectFileFactory::displayName() const -{ - return tr("Project File Factory", "ProjectExplorer::ProjectFileFactory display name."); + setId(Constants::FILE_FACTORY_ID); + setDisplayName(tr("Project File Factory", "ProjectExplorer::ProjectFileFactory display name.")); + addMimeType(manager->mimeType()); } Core::IDocument *ProjectFileFactory::open(const QString &fileName) diff --git a/src/plugins/projectexplorer/pluginfilefactory.h b/src/plugins/projectexplorer/pluginfilefactory.h index 68cb962b4c1ad6805c1067599fc59496f7540332..61dbbfb87e18ae9c7b58133db707f4b69f2170ee 100644 --- a/src/plugins/projectexplorer/pluginfilefactory.h +++ b/src/plugins/projectexplorer/pluginfilefactory.h @@ -48,16 +48,11 @@ class ProjectFileFactory : public Core::IDocumentFactory explicit ProjectFileFactory(ProjectExplorer::IProjectManager *manager); public: - virtual QStringList mimeTypes() const; - Core::Id id() const; - QString displayName() const; - Core::IDocument *open(const QString &fileName); static QList<ProjectFileFactory*> createFactories(QString *filterString); private: - const QStringList m_mimeTypes; ProjectExplorer::IProjectManager *m_manager; }; diff --git a/src/plugins/pythoneditor/pythoneditorfactory.cpp b/src/plugins/pythoneditor/pythoneditorfactory.cpp index 5dc783f6ae906692776280755117a7d124477e50..e0b36e189939174db2254ee817aecfe0fbff4c46 100644 --- a/src/plugins/pythoneditor/pythoneditorfactory.cpp +++ b/src/plugins/pythoneditor/pythoneditorfactory.cpp @@ -43,17 +43,9 @@ namespace PythonEditor { EditorFactory::EditorFactory(QObject *parent) : Core::IEditorFactory(parent) { - m_mimeTypes << QLatin1String(Constants::C_PY_MIMETYPE); -} - -Core::Id EditorFactory::id() const -{ - return Constants::C_PYTHONEDITOR_ID; -} - -QString EditorFactory::displayName() const -{ - return tr(Constants::C_EDITOR_DISPLAY_NAME); + setId(Constants::C_PYTHONEDITOR_ID); + setDisplayName(tr(Constants::C_EDITOR_DISPLAY_NAME)); + addMimeType(QLatin1String(Constants::C_PY_MIMETYPE)); } Core::IEditor *EditorFactory::createEditor(QWidget *parent) @@ -64,9 +56,4 @@ Core::IEditor *EditorFactory::createEditor(QWidget *parent) return widget->editor(); } -QStringList EditorFactory::mimeTypes() const -{ - return m_mimeTypes; -} - } // namespace PythonEditor diff --git a/src/plugins/pythoneditor/pythoneditorfactory.h b/src/plugins/pythoneditor/pythoneditorfactory.h index 5879e6fe391eb24d44eb42eddcbaca5e09d40dac..334002121271d1e11b58c9676b8fa213c94e1d86 100644 --- a/src/plugins/pythoneditor/pythoneditorfactory.h +++ b/src/plugins/pythoneditor/pythoneditorfactory.h @@ -32,7 +32,6 @@ #include "pythoneditor_global.h" #include <coreplugin/editormanager/ieditorfactory.h> -#include <QStringList> namespace PythonEditor { @@ -43,24 +42,10 @@ class PYEDITOR_EXPORT EditorFactory : public Core::IEditorFactory public: EditorFactory(QObject *parent); - /** - Returns MIME types handled by editor - */ - QStringList mimeTypes() const; - - /** - Unique editor class identifier, see Constants::C_PYEDITOR_ID - */ - Core::Id id() const; - QString displayName() const; - /** Creates and initializes new editor widget */ Core::IEditor *createEditor(QWidget *parent); - -private: - QStringList m_mimeTypes; }; } // namespace PythonEditor diff --git a/src/plugins/qmljseditor/qmljseditorfactory.cpp b/src/plugins/qmljseditor/qmljseditorfactory.cpp index 56f806617075b208a1b25aef5fd51cc84aa7739c..4a2efa605381beeeecd05082ac6e77860be40ce1 100644 --- a/src/plugins/qmljseditor/qmljseditorfactory.cpp +++ b/src/plugins/qmljseditor/qmljseditorfactory.cpp @@ -35,19 +35,7 @@ #include <qmljstools/qmljstoolsconstants.h> -#include <extensionsystem/pluginmanager.h> -#include <extensionsystem/pluginspec.h> - -#include <coreplugin/icore.h> -#include <coreplugin/infobar.h> -#include <coreplugin/editormanager/editormanager.h> - #include <QCoreApplication> -#include <QFileInfo> -#include <QDebug> -#include <QSettings> -#include <QMessageBox> -#include <QPushButton> namespace QmlJSEditor { namespace Internal { @@ -55,24 +43,15 @@ namespace Internal { QmlJSEditorFactory::QmlJSEditorFactory(QObject *parent) : Core::IEditorFactory(parent) { - m_mimeTypes - << QLatin1String(QmlJSTools::Constants::QML_MIMETYPE) - << QLatin1String(QmlJSTools::Constants::QMLPROJECT_MIMETYPE) - << QLatin1String(QmlJSTools::Constants::QBS_MIMETYPE) - << QLatin1String(QmlJSTools::Constants::QMLTYPES_MIMETYPE) - << QLatin1String(QmlJSTools::Constants::JS_MIMETYPE) - << QLatin1String(QmlJSTools::Constants::JSON_MIMETYPE) - ; -} - -Core::Id QmlJSEditorFactory::id() const -{ - return Core::Id(Constants::C_QMLJSEDITOR_ID); -} + setId(Constants::C_QMLJSEDITOR_ID); + setDisplayName(qApp->translate("OpenWith::Editors", Constants::C_QMLJSEDITOR_DISPLAY_NAME)); -QString QmlJSEditorFactory::displayName() const -{ - return qApp->translate("OpenWith::Editors", Constants::C_QMLJSEDITOR_DISPLAY_NAME); + addMimeType(QmlJSTools::Constants::QML_MIMETYPE); + addMimeType(QmlJSTools::Constants::QMLPROJECT_MIMETYPE); + addMimeType(QmlJSTools::Constants::QBS_MIMETYPE); + addMimeType(QmlJSTools::Constants::QMLTYPES_MIMETYPE); + addMimeType(QmlJSTools::Constants::JS_MIMETYPE); + addMimeType(QmlJSTools::Constants::JSON_MIMETYPE); } Core::IEditor *QmlJSEditorFactory::createEditor(QWidget *parent) @@ -82,10 +61,5 @@ Core::IEditor *QmlJSEditorFactory::createEditor(QWidget *parent) return rc->editor(); } -QStringList QmlJSEditorFactory::mimeTypes() const -{ - return m_mimeTypes; -} - } // namespace Internal } // namespace QmlJSEditor diff --git a/src/plugins/qmljseditor/qmljseditorfactory.h b/src/plugins/qmljseditor/qmljseditorfactory.h index ed91e33cd276b43f24263c938a5657969c048fa7..79d4b3cada4b56439b4181c2c6c7f3685592da54 100644 --- a/src/plugins/qmljseditor/qmljseditorfactory.h +++ b/src/plugins/qmljseditor/qmljseditorfactory.h @@ -32,8 +32,6 @@ #include <coreplugin/editormanager/ieditorfactory.h> -#include <QStringList> - namespace QmlJSEditor { namespace Internal { @@ -44,14 +42,7 @@ class QmlJSEditorFactory : public Core::IEditorFactory public: QmlJSEditorFactory(QObject *parent); - // IEditorFactory - QStringList mimeTypes() const; - Core::Id id() const; - QString displayName() const; Core::IEditor *createEditor(QWidget *parent); - -private: - QStringList m_mimeTypes; }; } // namespace Internal diff --git a/src/plugins/qnx/bardescriptoreditorfactory.cpp b/src/plugins/qnx/bardescriptoreditorfactory.cpp index ac300d3710cf2682a117bc49dec606aac8d18080..5a2806039d39b57295624bcb454d9b3859b74e36 100644 --- a/src/plugins/qnx/bardescriptoreditorfactory.cpp +++ b/src/plugins/qnx/bardescriptoreditorfactory.cpp @@ -42,23 +42,10 @@ using namespace Qnx::Internal; BarDescriptorEditorFactory::BarDescriptorEditorFactory(QObject *parent) : Core::IEditorFactory(parent) - , m_mimeTypes(QStringList() << QLatin1String(Constants::QNX_BAR_DESCRIPTOR_MIME_TYPE)) { -} - -QStringList BarDescriptorEditorFactory::mimeTypes() const -{ - return m_mimeTypes; -} - -Core::Id BarDescriptorEditorFactory::id() const -{ - return Constants::QNX_BAR_DESCRIPTOR_EDITOR_ID; -} - -QString BarDescriptorEditorFactory::displayName() const -{ - return tr("Bar descriptor editor"); + setId(Constants::QNX_BAR_DESCRIPTOR_EDITOR_ID); + setDisplayName(tr("Bar descriptor editor")); + addMimeType(Constants::QNX_BAR_DESCRIPTOR_MIME_TYPE); } Core::IEditor *BarDescriptorEditorFactory::createEditor(QWidget *parent) diff --git a/src/plugins/qnx/bardescriptoreditorfactory.h b/src/plugins/qnx/bardescriptoreditorfactory.h index 36bade0089bbbbb1b47d6a859135d010fd3ccd3b..9a7ddfa687a7cc943f181f988015c08754c77df7 100644 --- a/src/plugins/qnx/bardescriptoreditorfactory.h +++ b/src/plugins/qnx/bardescriptoreditorfactory.h @@ -34,25 +34,17 @@ #include <coreplugin/editormanager/ieditorfactory.h> -#include <QtCore/QStringList> - namespace Qnx { namespace Internal { class BarDescriptorEditorFactory : public Core::IEditorFactory { Q_OBJECT + public: explicit BarDescriptorEditorFactory(QObject *parent = 0); - QStringList mimeTypes() const; - Core::Id id() const; - QString displayName() const; - Core::IEditor *createEditor(QWidget *parent); - -private: - QStringList m_mimeTypes; }; } // namespace Internal diff --git a/src/plugins/qt4projectmanager/profileeditorfactory.cpp b/src/plugins/qt4projectmanager/profileeditorfactory.cpp index bb2c8323d1b571fc47c62439bc53ca2f66357cc9..a7d0ca61b09e9dace901ea3b0cbb454a8cd30c56 100644 --- a/src/plugins/qt4projectmanager/profileeditorfactory.cpp +++ b/src/plugins/qt4projectmanager/profileeditorfactory.cpp @@ -43,12 +43,15 @@ using namespace Qt4ProjectManager; using namespace Qt4ProjectManager::Internal; ProFileEditorFactory::ProFileEditorFactory(Qt4Manager *manager, TextEditor::TextEditorActionHandler *handler) : - m_mimeTypes(QStringList() << QLatin1String(Qt4ProjectManager::Constants::PROFILE_MIMETYPE) - << QLatin1String(Qt4ProjectManager::Constants::PROINCLUDEFILE_MIMETYPE) - << QLatin1String(Qt4ProjectManager::Constants::PROFEATUREFILE_MIMETYPE)), m_manager(manager), m_actionHandler(handler) { + setId(Qt4ProjectManager::Constants::PROFILE_EDITOR_ID); + setDisplayName(qApp->translate("OpenWith::Editors", Qt4ProjectManager::Constants::PROFILE_EDITOR_DISPLAY_NAME)); + addMimeType(Qt4ProjectManager::Constants::PROFILE_MIMETYPE); + addMimeType(Qt4ProjectManager::Constants::PROINCLUDEFILE_MIMETYPE); + addMimeType(Qt4ProjectManager::Constants::PROFEATUREFILE_MIMETYPE); + Core::FileIconProvider *iconProvider = Core::FileIconProvider::instance(); iconProvider->registerIconOverlayForSuffix(QIcon(QLatin1String(QtSupport::Constants::ICON_QT_PROJECT)), QLatin1String("pro")); @@ -58,28 +61,9 @@ ProFileEditorFactory::ProFileEditorFactory(Qt4Manager *manager, TextEditor::Text QLatin1String("prf")); } -ProFileEditorFactory::~ProFileEditorFactory() -{ -} - -Core::Id ProFileEditorFactory::id() const -{ - return Core::Id(Qt4ProjectManager::Constants::PROFILE_EDITOR_ID); -} - -QString ProFileEditorFactory::displayName() const -{ - return qApp->translate("OpenWith::Editors", Qt4ProjectManager::Constants::PROFILE_EDITOR_DISPLAY_NAME); -} - Core::IEditor *ProFileEditorFactory::createEditor(QWidget *parent) { ProFileEditorWidget *editor = new ProFileEditorWidget(parent, this, m_actionHandler); TextEditor::TextEditorSettings::instance()->initializeEditor(editor); return editor->editor(); } - -QStringList ProFileEditorFactory::mimeTypes() const -{ - return m_mimeTypes; -} diff --git a/src/plugins/qt4projectmanager/profileeditorfactory.h b/src/plugins/qt4projectmanager/profileeditorfactory.h index 2ad656320dd2ac036ee5196d57e0f25aad5220e3..41c5e8c477f4b86cd8e79bc97595f2efdd08d5d4 100644 --- a/src/plugins/qt4projectmanager/profileeditorfactory.h +++ b/src/plugins/qt4projectmanager/profileeditorfactory.h @@ -32,11 +32,7 @@ #include <coreplugin/editormanager/ieditorfactory.h> -#include <QStringList> - -namespace TextEditor { -class TextEditorActionHandler; -} +namespace TextEditor { class TextEditorActionHandler; } namespace Qt4ProjectManager { @@ -50,18 +46,12 @@ class ProFileEditorFactory : public Core::IEditorFactory public: ProFileEditorFactory(Qt4Manager *parent, TextEditor::TextEditorActionHandler *handler); - ~ProFileEditorFactory(); - // IEditorFactory - QStringList mimeTypes() const; - Core::Id id() const; - QString displayName() const; Core::IEditor *createEditor(QWidget *parent); Qt4Manager *qt4ProjectManager() const { return m_manager; } private: - const QStringList m_mimeTypes; Qt4Manager *m_manager; TextEditor::TextEditorActionHandler *m_actionHandler; }; diff --git a/src/plugins/resourceeditor/resourceeditorfactory.cpp b/src/plugins/resourceeditor/resourceeditorfactory.cpp index 7adc6de66ceb6724679936a3a51f4184463cef23..120c342800cddd9743d803483dc6603961894480 100644 --- a/src/plugins/resourceeditor/resourceeditorfactory.cpp +++ b/src/plugins/resourceeditor/resourceeditorfactory.cpp @@ -44,31 +44,19 @@ using namespace ResourceEditor::Constants; ResourceEditorFactory::ResourceEditorFactory(ResourceEditorPlugin *plugin) : Core::IEditorFactory(plugin), - m_mimeTypes(QStringList(QLatin1String(C_RESOURCE_MIMETYPE))), m_plugin(plugin) { + setId(RESOURCEEDITOR_ID); + setMimeTypes(QStringList(QLatin1String(C_RESOURCE_MIMETYPE))); + setDisplayName(qApp->translate("OpenWith::Editors", C_RESOURCEEDITOR_DISPLAY_NAME)); + Core::FileIconProvider *iconProvider = Core::FileIconProvider::instance(); iconProvider->registerIconOverlayForSuffix(QIcon(QLatin1String(":/resourceeditor/images/qt_qrc.png")), QLatin1String("qrc")); } -Core::Id ResourceEditorFactory::id() const -{ - return Core::Id(RESOURCEEDITOR_ID); -} - -QString ResourceEditorFactory::displayName() const -{ - return qApp->translate("OpenWith::Editors", C_RESOURCEEDITOR_DISPLAY_NAME); -} - Core::IEditor *ResourceEditorFactory::createEditor(QWidget *parent) { Core::Context context(ResourceEditor::Constants::C_RESOURCEEDITOR); return new ResourceEditorW(context, m_plugin, parent); } - -QStringList ResourceEditorFactory::mimeTypes() const -{ - return m_mimeTypes; -} diff --git a/src/plugins/resourceeditor/resourceeditorfactory.h b/src/plugins/resourceeditor/resourceeditorfactory.h index e1f84e437a18c1a7ce2e5882019058ba149fe3d5..f0878be78f004c53e70d008adab479d8239c26c2 100644 --- a/src/plugins/resourceeditor/resourceeditorfactory.h +++ b/src/plugins/resourceeditor/resourceeditorfactory.h @@ -47,15 +47,9 @@ class ResourceEditorFactory : public Core::IEditorFactory public: explicit ResourceEditorFactory(ResourceEditorPlugin *plugin); - virtual QStringList mimeTypes() const; - - // IEditorFactory - Core::Id id() const; - QString displayName() const; Core::IEditor *createEditor(QWidget *parent); private: - const QStringList m_mimeTypes; ResourceEditorPlugin *m_plugin; }; diff --git a/src/plugins/tasklist/taskfilefactory.cpp b/src/plugins/tasklist/taskfilefactory.cpp index 7fc761f0401d587ddb15037441cf825af92dca0f..19c67ada1e65b2ab9963c3e7c34874ee45e13ed4 100644 --- a/src/plugins/tasklist/taskfilefactory.cpp +++ b/src/plugins/tasklist/taskfilefactory.cpp @@ -33,7 +33,6 @@ #include <projectexplorer/projectexplorer.h> #include <coreplugin/icore.h> -#include <coreplugin/id.h> #include <coreplugin/documentmanager.h> #include <QMessageBox> @@ -45,26 +44,11 @@ using namespace TaskList::Internal; // -------------------------------------------------------------------------- TaskFileFactory::TaskFileFactory(QObject * parent) : - Core::IDocumentFactory(parent), - m_mimeTypes(QStringList() << QLatin1String("text/x-tasklist")) -{ } - -TaskFileFactory::~TaskFileFactory() -{ } - -QStringList TaskFileFactory::mimeTypes() const -{ - return m_mimeTypes; -} - -Core::Id TaskFileFactory::id() const -{ - return Core::Id("ProjectExplorer.TaskFileFactory"); -} - -QString TaskFileFactory::displayName() const + Core::IDocumentFactory(parent) { - return tr("Task file reader"); + setId("ProjectExplorer.TaskFileFactory"); + setDisplayName(tr("Task file reader")); + addMimeType(QLatin1String("text/x-tasklist")); } Core::IDocument *TaskFileFactory::open(const QString &fileName) diff --git a/src/plugins/tasklist/taskfilefactory.h b/src/plugins/tasklist/taskfilefactory.h index 3a28ecb986ca6b3bc3ece6e99875a37c9cd7cc37..9dc7bbec1593215caef956bdade836f009c3b868 100644 --- a/src/plugins/tasklist/taskfilefactory.h +++ b/src/plugins/tasklist/taskfilefactory.h @@ -33,11 +33,7 @@ #include <coreplugin/idocumentfactory.h> #include <coreplugin/idocument.h> -#include <QStringList> - -namespace ProjectExplorer { -class Project; -} // namespace ProjectExplorer +namespace ProjectExplorer { class Project; } namespace TaskList { namespace Internal { @@ -45,14 +41,9 @@ namespace Internal { class TaskFileFactory : public Core::IDocumentFactory { Q_OBJECT + public: TaskFileFactory(QObject *parent = 0); - ~TaskFileFactory(); - - QStringList mimeTypes() const; - - Core::Id id() const; - QString displayName() const; Core::IDocument *open(const QString &fileName); Core::IDocument *open(ProjectExplorer::Project *context, const QString &fileName); @@ -60,7 +51,6 @@ public: void closeAllFiles(); private: - QStringList m_mimeTypes; QList<Core::IDocument *> m_openFiles; }; diff --git a/src/plugins/texteditor/plaintexteditorfactory.cpp b/src/plugins/texteditor/plaintexteditorfactory.cpp index d58827e3670fcea89a768efc86363b7da199016a..c31d411e5825bed52df028671d9a9994498a0ef7 100644 --- a/src/plugins/texteditor/plaintexteditorfactory.cpp +++ b/src/plugins/texteditor/plaintexteditorfactory.cpp @@ -46,12 +46,15 @@ using namespace TextEditor::Internal; PlainTextEditorFactory::PlainTextEditorFactory(QObject *parent) : Core::IEditorFactory(parent) { + setId(Core::Constants::K_DEFAULT_TEXT_EDITOR_ID); + setDisplayName(qApp->translate("OpenWith::Editors", Core::Constants::K_DEFAULT_TEXT_EDITOR_DISPLAY_NAME)); + addMimeType(QLatin1String(TextEditor::Constants::C_TEXTEDITOR_MIMETYPE_TEXT)); + m_actionHandler = new TextEditorActionHandler( TextEditor::Constants::C_TEXTEDITOR, TextEditorActionHandler::Format | TextEditorActionHandler::UnCommentSelection | TextEditorActionHandler::UnCollapseAll); - m_mimeTypes << QLatin1String(TextEditor::Constants::C_TEXTEDITOR_MIMETYPE_TEXT); } PlainTextEditorFactory::~PlainTextEditorFactory() @@ -59,16 +62,6 @@ PlainTextEditorFactory::~PlainTextEditorFactory() delete m_actionHandler; } -Core::Id PlainTextEditorFactory::id() const -{ - return Core::Id(Core::Constants::K_DEFAULT_TEXT_EDITOR_ID); -} - -QString PlainTextEditorFactory::displayName() const -{ - return qApp->translate("OpenWith::Editors", Core::Constants::K_DEFAULT_TEXT_EDITOR_DISPLAY_NAME); -} - Core::IEditor *PlainTextEditorFactory::createEditor(QWidget *parent) { PlainTextEditorWidget *rc = new PlainTextEditorWidget(parent); @@ -106,13 +99,3 @@ void PlainTextEditorFactory::updateEditorInfoBar(Core::IEditor *editor) } } } - -void PlainTextEditorFactory::addMimeType(const QString &type) -{ - m_mimeTypes.append(type); -} - -QStringList PlainTextEditorFactory::mimeTypes() const -{ - return m_mimeTypes; -} diff --git a/src/plugins/texteditor/plaintexteditorfactory.h b/src/plugins/texteditor/plaintexteditorfactory.h index 712c6701ff7c0350d1907887c5eb0e88f19918ce..facf43fa9b7c9ed3bbfb6005f2f5a64fc3a5e336 100644 --- a/src/plugins/texteditor/plaintexteditorfactory.h +++ b/src/plugins/texteditor/plaintexteditorfactory.h @@ -44,22 +44,16 @@ class PlainTextEditorFactory : public Core::IEditorFactory public: PlainTextEditorFactory(QObject *parent = 0); - virtual ~PlainTextEditorFactory(); + ~PlainTextEditorFactory(); - void addMimeType(const QString &type); - virtual QStringList mimeTypes() const; - //Core::IEditorFactory - Core::Id id() const; - QString displayName() const; + using Core::IEditorFactory::addMimeType; Core::IEditor *createEditor(QWidget *parent); - TextEditor::TextEditorActionHandler *actionHandler() const { return m_actionHandler; } private slots: void updateEditorInfoBar(Core::IEditor *editor); private: - QStringList m_mimeTypes; TextEditor::TextEditorActionHandler *m_actionHandler; }; diff --git a/src/plugins/vcsbase/basevcseditorfactory.cpp b/src/plugins/vcsbase/basevcseditorfactory.cpp index 0d2780bf45d7da8ab9f86722ea4ff3e6f4e626b7..924fa3c1d4e1a873d7c8bef9baaf97515c9aab27 100644 --- a/src/plugins/vcsbase/basevcseditorfactory.cpp +++ b/src/plugins/vcsbase/basevcseditorfactory.cpp @@ -54,16 +54,11 @@ public: BaseVcsEditorFactoryPrivate(const VcsBaseEditorParameters *t); const VcsBaseEditorParameters *m_type; - const Core::Id m_id; - QString m_displayName; - const QStringList m_mimeTypes; TextEditor::TextEditorActionHandler *m_editorHandler; }; BaseVcsEditorFactoryPrivate::BaseVcsEditorFactoryPrivate(const VcsBaseEditorParameters *t) : m_type(t), - m_id(t->id), - m_mimeTypes(QStringList(QLatin1String(t->mimeType))), m_editorHandler(new TextEditor::TextEditorActionHandler(t->context)) { } @@ -73,7 +68,9 @@ BaseVcsEditorFactoryPrivate::BaseVcsEditorFactoryPrivate(const VcsBaseEditorPara BaseVcsEditorFactory::BaseVcsEditorFactory(const VcsBaseEditorParameters *t) : d(new Internal::BaseVcsEditorFactoryPrivate(t)) { - d->m_displayName = QCoreApplication::translate("VCS", t->displayName); + setId(t->id); + setDisplayName(QCoreApplication::translate("VCS", t->displayName)); + addMimeType(t->mimeType); } BaseVcsEditorFactory::~BaseVcsEditorFactory() @@ -81,26 +78,11 @@ BaseVcsEditorFactory::~BaseVcsEditorFactory() delete d; } -QStringList BaseVcsEditorFactory::mimeTypes() const -{ - return d->m_mimeTypes; -} - -Core::Id BaseVcsEditorFactory::id() const -{ - return d->m_id; -} - -QString BaseVcsEditorFactory::displayName() const -{ - return d->m_displayName; -} - Core::IEditor *BaseVcsEditorFactory::createEditor(QWidget *parent) { VcsBaseEditorWidget *vcsEditor = createVcsBaseEditor(d->m_type, parent); - vcsEditor ->setMimeType(d->m_mimeTypes.front()); + vcsEditor->setMimeType(mimeTypes().front()); d->m_editorHandler->setupActions(vcsEditor); // Wire font settings and set initial values diff --git a/src/plugins/vcsbase/basevcseditorfactory.h b/src/plugins/vcsbase/basevcseditorfactory.h index 1f0d4402009013fc043c66d7b16fd07bd41957d1..727ac353cae4d18a8380ca51b8ac04e8572981bf 100644 --- a/src/plugins/vcsbase/basevcseditorfactory.h +++ b/src/plugins/vcsbase/basevcseditorfactory.h @@ -35,8 +35,6 @@ #include <coreplugin/editormanager/ieditorfactory.h> -QT_FORWARD_DECLARE_CLASS(QStringList) - namespace VcsBase { namespace Internal { class BaseVcsEditorFactoryPrivate; @@ -45,15 +43,11 @@ class BaseVcsEditorFactoryPrivate; class VCSBASE_EXPORT BaseVcsEditorFactory : public Core::IEditorFactory { Q_OBJECT + public: explicit BaseVcsEditorFactory(const VcsBaseEditorParameters *type); ~BaseVcsEditorFactory(); - QStringList mimeTypes() const; - // IEditorFactory - - Core::Id id() const; - QString displayName() const; Core::IEditor *createEditor(QWidget *parent); private: diff --git a/src/plugins/vcsbase/basevcssubmiteditorfactory.cpp b/src/plugins/vcsbase/basevcssubmiteditorfactory.cpp index d17ba6a582bd52abaebfaa74ba39f3e282bee8e6..8ceed8177e1b502d948cee7d8cb21e0127604f5a 100644 --- a/src/plugins/vcsbase/basevcssubmiteditorfactory.cpp +++ b/src/plugins/vcsbase/basevcssubmiteditorfactory.cpp @@ -32,58 +32,21 @@ namespace VcsBase { -namespace Internal { - -class BaseVcsSubmitEditorFactoryPrivate -{ -public: - BaseVcsSubmitEditorFactoryPrivate(const VcsBaseSubmitEditorParameters *parameters); - - const VcsBaseSubmitEditorParameters *m_parameters; - const Core::Id m_id; - const QString m_displayName; - const QStringList m_mimeTypes; -}; - -BaseVcsSubmitEditorFactoryPrivate::BaseVcsSubmitEditorFactoryPrivate(const VcsBaseSubmitEditorParameters *parameters) : - m_parameters(parameters), - m_id(parameters->id), - m_displayName(QLatin1String(parameters->displayName)), - m_mimeTypes(QLatin1String(parameters->mimeType)) -{ -} - -} // namespace Internal - -BaseVcsSubmitEditorFactory::BaseVcsSubmitEditorFactory(const VcsBaseSubmitEditorParameters *parameters) : - d(new Internal::BaseVcsSubmitEditorFactoryPrivate(parameters)) +BaseVcsSubmitEditorFactory::BaseVcsSubmitEditorFactory(const VcsBaseSubmitEditorParameters *parameters) + : m_parameters(parameters) { + setId(parameters->id); + setDisplayName(QLatin1String(parameters->displayName)); + addMimeType(parameters->mimeType); } BaseVcsSubmitEditorFactory::~BaseVcsSubmitEditorFactory() { - delete d; } Core::IEditor *BaseVcsSubmitEditorFactory::createEditor(QWidget *parent) { - return createBaseSubmitEditor(d->m_parameters, parent); -} - -Core::Id BaseVcsSubmitEditorFactory::id() const -{ - return d->m_id; -} - -QString BaseVcsSubmitEditorFactory::displayName() const -{ - return d->m_displayName; -} - - -QStringList BaseVcsSubmitEditorFactory::mimeTypes() const -{ - return d->m_mimeTypes; + return createBaseSubmitEditor(m_parameters, parent); } } // namespace VcsBase diff --git a/src/plugins/vcsbase/basevcssubmiteditorfactory.h b/src/plugins/vcsbase/basevcssubmiteditorfactory.h index 7943df52e08c2d240a1cadc1742ddf75e8fa6e66..95280ca34b9c929585ac14a527f215f766a6b540 100644 --- a/src/plugins/vcsbase/basevcssubmiteditorfactory.h +++ b/src/plugins/vcsbase/basevcssubmiteditorfactory.h @@ -39,10 +39,6 @@ namespace VcsBase { class VcsBaseSubmitEditor; class VcsBaseSubmitEditorParameters; -namespace Internal { -class BaseVcsSubmitEditorFactoryPrivate; -} // namespace Internal - // Parametrizable base class for editor factories creating instances of // VcsBaseSubmitEditor subclasses. class VCSBASE_EXPORT BaseVcsSubmitEditorFactory : public Core::IEditorFactory @@ -51,21 +47,17 @@ class VCSBASE_EXPORT BaseVcsSubmitEditorFactory : public Core::IEditorFactory protected: explicit BaseVcsSubmitEditorFactory(const VcsBaseSubmitEditorParameters *parameters); - -public: ~BaseVcsSubmitEditorFactory(); +public: Core::IEditor *createEditor(QWidget *parent); - Core::Id id() const; - QString displayName() const; - QStringList mimeTypes() const; private: virtual VcsBaseSubmitEditor *createBaseSubmitEditor(const VcsBaseSubmitEditorParameters *parameters, QWidget *parent) = 0; - Internal::BaseVcsSubmitEditorFactoryPrivate *const d; + const VcsBaseSubmitEditorParameters *const m_parameters; // Not owned. }; // Utility template to create an editor that has a constructor taking the