Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

SwitchRole

A role using Filter to conditionnaly compute its data. More...

Import Statement: import Felgo 4.0
Since: Felgo 2.18.1
Inherits:

SingleRole

Properties

Attached Properties

Detailed Description

A SwitchRole is a ProxyRole that computes its data with the help of Filter. Each top level filters specified in the SwitchRole is evaluated on the rows of the model, if a Filter evaluates to true, the data of the SwitchRole for this row will be the one of the attached SwitchRole.value property. If no top level filters evaluate to true, the data will default to the one of the defaultRoleName (or the defaultValue if no defaultRoleName is specified).

In the following example, the favoriteOrFirstNameSection role is equal to * if the favorite role of a row is true, otherwise it's the same as the firstName role :

 SortFilterProxyModel {
    sourceModel: contactModel
    proxyRoles: SwitchRole {
        name: "favoriteOrFirstNameSection"
        filters: ValueFilter {
            roleName: "favorite"
            value: true
            SwitchRole.value: "*"
        }
        defaultRoleName: "firstName"
     }
 }

See also FilterContainer.

Property Documentation

defaultRoleName : string

This property holds the default role name of the role. If no filter match a row, the data of this role will be the data of the role whose name is defaultRoleName.


defaultValue : var

This property holds the default value of the role. If no filter match a row, and no defaultRoleName is set, the data of this role will be defaultValue.


[default] filters : list<Filter>

This property holds the list of filters for this proxy role. The data of this role will be equal to the attached SwitchRole.value property of the first filter that matches the model row.

See also Filter and FilterContainer.


name : string

This property holds the role name of the proxy role.


Attached Property Documentation

SwitchRole.value : var

This property attaches a value to a Filter.


Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded