From 13560f13b1f3d204efc52944f0aaadbad5567d06 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Mon, 9 May 2016 09:48:07 +0200 Subject: Property filter for list --- sinksh/syntax_modules/sink_list.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'sinksh/syntax_modules') diff --git a/sinksh/syntax_modules/sink_list.cpp b/sinksh/syntax_modules/sink_list.cpp index cb71ce4..b85de97 100644 --- a/sinksh/syntax_modules/sink_list.cpp +++ b/sinksh/syntax_modules/sink_list.cpp @@ -46,8 +46,7 @@ bool list(const QStringList &args, State &state) return false; } - auto resources = args; - auto type = !resources.isEmpty() ? resources.takeFirst() : QString(); + auto type = !args.isEmpty() ? args.at(0) : QString(); if (!type.isEmpty() && !SinkshUtils::isValidStoreType(type)) { state.printError(QObject::tr("Unknown type: %1").arg(type)); @@ -55,9 +54,20 @@ bool list(const QStringList &args, State &state) } Sink::Query query; - for (const auto &res : resources) { - query.resources << res.toLatin1(); + + auto filterIndex = args.indexOf("--filter"); + if (filterIndex >= 0) { + for (int i = 1; i < filterIndex; i++) { + query.resources << args.at(i).toLatin1(); + query += Sink::Query::ResourceFilter(args.at(i).toLatin1()); + } + for (int i = filterIndex + 1; i < args.size(); i++) { + auto filter = args.at(i).split("="); + query += Sink::Query::PropertyFilter(filter.at(0).toLatin1(), filter.at(1)); + } + } + query.liveQuery = false; QTime time; -- cgit v1.2.3