Spearate completion from ChatDocumentHandler

This commit is contained in:
James Graham
2025-12-23 16:22:09 +00:00
parent 02bed79265
commit 416d85af3b
13 changed files with 283 additions and 210 deletions

View File

@@ -150,7 +150,6 @@ QQC2.Control {
CompletionMenu {
id: completionMenu
chatDocumentHandler: contentModel.focusedDocumentHandler
connection: root.connection
x: 1
y: -height

View File

@@ -16,12 +16,7 @@ import org.kde.neochat
QQC2.Popup {
id: root
required property NeoChatConnection connection
required property var chatDocumentHandler
onChatDocumentHandlerChanged: if (chatDocumentHandler) {
chatDocumentHandler.completionModel.roomListModel = RoomManager.roomListModel;
chatDocumentHandler.completionModel.userListModel = RoomManager.userListModel;
}
visible: completions.count > 0
@@ -38,7 +33,7 @@ QQC2.Popup {
}
function complete() {
root.chatDocumentHandler.complete(completions.currentIndex);
root.chatDocumentHandler.insertCompletion(completions.currentItem.replacedText, completions.currentItem.hRef)
}
leftPadding: 0
@@ -65,7 +60,11 @@ QQC2.Popup {
ListView {
id: completions
model: root.chatDocumentHandler.completionModel
model: CompletionModel {
textItem: root.chatDocumentHandler.textItem
roomListModel: RoomManager.roomListModel
userListModel: RoomManager.userListModel
}
currentIndex: 0
keyNavigationWraps: true
highlightMoveDuration: 100
@@ -77,6 +76,8 @@ QQC2.Popup {
required property string displayName
required property string subtitle
required property string iconName
required property string replacedText
required property url hRef
text: displayName
@@ -96,7 +97,7 @@ QQC2.Popup {
subtitleItem.textFormat: Text.PlainText
}
}
onClicked: root.chatDocumentHandler.complete(completionDelegate.index)
onClicked: root.chatDocumentHandler.insertCompletion(replacedText, hRef)
}
}
}