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  SCORE_GRAPHICS_ITEM_TYPE(40)
20 
21 protected:
22  int m_value{};
23  int m_clicking{-1};
24  QRectF m_rect;
25  QRectF m_smallRect;
26  int m_actualRows{1};
27  int m_actualColumns{1};
28 
29 public:
30  std::vector<QString> array;
31  int rows{1};
32  int columns{4};
33 
34  template <std::size_t N>
35  QGraphicsEnum(const std::array<const char*, N>& arr, QGraphicsItem* parent)
36  : QGraphicsEnum{parent}
37  {
38  array.reserve(N);
39  for(auto str : arr)
40  array.push_back(str);
41  updateRect();
42  }
43  QGraphicsEnum(std::vector<QString> arr, QGraphicsItem* parent)
44  : QGraphicsEnum{parent}
45  {
46  array = std::move(arr);
47  updateRect();
48  }
49  explicit QGraphicsEnum(QGraphicsItem* parent);
50 
51  void updateRect();
52  void setRect(const QRectF& r);
53  void setOneLineRect();
54  void setValue(int32_t v);
55  int value() const;
56  QRectF boundingRect() const override;
57 
58 public:
59  void currentIndexChanged(int arg_1)
60  E_SIGNAL(SCORE_LIB_BASE_EXPORT, currentIndexChanged, arg_1)
61 
62 private:
63  void mousePressEvent(QGraphicsSceneMouseEvent* event) override;
64  void mouseMoveEvent(QGraphicsSceneMouseEvent* event) override;
65  void mouseReleaseEvent(QGraphicsSceneMouseEvent* event) override;
66 
67  void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
68  override;
69 };
70 }
Definition: QGraphicsEnum.hpp:17
Base toolkit upon which the software is built.
Definition: Application.cpp:90