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


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

The following commit has been merged in the master branch:
commit ef3b98f0aa1a0007866fd8c3eda5f72519c37b61
Author: Alexandr Akulich <akulichalexander at gmail.com>
Date:   Thu Apr 10 13:10:14 2014 +0200

    KPeople plugin: Implemented groups cache support.
    
    REVIEW: 116706
    BUG: 331272
---
 .../datasourceplugin/im-persons-data-source.cpp    | 31 ++++++++++++++++++----
 1 file changed, 26 insertions(+), 5 deletions(-)

diff --git a/kpeople/datasourceplugin/im-persons-data-source.cpp b/kpeople/datasourceplugin/im-persons-data-source.cpp
index e1261ab..234ae10 100644
--- a/kpeople/datasourceplugin/im-persons-data-source.cpp
+++ b/kpeople/datasourceplugin/im-persons-data-source.cpp
@@ -86,11 +86,18 @@ void KTpAllContacts::loadCache()
     db.setDatabaseName(KGlobal::dirs()->locateLocal("data", QLatin1String("ktp/cache.db")));
     db.open();
 
-    QSqlQuery query(QLatin1String("SELECT accountId, contactId, alias, avatarFileName FROM contacts"), db);
+    QSqlQuery query(db);
+    query.exec(QLatin1String("SELECT groupName FROM groups ORDER BY groupId;"));
 
-    if (!query.exec()) {
-        emitInitialFetchComplete(false);
-        return;
+    QStringList groupsList;
+    while (query.next()) {
+        groupsList.append(query.value(0).toString());
+    }
+
+    if (!groupsList.isEmpty()) {
+        query.exec(QLatin1String("SELECT accountId, contactId, alias, avatarFileName, groupsIds FROM contacts;"));
+    } else {
+        query.exec(QLatin1String("SELECT accountId, contactId, alias, avatarFileName FROM contacts;"));
     }
 
     while (query.next()) {
@@ -101,6 +108,21 @@ void KTpAllContacts::loadCache()
         addressee.setFormattedName(query.value(2).toString());
         addressee.setPhoto(KABC::Picture(query.value(3).toString()));
 
+        if (!groupsList.isEmpty()) {
+            QStringList contactGroups;
+
+            Q_FOREACH (const QString &groupIdStr, query.value(4).toString().split(QLatin1String(","))) {
+                bool convSuccess;
+                int groupId = groupIdStr.toInt(&convSuccess);
+                if ((!convSuccess) || (groupId >= groupsList.count()))
+                    continue;
+
+                contactGroups.append(groupsList.at(groupId));
+            }
+
+            addressee.setCategories(contactGroups);
+        }
+
         addressee.insertCustom(QLatin1String("telepathy"), QLatin1String("contactId"), contactId);
         addressee.insertCustom(QLatin1String("telepathy"), QLatin1String("accountPath"), accountId);
         addressee.insertCustom(QLatin1String("telepathy"), QLatin1String("presence"), QLatin1String("offline"));
@@ -118,7 +140,6 @@ void KTpAllContacts::loadCache()
     emitInitialFetchComplete(true);
 }
 
-
 QString KTpAllContacts::createUri(const KTp::ContactPtr &contact) const
 {
     // so real ID will look like

-- 
ktp-common-internals packaging



More information about the pkg-kde-commits mailing list