[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:07:47 UTC 2016


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

The following commit has been merged in the master branch:
commit 36d4bc77304bc2d3682e2c79e8f30723a6b450fb
Author: David Edmundson <kde at davidedmundson.co.uk>
Date:   Fri Oct 7 00:25:02 2011 +0100

    Load + Save custom messages
---
 dialogs/custom-presence-dialog.cpp | 11 --------
 kpresence.cpp                      |  1 -
 kpresence.h                        |  3 +-
 presence-model.cpp                 | 56 ++++++++++++++++++++++++++++----------
 presence-model.h                   |  5 ++--
 5 files changed, 45 insertions(+), 31 deletions(-)

diff --git a/dialogs/custom-presence-dialog.cpp b/dialogs/custom-presence-dialog.cpp
index 9459087..935d7ab 100644
--- a/dialogs/custom-presence-dialog.cpp
+++ b/dialogs/custom-presence-dialog.cpp
@@ -107,13 +107,6 @@ void CustomPresenceDialog::setupDialog()
 
     setMainWidget(mainDialogWidget);
 
-
-//    int presenceIcon;
-//    foreach(const QString& presenceString, m_presenceGroup->keyList()) {
-//       presenceIcon = m_presenceGroup->readEntry<int>(presenceString, 0);
-//       new QListWidgetItem(iconForIndex(presenceIcon), presenceString.left(presenceString.size() - 2), m_listView);
-//    }
-    
     connect(addStatus, SIGNAL(clicked()), SLOT(addCustomPresence()));
     connect(removeStatus, SIGNAL(clicked()), SLOT(removeCustomPresence()));
     connect(m_statusMessage, SIGNAL(returnPressed()), SLOT(addCustomPresence()));
@@ -126,10 +119,6 @@ void CustomPresenceDialog::addCustomPresence()
     presence.setStatus(presence.type(), QString(), m_statusMessage->currentText());
 
     m_model->addPresence(presence);
-
-//    QString uniquePresenceString = m_statusMessage->currentText() + "_" + QString::number(m_statusMessage->currentIndex());
-//    m_presenceGroup->writeEntry(uniquePresenceString, m_statusMessage->currentIndex());
-//    m_presenceGroup->sync();
 }
 
 void CustomPresenceDialog::removeCustomPresence()
diff --git a/kpresence.cpp b/kpresence.cpp
index 698812d..fe65fac 100644
--- a/kpresence.cpp
+++ b/kpresence.cpp
@@ -3,7 +3,6 @@
 KPresence::KPresence() :
     Tp::Presence()
 {
-
 }
 
 KPresence::KPresence(const Tp::Presence &presence) :
diff --git a/kpresence.h b/kpresence.h
index 59d4fc1..4ac63d1 100644
--- a/kpresence.h
+++ b/kpresence.h
@@ -5,7 +5,6 @@
 
 #include <KIcon>
 
-
 class KPresence : public Tp::Presence
 {
 public:
@@ -13,7 +12,7 @@ public:
     KPresence(const Tp::Presence &presence);
     KIcon icon() const;
 
-
+    /** Returns which presence is "more available" */
     bool operator <(const KPresence &other) const;
 };
 
diff --git a/presence-model.cpp b/presence-model.cpp
index 23a7947..755ed37 100644
--- a/presence-model.cpp
+++ b/presence-model.cpp
@@ -1,6 +1,7 @@
 #include "presence-model.h"
 
 #include <QFont>
+#include <QUuid>
 
 #include <KIcon>
 #include <KLocalizedString>
@@ -13,10 +14,24 @@
 PresenceModel::PresenceModel(QObject *parent) :
     QAbstractListModel(parent)
 {
+    KSharedConfigPtr config = KSharedConfig::openConfig("telepathy-kde-contactlistrc");
+    m_presenceGroup = config->group("Custom Presence List");
+
     loadDefaultPresences();
+    loadCustomPresences();
+}
 
-    KSharedConfigPtr config = KSharedConfig::openConfig("telepathy-kde-contactlistrc");
-    m_presenceGroup = new KConfigGroup( config, "Custom Presence List" );
+PresenceModel::~PresenceModel()
+{
+    Q_FOREACH(const KPresence &presence, m_presences) {
+        if (!presence.statusMessage().isEmpty()) {
+            QVariantList presenceVariant;
+            presenceVariant.append(presence.type());
+            presenceVariant.append(presence.statusMessage());
+            QString id = QString::number(presence.type()).append(presence.statusMessage());
+            m_presenceGroup.writeEntry(id, presenceVariant);
+        }
+    }
 }
 
 QVariant PresenceModel::data(const QModelIndex &index, int role) const
@@ -71,18 +86,9 @@ int PresenceModel::rowCount(const QModelIndex &parent) const
 void PresenceModel::loadDefaultPresences()
 {
     addPresence(Tp::Presence::available());
-
     addPresence(Tp::Presence::busy());
-
-    addPresence(Tp::Presence::xa());
-    addPresence(Tp::Presence::xa("Abducted by aliens, back later"));
-
-
     addPresence(Tp::Presence::away());
-    addPresence(Tp::Presence::away("Back Soon!"));
-    addPresence(Tp::Presence::away("Off to eat some cheese"));
-
-
+    addPresence(Tp::Presence::xa());
     addPresence(Tp::Presence::hidden());
     addPresence(Tp::Presence::offline());
 
@@ -91,6 +97,28 @@ void PresenceModel::loadDefaultPresences()
     addPresence(Tp::Presence::offline("Configure Custom Messages..."));
 }
 
+
+void PresenceModel::loadCustomPresences()
+{
+    Q_FOREACH(const QString key, m_presenceGroup.keyList()) {
+        QVariantList entry = m_presenceGroup.readEntry(key, QVariantList());
+
+        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;
+        }
+    }
+}
+
 QModelIndex PresenceModel::addPresence(const Tp::Presence &presence)
 {
     QList<KPresence>::iterator i = qLowerBound(m_presences.begin(), m_presences.end(), KPresence(presence));
@@ -101,9 +129,6 @@ QModelIndex PresenceModel::addPresence(const Tp::Presence &presence)
     beginInsertRows(QModelIndex(), index, index);
     endInsertRows();
 
-    //save changes
-    m_presenceGroup->writeEntry("presences", presence);
-
     return createIndex(index, 0);
 }
 
@@ -116,3 +141,4 @@ void PresenceModel::removePresence(const Tp::Presence &presence)
 
     //FIXME edit the config file too
 }
+
diff --git a/presence-model.h b/presence-model.h
index 9138b6c..b1df644 100644
--- a/presence-model.h
+++ b/presence-model.h
@@ -5,13 +5,14 @@
 
 #include <QAbstractListModel>
 
-class KConfigGroup;
+#include <KConfigGroup>
 
 class PresenceModel : public QAbstractListModel
 {
     Q_OBJECT
 public:
     explicit PresenceModel(QObject *parent = 0);
+    ~PresenceModel();
 
     enum Roles {
         //Also supplies Qt::DisplayRole and Qt::DecorationRole
@@ -48,7 +49,7 @@ private:
     QList<KPresence> m_presences;
 
     //this is wrong, KConfigGroup is a sharedptr..
-    KConfigGroup *m_presenceGroup;
+    KConfigGroup m_presenceGroup;
 };
 
 #endif // PRESENCEMODEL_H

-- 
ktp-contact-list packaging



More information about the pkg-kde-commits mailing list