[SCM] ktp-contact-list packaging branch, master, updated. debian/15.12.1-2-1070-g6c56f91

Maximiliano Curia maxy at moszumanska.debian.org
Sat May 28 00:04:29 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-contact-list.git;a=commitdiff;h=98a082c

The following commit has been merged in the master branch:
commit 98a082c56a1dbd759ac06a84535537e786de3cd4
Author: George Goldberg <grundleborg at googlemail.com>
Date:   Wed Feb 24 17:00:54 2010 +0000

    Show the presence of contacts in the contact list. WARNING: Currently doesn't update after the app is loaded.
    
    svn path=/trunk/playground/network/telepathy-contactlist/; revision=1095608
---
 contact-item.cpp        | 53 ++++++++++++++++++++++++++++++++++++++++++++++++-
 contact-item.h          |  8 ++++++++
 contacts-list-model.cpp |  3 +++
 3 files changed, 63 insertions(+), 1 deletion(-)

diff --git a/contact-item.cpp b/contact-item.cpp
index 1a5fd2d..0fbe40a 100644
--- a/contact-item.cpp
+++ b/contact-item.cpp
@@ -28,9 +28,12 @@ ContactItem::ContactItem(Nepomuk::PersonContact personContact,
                          QObject *parent)
   : QObject(parent),
     m_personContact(personContact),
-    m_imAccount(imAccount)
+    m_imAccount(imAccount),
+    m_presenceIcon(new KIcon)
 {
     kDebug() << this << ": New ContactItem: " << personContact.uri() << imAccount.uri();
+
+    updatePresenceIcon();
 }
 
 ContactItem::~ContactItem()
@@ -44,6 +47,54 @@ QString ContactItem::displayName() const
     return m_imAccount.imNicknames().first();
 }
 
+void ContactItem::updatePresenceIcon()
+{
+    // First, delete the old Icon.
+    delete m_presenceIcon;
+
+    // Now find out the current status.
+    QList<qint64> statusTypes = m_imAccount.statusTypes();
+
+    // If no presenceType set, then null KIcon.
+    if (statusTypes.size() == 0) {
+        m_presenceIcon = new KIcon();
+        return;
+    }
+
+    // Get the presence type and set the icon appropriately from it.
+    QString iconName;
+
+    switch (statusTypes.first()) {
+    case 2:
+        iconName = "user-online";
+        break;
+    case 3:
+        iconName = "user-away";
+        break;
+    case 4:
+        iconName = "user-away-extended";
+        break;
+    case 5:
+        iconName = "user-invisible";
+        break;
+    case 6:
+        iconName = "user-busy";
+        break;
+    default:
+        iconName = "user-offline";
+        break;
+    }
+
+    m_presenceIcon = new KIcon(iconName);
+}
+
+const KIcon& ContactItem::presenceIcon() const
+{
+    Q_ASSERT(m_presenceIcon != 0);
+
+    return *m_presenceIcon;
+}
+
 
 #include "contact-item.moc"
 
diff --git a/contact-item.h b/contact-item.h
index 323ab11..36befca 100644
--- a/contact-item.h
+++ b/contact-item.h
@@ -25,6 +25,8 @@
 #include "imaccount.h"
 #include "personcontact.h"
 
+#include <KIcon>
+
 #include <QObject>
 
 class ContactItem : public QObject {
@@ -38,12 +40,18 @@ public:
     ~ContactItem();
 
     QString displayName() const;
+    const KIcon& presenceIcon() const;
+
+private Q_SLOTS:
+    void updatePresenceIcon();
 
 private:
     Q_DISABLE_COPY(ContactItem);
 
     Nepomuk::PersonContact m_personContact;
     Nepomuk::IMAccount m_imAccount;
+
+    KIcon *m_presenceIcon;
 };
 
 #endif // Header guard
diff --git a/contacts-list-model.cpp b/contacts-list-model.cpp
index d368acd..66aff4a 100644
--- a/contacts-list-model.cpp
+++ b/contacts-list-model.cpp
@@ -109,6 +109,9 @@ QVariant ContactsListModel::data(const QModelIndex &index, int role) const
     case Qt::DisplayRole:
         data.setValue<QString>(m_contactItems.at(index.row())->displayName());
         break;
+    case Qt::DecorationRole:
+        data.setValue<QIcon>(m_contactItems.at(index.row())->presenceIcon());
+        break;
     default:
         break;
     }

-- 
ktp-contact-list packaging



More information about the pkg-kde-commits mailing list