OSSIA
Open Scenario System for Interactive Application
Loading...
Searching...
No Matches
qml_property.hpp
1#pragma once
2#include <ossia/network/base/parameter.hpp>
3
4#include <ossia-qt/device/qml_node_base.hpp>
5#include <ossia-qt/qml_context.hpp>
6
7#include <QObject>
8#include <QQmlProperty>
9#include <QQmlPropertyValueSource>
10
11#include <verdigris>
12namespace ossia
13{
14namespace qt
15{
16class qml_node;
17class qml_device;
18
19class OSSIA_EXPORT qml_property
20 : public qml_property_base
21 , public QQmlPropertyValueSource
22{
23 W_OBJECT(qml_property)
24 W_INTERFACE(QQmlPropertyValueSource)
25
26public:
27 qml_property(QQuickItem* parent = nullptr);
28 ~qml_property() override;
29
30 void setTarget(const QQmlProperty& prop) override;
31 void resetNode() override;
32 void setDevice(QObject* device) override;
33
34 qml_val_type::val_type valueType() const;
35 qml_access_mode::access_mode access() const;
36 qml_bounding_mode::bounding_mode bounding() const;
37 qml_rep_filter::repetition_filter filterRepetitions() const;
38 QVariant min() const;
39 QVariant max() const;
40 QVariantList values() const;
41 QString unit() const;
42
43public:
44 void setValue_sig(const ossia::value& arg_1)
45 E_SIGNAL(OSSIA_EXPORT, setValue_sig, arg_1);
46
47 void valueTypeChanged(qml_val_type::val_type valueType)
48 E_SIGNAL(OSSIA_EXPORT, valueTypeChanged, valueType);
49 void accessChanged(qml_access_mode::access_mode access)
50 E_SIGNAL(OSSIA_EXPORT, accessChanged, access);
51 void boundingChanged(qml_bounding_mode::bounding_mode bounding)
52 E_SIGNAL(OSSIA_EXPORT, boundingChanged, bounding);
53 void filterRepetitionsChanged(qml_rep_filter::repetition_filter filterRepetitions)
54 E_SIGNAL(OSSIA_EXPORT, filterRepetitionsChanged, filterRepetitions);
55 void minChanged(QVariant min) E_SIGNAL(OSSIA_EXPORT, minChanged, min);
56 void maxChanged(QVariant max) E_SIGNAL(OSSIA_EXPORT, maxChanged, max);
57 void valuesChanged(QVariantList values) E_SIGNAL(OSSIA_EXPORT, valuesChanged, values);
58 void unitChanged(QString unit) E_SIGNAL(OSSIA_EXPORT, unitChanged, unit);
59
60public:
61 void qtVariantChanged();
62 W_SLOT(qtVariantChanged);
63 void setValue_slot(const value&);
64 W_SLOT(setValue_slot);
65
66 void setValueType(qml_val_type::val_type valueType);
67 W_SLOT(setValueType);
68 void setAccess(qml_access_mode::access_mode access);
69 W_SLOT(setAccess);
70 void setBounding(qml_bounding_mode::bounding_mode bounding);
71 W_SLOT(setBounding);
72 void setFilterRepetitions(qml_rep_filter::repetition_filter filterRepetitions);
73 W_SLOT(setFilterRepetitions);
74 void setMin(QVariant min);
75 W_SLOT(setMin);
76 void setMax(QVariant max);
77 W_SLOT(setMax);
78 void setValues(QVariantList values);
79 W_SLOT(setValues);
80 void setUnit(QString unit);
81 W_SLOT(setUnit);
82
83 void resetValueType()
84 {
85 if(m_valueType)
86 {
87 m_valueType = std::nullopt;
88 }
89 };
90 W_SLOT(resetValueType)
91 void resetAccess()
92 {
93 if(m_access)
94 {
95 m_access = std::nullopt;
96 }
97 };
98 W_SLOT(resetAccess)
99 void resetBounding()
100 {
101 if(m_bounding)
102 {
103 m_bounding = std::nullopt;
104 }
105 };
106 W_SLOT(resetBounding)
107 void resetFilterRepetitions()
108 {
109 if(m_filterRepetitions)
110 {
111 m_filterRepetitions = std::nullopt;
112 }
113 };
114 W_SLOT(resetFilterRepetitions)
115 void resetMin() { setMin(QVariant{}); };
116 W_SLOT(resetMin)
117 void resetMax() { setMax(QVariant{}); };
118 W_SLOT(resetMax)
119 void resetValues()
120 {
121 if(m_values)
122 {
123 m_values = std::nullopt;
124 }
125 };
126 W_SLOT(resetValues)
127 void resetUnit()
128 {
129 if(m_unit)
130 {
131 m_values = std::nullopt;
132 }
133 };
134 W_SLOT(resetUnit)
135
136 void node_destroyed();
137 W_SLOT(node_destroyed);
138
139private:
140 void setupAddress(bool reading);
141 void updateDomain();
142
143 QQmlProperty m_targetProperty;
144 std::optional<qml_val_type::val_type> m_valueType{};
145 std::optional<qml_access_mode::access_mode> m_access{};
146 std::optional<qml_bounding_mode::bounding_mode> m_bounding{};
147 std::optional<qml_rep_filter::repetition_filter> m_filterRepetitions{};
148 QVariant m_min{};
149 QVariant m_max{};
150 std::optional<QVariantList> m_values{};
151 std::optional<QString> m_unit{};
152 bool m_updatingFromSetValue{};
153
154 W_PROPERTY(
155 QVariantList,
156 values READ values WRITE setValues NOTIFY valuesChanged RESET resetValues, W_Final)
157
158 W_PROPERTY(
159 QVariant, max READ max WRITE setMax NOTIFY maxChanged RESET resetMax, W_Final)
160
161 W_PROPERTY(
162 QVariant, min READ min WRITE setMin NOTIFY minChanged RESET resetMin, W_Final)
163
164 W_PROPERTY(
165 ossia::qt::qml_rep_filter::repetition_filter,
166 filterRepetitions READ filterRepetitions WRITE setFilterRepetitions NOTIFY
167 filterRepetitionsChanged RESET resetFilterRepetitions,
168 W_Final)
169
170 W_PROPERTY(
171 ossia::qt::qml_bounding_mode::bounding_mode,
172 bounding READ bounding WRITE setBounding NOTIFY boundingChanged RESET
173 resetBounding,
174 W_Final)
175
176 W_PROPERTY(
177 ossia::qt::qml_access_mode::access_mode,
178 access READ access WRITE setAccess NOTIFY accessChanged RESET resetAccess, W_Final)
179
180 W_PROPERTY(
181 ossia::qt::qml_val_type::val_type,
182 valueType READ valueType WRITE setValueType NOTIFY valueTypeChanged RESET
183 resetValueType,
184 W_Final)
185
186 W_PROPERTY(
187 QString, unit READ unit WRITE setUnit NOTIFY unitChanged RESET resetUnit, W_Final)
188};
189}
190}
The value class.
Definition value.hpp:173
Definition git_info.h:7
OSSIA_INLINE constexpr auto min(const T a, const U b) noexcept -> typename std::conditional<(sizeof(T) > sizeof(U)), T, U >::type
min function tailored for values
Definition math.hpp:125
OSSIA_INLINE constexpr auto max(const T a, const U b) noexcept -> typename std::conditional<(sizeof(T) > sizeof(U)), T, U >::type
max function tailored for values
Definition math.hpp:96