2
* Copyright (C) 2011 Ivan Cukic <ivan.cukic@kde.org>
4
* This program is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU General Public License as
6
* published by the Free Software Foundation; either version 2 of
7
* the License, or (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18
#ifndef PLUGINS_NEPOMUK_RANKINGS_H
19
#define PLUGINS_NEPOMUK_RANKINGS_H
24
#include <QStringList>
28
#include <Nepomuk/Resource>
30
class Rankings: public QObject
33
Q_CLASSINFO("D-Bus Interface", "org.kde.ActivityManager.Rankings")
36
static void init(QObject * parent = 0);
37
static Rankings * self();
39
void resourceScoreUpdated(const QString & activity,
40
const QString & application, const QUrl & uri, qreal score);
46
* Registers a new client for the specified activity and application
47
* @param client d-bus name
48
* @param activity activity to track. If empty, uses the default activity.
49
* @param application application to track. If empty, all applications are aggregated
50
* @param type resource type that the client is interested in
51
* @note If the activity is left empty - the results are always related to the current activity,
52
* not the activity that was current when calling this method.
54
void registerClient(const QString & client,
55
const QString & activity = QString(),
56
const QString & type = QString()
60
* Deregisters a client
62
void deregisterClient(const QString & client);
65
* Don't use this, will be removed
67
void requestScoreUpdate(const QString & activity, const QString & application, const QString & resource);
70
void setCurrentActivity(const QString & activityId);
73
Rankings(QObject * parent = 0);
74
void updateScoreTrashold(const QString & activity);
76
static Rankings * s_instance;
85
: uri(_uri), score(_score)
94
typedef QString Activity;
95
typedef QString Client;
98
void initResults(const QString & activity);
99
void notifyResultsUpdated(const QString & activity, QStringList clients = QStringList());
102
QHash < Activity, QStringList > m_clients;
103
QHash < Activity, QList < ResultItem > > m_results;
104
QHash < Activity, qreal > m_resultScoreTreshold;
107
class RankingsUpdateThread: public QThread {
111
RankingsUpdateThread(const QString & activity, QList < Rankings::ResultItem > * listptr,
112
QHash < Rankings::Activity, qreal > * scoreTrashold);
113
virtual ~RankingsUpdateThread();
118
void loaded(const QString & activity);
121
static QUrl urlFor(const Nepomuk::Resource & resource);
124
QList < Rankings::ResultItem > * m_listptr;
125
QHash < Rankings::Activity, qreal > * m_scoreTrashold;
128
#endif // PLUGINS_NEPOMUK_RANKINGS_H