Akonadi

agentsearchinterface.h
1 /*
2  SPDX-FileCopyrightText: 2009 Volker Krause <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #pragma once
8 
9 #include "akonadiagentbase_export.h"
10 #include <QString>
11 
12 #include <memory>
13 
14 namespace Akonadi
15 {
16 class Collection;
17 class AgentSearchInterfacePrivate;
18 class ImapSet;
19 
20 /**
21  * @short An interface for agents (or resources) that support searching in their backend.
22  *
23  * Inherit from this additionally to Akonadi::AgentBase (or Akonadi::ResourceBase)
24  * and implement its two pure virtual methods.
25  *
26  * Make sure to add the @c Search capability to the agent desktop file.
27  *
28  * @since 4.5
29  */
30 class AKONADIAGENTBASE_EXPORT AgentSearchInterface
31 {
32 public:
33  enum ResultScope {
34  Uid,
35  Rid,
36  };
37 
38  /**
39  * Creates a new agent search interface.
40  */
42 
43  /**
44  * Destroys the agent search interface.
45  */
46  virtual ~AgentSearchInterface();
47 
48  /**
49  * Adds a new search.
50  *
51  * @param query The query string, using the language specified in @p queryLanguage
52  * @param queryLanguage The query language used for @p query
53  * @param resultCollection The destination collection for the search results. It's a virtual
54  * collection, results can be added/removed using Akonadi::LinkJob and Akonadi::UnlinkJob respectively.
55  */
56  virtual void addSearch(const QString &query, const QString &queryLanguage, const Akonadi::Collection &resultCollection) = 0;
57 
58  /**
59  * Removes a previously added search.
60  * @param resultCollection The result collection given in an previous addSearch() call.
61  * You do not need to take care of deleting results in there, the collection is just provided as a way to
62  * identify the search.
63  */
64  virtual void removeSearch(const Akonadi::Collection &resultCollection) = 0;
65 
66  /**
67  * Perform a search on remote storage and return results using SearchResultJob.
68  *
69  * @since 4.13
70  */
71  virtual void search(const QString &query, const Collection &collection) = 0;
72 
73  void searchFinished(const QVector<qint64> &result, ResultScope scope);
74  void searchFinished(const ImapSet &result, ResultScope scope);
75  void searchFinished(const QVector<QByteArray> &result);
76 
77 private:
78  /// @cond PRIVATE
79  std::unique_ptr<AgentSearchInterfacePrivate> const d;
80  /// @endcond
81 };
82 
83 }
84 
An interface for agents (or resources) that support searching in their backend.
Represents a collection of PIM items.
Definition: collection.h:61
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu Jun 30 2022 03:51:45 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.