Skip to content

Commit

Permalink
fix sorting in Files
Browse files Browse the repository at this point in the history
  • Loading branch information
ddennedy committed Jan 6, 2025
1 parent 79a2040 commit f2b2a9d
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/docks/filesdock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -480,10 +480,18 @@ class FilesProxyModel : public QSortFilterProxyModel
{
const auto model = qobject_cast<const QFileSystemModel *>(sourceModel());
if (model->isDir(left) && model->isDir(right)) {
if (left.column() == 3)
return model->lastModified(left) < model->lastModified(right);
return left.data().toString().toLower() < right.data().toString().toLower();
} else if (model->isDir(left) || model->isDir(right)) {
return model->isDir(left);
}
if (model->isDir(left) || model->isDir(right))
return model->isDir(left);
// file size
if (left.column() == 1)
return model->size(left) < model->size(right);
// file date
if (left.column() == 3)
return model->lastModified(left) < model->lastModified(right);
return QSortFilterProxyModel::lessThan(left, right);
}

Expand Down Expand Up @@ -691,6 +699,7 @@ FilesDock::FilesDock(QWidget *parent)
});
connect(ui->tableView->horizontalHeader(), &QHeaderView::sortIndicatorChanged,
this, [ = ](int column, Qt::SortOrder order) {
LOG_DEBUG() << "sort by column" << column;
ui->tableView->sortByColumn(column, order);
});
connect(ui->listView, &QAbstractItemView::activated, ui->tableView, &QAbstractItemView::activated);
Expand Down

0 comments on commit f2b2a9d

Please sign in to comment.