moment/harmonyqml/components/SidePane/RoomDelegate.qml
miruka 52d538e995 Merge Backend and QMLModels
Backend.models.accounts → Backend.accounts
Backend.models.roomEvents → Backend.roomEvents
2019-05-02 14:31:47 -04:00

64 lines
1.7 KiB
QML

import QtQuick 2.7
import QtQuick.Layouts 1.3
import "../Base"
import "utils.js" as SidePaneJS
MouseArea {
id: roomDelegate
width: roomList.width
height: childrenRect.height
onClicked: pageStack.showRoom(roomList.userId, roomList.category, roomId)
HRowLayout {
width: parent.width
spacing: roomList.spacing
HAvatar {
id: roomAvatar
name: displayName
}
HColumnLayout {
Layout.fillWidth: true
Layout.maximumWidth:
parent.width - parent.totalSpacing - roomAvatar.width
HLabel {
id: roomLabel
text: displayName ? displayName : "<i>Empty room</i>"
textFormat: Text.StyledText
elide: Text.ElideRight
maximumLineCount: 1
verticalAlignment: Qt.AlignVCenter
Layout.maximumWidth: parent.width
}
HLabel {
function getText() {
return SidePaneJS.getLastRoomEventText(
roomId, roomList.userId
)
}
Connections {
target: Backend.roomEvents.get(roomId)
onChanged: subtitleLabel.text = subtitleLabel.getText()
}
id: subtitleLabel
visible: text !== ""
text: getText()
textFormat: Text.StyledText
font.pixelSize: HStyle.fontSize.small
elide: Text.ElideRight
maximumLineCount: 1
Layout.maximumWidth: parent.width
}
}
}
}