diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-12-04 16:40:28 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-12-04 16:40:28 +0100 |
commit | 46570dd9684990846cfd4c3dc5be71498c5a6278 (patch) | |
tree | 3dc2369059f795f4be2ff6e2bca84db0c5bde749 /examples/client/main.cpp | |
parent | 983af5f1442ff27dc14da6fdac28f51a38184f0a (diff) | |
download | sink-46570dd9684990846cfd4c3dc5be71498c5a6278.tar.gz sink-46570dd9684990846cfd4c3dc5be71498c5a6278.zip |
example client and properties
Diffstat (limited to 'examples/client/main.cpp')
-rw-r--r-- | examples/client/main.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/examples/client/main.cpp b/examples/client/main.cpp index 31947e8..8e1cc80 100644 --- a/examples/client/main.cpp +++ b/examples/client/main.cpp | |||
@@ -115,7 +115,7 @@ static QSharedPointer<QAbstractItemModel> loadModel(const QString &type, Akonadi | |||
115 | query.requestedProperties << "name" << "parent"; | 115 | query.requestedProperties << "name" << "parent"; |
116 | model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Folder>(query); | 116 | model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Folder>(query); |
117 | } else if (type == "mail") { | 117 | } else if (type == "mail") { |
118 | query.requestedProperties << "subject" << "folder"; | 118 | query.requestedProperties << "subject" << "folder" << "date"; |
119 | model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Mail>(query); | 119 | model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Mail>(query); |
120 | } else if (type == "event") { | 120 | } else if (type == "event") { |
121 | query.requestedProperties << "summary"; | 121 | query.requestedProperties << "summary"; |
@@ -133,15 +133,19 @@ int main(int argc, char *argv[]) | |||
133 | QCommandLineParser cliOptions; | 133 | QCommandLineParser cliOptions; |
134 | cliOptions.addPositionalArgument(QObject::tr("[resource]"), | 134 | cliOptions.addPositionalArgument(QObject::tr("[resource]"), |
135 | QObject::tr("A resource to connect to")); | 135 | QObject::tr("A resource to connect to")); |
136 | cliOptions.addPositionalArgument(QObject::tr("[type]"), | ||
137 | QObject::tr("A type to work with")); | ||
136 | cliOptions.addOption(QCommandLineOption("clear")); | 138 | cliOptions.addOption(QCommandLineOption("clear")); |
137 | cliOptions.addOption(QCommandLineOption("debuglevel")); | 139 | cliOptions.addOption(QCommandLineOption("debuglevel")); |
138 | cliOptions.addOption(QCommandLineOption("type", "type to list", "type")); | 140 | // cliOptions.addOption(QCommandLineOption("type", "type to list", "type")); |
139 | cliOptions.addOption(QCommandLineOption("list")); | 141 | cliOptions.addOption(QCommandLineOption("list")); |
140 | cliOptions.addOption(QCommandLineOption("count")); | 142 | cliOptions.addOption(QCommandLineOption("count")); |
141 | cliOptions.addOption(QCommandLineOption("synchronize")); | 143 | cliOptions.addOption(QCommandLineOption("synchronize")); |
142 | cliOptions.addHelpOption(); | 144 | cliOptions.addHelpOption(); |
143 | cliOptions.process(app); | 145 | cliOptions.process(app); |
144 | QStringList resources = cliOptions.positionalArguments(); | 146 | QStringList args = cliOptions.positionalArguments(); |
147 | auto type = args.takeLast(); | ||
148 | auto resources = args; | ||
145 | if (resources.isEmpty()) { | 149 | if (resources.isEmpty()) { |
146 | resources << "org.kde.dummy.instance1"; | 150 | resources << "org.kde.dummy.instance1"; |
147 | } | 151 | } |
@@ -172,7 +176,6 @@ int main(int argc, char *argv[]) | |||
172 | query.processAll = false; | 176 | query.processAll = false; |
173 | query.liveQuery = true; | 177 | query.liveQuery = true; |
174 | 178 | ||
175 | const auto type = cliOptions.value("type"); | ||
176 | qDebug() << "Type: " << type; | 179 | qDebug() << "Type: " << type; |
177 | 180 | ||
178 | if (cliOptions.isSet("list")) { | 181 | if (cliOptions.isSet("list")) { |
@@ -181,8 +184,9 @@ int main(int argc, char *argv[]) | |||
181 | qDebug() << "Listing"; | 184 | qDebug() << "Listing"; |
182 | std::cout << "\tColumn\t "; | 185 | std::cout << "\tColumn\t "; |
183 | for (int i = 0; i < model->columnCount(QModelIndex()); i++) { | 186 | for (int i = 0; i < model->columnCount(QModelIndex()); i++) { |
184 | std::cout << "\t" << model->headerData(i, Qt::Horizontal).toString().toStdString() << std::endl; | 187 | std::cout << "\t" << model->headerData(i, Qt::Horizontal).toString().toStdString(); |
185 | } | 188 | } |
189 | std::cout << std::endl; | ||
186 | QObject::connect(model.data(), &QAbstractItemModel::rowsInserted, [model](const QModelIndex &index, int start, int end) { | 190 | QObject::connect(model.data(), &QAbstractItemModel::rowsInserted, [model](const QModelIndex &index, int start, int end) { |
187 | for (int i = start; i <= end; i++) { | 191 | for (int i = start; i <= end; i++) { |
188 | std::cout << "\tRow " << model->rowCount() << ":\t "; | 192 | std::cout << "\tRow " << model->rowCount() << ":\t "; |