File indexing completed on 2024-05-12 05:10:40
0001 /* 0002 * SPDX-FileCopyrightText: 2019 Dimitris Kardarakos <dimkard@posteo.net> 0003 * 0004 * SPDX-License-Identifier: GPL-3.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include <KCalendarCore/Incidence> 0010 #include <KNotification> 0011 #include <QDateTime> 0012 #include <QPointer> 0013 #include <QUrl> 0014 0015 class KalendarAlarmClient; 0016 0017 /** 0018 * @brief The alarm notification that should be displayed. It is a wrapper of a KNotification enhanced with alarm properties, like uid and remind time 0019 * 0020 */ 0021 class AlarmNotification 0022 { 0023 public: 0024 explicit AlarmNotification(const QString &uid); 0025 ~AlarmNotification(); 0026 0027 /** 0028 * @brief Sends the notification to be displayed 0029 */ 0030 void send(KalendarAlarmClient *client, const KCalendarCore::Incidence::Ptr &incidence); 0031 0032 /** 0033 * @return The uid of the Incidence of the alarm of the notification 0034 */ 0035 [[nodiscard]] QString uid() const; 0036 0037 /** 0038 * @brief The text of the notification that should be displayed 0039 */ 0040 [[nodiscard]] QString text() const; 0041 0042 /** 0043 * @brief Sets the to-be-displayed text of the notification 0044 */ 0045 void setText(const QString &alarmText); 0046 0047 /** Occurrence time in case of recurring incidences. */ 0048 [[nodiscard]] QDateTime occurrence() const; 0049 void setOccurrence(const QDateTime &occurrence); 0050 0051 /** 0052 * @return In case of a suspended notification, the time that the notification should be displayed. Otherwise, it is empty. 0053 */ 0054 [[nodiscard]] QDateTime remindAt() const; 0055 0056 /** 0057 * @brief Sets the time that should be displayed a suspended notification 0058 */ 0059 void setRemindAt(const QDateTime &remindAtDt); 0060 0061 /** 0062 * @return true if we suspended alarm notification. 0063 */ 0064 [[nodiscard]] bool wasSuspended() const; 0065 0066 void setWasSuspended(bool newWasSuspended); 0067 0068 private: 0069 bool hasValidContextAction() const; 0070 [[nodiscard]] QString determineContextAction(const KCalendarCore::Incidence::Ptr &incidence); 0071 0072 QPointer<KNotification> m_notification; 0073 QString m_uid; 0074 QString m_text; 0075 QDateTime m_occurrence; 0076 QDateTime m_remind_at; 0077 QUrl m_contextAction; 0078 bool m_wasSuspended = false; 0079 };