Add file list sorting

This commit is contained in:
2023-03-11 10:41:26 +01:00
parent a9783f6030
commit fde1594086
12 changed files with 121 additions and 5 deletions
+12
View File
@@ -20,6 +20,18 @@ FilesystemWidget::FilesystemWidget(QAbstractItemModel *model, QWidget *parent) :
connect(m_listView->selectionModel(), &QItemSelectionModel::currentChanged, this, &FilesystemWidget::fileClicked);
}
void FilesystemWidget::contextMenuEvent(QContextMenuEvent *event)
{
QMenu menu;
menu.addAction(tr("Sort by filename"), [this](){ emit sortChanged(QDir::Name); });
menu.addAction(tr("Sort by time"), [this](){ emit sortChanged(QDir::Time); });
menu.addAction(tr("Sort by size"), [this](){ emit sortChanged(QDir::Size); });
menu.addAction(tr("Sort by type"), [this](){ emit sortChanged(QDir::Type); });
menu.addAction(tr("Reverse"), [this](){ emit reverseSort(); });
menu.exec(event->globalPos());
}
void FilesystemWidget::selectFile(int row)
{
QModelIndex index = m_model->index(row, 0);