Use enum instead of strings for message type

This commit is contained in:
Tobias Fella
2022-11-01 21:15:44 +01:00
committed by Carl Schwan
parent bba947e508
commit 92ec441594
9 changed files with 69 additions and 53 deletions

View File

@@ -14,64 +14,64 @@ DelegateChooser {
role: "eventType"
DelegateChoice {
roleValue: "state"
roleValue: MessageEventModel.State
delegate: StateDelegate {}
}
DelegateChoice {
roleValue: "emote"
roleValue: MessageEventModel.Emote
delegate: MessageDelegate {
isEmote: true
}
}
DelegateChoice {
roleValue: "message"
roleValue: MessageEventModel.Message
delegate: MessageDelegate {}
}
DelegateChoice {
roleValue: "notice"
roleValue: MessageEventModel.Notice
delegate: MessageDelegate {}
}
DelegateChoice {
roleValue: "image"
roleValue: MessageEventModel.Image
delegate: ImageDelegate {}
}
DelegateChoice {
roleValue: "sticker"
roleValue: MessageEventModel.Sticker
delegate: ImageDelegate {}
}
DelegateChoice {
roleValue: "audio"
roleValue: MessageEventModel.Audio
delegate: AudioDelegate {}
}
DelegateChoice {
roleValue: "video"
roleValue: MessageEventModel.Video
delegate: VideoDelegate {}
}
DelegateChoice {
roleValue: "file"
roleValue: MessageEventModel.File
delegate: FileDelegate {}
}
DelegateChoice {
roleValue: "encrypted"
roleValue: MessageEventModel.Encrypted
delegate: EncryptedDelegate {}
}
DelegateChoice {
roleValue: "readMarker"
roleValue: MessageEventModel.ReadMarker
delegate: ReadMarkerDelegate {}
}
DelegateChoice {
roleValue: "other"
roleValue: MessageEventModel.Other
delegate: Item {}
}
}

View File

@@ -65,17 +65,17 @@ Item {
sourceComponent: {
switch (reply.type) {
case "image":
case "sticker":
case MessageEventModel.Image:
case MessageEventModel.Sticker:
return imageComponent;
case "message":
case "notice":
case MessageEventModel.Message:
case MessageEventModel.Notice:
return textComponent;
case "file":
case "video":
case "audio":
case MessageEventModel.File:
case MessageEventModel.Video:
case MessageEventModel.Audio:
return mimeComponent;
case "encrypted":
case MessageEventModel.Encrypted:
return encryptedComponent;
default:
return textComponent;
@@ -114,7 +114,7 @@ Item {
MimeComponent {
mimeIconSource: reply.content.info.mimetype.replace("/", "-")
label: reply.display
subLabel: reply.type === "file" ? Controller.formatByteSize(reply.content.info ? reply.content.info.size : 0) : Controller.formatDuration(reply.content.info.duration)
subLabel: reply.type === MessageEventModel.File ? Controller.formatByteSize(reply.content.info ? reply.content.info.size : 0) : Controller.formatDuration(reply.content.info.duration)
}
}
Component {

View File

@@ -308,7 +308,7 @@ QQC2.ItemDelegate {
}
height: active ? item.implicitHeight : 0
//Layout.bottomMargin: readMarker ? Kirigami.Units.smallSpacing : 0
active: eventType !== "state" && eventType !== "notice" && reaction != undefined && reaction.length > 0
active: eventType !== MessageEventModel.State && eventType !== MessageEventModel.Notice && reaction != undefined && reaction.length > 0
visible: active
sourceComponent: ReactionDelegate { }
}