QGraphicsEnum.hpp
1 #pragma once
2 #include <score/graphics/widgets/Constants.hpp>
3 
4 #include <QGraphicsItem>
5 #include <QObject>
6 
7 #include <score_lib_base_export.h>
8 
9 #include <vector>
10 #include <verdigris>
11 
12 namespace score
13 {
14 class SCORE_LIB_BASE_EXPORT QGraphicsEnum
15  : public QObject
16  , public QGraphicsItem
17 {
18  W_OBJECT(QGraphicsEnum)
19  Q_INTERFACES(QGraphicsItem)
20 
21 protected:
22  int m_value{};
23  int m_clicking{-1};
24  QRectF m_rect;
25  QRectF m_smallRect;
26 
27 public:
28  std::vector<QString> array;
29  int rows{1};
30  int columns{4};
31 
32  template <std::size_t N>
33  QGraphicsEnum(const std::array<const char*, N>& arr, QGraphicsItem* parent)
34  : QGraphicsEnum{parent}
35  {
36  array.reserve(N);
37  for(auto str : arr)
38  array.push_back(str);
39  updateRect();
40  }
41  QGraphicsEnum(std::vector<QString> arr, QGraphicsItem* parent)
42  : QGraphicsEnum{parent}
43  {
44  array = std::move(arr);
45  updateRect();
46  }
47  QGraphicsEnum(QGraphicsItem* parent);
48 
49  void updateRect();
50  void setRect(const QRectF& r);
51  void setOneLineRect();
52  void setValue(int32_t v);
53  int value() const;
54  QRectF boundingRect() const override;
55 
56 public:
57  void currentIndexChanged(int arg_1)
58  E_SIGNAL(SCORE_LIB_BASE_EXPORT, currentIndexChanged, arg_1)
59 
60 private:
61  void mousePressEvent(QGraphicsSceneMouseEvent* event) override;
62  void mouseMoveEvent(QGraphicsSceneMouseEvent* event) override;
63  void mouseReleaseEvent(QGraphicsSceneMouseEvent* event) override;
64 
65  void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
66  override;
67 };
68 }
Definition: QGraphicsEnum.hpp:17
Base toolkit upon which the software is built.
Definition: Application.cpp:90