SelectionStack.hpp
1 #pragma once
2 #include <score/selection/Selection.hpp>
3 
4 #include <ossia/detail/hash_map.hpp>
5 
6 #include <QObject>
7 #include <QStack>
8 
9 #include <verdigris>
10 
12 
13 namespace score
14 {
23 class SCORE_LIB_BASE_EXPORT SelectionStack final : public QObject
24 {
25  W_OBJECT(SelectionStack)
26 public:
28  ~SelectionStack();
29 
30  bool canUnselect() const;
31  bool canReselect() const;
32  void clear();
33  void clearAllButLast();
34 
35  // Go to the previous set of selections
36  void unselect();
37 
38  // Go to the next set of selections
39  void reselect();
40 
41  // Push a new set of empty selection.
42  void deselect();
43 
44  // Push a new selection without these objects
45  void deselectObjects(const Selection& toDeselect);
46 
47  Selection currentSelection() const;
48 
49  void pushNewSelection(const Selection& s)
50  E_SIGNAL(SCORE_LIB_BASE_EXPORT, pushNewSelection, s)
51 
52  void currentSelectionChanged(const Selection& old, const Selection& current)
53  E_SIGNAL(SCORE_LIB_BASE_EXPORT, currentSelectionChanged, old, current)
54 
55  void prune(IdentifiedObjectAbstract* p);
56  W_INVOKABLE(prune)
57 
58  void pruneRecursively(IdentifiedObjectAbstract* p);
59  W_INVOKABLE(pruneRecursively)
60 
61 private:
62  // Select new objects
63  void push(const Selection& s);
64  void pruneConnections();
65 
66  // m_unselectable always contains the empty set at the beginning
67  QStack<Selection> m_unselectable;
68  QStack<Selection> m_reselectable;
69 
70  ossia::hash_map<const IdentifiedObjectAbstract*, QMetaObject::Connection>
71  m_connections;
72 };
73 }
Base class for IdentifiedObject.
Definition: IdentifiedObjectAbstract.hpp:16
Definition: Selection.hpp:12
The SelectionStack class.
Definition: SelectionStack.hpp:24
Base toolkit upon which the software is built.
Definition: Application.cpp:90