mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-17 15:31:20 +00:00
Disable Hidden Files Last sort by default
This commit is contained in:
parent
50149d6abb
commit
fd2203bb39
|
@ -34,7 +34,7 @@ KFileItemModel::KFileItemModel(QObject* parent) :
|
||||||
KItemModelBase("text", parent),
|
KItemModelBase("text", parent),
|
||||||
m_dirLister(nullptr),
|
m_dirLister(nullptr),
|
||||||
m_sortDirsFirst(true),
|
m_sortDirsFirst(true),
|
||||||
m_sortHiddenLast(true),
|
m_sortHiddenLast(false),
|
||||||
m_sortRole(NameRole),
|
m_sortRole(NameRole),
|
||||||
m_sortingProgressPercent(-1),
|
m_sortingProgressPercent(-1),
|
||||||
m_roles(),
|
m_roles(),
|
||||||
|
|
|
@ -59,7 +59,7 @@
|
||||||
|
|
||||||
<entry name="SortHiddenLast" type="Bool" >
|
<entry name="SortHiddenLast" type="Bool" >
|
||||||
<label context="@label">Show hidden files and folders last</label>
|
<label context="@label">Show hidden files and folders last</label>
|
||||||
<default>true</default>
|
<default>false</default>
|
||||||
</entry>
|
</entry>
|
||||||
|
|
||||||
<entry name="VisibleRoles" type="StringList">
|
<entry name="VisibleRoles" type="StringList">
|
||||||
|
|
|
@ -814,16 +814,16 @@ void KFileItemModelTest::testSorting()
|
||||||
{
|
{
|
||||||
// testDir structure is as follows
|
// testDir structure is as follows
|
||||||
// ./
|
// ./
|
||||||
|
// ├─ .g/
|
||||||
// ├─ a
|
// ├─ a
|
||||||
// ├─ b
|
// ├─ b
|
||||||
// ├─ c/
|
// ├─ c/
|
||||||
// │ ├─ c-2/
|
// │ ├─ c-2/
|
||||||
// │ │ ├─ c-3
|
// │ │ ├─ c-3
|
||||||
// │ ├─ c-1
|
// │ ├─ c-1
|
||||||
|
// ├─ .f
|
||||||
// ├─ d
|
// ├─ d
|
||||||
// ├─ e
|
// ├─ e
|
||||||
// ├─ .f
|
|
||||||
// ├─ .g/
|
|
||||||
|
|
||||||
QSignalSpy itemsInsertedSpy(m_model, &KFileItemModel::itemsInserted);
|
QSignalSpy itemsInsertedSpy(m_model, &KFileItemModel::itemsInserted);
|
||||||
QSignalSpy itemsMovedSpy(m_model, &KFileItemModel::itemsMoved);
|
QSignalSpy itemsMovedSpy(m_model, &KFileItemModel::itemsMoved);
|
||||||
|
@ -968,10 +968,20 @@ void KFileItemModelTest::testSorting()
|
||||||
// 'Show Hidden Files' enabled
|
// 'Show Hidden Files' enabled
|
||||||
m_model->setShowHiddenFiles(true);
|
m_model->setShowHiddenFiles(true);
|
||||||
QVERIFY(m_model->showHiddenFiles());
|
QVERIFY(m_model->showHiddenFiles());
|
||||||
QCOMPARE(itemsInModel(), QStringList() << "c" << "c-2" << "c-3" << "c-1" << "d" << "e" << "b" << "a" << ".g" << ".f");
|
QVERIFY(!m_model->sortHiddenLast());
|
||||||
|
QCOMPARE(itemsInModel(), QStringList() << "c" << "c-2" << "c-3" << "c-1" << ".g" << "d" << "e" << "b" << "a" << ".f");
|
||||||
QCOMPARE(itemsMovedSpy.count(), 0);
|
QCOMPARE(itemsMovedSpy.count(), 0);
|
||||||
QCOMPARE(itemsInsertedSpy.count(), 1);
|
QCOMPARE(itemsInsertedSpy.count(), 1);
|
||||||
QCOMPARE(itemsInsertedSpy.takeFirst().at(0).value<KItemRangeList>(), KItemRangeList() << KItemRange(8, 2));
|
QCOMPARE(itemsInsertedSpy.takeFirst().at(0).value<KItemRangeList>(), KItemRangeList() << KItemRange(4, 1) << KItemRange(8, 1));
|
||||||
|
|
||||||
|
// 'Sort Hidden Files Last' enabled
|
||||||
|
m_model->setSortHiddenLast(true);
|
||||||
|
QVERIFY(m_model->sortHiddenLast());
|
||||||
|
QCOMPARE(itemsInModel(), QStringList() << "c" << "c-2" << "c-3" << "c-1" << "d" << "e" << "b" << "a" << ".g" << ".f");
|
||||||
|
QCOMPARE(itemsMovedSpy.count(), 1);
|
||||||
|
QCOMPARE(itemsInsertedSpy.count(), 0);
|
||||||
|
QCOMPARE(itemsMovedSpy.first().at(0).value<KItemRange>(), KItemRange(4, 5));
|
||||||
|
QCOMPARE(itemsMovedSpy.takeFirst().at(1).value<QList<int> >(), QList<int>() << 8 << 4 << 5 << 6 << 7);
|
||||||
|
|
||||||
// Sort by Name
|
// Sort by Name
|
||||||
m_model->setSortRole("text");
|
m_model->setSortRole("text");
|
||||||
|
@ -1151,7 +1161,7 @@ void KFileItemModelTest::testRemoveHiddenItems()
|
||||||
m_model->setShowHiddenFiles(true);
|
m_model->setShowHiddenFiles(true);
|
||||||
m_model->loadDirectory(m_testDir->url());
|
m_model->loadDirectory(m_testDir->url());
|
||||||
QVERIFY(itemsInsertedSpy.wait());
|
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(itemsInsertedSpy.count(), 1);
|
||||||
QCOMPARE(itemsRemovedSpy.count(), 0);
|
QCOMPARE(itemsRemovedSpy.count(), 0);
|
||||||
KItemRangeList itemRangeList = itemsInsertedSpy.takeFirst().at(0).value<KItemRangeList>();
|
KItemRangeList itemRangeList = itemsInsertedSpy.takeFirst().at(0).value<KItemRangeList>();
|
||||||
|
@ -1162,14 +1172,14 @@ void KFileItemModelTest::testRemoveHiddenItems()
|
||||||
QCOMPARE(itemsInsertedSpy.count(), 0);
|
QCOMPARE(itemsInsertedSpy.count(), 0);
|
||||||
QCOMPARE(itemsRemovedSpy.count(), 1);
|
QCOMPARE(itemsRemovedSpy.count(), 1);
|
||||||
itemRangeList = itemsRemovedSpy.takeFirst().at(0).value<KItemRangeList>();
|
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);
|
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(itemsInsertedSpy.count(), 1);
|
||||||
QCOMPARE(itemsRemovedSpy.count(), 0);
|
QCOMPARE(itemsRemovedSpy.count(), 0);
|
||||||
itemRangeList = itemsInsertedSpy.takeFirst().at(0).value<KItemRangeList>();
|
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();
|
m_model->clear();
|
||||||
QCOMPARE(itemsInModel(), QStringList());
|
QCOMPARE(itemsInModel(), QStringList());
|
||||||
|
|
Loading…
Reference in a new issue