File indexing completed on 2024-04-21 05:50:56

0001 /*
0002  * SPDX-FileCopyrightText: 2020 Dimitris Kardarakos <dimkard@posteo.net>
0003  *
0004  * SPDX-License-Identifier: GPL-3.0-or-later
0005  */
0006 
0007 #ifndef NOTIFICATIONHANDLER_H
0008 #define NOTIFICATIONHANDLER_H
0009 
0010 #include "alarmsmodel.h"
0011 
0012 class AlarmNotification;
0013 
0014 /**
0015  * @brief Manages the creation and triggering of event alarm notifications
0016  *
0017  */
0018 class NotificationHandler : public QObject
0019 {
0020     Q_OBJECT
0021 public:
0022     explicit NotificationHandler(QObject *parent);
0023 
0024     /**
0025      * @brief Parses the internal list of active notifications and triggers their sending
0026      */
0027     void sendNotifications();
0028 
0029     /**
0030      * @brief Creates an alarm notification object for the Incidence with \p uid. It sets the text to be displayed according to \p text. It adds this alarm notification to the internal list of active notifications (the list of notifications that should be sent at the next check).
0031      */
0032     void addActiveNotification(const QString &uid, const QString &text);
0033 
0034     /**
0035      * @return The list of active notifications. It is the set of notification that should be sent at the next check
0036      */
0037     QHash<QString, AlarmNotification *> activeNotifications() const;
0038 
0039 private:
0040     QHash<QString, AlarmNotification *> m_active_notifications;
0041     FilterPeriod m_period;
0042 };
0043 #endif