Notifications: remove notification widgets if the notification is gone.

If a notification is not longer in the list that comes from the
server, the notification is removed.

That is mainly for the notifications that are created by the
announcement application
This commit is contained in:
Klaas Freitag 2016-03-21 16:26:37 +01:00
parent f587f35ef0
commit d407aacc4a

View file

@ -273,6 +273,30 @@ void ActivityWidget::slotBuildNotificationDisplay(const ActivityList& list)
}
}
// check if we have widgets that have no corresponding activity from
// the server any more. Collect them in a list
QList<int> strayCats;
foreach( auto id, _widgetForNotifId.keys() ) {
bool found = false;
foreach( auto activity, list ) {
if( activity._id == id ) {
// found an activity
found = true;
break;
}
}
if( ! found ) {
// the activity does not exist any more.
strayCats.append(id);
}
}
// .. and now delete all these stray cat widgets.
foreach( auto strayCatId, strayCats ) {
NotificationWidget *widgetToGo = _widgetForNotifId[strayCatId];
widgetToGo->deleteLater();
_widgetForNotifId.remove(strayCatId);
}
_ui->_notifyLabel->setHidden( _widgetForNotifId.isEmpty() );
_ui->_notifyScroll->setHidden( _widgetForNotifId.isEmpty() );