Fix roomList height with sections
This commit is contained in:
parent
9602608b87
commit
94d6bc0e52
|
@ -3,7 +3,6 @@ import "../base" as Base
|
|||
|
||||
Base.HLabel {
|
||||
width: roomList.width
|
||||
height: text.height
|
||||
|
||||
// topPadding is provided by the roomList spacing
|
||||
bottomPadding: roomList.spacing
|
||||
|
|
|
@ -7,11 +7,21 @@ ListView {
|
|||
property var forUserId: null
|
||||
|
||||
property int childrenHeight: 36
|
||||
property int sectionHeight: 16 + spacing
|
||||
property int contentHeight: 0
|
||||
|
||||
onCountChanged: {
|
||||
contentHeight = childrenHeight * model.count +
|
||||
spacing * (model.count - 1)
|
||||
var sections = []
|
||||
|
||||
for (var i = 0; i < model.count; i++) {
|
||||
var categ = model.get(i).category
|
||||
if (sections.indexOf(categ) == -1) { sections.push(categ) }
|
||||
}
|
||||
|
||||
contentHeight =
|
||||
childrenHeight * model.count +
|
||||
spacing * Math.max(0, (model.count - 1)) +
|
||||
sectionHeight * sections.length
|
||||
}
|
||||
|
||||
id: roomList
|
||||
|
@ -20,5 +30,5 @@ ListView {
|
|||
delegate: RoomDelegate {}
|
||||
|
||||
section.property: "category"
|
||||
section.delegate: RoomCategoryDelegate {}
|
||||
section.delegate: RoomCategoryDelegate { height: sectionHeight }
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user