From ef205affdb73bfdbef5830996e6336e583660fbc Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Thu, 19 Nov 2015 09:37:42 +0100 Subject: Use the new modelresult in the dummyclient --- examples/client/main.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'examples/client') diff --git a/examples/client/main.cpp b/examples/client/main.cpp index 0a1a725..75fcf18 100644 --- a/examples/client/main.cpp +++ b/examples/client/main.cpp @@ -23,14 +23,13 @@ #include "common/clientapi.h" #include "common/resource.h" -#include "common/listmodelresult.h" #include "common/storage.h" #include "common/domain/event.h" #include "common/resourceconfig.h" #include "console.h" #include -#include +#include #include #include #include @@ -43,8 +42,8 @@ public: View(QAbstractItemModel *model) : QWidget() { - auto listView = new QListView(this); - listView->setModel(model); + auto modelView = new QTreeView(this); + modelView->setModel(model); resize(1000, 1500); auto topLayout = new QVBoxLayout(this); @@ -61,21 +60,23 @@ public: QObject::connect(syncButton, &QPushButton::pressed, []() { Akonadi2::Query query; query.resources << "org.kde.dummy.instance1"; - Akonadi2::Store::synchronize(query); + query.syncOnDemand = true; + Akonadi2::Store::synchronize(query).exec(); }); auto removeButton = new QPushButton(this); removeButton->setText("Remove"); - QObject::connect(removeButton, &QPushButton::pressed, [listView]() { - for (auto index :listView->selectionModel()->selectedIndexes()) { - auto object = index.data(DomainObjectRole).value(); + QObject::connect(removeButton, &QPushButton::pressed, [modelView]() { + for (auto index :modelView->selectionModel()->selectedIndexes()) { + auto object = index.data(Akonadi2::Store::DomainObjectRole).value(); Akonadi2::Store::remove(*object).exec(); } }); topLayout->addWidget(titleLabel); topLayout->addWidget(syncButton); - topLayout->addWidget(listView, 10); + topLayout->addWidget(modelView, 10); + model->fetchMore(QModelIndex()); show(); } @@ -123,8 +124,9 @@ int main(int argc, char *argv[]) query.syncOnDemand = false; query.processAll = false; query.liveQuery = true; + query.requestedProperties << "summary" << "uid"; - auto model = QSharedPointer >::create(Akonadi2::Store::load(query), QList() << "summary" << "uid"); + auto model = Akonadi2::Store::loadModel(query); auto view = QSharedPointer >::create(model.data()); return app.exec(); -- cgit v1.2.3