[telepathy-qt4/master] ContactManager: Refactor common code for setting/adding contact list groups.
Andre Moreira Magalhaes (andrunko)
andre.magalhaes at collabora.co.uk
Wed Jul 22 11:55:50 PDT 2009
---
TelepathyQt4/contact-manager.cpp | 27 +++++++++++++--------------
1 files changed, 13 insertions(+), 14 deletions(-)
diff --git a/TelepathyQt4/contact-manager.cpp b/TelepathyQt4/contact-manager.cpp
index ce37043..6d7321b 100644
--- a/TelepathyQt4/contact-manager.cpp
+++ b/TelepathyQt4/contact-manager.cpp
@@ -70,6 +70,17 @@ struct ContactManager::Private
{
}
+ QString addContactListGroupChannel(const ChannelPtr &contactListGroupChannel)
+ {
+ QString id = contactListGroupChannel->immutableProperties().value(
+ QLatin1String(TELEPATHY_INTERFACE_CHANNEL ".TargetID")).toString();
+ contactListGroupsChannels.insert(id, contactListGroupChannel);
+ parent->connect(contactListGroupChannel.data(),
+ SIGNAL(invalidated(Tp::DBusProxy *, const QString &, const QString &)),
+ SLOT(onContactListGroupRemoved(Tp::DBusProxy *, const QString &, const QString &)));
+ return id;
+ }
+
ContactManager *parent;
WeakPtr<Connection> connection;
QMap<uint, QWeakPointer<Contact> > contacts;
@@ -972,27 +983,15 @@ void ContactManager::setContactListGroupsChannels(
{
Q_ASSERT(mPriv->contactListGroupsChannels.isEmpty());
- QString id;
foreach (const ChannelPtr &contactListGroupChannel, contactListGroupsChannels) {
- id = contactListGroupChannel->immutableProperties().value(
- QLatin1String(TELEPATHY_INTERFACE_CHANNEL ".TargetID")).toString();
- mPriv->contactListGroupsChannels.insert(id, contactListGroupChannel);
- connect(contactListGroupChannel.data(),
- SIGNAL(invalidated(Tp::DBusProxy *, const QString &, const QString &)),
- SLOT(onContactListGroupRemoved(Tp::DBusProxy *, const QString &, const QString &)));
+ mPriv->addContactListGroupChannel(contactListGroupChannel);
}
}
void ContactManager::addContactListGroupChannel(
const ChannelPtr &contactListGroupChannel)
{
- QString id = contactListGroupChannel->immutableProperties().value(
- QLatin1String(TELEPATHY_INTERFACE_CHANNEL ".TargetID")).toString();
- mPriv->contactListGroupsChannels.insert(id, contactListGroupChannel);
- connect(contactListGroupChannel.data(),
- SIGNAL(invalidated(Tp::DBusProxy *, const QString &, const QString &)),
- SLOT(onContactListGroupRemoved(Tp::DBusProxy *, const QString &, const QString &)));
-
+ QString id = mPriv->addContactListGroupChannel(contactListGroupChannel);
emit groupAdded(id);
}
--
1.5.6.5
More information about the telepathy-commits
mailing list