PlasmaActivitiesStats

resultwatcher.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_RESULTWATCHER
8#define KACTIVITIES_STATS_RESULTWATCHER
9
10#include <QObject>
11
12#include "query.h"
13#include "resultset.h"
14
15namespace KActivities
16{
17namespace Stats
18{
19class ResultWatcherPrivate;
20
21/**
22 * @class KActivities::Stats::ResultWatcher resultwatcher.h <KActivities/Stats/ResultWatcher>
23 *
24 * A very thin class that sends signals when new resources matching
25 * a predefined query are available.
26 */
27class PLASMAACTIVITIESSTATS_EXPORT ResultWatcher : public QObject
28{
30
31public:
32 explicit ResultWatcher(Query query, QObject *parent = nullptr);
33 ~ResultWatcher() override;
34
36 /**
37 * Emitted when a result has been added or updated. This either means
38 * a new resource has appeared in the result set, or that
39 * a previously existing one has some of the attributes changed.
40 * @param result new data for the resource defined by result.resource
41 */
42 void resultScoreUpdated(const QString &resource, double score, uint lastUpdate, uint firstUpdate);
43
44 /**
45 * Emitted when a result has been added or updated. This either means
46 * a new resource has appeared in the result set, or that
47 * a previously existing one has some of the attributes changed.
48 * @param result new data for the resource defined by result.resource
49 */
50 void resultRemoved(const QString &resource);
51
52 /**
53 * Emitted when a result has been linked to the activity
54 */
55 void resultLinked(const QString &resource);
56
57 /**
58 * Emitted when a result has been unlinked from the activity
59 */
60 void resultUnlinked(const QString &resource);
61
62 /**
63 * Emitted when the title of a resource has been changed.
64 * @param resource URL of the resource that has a new title
65 * @param title new title of the resource
66 * @note This signal will be emitted even for the resources that
67 * do not match the specified query. This is because the class is
68 * lightweight, and it does not keep track of which resources match
69 * the query to be able to filter this signal.
70 */
71 void resourceTitleChanged(const QString &resource, const QString &title);
72
73 /**
74 * Emitted when the mimetype of a resource has been changed.
75 * @param resource URL of the resource that has a new mimetype
76 * @param mimetype new mimetype of the resource
77 * @note This signal will be emitted even for the resources that
78 * do not match the specified query. This is because the class is
79 * lightweight, and it does not keep track of which resources match
80 * the query to be able to filter this signal.
81 */
82 void resourceMimetypeChanged(const QString &resource, const QString &mimetype);
83
84 /**
85 * Emitted when the client should forget about all the results it
86 * knew about and reload them. This can happen when the user clears
87 * the history, or when there are more significant changes to the data.
88 */
90
91public:
92 void linkToActivity(const QUrl &resource,
93 const Terms::Activity &activity = Terms::Activity(QStringList()),
94 const Terms::Agent &agent = Terms::Agent(QStringList()));
95
96 void unlinkFromActivity(const QUrl &resource,
97 const Terms::Activity &activity = Terms::Activity(QStringList()),
98 const Terms::Agent &agent = Terms::Agent(QStringList()));
99
100private:
101 ResultWatcherPrivate *const d;
102};
103
104} // namespace Stats
105} // namespace KActivities
106
107#endif // KACTIVITIES_STATS_RESULTWATCHER
The activities system tracks resources (documents, contacts, etc.) that the user has used.
Definition query.h:54
void resourceMimetypeChanged(const QString &resource, const QString &mimetype)
Emitted when the mimetype of a resource has been changed.
void resultsInvalidated()
Emitted when the client should forget about all the results it knew about and reload them.
void resultLinked(const QString &resource)
Emitted when a result has been linked to the activity.
void resultUnlinked(const QString &resource)
Emitted when a result has been unlinked from the activity.
void resultScoreUpdated(const QString &resource, double score, uint lastUpdate, uint firstUpdate)
Emitted when a result has been added or updated.
void resourceTitleChanged(const QString &resource, const QString &title)
Emitted when the title of a resource has been changed.
void resultRemoved(const QString &resource)
Emitted when a result has been added or updated.
QObject(QObject *parent)
Q_OBJECTQ_OBJECT
Q_SIGNALSQ_SIGNALS
QObject * parent() const const
Term to filter the resources according the activity in which they were accessed.
Definition terms.h:139
Term to filter the resources according the agent (application) which accessed it.
Definition terms.h:106
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Feb 28 2025 12:01:02 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.