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

feat(StatusQ/SubmodelProxyModel): Allow defining new proxy roles via delegateModel component #14390

Closed
micieslak opened this issue Apr 10, 2024 · 0 comments · Fixed by #14541
Closed

Comments

@micieslak
Copy link
Member

micieslak commented Apr 10, 2024

Description

It would be very convenient to have possibility of creating proxy models directly from delegate model's instance instead of using SFPM's proxy roles. Moreover SFPM's proxy roles depending on submodel's content cannot be updated properly when submodel is changing.

SubmodelProxyModel {
    id: submodelProxyModel

    sourceModel: tokensModel
    
    delegateModel: SortFilterProxyModel {
        id: delegateRoot
        
        sourceModel: submodel
        
        readonly property alias totalBalanceRole: aggregator.value

        filters: ValueFilter {
            roleName: "address"
            value: selectedAddress
        }
        
        SumAggregator {
            id: aggregator

            model: delegateRoot
            roleName: "balance"
        }
    }
}

It would add totalBalance role to the tokensModel.
New roles can be defined using simple pattern - properties like xxxRole are intended to add xxx role to the top-level model.

It's an alternative to currently used approach based on expression roles and imperative js code iterating over submodels:

FastExpressionRole {
    name: "totalBalance"
    expression: d.getTotalBalance(model.balances, model.decimals, "balance")
    expectedRoles: ["balances", "decimals"]
}

Moreover this expression role based approach is not dynamic, changes in submodel don't trigger changes in a top-level model. Proposed solution, when implemented correctly, can be fully dynamic out of the box.

Depends on: #14389

@micieslak micieslak added the bug Something isn't working label Apr 10, 2024
@micieslak micieslak self-assigned this Apr 10, 2024
@micieslak micieslak added ui-team E:Desktop Qt Proxy Models Library E:Desktop Profile Showcase Implementation of the Profile showcase and removed bug Something isn't working labels Apr 10, 2024
@noeliaSD noeliaSD added this to the 2.29.0 Beta milestone Apr 11, 2024
micieslak added a commit that referenced this issue Apr 29, 2024
micieslak added a commit that referenced this issue Apr 29, 2024
micieslak added a commit that referenced this issue Apr 30, 2024
micieslak added a commit that referenced this issue Apr 30, 2024
micieslak added a commit that referenced this issue Apr 30, 2024
micieslak added a commit that referenced this issue May 7, 2024
micieslak added a commit that referenced this issue May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment