2019-03-26 18:19:55 +11:00
|
|
|
import QtQuick 2.7
|
2019-04-29 05:45:42 +10:00
|
|
|
import QtQuick.Layouts 1.3
|
2019-04-29 05:18:36 +10:00
|
|
|
import "../Base"
|
2019-03-26 18:19:55 +11:00
|
|
|
|
|
|
|
ListView {
|
2019-04-29 02:40:18 +10:00
|
|
|
property var userId: null
|
2019-03-26 18:19:55 +11:00
|
|
|
|
2019-04-13 22:59:10 +10:00
|
|
|
property int childrenHeight: 36
|
2019-04-22 01:39:29 +10:00
|
|
|
property int sectionHeight: 16 + spacing
|
2019-04-22 06:53:16 +10:00
|
|
|
property int contentHeight: getContentHeight()
|
2019-03-26 18:19:55 +11:00
|
|
|
|
2019-04-22 06:53:16 +10:00
|
|
|
function getContentHeight() {
|
2019-04-22 01:39:29 +10:00
|
|
|
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
|
2019-03-26 18:19:55 +11:00
|
|
|
}
|
|
|
|
|
2019-04-22 06:53:16 +10:00
|
|
|
Connections {
|
|
|
|
target: model
|
|
|
|
onChanged: getContentHeight()
|
|
|
|
}
|
|
|
|
|
2019-04-21 07:45:51 +10:00
|
|
|
id: roomList
|
2019-03-26 18:19:55 +11:00
|
|
|
spacing: 8
|
2019-04-29 02:40:18 +10:00
|
|
|
model: Backend.models.rooms.get(userId)
|
2019-03-26 18:19:55 +11:00
|
|
|
delegate: RoomDelegate {}
|
2019-04-21 20:56:59 +10:00
|
|
|
|
|
|
|
section.property: "category"
|
2019-04-22 01:39:29 +10:00
|
|
|
section.delegate: RoomCategoryDelegate { height: sectionHeight }
|
2019-03-26 18:19:55 +11:00
|
|
|
}
|