ui: Added custom tooltipping to code and graph (issue #195)
* Tooltips show node type with access specifier, reference count and fully qualified name * Fields and global variables include the type name * Methods and functinos show whole signature. Gets broken into multiple lines if too long. Included changes: * Upgraded to C++14 * fixed clang warnings * Pass location of .srctrlprj file to build.sh script to load on launch * Split off QtCodeField for showing highlighted and annotated code fom QtCodeArea * removed TokenComponentSignature * added TaskDecoratorDelay bug id = 195
This commit is contained in:
@@ -16,8 +16,11 @@
|
||||
#include "utility/messaging/type/MessageFocusIn.h"
|
||||
#include "utility/messaging/type/MessageFocusOut.h"
|
||||
#include "utility/messaging/type/MessageGraphNodeBundleSplit.h"
|
||||
#include "utility/messaging/type/MessageTooltipShow.h"
|
||||
#include "utility/messaging/type/MessageTooltipHide.h"
|
||||
#include "utility/utility.h"
|
||||
|
||||
QtGraphEdge* QtGraphEdge::s_focusedEdge = nullptr;
|
||||
QtGraphEdge* QtGraphEdge::s_focusedBezierEdge = nullptr;
|
||||
|
||||
QtGraphEdge::QtGraphEdge(
|
||||
@@ -52,6 +55,7 @@ QtGraphEdge::QtGraphEdge(
|
||||
m_fromActive = m_owner.lock()->getIsActive();
|
||||
m_toActive = m_target.lock()->getIsActive();
|
||||
|
||||
s_focusedEdge = nullptr;
|
||||
s_focusedBezierEdge = nullptr;
|
||||
}
|
||||
|
||||
@@ -85,26 +89,7 @@ void QtGraphEdge::updateLine()
|
||||
return;
|
||||
}
|
||||
|
||||
Edge::EdgeType type;
|
||||
if (getData())
|
||||
{
|
||||
type = getData()->getType();
|
||||
}
|
||||
else
|
||||
{
|
||||
type = Edge::EDGE_AGGREGATION;
|
||||
}
|
||||
|
||||
QString toolTip = Edge::getReadableTypeString(type).c_str();
|
||||
if (type == Edge::EDGE_AGGREGATION)
|
||||
{
|
||||
toolTip += ": " + QString::number(m_weight) + " edge";
|
||||
if (m_weight != 1)
|
||||
{
|
||||
toolTip += "s";
|
||||
}
|
||||
}
|
||||
|
||||
Edge::EdgeType type = (getData() ? getData()->getType() : Edge::EDGE_AGGREGATION);
|
||||
GraphViewStyle::EdgeStyle style = GraphViewStyle::getStyleForEdgeType(type, m_isActive | m_isFocused, false, m_isTrailEdge);
|
||||
|
||||
if (m_useBezier)
|
||||
@@ -130,10 +115,8 @@ void QtGraphEdge::updateLine()
|
||||
bezier->updateLine(ownerRect, rect, ownerParentRect, rect, style, m_weight, false);
|
||||
bezier->setRoute(route);
|
||||
bezier->setPivot(QtLineItemBase::PIVOT_MIDDLE);
|
||||
bezier->setToolTip(toolTip);
|
||||
|
||||
QtLineItemStraight* line = new QtLineItemStraight(this);
|
||||
line->setToolTip(toolTip);
|
||||
if (route == QtLineItemBase::ROUTE_HORIZONTAL)
|
||||
{
|
||||
line->updateLine(Vec2i(rect.x(), (rect.y() + rect.w()) / 2), Vec2i(rect.z(), (rect.y() + rect.w()) / 2), style);
|
||||
@@ -155,7 +138,6 @@ void QtGraphEdge::updateLine()
|
||||
style, m_weight, showArrow);
|
||||
bezier->setRoute(route);
|
||||
bezier->setPivot(QtLineItemBase::PIVOT_MIDDLE);
|
||||
bezier->setToolTip(toolTip);
|
||||
|
||||
if (owner->getLastParent() == target->getLastParent())
|
||||
{
|
||||
@@ -221,8 +203,6 @@ void QtGraphEdge::updateLine()
|
||||
owner->getBoundingRect(), target->getBoundingRect(),
|
||||
owner->getParentBoundingRect(), target->getParentBoundingRect(),
|
||||
style, m_weight, showArrow);
|
||||
|
||||
child->setToolTip(toolTip);
|
||||
}
|
||||
|
||||
this->setZValue(style.zValue);
|
||||
@@ -301,6 +281,22 @@ void QtGraphEdge::focusIn()
|
||||
{
|
||||
m_isFocused = true;
|
||||
updateLine();
|
||||
|
||||
if (s_focusedEdge == this)
|
||||
{
|
||||
Edge::EdgeType type = (getData() ? getData()->getType() : Edge::EDGE_AGGREGATION);
|
||||
|
||||
TooltipInfo info;
|
||||
info.title = Edge::getReadableTypeString(type);
|
||||
if (type == Edge::EDGE_AGGREGATION)
|
||||
{
|
||||
info.count = m_weight;
|
||||
info.countText = "edge";
|
||||
}
|
||||
info.offset = Vec2i(10, 20);
|
||||
|
||||
MessageTooltipShow(info, TOOLTIP_ORIGIN_GRAPH).dispatch();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -310,6 +306,11 @@ void QtGraphEdge::focusOut()
|
||||
{
|
||||
m_isFocused = false;
|
||||
updateLine();
|
||||
|
||||
if (s_focusedEdge == this)
|
||||
{
|
||||
MessageTooltipHide().dispatch();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -349,9 +350,11 @@ void QtGraphEdge::hoverEnterEvent(QGraphicsSceneHoverEvent* event)
|
||||
s_focusedBezierEdge = this;
|
||||
}
|
||||
|
||||
s_focusedEdge = this;
|
||||
|
||||
if (getData() && !m_useBezier)
|
||||
{
|
||||
MessageFocusIn(std::vector<Id>(1, getData()->getId())).dispatch();
|
||||
MessageFocusIn(std::vector<Id>(1, getData()->getId()), TOOLTIP_ORIGIN_GRAPH).dispatch();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -371,6 +374,8 @@ void QtGraphEdge::hoverLeaveEvent(QGraphicsSceneHoverEvent* event)
|
||||
{
|
||||
focusOut();
|
||||
}
|
||||
|
||||
s_focusedEdge = nullptr;
|
||||
}
|
||||
|
||||
void QtGraphEdge::setDirection(TokenComponentAggregation::Direction direction)
|
||||
|
||||
@@ -64,6 +64,9 @@ protected:
|
||||
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent* event);
|
||||
|
||||
private:
|
||||
// used to send tooltip message on focusIn(), because both focus messages are filtered out if sent close together
|
||||
static QtGraphEdge* s_focusedEdge;
|
||||
|
||||
// used to unfocus recent edge, because hover leave event is not always received for bezier edges
|
||||
static QtGraphEdge* s_focusedBezierEdge;
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include "utility/messaging/type/MessageGraphNodeMove.h"
|
||||
|
||||
#include "data/graph/token_component/TokenComponentFilePath.h"
|
||||
#include "data/graph/token_component/TokenComponentSignature.h"
|
||||
|
||||
QtGraphNodeData::QtGraphNodeData(const Node* data, const std::string& name, bool hasParent, bool childVisible, bool hasQualifier)
|
||||
: m_data(data)
|
||||
@@ -18,39 +17,6 @@ QtGraphNodeData::QtGraphNodeData(const Node* data, const std::string& name, bool
|
||||
this->setAcceptHoverEvents(true);
|
||||
|
||||
this->setName(name);
|
||||
|
||||
std::string toolTip = data->getReadableTypeString();
|
||||
if (!data->isDefined() && data->isType(Node::NODE_FILE))
|
||||
{
|
||||
toolTip = "incomplete " + toolTip;
|
||||
}
|
||||
else if (!data->isDefined() && !data->isType(Node::NODE_NON_INDEXED))
|
||||
{
|
||||
toolTip = "non-indexed " + toolTip;
|
||||
}
|
||||
else if (data->isImplicit())
|
||||
{
|
||||
toolTip = "implicit " + toolTip;
|
||||
}
|
||||
|
||||
if (data->isType(Node::NODE_FUNCTION | Node::NODE_METHOD))
|
||||
{
|
||||
TokenComponentSignature* sig = data->getComponent<TokenComponentSignature>();
|
||||
if (sig)
|
||||
{
|
||||
toolTip += ": " + sig->getSignature();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FilePath path = getFilePath();
|
||||
if (!path.empty())
|
||||
{
|
||||
toolTip += ": " + path.str();
|
||||
}
|
||||
}
|
||||
|
||||
this->setToolTip(QString::fromStdString(toolTip));
|
||||
}
|
||||
|
||||
QtGraphNodeData::~QtGraphNodeData()
|
||||
@@ -113,7 +79,7 @@ void QtGraphNodeData::updateStyle()
|
||||
|
||||
void QtGraphNodeData::hoverEnterEvent(QGraphicsSceneHoverEvent* event)
|
||||
{
|
||||
MessageFocusIn(std::vector<Id>(1, m_data->getId())).dispatch();
|
||||
MessageFocusIn(std::vector<Id>(1, m_data->getId()), TOOLTIP_ORIGIN_GRAPH).dispatch();
|
||||
}
|
||||
|
||||
void QtGraphNodeData::hoverLeaveEvent(QGraphicsSceneHoverEvent* event)
|
||||
|
||||
Reference in New Issue
Block a user