2
* This file is part of the KDE Baloo Project
3
* Copyright (C) 2013 Vishesh Handa <me@vhanda.in>
5
* This library is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU Lesser General Public
7
* License as published by the Free Software Foundation; either
8
* version 2.1 of the License, or (at your option) version 3, or any
9
* later version accepted by the membership of KDE e.V. (or its
10
* successor approved by the membership of KDE e.V.), which shall
11
* act as a proxy defined in Section 6 of version 3 of the license.
13
* This library is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
* Lesser General Public License for more details.
18
* You should have received a copy of the GNU Lesser General Public
19
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
23
#ifndef _BALOO_SEARCHSTORE_H
24
#define _BALOO_SEARCHSTORE_H
31
#include "core_export.h"
37
class BALOO_CORE_EXPORT SearchStore : public QObject
41
explicit SearchStore(QObject* parent = 0);
42
virtual ~SearchStore();
45
* Override search stores for testing
47
static void overrideSearchStores(const QList<SearchStore*> &overrideSearchStores);
49
typedef QList< QSharedPointer<SearchStore> > List;
52
* Gives a list of available search stores. These stores must be managed and
53
* deleted by the caller
55
static List searchStores();
58
* Returns a list of types which can be searched for
61
virtual QStringList types() = 0;
64
* Executes the particular query synchronously.
66
* \return Returns a integer representating the integer
68
virtual int exec(const Query& query) = 0;
69
virtual bool next(int queryId) = 0;
70
virtual void close(int queryId) = 0;
72
virtual QByteArray id(int queryId) = 0;
74
virtual QUrl url(int queryId);
75
virtual QString text(int queryId);
76
virtual QString icon(int queryId);
77
virtual QString property(int queryId, const QString& propName);
81
// Convenience functions
83
inline QByteArray serialize(const QByteArray& namespace_, int id) {
84
return namespace_ + ':' + QByteArray::number(id);
87
inline int deserialize(const QByteArray& namespace_, const QByteArray& str) {
88
// The +1 is for the ':'
89
return str.mid(namespace_.size() + 1).toInt();
94
Q_DECLARE_INTERFACE(Baloo::SearchStore, "org.kde.Baloo.SearchStore")
96
#endif // _BALOO_SEARCHSTORE_H