┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2011-11-30 00:18:22 +0100
committerPeter Penz <[email protected]>2011-11-30 00:24:33 +0100
commit7b8fbf737496e44e7676a437f000377d737dfd9c (patch)
tree5b64891095993e59b268e04dc44db77ded1fd030 /src/tests
parent3719ce7d2a7f4ee6a0585763139eea8f7786630c (diff)
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
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/kfileitemmodeltest.cpp30
1 files changed, 30 insertions, 0 deletions
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) {