SwitchRole

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

Import Statement: import VPlayApps 1.0
Since: V-Play 2.18.1
Inherits:

ProxyRole

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"
     }
 }

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.


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.


Attached Property Documentation

SwitchRole.value : var

This property attaches a value to a Filter.


Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
FREE!
create apps
create games
cross platform
native performance
3rd party services
game network
multiplayer
level editor
easiest to learn
biggest time saving
best support