ScenarioView.hpp
1 #pragma once
2 #include <Process/LayerView.hpp>
3 
4 #include <score/tools/std/Optional.hpp>
5 #include <score/widgets/MimeData.hpp>
6 
7 #include <QPoint>
8 #include <QRect>
9 
10 #include <score_plugin_scenario_export.h>
11 
12 #include <verdigris>
13 class QGraphicsItem;
14 class QGraphicsSceneContextMenuEvent;
15 class QGraphicsSceneDragDropEvent;
16 class QGraphicsSceneMouseEvent;
17 class QKeyEvent;
18 class QMimeData;
19 class QPainter;
20 
21 namespace Scenario
22 {
23 class ProcessModel;
24 class ScenarioPresenter;
25 
26 class ScenarioView final : public Process::LayerView
27 {
28 public:
29  ScenarioView(QGraphicsItem* parent);
30  ~ScenarioView();
31  void init(ScenarioPresenter* p) { m_scenario = p; }
32 
33  void paint_impl(QPainter* painter) const override;
34 
35  void setSelectionArea(const QRectF& rect)
36  {
37  m_selectArea = rect;
38  update();
39  }
40 
41  void drawDragLine(QPointF, QPointF, const QString&);
42  void stopDrawDragLine();
43 
44 public:
45  void lock()
46  {
47  m_lock = true;
48  update();
49  }
50  void unlock()
51  {
52  m_lock = false;
53  update();
54  }
55 
56  void pressedAsked(const QPointF& p)
57  {
58  m_previousPoint = p;
59  pressed(p);
60  }
61  void movedAsked(const QPointF& p);
62 
63  void setSnapLine(std::optional<double>);
64 
65 protected:
66  void mousePressEvent(QGraphicsSceneMouseEvent* event) override;
67  void mouseMoveEvent(QGraphicsSceneMouseEvent* event) override;
68  void mouseReleaseEvent(QGraphicsSceneMouseEvent* event) override;
69  void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event) override;
70 
71  void keyPressEvent(QKeyEvent* event) override;
72  void keyReleaseEvent(QKeyEvent* event) override;
73 
74  void dragEnterEvent(QGraphicsSceneDragDropEvent* event) override;
75  void dragMoveEvent(QGraphicsSceneDragDropEvent* event) override;
76  void dragLeaveEvent(QGraphicsSceneDragDropEvent* event) override;
77  void dropEvent(QGraphicsSceneDragDropEvent* event) override;
78 
79 private:
80  ScenarioPresenter* m_scenario{};
81  QRectF m_selectArea{};
82  QPointF m_previousPoint{};
83  std::optional<QRectF> m_dragLine{};
84  std::optional<double> m_snapLine{};
85  QString m_dragText;
86  bool m_lock{};
87  bool m_moving{};
88 };
89 }
Definition: LayerView.hpp:21
Definition: ScenarioPresenter.hpp:29
Definition: ScenarioView.hpp:27
Main plug-in of score.
Definition: score-plugin-dataflow/Dataflow/PortItem.hpp:14