Pimcommon

activitiesbasemanager.h
1/*
2 SPDX-FileCopyrightText: 2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "pimcommonactivities_export.h"
10#include <QObject>
11namespace KActivities
12{
13class Consumer;
14}
15namespace PimCommonActivities
16{
17class PIMCOMMONACTIVITIES_EXPORT ActivitiesBaseManager : public QObject
18{
19 Q_OBJECT
20public:
21 struct ActivitySettings {
22 QStringList activities;
23 bool enabled = false;
24 [[nodiscard]] bool contains(const QString &str) const
25 {
26 return activities.contains(str);
27 }
28
29 void changeActivities(bool added, const QString &currentActivity)
30 {
31 if (added) {
32 if (!activities.contains(currentActivity)) {
33 activities.append(currentActivity);
34 }
35 } else {
36 if (activities.contains(currentActivity)) {
37 activities.removeAll(currentActivity);
38 }
39 }
40 enabled = true;
41 }
42 };
43
44 explicit ActivitiesBaseManager(QObject *parent = nullptr);
45 ~ActivitiesBaseManager() override;
46 [[nodiscard]] virtual bool enabled() const = 0;
47
48 [[nodiscard]] bool isInCurrentActivity(const QStringList &lst) const;
49
50 [[nodiscard]] QString currentActivity() const;
51Q_SIGNALS:
52 void activitiesChanged();
53
54private:
55 KActivities::Consumer *const mActivitiesConsumer;
56};
57}
58PIMCOMMONACTIVITIES_EXPORT QDebug operator<<(QDebug d, const PimCommonActivities::ActivitiesBaseManager::ActivitySettings &t);
KCALENDARCORE_EXPORT QDataStream & operator<<(QDataStream &out, const KCalendarCore::Alarm::Ptr &)
void append(QList< T > &&value)
qsizetype removeAll(const AT &t)
bool contains(QLatin1StringView str, Qt::CaseSensitivity cs) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:39:22 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.