misc: set filters as the default property of SwitchRole

This commit is contained in:
Grecko 2018-09-28 22:16:41 +02:00
parent 51c6a62f4d
commit 1ae65bca74
2 changed files with 20 additions and 21 deletions

View File

@ -31,6 +31,7 @@ class SwitchRole : public SingleRole, public FilterContainer
Q_PROPERTY(QString defaultRoleName READ defaultRoleName WRITE setDefaultRoleName NOTIFY defaultRoleNameChanged)
Q_PROPERTY(QVariant defaultValue READ defaultValue WRITE setDefaultValue NOTIFY defaultValueChanged)
Q_PROPERTY(QQmlListProperty<qqsfpm::Filter> filters READ filtersListProperty)
Q_CLASSINFO("DefaultProperty", "filters")
public:
using SingleRole::SingleRole;

View File

@ -20,26 +20,24 @@ Item {
proxyRoles: SwitchRole {
id: switchRole
name: "switchRole"
filters: [
ValueFilter {
id: valueFilter
roleName: "favorite"
value: true
SwitchRole.value: "*"
},
ValueFilter {
id: secondValueFilter
roleName: "favorite"
value: true
SwitchRole.value: "%"
},
ValueFilter {
id: thirdValueFilter
roleName: "name"
value: 3
SwitchRole.value: "three"
}
]
ValueFilter {
id: valueFilter
roleName: "favorite"
value: true
SwitchRole.value: "*"
}
ValueFilter {
id: secondValueFilter
roleName: "favorite"
value: true
SwitchRole.value: "%"
}
ValueFilter {
id: thirdValueFilter
roleName: "name"
value: 3
SwitchRole.value: "three"
}
defaultRoleName: "name"
defaultValue: "foo"
}
@ -56,7 +54,7 @@ Item {
TestCase {
name: "SwitchRole"
function test_data() {
function test_role() {
compare(testModel.get(0, "switchRole"), "*");
compare(testModel.get(1, "switchRole"), "2");
compare(testModel.get(2, "switchRole"), "three");