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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
#ifndef AMBQT_H
#define AMBQT_H
#include <QObject>
#include <QDBusInterface>
#include <QtDebug>
#define AUTOPROPERTY(type, name, Name) \
public: \
void set ## Name(type s) { m ## Name = s; } \
type name() { return m ## Name; } \
private: \
type m ## Name;
class QDBusInterface;
class AmbProperty: public QObject
{
Q_OBJECT
Q_PROPERTY(QString propertyName READ propertyName WRITE setPropertyName)
AUTOPROPERTY(QString, propertyName, PropertyName)
Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged)
Q_PROPERTY(QString interfaceName READ interfaceName WRITE setInterfaceName)
AUTOPROPERTY(QString, interfaceName, InterfaceName)
Q_PROPERTY(QString objectPath READ objectPath WRITE setObjectPath)
AUTOPROPERTY(QString, objectPath, ObjectPath)
Q_PROPERTY(int zone READ zone WRITE setZone)
AUTOPROPERTY(int, zone, Zone)
Q_PROPERTY(double time READ time)
public:
AmbProperty():mDBusInterface(NULL),mZone(0),mTime(0) { }
AmbProperty(QString op, QString iface, QString propName);
QVariant value()
{
return mValue;
}
void setValue(QVariant v)
{
if(!mDBusInterface || !mDBusInterface->isValid())
{
qDebug()<<"error Interface is not valid "<<interfaceName();
}
mDBusInterface->setProperty(propertyName().toUtf8(), v);
}
double time(){ return mTime; }
Q_SIGNALS:
void valueChanged(QVariant val);
///TODO: remove
void signalChanged(QVariant val);
public Q_SLOTS:
void connect();
private Q_SLOTS:
void propertyChangedSlot(QString, QVariantMap values, QVariantMap);
void propertyChanged1(QDBusVariant, double);
private:
void getObjectPath();
QDBusInterface* mDBusInterface;
double mTime;
QVariant mValue;
};
#endif // AMBQT_H
|