ui: Added "Show Definition in IDE" action to graph context menu for nodes (issue #687)
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include "ApplicationSettings.h"
|
||||
#include "FileInfo.h"
|
||||
#include "logging.h"
|
||||
#include "MessageMoveIDECursor.h"
|
||||
#include "MessageStatus.h"
|
||||
#include "TextAccess.h"
|
||||
#include "tracing.h"
|
||||
@@ -311,6 +312,7 @@ void CodeController::handleMessage(MessageCodeShowDefinition* message)
|
||||
}
|
||||
|
||||
size_t lineNumber = 1;
|
||||
size_t columnNumber = 1;
|
||||
FilePath filePath;
|
||||
|
||||
// use first scope location for nodeId, otherwise first location
|
||||
@@ -334,6 +336,7 @@ void CodeController::handleMessage(MessageCodeShowDefinition* message)
|
||||
|
||||
filePath = location->getFilePath();
|
||||
lineNumber = location->getLineNumber();
|
||||
columnNumber = location->getColumnNumber();
|
||||
addedLocation = true;
|
||||
return;
|
||||
}
|
||||
@@ -348,6 +351,7 @@ void CodeController::handleMessage(MessageCodeShowDefinition* message)
|
||||
|
||||
filePath = location->getFilePath();
|
||||
lineNumber = location->getStartLocation()->getLineNumber();
|
||||
columnNumber = location->getStartLocation()->getColumnNumber();
|
||||
}
|
||||
|
||||
collection = filteredCollection;
|
||||
@@ -357,6 +361,12 @@ void CodeController::handleMessage(MessageCodeShowDefinition* message)
|
||||
filePath = collection->getSourceLocationFiles().begin()->second->getFilePath();
|
||||
}
|
||||
|
||||
if (message->inIDE)
|
||||
{
|
||||
MessageMoveIDECursor(filePath, lineNumber, columnNumber).dispatch();
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<CodeSnippetParams> snippets = getSnippetsForFile(collection->getSourceLocationFiles().begin()->second);
|
||||
if (snippets.size() != 1)
|
||||
{
|
||||
|
||||
@@ -14,8 +14,9 @@ public:
|
||||
return "MessageCodeShowDefinition";
|
||||
}
|
||||
|
||||
MessageCodeShowDefinition(Id nodeId)
|
||||
MessageCodeShowDefinition(Id nodeId, bool inIDE = false)
|
||||
: nodeId(nodeId)
|
||||
, inIDE(inIDE)
|
||||
{
|
||||
setSchedulerId(TabId::currentTab());
|
||||
}
|
||||
@@ -26,6 +27,7 @@ public:
|
||||
}
|
||||
|
||||
const Id nodeId;
|
||||
const bool inIDE;
|
||||
};
|
||||
|
||||
#endif // MESSAGE_CODE_SHOW_DEFINITION_H
|
||||
|
||||
@@ -76,9 +76,17 @@ QtGraphicsView::QtGraphicsView(QWidget* parent)
|
||||
m_expandAction->setToolTip("Show unconnected members of the node");
|
||||
connect(m_expandAction, &QAction::triggered, this, &QtGraphicsView::expandNode);
|
||||
|
||||
m_showDefinitionAction = new QAction("Show Definition (Ctrl + Left Click)", this);
|
||||
m_showInIDEAction = new QAction("Show Definition in IDE (Ctrl + Left Click)", this);
|
||||
#if defined(Q_OS_MAC)
|
||||
m_showDefinitionAction->setText("Show Definition (Cmd + Left Click)");
|
||||
m_showInIDEAction->setText("Show Definition in IDE (Cmd + Left Click)");
|
||||
#endif
|
||||
m_showInIDEAction->setStatusTip("Show definition of this symbol in the IDE (via plug-in)");
|
||||
m_showInIDEAction->setToolTip("Show definition of this symbol in the IDE (via plug-in)");
|
||||
connect(m_showInIDEAction, &QAction::triggered, this, &QtGraphicsView::showInIDE);
|
||||
|
||||
m_showDefinitionAction = new QAction("Show Definition (Ctrl + Alt + Left Click)", this);
|
||||
#if defined(Q_OS_MAC)
|
||||
m_showDefinitionAction->setText("Show Definition (Cmd + Alt + Left Click)");
|
||||
#endif
|
||||
m_showDefinitionAction->setStatusTip("Show definition of this symbol in the code");
|
||||
m_showDefinitionAction->setToolTip("Show definition of this symbol in the code");
|
||||
@@ -419,6 +427,7 @@ void QtGraphicsView::contextMenuEvent(QContextMenuEvent* event)
|
||||
m_openInTabAction->setEnabled(m_openInTabNodeId);
|
||||
m_collapseAction->setEnabled(m_collapseNodeId);
|
||||
m_expandAction->setEnabled(m_expandNodeId);
|
||||
m_showInIDEAction->setEnabled(m_hideNodeId);
|
||||
m_showDefinitionAction->setEnabled(m_hideNodeId);
|
||||
m_hideNodeAction->setEnabled(m_hideNodeId);
|
||||
m_hideEdgeAction->setEnabled(m_hideEdgeId);
|
||||
@@ -433,6 +442,9 @@ void QtGraphicsView::contextMenuEvent(QContextMenuEvent* event)
|
||||
|
||||
menu.addSeparator();
|
||||
|
||||
menu.addAction(m_showDefinitionAction);
|
||||
menu.addAction(m_showInIDEAction);
|
||||
|
||||
if (m_collapseNodeId)
|
||||
{
|
||||
menu.addAction(m_collapseAction);
|
||||
@@ -442,7 +454,6 @@ void QtGraphicsView::contextMenuEvent(QContextMenuEvent* event)
|
||||
menu.addAction(m_expandAction);
|
||||
}
|
||||
|
||||
menu.addAction(m_showDefinitionAction);
|
||||
menu.addAction(m_hideNodeAction);
|
||||
menu.addAction(m_hideEdgeAction);
|
||||
menu.addAction(m_bookmarkNodeAction);
|
||||
@@ -616,6 +627,11 @@ void QtGraphicsView::expandNode()
|
||||
MessageGraphNodeExpand(m_expandNodeId, true).dispatch();
|
||||
}
|
||||
|
||||
void QtGraphicsView::showInIDE()
|
||||
{
|
||||
MessageCodeShowDefinition(m_hideNodeId, true).dispatch();
|
||||
}
|
||||
|
||||
void QtGraphicsView::showDefinition()
|
||||
{
|
||||
MessageCodeShowDefinition(m_hideNodeId).dispatch();
|
||||
|
||||
@@ -63,6 +63,7 @@ private slots:
|
||||
void collapseNode();
|
||||
void expandNode();
|
||||
|
||||
void showInIDE();
|
||||
void showDefinition();
|
||||
void hideNode();
|
||||
void hideEdge();
|
||||
@@ -109,6 +110,7 @@ private:
|
||||
QAction* m_copyNodeNameAction;
|
||||
QAction* m_collapseAction;
|
||||
QAction* m_expandAction;
|
||||
QAction* m_showInIDEAction;
|
||||
QAction* m_showDefinitionAction;
|
||||
QAction* m_hideNodeAction;
|
||||
QAction* m_hideEdgeAction;
|
||||
|
||||
@@ -417,17 +417,17 @@ void QtGraphNode::onCollapseExpand()
|
||||
}
|
||||
}
|
||||
|
||||
void QtGraphNode::onShowDefinition()
|
||||
void QtGraphNode::onShowDefinition(bool inIDE)
|
||||
{
|
||||
Id tokenId = getTokenId();
|
||||
|
||||
if (tokenId)
|
||||
{
|
||||
MessageCodeShowDefinition(tokenId).dispatch();
|
||||
MessageCodeShowDefinition(tokenId, inIDE).dispatch();
|
||||
}
|
||||
else if (getParent())
|
||||
{
|
||||
getParent()->onShowDefinition();
|
||||
getParent()->onShowDefinition(inIDE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ public:
|
||||
|
||||
void onHide();
|
||||
void onCollapseExpand();
|
||||
void onShowDefinition();
|
||||
void onShowDefinition(bool inIDE);
|
||||
|
||||
virtual void moved(const Vec2i& oldPosition);
|
||||
|
||||
|
||||
@@ -50,17 +50,21 @@ void QtGraphNodeComponentClickable::nodeMouseReleaseEvent(QGraphicsSceneMouseEve
|
||||
|
||||
if (!m_mouseMoved)
|
||||
{
|
||||
if (event->modifiers() & Qt::AltModifier && event->button() == Qt::LeftButton)
|
||||
{
|
||||
m_graphNode->onHide();
|
||||
}
|
||||
else if (event->modifiers() & Qt::ShiftModifier && event->button() == Qt::LeftButton)
|
||||
if (event->modifiers() & Qt::ShiftModifier && event->button() == Qt::LeftButton)
|
||||
{
|
||||
m_graphNode->onCollapseExpand();
|
||||
}
|
||||
else if (event->modifiers() & Qt::ControlModifier && event->modifiers() & Qt::AltModifier && event->button() == Qt::LeftButton)
|
||||
{
|
||||
m_graphNode->onShowDefinition(false);
|
||||
}
|
||||
else if (event->modifiers() & Qt::ControlModifier && event->button() == Qt::LeftButton)
|
||||
{
|
||||
m_graphNode->onShowDefinition();
|
||||
m_graphNode->onShowDefinition(true);
|
||||
}
|
||||
else if (event->modifiers() & Qt::AltModifier && event->button() == Qt::LeftButton)
|
||||
{
|
||||
m_graphNode->onHide();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user