From 7b8fbf737496e44e7676a437f000377d737dfd9c Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Wed, 30 Nov 2011 00:18:22 +0100 Subject: Reimplement name-filtering The filtering of items has not been implemented yet in the KFileItemModel of the new view-engine. The patch brings back this functionality again, but some minor issues are open: - When filtering trees expanded directories should only get hidden if no child is visible - Regular expressions are not supported yet (they have not been supported in Dolphin 1.x but it is now quite simple to implement). - When filtering previews and removing the filter it might be possible that the preview is not shown (is most probably an an already existing bug in KFileItemModelRolesUpdater). BUG: 287642 FIXED-IN: 4.8.0 --- src/tests/kfileitemmodeltest.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'src/tests') diff --git a/src/tests/kfileitemmodeltest.cpp b/src/tests/kfileitemmodeltest.cpp index 59e817fff..23b899136 100644 --- a/src/tests/kfileitemmodeltest.cpp +++ b/src/tests/kfileitemmodeltest.cpp @@ -75,6 +75,8 @@ private slots: void testIndexForKeyboardSearch(); + void testNameFilter(); + private: bool isModelConsistent() const; QStringList itemsInModel() const; @@ -643,6 +645,34 @@ void KFileItemModelTest::testIndexForKeyboardSearch() // TODO: Maybe we should also test keyboard searches in directories which are not sorted by Name? } +void KFileItemModelTest::testNameFilter() +{ + QStringList files; + files << "A1" << "A2" << "Abc" << "Bcd" << "Cde"; + m_testDir->createFiles(files); + + m_dirLister->openUrl(m_testDir->url()); + QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + + m_model->setNameFilter("A"); // Shows A1, A2 and Abc + QCOMPARE(m_model->count(), 3); + + m_model->setNameFilter("A2"); // Shows only A2 + QCOMPARE(m_model->count(), 1); + + m_model->setNameFilter("A2"); // Shows only A1 + QCOMPARE(m_model->count(), 1); + + m_model->setNameFilter("Bc"); // Shows "Abc" and "Bcd" + QCOMPARE(m_model->count(), 2); + + m_model->setNameFilter("bC"); // Shows "Abc" and "Bcd" + QCOMPARE(m_model->count(), 2); + + m_model->setNameFilter(QString()); // Shows again all items + QCOMPARE(m_model->count(), 5); +} + bool KFileItemModelTest::isModelConsistent() const { for (int i = 0; i < m_model->count(); ++i) { -- cgit v1.3