summaryrefslogtreecommitdiffstats
path: root/examples/statemachine/citizenquartz/propertyaddstate.h
blob: 4d28055d1a73d29213adc3f2487bd140b0d1678d (plain)
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
#ifndef PropertyAddState_H
#define PropertyAddState_H

#include <qstate.h>

#include <QVariant>
#include <QList>

class PropertyAddState: public QState
{
public:
    PropertyAddState(QState *parent = 0);
    
    void addToProperty(QObject *object, const char *propertyName, const QVariant &valueToAdd);
    virtual void onEntry();

private:
    QVariant addProperties(const QVariant &current, const QVariant &toAdd) const;

    struct PropertyAdder {
        PropertyAdder(QObject *_object, const char *_propertyName, const QVariant &_valueToAdd)
            : object(_object), propertyName(_propertyName), valueToAdd(_valueToAdd)
        {
        }

        QObject *object;
        QByteArray propertyName;
        QVariant valueToAdd;
    };
    QList<PropertyAdder> m_propertyAdditions;
};

#endif // PropertyAddState_H