Pass room through the model, not when creating the delegate
This is another thing that enables us to view multiple rooms in a single timeline. Specifically, this improves the experience in room search going across room versions and getting a correct readOnly status (for hiding certain hover actions.)
This commit is contained in:
@@ -52,7 +52,6 @@ QQC2.ScrollView {
|
|||||||
delegate: Timeline.MessageDelegate {
|
delegate: Timeline.MessageDelegate {
|
||||||
alwaysFillWidth: true
|
alwaysFillWidth: true
|
||||||
cardBackground: false
|
cardBackground: false
|
||||||
room: root.room
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,7 +60,6 @@ QQC2.ScrollView {
|
|||||||
delegate: Timeline.MessageDelegate {
|
delegate: Timeline.MessageDelegate {
|
||||||
alwaysFillWidth: true
|
alwaysFillWidth: true
|
||||||
cardBackground: false
|
cardBackground: false
|
||||||
room: root.room
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,16 +21,12 @@ DelegateChooser {
|
|||||||
|
|
||||||
DelegateChoice {
|
DelegateChoice {
|
||||||
roleValue: DelegateType.State
|
roleValue: DelegateType.State
|
||||||
delegate: StateDelegate {
|
delegate: StateDelegate {}
|
||||||
room: root.room
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DelegateChoice {
|
DelegateChoice {
|
||||||
roleValue: DelegateType.Message
|
roleValue: DelegateType.Message
|
||||||
delegate: MessageDelegate {
|
delegate: MessageDelegate {}
|
||||||
room: root.room
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DelegateChoice {
|
DelegateChoice {
|
||||||
@@ -45,23 +41,17 @@ DelegateChooser {
|
|||||||
|
|
||||||
DelegateChoice {
|
DelegateChoice {
|
||||||
roleValue: DelegateType.Predecessor
|
roleValue: DelegateType.Predecessor
|
||||||
delegate: PredecessorDelegate {
|
delegate: PredecessorDelegate {}
|
||||||
room: root.room
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DelegateChoice {
|
DelegateChoice {
|
||||||
roleValue: DelegateType.Successor
|
roleValue: DelegateType.Successor
|
||||||
delegate: SuccessorDelegate {
|
delegate: SuccessorDelegate {}
|
||||||
room: root.room
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DelegateChoice {
|
DelegateChoice {
|
||||||
roleValue: DelegateType.TimelineEnd
|
roleValue: DelegateType.TimelineEnd
|
||||||
delegate: TimelineEndDelegate {
|
delegate: TimelineEndDelegate {}
|
||||||
room: root.room
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DelegateChoice {
|
DelegateChoice {
|
||||||
@@ -75,9 +65,7 @@ DelegateChooser {
|
|||||||
|
|
||||||
Component {
|
Component {
|
||||||
id: hiddenDelegate
|
id: hiddenDelegate
|
||||||
HiddenDelegate {
|
HiddenDelegate {}
|
||||||
room: root.room
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Component {
|
Component {
|
||||||
id: emptyDelegate
|
id: emptyDelegate
|
||||||
|
|||||||
@@ -326,6 +326,10 @@ QVariant MessageModel::data(const QModelIndex &idx, int role) const
|
|||||||
return event.value().get().matrixType();
|
return event.value().get().matrixType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (role == RoomRole) {
|
||||||
|
return QVariant::fromValue(eventRoom);
|
||||||
|
}
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -356,6 +360,7 @@ QHash<int, QByteArray> MessageModel::roleNames() const
|
|||||||
roles[IsEditableRole] = "isEditable";
|
roles[IsEditableRole] = "isEditable";
|
||||||
roles[ShowAuthorRole] = "showAuthor";
|
roles[ShowAuthorRole] = "showAuthor";
|
||||||
roles[EventTypeRole] = "eventType";
|
roles[EventTypeRole] = "eventType";
|
||||||
|
roles[RoomRole] = "room";
|
||||||
return roles;
|
return roles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ public:
|
|||||||
IsEditableRole, /**< Whether the event can be edited by the user. */
|
IsEditableRole, /**< Whether the event can be edited by the user. */
|
||||||
ShowAuthorRole, /**< Whether the author of a message should be shown. */
|
ShowAuthorRole, /**< Whether the author of a message should be shown. */
|
||||||
EventTypeRole, /**< The matrix event type of this message. */
|
EventTypeRole, /**< The matrix event type of this message. */
|
||||||
|
RoomRole, /**< The room this event is from. */
|
||||||
LastRole, // Keep this last
|
LastRole, // Keep this last
|
||||||
};
|
};
|
||||||
Q_ENUM(EventRoles)
|
Q_ENUM(EventRoles)
|
||||||
|
|||||||
Reference in New Issue
Block a user