Akonadi Search

searchstore.h
1/*
2 * This file is part of the KDE Akonadi Search Project
3 * SPDX-FileCopyrightText: 2013 Vishesh Handa <me@vhanda.in>
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
17namespace Akonadi
18{
19/** Akonadi search infrastructure. */
20namespace Search
21{
22class Query;
23
24/** Search store. */
25class AKONADI_SEARCH_CORE_EXPORT SearchStore : public QObject
26{
27 Q_OBJECT
28public:
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 [[nodiscard]] virtual QByteArray id(int queryId) = 0;
61
62 [[nodiscard]] virtual QUrl url(int queryId);
63 [[nodiscard]] virtual QString text(int queryId);
64 [[nodiscard]] virtual QString icon(int queryId);
65 [[nodiscard]] virtual QString property(int queryId, const QString &propName);
66};
67
68//
69// Convenience functions
70//
71inline QByteArray serialize(const QByteArray &namespace_, int id)
72{
73 return namespace_ + ':' + QByteArray::number(id);
74}
75
76inline 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
84Q_DECLARE_INTERFACE(Akonadi::Search::SearchStore, "org.kde.Akonadi.Search.SearchStore")
virtual QStringList types()=0
Returns a list of types which can be searched for in this store.
virtual int exec(const Query &query)=0
Executes the particular query synchronously.
QByteArray mid(qsizetype pos, qsizetype len) const const
QByteArray number(double n, char format, int precision)
qsizetype size() const const
int toInt(bool *ok, int base) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 6 2024 12:04:57 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.