2019-07-08 13:52:41 +10:00
|
|
|
// Copyright 2019 miruka
|
|
|
|
// This file is part of harmonyqml, licensed under LGPLv3.
|
|
|
|
|
2019-07-13 19:39:01 +10:00
|
|
|
import QtQuick 2.12
|
|
|
|
import QtQuick.Layouts 1.12
|
2019-04-29 05:18:36 +10:00
|
|
|
import "../../Base"
|
2019-03-22 14:28:14 +11:00
|
|
|
|
|
|
|
Column {
|
2019-07-20 13:07:26 +10:00
|
|
|
id: eventDelegate
|
2019-03-22 14:28:14 +11:00
|
|
|
|
2019-07-20 13:07:26 +10:00
|
|
|
// Remember timeline goes from newest message at index 0 to oldest
|
|
|
|
property var previousItem: eventList.model.get(model.index + 1)
|
|
|
|
property var nextItem: eventList.model.get(model.index - 1)
|
2019-03-22 14:28:14 +11:00
|
|
|
|
2019-07-20 16:21:12 +10:00
|
|
|
property int modelIndex: model.index
|
|
|
|
onModelIndexChanged: {
|
2019-07-20 13:07:26 +10:00
|
|
|
previousItem = eventList.model.get(model.index + 1)
|
|
|
|
nextItem = eventList.model.get(model.index - 1)
|
2019-07-03 13:32:39 +10:00
|
|
|
}
|
|
|
|
|
2019-07-20 13:07:26 +10:00
|
|
|
property var senderInfo: senderInfo = users.find(model.senderId)
|
2019-07-20 10:55:52 +10:00
|
|
|
|
2019-07-20 13:07:26 +10:00
|
|
|
property bool isOwn: chatPage.userId === model.senderId
|
|
|
|
property bool onRight: eventList.ownEventsOnRight && isOwn
|
|
|
|
property bool combine: eventList.canCombine(previousItem, model)
|
|
|
|
property bool talkBreak: eventList.canTalkBreak(previousItem, model)
|
|
|
|
property bool dayBreak: eventList.canDayBreak(previousItem, model)
|
2019-07-20 10:55:52 +10:00
|
|
|
|
2019-07-20 13:07:26 +10:00
|
|
|
readonly property bool smallAvatar:
|
|
|
|
eventList.canCombine(model, nextItem) &&
|
|
|
|
(model.eventType == "RoomMessageEmote" ||
|
|
|
|
! model.eventType.startsWith("RoomMessage"))
|
2019-03-22 14:28:14 +11:00
|
|
|
|
2019-07-20 13:07:26 +10:00
|
|
|
readonly property bool collapseAvatar: combine
|
|
|
|
readonly property bool hideAvatar: onRight
|
2019-03-22 14:28:14 +11:00
|
|
|
|
2019-07-20 13:07:26 +10:00
|
|
|
readonly property bool hideNameLine:
|
|
|
|
model.eventType == "RoomMessageEmote" ||
|
|
|
|
! model.eventType.startsWith("RoomMessage") ||
|
|
|
|
onRight ||
|
|
|
|
combine
|
2019-04-20 17:29:24 +10:00
|
|
|
|
2019-07-18 20:23:31 +10:00
|
|
|
width: eventList.width
|
2019-04-20 17:29:24 +10:00
|
|
|
|
2019-03-22 14:28:14 +11:00
|
|
|
topPadding:
|
2019-07-20 13:07:26 +10:00
|
|
|
model.eventType == "RoomCreateEvent" ? 0 :
|
|
|
|
dayBreak ? theme.spacing * 4 :
|
2019-07-16 19:29:47 +10:00
|
|
|
talkBreak ? theme.spacing * 6 :
|
2019-07-20 13:07:26 +10:00
|
|
|
combine ? theme.spacing / 2 :
|
2019-07-16 19:29:47 +10:00
|
|
|
theme.spacing * 2
|
2019-04-18 06:43:18 +10:00
|
|
|
|
2019-07-20 16:21:12 +10:00
|
|
|
Daybreak {
|
|
|
|
visible: dayBreak
|
2019-07-20 13:07:26 +10:00
|
|
|
width: eventDelegate.width
|
2019-04-29 04:48:59 +10:00
|
|
|
}
|
2019-03-22 14:28:14 +11:00
|
|
|
|
2019-07-03 12:29:09 +10:00
|
|
|
EventContent {
|
2019-07-18 21:22:41 +10:00
|
|
|
x: onRight ? parent.width - width : 0
|
|
|
|
Behavior on x { HNumberAnimation {} }
|
2019-04-29 04:48:59 +10:00
|
|
|
}
|
2019-03-22 14:28:14 +11:00
|
|
|
}
|