Simplify some auto completion logic.
This commit is contained in:
parent
a865aaabb1
commit
c19f49a898
|
@ -1,16 +1,15 @@
|
||||||
import QtQuick 2.9
|
import QtQuick 2.9
|
||||||
|
|
||||||
RoomPanelForm {
|
RoomPanelForm {
|
||||||
roomHeader.onClicked: roomDrawer.open()
|
|
||||||
roomHeader.image: spectralController.safeImage(currentRoom ? currentRoom.avatar : null)
|
roomHeader.image: spectralController.safeImage(currentRoom ? currentRoom.avatar : null)
|
||||||
roomHeader.topic: currentRoom ? (currentRoom.topic).replace(/(\r\n\t|\n|\r\t)/gm,"") : ""
|
roomHeader.topic: currentRoom ? (currentRoom.topic).replace(/(\r\n\t|\n|\r\t)/gm,"") : ""
|
||||||
|
roomHeader.onClicked: roomDrawer.open()
|
||||||
|
|
||||||
sortedMessageEventModel.onModelReset: {
|
sortedMessageEventModel.onModelReset: {
|
||||||
if (currentRoom) {
|
if (currentRoom) {
|
||||||
var lastScrollPosition = sortedMessageEventModel.mapFromSource(currentRoom.savedTopVisibleIndex())
|
var lastScrollPosition = sortedMessageEventModel.mapFromSource(currentRoom.savedTopVisibleIndex())
|
||||||
console.log("Scrolling to position", lastScrollPosition)
|
|
||||||
messageListView.currentIndex = lastScrollPosition
|
messageListView.currentIndex = lastScrollPosition
|
||||||
if (messageListView.contentY < messageListView.originY + 10 || messageListView.contentHeight < messageListView.height || currentRoom.timelineSize === 0)
|
if (messageListView.contentY < messageListView.originY + 10 || currentRoom.timelineSize < 20)
|
||||||
currentRoom.getPreviousContent(100)
|
currentRoom.getPreviousContent(100)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,6 +51,7 @@ Rectangle {
|
||||||
clip: true
|
clip: true
|
||||||
orientation: ListView.Horizontal
|
orientation: ListView.Horizontal
|
||||||
highlightFollowsCurrentItem: true
|
highlightFollowsCurrentItem: true
|
||||||
|
keyNavigationWraps: true
|
||||||
|
|
||||||
highlight: Rectangle {
|
highlight: Rectangle {
|
||||||
color: Material.accent
|
color: Material.accent
|
||||||
|
@ -205,17 +206,11 @@ Rectangle {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Keys.onBacktabPressed: {
|
Keys.onBacktabPressed: if (isAutoCompleting) autoCompleteListView.decrementCurrentIndex()
|
||||||
if (isAutoCompleting) {
|
|
||||||
if (autoCompleteListView.currentIndex == 0) autoCompleteListView.currentIndex = autoCompleteListView.count - 1
|
|
||||||
else autoCompleteListView.currentIndex--
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Keys.onTabPressed: {
|
Keys.onTabPressed: {
|
||||||
if (isAutoCompleting) {
|
if (isAutoCompleting) {
|
||||||
if (autoCompleteListView.currentIndex + 1 == autoCompleteListView.count) autoCompleteListView.currentIndex = 0
|
autoCompleteListView.incrementCurrentIndex()
|
||||||
else autoCompleteListView.currentIndex++
|
|
||||||
} else {
|
} else {
|
||||||
autoCompleteBeginPosition = text.substring(0, cursorPosition).lastIndexOf(" ") + 1
|
autoCompleteBeginPosition = text.substring(0, cursorPosition).lastIndexOf(" ") + 1
|
||||||
var autoCompletePrefix = text.substring(0, cursorPosition).split(" ").pop()
|
var autoCompletePrefix = text.substring(0, cursorPosition).split(" ").pop()
|
||||||
|
|
Loading…
Reference in New Issue