So it appears it’s not a bug in the UITK, but in the way it is being
used in the browser and in the standalone example (see comment #1).
Changing ViewItems.selectedIndices in onSelectedChanged is not a good
idea.
I came up with a different approach which solves that issue:
import QtQuick 2.4
import Ubuntu.Components 1.3
ListView {
id: listview
width: 300
height: 120
model: 2
delegate: ListItem {
ListItemLayout {
title.text: "selected: " + selected
}
}
property int selectedIndex: -1
ViewItems.selectMode: true
ViewItems.onSelectedIndicesChanged: {
if (ViewItems.selectedIndices.length > 1 && selectedIndex != -1) {
var selection = ViewItems.selectedIndices
selection.splice(selection.indexOf(selectedIndex), 1)
selectedIndex = selection[0]
ViewItems.selectedIndices = selection
return
}
if (ViewItems.selectedIndices.length > 0) {
selectedIndex = ViewItems.selectedIndices[0]
} else {
selectedIndex = -1
}
}
}
However I’m now seeing another issue: after selecting the first item,
then the second one, then the first one again, the 'selected' property
of the item doesn’t reflect the current state: the first item is
selected, selectedIndices is [0], yet the first delegate’s selected
property is false.
** Changed in: ubuntu-ui-toolkit (Ubuntu)
Status: Confirmed => Invalid
** Changed in: ubuntu-ui-toolkit (Ubuntu)
Assignee: Zsombor Egri (zsombi) => (unassigned)
--
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1534112
Title:
Can select multiple files in downloads view when only one expected
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/ubuntu-ui-toolkit/+bug/1534112/+subscriptions
--
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs