Message attached property

Create Message attached property to propagate parameters like room, timeline, index and maxContentWidth down to the message content avoiding lots of boilerplate
This commit is contained in:
James Graham
2025-03-10 18:28:42 +00:00
parent ea6ad902a7
commit 2aeed10429
32 changed files with 310 additions and 447 deletions

View File

@@ -22,16 +22,6 @@ import org.kde.neochat
QQC2.Control {
id: root
/**
* @brief The NeoChatRoom the delegate is being displayed in.
*/
required property NeoChatRoom room
/**
* @brief The index of the delegate in the model.
*/
required property var index
/**
* @brief The message author.
*
@@ -66,23 +56,8 @@ QQC2.Control {
*/
property alias showBackground: bubbleBackground.visible
/**
* @brief The timeline ListView this component is being used in.
*/
required property ListView timeline
/**
* @brief The maximum width that the bubble's content can be.
*/
property real maxContentWidth: -1
required property bool isPending
/**
* @brief The reply has been clicked.
*/
signal replyClicked(string eventID)
/**
* @brief The user selected text has changed.
*/
@@ -108,6 +83,7 @@ QQC2.Control {
ColumnLayout {
id: contentColumn
spacing: Kirigami.Units.smallSpacing
Repeater {
id: contentRepeater
model: MessageContentFilterModel {
@@ -115,14 +91,6 @@ QQC2.Control {
sourceModel: root.contentModel
}
delegate: MessageComponentChooser {
room: root.room
index: root.index
timeline: root.timeline
maxContentWidth: root.maxContentWidth
onReplyClicked: eventId => {
root.replyClicked(eventId);
}
onSelectedTextChanged: selectedText => {
root.selectedTextChanged(selectedText);
}