Akonadi Search

searchstore.h
1 /*
2  * This file is part of the KDE Akonadi Search Project
3  * SPDX-FileCopyrightText: 2013 Vishesh Handa <[email protected]>
4  *
5  * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
6  *
7  */
8 
9 #pragma once
10 
11 #include <QObject>
12 #include <QString>
13 #include <QUrl>
14 
15 #include "search_core_export.h"
16 
17 namespace Akonadi
18 {
19 /** Akonadi search infrastructure. */
20 namespace Search
21 {
22 class Query;
23 
24 /** Search store. */
25 class AKONADI_SEARCH_CORE_EXPORT SearchStore : public QObject
26 {
27  Q_OBJECT
28 public:
29  explicit SearchStore(QObject *parent = nullptr);
30  ~SearchStore() override;
31 
32  /**
33  * Override search stores for testing
34  */
35  static void overrideSearchStores(const QList<SearchStore *> &overrideSearchStores);
36 
38 
39  /**
40  * Gives a list of available search stores. These stores must be managed and
41  * deleted by the caller
42  */
43  static List searchStores();
44 
45  /**
46  * Returns a list of types which can be searched for
47  * in this store
48  */
49  virtual QStringList types() = 0;
50 
51  /**
52  * Executes the particular query synchronously.
53  *
54  * \return Returns a integer representing the integer
55  */
56  virtual int exec(const Query &query) = 0;
57  virtual bool next(int queryId) = 0;
58  virtual void close(int queryId) = 0;
59 
60  virtual QByteArray id(int queryId) = 0;
61 
62  virtual QUrl url(int queryId);
63  virtual QString text(int queryId);
64  virtual QString icon(int queryId);
65  virtual QString property(int queryId, const QString &propName);
66 };
67 
68 //
69 // Convenience functions
70 //
71 inline QByteArray serialize(const QByteArray &namespace_, int id)
72 {
73  return namespace_ + ':' + QByteArray::number(id);
74 }
75 
76 inline int deserialize(const QByteArray &namespace_, const QByteArray &str)
77 {
78  // The +1 is for the ':'
79  return str.mid(namespace_.size() + 1).toInt();
80 }
81 } // namespace Search
82 } // namespace Akonadi
83 
84 Q_DECLARE_INTERFACE(Akonadi::Search::SearchStore, "org.kde.Akonadi.Search.SearchStore")
QByteArray number(int n, int base)
QByteArray mid(int pos, int len) const const
int toInt(bool *ok, int base) const const
int size() const const
Search query.
Definition: core/query.h:26
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Dec 11 2023 04:06:30 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.