diff options
author | Erik Verbruggen <erik.verbruggen@nokia.com> | 2010-09-15 14:33:44 +0200 |
---|---|---|
committer | Erik Verbruggen <erik.verbruggen@nokia.com> | 2010-09-15 14:35:12 +0200 |
commit | 39a03d2505104d197f1c98a1055559f4d04f8ba7 (patch) | |
tree | 0b0a3e73224f7bfce9b262f3f6f91caf38b4290c | |
parent | 670e960f97bca721083161f2246f227813a34a2b (diff) | |
download | qt-creator-39a03d2505104d197f1c98a1055559f4d04f8ba7.tar.gz |
C++ Editor: Moved refactoring actions into sub-menu.
-rw-r--r-- | src/plugins/cppeditor/cppeditor.cpp | 19 | ||||
-rw-r--r-- | src/plugins/cppeditor/cppeditorconstants.h | 4 | ||||
-rw-r--r-- | src/plugins/cppeditor/cppplugin.cpp | 30 | ||||
-rw-r--r-- | src/plugins/cpptools/cpptoolsconstants.h | 1 |
4 files changed, 37 insertions, 17 deletions
diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp index 817b819874..7e4314c05b 100644 --- a/src/plugins/cppeditor/cppeditor.cpp +++ b/src/plugins/cppeditor/cppeditor.cpp @@ -63,6 +63,7 @@ #include <coreplugin/icore.h> #include <coreplugin/actionmanager/actionmanager.h> #include <coreplugin/actionmanager/actioncontainer.h> +#include <coreplugin/actionmanager/command.h> #include <coreplugin/editormanager/ieditor.h> #include <coreplugin/editormanager/editormanager.h> #include <coreplugin/mimedatabase.h> @@ -1576,7 +1577,7 @@ void CPPEditor::contextMenuEvent(QContextMenuEvent *e) QMenu *menu = new QMenu; Core::ActionManager *am = Core::ICore::instance()->actionManager(); - Core::ActionContainer *mcontext = am->actionContainer(CppEditor::Constants::M_CONTEXT); + Core::ActionContainer *mcontext = am->actionContainer(Constants::M_CONTEXT); QMenu *contextMenu = mcontext->menu(); CppQuickFixCollector *quickFixCollector = CppPlugin::instance()->quickFixCollector(); @@ -1584,24 +1585,30 @@ void CPPEditor::contextMenuEvent(QContextMenuEvent *e) QSignalMapper mapper; connect(&mapper, SIGNAL(mapped(int)), this, SLOT(performQuickFix(int))); + QMenu *quickFixMenu = new QMenu("&Refactor", menu); + quickFixMenu->addAction(am->command(Constants::RENAME_SYMBOL_UNDER_CURSOR)->action()); + if (! isOutdated()) { if (quickFixCollector->startCompletion(editableInterface()) != -1) { m_quickFixes = quickFixCollector->quickFixes(); + if (! m_quickFixes.isEmpty()) + quickFixMenu->addSeparator(); + for (int index = 0; index < m_quickFixes.size(); ++index) { TextEditor::QuickFixOperation::Ptr op = m_quickFixes.at(index); - QAction *action = menu->addAction(op->description()); + QAction *action = quickFixMenu->addAction(op->description()); mapper.setMapping(action, index); connect(action, SIGNAL(triggered()), &mapper, SLOT(map())); } - - if (! m_quickFixes.isEmpty()) - menu->addSeparator(); } } - foreach (QAction *action, contextMenu->actions()) + foreach (QAction *action, contextMenu->actions()) { menu->addAction(action); + if (action->objectName() == Constants::M_REFACTORING_MENU_INSERTION_POINT) + menu->addMenu(quickFixMenu); + } appendStandardContextMenuActions(menu); diff --git a/src/plugins/cppeditor/cppeditorconstants.h b/src/plugins/cppeditor/cppeditorconstants.h index 5a68c78e4c..17c13d1186 100644 --- a/src/plugins/cppeditor/cppeditorconstants.h +++ b/src/plugins/cppeditor/cppeditorconstants.h @@ -41,9 +41,11 @@ const char * const CPPEDITOR_DISPLAY_NAME = QT_TRANSLATE_NOOP("OpenWith::Editors const char * const SWITCH_DECLARATION_DEFINITION = "CppEditor.SwitchDeclarationDefinition"; const char * const RENAME_SYMBOL_UNDER_CURSOR = "CppEditor.RenameSymbolUnderCursor"; const char * const FIND_USAGES = "CppEditor.FindUsages"; -const char * const REFACTOR_MENU = "CppEditor.RefactorMenu"; +const char * const M_REFACTORING_MENU_INSERTION_POINT = "CppEditor.RefactorGroup"; const char * const SEPARATOR = "CppEditor.Separator"; const char * const SEPARATOR2 = "CppEditor.Separator2"; +const char * const SEPARATOR3 = "CppEditor.Separator3"; +const char * const SEPARATOR4 = "CppEditor.Separator4"; const char * const FIND_REFERENCES = "CppEditor.FindReferences"; const char * const JUMP_TO_DEFINITION = "CppEditor.JumpToDefinition"; const char * const UPDATE_CODEMODEL = "CppEditor.UpdateCodeModel"; diff --git a/src/plugins/cppeditor/cppplugin.cpp b/src/plugins/cppeditor/cppplugin.cpp index db44d239e7..3d11283627 100644 --- a/src/plugins/cppeditor/cppplugin.cpp +++ b/src/plugins/cppeditor/cppplugin.cpp @@ -269,14 +269,6 @@ bool CppPlugin::initialize(const QStringList & /*arguments*/, QString *errorMess contextMenu->addAction(cmd); cppToolsMenu->addAction(cmd); - m_renameSymbolUnderCursorAction = new QAction(tr("Rename Symbol Under Cursor"), this); - cmd = am->registerAction(m_renameSymbolUnderCursorAction, - Constants::RENAME_SYMBOL_UNDER_CURSOR, context); - cmd->setDefaultKeySequence(QKeySequence("CTRL+SHIFT+R")); - connect(m_renameSymbolUnderCursorAction, SIGNAL(triggered()), this, SLOT(renameSymbolUnderCursor())); - contextMenu->addAction(cmd); - cppToolsMenu->addAction(cmd); - m_openTypeHierarchyAction = new QAction(tr("Open Type Hierarchy"), this); cmd = am->registerAction(m_openTypeHierarchyAction, Constants::OPEN_TYPE_HIERARCHY, context); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+T"))); @@ -284,9 +276,27 @@ bool CppPlugin::initialize(const QStringList & /*arguments*/, QString *errorMess contextMenu->addAction(cmd); cppToolsMenu->addAction(cmd); - // Update context in global context + // Refactoring sub-menu Core::Context globalContext(Core::Constants::C_GLOBAL); - cppToolsMenu->addAction(createSeparator(am, this, globalContext, CppEditor::Constants::SEPARATOR2)); + Core::Command *sep = createSeparator(am, this, globalContext, + Constants::SEPARATOR2); + sep->action()->setObjectName(Constants::M_REFACTORING_MENU_INSERTION_POINT); + contextMenu->addAction(sep); + contextMenu->addAction(createSeparator(am, this, globalContext, + Constants::SEPARATOR3)); + + m_renameSymbolUnderCursorAction = new QAction(tr("Rename Symbol Under Cursor"), + this); + cmd = am->registerAction(m_renameSymbolUnderCursorAction, + Constants::RENAME_SYMBOL_UNDER_CURSOR, + context); + cmd->setDefaultKeySequence(QKeySequence("CTRL+SHIFT+R")); + connect(m_renameSymbolUnderCursorAction, SIGNAL(triggered()), + this, SLOT(renameSymbolUnderCursor())); + cppToolsMenu->addAction(cmd); + + // Update context in global context + cppToolsMenu->addAction(createSeparator(am, this, globalContext, CppEditor::Constants::SEPARATOR4)); m_updateCodeModelAction = new QAction(tr("Update Code Model"), this); cmd = am->registerAction(m_updateCodeModelAction, Core::Id(Constants::UPDATE_CODEMODEL), globalContext); CppTools::CppModelManagerInterface *cppModelManager = CppTools::CppModelManagerInterface::instance(); diff --git a/src/plugins/cpptools/cpptoolsconstants.h b/src/plugins/cpptools/cpptoolsconstants.h index 791915f31c..874db4cff7 100644 --- a/src/plugins/cpptools/cpptoolsconstants.h +++ b/src/plugins/cpptools/cpptoolsconstants.h @@ -36,6 +36,7 @@ namespace CppTools { namespace Constants { const char * const M_TOOLS_CPP = "CppTools.Tools.Menu"; +const char * const M_CPP_REFACTORING = "CppTools.Refactoring.Menu"; const char * const SWITCH_HEADER_SOURCE = "CppTools.SwitchHeaderSource"; const char * const TASK_INDEX = "CppTools.Task.Index"; const char * const TASK_SEARCH = "CppTools.Task.Search"; |