#include "notificationmanager.h" #include "notificationmonitor.h" NotificationManager::NotificationManager(CardManager *card, ToqManager *toq) : QObject(toq), _toq(toq), _monitor(NotificationMonitor::instance()), _card(card), _deck(new CardDeck("com.qualcomm.qce.androidnotifications", "Notifications", this)) { _card->installDeck(_deck); connect(_monitor, &NotificationMonitor::notification, this, &NotificationManager::handleNotification); } void NotificationManager::handleNotification(MonitoredNotification *n) { uint notificationId = n->id(); Card *card = new Card(QString::number(qint64(notificationId))); card->setHeader(n->sender()); card->setTitle(n->summary()); card->setText(n->body()); card->setDateTime(n->timestamp()); card->setVibrate(true); connect(n, &MonitoredNotification::closed, this, &NotificationManager::handleClosedNotification); _cards.insert(notificationId, card); _deck->insertCard(0, card); } void NotificationManager::handleClosedNotification() { MonitoredNotification *n = static_cast(sender()); uint notificationId = n->id(); Card *card = _cards.take(notificationId); if (card) { _deck->removeCard(card); card->deleteLater(); } else { qDebug() << "Notification" << notificationId << "does not have an attached card"; } disconnect(n, 0, this, 0); }