SelectionButton.hpp
1 #pragma once
2 #include <score/selection/Selection.hpp>
3 
4 #include <QString>
5 #include <QToolButton>
6 #include <QWidget>
7 
8 class QPushButton;
9 
10 namespace score
11 {
12 class SelectionDispatcher;
13 }
14 class SCORE_LIB_BASE_EXPORT SelectionButton final : public QToolButton
15 {
16 public:
18  const QString& text, Selection target, score::SelectionDispatcher& disp,
19  QWidget* parent);
20 
21  template <typename Obj>
22  static SelectionButton*
23  make(Obj* obj, score::SelectionDispatcher& disp, QWidget* parent)
24  {
25  auto ptr = const_cast<std::remove_const_t<Obj>*>(obj);
26  return new SelectionButton{
27  QString::number(*obj->id().val()), Selection{ptr}, disp, parent};
28  }
29 
30  template <typename Obj>
31  static SelectionButton*
32  make(const QString& text, Obj* obj, score::SelectionDispatcher& disp, QWidget* parent)
33  {
34  auto ptr = const_cast<std::remove_const_t<Obj>*>(obj);
35  auto but = new SelectionButton{text, Selection{ptr}, disp, parent};
36 
37  but->setToolTip(QString::number(obj->id().val()));
38  return but;
39  }
40 
41 private:
42  score::SelectionDispatcher& m_dispatcher;
43 };
Definition: SelectionButton.hpp:15
Definition: Selection.hpp:12
The SelectionDispatcher class.
Definition: SelectionDispatcher.hpp:15
Base toolkit upon which the software is built.
Definition: Application.cpp:90