[SCM] ktp-common-internals packaging branch, master, updated. debian/15.12.1-2-1839-gf0635e9

Maximiliano Curia maxy at moszumanska.debian.org
Mon May 9 09:06:22 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-common-internals.git;a=commitdiff;h=4bbe081

The following commit has been merged in the master branch:
commit 4bbe08171e1e7e466fee10d1395acf4fcd57532b
Author: David Edmundson <kde at davidedmundson.co.uk>
Date:   Thu Feb 7 11:11:26 2013 +0000

    Simplify ContactsFilterModel
---
 KTp/Models/accounts-tree-proxy-model.cpp |  6 ++++
 KTp/Models/contacts-filter-model.cpp     | 59 +++++---------------------------
 2 files changed, 15 insertions(+), 50 deletions(-)

diff --git a/KTp/Models/accounts-tree-proxy-model.cpp b/KTp/Models/accounts-tree-proxy-model.cpp
index acc803e..fa61e2f 100644
--- a/KTp/Models/accounts-tree-proxy-model.cpp
+++ b/KTp/Models/accounts-tree-proxy-model.cpp
@@ -80,6 +80,12 @@ QVariant KTp::AccountsTreeProxyModel::dataForGroup(const QString &group, int rol
         return QVariant::fromValue(d->accountManager->accountForObjectPath(group));
     case KTp::RowTypeRole:
         return KTp::AccountRowType;
+    case KTp::IdRole:
+        account = d->accountManager->accountForObjectPath(group);
+        if (account) {
+            return account->uniqueIdentifier();
+        }
+        break;
     }
 
     return QVariant();
diff --git a/KTp/Models/contacts-filter-model.cpp b/KTp/Models/contacts-filter-model.cpp
index 343f4fa..f0372b4 100644
--- a/KTp/Models/contacts-filter-model.cpp
+++ b/KTp/Models/contacts-filter-model.cpp
@@ -350,20 +350,7 @@ bool ContactsFilterModel::Private::filterAcceptsGroup(const QModelIndex &index)
 
 void ContactsFilterModel::Private::countContacts(const QModelIndex &sourceParent)
 {
-    QString key;
-
-    KTp::RowType rowType = static_cast<KTp::RowType>(sourceParent.data(KTp::RowTypeRole).toInt());
-    if (rowType == KTp::GroupRowType) {
-        key = sourceParent.data(Qt::DisplayRole).toString();
-    } else if (rowType == KTp::AccountRowType) {
-        Tp::AccountPtr account = sourceParent.data(KTp::AccountRole).value<Tp::AccountPtr>();
-        if (account.isNull()) {
-            return;
-        }
-        key = account->uniqueIdentifier();
-    } else {
-        return;
-    }
+    QString key = sourceParent.data(KTp::IdRole).toString();
 
     // Count the online contacts
     int tmpCounter = 0;
@@ -439,46 +426,18 @@ QVariant ContactsFilterModel::data(const QModelIndex &index, int role) const
         return QVariant();
     }
 
-    // Special handling for the counts
-    KTp::RowType rowType = static_cast<KTp::RowType>(sourceIndex.data(KTp::RowTypeRole).toInt());
     if (role == KTp::HeaderOnlineUsersRole) {
-        if (rowType == KTp::GroupRowType) {
-            const QString groupName = sourceIndex.data(Qt::DisplayRole).toString();
-            // If there is no cached value, create one
-            if (!d->m_onlineContactsCounts.contains(groupName)) {
-                d->countContacts(sourceIndex);
-            }
-            return d->m_onlineContactsCounts.value(groupName);
-        } else if (rowType == KTp::AccountRowType) {
-            const Tp::AccountPtr account = sourceIndex.data(KTp::AccountRole).value<Tp::AccountPtr>();
-            if (account.isNull()) {
-                return 0;
-            }
-            // If there is no cached value, create one
-            if (!d->m_onlineContactsCounts.contains(account->uniqueIdentifier())) {
-                d->countContacts(sourceIndex);
-            }
-            return d->m_onlineContactsCounts.value(account->uniqueIdentifier());
+        const QString &key = sourceIndex.data(KTp::IdRole).toString();
+        if (!d->m_onlineContactsCounts.contains(key)) {
+            d->countContacts(sourceIndex);
         }
+        return d->m_onlineContactsCounts.value(key);
     } else if (role == KTp::HeaderTotalUsersRole) {
-        if (rowType == KTp::GroupRowType) {
-            const QString groupName = sourceIndex.data(Qt::DisplayRole).toString();
-            // If there is no cached value, create one
-            if (!d->m_totalContactsCounts.contains(groupName)) {
-                d->countContacts(sourceIndex);
-            }
-            return d->m_totalContactsCounts.value(groupName);
-        } else if (rowType == KTp::AccountRowType) {
-            const Tp::AccountPtr account = sourceIndex.data(KTp::AccountRole).value<Tp::AccountPtr>();
-            if (account.isNull()) {
-                return 0;
-            }
-            // If there is no cached value, create one
-            if (!d->m_totalContactsCounts.contains(account->uniqueIdentifier())) {
-                d->countContacts(sourceIndex);
-            }
-            return d->m_totalContactsCounts.value(account->uniqueIdentifier());
+        const QString &key = sourceIndex.data(KTp::IdRole).toString();
+        if (!d->m_totalContactsCounts.contains(key)) {
+            d->countContacts(sourceIndex);
         }
+        return d->m_totalContactsCounts.value(key);
     }
 
     // In all other cases just delegate it to the source model

-- 
ktp-common-internals packaging



More information about the pkg-kde-commits mailing list