File indexing completed on 2024-11-10 04:40:08
0001 /* 0002 * SPDX-FileCopyrightText: 2014 Christian Mollekopf <mollekopf@kolabsys.com> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "testsearchplugin.h" 0008 0009 #include "searchquery.h" 0010 #include <QDebug> 0011 #include <QVariant> 0012 0013 QSet<qint64> TestSearchPlugin::search(const QString &query, const QList<qint64> &collections, const QStringList &mimeTypes) 0014 { 0015 Q_UNUSED(collections) 0016 Q_UNUSED(mimeTypes) 0017 const QSet<qint64> result = parseQuery(query); 0018 qDebug() << "PLUGIN QUERY:" << query; 0019 qDebug() << "PLUGIN RESULT:" << result; 0020 return parseQuery(query); 0021 } 0022 0023 QSet<qint64> TestSearchPlugin::parseQuery(const QString &queryString) 0024 { 0025 QSet<qint64> resultSet; 0026 const Akonadi::SearchQuery query = Akonadi::SearchQuery::fromJSON(queryString.toLatin1()); 0027 const QList<Akonadi::SearchTerm> subTerms = query.term().subTerms(); 0028 for (const Akonadi::SearchTerm &term : subTerms) { 0029 if (term.key() == QLatin1StringView("plugin")) { 0030 resultSet << term.value().toInt(); 0031 } 0032 } 0033 return resultSet; 0034 } 0035 0036 #include "moc_testsearchplugin.cpp"