summaryrefslogtreecommitdiffstats
path: root/examples/client/main.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2015-11-19 09:37:42 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2015-11-19 09:37:42 +0100
commitef205affdb73bfdbef5830996e6336e583660fbc (patch)
treeaba43d38e6ea9a2b48a6818978bad123fbb5bcc0 /examples/client/main.cpp
parentb42047ad90470ecab329375fdacff03564c80074 (diff)
downloadsink-ef205affdb73bfdbef5830996e6336e583660fbc.tar.gz
sink-ef205affdb73bfdbef5830996e6336e583660fbc.zip
Use the new modelresult in the dummyclient
Diffstat (limited to 'examples/client/main.cpp')
-rw-r--r--examples/client/main.cpp22
1 files changed, 12 insertions, 10 deletions
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 @@
23 23
24#include "common/clientapi.h" 24#include "common/clientapi.h"
25#include "common/resource.h" 25#include "common/resource.h"
26#include "common/listmodelresult.h"
27#include "common/storage.h" 26#include "common/storage.h"
28#include "common/domain/event.h" 27#include "common/domain/event.h"
29#include "common/resourceconfig.h" 28#include "common/resourceconfig.h"
30#include "console.h" 29#include "console.h"
31 30
32#include <QWidget> 31#include <QWidget>
33#include <QListView> 32#include <QTreeView>
34#include <QVBoxLayout> 33#include <QVBoxLayout>
35#include <QLabel> 34#include <QLabel>
36#include <QPushButton> 35#include <QPushButton>
@@ -43,8 +42,8 @@ public:
43 View(QAbstractItemModel *model) 42 View(QAbstractItemModel *model)
44 : QWidget() 43 : QWidget()
45 { 44 {
46 auto listView = new QListView(this); 45 auto modelView = new QTreeView(this);
47 listView->setModel(model); 46 modelView->setModel(model);
48 resize(1000, 1500); 47 resize(1000, 1500);
49 48
50 auto topLayout = new QVBoxLayout(this); 49 auto topLayout = new QVBoxLayout(this);
@@ -61,21 +60,23 @@ public:
61 QObject::connect(syncButton, &QPushButton::pressed, []() { 60 QObject::connect(syncButton, &QPushButton::pressed, []() {
62 Akonadi2::Query query; 61 Akonadi2::Query query;
63 query.resources << "org.kde.dummy.instance1"; 62 query.resources << "org.kde.dummy.instance1";
64 Akonadi2::Store::synchronize(query); 63 query.syncOnDemand = true;
64 Akonadi2::Store::synchronize(query).exec();
65 }); 65 });
66 66
67 auto removeButton = new QPushButton(this); 67 auto removeButton = new QPushButton(this);
68 removeButton->setText("Remove"); 68 removeButton->setText("Remove");
69 QObject::connect(removeButton, &QPushButton::pressed, [listView]() { 69 QObject::connect(removeButton, &QPushButton::pressed, [modelView]() {
70 for (auto index :listView->selectionModel()->selectedIndexes()) { 70 for (auto index :modelView->selectionModel()->selectedIndexes()) {
71 auto object = index.data(DomainObjectRole).value<typename T::Ptr>(); 71 auto object = index.data(Akonadi2::Store::DomainObjectRole).value<typename T::Ptr>();
72 Akonadi2::Store::remove(*object).exec(); 72 Akonadi2::Store::remove(*object).exec();
73 } 73 }
74 }); 74 });
75 75
76 topLayout->addWidget(titleLabel); 76 topLayout->addWidget(titleLabel);
77 topLayout->addWidget(syncButton); 77 topLayout->addWidget(syncButton);
78 topLayout->addWidget(listView, 10); 78 topLayout->addWidget(modelView, 10);
79 model->fetchMore(QModelIndex());
79 80
80 show(); 81 show();
81 } 82 }
@@ -123,8 +124,9 @@ int main(int argc, char *argv[])
123 query.syncOnDemand = false; 124 query.syncOnDemand = false;
124 query.processAll = false; 125 query.processAll = false;
125 query.liveQuery = true; 126 query.liveQuery = true;
127 query.requestedProperties << "summary" << "uid";
126 128
127 auto model = QSharedPointer<ListModelResult<Akonadi2::ApplicationDomain::Event::Ptr> >::create(Akonadi2::Store::load<Akonadi2::ApplicationDomain::Event>(query), QList<QByteArray>() << "summary" << "uid"); 129 auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Event>(query);
128 auto view = QSharedPointer<View<Akonadi2::ApplicationDomain::Event> >::create(model.data()); 130 auto view = QSharedPointer<View<Akonadi2::ApplicationDomain::Event> >::create(model.data());
129 131
130 return app.exec(); 132 return app.exec();