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:
@@ -180,11 +180,6 @@ void CMakeEditorWidget::setFontSettings(const TextEditor::FontSettings &fs)
|
|||||||
highlighter->rehighlight();
|
highlighter->rehighlight();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMakeEditorWidget::jumpToFile()
|
|
||||||
{
|
|
||||||
openLink(findLinkAt(textCursor()));
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool isValidFileNameChar(const QChar &c)
|
static bool isValidFileNameChar(const QChar &c)
|
||||||
{
|
{
|
||||||
if (c.isLetterOrNumber()
|
if (c.isLetterOrNumber()
|
||||||
|
@@ -83,8 +83,6 @@ public:
|
|||||||
CMakeEditorFactory *factory() { return m_factory; }
|
CMakeEditorFactory *factory() { return m_factory; }
|
||||||
TextEditor::TextEditorActionHandler *actionHandler() const { return m_ah; }
|
TextEditor::TextEditorActionHandler *actionHandler() const { return m_ah; }
|
||||||
|
|
||||||
void jumpToFile();
|
|
||||||
|
|
||||||
Link findLinkAt(const QTextCursor &cursor,
|
Link findLinkAt(const QTextCursor &cursor,
|
||||||
bool resolveTarget = true);
|
bool resolveTarget = true);
|
||||||
|
|
||||||
|
@@ -54,7 +54,8 @@ CMakeEditorFactory::CMakeEditorFactory(CMakeManager *manager)
|
|||||||
|
|
||||||
m_actionHandler =
|
m_actionHandler =
|
||||||
new TextEditorActionHandler(Constants::C_CMAKEEDITOR,
|
new TextEditorActionHandler(Constants::C_CMAKEEDITOR,
|
||||||
TextEditorActionHandler::UnCommentSelection);
|
TextEditorActionHandler::UnCommentSelection
|
||||||
|
| TextEditorActionHandler::JumpToFileUnderCursor);
|
||||||
|
|
||||||
ICore *core = ICore::instance();
|
ICore *core = ICore::instance();
|
||||||
ActionManager *am = core->actionManager();
|
ActionManager *am = core->actionManager();
|
||||||
@@ -62,11 +63,7 @@ CMakeEditorFactory::CMakeEditorFactory(CMakeManager *manager)
|
|||||||
Command *cmd;
|
Command *cmd;
|
||||||
Context cmakeEditorContext = Context(Constants::C_CMAKEEDITOR);
|
Context cmakeEditorContext = Context(Constants::C_CMAKEEDITOR);
|
||||||
|
|
||||||
QAction *jumpToFile = new QAction(tr("Jump to File Under Cursor"), this);
|
cmd = am->command(TextEditor::Constants::JUMP_TO_FILE_UNDER_CURSOR);
|
||||||
cmd = am->registerAction(jumpToFile,
|
|
||||||
Constants::JUMP_TO_FILE, cmakeEditorContext);
|
|
||||||
cmd->setDefaultKeySequence(QKeySequence(Qt::Key_F2));
|
|
||||||
connect(jumpToFile, SIGNAL(triggered()), this, SLOT(jumpToFile()));
|
|
||||||
contextMenu->addAction(cmd);
|
contextMenu->addAction(cmd);
|
||||||
|
|
||||||
QAction *separator = new QAction(this);
|
QAction *separator = new QAction(this);
|
||||||
@@ -101,14 +98,6 @@ Core::IEditor *CMakeEditorFactory::createEditor(QWidget *parent)
|
|||||||
return rc->editor();
|
return rc->editor();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMakeEditorFactory::jumpToFile()
|
|
||||||
{
|
|
||||||
Core::EditorManager *em = Core::EditorManager::instance();
|
|
||||||
CMakeEditorWidget *editor = qobject_cast<CMakeEditorWidget*>(em->currentEditor()->widget());
|
|
||||||
if (editor)
|
|
||||||
editor->jumpToFile();
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList CMakeEditorFactory::mimeTypes() const
|
QStringList CMakeEditorFactory::mimeTypes() const
|
||||||
{
|
{
|
||||||
return m_mimeTypes;
|
return m_mimeTypes;
|
||||||
|
@@ -60,9 +60,6 @@ public:
|
|||||||
Core::IDocument *open(const QString &fileName);
|
Core::IDocument *open(const QString &fileName);
|
||||||
Core::IEditor *createEditor(QWidget *parent);
|
Core::IEditor *createEditor(QWidget *parent);
|
||||||
|
|
||||||
public slots:
|
|
||||||
void jumpToFile();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const QStringList m_mimeTypes;
|
const QStringList m_mimeTypes;
|
||||||
CMakeManager *m_manager;
|
CMakeManager *m_manager;
|
||||||
|
@@ -52,7 +52,6 @@ const char M_CONTEXT[] = "CMakeEditor.ContextMenu";
|
|||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
const char SEPARATOR[] = "CMakeEditor.Separator";
|
const char SEPARATOR[] = "CMakeEditor.Separator";
|
||||||
const char JUMP_TO_FILE[] = "CMakeEditor.JumpToFile";
|
|
||||||
|
|
||||||
} // namespace Constants
|
} // namespace Constants
|
||||||
} // namespace CMakeProjectManager
|
} // namespace CMakeProjectManager
|
||||||
|
@@ -1485,11 +1485,6 @@ CPPEditorWidget::Link CPPEditorWidget::findLinkAt(const QTextCursor &cursor,
|
|||||||
return Link();
|
return Link();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPPEditorWidget::jumpToDefinition()
|
|
||||||
{
|
|
||||||
openLink(findLinkAt(textCursor()));
|
|
||||||
}
|
|
||||||
|
|
||||||
Symbol *CPPEditorWidget::findDefinition(Symbol *symbol, const Snapshot &snapshot) const
|
Symbol *CPPEditorWidget::findDefinition(Symbol *symbol, const Snapshot &snapshot) const
|
||||||
{
|
{
|
||||||
if (symbol->isFunction())
|
if (symbol->isFunction())
|
||||||
|
@@ -208,7 +208,6 @@ public Q_SLOTS:
|
|||||||
virtual void setTabSettings(const TextEditor::TabSettings &);
|
virtual void setTabSettings(const TextEditor::TabSettings &);
|
||||||
void setSortedOutline(bool sort);
|
void setSortedOutline(bool sort);
|
||||||
void switchDeclarationDefinition();
|
void switchDeclarationDefinition();
|
||||||
void jumpToDefinition();
|
|
||||||
void renameSymbolUnderCursor();
|
void renameSymbolUnderCursor();
|
||||||
void renameUsages();
|
void renameUsages();
|
||||||
void findUsages();
|
void findUsages();
|
||||||
|
@@ -48,7 +48,6 @@ const char SEPARATOR[] = "CppEditor.Separator";
|
|||||||
const char SEPARATOR2[] = "CppEditor.Separator2";
|
const char SEPARATOR2[] = "CppEditor.Separator2";
|
||||||
const char SEPARATOR3[] = "CppEditor.Separator3";
|
const char SEPARATOR3[] = "CppEditor.Separator3";
|
||||||
const char SEPARATOR4[] = "CppEditor.Separator4";
|
const char SEPARATOR4[] = "CppEditor.Separator4";
|
||||||
const char JUMP_TO_DEFINITION[] = "CppEditor.JumpToDefinition";
|
|
||||||
const char UPDATE_CODEMODEL[] = "CppEditor.UpdateCodeModel";
|
const char UPDATE_CODEMODEL[] = "CppEditor.UpdateCodeModel";
|
||||||
|
|
||||||
const int TYPE_HIERARCHY_PRIORITY = 700;
|
const int TYPE_HIERARCHY_PRIORITY = 700;
|
||||||
|
@@ -242,12 +242,7 @@ bool CppPlugin::initialize(const QStringList & /*arguments*/, QString *errorMess
|
|||||||
cmd = am->command(Core::Id(CppTools::Constants::SWITCH_HEADER_SOURCE));
|
cmd = am->command(Core::Id(CppTools::Constants::SWITCH_HEADER_SOURCE));
|
||||||
contextMenu->addAction(cmd);
|
contextMenu->addAction(cmd);
|
||||||
|
|
||||||
QAction *jumpToDefinition = new QAction(tr("Follow Symbol Under Cursor"), this);
|
cmd = am->command(TextEditor::Constants::FOLLOW_SYMBOL_UNDER_CURSOR);
|
||||||
cmd = am->registerAction(jumpToDefinition,
|
|
||||||
Constants::JUMP_TO_DEFINITION, context, true);
|
|
||||||
cmd->setDefaultKeySequence(QKeySequence(Qt::Key_F2));
|
|
||||||
connect(jumpToDefinition, SIGNAL(triggered()),
|
|
||||||
this, SLOT(jumpToDefinition()));
|
|
||||||
contextMenu->addAction(cmd);
|
contextMenu->addAction(cmd);
|
||||||
cppToolsMenu->addAction(cmd);
|
cppToolsMenu->addAction(cmd);
|
||||||
|
|
||||||
@@ -304,7 +299,8 @@ bool CppPlugin::initialize(const QStringList & /*arguments*/, QString *errorMess
|
|||||||
m_actionHandler = new TextEditor::TextEditorActionHandler(CppEditor::Constants::C_CPPEDITOR,
|
m_actionHandler = new TextEditor::TextEditorActionHandler(CppEditor::Constants::C_CPPEDITOR,
|
||||||
TextEditor::TextEditorActionHandler::Format
|
TextEditor::TextEditorActionHandler::Format
|
||||||
| TextEditor::TextEditorActionHandler::UnCommentSelection
|
| TextEditor::TextEditorActionHandler::UnCommentSelection
|
||||||
| TextEditor::TextEditorActionHandler::UnCollapseAll);
|
| TextEditor::TextEditorActionHandler::UnCollapseAll
|
||||||
|
| TextEditor::TextEditorActionHandler::FollowSymbolUnderCursor);
|
||||||
|
|
||||||
m_actionHandler->initializeActions();
|
m_actionHandler->initializeActions();
|
||||||
|
|
||||||
@@ -355,14 +351,6 @@ void CppPlugin::switchDeclarationDefinition()
|
|||||||
editor->switchDeclarationDefinition();
|
editor->switchDeclarationDefinition();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppPlugin::jumpToDefinition()
|
|
||||||
{
|
|
||||||
Core::EditorManager *em = Core::EditorManager::instance();
|
|
||||||
CPPEditorWidget *editor = qobject_cast<CPPEditorWidget*>(em->currentEditor()->widget());
|
|
||||||
if (editor)
|
|
||||||
editor->jumpToDefinition();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CppPlugin::renameSymbolUnderCursor()
|
void CppPlugin::renameSymbolUnderCursor()
|
||||||
{
|
{
|
||||||
Core::EditorManager *em = Core::EditorManager::instance();
|
Core::EditorManager *em = Core::EditorManager::instance();
|
||||||
|
@@ -83,7 +83,6 @@ public slots:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void switchDeclarationDefinition();
|
void switchDeclarationDefinition();
|
||||||
void jumpToDefinition();
|
|
||||||
void renameSymbolUnderCursor();
|
void renameSymbolUnderCursor();
|
||||||
void onTaskStarted(const QString &type);
|
void onTaskStarted(const QString &type);
|
||||||
void onAllTasksFinished(const QString &type);
|
void onAllTasksFinished(const QString &type);
|
||||||
|
@@ -78,8 +78,6 @@
|
|||||||
#include <utils/treewidgetcolumnstretcher.h>
|
#include <utils/treewidgetcolumnstretcher.h>
|
||||||
#include <utils/stylehelper.h>
|
#include <utils/stylehelper.h>
|
||||||
|
|
||||||
#include <cppeditor/cppeditorconstants.h>
|
|
||||||
|
|
||||||
#include <cpptools/cpptoolsconstants.h>
|
#include <cpptools/cpptoolsconstants.h>
|
||||||
|
|
||||||
#include <QAbstractTableModel>
|
#include <QAbstractTableModel>
|
||||||
@@ -895,7 +893,7 @@ FakeVimPluginPrivate::FakeVimPluginPrivate(FakeVimPlugin *plugin)
|
|||||||
QRegExp("^(cN(ext)?|cp(revious)?)!?( (.*))?$");
|
QRegExp("^(cN(ext)?|cp(revious)?)!?( (.*))?$");
|
||||||
defaultExCommandMap()["Coreplugin.OutputPane.nextitem"] =
|
defaultExCommandMap()["Coreplugin.OutputPane.nextitem"] =
|
||||||
QRegExp("^cn(ext)?!?( (.*))?$");
|
QRegExp("^cn(ext)?!?( (.*))?$");
|
||||||
defaultExCommandMap()[CppEditor::Constants::JUMP_TO_DEFINITION] =
|
defaultExCommandMap()[TextEditor::Constants::FOLLOW_SYMBOL_UNDER_CURSOR] =
|
||||||
QRegExp("^tag?$");
|
QRegExp("^tag?$");
|
||||||
defaultExCommandMap()[Core::Constants::GO_BACK] =
|
defaultExCommandMap()[Core::Constants::GO_BACK] =
|
||||||
QRegExp("^pop?$");
|
QRegExp("^pop?$");
|
||||||
|
@@ -1387,11 +1387,6 @@ TextEditor::BaseTextEditorWidget::Link QmlJSTextEditorWidget::findLinkAt(const Q
|
|||||||
return Link();
|
return Link();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlJSTextEditorWidget::followSymbolUnderCursor()
|
|
||||||
{
|
|
||||||
openLink(findLinkAt(textCursor()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void QmlJSTextEditorWidget::findUsages()
|
void QmlJSTextEditorWidget::findUsages()
|
||||||
{
|
{
|
||||||
m_findReferences->findUsages(editorDocument()->fileName(), textCursor().position());
|
m_findReferences->findUsages(editorDocument()->fileName(), textCursor().position());
|
||||||
|
@@ -176,7 +176,6 @@ public slots:
|
|||||||
void reparseDocumentNow();
|
void reparseDocumentNow();
|
||||||
void updateSemanticInfo();
|
void updateSemanticInfo();
|
||||||
void updateSemanticInfoNow();
|
void updateSemanticInfoNow();
|
||||||
void followSymbolUnderCursor();
|
|
||||||
void findUsages();
|
void findUsages();
|
||||||
void renameUsages();
|
void renameUsages();
|
||||||
void showContextPane();
|
void showContextPane();
|
||||||
|
@@ -51,7 +51,6 @@ const char TASK_SEARCH[] = "QmlJSEditor.TaskSearch";
|
|||||||
const char SETTINGS_CATEGORY_QML[] = "J.QtQuick";
|
const char SETTINGS_CATEGORY_QML[] = "J.QtQuick";
|
||||||
const char SETTINGS_TR_CATEGORY_QML[] = QT_TRANSLATE_NOOP("QmlJSEditor", "Qt Quick");
|
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 FIND_USAGES[] = "QmlJSEditor.FindUsages";
|
||||||
const char RENAME_USAGES[] = "QmlJSEditor.RenameUsages";
|
const char RENAME_USAGES[] = "QmlJSEditor.RenameUsages";
|
||||||
const char RUN_SEMANTIC_SCAN[] = "QmlJSEditor.RunSemanticScan";
|
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,
|
m_actionHandler = new TextEditor::TextEditorActionHandler(QmlJSEditor::Constants::C_QMLJSEDITOR_ID,
|
||||||
TextEditor::TextEditorActionHandler::Format
|
TextEditor::TextEditorActionHandler::Format
|
||||||
| TextEditor::TextEditorActionHandler::UnCommentSelection
|
| TextEditor::TextEditorActionHandler::UnCommentSelection
|
||||||
| TextEditor::TextEditorActionHandler::UnCollapseAll);
|
| TextEditor::TextEditorActionHandler::UnCollapseAll
|
||||||
|
| TextEditor::TextEditorActionHandler::FollowSymbolUnderCursor);
|
||||||
m_actionHandler->initializeActions();
|
m_actionHandler->initializeActions();
|
||||||
|
|
||||||
Core::ActionManager *am = Core::ICore::actionManager();
|
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));
|
qmlToolsMenu->addAction(createSeparator(am, this, globalContext, QmlJSEditor::Constants::SEPARATOR3));
|
||||||
|
|
||||||
Core::Command *cmd;
|
Core::Command *cmd;
|
||||||
QAction *followSymbolUnderCursorAction = new QAction(tr("Follow Symbol Under Cursor"), this);
|
cmd = am->command(TextEditor::Constants::FOLLOW_SYMBOL_UNDER_CURSOR);
|
||||||
cmd = am->registerAction(followSymbolUnderCursorAction, Constants::FOLLOW_SYMBOL_UNDER_CURSOR, context);
|
|
||||||
cmd->setDefaultKeySequence(QKeySequence(Qt::Key_F2));
|
|
||||||
connect(followSymbolUnderCursorAction, SIGNAL(triggered()), this, SLOT(followSymbolUnderCursor()));
|
|
||||||
contextMenu->addAction(cmd);
|
contextMenu->addAction(cmd);
|
||||||
qmlToolsMenu->addAction(cmd);
|
qmlToolsMenu->addAction(cmd);
|
||||||
|
|
||||||
@@ -294,14 +292,6 @@ Utils::JsonSchemaManager *QmlJSEditorPlugin::jsonManager() const
|
|||||||
return m_jsonManager.data();
|
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()
|
void QmlJSEditorPlugin::findUsages()
|
||||||
{
|
{
|
||||||
Core::EditorManager *em = Core::EditorManager::instance();
|
Core::EditorManager *em = Core::EditorManager::instance();
|
||||||
|
@@ -100,7 +100,6 @@ public:
|
|||||||
Utils::JsonSchemaManager *jsonManager() const;
|
Utils::JsonSchemaManager *jsonManager() const;
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void followSymbolUnderCursor();
|
|
||||||
void findUsages();
|
void findUsages();
|
||||||
void renameUsages();
|
void renameUsages();
|
||||||
void reformatFile();
|
void reformatFile();
|
||||||
|
@@ -233,11 +233,6 @@ void ProFileEditorWidget::setFontSettings(const TextEditor::FontSettings &fs)
|
|||||||
highlighter->rehighlight();
|
highlighter->rehighlight();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProFileEditorWidget::jumpToFile()
|
|
||||||
{
|
|
||||||
openLink(findLinkAt(textCursor()));
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// ProFileDocument
|
// ProFileDocument
|
||||||
//
|
//
|
||||||
|
@@ -88,7 +88,6 @@ protected:
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual void setFontSettings(const TextEditor::FontSettings &);
|
virtual void setFontSettings(const TextEditor::FontSettings &);
|
||||||
void jumpToFile();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ProFileEditorFactory *m_factory;
|
ProFileEditorFactory *m_factory;
|
||||||
|
@@ -63,7 +63,6 @@ const char BUILDSUBDIR[] = "Qt4Builder.BuildSubDir";
|
|||||||
const char REBUILDSUBDIR[] = "Qt4Builder.RebuildSubDir";
|
const char REBUILDSUBDIR[] = "Qt4Builder.RebuildSubDir";
|
||||||
const char CLEANSUBDIR[] = "Qt4Builder.CleanSubDir";
|
const char CLEANSUBDIR[] = "Qt4Builder.CleanSubDir";
|
||||||
const char ADDLIBRARY[] = "Qt4.AddLibrary";
|
const char ADDLIBRARY[] = "Qt4.AddLibrary";
|
||||||
const char JUMP_TO_FILE[] = "Qt4.JumpToFile";
|
|
||||||
const char SEPARATOR[] = "Qt4.Separator";
|
const char SEPARATOR[] = "Qt4.Separator";
|
||||||
|
|
||||||
// Tasks
|
// Tasks
|
||||||
|
@@ -129,7 +129,8 @@ bool Qt4ProjectManagerPlugin::initialize(const QStringList &arguments, QString *
|
|||||||
|
|
||||||
TextEditor::TextEditorActionHandler *editorHandler
|
TextEditor::TextEditorActionHandler *editorHandler
|
||||||
= new TextEditor::TextEditorActionHandler(Constants::C_PROFILEEDITOR,
|
= new TextEditor::TextEditorActionHandler(Constants::C_PROFILEEDITOR,
|
||||||
TextEditor::TextEditorActionHandler::UnCommentSelection);
|
TextEditor::TextEditorActionHandler::UnCommentSelection
|
||||||
|
| TextEditor::TextEditorActionHandler::JumpToFileUnderCursor);
|
||||||
|
|
||||||
m_proFileEditorFactory = new ProFileEditorFactory(m_qt4ProjectManager, editorHandler);
|
m_proFileEditorFactory = new ProFileEditorFactory(m_qt4ProjectManager, editorHandler);
|
||||||
addObject(m_proFileEditorFactory);
|
addObject(m_proFileEditorFactory);
|
||||||
@@ -238,12 +239,7 @@ bool Qt4ProjectManagerPlugin::initialize(const QStringList &arguments, QString *
|
|||||||
|
|
||||||
Core::Context proFileEditorContext = Core::Context(Qt4ProjectManager::Constants::C_PROFILEEDITOR);
|
Core::Context proFileEditorContext = Core::Context(Qt4ProjectManager::Constants::C_PROFILEEDITOR);
|
||||||
|
|
||||||
QAction *jumpToFile = new QAction(tr("Jump to File Under Cursor"), this);
|
command = am->command(TextEditor::Constants::JUMP_TO_FILE_UNDER_CURSOR);
|
||||||
command = am->registerAction(jumpToFile,
|
|
||||||
Constants::JUMP_TO_FILE, proFileEditorContext);
|
|
||||||
command->setDefaultKeySequence(QKeySequence(Qt::Key_F2));
|
|
||||||
connect(jumpToFile, SIGNAL(triggered()),
|
|
||||||
this, SLOT(jumpToFile()));
|
|
||||||
contextMenu->addAction(command);
|
contextMenu->addAction(command);
|
||||||
|
|
||||||
m_addLibraryAction = new QAction(tr("Add Library..."), this);
|
m_addLibraryAction = new QAction(tr("Add Library..."), this);
|
||||||
@@ -369,12 +365,4 @@ void Qt4ProjectManagerPlugin::buildStateChanged(ProjectExplorer::Project *pro)
|
|||||||
updateRunQMakeAction();
|
updateRunQMakeAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Qt4ProjectManagerPlugin::jumpToFile()
|
|
||||||
{
|
|
||||||
Core::EditorManager *em = Core::EditorManager::instance();
|
|
||||||
ProFileEditorWidget *editor = qobject_cast<ProFileEditorWidget*>(em->currentEditor()->widget());
|
|
||||||
if (editor)
|
|
||||||
editor->jumpToFile();
|
|
||||||
}
|
|
||||||
|
|
||||||
Q_EXPORT_PLUGIN(Qt4ProjectManagerPlugin)
|
Q_EXPORT_PLUGIN(Qt4ProjectManagerPlugin)
|
||||||
|
@@ -75,7 +75,6 @@ private slots:
|
|||||||
void updateRunQMakeAction();
|
void updateRunQMakeAction();
|
||||||
void currentNodeChanged(ProjectExplorer::Node *node);
|
void currentNodeChanged(ProjectExplorer::Node *node);
|
||||||
void buildStateChanged(ProjectExplorer::Project *pro);
|
void buildStateChanged(ProjectExplorer::Project *pro);
|
||||||
void jumpToFile();
|
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
void testAbldOutputParsers_data();
|
void testAbldOutputParsers_data();
|
||||||
|
@@ -1074,6 +1074,11 @@ void BaseTextEditorWidget::unindent()
|
|||||||
indentOrUnindent(false);
|
indentOrUnindent(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BaseTextEditorWidget::openLinkUnderCursor()
|
||||||
|
{
|
||||||
|
openLink(findLinkAt(textCursor()));
|
||||||
|
}
|
||||||
|
|
||||||
void BaseTextEditorWidget::moveLineUpDown(bool up)
|
void BaseTextEditorWidget::moveLineUpDown(bool up)
|
||||||
{
|
{
|
||||||
QTextCursor cursor = textCursor();
|
QTextCursor cursor = textCursor();
|
||||||
|
@@ -326,6 +326,8 @@ public slots:
|
|||||||
void indent();
|
void indent();
|
||||||
void unindent();
|
void unindent();
|
||||||
|
|
||||||
|
void openLinkUnderCursor();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void changed();
|
void changed();
|
||||||
|
|
||||||
|
@@ -105,6 +105,8 @@ TextEditorActionHandler::TextEditorActionHandler(const char *context,
|
|||||||
m_lowerCaseSelectionAction(0),
|
m_lowerCaseSelectionAction(0),
|
||||||
m_indentAction(0),
|
m_indentAction(0),
|
||||||
m_unindentAction(0),
|
m_unindentAction(0),
|
||||||
|
m_followSymbolAction(0),
|
||||||
|
m_jumpToFileAction(0),
|
||||||
m_optionalActions(optionalActions),
|
m_optionalActions(optionalActions),
|
||||||
m_currentEditor(0),
|
m_currentEditor(0),
|
||||||
m_contextId(context),
|
m_contextId(context),
|
||||||
@@ -395,6 +397,16 @@ void TextEditorActionHandler::createActions()
|
|||||||
command = am->registerAction(m_unindentAction, Constants::UNINDENT, m_contextId, true);
|
command = am->registerAction(m_unindentAction, Constants::UNINDENT, m_contextId, true);
|
||||||
connect(m_unindentAction, SIGNAL(triggered()), this, SLOT(unindent()));
|
connect(m_unindentAction, SIGNAL(triggered()), this, SLOT(unindent()));
|
||||||
|
|
||||||
|
m_followSymbolAction = new QAction(tr("Follow Symbol Under Cursor"), this);
|
||||||
|
command = am->registerAction(m_followSymbolAction, Constants::FOLLOW_SYMBOL_UNDER_CURSOR, m_contextId, true);
|
||||||
|
command->setDefaultKeySequence(QKeySequence(Qt::Key_F2));
|
||||||
|
connect(m_followSymbolAction, SIGNAL(triggered()), this, SLOT(openLinkUnderCursor()));
|
||||||
|
|
||||||
|
m_jumpToFileAction = new QAction(tr("Jump To File Under Cursor"), this);
|
||||||
|
command = am->registerAction(m_jumpToFileAction, Constants::JUMP_TO_FILE_UNDER_CURSOR, m_contextId, true);
|
||||||
|
command->setDefaultKeySequence(QKeySequence(Qt::Key_F2));
|
||||||
|
connect(m_jumpToFileAction, SIGNAL(triggered()), this, SLOT(openLinkUnderCursor()));
|
||||||
|
|
||||||
QAction *a = 0;
|
QAction *a = 0;
|
||||||
a = new QAction(tr("Go to Line Start"), this);
|
a = new QAction(tr("Go to Line Start"), this);
|
||||||
command = am->registerAction(a, Constants::GOTO_LINE_START, m_contextId, true);
|
command = am->registerAction(a, Constants::GOTO_LINE_START, m_contextId, true);
|
||||||
@@ -508,6 +520,8 @@ void TextEditorActionHandler::updateActions(UpdateMode um)
|
|||||||
a->setEnabled(um != ReadOnlyMode);
|
a->setEnabled(um != ReadOnlyMode);
|
||||||
m_formatAction->setEnabled((m_optionalActions & Format) && um != ReadOnlyMode);
|
m_formatAction->setEnabled((m_optionalActions & Format) && um != ReadOnlyMode);
|
||||||
m_unCommentSelectionAction->setEnabled((m_optionalActions & UnCommentSelection) && um != ReadOnlyMode);
|
m_unCommentSelectionAction->setEnabled((m_optionalActions & UnCommentSelection) && um != ReadOnlyMode);
|
||||||
|
m_followSymbolAction->setEnabled(m_optionalActions & FollowSymbolUnderCursor);
|
||||||
|
m_jumpToFileAction->setEnabled(m_optionalActions & JumpToFileUnderCursor);
|
||||||
|
|
||||||
m_unfoldAllAction->setEnabled((m_optionalActions & UnCollapseAll));
|
m_unfoldAllAction->setEnabled((m_optionalActions & UnCollapseAll));
|
||||||
m_visualizeWhitespaceAction->setChecked(m_currentEditor->displaySettings().m_visualizeWhitespace);
|
m_visualizeWhitespaceAction->setChecked(m_currentEditor->displaySettings().m_visualizeWhitespace);
|
||||||
@@ -632,6 +646,7 @@ FUNCTION(insertLineAbove)
|
|||||||
FUNCTION(insertLineBelow)
|
FUNCTION(insertLineBelow)
|
||||||
FUNCTION(indent)
|
FUNCTION(indent)
|
||||||
FUNCTION(unindent)
|
FUNCTION(unindent)
|
||||||
|
FUNCTION(openLinkUnderCursor)
|
||||||
|
|
||||||
FUNCTION(gotoLineStart)
|
FUNCTION(gotoLineStart)
|
||||||
FUNCTION(gotoLineStartWithSelection)
|
FUNCTION(gotoLineStartWithSelection)
|
||||||
|
@@ -63,7 +63,9 @@ public:
|
|||||||
None = 0,
|
None = 0,
|
||||||
Format = 1,
|
Format = 1,
|
||||||
UnCommentSelection = 2,
|
UnCommentSelection = 2,
|
||||||
UnCollapseAll = 4
|
UnCollapseAll = 4,
|
||||||
|
FollowSymbolUnderCursor = 8,
|
||||||
|
JumpToFileUnderCursor = 16
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit TextEditorActionHandler(const char *context, uint optionalActions = None);
|
explicit TextEditorActionHandler(const char *context, uint optionalActions = None);
|
||||||
@@ -141,6 +143,7 @@ private slots:
|
|||||||
void updateCurrentEditor(Core::IEditor *editor);
|
void updateCurrentEditor(Core::IEditor *editor);
|
||||||
void indent();
|
void indent();
|
||||||
void unindent();
|
void unindent();
|
||||||
|
void openLinkUnderCursor();
|
||||||
|
|
||||||
void gotoLineStart();
|
void gotoLineStart();
|
||||||
void gotoLineStartWithSelection();
|
void gotoLineStartWithSelection();
|
||||||
@@ -212,6 +215,8 @@ private:
|
|||||||
QAction *m_lowerCaseSelectionAction;
|
QAction *m_lowerCaseSelectionAction;
|
||||||
QAction *m_indentAction;
|
QAction *m_indentAction;
|
||||||
QAction *m_unindentAction;
|
QAction *m_unindentAction;
|
||||||
|
QAction *m_followSymbolAction;
|
||||||
|
QAction *m_jumpToFileAction;
|
||||||
QList<QAction *> m_modifyingActions;
|
QList<QAction *> m_modifyingActions;
|
||||||
|
|
||||||
uint m_optionalActions;
|
uint m_optionalActions;
|
||||||
|
@@ -105,6 +105,8 @@ const char CIRCULAR_PASTE[] = "TextEditor.CircularPaste";
|
|||||||
const char SWITCH_UTF8BOM[] = "TextEditor.SwitchUtf8bom";
|
const char SWITCH_UTF8BOM[] = "TextEditor.SwitchUtf8bom";
|
||||||
const char INDENT[] = "TextEditor.Indent";
|
const char INDENT[] = "TextEditor.Indent";
|
||||||
const char UNINDENT[] = "TextEditor.Unindent";
|
const char UNINDENT[] = "TextEditor.Unindent";
|
||||||
|
const char FOLLOW_SYMBOL_UNDER_CURSOR[] = "TextEditor.FollowSymbolUnderCursor";
|
||||||
|
const char JUMP_TO_FILE_UNDER_CURSOR[] = "TextEditor.JumpToFileUnderCursor";
|
||||||
|
|
||||||
// Text color and style categories
|
// Text color and style categories
|
||||||
const char C_TEXT[] = "Text";
|
const char C_TEXT[] = "Text";
|
||||||
|
Reference in New Issue
Block a user