diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-07-07 22:23:49 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-07-07 22:23:49 +0200 |
commit | da2b049e248c1ad7efeb53685158a205335e4e36 (patch) | |
tree | 1e7e5e940e9b760b2108081b1d2f3879cebdb0ff /common/modelresult.cpp | |
parent | 9bcb822963fc96c94dbe7dcc4134dcd2dac454ff (diff) | |
download | sink-da2b049e248c1ad7efeb53685158a205335e4e36.tar.gz sink-da2b049e248c1ad7efeb53685158a205335e4e36.zip |
A new debug system.
Instead of a single #define as debug area the new system allows for an
identifier for each debug message with the structure component.area.
The component is a dot separated identifier of the runtime component,
such as the process or the plugin.
The area is the code component, and can be as such defined at
compiletime.
The idea of this system is that it becomes possible to i.e. look at the
output of all messages in the query subsystem of a specific resource
(something that happens in the client process, but in the
resource-specific subcomponent).
The new macros are supposed to be less likely to clash with other names,
hence the new names.
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); |