From ffffb6e63abfc33bc339d89a7bfcdd1734c48bef Mon Sep 17 00:00:00 2001 From: Arno Date: Thu, 4 Jan 2018 10:55:25 +0100 Subject: Implement filtering by MIME-Type The MIME-type is a regular expression that can be configured. Show the configured types in a QComboBox with the special value "" at the top, which invalidates the MIME type filter. --- filesorter.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'filesorter.cpp') diff --git a/filesorter.cpp b/filesorter.cpp index 7c6d1d1..fcecfad 100644 --- a/filesorter.cpp +++ b/filesorter.cpp @@ -54,3 +54,12 @@ bool VideoSorter::lessThan(const QModelIndex &source_left, const QModelIndex &so return QSortFilterProxyModel::lessThan(source_left, source_right); } + +bool VideoSorter::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const { + QModelIndex nameIdx = sourceModel()->index(source_row, 0, source_parent); + int attr = nameIdx.data(FileWidget::AttrsRole).toInt(); + if(attr == FileWidget::Directory || attr == FileWidget::ParentDir){ + return true; + } + return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent); +} -- cgit v1.2.3-70-g09d2