2020-05-28 22:22:51 +00:00
|
|
|
import QtQuick 2.14
|
2020-05-27 22:59:17 +00:00
|
|
|
import QtQuick.Controls 2.3
|
2020-05-28 22:22:51 +00:00
|
|
|
import QtQuick.Controls 2.14 as QQC2
|
2020-05-27 22:59:17 +00:00
|
|
|
import QtQuick.Layouts 1.3
|
|
|
|
import Qt.labs.platform 1.1
|
|
|
|
import "../../../../shared"
|
|
|
|
import "../../../../imports"
|
2020-05-28 17:34:54 +00:00
|
|
|
import "./samples/"
|
2020-05-27 22:59:17 +00:00
|
|
|
|
2020-05-28 22:22:51 +00:00
|
|
|
ScrollView {
|
2020-05-28 17:34:54 +00:00
|
|
|
property var messageList: MessagesData {}
|
2020-05-28 22:22:51 +00:00
|
|
|
|
|
|
|
anchors.fill: parent
|
2020-05-27 22:59:17 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
|
2020-05-28 22:22:51 +00:00
|
|
|
ScrollBar.vertical.policy: chatLogView.contentHeight > chatLogView.height ? ScrollBar.AlwaysOn : ScrollBar.AlwaysOff
|
|
|
|
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
|
|
|
|
|
2020-06-04 19:07:07 +00:00
|
|
|
SortFilterModel {
|
|
|
|
id: messageListDelegate
|
|
|
|
lessThan: function(left, right) {
|
|
|
|
return left.clock < right.clock;
|
|
|
|
}
|
2020-05-28 22:22:51 +00:00
|
|
|
model: messageList
|
|
|
|
delegate: Message {
|
|
|
|
userName: model.userName
|
|
|
|
message: model.message
|
|
|
|
identicon: model.identicon
|
|
|
|
isCurrentUser: model.isCurrentUser
|
|
|
|
repeatMessageInfo: model.repeatMessageInfo
|
|
|
|
timestamp: model.timestamp
|
2020-05-28 21:34:04 +00:00
|
|
|
sticker: model.sticker
|
|
|
|
contentType: model.contentType
|
2020-05-27 22:59:17 +00:00
|
|
|
}
|
2020-06-04 19:07:07 +00:00
|
|
|
}
|
2020-05-28 22:22:51 +00:00
|
|
|
|
2020-06-04 19:07:07 +00:00
|
|
|
ListView {
|
|
|
|
anchors.fill: parent
|
|
|
|
spacing: 4
|
|
|
|
id: chatLogView
|
|
|
|
model: messageListDelegate
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
highlightFollowsCurrentItem: true
|
2020-05-28 22:22:51 +00:00
|
|
|
onCountChanged: {
|
|
|
|
if (!this.atYEnd) {
|
|
|
|
// User has scrolled up, we don't want to scroll back
|
|
|
|
return
|
|
|
|
}
|
2020-05-27 22:59:17 +00:00
|
|
|
|
2020-05-28 22:22:51 +00:00
|
|
|
// positionViewAtEnd doesn't work well. Instead, we use highlightFollowsCurrentItem
|
|
|
|
// and set the current Item/Index to the latest item
|
|
|
|
while (this.currentIndex < this.count - 1) {
|
|
|
|
this.incrementCurrentIndex()
|
|
|
|
}
|
2020-05-27 22:59:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-05-28 15:55:52 +00:00
|
|
|
|
|
|
|
/*##^##
|
|
|
|
Designer {
|
|
|
|
D{i:0;autoSize:true;height:480;width:640}
|
|
|
|
}
|
|
|
|
##^##*/
|