-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmodel.h
More file actions
66 lines (51 loc) · 1.36 KB
/
model.h
File metadata and controls
66 lines (51 loc) · 1.36 KB
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
#ifndef MODEL_H
#define MODEL_H
#include <QMap>
#include <QString>
#include <QVariant>
class Model
{
friend class Builder;
class AttributeRef
{
public:
AttributeRef(Model &model, const QString &key);
QVariant &operator =(const QVariant &value) const;
QString toString() const;
operator QVariant() const;
operator QString() const;
operator int() const;
protected:
Model &model;
QString key;
};
public:
Model();
Model(const QMap<QString, QVariant> &map);
virtual ~Model();
QString get(const QString &key) const;
int getInt(const QString &key) const;
void set(const QString &key, const QVariant &value);
virtual int id() const;
QStringList keys() const;
QStringList dirtyKeys() const;
virtual QString created_at() const;
virtual QString updated_at() const;
virtual bool useTimestamps() const;
void touch();
/**
* If the QMap (base class) and original is both empty,
* this Model is considered to be invalid, vise versa.
*/
operator bool() const;
AttributeRef operator [](const char *key);
AttributeRef operator [](const QString &key);
bool exists;
private:
void saved();
protected:
QMap<QString, QVariant> data;
QMap<QString, QVariant> original;
};
#include "inloquentmodel.h"
#endif // MODEL_H