forked from victronenergy/dbus_modbustcp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnostorage_qitem_producer.h
51 lines (44 loc) · 1.26 KB
/
nostorage_qitem_producer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#ifndef NOSTORAGE_QITEM_PRODUCER_H
#define NOSTORAGE_QITEM_PRODUCER_H
#include <veutil/qt/ve_qitems_dbus.hpp>
/**
* A VeQItemDbus that forces the item's state back to Synchronized after a call to setValue.
* This is a workaround for the problem that a call to setValue will not trigger a SetValue on the
* D-Bus if the previous setValue used the same value and there was no PropertiesChange from
* the D-Bus object after the first setValue.
*/
class NoStorageQItem: public VeQItemDbus
{
Q_OBJECT
public:
NoStorageQItem(VeQItemDbusProducer *producer):
VeQItemDbus(producer)
{
}
virtual int setValue(QVariant const &value)
{
int i = VeQItemDbus::setValue(value);
if (i != 0)
return i;
VeQItemDbus::setState(VeQItem::Synchronized);
return 0;
}
};
/**
* A VeQItemDbusProducer that creates NoStorageQItem instead of VeQItemDbus
*/
class NostorageQItemProducer: public VeQItemDbusProducer
{
Q_OBJECT
public:
NostorageQItemProducer(VeQItem *root, QString id, bool findVictronServices = true,
bool bulkInitOfNewService = true, QObject *parent = 0):
VeQItemDbusProducer(root, id, findVictronServices, bulkInitOfNewService, parent)
{
}
virtual VeQItem *createItem()
{
return new NoStorageQItem(this);
}
};
#endif // NOSTORAGE_QITEM_PRODUCER_H