Comment 0 for bug 1469471

Revision history for this message
Nekhelesh Ramananthan (nik90) wrote :

The ListItem in Ubuntu.Components 1.2 and higher supports multiselect mode which is controlled by the "selectMode" property. The "selected" property controls whether a listitem is selected or not. However it seems that the checkbox shown during multiselect mode doesn't seem to obey the "selected property.

Steps to reproduce the bug:
1. Run the sample code
2. Long press to active multiselect mode
3. Press on any checkbox visible while in multiselect mode
4. Now press on that listitem.

Notice the following,
- Clicking on the listitem toggles the "selected" property. But the checkbox does not seem to respect that.
- The "selectedIndices" array correctly shows that the listitem is selected/unselected on pressing it, but the checkbox just ignores that.

I have attached sample code which reproduces the bug in a simple manner.

import QtQuick 2.4
import Ubuntu.Components 1.2

MainView {
    applicationName: "testapp.nik90"

    width: units.gu(100)
    height: units.gu(75)

    Page {
        title: i18n.tr("ListView Bug")

        UbuntuListView {
            id: listview

            ListModel {
                id: instructionModel
                ListElement { text: "Let's try to reproduce this listview bug ;)" }
                ListElement { text: "Step 1: Long press to active multiselect mode" }
                ListElement { text: "Step 2: Press on any checkbox to select that listitem" }
                ListElement { text: "Step 3: Now press on the list item of the checkbox you chose in the previous step." }
                ListElement { text: "Notice how it doesn't select/unselect it despite pressing it" }
                ListElement { text: "Also notice how when pressing on the listitem in step 3, the selected indice still changes!" }
            }

            anchors.fill: parent
            model: instructionModel

            delegate: ListItem {
                height: units.gu(8)
                contentItem.anchors { leftMargin: units.gu(2); rightMargin: units.gu(2) }

                Label {
                    id: label
                    text: modelData
                    anchors.fill: parent
                    wrapMode: Text.WordWrap
                    verticalAlignment: Text.AlignVCenter
                }

                onPressAndHold: {
                    ListView.view.ViewItems.selectMode = !ListView.view.ViewItems.selectMode
                }

                onClicked: {
                    if (selectMode) {
                        selected = !selected
                    }
                }
            }

            footer: Label {
                anchors { left: parent.left; leftMargin: units.gu(2) }
                width: parent.width
                text: "Selected Indices: " + listview.ViewItems.selectedIndices
            }
        }
    }
}