ClickableLabelItem.hpp
1 #pragma once
2 #include <score/graphics/TextItem.hpp>
3 
4 #include <QGraphicsItem>
5 #include <QString>
6 
7 #include <functional>
8 #include <verdigris>
9 
10 namespace score
11 {
12 class ModelMetadata;
13 }
14 class QGraphicsSceneHoverEvent;
15 class QGraphicsSceneMouseEvent;
16 
17 namespace Scenario
18 {
19 class SeparatorItem final : public QGraphicsItem
20 {
21 public:
22  SeparatorItem(QGraphicsItem* parent);
23 
24  // QGraphicsItem interface
25 public:
26  QRectF boundingRect() const override;
27  void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
28  override;
29 };
30 
31 class ClickableLabelItem final
32  : // public QObject,
34 {
35  W_OBJECT(ClickableLabelItem)
36 public:
37  using ClickHandler = std::function<void(ClickableLabelItem*)>;
39  score::ModelMetadata& interval, ClickHandler&& onClick, const QString& text,
40  QGraphicsItem* parent);
41 
42  int index() const;
43  void setIndex(int index);
44 
45 public:
46  void textChanged() W_SIGNAL(textChanged);
47 
48 protected:
49  void mousePressEvent(QGraphicsSceneMouseEvent* event) override;
50  void hoverEnterEvent(QGraphicsSceneHoverEvent* event) override;
51  void hoverLeaveEvent(QGraphicsSceneHoverEvent* event) override;
52 
53 private:
54  int m_index{-1};
55  ClickHandler m_onClick;
56 };
57 }
Definition: ClickableLabelItem.hpp:34
Definition: ClickableLabelItem.hpp:20
The ModelMetadata class.
Definition: ModelMetadata.hpp:22
Definition: TextItem.hpp:28
Main plug-in of score.
Definition: score-plugin-dataflow/Dataflow/PortItem.hpp:14
Base toolkit upon which the software is built.
Definition: Application.cpp:90