diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-07-11 11:55:29 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-07-11 11:55:29 +0200 |
commit | 3a3118e768e1447dc7524328e84b8d7faef81fe1 (patch) | |
tree | af5582170ed6164fffc9365f34b17bf449c0db40 /sinksh/sinksh_utils.cpp | |
parent | f9379318d801df204cc50385c5eca1f28e91755e (diff) | |
parent | ce2fd2666f084eebe443598f6f3740a02913091e (diff) | |
download | sink-3a3118e768e1447dc7524328e84b8d7faef81fe1.tar.gz sink-3a3118e768e1447dc7524328e84b8d7faef81fe1.zip |
Merge branch 'feature/notifications' into develop
Diffstat (limited to 'sinksh/sinksh_utils.cpp')
-rw-r--r-- | sinksh/sinksh_utils.cpp | 40 |
1 files changed, 14 insertions, 26 deletions
diff --git a/sinksh/sinksh_utils.cpp b/sinksh/sinksh_utils.cpp index 091eb38..0e26c5a 100644 --- a/sinksh/sinksh_utils.cpp +++ b/sinksh/sinksh_utils.cpp | |||
@@ -21,6 +21,7 @@ | |||
21 | #include "sinksh_utils.h" | 21 | #include "sinksh_utils.h" |
22 | 22 | ||
23 | #include "common/store.h" | 23 | #include "common/store.h" |
24 | #include "common/log.h" | ||
24 | 25 | ||
25 | #include "utils.h" | 26 | #include "utils.h" |
26 | 27 | ||
@@ -88,48 +89,35 @@ QSharedPointer<QAbstractItemModel> loadModel(const QString &type, Sink::Query qu | |||
88 | return model; | 89 | return model; |
89 | } | 90 | } |
90 | 91 | ||
91 | QStringList resourceIds(State &state) | 92 | QStringList resourceIds() |
92 | { | 93 | { |
93 | QStringList resources; | ||
94 | Sink::Query query; | 94 | Sink::Query query; |
95 | query.liveQuery = false; | 95 | query.liveQuery = false; |
96 | auto model = SinkshUtils::loadModel("resource", query); | 96 | QStringList resources; |
97 | 97 | for (const auto &r : getStore("resource").read(query)) { | |
98 | QObject::connect(model.data(), &QAbstractItemModel::rowsInserted, [model, &resources](const QModelIndex &index, int start, int end) mutable { | 98 | resources << r.identifier(); |
99 | for (int i = start; i <= end; i++) { | 99 | } |
100 | auto object = model->data(model->index(i, 0, index), Sink::Store::DomainObjectBaseRole).value<Sink::ApplicationDomain::ApplicationDomainType::Ptr>(); | ||
101 | resources << object->identifier(); | ||
102 | } | ||
103 | }); | ||
104 | |||
105 | QObject::connect(model.data(), &QAbstractItemModel::dataChanged, [model, state](const QModelIndex &, const QModelIndex &, const QVector<int> &roles) { | ||
106 | if (roles.contains(Sink::Store::ChildrenFetchedRole)) { | ||
107 | state.commandFinished(); | ||
108 | } | ||
109 | }); | ||
110 | |||
111 | state.commandStarted(); | ||
112 | |||
113 | return resources; | 100 | return resources; |
114 | } | 101 | } |
115 | 102 | ||
103 | QStringList debugareaCompleter(const QStringList &, const QString &fragment, State &state) | ||
104 | { | ||
105 | return Utils::filteredCompletions(Sink::Log::debugAreas().toList(), fragment); | ||
106 | } | ||
107 | |||
116 | QStringList resourceCompleter(const QStringList &, const QString &fragment, State &state) | 108 | QStringList resourceCompleter(const QStringList &, const QString &fragment, State &state) |
117 | { | 109 | { |
118 | return Utils::filteredCompletions(resourceIds(state), fragment); | 110 | return Utils::filteredCompletions(resourceIds(), fragment); |
119 | } | 111 | } |
120 | 112 | ||
121 | QStringList resourceOrTypeCompleter(const QStringList &commands, const QString &fragment, State &state) | 113 | QStringList resourceOrTypeCompleter(const QStringList &commands, const QString &fragment, State &state) |
122 | { | 114 | { |
123 | static QStringList types = QStringList() << "resource" | 115 | static QStringList types = s_types; |
124 | << "folder" | ||
125 | << "mail" | ||
126 | << "event" | ||
127 | << "account"; | ||
128 | if (commands.count() == 1) { | 116 | if (commands.count() == 1) { |
129 | return Utils::filteredCompletions(s_types, fragment); | 117 | return Utils::filteredCompletions(s_types, fragment); |
130 | } | 118 | } |
131 | 119 | ||
132 | return Utils::filteredCompletions(resourceIds(state), fragment); | 120 | return Utils::filteredCompletions(resourceIds(), fragment); |
133 | } | 121 | } |
134 | 122 | ||
135 | QStringList typeCompleter(const QStringList &commands, const QString &fragment, State &state) | 123 | QStringList typeCompleter(const QStringList &commands, const QString &fragment, State &state) |