Akonadi

searchmanager.h
1/*
2 SPDX-FileCopyrightText: 2010 Volker Krause <vkrause@kde.org>
3 SPDX-FileCopyrightText: 2013 Daniel Vrátil <dvratil@redhat.com>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#pragma once
9
10#include "akthread.h"
11
12#include <QList>
13#include <QMutex>
14#include <QSet>
15
16class QTimer;
17class QPluginLoader;
18
19namespace Akonadi
20{
21class AbstractSearchPlugin;
22
23namespace Server
24{
25class AbstractSearchEngine;
26class Collection;
27class SearchTaskManager;
28
29/**
30 * SearchManager creates and deletes persistent searches for all currently
31 * active search engines.
32 */
33class SearchManager : public AkThread
34{
36 Q_CLASSINFO("D-Bus Interface", "org.freedesktop.Akonadi.SearchManager")
37
38protected:
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
46public:
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
64public 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
79private 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
90private:
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 QList<QPluginLoader *> mPluginLoaders;
104
105 QTimer *mSearchUpdateTimer = nullptr;
106
107 QMutex mLock;
108 QSet<qint64> mUpdatingCollections;
109};
110
111} // namespace Server
112} // namespace Akonadi
Represents a collection of PIM items.
Definition collection.h:62
SearchManager creates and deletes persistent searches for all currently active search engines.
virtual void registerInstance(const QString &id)
This is called via D-Bus from AgentManager to register an agent with search interface.
SearchManager(const QStringList &searchEngines, SearchTaskManager &agentSearchManager)
Create a new search manager with the given searchEngines.
virtual QList< AbstractSearchPlugin * > searchPlugins() const
Returns currently available search plugins.
virtual void updateSearch(const Collection &collection)
Updates the search query synchronously.
virtual void unregisterInstance(const QString &id)
This is called via D-Bus from AgentManager to unregister an agent with search interface.
virtual void updateSearchAsync(const Collection &collection)
Updates the search query asynchronously.
Helper integration between Akonadi and Qt.
Q_CLASSINFO(Name, Value)
Q_OBJECTQ_OBJECT
Q_SLOTSQ_SLOTS
T qobject_cast(QObject *object)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jun 7 2024 11:56:45 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.