~ubuntu-branches/debian/sid/baloo-kf5/sid

« back to all changes in this revision

Viewing changes to src/core/searchstore.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2014-07-10 21:13:07 UTC
  • Revision ID: package-import@ubuntu.com-20140710211307-iku0qs6vlplgn06m
Tags: upstream-5.0.0b
ImportĀ upstreamĀ versionĀ 5.0.0b

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * This file is part of the KDE Baloo Project
 
3
 * Copyright (C) 2013  Vishesh Handa <me@vhanda.in>
 
4
 *
 
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.
 
12
 *
 
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.
 
17
 *
 
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/>.
 
20
 *
 
21
 */
 
22
 
 
23
#ifndef _BALOO_SEARCHSTORE_H
 
24
#define _BALOO_SEARCHSTORE_H
 
25
 
 
26
#include <QObject>
 
27
#include <QString>
 
28
#include <QHash>
 
29
#include <QUrl>
 
30
 
 
31
#include "core_export.h"
 
32
 
 
33
namespace Baloo {
 
34
 
 
35
class Query;
 
36
 
 
37
class BALOO_CORE_EXPORT SearchStore : public QObject
 
38
{
 
39
    Q_OBJECT
 
40
public:
 
41
    explicit SearchStore(QObject* parent = 0);
 
42
    virtual ~SearchStore();
 
43
 
 
44
    /**
 
45
     * Override search stores for testing
 
46
     */
 
47
    static void overrideSearchStores(const QList<SearchStore*> &overrideSearchStores);
 
48
 
 
49
    typedef QList< QSharedPointer<SearchStore> > List;
 
50
 
 
51
    /**
 
52
     * Gives a list of available search stores. These stores must be managed and
 
53
     * deleted by the caller
 
54
     */
 
55
    static List searchStores();
 
56
 
 
57
    /**
 
58
     * Returns a list of types which can be searched for
 
59
     * in this store
 
60
     */
 
61
    virtual QStringList types() = 0;
 
62
 
 
63
    /**
 
64
     * Executes the particular query synchronously.
 
65
     *
 
66
     * \return Returns a integer representating the integer
 
67
     */
 
68
    virtual int exec(const Query& query) = 0;
 
69
    virtual bool next(int queryId) = 0;
 
70
    virtual void close(int queryId) = 0;
 
71
 
 
72
    virtual QByteArray id(int queryId) = 0;
 
73
 
 
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);
 
78
};
 
79
 
 
80
//
 
81
// Convenience functions
 
82
//
 
83
inline QByteArray serialize(const QByteArray& namespace_, int id) {
 
84
    return namespace_ + ':' + QByteArray::number(id);
 
85
}
 
86
 
 
87
inline int deserialize(const QByteArray& namespace_, const QByteArray& str) {
 
88
    // The +1 is for the ':'
 
89
    return str.mid(namespace_.size() + 1).toInt();
 
90
}
 
91
 
 
92
}
 
93
 
 
94
Q_DECLARE_INTERFACE(Baloo::SearchStore, "org.kde.Baloo.SearchStore")
 
95
 
 
96
#endif // _BALOO_SEARCHSTORE_H