Changeset View
Changeset View
Standalone View
Standalone View
imports/activitymanager/backport/switcheractivitiesmodel_p.h
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | * Copyright (C) 2012, 2013, 2014 Ivan Cukic <ivan.cukic(at)kde.org> | ||||
3 | * | ||||
4 | * This program is free software; you can redistribute it and/or modify | ||||
5 | * it under the terms of the GNU General Public License version 2, | ||||
6 | * or (at your option) any later version, as published by the Free | ||||
7 | * Software Foundation | ||||
8 | * | ||||
9 | * This program is distributed in the hope that it will be useful, | ||||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
12 | * GNU General Public License for more details | ||||
13 | * | ||||
14 | * You should have received a copy of the GNU General Public | ||||
15 | * License along with this program; if not, write to the | ||||
16 | * Free Software Foundation, Inc., | ||||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
18 | */ | ||||
19 | | ||||
20 | #ifndef ACTIVITIES_ACTIVITYMODEL_P_H | ||||
21 | #define ACTIVITIES_ACTIVITYMODEL_P_H | ||||
22 | | ||||
23 | #include <QObject> | ||||
24 | #include <KActivities/Consumer> | ||||
25 | | ||||
26 | #include "model_updaters.h" | ||||
27 | #include "switcheractivitiesmodel.h" | ||||
28 | #include "qflatset.h" | ||||
29 | | ||||
30 | namespace KActivitiesBackport { | ||||
31 | | ||||
32 | class ActivitiesModelPrivate : public QObject { | ||||
33 | Q_OBJECT | ||||
34 | public: | ||||
35 | ActivitiesModelPrivate(ActivitiesModel *parent); | ||||
36 | | ||||
37 | public Q_SLOTS: | ||||
38 | void onActivityNameChanged(const QString &name); | ||||
39 | void onActivityDescriptionChanged(const QString &description); | ||||
40 | void onActivityIconChanged(const QString &icon); | ||||
41 | void onActivityStateChanged(KActivities::Info::State state); | ||||
42 | | ||||
43 | void replaceActivities(const QStringList &activities); | ||||
44 | void onActivityAdded(const QString &id, bool notifyClients = true); | ||||
45 | void onActivityRemoved(const QString &id); | ||||
46 | void onCurrentActivityChanged(const QString &id); | ||||
47 | | ||||
48 | void setServiceStatus(KActivities::Consumer::ServiceStatus status); | ||||
49 | | ||||
50 | public: | ||||
51 | KActivities::Consumer activities; | ||||
52 | QVector<Info::State> shownStates; | ||||
53 | | ||||
54 | typedef std::shared_ptr<Info> InfoPtr; | ||||
55 | | ||||
56 | struct InfoPtrComparator { | ||||
57 | bool operator() (const InfoPtr& left, const InfoPtr& right) const | ||||
58 | { | ||||
59 | const QString &leftName = left->name().toLower(); | ||||
60 | const QString &rightName = right->name().toLower(); | ||||
61 | | ||||
62 | return | ||||
63 | (leftName < rightName) || | ||||
64 | (leftName == rightName && left->id() < right->id()); | ||||
65 | } | ||||
66 | }; | ||||
67 | | ||||
68 | QFlatSet<InfoPtr, InfoPtrComparator> knownActivities; | ||||
69 | QFlatSet<InfoPtr, InfoPtrComparator> shownActivities; | ||||
70 | | ||||
71 | InfoPtr registerActivity(const QString &id); | ||||
72 | void unregisterActivity(const QString &id); | ||||
73 | void showActivity(InfoPtr activityInfo, bool notifyClients); | ||||
74 | void hideActivity(const QString &id); | ||||
75 | void backgroundsUpdated(const QStringList &activities); | ||||
76 | | ||||
77 | InfoPtr findActivity(QObject *ptr) const; | ||||
78 | | ||||
79 | ActivitiesModel *const q; | ||||
80 | | ||||
81 | DECLARE_RAII_MODEL_UPDATERS(ActivitiesModel) | ||||
82 | }; | ||||
83 | | ||||
84 | } // namespace KActivitiesBackport | ||||
85 | | ||||
86 | #endif // ACTIVITIES_ACTIVITYMODEL_P_H | ||||
87 | |