Fix the count of ListView item

This commit is contained in:
cutefishd 2021-04-01 22:16:42 +08:00
parent 37b0b93d56
commit ee6a158c79
3 changed files with 8 additions and 2 deletions

View file

@ -133,7 +133,9 @@ QVariant FolderModel::data(const QModelIndex &index, int role) const
} }
case FileSizeRole: { case FileSizeRole: {
if (item.isDir()) { 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); return count == 1 ? tr("%1 item").arg(count) : tr("%1 items").arg(count);
} }

View file

@ -74,6 +74,10 @@ GridView {
if (currentIndex != -1) if (currentIndex != -1)
anchorIndex = currentIndex 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) control.keyPress(event)

View file

@ -314,7 +314,7 @@ ListView {
onTargetItemChanged: { onTargetItemChanged: {
if (targetItem != null) { if (targetItem != null) {
var pos = control.mapFromItem(targetItem, targetItem.labelArea.x, targetItem.labelArea.y) 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 height = targetItem.height
x = control.mapFromItem(targetItem.labelArea, 0, 0).x x = control.mapFromItem(targetItem.labelArea, 0, 0).x
y = pos.y y = pos.y