Instead of a list of strings as input for the Sections you can also use
the 'actions' property with a list of Actions. Then renaming a sim can
update the text for the action, without changing the list that the
Sections use, so selectedIndex is not changed.

Using an Action for each sim might also be a slightly more
straightforward way to change the configuration instead of using
onSelectedIndexChanged to detect when the user taps on a SIM name.

For example, clicking the button in the example below will change the
name of the section without changing selectedIndex:

import QtQuick 2.4
import Ubuntu.Components 1.3

MainView {
    width: units.gu(80)
    height: units.gu(70)
    Page {
        header: PageHeader {
            title: "Example"
            extension: Sections {
                actions: [
                    Action {
                        id: action1
                        text: "Action 1"
                        onTriggered: print("first one")
                    },
                    Action {
                        id: action2
                        text: "Action 2"
                        onTriggered: print("second one")
                    }
                ]
                selectedIndex: 1
            }
        }

        Button {
            anchors.centerIn: parent
            text: "Change action name"
            onClicked: action1.text = "First action"
        }
    }
}

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1557707

Title:
  [Sections] selectedIndex binding is broken if the model changes

To manage notifications about this bug go to:
https://bugs.launchpad.net/canonical-devices-system-image/+bug/1557707/+subscriptions

-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to