Skip to content

Commit

Permalink
BufferListPanel: improve the first/last item detection logic
Browse files Browse the repository at this point in the history
  • Loading branch information
jpnurmi committed Apr 6, 2014
1 parent 199eafe commit 57c2e6a
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion ui/view/BufferListPanel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,23 @@ Panel {
property int lastIndex: -1

onContentYChanged: {
// the index for section/network items is -1 => retain the previous index
var first = indexAt(0, contentY + Theme.itemSizeExtraSmall)
if (first === -1) {
// the first item is a section item (a network delegate)
var firstItem = contentItem.childAt(0, contentY + Theme.itemSizeExtraSmall)
if (firstItem && firstItem.buffer)
first = BufferModel.indexOf(firstItem.buffer)
}
if (first !== -1)
firstIndex = first

var last = indexAt(0, contentY + height)
if (last === -1) {
// the last item is a section item (a network delegate)
var lastItem = contentItem.childAt(0, contentY + height)
if (lastItem && lastItem.buffer)
last = BufferModel.indexOf(lastItem.buffer)
}
if (last !== -1)
lastIndex = last
}
Expand Down

0 comments on commit 57c2e6a

Please sign in to comment.