diff options
author | Eike Ziller <eike.ziller@digia.com> | 2013-12-10 17:13:21 +0100 |
---|---|---|
committer | Eike Ziller <eike.ziller@digia.com> | 2013-12-12 09:59:55 +0100 |
commit | d80fb696aba1594afa76d0573d79e9aa9da09005 (patch) | |
tree | cd5b442a8668596052596dc44e5f7e59952e2e03 | |
parent | 3d1b70c58e0d2eea47572ec4a018a18674508f9b (diff) | |
download | qt-creator-d80fb696aba1594afa76d0573d79e9aa9da09005.tar.gz |
Give TextEditorActionHandler an explicit parent and unify usage.
The action handler implicitly passed ownership to ICore, which is non-
to the action handler. We now consistently create the action handler in
the editor factory, give ownership to the editor factory, and don't hold
a reference to it.
Change-Id: I4372f8de966e3ceff87c06c5528c6b54522c1d57
Reviewed-by: David Schulz <david.schulz@digia.com>
27 files changed, 48 insertions, 106 deletions
diff --git a/src/plugins/android/androidmanifesteditorfactory.cpp b/src/plugins/android/androidmanifesteditorfactory.cpp index 58cdbaaa96..ac2e1f5e5a 100644 --- a/src/plugins/android/androidmanifesteditorfactory.cpp +++ b/src/plugins/android/androidmanifesteditorfactory.cpp @@ -41,12 +41,12 @@ using namespace Android::Internal; AndroidManifestEditorFactory::AndroidManifestEditorFactory(QObject *parent) - : Core::IEditorFactory(parent), - m_actionHandler(new TextEditor::TextEditorActionHandler(Constants::ANDROID_MANIFEST_EDITOR_CONTEXT)) + : Core::IEditorFactory(parent) { setId(Constants::ANDROID_MANIFEST_EDITOR_ID); setDisplayName(tr("Android Manifest editor")); addMimeType(Constants::ANDROID_MANIFEST_MIME_TYPE); + new TextEditor::TextEditorActionHandler(this, Constants::ANDROID_MANIFEST_EDITOR_CONTEXT); } Core::IEditor *AndroidManifestEditorFactory::createEditor(QWidget *parent) diff --git a/src/plugins/android/androidmanifesteditorfactory.h b/src/plugins/android/androidmanifesteditorfactory.h index 3a1fa07844..afcb8abe24 100644 --- a/src/plugins/android/androidmanifesteditorfactory.h +++ b/src/plugins/android/androidmanifesteditorfactory.h @@ -32,8 +32,6 @@ #include <coreplugin/editormanager/ieditorfactory.h> -namespace TextEditor { class TextEditorActionHandler; } - namespace Android { namespace Internal { @@ -45,9 +43,6 @@ public: explicit AndroidManifestEditorFactory(QObject *parent = 0); Core::IEditor *createEditor(QWidget *parent); - -private: - TextEditor::TextEditorActionHandler *m_actionHandler; }; } // namespace Internal diff --git a/src/plugins/cmakeprojectmanager/cmakeeditorfactory.cpp b/src/plugins/cmakeprojectmanager/cmakeeditorfactory.cpp index 629518f08a..fd16bf2d7d 100644 --- a/src/plugins/cmakeprojectmanager/cmakeeditorfactory.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeeditorfactory.cpp @@ -52,8 +52,7 @@ CMakeEditorFactory::CMakeEditorFactory(CMakeManager *manager) setDisplayName(tr(CMakeProjectManager::Constants::CMAKE_EDITOR_DISPLAY_NAME)); addMimeType(CMakeProjectManager::Constants::CMAKEMIMETYPE); - m_actionHandler = - new TextEditorActionHandler(Constants::C_CMAKEEDITOR, + new TextEditorActionHandler(this, Constants::C_CMAKEEDITOR, TextEditorActionHandler::UnCommentSelection | TextEditorActionHandler::JumpToFileUnderCursor); diff --git a/src/plugins/cmakeprojectmanager/cmakeeditorfactory.h b/src/plugins/cmakeprojectmanager/cmakeeditorfactory.h index aafa5a4875..7356b445fe 100644 --- a/src/plugins/cmakeprojectmanager/cmakeeditorfactory.h +++ b/src/plugins/cmakeprojectmanager/cmakeeditorfactory.h @@ -34,8 +34,6 @@ #include <coreplugin/editormanager/ieditorfactory.h> -namespace TextEditor { class TextEditorActionHandler; } - namespace CMakeProjectManager { namespace Internal { @@ -50,7 +48,6 @@ public: private: const QStringList m_mimeTypes; CMakeManager *m_manager; - TextEditor::TextEditorActionHandler *m_actionHandler; }; } // namespace Internal diff --git a/src/plugins/cppeditor/cppeditorplugin.cpp b/src/plugins/cppeditor/cppeditorplugin.cpp index 6ed4ed215a..e4eadfb98e 100644 --- a/src/plugins/cppeditor/cppeditorplugin.cpp +++ b/src/plugins/cppeditor/cppeditorplugin.cpp @@ -80,6 +80,12 @@ CppEditorFactory::CppEditorFactory(CppEditorPlugin *owner) : addMimeType(CppEditor::Constants::CPP_SOURCE_MIMETYPE); addMimeType(CppEditor::Constants::CPP_HEADER_MIMETYPE); + new TextEditor::TextEditorActionHandler(this, CppEditor::Constants::C_CPPEDITOR, + TextEditor::TextEditorActionHandler::Format + | TextEditor::TextEditorActionHandler::UnCommentSelection + | TextEditor::TextEditorActionHandler::UnCollapseAll + | TextEditor::TextEditorActionHandler::FollowSymbolUnderCursor); + if (!Utils::HostOsInfo::isMacHost() && !Utils::HostOsInfo::isWindowsHost()) { FileIconProvider::registerIconOverlayForMimeType(":/cppeditor/images/qt_cpp.png", CppEditor::Constants::CPP_SOURCE_MIMETYPE); FileIconProvider::registerIconOverlayForMimeType(":/cppeditor/images/qt_c.png", CppEditor::Constants::C_SOURCE_MIMETYPE); @@ -100,7 +106,6 @@ IEditor *CppEditorFactory::createEditor(QWidget *parent) CppEditorPlugin *CppEditorPlugin::m_instance = 0; CppEditorPlugin::CppEditorPlugin() : - m_actionHandler(0), m_sortedOutline(false), m_renameSymbolUnderCursorAction(0), m_findUsagesAction(0), @@ -114,7 +119,6 @@ CppEditorPlugin::CppEditorPlugin() : CppEditorPlugin::~CppEditorPlugin() { - delete m_actionHandler; m_instance = 0; } @@ -290,12 +294,6 @@ bool CppEditorPlugin::initialize(const QStringList & /*arguments*/, QString *err cmd->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+Shift+F12") : tr("Ctrl+Shift+F12"))); connect(inspectCppCodeModel, SIGNAL(triggered()), this, SLOT(inspectCppCodeModel())); - m_actionHandler = new TextEditor::TextEditorActionHandler(CppEditor::Constants::C_CPPEDITOR, - TextEditor::TextEditorActionHandler::Format - | TextEditor::TextEditorActionHandler::UnCommentSelection - | TextEditor::TextEditorActionHandler::UnCollapseAll - | TextEditor::TextEditorActionHandler::FollowSymbolUnderCursor); - contextMenu->addSeparator(context); cmd = ActionManager::command(TextEditor::Constants::AUTO_INDENT_SELECTION); diff --git a/src/plugins/cppeditor/cppeditorplugin.h b/src/plugins/cppeditor/cppeditorplugin.h index f321274cd0..9bf3e13d10 100644 --- a/src/plugins/cppeditor/cppeditorplugin.h +++ b/src/plugins/cppeditor/cppeditorplugin.h @@ -38,7 +38,6 @@ #include <QAction> namespace TextEditor { -class TextEditorActionHandler; class ITextEditor; } // namespace TextEditor @@ -234,7 +233,6 @@ private: static CppEditorPlugin *m_instance; - TextEditor::TextEditorActionHandler *m_actionHandler; bool m_sortedOutline; QAction *m_renameSymbolUnderCursorAction; QAction *m_findUsagesAction; diff --git a/src/plugins/genericprojectmanager/genericprojectfileseditor.cpp b/src/plugins/genericprojectmanager/genericprojectfileseditor.cpp index 61470effc4..531cd516a5 100644 --- a/src/plugins/genericprojectmanager/genericprojectfileseditor.cpp +++ b/src/plugins/genericprojectmanager/genericprojectfileseditor.cpp @@ -58,6 +58,8 @@ ProjectFilesFactory::ProjectFilesFactory(Manager *manager) addMimeType(Constants::FILES_MIMETYPE); addMimeType(Constants::INCLUDES_MIMETYPE); addMimeType(Constants::CONFIG_MIMETYPE); + new TextEditor::TextEditorActionHandler(this, Constants::C_FILESEDITOR); + } Core::IEditor *ProjectFilesFactory::createEditor(QWidget *parent) diff --git a/src/plugins/genericprojectmanager/genericprojectplugin.cpp b/src/plugins/genericprojectmanager/genericprojectplugin.cpp index d43c175d53..713c9be771 100644 --- a/src/plugins/genericprojectmanager/genericprojectplugin.cpp +++ b/src/plugins/genericprojectmanager/genericprojectplugin.cpp @@ -46,7 +46,6 @@ #include <projectexplorer/projectexplorer.h> #include <projectexplorer/selectablefilesmodel.h> -#include <texteditor/texteditoractionhandler.h> #include <QtPlugin> #include <QDebug> @@ -75,8 +74,6 @@ bool GenericProjectPlugin::initialize(const QStringList &, QString *errorMessage Manager *manager = new Manager; - new TextEditor::TextEditorActionHandler(Constants::C_FILESEDITOR); // owned by ICore - m_projectFilesEditorFactory = new ProjectFilesFactory(manager); addObject(m_projectFilesEditorFactory); diff --git a/src/plugins/glsleditor/glsleditorfactory.cpp b/src/plugins/glsleditor/glsleditorfactory.cpp index 4ccceddae1..a6bfc4e143 100644 --- a/src/plugins/glsleditor/glsleditorfactory.cpp +++ b/src/plugins/glsleditor/glsleditorfactory.cpp @@ -37,6 +37,7 @@ #include <extensionsystem/pluginspec.h> #include <coreplugin/icore.h> +#include <texteditor/texteditoractionhandler.h> #include <texteditor/texteditorsettings.h> #include <QCoreApplication> @@ -55,6 +56,11 @@ GLSLEditorFactory::GLSLEditorFactory(QObject *parent) addMimeType(GLSLEditor::Constants::GLSL_MIMETYPE_FRAG); addMimeType(GLSLEditor::Constants::GLSL_MIMETYPE_VERT_ES); addMimeType(GLSLEditor::Constants::GLSL_MIMETYPE_FRAG_ES); + new TextEditor::TextEditorActionHandler(this, Constants::C_GLSLEDITOR_ID, + TextEditor::TextEditorActionHandler::Format + | TextEditor::TextEditorActionHandler::UnCommentSelection + | TextEditor::TextEditorActionHandler::UnCollapseAll); + } Core::IEditor *GLSLEditorFactory::createEditor(QWidget *parent) diff --git a/src/plugins/glsleditor/glsleditorplugin.cpp b/src/plugins/glsleditor/glsleditorplugin.cpp index de927d26ec..41a3f5db2d 100644 --- a/src/plugins/glsleditor/glsleditorplugin.cpp +++ b/src/plugins/glsleditor/glsleditorplugin.cpp @@ -49,7 +49,6 @@ #include <extensionsystem/pluginmanager.h> #include <texteditor/texteditorconstants.h> #include <texteditor/textfilewizard.h> -#include <texteditor/texteditoractionhandler.h> #include <utils/qtcassert.h> #include <glsl/glslengine.h> @@ -76,7 +75,6 @@ class GLSLEditorPluginPrivate public: GLSLEditorPluginPrivate() : m_editor(0), - m_actionHandler(0), m_glsl_120_frag(0), m_glsl_120_vert(0), m_glsl_120_common(0), @@ -87,7 +85,6 @@ public: ~GLSLEditorPluginPrivate() { - delete m_actionHandler; delete m_glsl_120_frag; delete m_glsl_120_vert; delete m_glsl_120_common; @@ -97,7 +94,6 @@ public: } GLSLEditorFactory *m_editor; - TextEditor::TextEditorActionHandler *m_actionHandler; QPointer<TextEditor::ITextEditor> m_currentTextEditable; GLSLEditorPlugin::InitFile *m_glsl_120_frag; @@ -144,11 +140,6 @@ bool GLSLEditorPlugin::initialize(const QStringList & /*arguments*/, QString *er addAutoReleasedObject(new GLSLCompletionAssistProvider); - dd->m_actionHandler = new TextEditorActionHandler(Constants::C_GLSLEDITOR_ID, - TextEditorActionHandler::Format - | TextEditorActionHandler::UnCommentSelection - | TextEditorActionHandler::UnCollapseAll); - ActionContainer *contextMenu = ActionManager::createMenu(GLSLEditor::Constants::M_CONTEXT); ActionContainer *glslToolsMenu = ActionManager::createMenu(Id(Constants::M_TOOLS_GLSL)); glslToolsMenu->setOnAllDisabledBehavior(ActionContainer::Hide); diff --git a/src/plugins/pythoneditor/pythoneditorfactory.cpp b/src/plugins/pythoneditor/pythoneditorfactory.cpp index e8b0d67274..4837e02419 100644 --- a/src/plugins/pythoneditor/pythoneditorfactory.cpp +++ b/src/plugins/pythoneditor/pythoneditorfactory.cpp @@ -34,6 +34,7 @@ #include <coreplugin/icore.h> #include <coreplugin/editormanager/editormanager.h> +#include <texteditor/texteditoractionhandler.h> #include <texteditor/texteditorsettings.h> #include <QDebug> @@ -47,6 +48,11 @@ EditorFactory::EditorFactory(QObject *parent) setId(Constants::C_PYTHONEDITOR_ID); setDisplayName(tr(Constants::C_EDITOR_DISPLAY_NAME)); addMimeType(QLatin1String(Constants::C_PY_MIMETYPE)); + new TextEditor::TextEditorActionHandler(this, + Constants::C_PYTHONEDITOR_ID, + TextEditor::TextEditorActionHandler::Format + | TextEditor::TextEditorActionHandler::UnCommentSelection + | TextEditor::TextEditorActionHandler::UnCollapseAll); } Core::IEditor *EditorFactory::createEditor(QWidget *parent) diff --git a/src/plugins/pythoneditor/pythoneditorplugin.cpp b/src/plugins/pythoneditor/pythoneditorplugin.cpp index 873661e185..97b17d06ea 100644 --- a/src/plugins/pythoneditor/pythoneditorplugin.cpp +++ b/src/plugins/pythoneditor/pythoneditorplugin.cpp @@ -197,7 +197,6 @@ static void copyIdentifiers(const char * const words[], size_t bytesCount, QSet< PythonEditorPlugin::PythonEditorPlugin() : m_factory(0) - , m_actionHandler(0) { m_instance = this; copyIdentifiers(LIST_OF_PYTHON_KEYWORDS, sizeof(LIST_OF_PYTHON_KEYWORDS), m_keywords); @@ -222,12 +221,6 @@ bool PythonEditorPlugin::initialize(const QStringList &arguments, QString *error addObject(m_factory); // Initialize editor actions handler - m_actionHandler = new TextEditor::TextEditorActionHandler( - C_PYTHONEDITOR_ID, - TextEditor::TextEditorActionHandler::Format - | TextEditor::TextEditorActionHandler::UnCommentSelection - | TextEditor::TextEditorActionHandler::UnCollapseAll); - // Add MIME overlay icons (these icons displayed at Project dock panel) const QIcon icon = QIcon::fromTheme(QLatin1String(C_PY_MIME_ICON)); if (!icon.isNull()) diff --git a/src/plugins/pythoneditor/pythoneditorplugin.h b/src/plugins/pythoneditor/pythoneditorplugin.h index 529d30202c..895a94e2f5 100644 --- a/src/plugins/pythoneditor/pythoneditorplugin.h +++ b/src/plugins/pythoneditor/pythoneditorplugin.h @@ -31,9 +31,7 @@ #define PYTHONEDITOR_PLUGIN_H #include <extensionsystem/iplugin.h> -#include <texteditor/texteditoractionhandler.h> #include <QSet> -#include <QScopedPointer> namespace PythonEditor { namespace Internal { @@ -65,7 +63,6 @@ public: private: static PythonEditorPlugin *m_instance; EditorFactory *m_factory; - TextEditor::TextEditorActionHandler *m_actionHandler; QSet<QString> m_keywords; QSet<QString> m_magics; QSet<QString> m_builtins; diff --git a/src/plugins/qmakeprojectmanager/profileeditorfactory.cpp b/src/plugins/qmakeprojectmanager/profileeditorfactory.cpp index b3ea76a576..13860e4519 100644 --- a/src/plugins/qmakeprojectmanager/profileeditorfactory.cpp +++ b/src/plugins/qmakeprojectmanager/profileeditorfactory.cpp @@ -35,6 +35,7 @@ #include <qtsupport/qtsupportconstants.h> #include <coreplugin/fileiconprovider.h> +#include <texteditor/texteditoractionhandler.h> #include <texteditor/texteditorsettings.h> #include <QCoreApplication> @@ -42,15 +43,17 @@ using namespace QmakeProjectManager; using namespace QmakeProjectManager::Internal; -ProFileEditorFactory::ProFileEditorFactory(QmakeManager *manager, TextEditor::TextEditorActionHandler *handler) : - m_manager(manager), - m_actionHandler(handler) +ProFileEditorFactory::ProFileEditorFactory(QmakeManager *manager) : + m_manager(manager) { setId(QmakeProjectManager::Constants::PROFILE_EDITOR_ID); setDisplayName(qApp->translate("OpenWith::Editors", QmakeProjectManager::Constants::PROFILE_EDITOR_DISPLAY_NAME)); addMimeType(QmakeProjectManager::Constants::PROFILE_MIMETYPE); addMimeType(QmakeProjectManager::Constants::PROINCLUDEFILE_MIMETYPE); addMimeType(QmakeProjectManager::Constants::PROFEATUREFILE_MIMETYPE); + new TextEditor::TextEditorActionHandler(this, Constants::C_PROFILEEDITOR, + TextEditor::TextEditorActionHandler::UnCommentSelection + | TextEditor::TextEditorActionHandler::JumpToFileUnderCursor); Core::FileIconProvider::registerIconOverlayForSuffix(QtSupport::Constants::ICON_QT_PROJECT, "pro"); Core::FileIconProvider::registerIconOverlayForSuffix(QtSupport::Constants::ICON_QT_PROJECT, "pri"); diff --git a/src/plugins/qmakeprojectmanager/profileeditorfactory.h b/src/plugins/qmakeprojectmanager/profileeditorfactory.h index 07a2e5e21c..2d7814b3ee 100644 --- a/src/plugins/qmakeprojectmanager/profileeditorfactory.h +++ b/src/plugins/qmakeprojectmanager/profileeditorfactory.h @@ -32,8 +32,6 @@ #include <coreplugin/editormanager/ieditorfactory.h> -namespace TextEditor { class TextEditorActionHandler; } - namespace QmakeProjectManager { class QmakeManager; @@ -45,7 +43,7 @@ class ProFileEditorFactory : public Core::IEditorFactory Q_OBJECT public: - ProFileEditorFactory(QmakeManager *parent, TextEditor::TextEditorActionHandler *handler); + ProFileEditorFactory(QmakeManager *parent); Core::IEditor *createEditor(QWidget *parent); @@ -53,7 +51,6 @@ public: private: QmakeManager *m_manager; - TextEditor::TextEditorActionHandler *m_actionHandler; }; } // namespace Internal diff --git a/src/plugins/qmakeprojectmanager/qmakeprojectmanagerplugin.cpp b/src/plugins/qmakeprojectmanager/qmakeprojectmanagerplugin.cpp index b5763e5d14..00f2ca4ba9 100644 --- a/src/plugins/qmakeprojectmanager/qmakeprojectmanagerplugin.cpp +++ b/src/plugins/qmakeprojectmanager/qmakeprojectmanagerplugin.cpp @@ -111,12 +111,7 @@ bool QmakeProjectManagerPlugin::initialize(const QStringList &arguments, QString m_qmakeProjectManager = new QmakeManager(this); addObject(m_qmakeProjectManager); - TextEditor::TextEditorActionHandler *editorHandler - = new TextEditor::TextEditorActionHandler(Constants::C_PROFILEEDITOR, - TextEditor::TextEditorActionHandler::UnCommentSelection - | TextEditor::TextEditorActionHandler::JumpToFileUnderCursor); - - m_proFileEditorFactory = new ProFileEditorFactory(m_qmakeProjectManager, editorHandler); + m_proFileEditorFactory = new ProFileEditorFactory(m_qmakeProjectManager); ProjectExplorer::KitManager::registerKitInformation(new QmakeKitInformation); diff --git a/src/plugins/qmljseditor/qmljseditorfactory.cpp b/src/plugins/qmljseditor/qmljseditorfactory.cpp index 4a2efa6053..90a8825bc0 100644 --- a/src/plugins/qmljseditor/qmljseditorfactory.cpp +++ b/src/plugins/qmljseditor/qmljseditorfactory.cpp @@ -34,6 +34,7 @@ #include "qmljseditorplugin.h" #include <qmljstools/qmljstoolsconstants.h> +#include <texteditor/texteditoractionhandler.h> #include <QCoreApplication> @@ -52,6 +53,12 @@ QmlJSEditorFactory::QmlJSEditorFactory(QObject *parent) addMimeType(QmlJSTools::Constants::QMLTYPES_MIMETYPE); addMimeType(QmlJSTools::Constants::JS_MIMETYPE); addMimeType(QmlJSTools::Constants::JSON_MIMETYPE); + new TextEditor::TextEditorActionHandler(this, Constants::C_QMLJSEDITOR_ID, + TextEditor::TextEditorActionHandler::Format + | TextEditor::TextEditorActionHandler::UnCommentSelection + | TextEditor::TextEditorActionHandler::UnCollapseAll + | TextEditor::TextEditorActionHandler::FollowSymbolUnderCursor); + } Core::IEditor *QmlJSEditorFactory::createEditor(QWidget *parent) diff --git a/src/plugins/qmljseditor/qmljseditorplugin.cpp b/src/plugins/qmljseditor/qmljseditorplugin.cpp index 672a9dd813..f7f0ce5eec 100644 --- a/src/plugins/qmljseditor/qmljseditorplugin.cpp +++ b/src/plugins/qmljseditor/qmljseditorplugin.cpp @@ -64,7 +64,6 @@ #include <texteditor/texteditorconstants.h> #include <texteditor/texteditorsettings.h> #include <texteditor/textfilewizard.h> -#include <texteditor/texteditoractionhandler.h> #include <utils/qtcassert.h> #include <utils/json.h> @@ -95,7 +94,6 @@ QmlJSEditorPlugin *QmlJSEditorPlugin::m_instance = 0; QmlJSEditorPlugin::QmlJSEditorPlugin() : m_modelManager(0), m_editor(0), - m_actionHandler(0), m_quickFixAssistProvider(0), m_reformatFileAction(0), m_currentEditor(0), @@ -109,7 +107,6 @@ QmlJSEditorPlugin::QmlJSEditorPlugin() : QmlJSEditorPlugin::~QmlJSEditorPlugin() { removeObject(m_editor); - delete m_actionHandler; m_instance = 0; } @@ -165,12 +162,6 @@ bool QmlJSEditorPlugin::initialize(const QStringList & /*arguments*/, QString *e wizard->setId(QLatin1String("Z.Js")); addAutoReleasedObject(wizard); - m_actionHandler = new TextEditor::TextEditorActionHandler(Constants::C_QMLJSEDITOR_ID, - TextEditor::TextEditorActionHandler::Format - | TextEditor::TextEditorActionHandler::UnCommentSelection - | TextEditor::TextEditorActionHandler::UnCollapseAll - | TextEditor::TextEditorActionHandler::FollowSymbolUnderCursor); - Core::ActionContainer *contextMenu = Core::ActionManager::createMenu(Constants::M_CONTEXT); Core::ActionContainer *qmlToolsMenu = Core::ActionManager::actionContainer(Core::Id(QmlJSTools::Constants::M_TOOLS_QMLJS)); diff --git a/src/plugins/qmljseditor/qmljseditorplugin.h b/src/plugins/qmljseditor/qmljseditorplugin.h index 45f2240123..1c33050373 100644 --- a/src/plugins/qmljseditor/qmljseditorplugin.h +++ b/src/plugins/qmljseditor/qmljseditorplugin.h @@ -42,10 +42,6 @@ namespace Utils { class JsonSchemaManager; } -namespace TextEditor { -class TextEditorActionHandler; -} // namespace TextEditor - namespace Core { class Command; class ActionContainer; @@ -115,7 +111,6 @@ private: QmlJS::ModelManagerInterface *m_modelManager; QmlJSEditorFactory *m_editor; - TextEditor::TextEditorActionHandler *m_actionHandler; QmlJSQuickFixAssistProvider *m_quickFixAssistProvider; QmlTaskManager *m_qmlTaskManager; diff --git a/src/plugins/qnx/bardescriptoreditorfactory.cpp b/src/plugins/qnx/bardescriptoreditorfactory.cpp index c89e09fcc5..5cba705085 100644 --- a/src/plugins/qnx/bardescriptoreditorfactory.cpp +++ b/src/plugins/qnx/bardescriptoreditorfactory.cpp @@ -44,8 +44,8 @@ using namespace Qnx::Internal; class BarDescriptorActionHandler : public TextEditor::TextEditorActionHandler { public: - BarDescriptorActionHandler() - : TextEditor::TextEditorActionHandler(Constants::QNX_BAR_DESCRIPTOR_EDITOR_CONTEXT) + BarDescriptorActionHandler(QObject *parent) + : TextEditor::TextEditorActionHandler(parent, Constants::QNX_BAR_DESCRIPTOR_EDITOR_CONTEXT) { } protected: @@ -58,16 +58,11 @@ protected: BarDescriptorEditorFactory::BarDescriptorEditorFactory(QObject *parent) : Core::IEditorFactory(parent) - , m_actionHandler(new BarDescriptorActionHandler) { setId(Constants::QNX_BAR_DESCRIPTOR_EDITOR_ID); setDisplayName(tr("Bar descriptor editor")); addMimeType(Constants::QNX_BAR_DESCRIPTOR_MIME_TYPE); -} - -BarDescriptorEditorFactory::~BarDescriptorEditorFactory() -{ - delete m_actionHandler; + new BarDescriptorActionHandler(this); } Core::IEditor *BarDescriptorEditorFactory::createEditor(QWidget *parent) diff --git a/src/plugins/qnx/bardescriptoreditorfactory.h b/src/plugins/qnx/bardescriptoreditorfactory.h index ed5a012d6a..fac30e7920 100644 --- a/src/plugins/qnx/bardescriptoreditorfactory.h +++ b/src/plugins/qnx/bardescriptoreditorfactory.h @@ -34,10 +34,6 @@ #include <coreplugin/editormanager/ieditorfactory.h> -namespace TextEditor { -class TextEditorActionHandler; -} - namespace Qnx { namespace Internal { @@ -47,12 +43,8 @@ class BarDescriptorEditorFactory : public Core::IEditorFactory public: explicit BarDescriptorEditorFactory(QObject *parent = 0); - ~BarDescriptorEditorFactory(); Core::IEditor *createEditor(QWidget *parent); - -private: - TextEditor::TextEditorActionHandler *m_actionHandler; }; } // namespace Internal diff --git a/src/plugins/texteditor/basetexteditor_p.h b/src/plugins/texteditor/basetexteditor_p.h index 0ea3d5fdf6..54ccd52a2b 100644 --- a/src/plugins/texteditor/basetexteditor_p.h +++ b/src/plugins/texteditor/basetexteditor_p.h @@ -49,7 +49,6 @@ namespace TextEditor { class BaseTextDocument; -class TextEditorActionHandler; class CodeAssistant; namespace Internal { diff --git a/src/plugins/texteditor/plaintexteditorfactory.cpp b/src/plugins/texteditor/plaintexteditorfactory.cpp index af85d21ac5..2efee71e0a 100644 --- a/src/plugins/texteditor/plaintexteditorfactory.cpp +++ b/src/plugins/texteditor/plaintexteditorfactory.cpp @@ -51,18 +51,13 @@ PlainTextEditorFactory::PlainTextEditorFactory(QObject *parent) 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( + new TextEditorActionHandler(this, TextEditor::Constants::C_TEXTEDITOR, TextEditorActionHandler::Format | TextEditorActionHandler::UnCommentSelection | TextEditorActionHandler::UnCollapseAll); } -PlainTextEditorFactory::~PlainTextEditorFactory() -{ - delete m_actionHandler; -} - 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 facf43fa9b..b60a1d1fca 100644 --- a/src/plugins/texteditor/plaintexteditorfactory.h +++ b/src/plugins/texteditor/plaintexteditorfactory.h @@ -35,7 +35,6 @@ #include <QStringList> namespace TextEditor { -class TextEditorActionHandler; namespace Internal { class PlainTextEditorFactory : public Core::IEditorFactory @@ -44,17 +43,12 @@ class PlainTextEditorFactory : public Core::IEditorFactory public: PlainTextEditorFactory(QObject *parent = 0); - ~PlainTextEditorFactory(); using Core::IEditorFactory::addMimeType; Core::IEditor *createEditor(QWidget *parent); - TextEditor::TextEditorActionHandler *actionHandler() const { return m_actionHandler; } private slots: void updateEditorInfoBar(Core::IEditor *editor); - -private: - TextEditor::TextEditorActionHandler *m_actionHandler; }; } // namespace Internal diff --git a/src/plugins/texteditor/texteditoractionhandler.cpp b/src/plugins/texteditor/texteditoractionhandler.cpp index eeaf6affd9..64ed02eaf5 100644 --- a/src/plugins/texteditor/texteditoractionhandler.cpp +++ b/src/plugins/texteditor/texteditoractionhandler.cpp @@ -49,8 +49,9 @@ using namespace TextEditor; using namespace TextEditor::Internal; -TextEditorActionHandler::TextEditorActionHandler(Core::Id contextId, uint optionalActions) - : QObject(Core::ICore::instance()), +TextEditorActionHandler::TextEditorActionHandler(QObject *parent, Core::Id contextId, + uint optionalActions) + : QObject(parent), m_undoAction(0), m_redoAction(0), m_copyAction(0), diff --git a/src/plugins/texteditor/texteditoractionhandler.h b/src/plugins/texteditor/texteditoractionhandler.h index eaea4735cf..bee5dc293b 100644 --- a/src/plugins/texteditor/texteditoractionhandler.h +++ b/src/plugins/texteditor/texteditoractionhandler.h @@ -65,7 +65,7 @@ public: JumpToFileUnderCursor = 16 }; - explicit TextEditorActionHandler(Core::Id contextId, uint optionalActions = None); + explicit TextEditorActionHandler(QObject *parent, Core::Id contextId, uint optionalActions = None); ~TextEditorActionHandler(); protected: diff --git a/src/plugins/vcsbase/basevcseditorfactory.cpp b/src/plugins/vcsbase/basevcseditorfactory.cpp index 85512b08fb..bbd641a096 100644 --- a/src/plugins/vcsbase/basevcseditorfactory.cpp +++ b/src/plugins/vcsbase/basevcseditorfactory.cpp @@ -54,12 +54,10 @@ public: BaseVcsEditorFactoryPrivate(const VcsBaseEditorParameters *t); const VcsBaseEditorParameters *m_type; - TextEditor::TextEditorActionHandler *m_editorHandler; }; BaseVcsEditorFactoryPrivate::BaseVcsEditorFactoryPrivate(const VcsBaseEditorParameters *t) : - m_type(t), - m_editorHandler(new TextEditor::TextEditorActionHandler(t->context)) + m_type(t) { } @@ -71,6 +69,7 @@ BaseVcsEditorFactory::BaseVcsEditorFactory(const VcsBaseEditorParameters *t) setId(t->id); setDisplayName(QCoreApplication::translate("VCS", t->displayName)); addMimeType(t->mimeType); + new TextEditor::TextEditorActionHandler(this, t->context); } BaseVcsEditorFactory::~BaseVcsEditorFactory() |