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
wilder
David Faure 10 years ago
parent e040853e82
commit e2a688651c
  1. 4
      autotests/krecursivefilterproxymodeltest.cpp
  2. 20
      src/krecursivefilterproxymodel.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();

@ -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

Loading…
Cancel
Save