forked from qt-creator/qt-creator
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:
@@ -1387,11 +1387,6 @@ TextEditor::BaseTextEditorWidget::Link QmlJSTextEditorWidget::findLinkAt(const Q
|
||||
return Link();
|
||||
}
|
||||
|
||||
void QmlJSTextEditorWidget::followSymbolUnderCursor()
|
||||
{
|
||||
openLink(findLinkAt(textCursor()));
|
||||
}
|
||||
|
||||
void QmlJSTextEditorWidget::findUsages()
|
||||
{
|
||||
m_findReferences->findUsages(editorDocument()->fileName(), textCursor().position());
|
||||
|
||||
@@ -176,7 +176,6 @@ public slots:
|
||||
void reparseDocumentNow();
|
||||
void updateSemanticInfo();
|
||||
void updateSemanticInfoNow();
|
||||
void followSymbolUnderCursor();
|
||||
void findUsages();
|
||||
void renameUsages();
|
||||
void showContextPane();
|
||||
|
||||
@@ -51,7 +51,6 @@ const char TASK_SEARCH[] = "QmlJSEditor.TaskSearch";
|
||||
const char SETTINGS_CATEGORY_QML[] = "J.QtQuick";
|
||||
const char SETTINGS_TR_CATEGORY_QML[] = QT_TRANSLATE_NOOP("QmlJSEditor", "Qt Quick");
|
||||
|
||||
const char FOLLOW_SYMBOL_UNDER_CURSOR[] = "QmlJSEditor.FollowSymbolUnderCursor";
|
||||
const char FIND_USAGES[] = "QmlJSEditor.FindUsages";
|
||||
const char RENAME_USAGES[] = "QmlJSEditor.RenameUsages";
|
||||
const char RUN_SEMANTIC_SCAN[] = "QmlJSEditor.RunSemanticScan";
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -100,7 +100,6 @@ public:
|
||||
Utils::JsonSchemaManager *jsonManager() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
void followSymbolUnderCursor();
|
||||
void findUsages();
|
||||
void renameUsages();
|
||||
void reformatFile();
|
||||
|
||||
Reference in New Issue
Block a user