ui: Hide nodes and edges from graph via context menu action or Alt + Click (issue #472)

* show all context menu actions, but disable unavailable
* added hide action to undo redo stack
This commit is contained in:
Eberhard Graether
2017-11-26 12:54:42 +01:00
parent 9e7e9176cb
commit 0d5c19db00
21 changed files with 402 additions and 87 deletions
@@ -16,6 +16,7 @@
#include "utility/messaging/type/MessageFocusIn.h"
#include "utility/messaging/type/MessageFocusOut.h"
#include "utility/messaging/type/MessageGraphNodeBundleSplit.h"
#include "utility/messaging/type/MessageGraphNodeHide.h"
#include "utility/messaging/type/MessageTooltipShow.h"
#include "utility/messaging/type/MessageTooltipHide.h"
#include "utility/utility.h"
@@ -80,6 +81,16 @@ QtGraphNode* QtGraphEdge::getTarget()
return m_target;
}
Id QtGraphEdge::getTokenId() const
{
if (getData())
{
return getData()->getId();
}
return 0;
}
void QtGraphEdge::updateLine()
{
QtGraphNode* owner = m_owner;
@@ -269,6 +280,16 @@ void QtGraphEdge::onClick()
}
}
void QtGraphEdge::onHide()
{
Id tokenId = getTokenId();
if (tokenId)
{
MessageGraphNodeHide(tokenId).dispatch();
}
}
void QtGraphEdge::focusIn()
{
if (!m_isFocused)
@@ -328,7 +349,14 @@ void QtGraphEdge::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
{
if (!m_mouseMoved)
{
this->onClick();
if (event->modifiers() & Qt::AltModifier)
{
this->onHide();
}
else
{
this->onClick();
}
}
}
@@ -35,6 +35,8 @@ public:
QtGraphNode* getOwner();
QtGraphNode* getTarget();
Id getTokenId() const;
void updateLine();
bool getIsActive() const;
@@ -44,6 +46,7 @@ public:
void setIsFocused(bool isFocused);
void onClick();
void onHide();
void focusIn();
void focusOut();
@@ -11,6 +11,7 @@
#include "qt/utility/utilityQt.h"
#include "qt/view/graphElements/nodeComponents/QtGraphNodeComponent.h"
#include "qt/view/graphElements/QtGraphEdge.h"
#include "utility/messaging/type/MessageGraphNodeHide.h"
#include "utility/ResourcePaths.h"
#include "utility/utilityString.h"
@@ -345,6 +346,20 @@ void QtGraphNode::onClick()
{
}
void QtGraphNode::onHide()
{
Id tokenId = getTokenId();
if (tokenId)
{
MessageGraphNodeHide(tokenId).dispatch();
}
else if (getParent())
{
getParent()->onHide();
}
}
void QtGraphNode::mousePressEvent(QGraphicsSceneMouseEvent* event)
{
event->ignore();
@@ -92,6 +92,7 @@ public:
virtual void addSubNode(QtGraphNode* node);
virtual void onClick();
virtual void onHide();
virtual void moved(const Vec2i& oldPosition);
virtual void updateStyle() = 0;
@@ -35,7 +35,14 @@ void QtGraphNodeComponentClickable::nodeMouseReleaseEvent(QGraphicsSceneMouseEve
{
if (!m_mouseMoved)
{
m_graphNode->onClick();
if (event->modifiers() & Qt::AltModifier)
{
m_graphNode->onHide();
}
else
{
m_graphNode->onClick();
}
event->accept();
}
}