[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:08:02 UTC 2016


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

The following commit has been merged in the master branch:
commit d6664b56c02ac5f023087599245128d1cda9017e
Author: David Edmundson <kde at davidedmundson.co.uk>
Date:   Sat Nov 12 20:39:28 2011 +0000

    Temporary presence
---
 global-presence-chooser.cpp | 61 +++++++++++++++++++++++++++++++++++----------
 global-presence-chooser.h   |  4 +++
 2 files changed, 52 insertions(+), 13 deletions(-)

diff --git a/global-presence-chooser.cpp b/global-presence-chooser.cpp
index a448846..44f53fb 100644
--- a/global-presence-chooser.cpp
+++ b/global-presence-chooser.cpp
@@ -42,21 +42,24 @@
 
 //A sneaky class that adds an extra entry to the end of the presence model
 //called "Configure Presences"
-class PresenceModelPlusConfig : public QAbstractListModel
+class PresenceModelExtended : public QAbstractListModel
 {
     Q_OBJECT
 public:
-    PresenceModelPlusConfig(PresenceModel *presenceModel, QObject *parent);
+    PresenceModelExtended(PresenceModel *presenceModel, QObject *parent);
     int rowCount(const QModelIndex &parent) const;
     QVariant data(const QModelIndex &index, int role) const;
+    QModelIndex addTemporaryPresence(const KPresence &presence);
+    void removeTemporaryPresence();
 private slots:
     void sourceRowsInserted(const QModelIndex &index, int start, int end);
     void sourceRowsRemoved(const QModelIndex &index, int start, int end);
 private:
+    KPresence m_temporaryPresence;
     PresenceModel *m_model;
 };
 
-PresenceModelPlusConfig::PresenceModelPlusConfig(PresenceModel *presenceModel, QObject *parent) :
+PresenceModelExtended::PresenceModelExtended(PresenceModel *presenceModel, QObject *parent) :
     QAbstractListModel(parent),
     m_model(presenceModel)
 {
@@ -65,15 +68,19 @@ PresenceModelPlusConfig::PresenceModelPlusConfig(PresenceModel *presenceModel, Q
 }
 
 //return number of rows + an extra item for the "configure presences" button
-int PresenceModelPlusConfig::rowCount(const QModelIndex &parent) const
+int PresenceModelExtended::rowCount(const QModelIndex &parent) const
 {
     if (parent.isValid()) {
         return 0;
     }
-    return m_model->rowCount(parent) + 2;
+    int rowCount = m_model->rowCount(parent) + 2;
+    if (m_temporaryPresence.isValid()) {
+        rowCount++;
+    }
+    return rowCount;
 }
 
-QVariant PresenceModelPlusConfig::data(const QModelIndex &index, int role) const
+QVariant PresenceModelExtended::data(const QModelIndex &index, int role) const
 {
     if (index.row() == rowCount(index.parent())-1) {
         switch(role) {
@@ -89,32 +96,60 @@ QVariant PresenceModelPlusConfig::data(const QModelIndex &index, int role) const
             case Qt::DecorationRole:
                 return KIcon("speaker");
         }
-    } else {
+    } else if (m_temporaryPresence.isValid() && index.row() == rowCount(index.parent()) -3) {
+        switch(role) {
+        case Qt::DisplayRole:
+            return m_temporaryPresence.statusMessage();
+        case Qt::DecorationRole:
+            return m_temporaryPresence.icon();
+        case PresenceModel::PresenceRole:
+            return QVariant::fromValue<Tp::Presence>(m_temporaryPresence);
+        }
+    }
+    else {
         return m_model->data(m_model->index(index.row()), role);
     }
     return QVariant();
 }
 
-void PresenceModelPlusConfig::sourceRowsInserted(const QModelIndex &index, int start, int end)
+void PresenceModelExtended::sourceRowsInserted(const QModelIndex &index, int start, int end)
 {
     beginInsertRows(createIndex(index.row(), 0), start, end);
     endInsertRows();
 }
 
-void PresenceModelPlusConfig::sourceRowsRemoved(const QModelIndex &index, int start, int end)
+void PresenceModelExtended::sourceRowsRemoved(const QModelIndex &index, int start, int end)
 {
     beginRemoveRows(createIndex(index.row(), 0), start, end);
     endRemoveRows();
 }
 
+QModelIndex PresenceModelExtended::addTemporaryPresence(const KPresence &presence)
+{
+    int row = m_model->rowCount(QModelIndex());
+    beginInsertRows(QModelIndex(),row, row);
+    m_temporaryPresence = presence;
+    endInsertRows();
+    return this->createIndex(row, 0);
+}
+
+void PresenceModelExtended::removeTemporaryPresence()
+{
+    int row = m_model->rowCount(QModelIndex());
+    beginRemoveRows(QModelIndex(),row, row);
+    m_temporaryPresence = KPresence();
+    endRemoveRows();
+}
+
 //----------------------------------------------------------------------------------------------------------
 
 GlobalPresenceChooser::GlobalPresenceChooser(QWidget *parent) :
     KComboBox(parent),
     m_globalPresence(new GlobalPresence(this)),
-    m_model(new PresenceModel(this))
+    m_model(new PresenceModel(this)),
+    m_modelExtended(new PresenceModelExtended(m_model, this))
 {
-    this->setModel(new PresenceModelPlusConfig(m_model, this));
+    this->setModel(m_modelExtended);
 
     m_busyOverlay = new KPixmapSequenceOverlayPainter(this);
     m_busyOverlay->setSequence(KPixmapSequence("process-working"));
@@ -215,6 +250,7 @@ void GlobalPresenceChooser::onCurrentIndexChanged(int index)
 
 void GlobalPresenceChooser::onPresenceChanged(const Tp::Presence &presence)
 {
+    m_modelExtended->removeTemporaryPresence();
     kDebug();
     for (int i=0; i < count() ; i++) {
         Tp::Presence itemPresence = itemData(i, PresenceModel::PresenceRole).value<Tp::Presence>();
@@ -224,8 +260,7 @@ void GlobalPresenceChooser::onPresenceChanged(const Tp::Presence &presence)
         }
     }
 
-    //FIXME this needs to only be a temporary presence, which we delete afterwards
-    QModelIndex index = m_model->addPresence(presence);
+    QModelIndex index = m_modelExtended->addTemporaryPresence(presence);
     setCurrentIndex(index.row());
 }
 
diff --git a/global-presence-chooser.h b/global-presence-chooser.h
index 740f6f3..c4e4302 100644
--- a/global-presence-chooser.h
+++ b/global-presence-chooser.h
@@ -28,6 +28,8 @@
 class KPixmapSequenceOverlayPainter;
 class GlobalPresence;
 class PresenceModel;
+class PresenceModelExtended;
+
 
 class GlobalPresenceChooser : public KComboBox
 {
@@ -49,6 +51,8 @@ private slots:
 private:
     GlobalPresence *m_globalPresence;
     PresenceModel *m_model;
+    PresenceModelExtended *m_modelExtended;
+
     KPixmapSequenceOverlayPainter *m_busyOverlay;
     Tp::AccountManagerPtr m_accountManager;
 };

-- 
ktp-contact-list packaging



More information about the pkg-kde-commits mailing list