ui: Added expand and collapse node actions to graph view context menu

* expand/collapse node via graph view context menu
* also possible with Shift + Left Click
This commit is contained in:
Eberhard Graether
2018-08-05 19:49:18 +02:00
parent f9b43526f4
commit ae7b827b0c
7 changed files with 113 additions and 14 deletions
@@ -11,7 +11,9 @@
#include "qt/utility/utilityQt.h"
#include "qt/view/graphElements/nodeComponents/QtGraphNodeComponent.h"
#include "qt/view/graphElements/QtGraphEdge.h"
#include "qt/view/graphElements/QtGraphNodeExpandToggle.h"
#include "utility/messaging/type/code/MessageCodeShowDefinition.h"
#include "utility/messaging/type/MessageGraphNodeExpand.h"
#include "utility/messaging/type/MessageGraphNodeHide.h"
#include "utility/messaging/type/MessageGraphNodeMove.h"
#include "utility/ResourcePaths.h"
@@ -394,6 +396,23 @@ void QtGraphNode::onHide()
}
}
void QtGraphNode::onCollapseExpand()
{
for (auto subNode : getSubNodes())
{
if (subNode->isExpandToggleNode())
{
MessageGraphNodeExpand(getTokenId(), !dynamic_cast<QtGraphNodeExpandToggle*>(subNode)->isExpanded()).dispatch();
return;
}
}
if (getParent())
{
getParent()->onCollapseExpand();
}
}
void QtGraphNode::onShowDefinition()
{
Id tokenId = getTokenId();
@@ -95,8 +95,11 @@ public:
virtual void addSubNode(QtGraphNode* node);
virtual void onClick();
virtual void onHide();
virtual void onShowDefinition();
void onHide();
void onCollapseExpand();
void onShowDefinition();
virtual void moved(const Vec2i& oldPosition);
virtual void updateStyle() = 0;
@@ -89,3 +89,8 @@ void QtGraphNodeExpandToggle::updateStyle()
m_icon->setPixmap(utility::colorizePixmap(m_icon->pixmap(), style.color.icon.c_str()));
}
bool QtGraphNodeExpandToggle::isExpanded() const
{
return m_expanded;
}
@@ -19,6 +19,8 @@ public:
virtual void onClick();
virtual void updateStyle();
bool isExpanded() const;
protected:
virtual void matchName(const std::wstring& query, std::vector<QtGraphNode*>* matchedNodes) {}
@@ -39,6 +39,10 @@ void QtGraphNodeComponentClickable::nodeMouseReleaseEvent(QGraphicsSceneMouseEve
{
m_graphNode->onHide();
}
else if (event->modifiers() & Qt::ShiftModifier)
{
m_graphNode->onCollapseExpand();
}
else if (event->modifiers() & Qt::ControlModifier)
{
m_graphNode->onShowDefinition();