diff options
Diffstat (limited to 'sinksh/syntax_modules/sink_stat.cpp')
-rw-r--r-- | sinksh/syntax_modules/sink_stat.cpp | 29 |
1 files changed, 5 insertions, 24 deletions
diff --git a/sinksh/syntax_modules/sink_stat.cpp b/sinksh/syntax_modules/sink_stat.cpp index 06586d9..9f0fe44 100644 --- a/sinksh/syntax_modules/sink_stat.cpp +++ b/sinksh/syntax_modules/sink_stat.cpp | |||
@@ -70,30 +70,11 @@ bool statAllResources(State &state) | |||
70 | { | 70 | { |
71 | Sink::Query query; | 71 | Sink::Query query; |
72 | query.liveQuery = false; | 72 | query.liveQuery = false; |
73 | auto model = SinkshUtils::loadModel("resource", query); | 73 | QStringList resources; |
74 | 74 | for (const auto &r : SinkshUtils::getStore("resource").read(query)) { | |
75 | //SUUUPER ugly, but can't think of a better way with 2 glasses of wine in me on Christmas day | 75 | resources << r.identifier(); |
76 | static QStringList resources; | ||
77 | resources.clear(); | ||
78 | |||
79 | QObject::connect(model.data(), &QAbstractItemModel::rowsInserted, [model](const QModelIndex &index, int start, int end) mutable { | ||
80 | for (int i = start; i <= end; i++) { | ||
81 | auto object = model->data(model->index(i, 0, index), Sink::Store::DomainObjectBaseRole).value<Sink::ApplicationDomain::ApplicationDomainType::Ptr>(); | ||
82 | resources << object->identifier(); | ||
83 | } | ||
84 | }); | ||
85 | |||
86 | QObject::connect(model.data(), &QAbstractItemModel::dataChanged, [model, state](const QModelIndex &, const QModelIndex &, const QVector<int> &roles) { | ||
87 | if (roles.contains(Sink::Store::ChildrenFetchedRole)) { | ||
88 | statResources(resources, state); | ||
89 | state.commandFinished(); | ||
90 | } | ||
91 | }); | ||
92 | |||
93 | if (!model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()) { | ||
94 | return true; | ||
95 | } | 76 | } |
96 | 77 | statResources(resources, state); | |
97 | return false; | 78 | return false; |
98 | } | 79 | } |
99 | 80 | ||
@@ -109,7 +90,7 @@ bool stat(const QStringList &args, State &state) | |||
109 | 90 | ||
110 | Syntax::List syntax() | 91 | Syntax::List syntax() |
111 | { | 92 | { |
112 | Syntax state("stat", QObject::tr("Shows database usage for the resources requested"), &SinkStat::stat, Syntax::EventDriven); | 93 | Syntax state("stat", QObject::tr("Shows database usage for the resources requested"), &SinkStat::stat, Syntax::NotInteractive); |
113 | state.completer = &SinkshUtils::resourceCompleter; | 94 | state.completer = &SinkshUtils::resourceCompleter; |
114 | 95 | ||
115 | return Syntax::List() << state; | 96 | return Syntax::List() << state; |