Fixed update of qued notifications

This commit is contained in:
Patrick von Reth 2014-07-06 12:09:47 +02:00
parent f333e04334
commit a1a569b242
1 changed files with 36 additions and 18 deletions

View File

@ -47,16 +47,33 @@ void SnoreNotifier::slotNotify(Snore::Notification notification)
{ {
if(notification.isUpdate()) if(notification.isUpdate())
{
if(notification.old().hints().privateValue(this, "id").isValid())
{ {
NotifyWidget *w = m_widgets[notification.old().hints().privateValue(this, "id").toInt()]; NotifyWidget *w = m_widgets[notification.old().hints().privateValue(this, "id").toInt()];
if(w->isVisible() && w->notification().isValid() && w->notification().id() == notification.old().id()) if(w->isVisible() && w->notification().isValid() && w->notification().id() == notification.old().id())
{ {
qDebug() << "replacing notification" << w->notification().id() << notification.id();
w->update(notification); w->update(notification);
notification.hints().setPrivateValue(this, "id", w->id()); notification.hints().setPrivateValue(this, "id", w->id());
startTimeout(notification); startTimeout(notification);
return;
} }
} }
else
{
for(int i = 0; i < m_queue.length(); ++i)
{
Notification n = m_queue.at(i);
if(n.id() == notification.old().id())
{
qDebug() << "replacing qued notification" << n.id() << notification.id();
m_queue.replace(i,notification);
}
}
}
}
else
{
if(m_queue.isEmpty()) if(m_queue.isEmpty())
{ {
foreach (NotifyWidget *w, m_widgets) foreach (NotifyWidget *w, m_widgets)
@ -72,6 +89,7 @@ void SnoreNotifier::slotNotify(Snore::Notification notification)
} }
m_queue.append(notification); m_queue.append(notification);
m_timer->start(); m_timer->start();
}
} }
void SnoreNotifier::slotCloseNotification(Snore::Notification notification) void SnoreNotifier::slotCloseNotification(Snore::Notification notification)
@ -104,7 +122,6 @@ void SnoreNotifier::slotProcessQueue()
{ {
if(m_queue.isEmpty()) if(m_queue.isEmpty())
{ {
snoreDebug( SNORE_DEBUG ) << "queue is empty"; snoreDebug( SNORE_DEBUG ) << "queue is empty";
m_timer->stop(); m_timer->stop();
} }
@ -120,6 +137,7 @@ void SnoreNotifier::slotProcessQueue()
startTimeout(notification); startTimeout(notification);
if(m_queue.isEmpty()) if(m_queue.isEmpty())
{ {
m_timer->stop();
return; return;
} }
} }