UbuntuListView dividers don't get updated on model changes
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
ubuntu-ui-toolkit (Ubuntu) |
Confirmed
|
Undecided
|
Unassigned |
Bug Description
I have an UbuntuListView with ListItems, and I add items into the model at runtime.
I want to keep the list sorted, so I insert items at specific positions instead of appending them.
The problem is that the divider only shows up for items that are inserted before the last one.
I read in the API documentation for ListItem [1]:
> When used in ListView or UbuntuListView, the last list item will not show the divider no matter of the visible property value set.
So I suppose this is the reason. But shouldn't the divider become visible when the model changes and the ListItem is no longer the last one?
For example, I add the following items, in order:
* aaa
* ccc
* bbb
Because the list is sorted, when adding `bbb` it is inserted in the middle and receives a divider. But `aaa` remains with no divider, and the list looks weird.
Expected:
aaa
-----
bbb
-----
ccc
Actual:
aaa
bbb
-----
ccc
Here is the full source code:
=== Main.qml ===
import QtQuick 2.4
import QtQuick.Layouts 1.1
import Ubuntu.Components 1.2
MainView {
width: units.gu(40)
height: units.gu(40)
Page {
anchors {
}
id: textInput
}
}
MyList {
id: myList
}
}
}
}
function addToList() {
}
}
}
=== MyList.qml ===
import QtQuick 2.4
import Ubuntu.Components 1.2
import Ubuntu.
Item {
ListModel {
id: listModel
}
UbuntuListView {
model: listModel
delegate: ListItem {
id: listItem
height: units.gu(5)
Label {
}
}
}
}
function add(text) {
var indexToInsert = listModel.count;
for(var i = 0; i < listModel.count; i++) {
var compareResult = text.localeComp
}
}
}
}
I'm not really sure if this is a bug, or if I'm not using the API correctly.
[1] https:/
affects: | ubuntu → ubuntu-ui-toolkit (Ubuntu) |
Status changed to 'Confirmed' because the bug affects multiple users.