[SCM] ktp-accounts-kcm packaging branch, master, updated. debian/15.12.1-1-1157-gc4589c5

Maximiliano Curia maxy at moszumanska.debian.org
Fri May 27 23:58:49 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-accounts-kcm.git;a=commitdiff;h=e9548f9

The following commit has been merged in the master branch:
commit e9548f98e22648e0d1a221462fe500ee10efb824
Author: David Edmundson <kde at davidedmundson.co.uk>
Date:   Sat Jan 8 16:24:37 2011 +0000

    Add connection state to the Accounts Model
---
 src/account-item.cpp        | 35 ++++++++++++++++++++++++++++++++++-
 src/account-item.h          |  2 ++
 src/accounts-list-model.cpp |  8 ++++++++
 src/accounts-list-model.h   |  6 ++++++
 4 files changed, 50 insertions(+), 1 deletion(-)

diff --git a/src/account-item.cpp b/src/account-item.cpp
index a670a1b..471d4d8 100644
--- a/src/account-item.cpp
+++ b/src/account-item.cpp
@@ -23,9 +23,11 @@
 #include "accounts-list-model.h"
 #include "edit-account-dialog.h"
 
+
 #include <KApplication>
 #include <KDebug>
 #include <KIcon>
+#include <KLocalizedString>
 
 #include <QtCore/QTimer>
 #include <QtGui/QPainter>
@@ -47,6 +49,9 @@ AccountItem::AccountItem(const Tp::AccountPtr &account, AccountsListModel *paren
     connect(m_account.data(),
             SIGNAL(displayNameChanged(const QString&)),
             SIGNAL(updated()));
+    connect(m_account.data(),
+            SIGNAL(connectionStatusChanged(Tp::ConnectionStatus)),
+            SIGNAL(updated()));
 
     generateIcon();
 }
@@ -80,12 +85,40 @@ const KIcon& AccountItem::icon() const
     return *m_icon;
 }
 
+const QString AccountItem::connectionStateString() const
+{
+    switch (m_account->connectionStatus()) {
+    case Tp::ConnectionStatusConnected:
+        return i18n("Online");
+    case Tp::ConnectionStatusConnecting:
+        return i18n("Connecting");
+    case Tp::ConnectionStatusDisconnected:
+        return i18n("Disconnected");
+    default:
+        return "Unknown";
+    }
+}
+
+const KIcon AccountItem::connectionStateIcon() const
+{
+    switch (m_account->connectionStatus()) {
+    case Tp::ConnectionStatusConnected:
+        return KIcon("user-online");
+    case Tp::ConnectionStatusConnecting:
+        return KIcon("user-away"); //FIXME this is bit misleading
+    case Tp::ConnectionStatusDisconnected:
+        return KIcon("user-offline");
+    default:
+        return KIcon("user-offline");
+    }
+}
+
 void AccountItem::generateIcon()
 {
     kDebug();
 
     QString iconPath = account()->iconName();
-    //if the icon has not been setted, we use the protocol icon
+    //if the icon has not been set, we use the protocol icon
 
     if(iconPath.isEmpty()) {
         iconPath = QString("im-%1").arg(account()->protocolName());
diff --git a/src/account-item.h b/src/account-item.h
index c078ce2..137e893 100644
--- a/src/account-item.h
+++ b/src/account-item.h
@@ -44,6 +44,8 @@ public:
     Tp::AccountPtr account() const;
     void remove();
     const KIcon& icon() const;
+    const QString connectionStateString() const;
+    const KIcon connectionStateIcon() const;
 
 public Q_SLOTS:
     void onTitleForCustomPages(QString, QList<QString>);
diff --git a/src/accounts-list-model.cpp b/src/accounts-list-model.cpp
index 5ceaa9a..5862398 100644
--- a/src/accounts-list-model.cpp
+++ b/src/accounts-list-model.cpp
@@ -78,6 +78,14 @@ QVariant AccountsListModel::data(const QModelIndex &index, int role) const
         }
         break;
 
+    case AccountsListModel::ConnectionStateDisplayRole:
+        data = QVariant(m_accounts.at(index.row())->connectionStateString());
+        break;
+
+    case AccountsListModel::ConnectionStateIconRole:
+        data = QVariant(m_accounts.at(index.row())->connectionStateIcon());
+        break;
+
     default:
         break;
     }
diff --git a/src/accounts-list-model.h b/src/accounts-list-model.h
index 38deb93..98d4942 100644
--- a/src/accounts-list-model.h
+++ b/src/accounts-list-model.h
@@ -32,6 +32,12 @@ class AccountsListModel : public QAbstractListModel
     Q_OBJECT
     Q_DISABLE_COPY(AccountsListModel);
 
+    enum Roles {
+        ConnectionStateDisplayRole = Qt::UserRole+1,
+        ConnectionStateIconRole = Qt::UserRole+2,
+        ConnectionErrorMessageDisplayRole = Qt::UserRole+3
+    };
+
 public:
     explicit AccountsListModel(QObject *parent = 0);
     virtual ~AccountsListModel();

-- 
ktp-accounts-kcm packaging



More information about the pkg-kde-commits mailing list