From ddd1616f5c310c94214e0ba2629f174c4cf768f3 Mon Sep 17 00:00:00 2001 From: Arno Date: Sat, 20 Aug 2016 10:13:44 +0200 Subject: Implement file search Search for a regular expression in all files of all torrents and select them. --- torrentparser.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'torrentparser.cpp') diff --git a/torrentparser.cpp b/torrentparser.cpp index 8e09681..cd2fde4 100644 --- a/torrentparser.cpp +++ b/torrentparser.cpp @@ -20,6 +20,34 @@ const QList TorrentParser::parse(){ return retval; } +const QStringList TorrentParser::files(QList data){ + QStringList retval; + foreach(QVariant cur, data){ + if(cur.canConvert()){ + QVariantHash h = cur.toHash(); + QHash::const_iterator it = h.constBegin(); + while(it != h.constEnd()){ + if(it.key() == "info"){ + QVariantHash infoD = it.value().toHash(); + if(infoD.contains("files")){ + QVariantList fileList = infoD.value("files").toList(); + foreach(QVariant fn, fileList){ + QVariantHash e = fn.toHash(); + QVariantList path = e.value("path").toList(); + retval << path.last().toString(); + } + }else{ + retval << infoD.value("name").toString(); + } + break; + } + ++it; + } + } + } + return retval; +} + const QVariant TorrentParser::parseObject(){ QChar cur = mData.at(mPos); if(cur == 'i'){ -- cgit v1.2.3-70-g09d2