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

« back to all changes in this revision

Viewing changes to lib/consumer.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_CONSUMER_H_
 
20
#define ACTIVITIES_CONSUMER_H_
 
21
 
 
22
#include <QObject>
 
23
#include <QWidget>
 
24
#include <QString>
 
25
#include <QStringList>
 
26
 
 
27
#include "info.h"
 
28
 
 
29
#include <kurl.h>
 
30
#include <kdemacros.h>
 
31
 
 
32
namespace KActivities {
 
33
 
 
34
class ConsumerPrivate;
 
35
 
 
36
/**
 
37
 * Contextual information can be, from the user's point of view, divided
 
38
 * into three aspects - "who am I?", "where am I?" (what are my surroundings?)
 
39
 * and "what am I doing?".
 
40
 *
 
41
 * Activities deal with the last one - "what am I doing?". The current activity
 
42
 * refers to what the user is doing at the moment, while the other activities represent
 
43
 * things that he/she was doing before, and probably will be doing again.
 
44
 *
 
45
 * Activity is an abstract concept whose meaning can differ from one user to another.
 
46
 * Typical examples of activities are "developing a KDE project", "studying the
 
47
 * 19th century art", "composing music", "lazing on a Sunday afternoon" etc.
 
48
 *
 
49
 * Every activity can have applications, documents, or other types of resources
 
50
 * assigned to it.
 
51
 *
 
52
 * Consumer provides an entry-level API for supporting activities in an
 
53
 * application - to react to the changes to the current activity as well as
 
54
 * registering the resources with its windows.
 
55
 *
 
56
 * Resource can be anything that is identifiable by an URI (for example,
 
57
 * a local file or a web page)
 
58
 *
 
59
 * @since 4.5
 
60
 */
 
61
class KDE_EXPORT Consumer: public QObject {
 
62
    Q_OBJECT
 
63
 
 
64
    Q_PROPERTY(QString currentActivity READ currentActivity)
 
65
    Q_PROPERTY(QStringList activities READ listActivities)
 
66
 
 
67
public:
 
68
    /**
 
69
     * Different states of the activities service
 
70
     */
 
71
    enum ServiceStatus {
 
72
        NotRunning,        ///< Service is not running
 
73
        BareFunctionality, ///< Service is running without a sane backend
 
74
        FullFunctionality  ///< Service is running, and a backend is available
 
75
    };
 
76
 
 
77
    explicit Consumer(QObject * parent = 0);
 
78
 
 
79
    ~Consumer();
 
80
 
 
81
    /**
 
82
     * @returns the id of the current activity
 
83
     */
 
84
    QString currentActivity() const;
 
85
 
 
86
    /**
 
87
     * @returns the list of activities filtered by state
 
88
     * @param state state of the activity
 
89
     */
 
90
    QStringList listActivities(Info::State state) const;
 
91
 
 
92
    /**
 
93
     * @returns the list of all existing activities
 
94
     */
 
95
    QStringList listActivities() const;
 
96
 
 
97
    /**
 
98
     * @returns status of the activities service
 
99
     */
 
100
    static ServiceStatus serviceStatus();
 
101
 
 
102
    /**
 
103
     * Links a resource to the activity
 
104
     * @param uri URI of the resource
 
105
     * @activityId id of the activity to link to. If empty, the
 
106
     *    resource is linked to the current activity.
 
107
     */
 
108
    void linkResourceToActivity(const QUrl & uri, const QString & activityId = QString());
 
109
 
 
110
Q_SIGNALS:
 
111
    /**
 
112
     * This signal is emitted when the global
 
113
     * activity is changed
 
114
     * @param id id of the new current activity
 
115
     */
 
116
    void currentActivityChanged(const QString & id);
 
117
 
 
118
    /**
 
119
     * This signal is emitted when the activity service
 
120
     * goes online or offline
 
121
     * @param status new status of the service
 
122
     */
 
123
    void serviceStatusChanged(Consumer::ServiceStatus status);
 
124
 
 
125
    /**
 
126
     * This signal is emitted when a new activity is added
 
127
     * @param id id of the new activity
 
128
     */
 
129
    void activityAdded(const QString & id);
 
130
 
 
131
    /**
 
132
     * This signal is emitted when the activity
 
133
     * is removed
 
134
     * @param id id of the removed activity
 
135
     */
 
136
    void activityRemoved(const QString & id);
 
137
 
 
138
private:
 
139
    ConsumerPrivate * const d;
 
140
};
 
141
 
 
142
} // namespace KActivities
 
143
 
 
144
#endif // ACTIVITIES_CONSUMER_H_