Skip to content

Commit

Permalink
GUI: Enable Diagram item selection
Browse files Browse the repository at this point in the history
Selected items are filled with color.

Issue #133
  • Loading branch information
rakhimov committed Jul 25, 2017
1 parent 7130d7f commit 30784f9
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions gui/diagram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ Event::Event(model::Element *event, QGraphicsItem *parent)
{
m_labelConnection = QObject::connect(event, &model::Element::labelChanged,
[this] { update(); });
setFlag(QGraphicsItem::ItemIsSelectable, true);
}

Event::~Event() noexcept
Expand Down Expand Up @@ -85,10 +86,12 @@ QRectF Event::boundingRect() const
return QRectF(-labelBoxWidth / 2, 0, labelBoxWidth, m_baseHeight * h);
}

void Event::paint(QPainter *painter,
const QStyleOptionGraphicsItem * /*option*/,
void Event::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget * /*widget*/)
{
if (option->state & QStyle::State_Selected)
painter->setBrush(QColor("cyan"));

int w = units().width();
int h = units().height();
double labelBoxWidth = m_size.width() * w ;
Expand Down

0 comments on commit 30784f9

Please sign in to comment.