diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-07-11 11:55:29 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-07-11 11:55:29 +0200 |
commit | 3a3118e768e1447dc7524328e84b8d7faef81fe1 (patch) | |
tree | af5582170ed6164fffc9365f34b17bf449c0db40 /common/modelresult.cpp | |
parent | f9379318d801df204cc50385c5eca1f28e91755e (diff) | |
parent | ce2fd2666f084eebe443598f6f3740a02913091e (diff) | |
download | sink-3a3118e768e1447dc7524328e84b8d7faef81fe1.tar.gz sink-3a3118e768e1447dc7524328e84b8d7faef81fe1.zip |
Merge branch 'feature/notifications' into develop
Diffstat (limited to 'common/modelresult.cpp')
-rw-r--r-- | common/modelresult.cpp | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/common/modelresult.cpp b/common/modelresult.cpp index 3778d4d..56a39ee 100644 --- a/common/modelresult.cpp +++ b/common/modelresult.cpp | |||
@@ -25,8 +25,7 @@ | |||
25 | #include "domain/folder.h" | 25 | #include "domain/folder.h" |
26 | #include "log.h" | 26 | #include "log.h" |
27 | 27 | ||
28 | #undef DEBUG_AREA | 28 | SINK_DEBUG_AREA("modelresult") |
29 | #define DEBUG_AREA "client.modelresult" | ||
30 | 29 | ||
31 | static uint qHash(const Sink::ApplicationDomain::ApplicationDomainType &type) | 30 | static uint qHash(const Sink::ApplicationDomain::ApplicationDomainType &type) |
32 | { | 31 | { |
@@ -123,7 +122,7 @@ QModelIndex ModelResult<T, Ptr>::index(int row, int column, const QModelIndex &p | |||
123 | const auto childId = list.at(row); | 122 | const auto childId = list.at(row); |
124 | return createIndex(row, column, childId); | 123 | return createIndex(row, column, childId); |
125 | } | 124 | } |
126 | Warning() << "Index not available " << row << column << parent; | 125 | SinkWarning() << "Index not available " << row << column << parent; |
127 | Q_ASSERT(false); | 126 | Q_ASSERT(false); |
128 | return QModelIndex(); | 127 | return QModelIndex(); |
129 | } | 128 | } |
@@ -174,7 +173,7 @@ bool ModelResult<T, Ptr>::canFetchMore(const QModelIndex &parent) const | |||
174 | template <class T, class Ptr> | 173 | template <class T, class Ptr> |
175 | void ModelResult<T, Ptr>::fetchMore(const QModelIndex &parent) | 174 | void ModelResult<T, Ptr>::fetchMore(const QModelIndex &parent) |
176 | { | 175 | { |
177 | Trace() << "Fetching more: " << parent; | 176 | SinkTrace() << "Fetching more: " << parent; |
178 | fetchEntities(parent); | 177 | fetchEntities(parent); |
179 | } | 178 | } |
180 | 179 | ||
@@ -185,7 +184,7 @@ void ModelResult<T, Ptr>::add(const Ptr &value) | |||
185 | const auto id = parentId(value); | 184 | const auto id = parentId(value); |
186 | // Ignore updates we get before the initial fetch is done | 185 | // Ignore updates we get before the initial fetch is done |
187 | if (!mEntityChildrenFetched.contains(id)) { | 186 | if (!mEntityChildrenFetched.contains(id)) { |
188 | Trace() << "Too early" << id; | 187 | SinkTrace() << "Too early" << id; |
189 | return; | 188 | return; |
190 | } | 189 | } |
191 | auto parent = createIndexFromId(id); | 190 | auto parent = createIndexFromId(id); |
@@ -198,7 +197,7 @@ void ModelResult<T, Ptr>::add(const Ptr &value) | |||
198 | } | 197 | } |
199 | } | 198 | } |
200 | if (mEntities.contains(childId)) { | 199 | if (mEntities.contains(childId)) { |
201 | Warning() << "Entity already in model " << value->identifier(); | 200 | SinkWarning() << "Entity already in model " << value->identifier(); |
202 | return; | 201 | return; |
203 | } | 202 | } |
204 | // qDebug() << "Inserting rows " << index << parent; | 203 | // qDebug() << "Inserting rows " << index << parent; |
@@ -234,18 +233,18 @@ void ModelResult<T, Ptr>::fetchEntities(const QModelIndex &parent) | |||
234 | const auto id = getIdentifier(parent); | 233 | const auto id = getIdentifier(parent); |
235 | mEntityChildrenFetchComplete.remove(id); | 234 | mEntityChildrenFetchComplete.remove(id); |
236 | mEntityChildrenFetched.insert(id); | 235 | mEntityChildrenFetched.insert(id); |
237 | Trace() << "Loading child entities of parent " << id; | 236 | SinkTrace() << "Loading child entities of parent " << id; |
238 | if (loadEntities) { | 237 | if (loadEntities) { |
239 | loadEntities(parent.data(DomainObjectRole).template value<Ptr>()); | 238 | loadEntities(parent.data(DomainObjectRole).template value<Ptr>()); |
240 | } else { | 239 | } else { |
241 | Warning() << "No way to fetch entities"; | 240 | SinkWarning() << "No way to fetch entities"; |
242 | } | 241 | } |
243 | } | 242 | } |
244 | 243 | ||
245 | template <class T, class Ptr> | 244 | template <class T, class Ptr> |
246 | void ModelResult<T, Ptr>::setFetcher(const std::function<void(const Ptr &parent)> &fetcher) | 245 | void ModelResult<T, Ptr>::setFetcher(const std::function<void(const Ptr &parent)> &fetcher) |
247 | { | 246 | { |
248 | Trace() << "Setting fetcher"; | 247 | SinkTrace() << "Setting fetcher"; |
249 | loadEntities = fetcher; | 248 | loadEntities = fetcher; |
250 | } | 249 | } |
251 | 250 | ||
@@ -270,7 +269,7 @@ void ModelResult<T, Ptr>::setEmitter(const typename Sink::ResultEmitter<Ptr>::Pt | |||
270 | }); | 269 | }); |
271 | }); | 270 | }); |
272 | emitter->onInitialResultSetComplete([this](const Ptr &parent) { | 271 | emitter->onInitialResultSetComplete([this](const Ptr &parent) { |
273 | Trace() << "Initial result set complete"; | 272 | SinkTrace() << "Initial result set complete"; |
274 | const qint64 parentId = parent ? qHash(*parent) : 0; | 273 | const qint64 parentId = parent ? qHash(*parent) : 0; |
275 | const auto parentIndex = createIndexFromId(parentId); | 274 | const auto parentIndex = createIndexFromId(parentId); |
276 | mEntityChildrenFetchComplete.insert(parentId); | 275 | mEntityChildrenFetchComplete.insert(parentId); |