KActivitiesStats 5.109.0
resultmodel.h
1/*
2 SPDX-FileCopyrightText: 2015, 2016 Ivan Cukic <ivan.cukic(at)kde.org>
3
4 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5*/
6
7#ifndef KACTIVITIES_STATS_RESULTMODEL_H
8#define KACTIVITIES_STATS_RESULTMODEL_H
9
10// Qt
11#include <QAbstractListModel>
12#include <QObject>
13
14// Local
15#include "query.h"
16
17class QModelIndex;
18class QDBusPendingCallWatcher;
19
20class KConfigGroup;
21
22namespace KActivities
23{
24namespace Stats
25{
26class ResultModelPrivate;
27
34class KACTIVITIESSTATS_EXPORT ResultModel : public QAbstractListModel
35{
36 Q_OBJECT
37
38public:
39 ResultModel(Query query, QObject *parent = nullptr);
40 ResultModel(Query query, const QString &clientId, QObject *parent = nullptr);
41 ~ResultModel() override;
42
43 enum Roles {
44 ResourceRole = Qt::UserRole,
45 TitleRole = Qt::UserRole + 1,
46 ScoreRole = Qt::UserRole + 2,
47 FirstUpdateRole = Qt::UserRole + 3,
48 LastUpdateRole = Qt::UserRole + 4,
49 LinkStatusRole = Qt::UserRole + 5,
50 LinkedActivitiesRole = Qt::UserRole + 6,
51 MimeType = Qt::UserRole + 7, // @since 5.77
52 };
53
54 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
55 QVariant data(const QModelIndex &item, int role = Qt::DisplayRole) const override;
56 QHash<int, QByteArray> roleNames() const override;
57
58 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
59
60 void fetchMore(const QModelIndex &parent) override;
61 bool canFetchMore(const QModelIndex &parent) const override;
62
63 void linkToActivity(const QUrl &resource,
64 const Terms::Activity &activity = Terms::Activity(QStringList()),
65 const Terms::Agent &agent = Terms::Agent(QStringList()));
66
67 void unlinkFromActivity(const QUrl &resource,
68 const Terms::Activity &activity = Terms::Activity(QStringList()),
69 const Terms::Agent &agent = Terms::Agent(QStringList()));
70
71public Q_SLOTS:
75 void forgetResource(const QString &resource);
76
80 void forgetResources(const QList<QString> &resources);
81
85 void forgetResource(int row);
86
92
102 void setResultPosition(const QString &resource, int position);
103
113 void sortItems(Qt::SortOrder sortOrder);
114
115private:
116 friend class ResultModelPrivate;
117 ResultModelPrivate *const d;
118};
119
120} // namespace Stats
121} // namespace KActivities
122
123#endif // KACTIVITIES_STATS_RESULTMODEL_H
The activities system tracks resources (documents, contacts, etc.) that the user has used.
Definition query.h:54
Provides a model which displays the resources matching the specified Query.
Definition resultmodel.h:35
void sortItems(Qt::SortOrder sortOrder)
Sort the items by title.
void forgetResource(const QString &resource)
Removes the specified resource from the history.
void setResultPosition(const QString &resource, int position)
Moves the resource to the specified position.
void forgetResources(const QList< QString > &resources)
Removes specified list of resources from the history.
void forgetAllResources()
Clears the history of all resources that match the current model query.
void forgetResource(int row)
Removes the specified resource from the history.
Term to filter the resources according the activity in which they were accessed.
Definition terms.h:140
Term to filter the resources according the agent (application) which accessed it.
Definition terms.h:107