From 8d5684292ef92f32487ba32df716a00c4a0841b5 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Thu, 19 Nov 2015 17:37:39 +0100 Subject: Loading data with the new model for the test client --- common/clientapi.h | 2 +- common/domain/folder.cpp | 1 + common/facade.h | 1 - common/modelresult.h | 6 +++++- 4 files changed, 7 insertions(+), 3 deletions(-) (limited to 'common') 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: template static QSharedPointer loadModel(Query query) { - auto model = QSharedPointer >::create(query, QList() << "summary" << "uid"); + auto model = QSharedPointer >::create(query, query.requestedProperties.toList()); auto resultProvider = std::make_shared >(model); //Keep the resultprovider alive for as long as the model lives model->setProperty("resultProvider", QVariant::fromValue(std::shared_ptr(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::index(const QByteArray &identifier, const Buffe const auto parent = bufferAdaptor.getProperty("parent"); Trace() << "indexing " << identifier << " with parent " << parent.toByteArray(); if (parent.isValid()) { + Q_ASSERT(!parent.toByteArray().isEmpty()); Index("folder.index.parent", transaction).add(parent.toByteArray(), identifier); } else { 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: //Incremental updates are always loaded directly, leaving it up to the result to discard the changes if they are not interesting runner->setQuery([this, query, &resultProvider] () -> KAsync::Job { return KAsync::start([this, query, &resultProvider](KAsync::Future &future) { - Trace() << "Executing query "; const qint64 newRevision = executeIncrementalQuery(query, resultProvider); mResourceAccess->sendRevisionReplayedCommand(newRevision); 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: break; } } - beginInsertRows(parent, index, index); + if (mEntities.contains(childId)) { + qWarning() << "Entity already in model " << value->identifier(); + return; + } + beginInsertRows(QModelIndex(), index, index); mEntities.insert(childId, value); mTree[id].insert(index, childId); mParents.insert(childId, id); -- cgit v1.2.3