2
* Copyright (c) 2010 Ivan Cukic <ivan.cukic(at)kde.org>
4
* This library is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU Library General Public
6
* License version 2 as published by the Free Software Foundation.
8
* This library is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
* Library General Public License for more details.
13
* You should have received a copy of the GNU Library General Public License
14
* along with this library; see the file COPYING.LIB. If not, write to
15
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16
* Boston, MA 02110-1301, USA.
19
#ifndef ACTIVITY_INFO_H
20
#define ACTIVITY_INFO_H
25
#include <QStringList>
28
#include <kdemacros.h>
31
* This class provides info about an activity. Most methods in it
32
* require a Nepomuk backend running.
34
* @see KActivityConsumer for info about activities
38
class KDE_EXPORT KActivityInfo: public QObject
42
Q_PROPERTY(KUrl uri READ uri)
43
Q_PROPERTY(KUrl resourceUri READ resourceUri)
44
Q_PROPERTY(QString id READ id)
45
Q_PROPERTY(QString name READ name)
48
explicit KActivityInfo(const QString & activityId, QObject *parent=0);
52
* @return true if the activity represented by this object exists and is valid
57
* Set of predefined resource types provided for convenience
60
UnspecifiedResource = 0,
61
DocumentResource = 1, ///< @see nfo:Document
62
FolderResource = 2, ///< @see nfo:Folder
63
ApplicationResource = 3, ///< @see nfo:Application
64
ContactResource = 4, ///< @see nco:Contact
65
LocationResource = 5 ///< @see pimo:Location
70
* Specifies which parts of this class are functional
73
Nothing = 0, ///< No activity info provided (isValid is false)
74
BasicInfo = 1, ///< Basic info is provided
75
Everything = 2 ///< Everything is available
79
* State of the activity
90
* @returns what info is provided by this instance of KActivityInfo
92
Availability availability() const;
95
* Associates the resource with the activity represented by this
96
* KActivityInfo object.
97
* @param resourceUrl url of the resource
98
* @param resourceType type of the resource
99
* @note Functional only when availability is Everything
101
void associateResource(const KUrl & resourceUrl, ResourceType resourceType = UnspecifiedResource);
104
* Associates the resource with the activity represented by this
105
* KActivityInfo object.
106
* @param resourceUrl url of the resource
107
* @param resourceType type of the resource
108
* @note Functional only when availability is Everything
110
void associateResource(const KUrl & resourceUrl, const KUrl & resourceType);
113
* Removes the association of this activity and the specified
115
* @param resourceUrl url of the resource
116
* @note Functional only when availability is Everything
118
void disassociateResource(const KUrl & resourceUrl);
121
* @param resourceType type of the resource
122
* @returns a list of resources of the specified type that are
123
* associated with this activity. If the type is not specified,
124
* all associated resources are returned,
125
* @note Functional only when availability is Everything
127
QList < KUrl > associatedResources(ResourceType resourceType = UnspecifiedResource) const;
130
* @param resourceType type of the resource
131
* @returns a list of resources of the specified type that are
132
* associated with this activity. If the type is not specified,
133
* all associated resources are returned,
134
* @note Functional only when availability is Everything
136
QList < KUrl > associatedResources(const KUrl & resourceType) const;
139
* @returns the URI of this activity. The same URI is used by
140
* activities KIO slave.
141
* @note Functional only when availability is Everything
146
* @returns the Nepomuk resource URI of this activity
147
* @note Functional only when availability is Everything
149
KUrl resourceUri() const;
152
* @returns the id of the activity
157
* @returns the name of the activity
158
* @note Functional when availability is BasicInfo or Everything
160
QString name() const;
163
* @returns the icon of the activity. Icon can be a
164
* freedesktop.org name or a file path. Or empty if
166
* @note Functional only when availability is Everything
168
QString icon() const;
171
* @returns the state of the activity
176
* This function is provided for convenience.
177
* @returns the name of the specified activity
178
* @param id id of the activity
180
static QString name(const QString & id);
184
* Emitted when the activity's name, icon or description is changed
189
* Emitted when the activity is added
194
* Emitted when the activity is removed
199
* Emitted when the activity is started
204
* Emitted when the activity is stopped
209
* Emitted when the activity changes state
210
* @param state new state of the activity
212
void stateChanged(KActivityInfo::State state);
218
Q_PRIVATE_SLOT(d, void activityStateChanged(const QString &, int))
219
Q_PRIVATE_SLOT(d, void added(const QString &))
220
Q_PRIVATE_SLOT(d, void removed(const QString &))
221
Q_PRIVATE_SLOT(d, void started(const QString &))
222
Q_PRIVATE_SLOT(d, void stopped(const QString &))
223
Q_PRIVATE_SLOT(d, void infoChanged(const QString &))
226
#endif // ACTIVITY_INFO_H