summaryrefslogtreecommitdiffstats
path: root/sinksh/sinksh_utils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'sinksh/sinksh_utils.cpp')
-rw-r--r--sinksh/sinksh_utils.cpp32
1 files changed, 19 insertions, 13 deletions
diff --git a/sinksh/sinksh_utils.cpp b/sinksh/sinksh_utils.cpp
index d5b1c22..9ff966b 100644
--- a/sinksh/sinksh_utils.cpp
+++ b/sinksh/sinksh_utils.cpp
@@ -24,10 +24,12 @@
24 24
25#include "utils.h" 25#include "utils.h"
26 26
27namespace SinkshUtils 27namespace SinkshUtils {
28{
29 28
30static QStringList s_types = QStringList() << "resource" << "folder" << "mail" << "event"; 29static QStringList s_types = QStringList() << "resource"
30 << "folder"
31 << "mail"
32 << "event";
31 33
32bool isValidStoreType(const QString &type) 34bool isValidStoreType(const QString &type)
33{ 35{
@@ -50,9 +52,9 @@ StoreBase &getStore(const QString &type)
50 return store; 52 return store;
51 } 53 }
52 54
53 //TODO: reinstate the warning+assert 55 // TODO: reinstate the warning+assert
54 //Q_ASSERT(false); 56 // Q_ASSERT(false);
55 //qWarning() << "Trying to get a store that doesn't exist, falling back to event"; 57 // qWarning() << "Trying to get a store that doesn't exist, falling back to event";
56 static Store<Sink::ApplicationDomain::Event> store; 58 static Store<Sink::ApplicationDomain::Event> store;
57 return store; 59 return store;
58} 60}
@@ -60,9 +62,12 @@ StoreBase &getStore(const QString &type)
60QSharedPointer<QAbstractItemModel> loadModel(const QString &type, Sink::Query query) 62QSharedPointer<QAbstractItemModel> loadModel(const QString &type, Sink::Query query)
61{ 63{
62 if (type == "folder") { 64 if (type == "folder") {
63 query.requestedProperties << "name" << "parent"; 65 query.requestedProperties << "name"
66 << "parent";
64 } else if (type == "mail") { 67 } else if (type == "mail") {
65 query.requestedProperties << "subject" << "folder" << "date"; 68 query.requestedProperties << "subject"
69 << "folder"
70 << "date";
66 } else if (type == "event") { 71 } else if (type == "event") {
67 query.requestedProperties << "summary"; 72 query.requestedProperties << "summary";
68 } else if (type == "resource") { 73 } else if (type == "resource") {
@@ -80,7 +85,7 @@ QStringList resourceIds(State &state)
80 query.liveQuery = false; 85 query.liveQuery = false;
81 auto model = SinkshUtils::loadModel("resource", query); 86 auto model = SinkshUtils::loadModel("resource", query);
82 87
83 QObject::connect(model.data(), &QAbstractItemModel::rowsInserted, [model, &resources] (const QModelIndex &index, int start, int end) mutable { 88 QObject::connect(model.data(), &QAbstractItemModel::rowsInserted, [model, &resources](const QModelIndex &index, int start, int end) mutable {
84 for (int i = start; i <= end; i++) { 89 for (int i = start; i <= end; i++) {
85 auto object = model->data(model->index(i, 0, index), Sink::Store::DomainObjectBaseRole).value<Sink::ApplicationDomain::ApplicationDomainType::Ptr>(); 90 auto object = model->data(model->index(i, 0, index), Sink::Store::DomainObjectBaseRole).value<Sink::ApplicationDomain::ApplicationDomainType::Ptr>();
86 resources << object->identifier(); 91 resources << object->identifier();
@@ -105,7 +110,10 @@ QStringList resourceCompleter(const QStringList &, const QString &fragment, Stat
105 110
106QStringList resourceOrTypeCompleter(const QStringList &commands, const QString &fragment, State &state) 111QStringList resourceOrTypeCompleter(const QStringList &commands, const QString &fragment, State &state)
107{ 112{
108 static QStringList types = QStringList() << "resource" << "folder" << "mail" << "event"; 113 static QStringList types = QStringList() << "resource"
114 << "folder"
115 << "mail"
116 << "event";
109 if (commands.count() == 1) { 117 if (commands.count() == 1) {
110 return Utils::filteredCompletions(s_types, fragment); 118 return Utils::filteredCompletions(s_types, fragment);
111 } 119 }
@@ -120,7 +128,7 @@ QStringList typeCompleter(const QStringList &commands, const QString &fragment,
120 128
121QMap<QString, QString> keyValueMapFromArgs(const QStringList &args) 129QMap<QString, QString> keyValueMapFromArgs(const QStringList &args)
122{ 130{
123 //TODO: this is not the most clever of algorithms. preserved during the port of commands 131 // TODO: this is not the most clever of algorithms. preserved during the port of commands
124 // from sink_client ... we can probably do better, however ;) 132 // from sink_client ... we can probably do better, however ;)
125 QMap<QString, QString> map; 133 QMap<QString, QString> map;
126 for (int i = 0; i + 2 <= args.size(); i += 2) { 134 for (int i = 0; i + 2 <= args.size(); i += 2) {
@@ -129,6 +137,4 @@ QMap<QString, QString> keyValueMapFromArgs(const QStringList &args)
129 137
130 return map; 138 return map;
131} 139}
132
133} 140}
134