`extra` properties not available as filter roleName for SortFilterProxyModel
doakey3 opened this issue · comments
In my game metadata files, I have a property: x-ESRB
with values like E
, E10plus
, T
, M
. I was wondering if I could filter the games by their ESRB rating using a SortFilterProxyModel, but I can't seem to figure out the proper role name to use. I've tried game.extra.ESRB
, extra.ESRB
, x-ESRB
. I was referring to this page in the api: https://pegasus-frontend.org/docs/themes/api/
Here is the relevant section of code:
SortFilterProxyModel {
id: filteredGames
sourceModel: api.allGames
filters: [
RegExpFilter {
roleName: "title" // <-- This works when this filter is enabled
pattern: "^(The\\s)?L.*"
caseSensitivity: Qt.CaseInsensitive
enabled: false
},
RegExpFilter {
roleName: "game.extra.ESRB" // <-- This does not work. Can I get it to work somehow?
pattern: "^T"
caseSensitivity: Qt.CaseInsensitive
enabled: true
}
]
}
This is solved by using an ExpressionFilter
SortFilterProxyModel {
id: filteredGames
sourceModel: api.allGames
filters: [
ExpressionFilter {
expression: {
if (window.esrb_filter == "none") {
return true
}
else if (window.esrb_filter == model.extra.esrb) {
return true
}
return false
}
enabled: true
}
]
}