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


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

The following commit has been merged in the master branch:
commit 1be2526bfc18254fdd335645bfcf236efcc83ae8
Author: David Edmundson <kde at davidedmundson.co.uk>
Date:   Mon Feb 17 13:19:28 2014 +0100

    Add a workaround for broken sorting
    
    There is a bug in QSortFilterProxyModel in which if sort() is called
    on a model where all items are filtered out it will not start sorting
    as it cannot map the proxy column to the source column.
    
    This gets updated whenever there's an insertRows but not from
    a dataChanged.
    
    With the kpeople cache we load all items, but
    none make it through the filter as everyone is assumed to be
    offline whilst we query telepathy over DBus. When we get data
    from Tp we will only ever call dataChanged() not insertRows()
    so we hit the Qt bug.
    
    This bug is fixed in Qt 5.2.1, but not in 4.x
    
    REVIEW:115828
    
    BUG:327008
    FIXED-IN: 0.8.0
    
    DIGEST: Please do not put this in the commit log. No-one should see
    how horrible this is.
---
 KTp/Models/contacts-filter-model.cpp | 47 ++++++++++++++++++++++++++++++++----
 KTp/Models/contacts-filter-model.h   |  2 ++
 2 files changed, 44 insertions(+), 5 deletions(-)

diff --git a/KTp/Models/contacts-filter-model.cpp b/KTp/Models/contacts-filter-model.cpp
index df12112..617d3aa 100644
--- a/KTp/Models/contacts-filter-model.cpp
+++ b/KTp/Models/contacts-filter-model.cpp
@@ -43,7 +43,8 @@ public:
           nicknameFilterMatchFlags(Qt::MatchContains),
           aliasFilterMatchFlags(Qt::MatchContains),
           groupsFilterMatchFlags(Qt::MatchContains),
-          idFilterMatchFlags(Qt::MatchContains)
+          idFilterMatchFlags(Qt::MatchContains),
+          m_qtSortHack(false)
     {
     }
 
@@ -80,6 +81,7 @@ public:
 
     QHash<QString, int> m_onlineContactsCounts;
     QHash<QString, int> m_totalContactsCounts;
+    bool m_qtSortHack;
 };
 
 using namespace KTp;
@@ -834,21 +836,56 @@ bool ContactsFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &sou
 {
     QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
 
+    bool rc;
     int type = index.data(KTp::RowTypeRole).toInt();
     if (type == KTp::ContactRowType || type == KTp::PersonRowType) {
-        return d->filterAcceptsContact(index);
+        rc = d->filterAcceptsContact(index);
     }
     else if (type == KTp::AccountRowType) {
-        return d->filterAcceptsAccount(index);
+        rc = d->filterAcceptsAccount(index);
     }
     else if (type == KTp::GroupRowType) {
-        return d->filterAcceptsGroup(index);
+        rc = d->filterAcceptsGroup(index);
     }
     else {
         kDebug() << "Unknown type found in Account Filter";
-        return true;
+        rc = true;
+    }
+
+    //START HORRENDOUS HACK
+    //remove in 5.2.1 +
+
+    //This is a horrendous hack around https://bugreports.qt-project.org/browse/QTBUG-30662
+    //if sort is enabled and nothing passes the filter
+    //the proxy model is unable to map the proxy column to the source model if all items are filtered
+    //this patch causes it to call sort after the first items is added
+
+    //calling sort whilst we are currently filtering seems unsafe, so we do this on a delay
+    //we need to const cast to emit a signal, but that should be safe
+    if (!d->m_qtSortHack && rc && !sourceParent.isValid()) {
+        KTp::ContactsFilterModel *nonConstThis = const_cast<KTp::ContactsFilterModel*>(this);
+        QTimer::singleShot(0, nonConstThis, SLOT(delayedSortFix()));
+        d->m_qtSortHack = true;
     }
+    //END HORRENDOUS HACK
+
+
+    return rc;
+}
+
+//START HORRENDOUS HACK
+//remove in 5.2.1 +
+void ContactsFilterModel::delayedSortFix()
+{
+    //we need to sort twice
+    //calling sort(0) will do nothing as the QSortFilterProxyModel::proxy_sort_column is already 0
+    //we need to change it to update the QSortFilterProxyModel::source_sort_column
+    sort(-1);
+    sort(0);
 }
+//END HORRENDOUS HACK
+
+
 
 bool ContactsFilterModel::lessThan(const QModelIndex &left, const QModelIndex &right) const
 {
diff --git a/KTp/Models/contacts-filter-model.h b/KTp/Models/contacts-filter-model.h
index a891d6b..bccc6f6 100644
--- a/KTp/Models/contacts-filter-model.h
+++ b/KTp/Models/contacts-filter-model.h
@@ -291,6 +291,8 @@ public:
     QString sortRoleString() const;
     Q_SLOT void setSortRoleString(const QString &role);
 
+    Q_SLOT void delayedSortFix();
+
 protected:
     bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
     bool lessThan (const QModelIndex &left, const QModelIndex &right) const;

-- 
ktp-common-internals packaging



More information about the pkg-kde-commits mailing list