EventView.hpp
1 #pragma once
2 #include "ExecutionStatus.hpp"
3 
4 #include <Scenario/Document/Event/ConditionView.hpp>
5 #include <Scenario/Document/ScenarioDocument/ScenarioDocumentViewConstants.hpp>
6 #include <Scenario/Document/VerticalExtent.hpp>
7 
8 #include <score/model/ColorInterpolator.hpp>
9 #include <score/model/ColorReference.hpp>
10 #include <score/widgets/MimeData.hpp>
11 
12 #include <QGraphicsItem>
13 #include <QPoint>
14 #include <QRect>
15 #include <QString>
16 
17 #include <score_plugin_scenario_export.h>
18 
19 #include <verdigris>
20 class QGraphicsSceneDragDropEvent;
21 class QGraphicsSceneHoverEvent;
22 class QGraphicsSceneMouseEvent;
23 class QMimeData;
24 class QPainter;
25 class QStyleOptionGraphicsItem;
26 class QWidget;
27 
28 namespace Scenario
29 {
30 class ConditionView;
31 class EventPresenter;
32 class SCORE_PLUGIN_SCENARIO_EXPORT EventView final
33  : public QObject
34  , public QGraphicsItem
35 {
36  W_OBJECT(EventView)
37  Q_INTERFACES(QGraphicsItem)
38 
39 public:
40  EventView(EventPresenter& presenter, QGraphicsItem* parent);
41  ~EventView() override;
42 
43  static const constexpr int Type = ItemType::Event;
44  int type() const final override { return Type; }
45 
46  const EventPresenter& presenter() const { return m_presenter; }
47 
48  QRectF boundingRect() const override { return {-1, 0., 6, m_height}; }
49  void setStatus(ExecutionStatus);
50 
51  void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
52  override;
53 
54  void setSelected(bool selected);
55  bool isSelected() const;
56 
57  void setCondition(const QString& cond);
58  bool hasCondition() const;
59  ConditionView& conditionItem() noexcept { return m_conditionItem; }
60 
61  void setExtent(const VerticalExtent& extent);
62  void setExtent(VerticalExtent&& extent);
63 
64  void changeToolTip(const QString&);
65 
66 public:
67  void eventHoverEnter() E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, eventHoverEnter)
68  void eventHoverLeave() E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, eventHoverLeave)
69 
70  void dropReceived(const QPointF& pos, const QMimeData& arg_2)
71  E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, dropReceived, pos, arg_2)
72 
73 protected:
74  void mousePressEvent(QGraphicsSceneMouseEvent* event) override;
75  void mouseMoveEvent(QGraphicsSceneMouseEvent* event) override;
76  void mouseReleaseEvent(QGraphicsSceneMouseEvent* event) override;
77 
78  void hoverEnterEvent(QGraphicsSceneHoverEvent* h) override;
79  void hoverLeaveEvent(QGraphicsSceneHoverEvent* h) override;
80 
81  void dropEvent(QGraphicsSceneDragDropEvent* event) override;
82 
83 private:
84  EventPresenter& m_presenter;
85  ConditionView m_conditionItem;
86  QString m_condition;
87  score::ColorRef m_color;
88  double m_height{};
89  score::ColorBang m_execPing;
90 
91  bool m_selected{};
92 };
93 }
Definition: ConditionView.hpp:21
Definition: EventPresenter.hpp:24
Definition: EventView.hpp:35
Definition: ColorInterpolator.hpp:9
Main plug-in of score.
Definition: score-plugin-dataflow/Dataflow/PortItem.hpp:14
The VerticalExtent struct.
Definition: VerticalExtent.hpp:20
A reference to a color. Used for skinning.
Definition: ColorReference.hpp:21