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