Added TextEditor commands FollowSymbol and JumpToFile.

Most of editors have "jump to file" or "follow symbol" actions. This
patch reduces amount of related boilerplate code.

New actions are made optional to prevent shortcut clash (both use F2).

Change-Id: I2af580ed9d6789df25f4487ba001f3b83887c504
Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
Konstantin Tokarev
2012-03-27 23:18:46 +04:00
committed by hjk
parent aa722e6a60
commit 7ae82b9f94
26 changed files with 43 additions and 96 deletions

View File

@@ -174,7 +174,8 @@ bool QmlJSEditorPlugin::initialize(const QStringList & /*arguments*/, QString *e
m_actionHandler = new TextEditor::TextEditorActionHandler(QmlJSEditor::Constants::C_QMLJSEDITOR_ID,
TextEditor::TextEditorActionHandler::Format
| TextEditor::TextEditorActionHandler::UnCommentSelection
| TextEditor::TextEditorActionHandler::UnCollapseAll);
| TextEditor::TextEditorActionHandler::UnCollapseAll
| TextEditor::TextEditorActionHandler::FollowSymbolUnderCursor);
m_actionHandler->initializeActions();
Core::ActionManager *am = Core::ICore::actionManager();
@@ -185,10 +186,7 @@ bool QmlJSEditorPlugin::initialize(const QStringList & /*arguments*/, QString *e
qmlToolsMenu->addAction(createSeparator(am, this, globalContext, QmlJSEditor::Constants::SEPARATOR3));
Core::Command *cmd;
QAction *followSymbolUnderCursorAction = new QAction(tr("Follow Symbol Under Cursor"), this);
cmd = am->registerAction(followSymbolUnderCursorAction, Constants::FOLLOW_SYMBOL_UNDER_CURSOR, context);
cmd->setDefaultKeySequence(QKeySequence(Qt::Key_F2));
connect(followSymbolUnderCursorAction, SIGNAL(triggered()), this, SLOT(followSymbolUnderCursor()));
cmd = am->command(TextEditor::Constants::FOLLOW_SYMBOL_UNDER_CURSOR);
contextMenu->addAction(cmd);
qmlToolsMenu->addAction(cmd);
@@ -294,14 +292,6 @@ Utils::JsonSchemaManager *QmlJSEditorPlugin::jsonManager() const
return m_jsonManager.data();
}
void QmlJSEditorPlugin::followSymbolUnderCursor()
{
Core::EditorManager *em = Core::EditorManager::instance();
if (QmlJSTextEditorWidget *editor = qobject_cast<QmlJSTextEditorWidget*>(em->currentEditor()->widget()))
editor->followSymbolUnderCursor();
}
void QmlJSEditorPlugin::findUsages()
{
Core::EditorManager *em = Core::EditorManager::instance();