[Interest] Can QSortFilterProxyModel sort the filtered data only?

Mark Gaiser markg85 at gmail.com
Fri Apr 11 19:00:47 CEST 2014


On Fri, Apr 11, 2014 at 5:00 PM, Jan Kundrát <jkt at flaska.net> wrote:
> On Friday, 11 April 2014 00:34:10 CEST, Mark Gaiser wrote:
>> The use case for this is quite simple. File browsing. The actual use
>> case within that is:
>> - Grouping files based on some (user defined) type (like mime)
>> - Within _each_ ("each".. that's the difficult part) group sorting on
>> some other type (like date, size, etc...)
>
> What about tweaking your sort function instead?
>
> bool lessThan(a, b)
> {
>     if (a.mime >= b.mime) {
>         return false;
>     } else if (a.date >= b.date) {
>         return false;
>     } else if (a.size >= b.size) {
>         return false;
>     } else {
>         return true;
>     }
> }
>
> Cheers,
> Jan

Yes, close to that is what i'm going to implement now. All i'm adding
is limiting the lessThen to the current group key. So for instance:
Grouping on mime give you:
- folders
- txt files
- exe files
- ... files

Then if you sort the txt files it will only pass the entries to
lessThan if they pass the group key. Or something alike. I have the
general idea, just have to implement it now.



More information about the Interest mailing list