File indexing completed on 2024-11-10 04:40:53
0001 /* 0002 SPDX-FileCopyrightText: 2013, 2014 Daniel Vrátil <dvratil@redhat.com> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include <QList> 0010 #include <QObject> 0011 #include <QSet> 0012 #include <QStringList> 0013 0014 namespace Akonadi 0015 { 0016 namespace Server 0017 { 0018 class Connection; 0019 class SearchManager; 0020 class SearchTaskManager; 0021 0022 class SearchRequest : public QObject 0023 { 0024 Q_OBJECT 0025 0026 public: 0027 explicit SearchRequest(const QByteArray &connectionId, SearchManager &searchManager, SearchTaskManager &agentSearchTask); 0028 ~SearchRequest() override; 0029 0030 void setQuery(const QString &query); 0031 QString query() const; 0032 void setCollections(const QList<qint64> &collections); 0033 QList<qint64> collections() const; 0034 void setMimeTypes(const QStringList &mimeTypes); 0035 QStringList mimeTypes() const; 0036 void setRemoteSearch(bool remote); 0037 bool remoteSearch() const; 0038 0039 /** 0040 * Whether results should be stored after they are emitted via resultsAvailable(), 0041 * so that they can be extracted via results() after the search is over. This 0042 * is disabled by default. 0043 */ 0044 void setStoreResults(bool storeResults); 0045 0046 QByteArray connectionId() const; 0047 0048 void exec(); 0049 0050 QSet<qint64> results() const; 0051 0052 Q_SIGNALS: 0053 void resultsAvailable(const QSet<qint64> &results); 0054 0055 private: 0056 void searchPlugins(); 0057 void emitResults(const QSet<qint64> &results); 0058 0059 QByteArray mConnectionId; 0060 QString mQuery; 0061 QList<qint64> mCollections; 0062 QStringList mMimeTypes; 0063 bool mRemoteSearch = false; 0064 bool mStoreResults = false; 0065 QSet<qint64> mResults; 0066 0067 SearchManager &mSearchManager; 0068 SearchTaskManager &mAgentSearchManager; 0069 }; 0070 0071 } // namespace Server 0072 } // namespace Akonadi