Move showAuthor role to MessageModel, so it's available for all models
This fixes features like the search model, where no message delegates could be created because it's missing showAuthor.
This commit is contained in:
committed by
James Graham
parent
a67ce75924
commit
1d532a1fc1
@@ -92,7 +92,7 @@ QVariant MessageFilterModel::data(const QModelIndex &index, int role) const
|
||||
return authorList(mapToSource(index).row());
|
||||
} else if (role == ExcessAuthorsRole) {
|
||||
return excessAuthors(mapToSource(index).row());
|
||||
} else if (role == ShowAuthorRole) {
|
||||
} else if (role == MessageModel::ShowAuthorRole) {
|
||||
return showAuthor(index);
|
||||
}
|
||||
return QSortFilterProxyModel::data(index, role);
|
||||
@@ -105,7 +105,6 @@ QHash<int, QByteArray> MessageFilterModel::roleNames() const
|
||||
roles[StateEventsRole] = "stateEvents";
|
||||
roles[AuthorListRole] = "authorList";
|
||||
roles[ExcessAuthorsRole] = "excessAuthors";
|
||||
roles[ShowAuthorRole] = "showAuthor";
|
||||
return roles;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,6 @@ public:
|
||||
StateEventsRole, /**< List of state events in the aggregated state. */
|
||||
AuthorListRole, /**< List of the first 5 unique authors of the aggregated state event. */
|
||||
ExcessAuthorsRole, /**< The number of unique authors beyond the first 5. */
|
||||
ShowAuthorRole, /**< Whether the author of a message should be shown. */
|
||||
LastRole, // Keep this last
|
||||
};
|
||||
|
||||
|
||||
@@ -300,6 +300,10 @@ QVariant MessageModel::data(const QModelIndex &idx, int role) const
|
||||
&& event.value().get().senderId() == m_room->localMember().id();
|
||||
}
|
||||
|
||||
if (role == ShowAuthorRole) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -329,6 +333,7 @@ QHash<int, QByteArray> MessageModel::roleNames() const
|
||||
roles[ContentModelRole] = "contentModel";
|
||||
roles[MediaInfoRole] = "mediaInfo";
|
||||
roles[IsEditableRole] = "isEditable";
|
||||
roles[ShowAuthorRole] = "showAuthor";
|
||||
return roles;
|
||||
}
|
||||
|
||||
|
||||
@@ -84,6 +84,7 @@ public:
|
||||
IsRedactedRole, /**< Whether an event has been deleted. */
|
||||
IsPendingRole, /**< Whether an event is waiting to be accepted by the server. */
|
||||
IsEditableRole, /**< Whether the event can be edited by the user. */
|
||||
ShowAuthorRole, /**< Whether the author of a message should be shown. */
|
||||
LastRole, // Keep this last
|
||||
};
|
||||
Q_ENUM(EventRoles)
|
||||
|
||||
Reference in New Issue
Block a user