Akonadi

searchmanager.h
1 /*
2  SPDX-FileCopyrightText: 2010 Volker Krause <[email protected]>
3  SPDX-FileCopyrightText: 2013 Daniel Vr├ítil <[email protected]>
4 
5  SPDX-License-Identifier: LGPL-2.0-or-later
6 */
7 
8 #pragma once
9 
10 #include "akthread.h"
11 
12 #include <QMutex>
13 #include <QSet>
14 #include <QVector>
15 
16 class QTimer;
17 class QPluginLoader;
18 
19 namespace Akonadi
20 {
21 class AbstractSearchPlugin;
22 
23 namespace Server
24 {
25 class AbstractSearchEngine;
26 class Collection;
27 class SearchTaskManager;
28 
29 /**
30  * SearchManager creates and deletes persistent searches for all currently
31  * active search engines.
32  */
33 class SearchManager : public AkThread
34 {
35  Q_OBJECT
36  Q_CLASSINFO("D-Bus Interface", "org.freedesktop.Akonadi.SearchManager")
37 
38 protected:
39  /**
40  * Create a new search manager with the given @p searchEngines.
41  *
42  * Use AkThread::create() to create and start a new SearchManager thread.
43  **/
44  explicit SearchManager(const QStringList &searchEngines, SearchTaskManager &agentSearchManager);
45 
46 public:
47  ~SearchManager() override;
48 
49  /**
50  * Updates the search query asynchronously. Returns immediately
51  */
52  virtual void updateSearchAsync(const Collection &collection);
53 
54  /**
55  * Updates the search query synchronously.
56  */
57  virtual void updateSearch(const Collection &collection);
58 
59  /**
60  * Returns currently available search plugins.
61  */
63 
64 public Q_SLOTS:
65  virtual void scheduleSearchUpdate();
66 
67  /**
68  * This is called via D-Bus from AgentManager to register an agent with
69  * search interface.
70  */
71  virtual void registerInstance(const QString &id);
72 
73  /**
74  * This is called via D-Bus from AgentManager to unregister an agent with
75  * search interface.
76  */
77  virtual void unregisterInstance(const QString &id);
78 
79 private Q_SLOTS:
80  void searchUpdateTimeout();
81  void searchUpdateResultsAvailable(const QSet<qint64> &results);
82 
83  /**
84  * Actual implementation of search updates.
85  *
86  * This method has to be called using QMetaObject::invokeMethod.
87  */
88  void updateSearchImpl(const Akonadi::Server::Collection &collection);
89 
90 private:
91  void init() override;
92  void quit() override;
93 
94  // Called from main thread
95  void loadSearchPlugins();
96  // Called from manager thread
97  void initSearchPlugins();
98 
99  SearchTaskManager &mAgentSearchManager;
100  QStringList mEngineNames;
101  QVector<QPluginLoader *> mPluginLoaders;
104 
105  QTimer *mSearchUpdateTimer = nullptr;
106 
107  QMutex mLock;
108  QSet<qint64> mUpdatingCollections;
109 };
110 
111 } // namespace Server
112 } // namespace Akonadi
Q_OBJECTQ_OBJECT
SearchManager(const QStringList &searchEngines, SearchTaskManager &agentSearchManager)
Create a new search manager with the given searchEngines.
Q_SLOTSQ_SLOTS
Q_CLASSINFO(Name, Value)
virtual void updateSearch(const Collection &collection)
Updates the search query synchronously.
Represents a collection of PIM items.
Definition: collection.h:61
virtual void updateSearchAsync(const Collection &collection)
Updates the search query asynchronously.
virtual void unregisterInstance(const QString &id)
This is called via D-Bus from AgentManager to unregister an agent with search interface.
virtual QVector< AbstractSearchPlugin * > searchPlugins() const
Returns currently available search plugins.
virtual void registerInstance(const QString &id)
This is called via D-Bus from AgentManager to register an agent with search interface.
SearchManager creates and deletes persistent searches for all currently active search engines.
Definition: searchmanager.h:33
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon May 8 2023 03:52:16 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.