[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=a294bbf

The following commit has been merged in the master branch:
commit a294bbf9317f2ea34b3c6143495d4108b8700e6e
Author: Aleix Pol <aleixpol at kde.org>
Date:   Fri Feb 8 02:12:30 2013 +0100

    Improve ContactsFilterModel for sorting
    
    Add a sortRoleString for sorting for a given role string.
    Also make sure that those will be applied by properly setting the
    dynamicSortFilter and calling sort(0).
    
    Reviewed by David Edmundson (who is very happy today)
---
 KTp/Declarative/contact-list.cpp     |  2 --
 KTp/Models/contacts-filter-model.cpp | 13 +++++++++++++
 KTp/Models/contacts-filter-model.h   |  6 ++++++
 3 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/KTp/Declarative/contact-list.cpp b/KTp/Declarative/contact-list.cpp
index 9e05d5c..58da5ab 100644
--- a/KTp/Declarative/contact-list.cpp
+++ b/KTp/Declarative/contact-list.cpp
@@ -70,8 +70,6 @@ ContactList::ContactList(QObject *parent)
                                                   channelFactory,
                                                   contactFactory);
 
-    m_filterModel->setDynamicSortFilter(true);
-
     connect(m_accountManager->becomeReady(),
             SIGNAL(finished(Tp::PendingOperation*)),
             SLOT(onAccountManagerReady(Tp::PendingOperation*)));
diff --git a/KTp/Models/contacts-filter-model.cpp b/KTp/Models/contacts-filter-model.cpp
index 3c88f37..f8ac2d0 100644
--- a/KTp/Models/contacts-filter-model.cpp
+++ b/KTp/Models/contacts-filter-model.cpp
@@ -408,6 +408,8 @@ ContactsFilterModel::ContactsFilterModel(QObject *parent)
     : QSortFilterProxyModel(parent),
       d(new Private(this))
 {
+    sort(0); //sort always
+    setDynamicSortFilter(true);
 }
 
 ContactsFilterModel::~ContactsFilterModel()
@@ -911,5 +913,16 @@ QModelIndexList ContactsFilterModel::match(const QModelIndex &start, int role,
     return result;
 }
 
+void ContactsFilterModel::setSortRoleString(const QString &role)
+{
+    Q_ASSERT(!roleNames().keys(role.toUtf8()).isEmpty());
+    setSortRole(roleNames().key(role.toUtf8()));
+}
+
+QString ContactsFilterModel::sortRoleString() const
+{
+    Q_ASSERT(roleNames().contains(sortRole()));
+    return QString::fromUtf8(roleNames().value(sortRole()));
+}
 
 #include "contacts-filter-model.moc"
diff --git a/KTp/Models/contacts-filter-model.h b/KTp/Models/contacts-filter-model.h
index fc9f663..e5a8c8f 100644
--- a/KTp/Models/contacts-filter-model.h
+++ b/KTp/Models/contacts-filter-model.h
@@ -132,6 +132,9 @@ class KTP_EXPORT ContactsFilterModel : public QSortFilterProxyModel
                RESET resetIdFilterMatchFlags
                WRITE setIdFilterMatchFlags
                NOTIFY idFilterMatchFlagsChanged)
+    Q_PROPERTY(QString sortRoleString
+               READ sortRoleString
+               WRITE setSortRoleString)
 
 public:
 
@@ -271,6 +274,9 @@ public:
     Q_SLOT void clearTubesFilterStrings();
     Q_SLOT void setTubesFilterStrings(const QStringList &tubesFilterStrings);
     Q_SIGNAL void tubesFilterStringsChanged(const QStringList &tubesFilterStrings);
+    
+    QString sortRoleString() const;
+    Q_SLOT void setSortRoleString(const QString &role);
 
 protected:
     bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;

-- 
ktp-common-internals packaging



More information about the pkg-kde-commits mailing list