]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Revert "Show hidden files and folders last"
authorNate Graham <nate@kde.org>
Fri, 6 Aug 2021 16:46:33 +0000 (10:46 -0600)
committerNate Graham <nate@kde.org>
Fri, 6 Aug 2021 16:46:33 +0000 (10:46 -0600)
This reverts commit 996e430b62075c5b69571f141456dbe5f2956679.

The accompanying feature to make the behavior configurable and disable
it by default was reverted in 21.08, so we need to revert the feature
itself as well and only ship it in 21.12, to avoid changing people's
setting back and forth, which is often not well-received.

src/kitemviews/kfileitemmodel.cpp
src/tests/kfileitemmodeltest.cpp

index e03ec7c0e9f2533a9d5e96a96fadbbb3955e9313..5b3c06d83cd2732aa076b8bb0848da5a78c3cb3a 100644 (file)
@@ -1733,15 +1733,6 @@ bool KFileItemModel::lessThan(const ItemData* a, const ItemData* b, const QColla
         }
     }
 
-    // Show hidden files and folders last
-    const bool isHiddenA = a->item.isHidden();
-    const bool isHiddenB = b->item.isHidden();
-    if (isHiddenA && !isHiddenB) {
-        return false;
-    } else if (!isHiddenA && isHiddenB) {
-        return true;
-    }
-
     if (m_sortDirsFirst || (DetailsModeSettings::directorySizeCount() && m_sortRole == SizeRole)) {
         const bool isDirA = a->item.isDir();
         const bool isDirB = b->item.isDir();
index f527fbc61b2043bd7d45bed1e44bbe7add949652..558a00ab592475fb2b30a6a295967d2913221943 100644 (file)
@@ -812,19 +812,6 @@ void KFileItemModelTest::testRemoveFilteredExpandedItems()
 
 void KFileItemModelTest::testSorting()
 {
-    // testDir structure is as follows
-    // ./
-    // ├─ a
-    // ├─ b
-    // ├─ c/
-    // │  ├─ c-2/
-    // │  │  ├─ c-3
-    // │  ├─ c-1
-    // ├─ d
-    // ├─ e
-    // ├─ .f
-    // ├─ .g/
-
     QSignalSpy itemsInsertedSpy(m_model, &KFileItemModel::itemsInserted);
     QSignalSpy itemsMovedSpy(m_model, &KFileItemModel::itemsMoved);
     QVERIFY(itemsMovedSpy.isValid());
@@ -849,27 +836,17 @@ void KFileItemModelTest::testSorting()
     m_testDir->createFile("d", "The largest file in this directory", now.addDays(-1));
     m_testDir->createFile("e", "An even larger file", now.addDays(-4));
     m_testDir->createFile(".f");
-    m_testDir->createDir(".g");
 
     m_model->loadDirectory(m_testDir->url());
     QVERIFY(itemsInsertedSpy.wait());
-    QCOMPARE(itemsInsertedSpy.count(), 1);
-    KItemRangeList itemRangeList = itemsInsertedSpy.takeFirst().at(0).value<KItemRangeList>();
-    QCOMPARE(itemRangeList, KItemRangeList() << KItemRange(0, 5));
 
     int index = m_model->index(QUrl(m_testDir->url().url() + "/c"));
     m_model->setExpanded(index, true);
     QVERIFY(itemsInsertedSpy.wait());
-    QCOMPARE(itemsInsertedSpy.count(), 1);
-    itemRangeList = itemsInsertedSpy.takeFirst().at(0).value<KItemRangeList>();
-    QCOMPARE(itemRangeList, KItemRangeList() << KItemRange(1, 2));
 
     index = m_model->index(QUrl(m_testDir->url().url() + "/c/c-2"));
     m_model->setExpanded(index, true);
     QVERIFY(itemsInsertedSpy.wait());
-    QCOMPARE(itemsInsertedSpy.count(), 1);
-    itemRangeList = itemsInsertedSpy.takeFirst().at(0).value<KItemRangeList>();
-    QCOMPARE(itemRangeList, KItemRangeList() << KItemRange(2, 1));
 
     // Default: Sort by Name, ascending
     QCOMPARE(m_model->sortRole(), QByteArray("text"));
@@ -965,36 +942,7 @@ void KFileItemModelTest::testSorting()
     QCOMPARE(itemsMovedSpy.first().at(0).value<KItemRange>(), KItemRange(4, 4));
     QCOMPARE(itemsMovedSpy.takeFirst().at(1).value<QList<int> >(), QList<int>() << 7 << 6 << 5 << 4);
 
-    // 'Show Hidden Files' enabled
-    m_model->setShowHiddenFiles(true);
-    QVERIFY(m_model->showHiddenFiles());
-    QCOMPARE(itemsInModel(), QStringList() << "c" << "c-2" << "c-3" << "c-1" << "d" << "e" << "b" << "a" << ".g" << ".f");
-    QCOMPARE(itemsMovedSpy.count(), 0);
-    QCOMPARE(itemsInsertedSpy.count(), 1);
-    QCOMPARE(itemsInsertedSpy.takeFirst().at(0).value<KItemRangeList>(), KItemRangeList() << KItemRange(8, 2));
-
-    // Sort by Name
-    m_model->setSortRole("text");
-    QCOMPARE(itemsInModel(), QStringList() << "c" << "c-2" << "c-3" << "c-1" << "e" << "d" << "b" << "a" << ".g" << ".f");
-    QCOMPARE(itemsMovedSpy.count(), 1);
-    QCOMPARE(itemsMovedSpy.first().at(0).value<KItemRange>(), KItemRange(4, 2));
-    QCOMPARE(itemsMovedSpy.takeFirst().at(1).value<QList<int> >(), QList<int>() << 5 << 4);
-
-    // Sort ascending
-    m_model->setSortOrder(Qt::AscendingOrder);
-    QCOMPARE(itemsInModel(), QStringList() << "c" << "c-2" << "c-3" << "c-1" << "a" << "b" << "d" << "e" << ".g" << ".f");
-    QCOMPARE(itemsMovedSpy.count(), 1);
-    QCOMPARE(itemsMovedSpy.first().at(0).value<KItemRange>(), KItemRange(4, 4));
-    QCOMPARE(itemsMovedSpy.takeFirst().at(1).value<QList<int> >(), QList<int>() << 7 << 6 << 5 << 4);
-
-    // 'Sort Folders First' disabled
-    m_model->setSortDirectoriesFirst(false);
-    QVERIFY(!m_model->sortDirectoriesFirst());
-    QCOMPARE(itemsInModel(), QStringList() << "a" << "b" << "c" << "c-1" << "c-2" << "c-3" << "d" << "e" << ".f" << ".g");
-    QCOMPARE(itemsMovedSpy.count(), 1);
-    QCOMPARE(itemsMovedSpy.first().at(0).value<KItemRange>(), KItemRange(0, 10));
-    QCOMPARE(itemsMovedSpy.takeFirst().at(1).value<QList<int> >(), QList<int>() << 2 << 4 << 5 << 3 << 0 << 1 << 6 << 7 << 9 << 8);
-
+    // TODO: Sort by other roles; show/hide hidden files
 }
 
 void KFileItemModelTest::testIndexForKeyboardSearch()
@@ -1151,7 +1099,7 @@ void KFileItemModelTest::testRemoveHiddenItems()
     m_model->setShowHiddenFiles(true);
     m_model->loadDirectory(m_testDir->url());
     QVERIFY(itemsInsertedSpy.wait());
-    QCOMPARE(itemsInModel(), QStringList() << "c" << "d" << "h" << "i" << ".a" << ".b" <<".f" << ".g");
+    QCOMPARE(itemsInModel(), QStringList() << ".a" << ".b" << "c" << "d" <<".f" << ".g" << "h" << "i");
     QCOMPARE(itemsInsertedSpy.count(), 1);
     QCOMPARE(itemsRemovedSpy.count(), 0);
     KItemRangeList itemRangeList = itemsInsertedSpy.takeFirst().at(0).value<KItemRangeList>();
@@ -1162,14 +1110,14 @@ void KFileItemModelTest::testRemoveHiddenItems()
     QCOMPARE(itemsInsertedSpy.count(), 0);
     QCOMPARE(itemsRemovedSpy.count(), 1);
     itemRangeList = itemsRemovedSpy.takeFirst().at(0).value<KItemRangeList>();
-    QCOMPARE(itemRangeList, KItemRangeList() << KItemRange(4, 4));
+    QCOMPARE(itemRangeList, KItemRangeList() << KItemRange(0, 2) << KItemRange(4, 2));
 
     m_model->setShowHiddenFiles(true);
-    QCOMPARE(itemsInModel(), QStringList() << "c" << "d" << "h" << "i" << ".a" << ".b" <<".f" << ".g");
+    QCOMPARE(itemsInModel(), QStringList() << ".a" << ".b" << "c" << "d" <<".f" << ".g" << "h" << "i");
     QCOMPARE(itemsInsertedSpy.count(), 1);
     QCOMPARE(itemsRemovedSpy.count(), 0);
     itemRangeList = itemsInsertedSpy.takeFirst().at(0).value<KItemRangeList>();
-    QCOMPARE(itemRangeList, KItemRangeList() << KItemRange(4, 4));
+    QCOMPARE(itemRangeList, KItemRangeList() << KItemRange(0, 2) << KItemRange(2, 2));
 
     m_model->clear();
     QCOMPARE(itemsInModel(), QStringList());