[SCM] ktp-contact-applet packaging branch, master, updated. debian/15.12.1-1-966-gde83ac5

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


Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-desktop-applets.git;a=commitdiff;h=728cfc7

The following commit has been merged in the master branch:
commit 728cfc78d694c4af860f5dc6e79d0db7d796f120
Author: Siddhartha Sahu <sh.siddhartha at gmail.com>
Date:   Thu Mar 20 02:54:35 2014 +0530

    Use PresenceModel from K-C-I
    
    REVIEW: 116911
---
 presence/src/presence-applet.cpp | 55 +++++-----------------------------------
 presence/src/presence-applet.h   |  4 +--
 2 files changed, 8 insertions(+), 51 deletions(-)

diff --git a/presence/src/presence-applet.cpp b/presence/src/presence-applet.cpp
index 7fe0496..1887070 100644
--- a/presence/src/presence-applet.cpp
+++ b/presence/src/presence-applet.cpp
@@ -34,6 +34,7 @@
 
 #include <KTp/actions.h>
 #include <KTp/global-presence.h>
+#include <KTp/Models/presence-model.h>
 #include <KTp/Widgets/add-contact-dialog.h>
 #include <KTp/Widgets/join-chat-room-dialog.h>
 
@@ -50,7 +51,8 @@ int TelepathyPresenceApplet::s_instanceCount = 0;
 
 TelepathyPresenceApplet::TelepathyPresenceApplet(QObject *parent, const QVariantList &args)
     : Plasma::Applet(parent, args),
-      m_globalPresence(new KTp::GlobalPresence(this))
+      m_globalPresence(new KTp::GlobalPresence(this)),
+      m_presences(new KTp::PresenceModel(this))
 {
     s_instanceCount ++;
     setupContextMenuActions();
@@ -161,67 +163,22 @@ KIcon TelepathyPresenceApplet::getThemedIcon(const QString &iconBaseName) const
 }
 
 int TelepathyPresenceApplet::handleCustomPresenceChange() {
+    m_presences->loadPresences();
     setupContextMenuActions();
     return 0;
 }
 
-void TelepathyPresenceApplet::addPresence(const KTp::Presence &presence)
-{
-    if(m_presences.contains(presence)) {
-        return;
-    }
-
-    //Add presence to correct place in list, sorted by presence type
-    QList<KTp::Presence>::iterator i = qLowerBound(m_presences.begin(), m_presences.end(), KTp::Presence(presence));
-    m_presences.insert(i, presence);
-}
-
 void TelepathyPresenceApplet::setupContextMenuActions()
 {
     m_contextActions.clear();
-    m_presences.clear();
 
     KActionMenu *moreMenu = new KActionMenu(i18n("More"), this);
 
-    KSharedConfigPtr config = KSharedConfig::openConfig("ktelepathyrc");
-    KConfigGroup m_presenceGroup = config->group("Custom Presence List");
-
-    //add default presences
-    addPresence(Tp::Presence::available());
-    addPresence(Tp::Presence::busy());
-    addPresence(Tp::Presence::away());
-    addPresence(Tp::Presence::xa());
-    addPresence(Tp::Presence::hidden());
-    addPresence(Tp::Presence::offline());
-
-    //add custom presences
-    Q_FOREACH(const QString &key, m_presenceGroup.keyList()) {
-        QVariantList entry = m_presenceGroup.readEntry(key, QVariantList());
-
-        if(entry.size()!=2)
-          continue;
-
-        QString statusMessage = entry.last().toString();
-
-        switch (entry.first().toInt()) {
-            case Tp::ConnectionPresenceTypeAvailable:
-                addPresence(Tp::Presence::available(statusMessage));
-                break;
-            case Tp::ConnectionPresenceTypeAway:
-                addPresence(Tp::Presence::away(statusMessage));
-                break;
-            case Tp::ConnectionPresenceTypeBusy:
-                addPresence(Tp::Presence::busy(statusMessage));
-                break;
-            case Tp::ConnectionPresenceTypeExtendedAway:
-                addPresence(Tp::Presence::xa(statusMessage));
-        }
-    }
-
     //This loops through the all presences and creates a menu, connects to slot and appends it to the context menu
-    Q_FOREACH(const KTp::Presence &presence, m_presences) {
+    for (int i = 0; i < m_presences->rowCount(); i++) {
         KAction *action;
         QString menuentry, icon;
+        KTp::Presence presence = m_presences->data(i).value<KTp::Presence>();
         switch (presence.type()) {
             case Tp::ConnectionPresenceTypeAvailable:
                 menuentry = (presence.statusMessage()=="") ? i18n("Online") : presence.statusMessage();
diff --git a/presence/src/presence-applet.h b/presence/src/presence-applet.h
index 76a1e36..e090f79 100644
--- a/presence/src/presence-applet.h
+++ b/presence/src/presence-applet.h
@@ -32,6 +32,7 @@
 
 namespace KTp {
     class GlobalPresence;
+    class PresenceModel;
 }
 
 namespace Tp {
@@ -98,8 +99,7 @@ private:
     QDBusServiceWatcher  *m_contactListWatcher;
     bool                  m_contactListRunning;
 
-    void addPresence(const KTp::Presence &presence);
-    QList<KTp::Presence> m_presences;
+    KTp::PresenceModel *m_presences;
 };
 
 #endif  // KTP_PRESENCE_APPLET_H

-- 
ktp-contact-applet packaging



More information about the pkg-kde-commits mailing list