1/*
2 SPDX-FileCopyrightText: 2014 Antonis Tsiapaliokas <antonis.tsiapaliokas@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#ifndef BALOO_QUERYRESULTSMODEL_H
8#define BALOO_QUERYRESULTSMODEL_H
9
10#include <QAbstractListModel>
11#include <QString>
12
13class Query : public QObject
14{
15 Q_OBJECT
16 Q_PROPERTY(QString searchString READ searchString WRITE setSearchString NOTIFY searchStringChanged)
17 Q_PROPERTY(int limit READ limit WRITE setLimit NOTIFY limitChanged)
18
19public:
20 explicit Query(QObject *parent = nullptr);
21 ~Query();
22
23 void setSearchString(const QString &searchString);
24 QString searchString() const;
25
26 void setLimit(const int &limit);
27 int limit() const;
28
29Q_SIGNALS:
30 void searchStringChanged();
31 void limitChanged();
32
33private:
34 QString m_searchString;
35 int m_limit;
36
37};
38
39class QueryResultsModel : public QAbstractListModel
40{
41 Q_OBJECT
42 Q_PROPERTY(Query* query READ query WRITE setQuery NOTIFY queryChanged)
43
44public:
45 explicit QueryResultsModel(QObject *parent = nullptr);
46 ~QueryResultsModel();
47 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
48
49 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
50
51 QHash<int, QByteArray> roleNames() const override;
52
53 enum Roles {
54 UrlRole = Qt::UserRole + 1,
55 };
56
57 void setQuery(Query *query);
58 Query* query() const;
59
60Q_SIGNALS:
61 void queryChanged();
62
63private Q_SLOTS:
64 void populateModel();
65
66private:
67 QStringList m_balooEntryList;
68 Query *m_query;
69};
70
71#endif
72

source code of baloo/src/qml/queryresultsmodel.h