ScenarioDropHandler.hpp
1 #pragma once
2 #include <Scenario/Palette/ScenarioPoint.hpp>
3 
4 #include <score/model/Identifier.hpp>
5 #include <score/plugins/Interface.hpp>
6 #include <score/plugins/InterfaceList.hpp>
7 
8 #include <QMimeData>
9 #include <QPointF>
10 
11 #include <score_plugin_scenario_export.h>
12 
13 namespace score
14 {
15 struct DocumentContext;
16 }
17 namespace Scenario
18 {
19 class StateModel;
20 class ProcessModel;
21 class ScenarioPresenter;
22 
24 {
25  Scenario::StateModel* horizontal{};
26  Scenario::StateModel* vertical{};
27  bool magnetic{};
28 };
29 
30 MagneticStates magneticStates(
32 
33 class ScenarioPresenter;
34 class SCORE_PLUGIN_SCENARIO_EXPORT DropHandler : public score::InterfaceBase
35 {
36  SCORE_INTERFACE(DropHandler, "ce1c5b6c-fe4c-416f-877c-eae642a1413a")
37 public:
38  ~DropHandler() override;
39 
40  // Returns false if not handled.
41  virtual bool
42  dragEnter(const Scenario::ScenarioPresenter&, QPointF pos, const QMimeData& mime);
43 
44  virtual bool
45  dragMove(const Scenario::ScenarioPresenter&, QPointF pos, const QMimeData& mime);
46 
47  virtual bool
48  dragLeave(const Scenario::ScenarioPresenter&, QPointF pos, const QMimeData& mime);
49 
50  virtual bool canDrop(const QMimeData& mime) const noexcept;
51 
52  virtual bool
53  drop(const Scenario::ScenarioPresenter&, QPointF pos, const QMimeData& mime)
54  = 0;
55 };
56 
57 class SCORE_PLUGIN_SCENARIO_EXPORT GhostIntervalDropHandler : public DropHandler
58 {
59 public:
60  ~GhostIntervalDropHandler() override;
61 
62 protected:
63  std::vector<QString> m_acceptableMimeTypes;
64  std::vector<QString> m_acceptableSuffixes;
65 
66  MagneticStates m_magnetic{};
67 
68 private:
69  bool dragEnter(const Scenario::ScenarioPresenter&, QPointF pos, const QMimeData& mime)
70  final override;
71  bool dragMove(const Scenario::ScenarioPresenter&, QPointF pos, const QMimeData& mime)
72  final override;
73  bool dragLeave(const Scenario::ScenarioPresenter&, QPointF pos, const QMimeData& mime)
74  final override;
75 };
76 
77 class DropHandlerList final : public score::InterfaceList<DropHandler>
78 {
79 public:
80  ~DropHandlerList() override;
81 
82  bool
83  dragEnter(const ScenarioPresenter& scen, QPointF pos, const QMimeData& mime) const;
84  bool dragMove(const ScenarioPresenter& scen, QPointF pos, const QMimeData& mime) const;
85  bool dragLeave(const ScenarioPresenter&, QPointF pos, const QMimeData& mime) const;
86  bool drop(const ScenarioPresenter& scen, QPointF pos, const QMimeData& mime) const;
87 };
88 
89 class IntervalModel;
90 class SCORE_PLUGIN_SCENARIO_EXPORT IntervalDropHandler : public score::InterfaceBase
91 {
92  SCORE_INTERFACE(IntervalDropHandler, "b9f3efc0-b906-487a-ac49-87924edd2cff")
93 public:
94  ~IntervalDropHandler() override;
95 
96  // Returns false if not handled.
97  virtual bool drop(
98  const score::DocumentContext& ctx, const Scenario::IntervalModel&, QPointF pos,
99  const QMimeData& mime)
100  = 0;
101 };
102 
103 class IntervalDropHandlerList final : public score::InterfaceList<IntervalDropHandler>
104 {
105 public:
106  ~IntervalDropHandlerList() override;
107 
108  bool drop(
109  const score::DocumentContext& ctx, const Scenario::IntervalModel&, QPointF pos,
110  const QMimeData& mime) const;
111 };
112 }
Definition: ScenarioDropHandler.hpp:35
Definition: ScenarioDropHandler.hpp:78
Definition: ScenarioDropHandler.hpp:58
Definition: ScenarioDropHandler.hpp:91
Definition: ScenarioDropHandler.hpp:104
Definition: IntervalModel.hpp:50
Definition: ScenarioPresenter.hpp:29
Definition: StateModel.hpp:63
Base class for plug-in interfaces.
Definition: Interface.hpp:52
InterfaceList Default implementation of InterfaceListBase.
Definition: InterfaceList.hpp:80
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
Definition: ScenarioDropHandler.hpp:24
Definition: ScenarioPoint.hpp:13
Definition: DocumentContext.hpp:18