diff options
author | Rémi Nicole <nicole@kolabsystems.com> | 2018-07-27 13:37:32 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-07-27 13:47:54 +0200 |
commit | 0a9b39a1f58c1f5b1a424acbe369db520a12df42 (patch) | |
tree | 4c64e5680150f50088bf114cbab39f79f781d242 /common/storage/key.cpp | |
parent | 620c4f551d3de830a516475ad02965695cb25945 (diff) | |
download | sink-0a9b39a1f58c1f5b1a424acbe369db520a12df42.tar.gz sink-0a9b39a1f58c1f5b1a424acbe369db520a12df42.zip |
Use Key API in DataStoreQuery
Reviewers: cmollekopf
Reviewed By: cmollekopf
Tags: #sink
Differential Revision: https://phabricator.kde.org/D14099
Diffstat (limited to 'common/storage/key.cpp')
-rw-r--r-- | common/storage/key.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/common/storage/key.cpp b/common/storage/key.cpp index 01a3e3a..cfeb016 100644 --- a/common/storage/key.cpp +++ b/common/storage/key.cpp | |||
@@ -46,8 +46,14 @@ QDebug &operator<<(QDebug &dbg, const Key &key) | |||
46 | 46 | ||
47 | // Identifier | 47 | // Identifier |
48 | 48 | ||
49 | Identifier Identifier::createIdentifier() | ||
50 | { | ||
51 | return Identifier(QUuid::createUuid()); | ||
52 | } | ||
53 | |||
49 | QByteArray Identifier::toInternalByteArray() const | 54 | QByteArray Identifier::toInternalByteArray() const |
50 | { | 55 | { |
56 | Q_ASSERT(!uid.isNull()); | ||
51 | return uid.toRfc4122(); | 57 | return uid.toRfc4122(); |
52 | } | 58 | } |
53 | 59 | ||
@@ -73,6 +79,21 @@ Identifier Identifier::fromDisplayByteArray(const QByteArray &bytes) | |||
73 | return Identifier(QUuid(bytes)); | 79 | return Identifier(QUuid(bytes)); |
74 | } | 80 | } |
75 | 81 | ||
82 | bool Identifier::isNull() const | ||
83 | { | ||
84 | return uid.isNull(); | ||
85 | } | ||
86 | |||
87 | bool Identifier::operator==(const Identifier &other) const | ||
88 | { | ||
89 | return uid == other.uid; | ||
90 | } | ||
91 | |||
92 | bool Identifier::operator!=(const Identifier &other) const | ||
93 | { | ||
94 | return !(*this == other); | ||
95 | } | ||
96 | |||
76 | // Revision | 97 | // Revision |
77 | 98 | ||
78 | QByteArray Revision::toInternalByteArray() const | 99 | QByteArray Revision::toInternalByteArray() const |
@@ -107,6 +128,16 @@ qint64 Revision::toQint64() const | |||
107 | return rev; | 128 | return rev; |
108 | } | 129 | } |
109 | 130 | ||
131 | bool Revision::operator==(const Revision &other) const | ||
132 | { | ||
133 | return rev == other.rev; | ||
134 | } | ||
135 | |||
136 | bool Revision::operator!=(const Revision &other) const | ||
137 | { | ||
138 | return !(*this == other); | ||
139 | } | ||
140 | |||
110 | // Key | 141 | // Key |
111 | 142 | ||
112 | QByteArray Key::toInternalByteArray() const | 143 | QByteArray Key::toInternalByteArray() const |
@@ -154,3 +185,19 @@ void Key::setRevision(const Revision &newRev) | |||
154 | { | 185 | { |
155 | rev = newRev; | 186 | rev = newRev; |
156 | } | 187 | } |
188 | |||
189 | bool Key::isNull() const | ||
190 | { | ||
191 | return id.isNull(); | ||
192 | } | ||
193 | |||
194 | bool Key::operator==(const Key &other) const | ||
195 | { | ||
196 | return (id == other.id) && (rev == other.rev); | ||
197 | } | ||
198 | |||
199 | bool Key::operator!=(const Key &other) const | ||
200 | { | ||
201 | return !(*this == other); | ||
202 | } | ||
203 | |||