Loading...
Searching...
No Matches
AddressItem.hpp
1#pragma once
2#include <ossia/detail/callback_container.hpp>
3#include <ossia/network/base/value_callback.hpp>
4
5#include <QQmlProperty>
6#include <QQmlPropertyValueSource>
7
8#include <nano_observer.hpp>
9
10#include <verdigris>
11namespace ossia::net
12{
13class device_base;
14class parameter_base;
15}
16namespace JS
17{
18class DeviceContext;
19
21 : public QObject
22 , public QQmlPropertyValueSource
23 , public Nano::Observer
24{
25 W_OBJECT(AddressSource)
26 W_INTERFACE(QQmlPropertyValueSource)
27 QML_ELEMENT
28
29public:
30 explicit AddressSource(QObject* parent = nullptr);
32
33 void init();
34
35 void setTarget(const QQmlProperty& prop) override;
36
37 void clearNetworkCallbacks();
38 void clearQMLCallbacks();
39 void on_addressChanged(const QString& addr);
40 void on_newNetworkValue(const ossia::value& v);
41 void on_newUIValue();
42 W_SLOT(on_newUIValue);
43
44 void on_parameterRemoving(const ossia::net::parameter_base& v);
45
46 INLINE_PROPERTY_CREF(QString, address, = "", address, setAddress, addressChanged)
47
48 // Send updates from the GUI to the network
49 INLINE_PROPERTY_CREF(
50 bool, sendUpdates, = true, sendUpdates, setSendUpdates, sendUpdatesChanged)
51
52 // Receive updates from the network to the GUI
53 INLINE_PROPERTY_CREF(
54 bool, receiveUpdates, = true, receiveUpdates, setReceiveUpdates,
55 receiveUpdatesChanged)
56
57private:
58 void rebuild();
59
60 QQmlProperty m_targetProperty;
61 JS::DeviceContext* m_devices{};
62
63 ossia::net::device_base* m_device{};
64 ossia::net::parameter_base* m_param{};
65 std::optional<ossia::callback_container<ossia::value_callback>::iterator> m_callback;
66 bool m_writingValue{};
67};
68}
Definition DeviceContext.hpp:19
Definition AddressItem.hpp:24