Baloo

queryresultsmodel.h
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{
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
30 void searchStringChanged();
31 void limitChanged();
32
33private:
34 QString m_searchString;
35 int m_limit;
36
37};
38
39class QueryResultsModel : public QAbstractListModel
40{
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
61 void queryChanged();
62
63private Q_SLOTS:
64 void populateModel();
65
66private:
67 QStringList m_balooEntryList;
68 Query *m_query;
69};
70
71#endif
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const const override
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
Q_SIGNALSQ_SIGNALS
Q_SLOTSQ_SLOTS
QObject * parent() const const
DisplayRole
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:20:16 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.