~ubuntu-branches/ubuntu/precise/kactivities/precise-proposed

« back to all changes in this revision

Viewing changes to lib/info.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2011-12-13 11:53:27 UTC
  • Revision ID: package-import@ubuntu.com-20111213115327-vqhdel92qx65us8y
Tags: upstream-4.7.90
ImportĀ upstreamĀ versionĀ 4.7.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (c) 2010 Ivan Cukic <ivan.cukic(at)kde.org>
 
3
 *
 
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.
 
7
 *
 
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.
 
12
 *
 
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.
 
17
 */
 
18
 
 
19
#ifndef ACTIVITIES_INFO_H_
 
20
#define ACTIVITIES_INFO_H_
 
21
 
 
22
#include <QObject>
 
23
#include <QWidget>
 
24
#include <QString>
 
25
#include <QStringList>
 
26
 
 
27
#include <kurl.h>
 
28
#include <kdemacros.h>
 
29
 
 
30
namespace KActivities {
 
31
 
 
32
class InfoPrivate;
 
33
 
 
34
/**
 
35
 * This class provides info about an activity. Most methods in it
 
36
 * require a Nepomuk backend running.
 
37
 *
 
38
 * @see Consumer for info about activities
 
39
 *
 
40
 * @since 4.5
 
41
 */
 
42
class KDE_EXPORT Info: public QObject
 
43
{
 
44
    Q_OBJECT
 
45
 
 
46
    Q_PROPERTY(KUrl uri READ uri)
 
47
    Q_PROPERTY(KUrl resourceUri READ resourceUri)
 
48
    Q_PROPERTY(QString id READ id)
 
49
    Q_PROPERTY(QString name READ name)
 
50
 
 
51
public:
 
52
    explicit Info(const QString & activityId, QObject *parent=0);
 
53
    ~Info();
 
54
 
 
55
    /**
 
56
     * @return true if the activity represented by this object exists and is valid
 
57
     */
 
58
    bool isValid() const;
 
59
 
 
60
    /**
 
61
     * Specifies which parts of this class are functional
 
62
     */
 
63
    enum Availability {
 
64
        Nothing = 0,             ///< No activity info provided (isValid is false)
 
65
        BasicInfo = 1,           ///< Basic info is provided
 
66
        Everything = 2           ///< Everything is available
 
67
    };
 
68
 
 
69
    /**
 
70
     * State of the activity
 
71
     */
 
72
    enum State {
 
73
        Invalid  = 0,
 
74
        Running  = 2,
 
75
        Starting = 3,
 
76
        Stopped  = 4,
 
77
        Stopping = 5
 
78
    };
 
79
 
 
80
    /**
 
81
     * @returns what info is provided by this instance of Info
 
82
     */
 
83
    Availability availability() const;
 
84
 
 
85
    /**
 
86
     * @returns the URI of this activity. The same URI is used by
 
87
     * activities KIO slave.
 
88
     * @note Functional only when availability is Everything
 
89
     */
 
90
    KUrl uri() const;
 
91
 
 
92
    /**
 
93
     * @returns the Nepomuk resource URI of this activity
 
94
     * @note Functional only when availability is Everything
 
95
     */
 
96
    KUrl resourceUri() const;
 
97
 
 
98
    /**
 
99
     * @returns the id of the activity
 
100
     */
 
101
    QString id() const;
 
102
 
 
103
    /**
 
104
     * @returns the name of the activity
 
105
     * @note Functional when availability is BasicInfo or Everything
 
106
     */
 
107
    QString name() const;
 
108
 
 
109
    /**
 
110
     * @returns the icon of the activity. Icon can be a
 
111
     * freedesktop.org name or a file path. Or empty if
 
112
     * no icon is set.
 
113
     * @note Functional only when availability is Everything
 
114
     */
 
115
    QString icon() const;
 
116
 
 
117
    /**
 
118
     * @returns the state of the activity
 
119
     */
 
120
    State state() const;
 
121
 
 
122
    /**
 
123
     * This function is provided for convenience.
 
124
     * @returns the name of the specified activity
 
125
     * @param id id of the activity
 
126
     */
 
127
    static QString name(const QString & id);
 
128
 
 
129
Q_SIGNALS:
 
130
    /**
 
131
     * Emitted when the activity's name, icon or description is changed
 
132
     */
 
133
    void infoChanged();
 
134
 
 
135
    /**
 
136
     * Emitted when the activity is added
 
137
     */
 
138
    void added();
 
139
 
 
140
    /**
 
141
     * Emitted when the activity is removed
 
142
     */
 
143
    void removed();
 
144
 
 
145
    /**
 
146
     * Emitted when the activity is started
 
147
     */
 
148
    void started();
 
149
 
 
150
    /**
 
151
     * Emitted when the activity is stopped
 
152
     */
 
153
    void stopped();
 
154
 
 
155
    /**
 
156
     * Emitted when the activity changes state
 
157
     * @param state new state of the activity
 
158
     */
 
159
    void stateChanged(Info::State state);
 
160
 
 
161
private:
 
162
    InfoPrivate * const d;
 
163
 
 
164
    Q_PRIVATE_SLOT(d, void activityStateChanged(const QString &, int))
 
165
    Q_PRIVATE_SLOT(d, void added(const QString &))
 
166
    Q_PRIVATE_SLOT(d, void removed(const QString &))
 
167
    Q_PRIVATE_SLOT(d, void started(const QString &))
 
168
    Q_PRIVATE_SLOT(d, void stopped(const QString &))
 
169
    Q_PRIVATE_SLOT(d, void infoChanged(const QString &))
 
170
 
 
171
    friend class InfoPrivate;
 
172
};
 
173
 
 
174
} // namespace KActivities
 
175
 
 
176
#endif // ACTIVITIES_INFO_H_