refactor: replace isCompletingEmoji with completionType

completionType (str) will tell completionListView
to load the correct delegate
This commit is contained in:
Srevin Saju
2021-05-01 13:33:55 +03:00
parent e234861ee6
commit 6781c0c964
2 changed files with 17 additions and 5 deletions

View File

@@ -5,6 +5,7 @@
import QtQuick 2.15
import QtQuick.Layouts 1.15
import QtQuick.Controls 2.15
import Qt.labs.qmlmodels 1.0
import org.kde.kirigami 2.15 as Kirigami
@@ -24,7 +25,7 @@ Popup {
property string currentDisplayText: currentItem && currentItem.displayName ? currentItem.displayName : ""
property string currentUserId: currentItem && currentItem.id ? currentItem.id : ""
property bool isCompletingEmoji: false
property string completionType: ""
property int beginPosition: 0
property int endPosition: 0
@@ -48,7 +49,15 @@ Popup {
ListView {
id: completionListView
implicitWidth: contentWidth
delegate: isCompletingEmoji ? emojiDelegate : usernameDelegate
delegate: {
if (completionType == "emoji") {
emojiDelegate
} else if (completionType == "command") {
commandDelegate
} else if (completionType == "username") {
usernameDelegate
}
}
keyNavigationWraps: true