File indexing completed on 2024-04-14 05:43:43

0001 /*
0002  * SPDX-FileCopyrightText: 2020 Dimitris Kardarakos <dimkard@posteo.net>
0003  *
0004  * SPDX-License-Identifier: GPL-3.0-or-later
0005  */
0006 
0007 #include "notificationhandler.h"
0008 #include "alarmnotification.h"
0009 #include <KLocalizedString>
0010 #include <KSharedConfig>
0011 #include <QDebug>
0012 
0013 NotificationHandler::NotificationHandler(QObject *parent) : QObject {parent}, m_active_notifications {QHash<QString, AlarmNotification*>()}
0014 {
0015 }
0016 
0017 void NotificationHandler::addActiveNotification(const QString &uid, const QString &text)
0018 {
0019     auto *notification = new AlarmNotification {this, uid};
0020     notification->setText(text);
0021     m_active_notifications[notification->uid()] = notification;
0022 }
0023 
0024 void NotificationHandler::sendNotifications()
0025 {
0026     for (const auto &n : std::as_const(m_active_notifications)) {
0027         qDebug() << "sendNotifications:\tSending notification for alarm" <<  n->uid();
0028         n->send();
0029     }
0030 
0031     m_active_notifications.clear();
0032 }
0033 
0034 QHash<QString, AlarmNotification *> NotificationHandler::activeNotifications() const
0035 {
0036     return m_active_notifications;
0037 }
0038 
0039 #include "moc_notificationhandler.cpp"