From e2a688651cc5fb3cca682c4153866609713e76a9 Mon Sep 17 00:00:00 2001 From: David Faure Date: Tue, 12 Jul 2016 09:39:31 +0200 Subject: [PATCH] KRecursiveFilterProxyModel: fix QSFPM corruption due to filtering out rowsRemoved signal If the row being removed from the source model isn't shown by KRFPM, it's correct that we don't need to emit any signals, however we still need to tell our base class QSFPM so that it updates the mappings of the visible siblings below that removed row. Testcase: deleting the Last Search folder in kmail (full integration test for this testcase will be added to mailcommon). REVIEW: 128428 BUG: 349789 FIXED-IN: 5.25 --- autotests/krecursivefilterproxymodeltest.cpp | 4 +++- src/krecursivefilterproxymodel.cpp | 20 -------------------- 2 files changed, 3 insertions(+), 21 deletions(-) diff --git a/autotests/krecursivefilterproxymodeltest.cpp b/autotests/krecursivefilterproxymodeltest.cpp index 85dbdfa..69edac5 100644 --- a/autotests/krecursivefilterproxymodeltest.cpp +++ b/autotests/krecursivefilterproxymodeltest.cpp @@ -551,9 +551,11 @@ private Q_SLOTS: const QStringList remove1_1_1 = (QStringList() << QStringLiteral("rowsAboutToBeRemoved(1.1.1)") << QStringLiteral("rowsRemoved(1.1.1)")); - QTest::newRow("toplevel") << "[1*]" << "[1*]" << "1" << "" + QTest::newRow("toplevel") << "[1* 2* 3*]" << "[1* 2* 3*]" << "1" << "[2* 3*]" << (QStringList() << QStringLiteral("rowsAboutToBeRemoved(1)") << QStringLiteral("rowsRemoved(1)")); + QTest::newRow("remove_hidden") << "[1 2* 3*]" << "[2* 3*]" << "1" << "[2* 3*]" << QStringList(); + QTest::newRow("parent_hidden") << "[1[1.1[1.1.1]]]" << "" << "1.1.1" << "" << QStringList(); QTest::newRow("child_hidden") << "[1[1.1*[1.1.1]]]" << "[1[1.1*]]" << "1.1.1" << "[1[1.1*]]" << QStringList(); diff --git a/src/krecursivefilterproxymodel.cpp b/src/krecursivefilterproxymodel.cpp index 10632ec..f6ae609 100644 --- a/src/krecursivefilterproxymodel.cpp +++ b/src/krecursivefilterproxymodel.cpp @@ -230,21 +230,6 @@ void KRecursiveFilterProxyModelPrivate::sourceRowsInserted(const QModelIndex &so void KRecursiveFilterProxyModelPrivate::sourceRowsAboutToBeRemoved(const QModelIndex &source_parent, int start, int end) { - Q_Q(KRecursiveFilterProxyModel); - - bool accepted = false; - for (int row = start; row <= end; ++row) { - if (q->filterAcceptsRow(row, source_parent)) { - accepted = true; - break; - } - } - if (!accepted) { - // All removed rows are already filtered out. We don't care about the signal. - ignoreRemove = true; - return; - } - invokeRowsAboutToBeRemoved(source_parent, start, end); } @@ -252,11 +237,6 @@ void KRecursiveFilterProxyModelPrivate::sourceRowsRemoved(const QModelIndex &sou { Q_Q(KRecursiveFilterProxyModel); - if (ignoreRemove) { - ignoreRemove = false; - return; - } - invokeRowsRemoved(source_parent, start, end); // Find out if removing this visible row means that some ascendant