From 94cf9be3c80a80a098c7d9eca931af5e533f3c69 Mon Sep 17 00:00:00 2001 From: Jeremy Lainé Date: Fri, 29 Apr 2011 08:23:59 +0000 Subject: make QXmppRosterManager emit itemRemoved(jid) when an item is removed (thanks Georg, fixes: #94) --- src/QXmppRosterManager.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/QXmppRosterManager.cpp') diff --git a/src/QXmppRosterManager.cpp b/src/QXmppRosterManager.cpp index 07cffef6..fd948e99 100644 --- a/src/QXmppRosterManager.cpp +++ b/src/QXmppRosterManager.cpp @@ -160,11 +160,17 @@ void QXmppRosterManager::rosterIqReceived(const QXmppRosterIq& rosterIq) // store updated entries and notify changes const QList items = rosterIq.items(); - for (int i = 0; i < items.count(); i++) - { - QString bareJid = items.at(i).bareJid(); - m_entries[bareJid] = items.at(i); - emit rosterChanged(bareJid); + foreach (const QXmppRosterIq::Item &item, items) { + const QString bareJid = item.bareJid(); + if (item.subscriptionType() == QXmppRosterIq::Item::Remove) { + // notify the user that the item was removed if we previously had it + if (m_entries.remove(bareJid)) + emit itemRemoved(bareJid); + } else { + // notify the user that the item changed + m_entries.insert(bareJid, item); + emit rosterChanged(bareJid); + } } } break; -- cgit v1.2.3