forked from benlau/qsyncable
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqspatch.h
76 lines (53 loc) · 1.5 KB
/
qspatch.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/* QSyncable Project
Author: Ben Lau
License: Apache-2.0
Web: https://github.com/benlau/qsyncable
*/
#pragma once
#include <QtCore>
#include <QSharedDataPointer>
#include <QVariantMap>
class QSPatchPriv;
class QSPatch
{
public:
enum Type {
Null,
Insert,
Remove,
Update,
Move
};
QSPatch();
QSPatch(Type type,int from = 0, int to = 0, int count = 0);
QSPatch(Type type,int from, int to, int count, const QVariantMap& data);
QSPatch(Type type,int from, int to, int count, const QVariantList& data);
QSPatch(const QSPatch &);
QSPatch &operator=(const QSPatch &);
~QSPatch();
QSPatch::Type type() const;
void setType(const QSPatch::Type &type);
QVariantList data() const;
void setData(const QVariantList &data);
void setData(const QVariantMap& data);
bool operator==(const QSPatch& rhs) const;
int from() const;
void setFrom(int from);
int to() const;
void setTo(int to);
bool isNull() const;
int count() const;
void setCount(int count);
bool canMerge(const QSPatch& other) const;
QSPatch merged(const QSPatch &other) const;
QSPatch& merge(const QSPatch &other);
static QSPatch createUpdate(int index, const QVariantMap& diff);
static QSPatch createRemove(int from,int to);
signals:
public slots:
private:
QSharedDataPointer<QSPatchPriv> d;
};
QDebug operator<<(QDebug dbg, const QSPatch& change);
typedef QList<QSPatch> QSPatchSet;
Q_DECLARE_METATYPE(QSPatch)