From 4c20cc0d27295d2ea8661e8823c75821ef99f996 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Mon, 7 Dec 2015 07:44:09 +0100 Subject: Example client: only load hierarchies if there is one --- examples/client/main.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'examples/client/main.cpp') diff --git a/examples/client/main.cpp b/examples/client/main.cpp index 8e1cc80..e0d9078 100644 --- a/examples/client/main.cpp +++ b/examples/client/main.cpp @@ -209,7 +209,7 @@ int main(int argc, char *argv[]) auto model = loadModel(type, query); 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()); + std::cout << "\tCounted results " << model->rowCount(QModelIndex()) << std::endl; app.quit(); } }); @@ -222,15 +222,17 @@ int main(int argc, char *argv[]) }).exec(); app.exec(); } else { - query.parentProperty = "parent"; query.liveQuery = true; + if (type == "folder") { + query.parentProperty = "parent"; + } auto model = loadModel(type, query); - QObject::connect(model.data(), &QAbstractItemModel::rowsInserted, [model](const QModelIndex &index, int start, int end) { - for (int i = start; i <= end; i++) { - model->fetchMore(model->index(i, 0, index)); - } - }); if (type == "folder") { + QObject::connect(model.data(), &QAbstractItemModel::rowsInserted, [model](const QModelIndex &index, int start, int end) { + for (int i = start; i <= end; i++) { + model->fetchMore(model->index(i, 0, index)); + } + }); auto view = QSharedPointer >::create(model.data()); app.exec(); } else if (type == "mail") { -- cgit v1.2.3