diff options
Diffstat (limited to 'sinksh/syntax_modules/sink_list.cpp')
-rw-r--r-- | sinksh/syntax_modules/sink_list.cpp | 44 |
1 files changed, 13 insertions, 31 deletions
diff --git a/sinksh/syntax_modules/sink_list.cpp b/sinksh/syntax_modules/sink_list.cpp index b85de97..b20f3d4 100644 --- a/sinksh/syntax_modules/sink_list.cpp +++ b/sinksh/syntax_modules/sink_list.cpp | |||
@@ -31,6 +31,7 @@ | |||
31 | #include "common/log.h" | 31 | #include "common/log.h" |
32 | #include "common/storage.h" | 32 | #include "common/storage.h" |
33 | #include "common/definitions.h" | 33 | #include "common/definitions.h" |
34 | #include "common/store.h" | ||
34 | 35 | ||
35 | #include "sinksh_utils.h" | 36 | #include "sinksh_utils.h" |
36 | #include "state.h" | 37 | #include "state.h" |
@@ -70,45 +71,26 @@ bool list(const QStringList &args, State &state) | |||
70 | 71 | ||
71 | query.liveQuery = false; | 72 | query.liveQuery = false; |
72 | 73 | ||
73 | QTime time; | 74 | query.requestedProperties = SinkshUtils::requestedProperties(type); |
74 | time.start(); | ||
75 | auto model = SinkshUtils::loadModel(type, query); | ||
76 | if (state.debugLevel() > 0) { | ||
77 | state.printLine(QObject::tr("Folder type %1").arg(type)); | ||
78 | state.printLine(QObject::tr("Loaded model in %1 ms").arg(time.elapsed())); | ||
79 | } | ||
80 | 75 | ||
81 | //qDebug() << "Listing"; | ||
82 | QStringList line; | 76 | QStringList line; |
83 | line << QObject::tr("Resource") << QObject::tr("Identifier"); | 77 | line << QObject::tr("Resource") << QObject::tr("Identifier"); |
84 | for (int i = 0; i < model->columnCount(QModelIndex()); i++) { | 78 | for (const auto &prop: query.requestedProperties) { |
85 | line << model->headerData(i, Qt::Horizontal).toString(); | 79 | line << prop; |
86 | } | 80 | } |
87 | state.stageTableLine(line); | 81 | state.stageTableLine(line); |
88 | 82 | ||
89 | QObject::connect(model.data(), &QAbstractItemModel::rowsInserted, [model, state](const QModelIndex &index, int start, int end) { | 83 | for (const auto &o : SinkshUtils::getStore(type).read(query)) { |
90 | for (int i = start; i <= end; i++) { | 84 | QStringList line; |
91 | auto object = model->data(model->index(i, 0, index), Sink::Store::DomainObjectBaseRole).value<Sink::ApplicationDomain::ApplicationDomainType::Ptr>(); | 85 | line << o.resourceInstanceIdentifier(); |
92 | QStringList line; | 86 | line << o.identifier(); |
93 | line << object->resourceInstanceIdentifier(); | 87 | for (const auto &prop: query.requestedProperties) { |
94 | line << object->identifier(); | 88 | line << o.getProperty(prop).toString(); |
95 | for (int col = 0; col < model->columnCount(QModelIndex()); col++) { | ||
96 | line << model->data(model->index(i, col, index)).toString(); | ||
97 | } | ||
98 | state.stageTableLine(line); | ||
99 | } | ||
100 | }); | ||
101 | |||
102 | QObject::connect(model.data(), &QAbstractItemModel::dataChanged, [model, state](const QModelIndex &, const QModelIndex &, const QVector<int> &roles) { | ||
103 | if (roles.contains(Sink::Store::ChildrenFetchedRole)) { | ||
104 | state.flushTable(); | ||
105 | state.commandFinished(); | ||
106 | } | 89 | } |
107 | }); | 90 | state.stageTableLine(line); |
108 | |||
109 | if (!model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()) { | ||
110 | return true; | ||
111 | } | 91 | } |
92 | state.flushTable(); | ||
93 | state.commandFinished(); | ||
112 | 94 | ||
113 | return false; | 95 | return false; |
114 | } | 96 | } |