Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModelEntry: generalization of entry search criteria #17117

Open
micieslak opened this issue Jan 23, 2025 · 0 comments
Open

ModelEntry: generalization of entry search criteria #17117

micieslak opened this issue Jan 23, 2025 · 0 comments
Labels

Comments

@micieslak
Copy link
Member

Description

Currently the ModelEntry can find entry only by value of a specified role:

ModelEntry {
    id: currentEntry

    sourceModel: root.model
    key: "keyUid"
    value: keyUidVal
}

It makes the ModelEntry not fully general and inconvenient where other search criteria are needed.

Good example is binding to the first entry from the given model. Or binding to the first entry as a fallback when search by key fails or key is not provided.

The idea is to utilize filtering mechanism of SFPM (Filter interface).

ModelEntry {
    id: currentEntry

    sourceModel: root.model
    
    filter: AnyOf {
        ValueFilter {
            id: valueFilter
            roleName: "keyUid"
        }
        IndexFilter {
            enabled: valueFilter.value === ""
            minimumIndex: 0
            maximumIndex: 0
        }
    }
}

The potential problem is IndexFilter must be enabled conditionally, otherwise first entry would be always selected. It causes (in the example) that when value is not empty but not found, fallback to first entry won't work.

Another possibility is to define separate fallbackFilter indended to be used when primary one fails to find entry:

ModelEntry {
    id: currentEntry

    sourceModel: root.model
    
    filter: ValueFilter {
        id: valueFilter
        roleName: "keyUid"
    }
    
    fallbackFilter: IndexFilter {
        minimumIndex: 0
        maximumIndex: 0
    }
}

Some other options should be considered as well, in order to provide simple but generic API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: No status
Development

No branches or pull requests

1 participant