From ee6a158c79be66a335f6e3611e796a0b545e2793 Mon Sep 17 00:00:00 2001 From: cutefishd Date: Thu, 1 Apr 2021 22:16:42 +0800 Subject: [PATCH] Fix the count of ListView item --- model/foldermodel.cpp | 4 +++- qml/FolderGridView.qml | 4 ++++ qml/FolderListView.qml | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/model/foldermodel.cpp b/model/foldermodel.cpp index 44fcd7e..1b63781 100644 --- a/model/foldermodel.cpp +++ b/model/foldermodel.cpp @@ -133,7 +133,9 @@ QVariant FolderModel::data(const QModelIndex &index, int role) const } case FileSizeRole: { if (item.isDir()) { - uint count = QDir(item.url().toLocalFile()).count(); + QDir dir(item.url().toLocalFile()); + dir.setFilter(QDir::Dirs | QDir::AllEntries | QDir::NoDotAndDotDot); + uint count = dir.count(); return count == 1 ? tr("%1 item").arg(count) : tr("%1 items").arg(count); } diff --git a/qml/FolderGridView.qml b/qml/FolderGridView.qml index 56d998a..2578f8f 100644 --- a/qml/FolderGridView.qml +++ b/qml/FolderGridView.qml @@ -74,6 +74,10 @@ GridView { if (currentIndex != -1) anchorIndex = currentIndex + } else if (event.key === Qt.Key_Equal && event.modifiers & Qt.ControlModifier) { + control.increaseIconSize() + } else if (event.key === Qt.Key_Minus && event.modifiers & Qt.ControlModifier) { + control.decreaseIconSize() } control.keyPress(event) diff --git a/qml/FolderListView.qml b/qml/FolderListView.qml index 1c60b59..5320535 100644 --- a/qml/FolderListView.qml +++ b/qml/FolderListView.qml @@ -314,7 +314,7 @@ ListView { onTargetItemChanged: { if (targetItem != null) { var pos = control.mapFromItem(targetItem, targetItem.labelArea.x, targetItem.labelArea.y) - width = targetItem.width - targetItem.iconArea.width * 2 + width = targetItem.labelArea.width height = targetItem.height x = control.mapFromItem(targetItem.labelArea, 0, 0).x y = pos.y