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


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

The following commit has been merged in the master branch:
commit ecb7db228d20434816605770c921436c16fd73e0
Author: Martin Klapetek <mklapetek at kde.org>
Date:   Fri Feb 6 17:05:54 2015 +0100

    Move the static data to a shared place for better reuse
    
    Reviewed-by: David Edmundson
---
 KTp/Models/kpeopletranslationproxy.cpp             | 36 ++++++----------------
 KTp/types.h                                        | 17 ++++++++++
 .../datasourceplugin/im-persons-data-source.cpp    | 15 ---------
 3 files changed, 26 insertions(+), 42 deletions(-)

diff --git a/KTp/Models/kpeopletranslationproxy.cpp b/KTp/Models/kpeopletranslationproxy.cpp
index 1c0e4d0..d8a0395 100644
--- a/KTp/Models/kpeopletranslationproxy.cpp
+++ b/KTp/Models/kpeopletranslationproxy.cpp
@@ -61,9 +61,9 @@ QVariant KPeopleTranslationProxy::data(const QModelIndex &proxyIndex, int role)
 
     switch (role) {
         case KTp::ContactPresenceTypeRole:
-            return translatePresence(contact->customProperty(QStringLiteral("telepathy-presence")));
+            return s_presenceStrings.key(contact->customProperty(S_KPEOPLE_PROPERTY_PRESENCE).toString());
         case KTp::ContactPresenceIconRole:
-            return KPeople::iconNameForPresenceString(contact->customProperty(QStringLiteral("telepathy-presence")).toString());
+            return KPeople::iconNameForPresenceString(contact->customProperty(S_KPEOPLE_PROPERTY_PRESENCE).toString());
 //         case KTp::ContactPresenceNameRole:
 //             return sourceIndex.data(PersonsModel::PresenceDisplayRole);
         case Qt::DisplayRole:
@@ -85,7 +85,7 @@ QVariant KPeopleTranslationProxy::data(const QModelIndex &proxyIndex, int role)
         case KTp::ContactAvatarPixmapRole:
             return sourceIndex.data(KPeople::PersonsModel::PhotoRole);
         case KTp::IdRole:
-            return contact->customProperty(QStringLiteral("telepathy-contactId"));
+            return contact->customProperty(S_KPEOPLE_PROPERTY_CONTACT_ID);
 //         case KTp::HeaderTotalUsersRole:
 //             return sourceModel()->rowCount(sourceIndex);
         case KTp::ContactGroupsRole:
@@ -101,8 +101,8 @@ QVariant KPeopleTranslationProxy::data(const QModelIndex &proxyIndex, int role)
     int mostOnlineIndex = 0;
 
     for (int i = 0; i < contacts.size(); i++) {
-        if (KPeople::presenceSortPriority(contact->customProperty(QStringLiteral("telepathy-presence")).toString())
-            < KPeople::presenceSortPriority(contacts.at(mostOnlineIndex)->customProperty(QStringLiteral("telepathy-presence")).toString())) {
+        if (KPeople::presenceSortPriority(contact->customProperty(S_KPEOPLE_PROPERTY_PRESENCE).toString())
+            < KPeople::presenceSortPriority(contacts.at(mostOnlineIndex)->customProperty(S_KPEOPLE_PROPERTY_PRESENCE).toString())) {
 
             mostOnlineIndex = i;
         }
@@ -110,9 +110,9 @@ QVariant KPeopleTranslationProxy::data(const QModelIndex &proxyIndex, int role)
 
     QVariant rValue;
     AbstractContact::Ptr informationContact = contacts.isEmpty() ? contact : contacts.at(mostOnlineIndex);
-    rValue = dataForKTpContact(informationContact->customProperty(QStringLiteral("telepathy-accountPath")).toString(),
-                               informationContact->customProperty(QStringLiteral("telepathy-contactId")).toString(),
-                                 role);
+    rValue = dataForKTpContact(informationContact->customProperty(S_KPEOPLE_PROPERTY_ACCOUNT_PATH).toString(),
+                               informationContact->customProperty(S_KPEOPLE_PROPERTY_CONTACT_ID).toString(),
+                               role);
 
     if (rValue.isNull()) {
         return sourceIndex.data(role);
@@ -168,30 +168,12 @@ bool KPeopleTranslationProxy::filterAcceptsRow(int source_row, const QModelIndex
     QModelIndex sourceIndex = sourceModel()->index(source_row, 0, source_parent);
 
     //if no valid presence (not even "offline") .. reject the contact
-    return !sourceIndex.data(KPeople::PersonsModel::PersonVCardRole).value<KPeople::AbstractContact::Ptr>()->customProperty(QStringLiteral("telepathy-presence")).isNull();
+    return !sourceIndex.data(KPeople::PersonsModel::PersonVCardRole).value<KPeople::AbstractContact::Ptr>()->customProperty(S_KPEOPLE_PROPERTY_PRESENCE).isNull();
 }
 
 QVariant KPeopleTranslationProxy::translatePresence(const QVariant &presenceName) const
 {
-    if (presenceName == QLatin1String("available")) {
-        return Tp::ConnectionPresenceTypeAvailable;
-    }
-
-    if (presenceName == QLatin1String("away")) {
-        return Tp::ConnectionPresenceTypeAway;
-    }
-
-    if (presenceName == QLatin1String("busy") || presenceName == QLatin1String("dnd")) {
-        return Tp::ConnectionPresenceTypeBusy;
-    }
-
-    if (presenceName == QLatin1String("xa")) {
-        return Tp::ConnectionPresenceTypeExtendedAway;
-    }
 
-    if (presenceName == QLatin1String("hidden")) {
-        return Tp::ConnectionPresenceTypeHidden;
-    }
 
     return Tp::ConnectionPresenceTypeOffline;
 }
diff --git a/KTp/types.h b/KTp/types.h
index 63c2ded..d0e4fd6 100644
--- a/KTp/types.h
+++ b/KTp/types.h
@@ -91,6 +91,23 @@ namespace KTp
     };
 }
 
+static const QString S_KPEOPLE_PROPERTY_ACCOUNT_PATH = QString::fromLatin1("telepathy-accountPath");
+static const QString S_KPEOPLE_PROPERTY_CONTACT_ID = QString::fromLatin1("telepathy-contactId");
+static const QString S_KPEOPLE_PROPERTY_PRESENCE = QString::fromLatin1("telepathy-presence");
+static const QString S_KPEOPLE_PROPERTY_IS_BLOCKED = QString::fromLatin1("telepathy-isBlocked");
+
+const QHash<Tp::ConnectionPresenceType, QString> s_presenceStrings = {
+    { Tp::ConnectionPresenceTypeUnset, QString() },
+    { Tp::ConnectionPresenceTypeOffline, QString::fromLatin1("offline") },
+    { Tp::ConnectionPresenceTypeAvailable, QString::fromLatin1("available") },
+    { Tp::ConnectionPresenceTypeAway, QString::fromLatin1("away") },
+    { Tp::ConnectionPresenceTypeExtendedAway, QString::fromLatin1("xa") },
+    { Tp::ConnectionPresenceTypeHidden, QString::fromLatin1("hidden") }, //or 'offline' ?
+    { Tp::ConnectionPresenceTypeBusy, QString::fromLatin1("busy") },
+    { Tp::ConnectionPresenceTypeUnknown, QString::fromLatin1("unknown") },
+    { Tp::ConnectionPresenceTypeError, QString::fromLatin1("error") }
+};
+
 Q_DECLARE_METATYPE(Tp::AccountPtr)
 Q_DECLARE_METATYPE(KTp::ContactPtr)
 Q_DECLARE_METATYPE(Tp::AccountManagerPtr);
diff --git a/kpeople/datasourceplugin/im-persons-data-source.cpp b/kpeople/datasourceplugin/im-persons-data-source.cpp
index f0868b8..92032c7 100644
--- a/kpeople/datasourceplugin/im-persons-data-source.cpp
+++ b/kpeople/datasourceplugin/im-persons-data-source.cpp
@@ -67,21 +67,6 @@ private:
     QMap<QString, AbstractContact::Ptr> m_contactVCards;
 };
 
-static const QString S_KPEOPLE_PROPERTY_ACCOUNT_PATH = QString::fromLatin1("telepathy-accountPath");
-static const QString S_KPEOPLE_PROPERTY_CONTACT_ID = QString::fromLatin1("telepathy-contactId");
-static const QString S_KPEOPLE_PROPERTY_PRESENCE = QString::fromLatin1("telepathy-presence");
-const QHash<Tp::ConnectionPresenceType, QString> s_presenceStrings = {
-        { Tp::ConnectionPresenceTypeUnset, QString() },
-        { Tp::ConnectionPresenceTypeOffline, QString::fromLatin1("offline") },
-        { Tp::ConnectionPresenceTypeAvailable, QString::fromLatin1("available") },
-        { Tp::ConnectionPresenceTypeAway, QString::fromLatin1("away") },
-        { Tp::ConnectionPresenceTypeExtendedAway, QString::fromLatin1("xa") },
-        { Tp::ConnectionPresenceTypeHidden, QString::fromLatin1("hidden") }, //of 'offline' ?
-        { Tp::ConnectionPresenceTypeBusy, QString::fromLatin1("busy") },
-        { Tp::ConnectionPresenceTypeUnknown, QString::fromLatin1("unknown") },
-        { Tp::ConnectionPresenceTypeError, QString::fromLatin1("error") }
-};
-
 class TelepathyContact : public KPeople::AbstractContact
 {
 public:

-- 
ktp-common-internals packaging



More information about the pkg-kde-commits mailing list