Commit 39a03d25 authored by Erik Verbruggen's avatar Erik Verbruggen

C++ Editor: Moved refactoring actions into sub-menu.

parent 670e960f
......@@ -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);
......
......@@ -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";
......
......@@ -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();
......
......@@ -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";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment