[SCM] ktp-text-ui packaging branch, master, updated. debian/15.12.1-1-1918-gdf4b0ec

Maximiliano Curia maxy at moszumanska.debian.org
Sat May 28 00:19:09 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-text-ui.git;a=commitdiff;h=62e35ba

The following commit has been merged in the master branch:
commit 62e35bafac288869da27980477b83f956164e391
Author: David Edmundson <kde at davidedmundson.co.uk>
Date:   Thu Mar 24 02:46:26 2011 +0000

    Code tidy up
---
 lib/channel-contact-list.cpp | 85 +++++++++++++++++++++++++-------------------
 lib/channel-contact-list.h   | 13 ++++---
 2 files changed, 56 insertions(+), 42 deletions(-)

diff --git a/lib/channel-contact-list.cpp b/lib/channel-contact-list.cpp
index 980f4eb..d970725 100644
--- a/lib/channel-contact-list.cpp
+++ b/lib/channel-contact-list.cpp
@@ -25,9 +25,10 @@
 ChannelContactList::ChannelContactList(const Tp::TextChannelPtr & channel, QObject *parent)
     : QAbstractListModel(parent)
 {
-
+    //add existing contacts
     addContacts(channel->groupContacts());
 
+    //monitor for future changes
     connect(channel.data(),
             SIGNAL(groupMembersChanged(Tp::Contacts,Tp::Contacts,Tp::Contacts,
                                        Tp::Contacts,Tp::Channel::GroupMemberChangeDetails)),
@@ -35,40 +36,6 @@ ChannelContactList::ChannelContactList(const Tp::TextChannelPtr & channel, QObje
                                      Tp::Contacts,Tp::Channel::GroupMemberChangeDetails)));
 }
 
-void ChannelContactList::onGroupMembersChanged(const Tp::Contacts & groupMembersAdded,
-                                             const Tp::Contacts & groupLocalPendingMembersAdded,
-                                             const Tp::Contacts & groupRemotePendingMembersAdded,
-                                             const Tp::Contacts & groupMembersRemoved,
-                                             const Tp::Channel::GroupMemberChangeDetails & details)
-{
-    kDebug();
-
-    Q_UNUSED(groupLocalPendingMembersAdded);
-    Q_UNUSED(groupRemotePendingMembersAdded);
-    Q_UNUSED(details);
-
-    addContacts(groupMembersAdded);
-    removeContacts(groupMembersRemoved);
-}
-
-void ChannelContactList::onContactPresenceChanged(const Tp::Presence &presence)
-{
-    Tp::ContactPtr contact(qobject_cast<Tp::Contact*>(sender()));
-
-    QModelIndex index = createIndex(m_contacts.lastIndexOf(contact), 0);
-    emit dataChanged(index, index);
-
-    emit contactPresenceChanged(contact, presence);}
-
-void ChannelContactList::onContactAliasChanged(const QString &alias)
-{
-    Tp::ContactPtr contact(qobject_cast<Tp::Contact*>(sender()));
-
-    QModelIndex index = createIndex(m_contacts.lastIndexOf(contact), 0);
-    emit dataChanged(index, index);
-
-    emit contactAliasChanged(contact, alias);
-}
 
 int ChannelContactList::rowCount(const QModelIndex &parent) const
 {
@@ -89,27 +56,65 @@ QVariant ChannelContactList::data(const QModelIndex &index, int role) const
     switch (role) {
     case Qt::DisplayRole:
         return QVariant(m_contacts[row]->alias());
+
     case Qt::DecorationRole:
         switch(m_contacts[row]->presence().type()) {
         case Tp::ConnectionPresenceTypeAvailable:
             return QVariant(KIcon("im-user"));
         case Tp::ConnectionPresenceTypeAway:
+            //fall through
         case Tp::ConnectionPresenceTypeExtendedAway:
             return QVariant(KIcon("im-user-away"));
         case Tp::ConnectionPresenceTypeBusy:
             return QVariant(KIcon("im-user-busy"));
         case Tp::ConnectionPresenceTypeOffline:
+            //fall through
         case Tp::ConnectionPresenceTypeHidden:
             return QVariant(KIcon("im-user-offline"));
         default:
             return QVariant(KIcon("im-user"));
         }
-         //icon for presence stuff here? im-user-away etc.
+
     default:
         return QVariant();
     }
 }
 
+void ChannelContactList::onGroupMembersChanged(const Tp::Contacts & groupMembersAdded,
+                                             const Tp::Contacts & groupLocalPendingMembersAdded,
+                                             const Tp::Contacts & groupRemotePendingMembersAdded,
+                                             const Tp::Contacts & groupMembersRemoved,
+                                             const Tp::Channel::GroupMemberChangeDetails & details)
+{
+    kDebug();
+
+    Q_UNUSED(groupLocalPendingMembersAdded);
+    Q_UNUSED(groupRemotePendingMembersAdded);
+    Q_UNUSED(details);
+
+    addContacts(groupMembersAdded);
+    removeContacts(groupMembersRemoved);
+}
+
+void ChannelContactList::onContactPresenceChanged(const Tp::Presence &presence)
+{
+    Tp::ContactPtr contact(qobject_cast<Tp::Contact*>(sender()));
+
+    QModelIndex index = createIndex(m_contacts.lastIndexOf(contact), 0);
+    emit dataChanged(index, index);
+
+    emit contactPresenceChanged(contact, presence);}
+
+void ChannelContactList::onContactAliasChanged(const QString &alias)
+{
+    Tp::ContactPtr contact(qobject_cast<Tp::Contact*>(sender()));
+
+    QModelIndex index = createIndex(m_contacts.lastIndexOf(contact), 0);
+    emit dataChanged(index, index);
+
+    emit contactAliasChanged(contact, alias);
+}
+
 void ChannelContactList::addContacts(const Tp::Contacts &contacts)
 {
     QList<Tp::ContactPtr> newContacts = contacts.toList();
@@ -127,7 +132,13 @@ void ChannelContactList::addContacts(const Tp::Contacts &contacts)
 void ChannelContactList::removeContacts(const Tp::Contacts &contacts)
 {
     foreach(Tp::ContactPtr contact, contacts) {
-        //does it make sense to disconnect the signals here too? as technically the contact itself hasn't actually been deleted yet...
+
+        //I think this is needed as technically the contact itself hasn't actually been deleted even if we remove our pointers to it
+        //and could be used referenced elsewhere in the chat application in a different tab.
+        //if we don't disconnect could we still get notifications here about their status/presence changes even if a contact has left the room
+        disconnect(contact.data(), SIGNAL(aliasChanged(QString)), SLOT(onContactAliasChanged(QString)));
+        disconnect(contact.data(), SIGNAL(presenceChanged(Tp::Presence)), SLOT(onContactPresenceChanged(Tp::Presence)));
+
         beginRemoveRows(QModelIndex(), m_contacts.indexOf(contact), m_contacts.indexOf(contact));
         m_contacts.removeAll(contact);
         endRemoveRows();
diff --git a/lib/channel-contact-list.h b/lib/channel-contact-list.h
index fe1db06..97d19c9 100644
--- a/lib/channel-contact-list.h
+++ b/lib/channel-contact-list.h
@@ -29,17 +29,20 @@
 #include <TelepathyQt4/Presence>
 
 /** A model of all users in the channel.
-  Also acts as a proxy for emiting presence and alias changes of any contacts in the channel for displaying as notifications*/
+  Also acts as a proxy for emiting presence and alias changes of any contacts in the channel
+  so that the main class doesn't need to monitor this and keep connection/disconnecting to alias change/presence
+  change for notification messages
+  */
 
 class ChannelContactList : public QAbstractListModel
 {
     Q_OBJECT
 public:
-    explicit ChannelContactList(const Tp::TextChannelPtr & channel, QObject *parent = 0);
+    explicit ChannelContactList(const Tp::TextChannelPtr &channel, QObject *parent = 0);
 
 signals:
-    void contactPresenceChanged(const Tp::ContactPtr & contact, const Tp::Presence & presence);
-    void contactAliasChanged(const Tp::ContactPtr & contact, const QString & alias);
+    void contactPresenceChanged(const Tp::ContactPtr &contact, const Tp::Presence &presence);
+    void contactAliasChanged(const Tp::ContactPtr &contact, const QString &alias);
 
 protected:
     int rowCount(const QModelIndex &parent) const;
@@ -51,7 +54,7 @@ private slots:
                              const Tp::Contacts &groupRemotePendingMembersAdded,
                              const Tp::Contacts &groupMembersRemoved,
                              const Tp::Channel::GroupMemberChangeDetails &details);
-    void onContactPresenceChanged(const Tp::Presence& presence);
+    void onContactPresenceChanged(const Tp::Presence &presence);
     void onContactAliasChanged(const QString &alias);
 
 

-- 
ktp-text-ui packaging



More information about the pkg-kde-commits mailing list