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#include <qqmlregistration.h>
13
14class Query : public QObject
15{
17 QML_ELEMENT
18 Q_PROPERTY(QString searchString READ searchString WRITE setSearchString NOTIFY searchStringChanged)
19 Q_PROPERTY(int limit READ limit WRITE setLimit NOTIFY limitChanged)
20
21public:
22 explicit Query(QObject *parent = nullptr);
23 ~Query();
24
25 void setSearchString(const QString &searchString);
26 QString searchString() const;
27
28 void setLimit(const int &limit);
29 int limit() const;
30
32 void searchStringChanged();
33 void limitChanged();
34
35private:
36 QString m_searchString;
37 int m_limit;
38
39};
40
41class QueryResultsModel : public QAbstractListModel
42{
44 QML_ELEMENT
45 Q_PROPERTY(Query* query READ query WRITE setQuery NOTIFY queryChanged)
46
47public:
48 explicit QueryResultsModel(QObject *parent = nullptr);
49 ~QueryResultsModel();
50 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
51
52 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
53
54 QHash<int, QByteArray> roleNames() const override;
55
56 enum Roles {
57 UrlRole = Qt::UserRole + 1,
58 };
59
60 void setQuery(Query *query);
61 Query* query() const;
62
64 void queryChanged();
65
66private Q_SLOTS:
67 void populateModel();
68
69private:
70 QStringList m_balooEntryList;
71 Query *m_query;
72};
73
74#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 Sat Dec 21 2024 16:56:58 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.