moment/harmonyqml/components/SidePane/RoomList.qml

40 lines
974 B
QML
Raw Normal View History

import QtQuick 2.7
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.4
import "../Base"
ListView {
property var userId: null
property int childrenHeight: 36
2019-04-22 01:39:29 +10:00
property int sectionHeight: 16 + spacing
property int contentHeight: getContentHeight()
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
}
Connections {
target: model
onChanged: getContentHeight()
}
id: roomList
spacing: 8
model: Backend.models.rooms.get(userId)
delegate: RoomDelegate {}
section.property: "category"
2019-04-22 01:39:29 +10:00
section.delegate: RoomCategoryDelegate { height: sectionHeight }
}