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


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

The following commit has been merged in the master branch:
commit f40ac94cd384a0780e9730c9a36b4e23966ccb3f
Author: David Edmundson <kde at davidedmundson.co.uk>
Date:   Sat Oct 8 14:22:22 2011 +0100

    Added the "configure button" to the presence drop down in a much better way.
---
 global-presence-chooser.cpp | 74 +++++++++++++++++++++++++++++++++++++++++++--
 global-presence.cpp         |  1 +
 presence-model.cpp          |  4 ---
 presence-model.h            |  2 +-
 4 files changed, 74 insertions(+), 7 deletions(-)

diff --git a/global-presence-chooser.cpp b/global-presence-chooser.cpp
index e74d95e..879f109 100644
--- a/global-presence-chooser.cpp
+++ b/global-presence-chooser.cpp
@@ -13,12 +13,80 @@
 
 #include <QMouseEvent>
 
+//A sneaky class that adds an extra entry to the end of the presence model
+//called "Configure Presences"
+class PresenceModelPlusConfig : public QAbstractListModel
+{
+    Q_OBJECT
+public:
+    PresenceModelPlusConfig(PresenceModel *presenceModel, QObject *parent);
+    int rowCount(const QModelIndex &parent) const;
+    QVariant data(const QModelIndex &index, int role) const;
+private slots:
+    void sourceRowsInserted(const QModelIndex &index, int start, int end);
+    void sourceRowsRemoved(const QModelIndex &index, int start, int end);
+private:
+    PresenceModel *m_model;
+};
+
+PresenceModelPlusConfig::PresenceModelPlusConfig(PresenceModel *presenceModel, QObject *parent) :
+    QAbstractListModel(parent),
+    m_model(presenceModel)
+{
+    connect(m_model, SIGNAL(rowsInserted(QModelIndex, int, int)), SLOT(sourceRowsInserted(QModelIndex,int,int)));
+    connect(m_model, SIGNAL(rowsRemoved(QModelIndex, int, int)), SLOT(sourceRowsRemoved(QModelIndex,int,int)));
+}
+
+//return number of rows + an extra item for the "configure presences" button
+int PresenceModelPlusConfig::rowCount(const QModelIndex &parent) const
+{
+    if (parent.isValid()) {
+        return 0;
+    }
+    return m_model->rowCount(parent) + 1;
+}
+
+QVariant PresenceModelPlusConfig::data(const QModelIndex &index, int role) const
+{
+/*    //if it's our new button
+    if (index.row() == rowCount(index.parent())-2) {
+        switch(role) {
+        case Qt::AccessibleDescriptionRole:
+            return QLatin1String("separator");
+        }
+    } else */
+    if (index.row() == rowCount(index.parent())-1) {
+        switch(role) {
+        case Qt::DisplayRole:
+            return i18n("Configure Custom Presences");
+        case Qt::DecorationRole:
+            return KIcon("configure");
+        }
+    } else {
+        return m_model->data(m_model->index(index.row()), role);
+    }
+    return QVariant();
+}
+
+void PresenceModelPlusConfig::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)
+{
+    beginRemoveRows(createIndex(index.row(), 0), start, end);
+    endRemoveRows();
+}
+
+
 GlobalPresenceChooser::GlobalPresenceChooser(QWidget *parent) :
     KComboBox(parent),
     m_globalPresence(new GlobalPresence(this)),
     m_model(new PresenceModel(this))
 {
-    this->setModel(m_model);
+    this->setModel(new PresenceModelPlusConfig(m_model, this));
 
     connect(this, SIGNAL(activated(int)), SLOT(onCurrentIndexChanged(int)));
     connect(m_globalPresence, SIGNAL(currentPresenceChanged(Tp::Presence)), SLOT(onPresenceChanged(Tp::Presence)));
@@ -33,7 +101,7 @@ void GlobalPresenceChooser::setAccountManager(const Tp::AccountManagerPtr &accou
 
 void GlobalPresenceChooser::onCurrentIndexChanged(int index)
 {
-    //FIXME hack - if they select the "configure item"
+    //if they select the "configure item"
     if (index == count()-1) {
         CustomPresenceDialog dialog(m_model, this);
         dialog.exec();
@@ -61,3 +129,5 @@ void GlobalPresenceChooser::onPresenceChanged(const Tp::Presence &presence)
     setCurrentIndex(index.row());
 }
 
+#include "global-presence-chooser.moc"
+#include "moc_global-presence-chooser.cpp" //hack because we have two QObejcts in teh same file
diff --git a/global-presence.cpp b/global-presence.cpp
index 1171ffc..37b3db3 100644
--- a/global-presence.cpp
+++ b/global-presence.cpp
@@ -125,3 +125,4 @@ void GlobalPresence::onChangingPresence()
     }
 }
 
+#include "global-presence.moc"
diff --git a/presence-model.cpp b/presence-model.cpp
index ee1cc81..de5c017 100644
--- a/presence-model.cpp
+++ b/presence-model.cpp
@@ -92,10 +92,6 @@ void PresenceModel::loadDefaultPresences()
     addPresence(Tp::Presence::xa());
     addPresence(Tp::Presence::hidden());
     addPresence(Tp::Presence::offline());
-
-
-    //FIXME FIXME FIXIME this is just a hack!
-    addPresence(Tp::Presence::offline("Configure Custom Messages..."));
 }
 
 
diff --git a/presence-model.h b/presence-model.h
index b1df644..27bc226 100644
--- a/presence-model.h
+++ b/presence-model.h
@@ -29,7 +29,7 @@ public:
     /** Returns the index of a given presence, adding it if needed*/
     QModelIndex indexOf(const Tp::Presence &presence);
 
-protected:
+//protected:
     virtual QVariant data(const QModelIndex &index, int role) const;
     virtual int rowCount(const QModelIndex &parent) const;
 

-- 
ktp-contact-list packaging



More information about the pkg-kde-commits mailing list