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 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 --- examples/client/main.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'examples/client') diff --git a/examples/client/main.cpp b/examples/client/main.cpp index 75fcf18..794fc58 100644 --- a/examples/client/main.cpp +++ b/examples/client/main.cpp @@ -25,6 +25,7 @@ #include "common/resource.h" #include "common/storage.h" #include "common/domain/event.h" +#include "common/domain/folder.h" #include "common/resourceconfig.h" #include "console.h" @@ -124,10 +125,10 @@ int main(int argc, char *argv[]) query.syncOnDemand = false; query.processAll = false; query.liveQuery = true; - query.requestedProperties << "summary" << "uid"; + query.requestedProperties << "name"; - auto model = Akonadi2::Store::loadModel(query); - auto view = QSharedPointer >::create(model.data()); + auto model = Akonadi2::Store::loadModel(query); + auto view = QSharedPointer >::create(model.data()); return app.exec(); } -- cgit v1.2.3 From 0118cd09f9a2cc956ae0a07b3ba8ad3c95314cab Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Fri, 27 Nov 2015 17:44:21 +0100 Subject: list and count options for non-gui operations --- examples/client/main.cpp | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'examples/client') diff --git a/examples/client/main.cpp b/examples/client/main.cpp index 794fc58..c75b3ce 100644 --- a/examples/client/main.cpp +++ b/examples/client/main.cpp @@ -68,7 +68,7 @@ public: auto removeButton = new QPushButton(this); removeButton->setText("Remove"); QObject::connect(removeButton, &QPushButton::pressed, [modelView]() { - for (auto index :modelView->selectionModel()->selectedIndexes()) { + for (auto index : modelView->selectionModel()->selectedIndexes()) { auto object = index.data(Akonadi2::Store::DomainObjectRole).value(); Akonadi2::Store::remove(*object).exec(); } @@ -93,6 +93,8 @@ int main(int argc, char *argv[]) QObject::tr("A resource to connect to")); cliOptions.addOption(QCommandLineOption("clear")); cliOptions.addOption(QCommandLineOption("debuglevel")); + cliOptions.addOption(QCommandLineOption("list")); + cliOptions.addOption(QCommandLineOption("count")); cliOptions.addHelpOption(); cliOptions.process(app); QStringList resources = cliOptions.positionalArguments(); @@ -124,11 +126,27 @@ int main(int argc, char *argv[]) } query.syncOnDemand = false; query.processAll = false; - query.liveQuery = true; query.requestedProperties << "name"; auto model = Akonadi2::Store::loadModel(query); - auto view = QSharedPointer >::create(model.data()); - - return app.exec(); + if (cliOptions.isSet("list")) { + query.liveQuery = false; + qDebug() << "Listing"; + QObject::connect(model.data(), &QAbstractItemModel::rowsInserted, [model](const QModelIndex &index, int start, int end) { + for (int i = start; i <= end; i++) { + qDebug() << model->data(model->index(i, 0, index)).toString(); + } + }); + model->fetchMore(QModelIndex()); + return app.exec(); + } else if (cliOptions.isSet("count")) { + query.liveQuery = false; + model->fetchMore(QModelIndex()); + qDebug() << "Counted results " << model->rowCount(QModelIndex()); + } else { + query.liveQuery = true; + auto view = QSharedPointer >::create(model.data()); + return app.exec(); + } + return 0; } -- cgit v1.2.3 From 4926e7f613ea3e03a2865eec66c6a8c1ec0b6516 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Sat, 28 Nov 2015 16:07:15 +0100 Subject: Cleanup --- examples/client/main.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'examples/client') diff --git a/examples/client/main.cpp b/examples/client/main.cpp index c75b3ce..3fa5a4e 100644 --- a/examples/client/main.cpp +++ b/examples/client/main.cpp @@ -77,7 +77,6 @@ public: topLayout->addWidget(titleLabel); topLayout->addWidget(syncButton); topLayout->addWidget(modelView, 10); - model->fetchMore(QModelIndex()); show(); } @@ -127,6 +126,7 @@ int main(int argc, char *argv[]) query.syncOnDemand = false; query.processAll = false; query.requestedProperties << "name"; + query.liveQuery = true; auto model = Akonadi2::Store::loadModel(query); if (cliOptions.isSet("list")) { @@ -137,11 +137,9 @@ int main(int argc, char *argv[]) qDebug() << model->data(model->index(i, 0, index)).toString(); } }); - model->fetchMore(QModelIndex()); return app.exec(); } else if (cliOptions.isSet("count")) { query.liveQuery = false; - model->fetchMore(QModelIndex()); qDebug() << "Counted results " << model->rowCount(QModelIndex()); } else { query.liveQuery = true; -- cgit v1.2.3 From 887abffb3f712acaa23eae174d5890f337fe43cb Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Sat, 28 Nov 2015 16:20:38 +0100 Subject: Cleanup --- examples/client/main.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'examples/client') diff --git a/examples/client/main.cpp b/examples/client/main.cpp index 3fa5a4e..7e69c0a 100644 --- a/examples/client/main.cpp +++ b/examples/client/main.cpp @@ -27,6 +27,7 @@ #include "common/domain/event.h" #include "common/domain/folder.h" #include "common/resourceconfig.h" +#include "common/log.h" #include "console.h" #include -- cgit v1.2.3 From 6ad307dd846d07f1b55a1679a8d2eb47525af57d Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Mon, 30 Nov 2015 18:46:50 +0100 Subject: example client: slot performance measurements, async commands --- examples/client/main.cpp | 47 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 4 deletions(-) (limited to 'examples/client') diff --git a/examples/client/main.cpp b/examples/client/main.cpp index 7e69c0a..2aeb328 100644 --- a/examples/client/main.cpp +++ b/examples/client/main.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include "common/clientapi.h" #include "common/resource.h" @@ -36,6 +37,7 @@ #include #include #include +#include template class View : public QWidget @@ -84,9 +86,29 @@ public: }; + +class MyApplication : public QApplication +{ + QElapsedTimer t; +public: + MyApplication(int& argc, char ** argv) : QApplication(argc, argv) { } + virtual ~MyApplication() { } + + virtual bool notify(QObject* receiver, QEvent* event) + { + t.start(); + bool ret = QApplication::notify(receiver, event); + if(t.elapsed() > 3) + qDebug("processing event type %d for object %s took %dms", + (int)event->type(), receiver->objectName().toLocal8Bit().data(), + (int)t.elapsed()); + return ret; + } +}; + int main(int argc, char *argv[]) { - QApplication app(argc, argv); + MyApplication app(argc, argv); QCommandLineParser cliOptions; cliOptions.addPositionalArgument(QObject::tr("[resource]"), @@ -129,19 +151,36 @@ int main(int argc, char *argv[]) query.requestedProperties << "name"; query.liveQuery = true; + QTime time; + time.start(); auto model = Akonadi2::Store::loadModel(query); + qDebug() << "Loaded model in " << time.elapsed() << " ms"; + if (cliOptions.isSet("list")) { query.liveQuery = false; qDebug() << "Listing"; QObject::connect(model.data(), &QAbstractItemModel::rowsInserted, [model](const QModelIndex &index, int start, int end) { for (int i = start; i <= end; i++) { - qDebug() << model->data(model->index(i, 0, index)).toString(); + std::cout << "\tRow " << model->rowCount() << ": " << model->data(model->index(i, 0, index)).toString().toStdString() << std::endl; } }); - return app.exec(); + QObject::connect(model.data(), &QAbstractItemModel::dataChanged, [model, &app](const QModelIndex &, const QModelIndex &, const QVector &roles) { + if (roles.contains(Akonadi2::Store::ChildrenFetchedRole)) { + app.quit(); + } + }); + if (!model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()) { + return app.exec(); + } } else if (cliOptions.isSet("count")) { query.liveQuery = false; - qDebug() << "Counted results " << model->rowCount(QModelIndex()); + QObject::connect(model.data(), &QAbstractItemModel::dataChanged, [model, &app](const QModelIndex &, const QModelIndex &, const QVector &roles) { + if (roles.contains(Akonadi2::Store::ChildrenFetchedRole)) { + std::cout << "\tCounted results " << model->rowCount(QModelIndex()); + app.quit(); + } + }); + return app.exec(); } else { query.liveQuery = true; auto view = QSharedPointer >::create(model.data()); -- cgit v1.2.3