From 3950eccaf08374862ba848eac5319645d6a0f0d9 Mon Sep 17 00:00:00 2001 From: Frank Reininghaus Date: Thu, 24 Nov 2011 23:38:36 +0100 Subject: Fix restoring expanded URLs When navigating back or forward in history, DolphinView tells the KFileItemModel about the expanded URLs which should be restored before the folder is entered. In this case, the algorithm in the new function KFileItemModel::setExpanded(const QSet&) does not work. To fix this, the old function KFileItemModel::restoreExpandedUrls(const QSet&) is restored. Unit test included. --- src/tests/kfileitemmodeltest.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/tests/kfileitemmodeltest.cpp') diff --git a/src/tests/kfileitemmodeltest.cpp b/src/tests/kfileitemmodeltest.cpp index f2d62fbad..59e817fff 100644 --- a/src/tests/kfileitemmodeltest.cpp +++ b/src/tests/kfileitemmodeltest.cpp @@ -451,7 +451,7 @@ void KFileItemModelTest::testExpandItems() QVERIFY(m_model->expandedUrls().empty()); m_dirLister->openUrl(m_testDir->url()); - m_model->setExpanded(allFolders); + m_model->restoreExpandedUrls(allFolders); QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(loadingCompleted()), DefaultTimeout)); QCOMPARE(m_model->count(), 5); // 5 items: "a/", "a/a/", "a/a/1", "a/a-1/", "a/a-1/1" QVERIFY(m_model->isExpanded(0)); @@ -460,6 +460,17 @@ void KFileItemModelTest::testExpandItems() QVERIFY(m_model->isExpanded(3)); QVERIFY(!m_model->isExpanded(4)); QCOMPARE(m_model->expandedUrls(), allFolders); + + // Move to a sub folder, then call restoreExpandedFolders() *before* going back. + // This is how DolphinView restores the expanded folders when navigating in history. + m_dirLister->openUrl(KUrl(m_testDir->name() + "a/a/")); + QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(loadingCompleted()), DefaultTimeout)); + QCOMPARE(m_model->count(), 1); // 1 item: "1" + m_model->restoreExpandedUrls(allFolders); + m_dirLister->openUrl(m_testDir->url()); + QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(loadingCompleted()), DefaultTimeout)); + QCOMPARE(m_model->count(), 5); // 5 items: "a/", "a/a/", "a/a/1", "a/a-1/", "a/a-1/1" + QCOMPARE(m_model->expandedUrls(), allFolders); } void KFileItemModelTest::testSorting() -- cgit v1.3