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


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

The following commit has been merged in the master branch:
commit d79b3645d2cc95680aa433053e89cc0a33712627
Author: George Goldberg <grundleborg at googlemail.com>
Date:   Fri Jul 24 18:50:59 2009 +0000

    Improve the appearance of the Accounts List view.
    - Add a checkbox to enable/disable accounts.
    - Show their icon in the view.
    - Update the item in the view when its display name or state change.
    
    Thanks to Matteo Nardi for the patch.
    
    svn path=/trunk/playground/network/telepathy-accounts-kcm/; revision=1002001
---
 src/account-item.cpp        |  6 +++++
 src/accounts-list-model.cpp | 61 ++++++++++++++++++++++++++++++++++++---------
 src/accounts-list-model.h   |  2 ++
 src/main-widget.ui          |  9 ++++++-
 4 files changed, 65 insertions(+), 13 deletions(-)

diff --git a/src/account-item.cpp b/src/account-item.cpp
index 7a914da..ee3ba69 100644
--- a/src/account-item.cpp
+++ b/src/account-item.cpp
@@ -71,6 +71,12 @@ void AccountItem::onAccountReady(Tp::PendingOperation *op)
         return;
     }
 
+    connect(m_account.data(),
+            SIGNAL(stateChanged(bool)),
+            SIGNAL(updated()));
+    connect(m_account.data(),
+            SIGNAL(displayNameChanged(const QString&)),
+            SIGNAL(updated()));
     Q_EMIT ready();
 }
 
diff --git a/src/accounts-list-model.cpp b/src/accounts-list-model.cpp
index 7b7d8db..92c1b12 100644
--- a/src/accounts-list-model.cpp
+++ b/src/accounts-list-model.cpp
@@ -24,6 +24,7 @@
 
 #include <KCategorizedSortFilterProxyModel>
 #include <KDebug>
+#include <KIcon>
 
 #include <TelepathyQt4/Account>
 
@@ -57,35 +58,47 @@ int AccountsListModel::rowCount(const QModelIndex &index) const
 
 QVariant AccountsListModel::data(const QModelIndex &index, int role) const
 {
-    // FIXME: This is a basic implementation just so I can see what's going
-    // on while developing this code further. Needs expanding.
     QVariant data;
+    Tp::AccountPtr account = m_readyAccounts.at(index.row())->account();
 
     switch(role)
     {
     case Qt::DisplayRole:
-        data = QVariant(m_readyAccounts.at(index.row())->account()->displayName());
+        data = QVariant(account->displayName());
         break;
+
+    case Qt::DecorationRole:
+        //FIXME: we need to move kopete protocol icons to oxygen..
+        data = QVariant(KIcon(account->icon()));
+        break;
+
+    case Qt::CheckStateRole:
+        if(account->isEnabled()) {
+            data = QVariant(Qt::Checked);
+        }
+        else {
+            data = QVariant(Qt::Unchecked);
+        }
+        break;
+
     case KCategorizedSortFilterProxyModel::CategoryDisplayRole:
-        if(m_readyAccounts.at(index.row())->account()->isValidAccount())
-        {
+        if(account->isValidAccount()) {
             data = QVariant(QString("Valid Accounts"));
         }
-        else
-        {
+        else {
             data = QVariant(QString("Invalid Accounts"));
         }
         break;
+
     case KCategorizedSortFilterProxyModel::CategorySortRole:
-        if(m_readyAccounts.at(index.row())->account()->isValidAccount())
-        {
+        if(account->isValidAccount()) {
             data = QVariant(4);
         }
-        else
-        {
+        else {
             data = QVariant(5);
         }
         break;
+
     default:
         break;
     }
@@ -93,6 +106,21 @@ QVariant AccountsListModel::data(const QModelIndex &index, int role) const
     return data;
 }
 
+bool AccountsListModel::setData(const QModelIndex &index, const QVariant &value, int role)
+{
+    kDebug();
+    if(role == Qt::CheckStateRole) {
+        m_readyAccounts.at(index.row())->account()->setEnabled(value.toInt() == Qt::Checked);
+        return true;
+    }
+    return false;
+}
+
+Qt::ItemFlags AccountsListModel::flags(const QModelIndex &index) const
+{
+    return QAbstractItemModel::flags(index) | Qt::ItemIsUserCheckable;
+}
+
 void AccountsListModel::addAccount(const Tp::AccountPtr &account)
 {
     kDebug() << "Creating a new AccountItem from account:" << account.data();
@@ -194,8 +222,17 @@ void AccountsListModel::onAccountItemRemoved()
 void AccountsListModel::onAccountItemUpdated()
 {
     kDebug();
+    
+    AccountItem *item = qobject_cast<AccountItem*>(sender());
 
-    // TODO: Implement me!
+    Q_ASSERT(item);
+    if (!item) {
+        kWarning() << "Not an AccountItem pointer:" << sender();
+        return;
+    }
+
+    QModelIndex index = createIndex(m_readyAccounts.lastIndexOf(item), 0);
+    emit dataChanged(index, index);
 }
 
 
diff --git a/src/accounts-list-model.h b/src/accounts-list-model.h
index cdffda8..02fd381 100644
--- a/src/accounts-list-model.h
+++ b/src/accounts-list-model.h
@@ -37,6 +37,8 @@ public:
     virtual ~AccountsListModel();
     virtual int rowCount(const QModelIndex &index) const;
     virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
+    virtual Qt::ItemFlags flags(const QModelIndex &index) const;
+    virtual bool setData(const QModelIndex &index, const QVariant &value, int role);
     void addAccount(const Tp::AccountPtr &account);
 
 private Q_SLOTS:
diff --git a/src/main-widget.ui b/src/main-widget.ui
index ead6304..33017dd 100644
--- a/src/main-widget.ui
+++ b/src/main-widget.ui
@@ -14,7 +14,14 @@
    <item>
     <layout class="QHBoxLayout" name="horizontalLayout">
      <item>
-      <widget class="KCategorizedView" name="m_accountsListView"/>
+      <widget class="KCategorizedView" name="m_accountsListView">
+       <property name="iconSize">
+        <size>
+         <width>32</width>
+         <height>32</height>
+        </size>
+       </property>
+      </widget>
      </item>
      <item>
       <layout class="QVBoxLayout" name="verticalLayout_2">

-- 
ktp-accounts-kcm packaging



More information about the pkg-kde-commits mailing list