Files
Sourcetrail/src/app/qt/view/graphElements/QtGraphNodeBundle.cpp
T
Eberhard Graether f5f4eed509 ui: extended color scheme and added new color scheme bad_rainbow
* added color scheme template
* define fill, border, text, icon and hatching colors for each node with states normal and focus
* define colors for each edge with states normal and focus
* use default node and edge colors when no type specific ones are defined
* use normal colors for nodes and edges when no focused are defined
* allow nodes and edges to imitate look of others with "like" tag
* added style for bundle
* added style for count circle
2015-11-20 15:24:20 +01:00

70 lines
1.4 KiB
C++

#include "qt/view/graphElements/QtGraphNodeBundle.h"
#include <QBrush>
#include <QPen>
#include "utility/messaging/type/MessageGraphNodeBundleSplit.h"
#include "component/view/GraphViewStyle.h"
#include "qt/graphics/QtCountCircleItem.h"
QtGraphNodeBundle::QtGraphNodeBundle(Id tokenId, size_t nodeCount, std::string name)
: QtGraphNode()
, m_tokenId(tokenId)
{
this->setName(name);
m_circle = new QtCountCircleItem(this);
m_circle->setNumber(nodeCount);
this->setAcceptHoverEvents(true);
this->setToolTip("bundle");
}
QtGraphNodeBundle::~QtGraphNodeBundle()
{
}
bool QtGraphNodeBundle::isBundleNode() const
{
return true;
}
Id QtGraphNodeBundle::getTokenId() const
{
return m_tokenId;
}
void QtGraphNodeBundle::onClick()
{
MessageGraphNodeBundleSplit(m_tokenId).dispatch();
}
void QtGraphNodeBundle::updateStyle()
{
GraphViewStyle::NodeStyle style = GraphViewStyle::getStyleOfBundleNode(m_isHovering);
setStyle(style);
m_circle->setPosition(Vec2f(m_rect->rect().right() - 3, m_rect->rect().top() + 3));
GraphViewStyle::NodeStyle accessStyle = GraphViewStyle::getStyleOfCountCircle();
m_circle->setStyle(
accessStyle.color.fill.c_str(),
accessStyle.color.text.c_str(),
accessStyle.color.border.c_str(),
style.borderWidth
);
}
void QtGraphNodeBundle::hoverEnterEvent(QGraphicsSceneHoverEvent* event)
{
focusIn();
}
void QtGraphNodeBundle::hoverLeaveEvent(QGraphicsSceneHoverEvent* event)
{
focusOut();
}