diff options
Diffstat (limited to 'sinksh/sinksh_utils.cpp')
-rw-r--r-- | sinksh/sinksh_utils.cpp | 28 |
1 files changed, 7 insertions, 21 deletions
diff --git a/sinksh/sinksh_utils.cpp b/sinksh/sinksh_utils.cpp index 14b0aab..0e26c5a 100644 --- a/sinksh/sinksh_utils.cpp +++ b/sinksh/sinksh_utils.cpp | |||
@@ -89,28 +89,14 @@ QSharedPointer<QAbstractItemModel> loadModel(const QString &type, Sink::Query qu | |||
89 | return model; | 89 | return model; |
90 | } | 90 | } |
91 | 91 | ||
92 | QStringList resourceIds(State &state) | 92 | QStringList resourceIds() |
93 | { | 93 | { |
94 | QStringList resources; | ||
95 | Sink::Query query; | 94 | Sink::Query query; |
96 | query.liveQuery = false; | 95 | query.liveQuery = false; |
97 | auto model = SinkshUtils::loadModel("resource", query); | 96 | QStringList resources; |
98 | 97 | for (const auto &r : getStore("resource").read(query)) { | |
99 | QObject::connect(model.data(), &QAbstractItemModel::rowsInserted, [model, &resources](const QModelIndex &index, int start, int end) mutable { | 98 | resources << r.identifier(); |
100 | for (int i = start; i <= end; i++) { | 99 | } |
101 | auto object = model->data(model->index(i, 0, index), Sink::Store::DomainObjectBaseRole).value<Sink::ApplicationDomain::ApplicationDomainType::Ptr>(); | ||
102 | resources << object->identifier(); | ||
103 | } | ||
104 | }); | ||
105 | |||
106 | QObject::connect(model.data(), &QAbstractItemModel::dataChanged, [model, state](const QModelIndex &, const QModelIndex &, const QVector<int> &roles) { | ||
107 | if (roles.contains(Sink::Store::ChildrenFetchedRole)) { | ||
108 | state.commandFinished(); | ||
109 | } | ||
110 | }); | ||
111 | |||
112 | state.commandStarted(); | ||
113 | |||
114 | return resources; | 100 | return resources; |
115 | } | 101 | } |
116 | 102 | ||
@@ -121,7 +107,7 @@ QStringList debugareaCompleter(const QStringList &, const QString &fragment, Sta | |||
121 | 107 | ||
122 | QStringList resourceCompleter(const QStringList &, const QString &fragment, State &state) | 108 | QStringList resourceCompleter(const QStringList &, const QString &fragment, State &state) |
123 | { | 109 | { |
124 | return Utils::filteredCompletions(resourceIds(state), fragment); | 110 | return Utils::filteredCompletions(resourceIds(), fragment); |
125 | } | 111 | } |
126 | 112 | ||
127 | QStringList resourceOrTypeCompleter(const QStringList &commands, const QString &fragment, State &state) | 113 | QStringList resourceOrTypeCompleter(const QStringList &commands, const QString &fragment, State &state) |
@@ -131,7 +117,7 @@ QStringList resourceOrTypeCompleter(const QStringList &commands, const QString & | |||
131 | return Utils::filteredCompletions(s_types, fragment); | 117 | return Utils::filteredCompletions(s_types, fragment); |
132 | } | 118 | } |
133 | 119 | ||
134 | return Utils::filteredCompletions(resourceIds(state), fragment); | 120 | return Utils::filteredCompletions(resourceIds(), fragment); |
135 | } | 121 | } |
136 | 122 | ||
137 | QStringList typeCompleter(const QStringList &commands, const QString &fragment, State &state) | 123 | QStringList typeCompleter(const QStringList &commands, const QString &fragment, State &state) |