7#include "activityinfo.h"
9#include <PlasmaActivities/ActivitiesModel>
10#include <PlasmaActivities/Consumer>
14class Q_DECL_HIDDEN ActivityInfo::Private
17 Private(ActivityInfo *q);
20 static int instanceCount;
21 static KActivities::Consumer *activityConsumer;
22 static KActivities::ActivitiesModel *activitiesModel;
25int ActivityInfo::Private::instanceCount = 0;
26KActivities::Consumer *ActivityInfo::Private::activityConsumer =
nullptr;
27KActivities::ActivitiesModel *ActivityInfo::Private::activitiesModel =
nullptr;
29ActivityInfo::Private::Private(ActivityInfo *)
34ActivityInfo::Private::~Private()
39 delete activityConsumer;
40 activityConsumer =
nullptr;
41 delete activitiesModel;
42 activitiesModel =
nullptr;
48 , d(new Private(this))
50 if (!d->activityConsumer) {
51 d->activityConsumer = new KActivities::Consumer();
54 connect(d->activityConsumer, &KActivities::Consumer::currentActivityChanged,
this, &ActivityInfo::currentActivityChanged);
55 connect(d->activityConsumer, &KActivities::Consumer::runningActivitiesChanged,
this, &ActivityInfo::numberOfRunningActivitiesChanged);
56 connect(d->activityConsumer, &KActivities::Consumer::runningActivitiesChanged,
this, &ActivityInfo::namesOfRunningActivitiesChanged);
58 if (!d->activitiesModel) {
59 d->activitiesModel = new KActivities::ActivitiesModel();
60 d->activitiesModel->setShownStates(QList<KActivities::Info::State>{KActivities::Info::Running});
63 connect(d->activitiesModel, &KActivities::ActivitiesModel::modelReset,
this, &ActivityInfo::namesOfRunningActivitiesChanged);
66 &KActivities::ActivitiesModel::dataChanged,
72 if (roles.isEmpty() || roles.contains(Qt::DisplayRole)) {
73 Q_EMIT namesOfRunningActivitiesChanged();
78ActivityInfo::~ActivityInfo()
82QString ActivityInfo::currentActivity()
const
84 return d->activityConsumer->currentActivity();
87int ActivityInfo::numberOfRunningActivities()
const
89 return d->activityConsumer->activities(KActivities::Info::State::Running).
count();
94 return d->activityConsumer->activities(KActivities::Info::State::Running);
99 KActivities::Info info(
id);
101 if (info.state() != KActivities::Info::Invalid) {
110 KActivities::Info info(
id);
112 if (info.state() != KActivities::Info::Invalid) {
120#include "moc_activityinfo.cpp"
QObject * parent() const const
qsizetype count() const const
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)