Update libqmatrixclient && save viewpoint.

This commit is contained in:
Black Hat 2018-09-30 15:55:28 +08:00
parent 01196e8b50
commit 7ad988df4a
3 changed files with 28 additions and 23 deletions

@ -1 +1 @@
Subproject commit 9fb5fd1181fc74a040630df333a20ddd29cd7b28 Subproject commit f5651c74ddddd8c66b3b42b471fbe2ff278c0d9a

View File

@ -77,8 +77,7 @@ RowLayout {
visible: isText visible: isText
color: highlighted ? "white": Material.foreground color: highlighted ? "white": Material.foreground
font.family: "Noto Sans" font: Qt.font({pointSize: 10})
font.pointSize: 10
selectByMouse: true selectByMouse: true
readOnly: true readOnly: true
wrapMode: Label.Wrap wrapMode: Label.Wrap

View File

@ -19,23 +19,6 @@ Item {
MessageEventModel { MessageEventModel {
id: messageEventModel id: messageEventModel
room: currentRoom room: currentRoom
onModelReset: {
if (currentRoom)
{
var lastScrollPosition = currentRoom.savedTopVisibleIndex()
if (lastScrollPosition === 0)
messageListView.positionViewAtBeginning()
else
{
console.log("Scrolling to position", lastScrollPosition)
messageListView.positionViewAtIndex(lastScrollPosition, ListView.Contain)
}
if (messageListView.contentY < messageListView.originY + 10)
currentRoom.getPreviousContent(100)
}
console.log("Model timeline reset")
}
} }
RoomDrawer { RoomDrawer {
@ -128,6 +111,7 @@ Item {
displayMarginEnd: 40 displayMarginEnd: 40
verticalLayoutDirection: ListView.BottomToTop verticalLayoutDirection: ListView.BottomToTop
spacing: 8 spacing: 8
cacheBuffer: 200
flickDeceleration: 4096 flickDeceleration: 4096
@ -138,7 +122,7 @@ Item {
onContentYChanged: { onContentYChanged: {
// Check whether we're about to bump into the ceiling in 2 seconds // Check whether we're about to bump into the ceiling in 2 seconds
var curVelocity = verticalVelocity // Snapshot the current speed var curVelocity = verticalVelocity // Snapshot the current speed
if( curVelocity < 0 && contentY + curVelocity*2 < originY) if(curVelocity < 0 && contentY + curVelocity*2 < originY)
{ {
// Request the amount of messages enough to scroll at this // Request the amount of messages enough to scroll at this
// rate for 3 more seconds // rate for 3 more seconds
@ -147,16 +131,38 @@ Item {
} }
} }
onMovementEnded: currentRoom.saveViewport(indexAt(contentX, contentY), largestVisibleIndex) onMovementEnded: currentRoom.saveViewport(sortedMessageEventModel.mapToSource(indexAt(contentX, contentY)), sortedMessageEventModel.mapToSource(largestVisibleIndex))
displaced: Transition { NumberAnimation {
property: "y"; duration: 200
easing.type: Easing.OutQuad
}}
model: SortFilterProxyModel { model: SortFilterProxyModel {
id: sortedRoomListModel id: sortedMessageEventModel
sourceModel: messageEventModel sourceModel: messageEventModel
filters: ExpressionFilter { filters: ExpressionFilter {
expression: marks !== 0x08 && marks !== 0x10 expression: marks !== 0x08 && marks !== 0x10
} }
onModelReset: {
if (currentRoom)
{
var lastScrollPosition = mapFromSource(currentRoom.savedTopVisibleIndex())
if (lastScrollPosition === 0)
messageListView.positionViewAtBeginning()
else
{
console.log("Scrolling to position", lastScrollPosition)
messageListView.currentIndex = lastScrollPosition
}
if (messageListView.contentY < messageListView.originY + 10)
currentRoom.getPreviousContent(100)
}
console.log("Model timeline reset")
}
} }
delegate: ColumnLayout { delegate: ColumnLayout {