diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-11-19 17:37:39 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-11-19 17:37:39 +0100 |
commit | 8d5684292ef92f32487ba32df716a00c4a0841b5 (patch) | |
tree | 1af55d3216f79175a55c1890d75cef2ae1f041d0 /common | |
parent | ef205affdb73bfdbef5830996e6336e583660fbc (diff) | |
download | sink-8d5684292ef92f32487ba32df716a00c4a0841b5.tar.gz sink-8d5684292ef92f32487ba32df716a00c4a0841b5.zip |
Loading data with the new model for the test client
Diffstat (limited to 'common')
-rw-r--r-- | common/clientapi.h | 2 | ||||
-rw-r--r-- | common/domain/folder.cpp | 1 | ||||
-rw-r--r-- | common/facade.h | 1 | ||||
-rw-r--r-- | common/modelresult.h | 6 |
4 files changed, 7 insertions, 3 deletions
diff --git a/common/clientapi.h b/common/clientapi.h index 179bb5c..6b11ad5 100644 --- a/common/clientapi.h +++ b/common/clientapi.h | |||
@@ -110,7 +110,7 @@ public: | |||
110 | template <class DomainType> | 110 | template <class DomainType> |
111 | static QSharedPointer<QAbstractItemModel> loadModel(Query query) | 111 | static QSharedPointer<QAbstractItemModel> loadModel(Query query) |
112 | { | 112 | { |
113 | auto model = QSharedPointer<ModelResult<DomainType, typename DomainType::Ptr> >::create(query, QList<QByteArray>() << "summary" << "uid"); | 113 | auto model = QSharedPointer<ModelResult<DomainType, typename DomainType::Ptr> >::create(query, query.requestedProperties.toList()); |
114 | auto resultProvider = std::make_shared<ModelResultProvider<DomainType, typename DomainType::Ptr> >(model); | 114 | auto resultProvider = std::make_shared<ModelResultProvider<DomainType, typename DomainType::Ptr> >(model); |
115 | //Keep the resultprovider alive for as long as the model lives | 115 | //Keep the resultprovider alive for as long as the model lives |
116 | model->setProperty("resultProvider", QVariant::fromValue(std::shared_ptr<void>(resultProvider))); | 116 | model->setProperty("resultProvider", QVariant::fromValue(std::shared_ptr<void>(resultProvider))); |
diff --git a/common/domain/folder.cpp b/common/domain/folder.cpp index 82f6c1f..989d2c4 100644 --- a/common/domain/folder.cpp +++ b/common/domain/folder.cpp | |||
@@ -60,6 +60,7 @@ void TypeImplementation<Folder>::index(const QByteArray &identifier, const Buffe | |||
60 | const auto parent = bufferAdaptor.getProperty("parent"); | 60 | const auto parent = bufferAdaptor.getProperty("parent"); |
61 | Trace() << "indexing " << identifier << " with parent " << parent.toByteArray(); | 61 | Trace() << "indexing " << identifier << " with parent " << parent.toByteArray(); |
62 | if (parent.isValid()) { | 62 | if (parent.isValid()) { |
63 | Q_ASSERT(!parent.toByteArray().isEmpty()); | ||
63 | Index("folder.index.parent", transaction).add(parent.toByteArray(), identifier); | 64 | Index("folder.index.parent", transaction).add(parent.toByteArray(), identifier); |
64 | } else { | 65 | } else { |
65 | Index("folder.index.parent", transaction).add("toplevel", identifier); | 66 | Index("folder.index.parent", transaction).add("toplevel", identifier); |
diff --git a/common/facade.h b/common/facade.h index f5c05f9..d150d60 100644 --- a/common/facade.h +++ b/common/facade.h | |||
@@ -184,7 +184,6 @@ public: | |||
184 | //Incremental updates are always loaded directly, leaving it up to the result to discard the changes if they are not interesting | 184 | //Incremental updates are always loaded directly, leaving it up to the result to discard the changes if they are not interesting |
185 | runner->setQuery([this, query, &resultProvider] () -> KAsync::Job<void> { | 185 | runner->setQuery([this, query, &resultProvider] () -> KAsync::Job<void> { |
186 | return KAsync::start<void>([this, query, &resultProvider](KAsync::Future<void> &future) { | 186 | return KAsync::start<void>([this, query, &resultProvider](KAsync::Future<void> &future) { |
187 | Trace() << "Executing query "; | ||
188 | const qint64 newRevision = executeIncrementalQuery(query, resultProvider); | 187 | const qint64 newRevision = executeIncrementalQuery(query, resultProvider); |
189 | mResourceAccess->sendRevisionReplayedCommand(newRevision); | 188 | mResourceAccess->sendRevisionReplayedCommand(newRevision); |
190 | future.setFinished(); | 189 | future.setFinished(); |
diff --git a/common/modelresult.h b/common/modelresult.h index 3b45955..1675e60 100644 --- a/common/modelresult.h +++ b/common/modelresult.h | |||
@@ -131,7 +131,11 @@ public: | |||
131 | break; | 131 | break; |
132 | } | 132 | } |
133 | } | 133 | } |
134 | beginInsertRows(parent, index, index); | 134 | if (mEntities.contains(childId)) { |
135 | qWarning() << "Entity already in model " << value->identifier(); | ||
136 | return; | ||
137 | } | ||
138 | beginInsertRows(QModelIndex(), index, index); | ||
135 | mEntities.insert(childId, value); | 139 | mEntities.insert(childId, value); |
136 | mTree[id].insert(index, childId); | 140 | mTree[id].insert(index, childId); |
137 | mParents.insert(childId, id); | 141 | mParents.insert(childId, id); |