KActivities 5.109.0
Public Types | Properties | Signals | Public Member Functions | List of all members
KActivities::Consumer

Contextual information can be, from the user's point of view, divided into three aspects - "who am I?", "where am I?" (what are my surroundings?) and "what am I doing?". More...

#include <consumer.h>

Public Types

enum  ServiceStatus { NotRunning , Unknown , Running }
 Different states of the activities service. More...
 

Properties

QStringList activities
 
QString currentActivity
 
QStringList runningActivities
 
ServiceStatus serviceStatus
 

Signals

void activitiesChanged (const QStringList &activities)
 This signal is emitted when the activity list changes.
 
void activityAdded (const QString &id)
 This signal is emitted when a new activity is added.
 
void activityRemoved (const QString &id)
 This signal is emitted when an activity has been removed.
 
void currentActivityChanged (const QString &id)
 This signal is emitted when the current activity is changed.
 
void runningActivitiesChanged (const QStringList &runningActivities)
 This signal is emitted when the list of running activities changes.
 
void serviceStatusChanged (Consumer::ServiceStatus status)
 This signal is emitted when the activity service goes online or offline, or when the class manages to synchronize the data with the service.
 

Public Member Functions

 Consumer (QObject *parent=nullptr)
 
QStringList activities () const
 
QStringList activities (Info::State state) const
 
QString currentActivity () const
 
QStringList runningActivities () const
 
ServiceStatus serviceStatus ()
 

Detailed Description

Contextual information can be, from the user's point of view, divided into three aspects - "who am I?", "where am I?" (what are my surroundings?) and "what am I doing?".

Activities deal with the last one - "what am I doing?". The current activity refers to what the user is doing at the moment, while the other activities represent things that he/she was doing before, and probably will be doing again.

Activity is an abstract concept whose meaning can differ from one user to another. Typical examples of activities are "developing a KDE project", "studying the 19th century art", "composing music", "lazing on a Sunday afternoon" etc.

Consumer provides read-only information about activities.

Before relying on the values retrieved by the class, make sure that the serviceStatus is set to Running. Otherwise, you can get invalid data either because the service is not functioning properly (or at all) or because the class did not have enough time to synchronize the data with it.

For example, if this is the only existing instance of the Consumer class, the listActivities method will return an empty list.

void someMethod() {
// Do not copy. This approach is not a good one!
doSomethingWith(c.listActivities());
}
Contextual information can be, from the user's point of view, divided into three aspects - "who am I?...
Definition consumer.h:63

Instances of the Consumer class should be long-lived. For example, members of the classes that use them, and you should listen for the changes in the provided properties.

Since
4.5

Member Enumeration Documentation

◆ ServiceStatus

Different states of the activities service.

Enumerator
NotRunning 

Service is not running.

Unknown 

Unable to determine the status of the service.

Running 

Service is running properly.

Member Function Documentation

◆ activities() [1/2]

QStringList KActivities::Consumer::activities ( ) const
Returns
the list of all existing activities
Note
If the serviceStatus is not Running, only a null activity will be returned.

◆ activities() [2/2]

QStringList KActivities::Consumer::activities ( Info::State  state) const
Returns
the list of activities filtered by state
Parameters
statestate of the activity
Note
If the serviceStatus is not Running, only a null activity will be returned.

◆ activitiesChanged

void KActivities::Consumer::activitiesChanged ( const QStringList &  activities)
signal

This signal is emitted when the activity list changes.

Parameters
activitieslist of activities

◆ activityAdded

void KActivities::Consumer::activityAdded ( const QString &  id)
signal

This signal is emitted when a new activity is added.

Parameters
idid of the new activity

◆ activityRemoved

void KActivities::Consumer::activityRemoved ( const QString &  id)
signal

This signal is emitted when an activity has been removed.

Parameters
idid of the removed activity

◆ currentActivity()

QString KActivities::Consumer::currentActivity ( ) const
Returns
the id of the current activity
Note
Activity ID is a UUID-formatted string. If the serviceStatus is not Running, a null UUID is returned. The ID can also be an empty string in the case there is no current activity.

◆ currentActivityChanged

void KActivities::Consumer::currentActivityChanged ( const QString &  id)
signal

This signal is emitted when the current activity is changed.

Parameters
idid of the new current activity

◆ runningActivities()

QStringList KActivities::Consumer::runningActivities ( ) const
Returns
a list of running activities This is a convenience method that returns Running and Stopping activities

◆ runningActivitiesChanged

void KActivities::Consumer::runningActivitiesChanged ( const QStringList &  runningActivities)
signal

This signal is emitted when the list of running activities changes.

Parameters
runningActivitieslist of running activities

◆ serviceStatus()

ServiceStatus KActivities::Consumer::serviceStatus ( )
Returns
status of the activities service

◆ serviceStatusChanged

void KActivities::Consumer::serviceStatusChanged ( Consumer::ServiceStatus  status)
signal

This signal is emitted when the activity service goes online or offline, or when the class manages to synchronize the data with the service.

Parameters
statusnew status of the service