FocusManager.hpp
1 #pragma once
2 #include <score/model/IdentifiedObjectAbstract.hpp>
3 
4 #include <QPointer>
5 
6 namespace score
7 {
8 struct SCORE_LIB_BASE_EXPORT FocusManager : public QObject
9 {
10  W_OBJECT(FocusManager)
11 public:
12  const IdentifiedObjectAbstract* get() { return m_obj; }
13 
14  template <typename T>
15  void set(QPointer<T> obj)
16  {
17  m_obj = obj.data();
18  changed();
19  }
20 
21  void set(std::nullptr_t)
22  {
23  m_obj.clear();
24  changed();
25  }
26 
27  void changed() E_SIGNAL(SCORE_LIB_BASE_EXPORT, changed)
28 
29 private:
30  QPointer<IdentifiedObjectAbstract> m_obj{};
31 };
32 
33 struct SCORE_LIB_BASE_EXPORT FocusFacade
34 {
35 private:
36  FocusManager& m_mgr;
37 
38 public:
40  : m_mgr{mgr}
41  {
42  }
43 
44  const IdentifiedObjectAbstract* get() const { return m_mgr.get(); }
45 };
46 }
Base class for IdentifiedObject.
Definition: IdentifiedObjectAbstract.hpp:16
Base toolkit upon which the software is built.
Definition: Application.cpp:90
Definition: FocusManager.hpp:34
Definition: FocusManager.hpp:9