Add button to thread to reply
{width=254 height=147}
This commit is contained in:
@@ -405,6 +405,7 @@ QHash<int, QByteArray> MessageContentModel::roleNames() const
|
||||
roles[ReplyEventIdRole] = "replyEventId";
|
||||
roles[ReplyAuthorRole] = "replyAuthor";
|
||||
roles[ReplyContentModelRole] = "replyContentModel";
|
||||
roles[ThreadRootRole] = "threadRoot";
|
||||
roles[LinkPreviewerRole] = "linkPreviewer";
|
||||
roles[ChatBarCacheRole] = "chatBarCache";
|
||||
return roles;
|
||||
|
||||
@@ -62,6 +62,8 @@ public:
|
||||
ReplyAuthorRole, /**< The author of the event that was replied to. */
|
||||
ReplyContentModelRole, /**< The MessageContentModel for the reply event. */
|
||||
|
||||
ThreadRootRole, /**< The thread root event ID for the event. */
|
||||
|
||||
LinkPreviewerRole, /**< The link preview details. */
|
||||
ChatBarCacheRole, /**< The ChatBarCache to use. */
|
||||
};
|
||||
|
||||
@@ -178,8 +178,14 @@ QVariant ThreadChatBarModel::data(const QModelIndex &idx, int role) const
|
||||
return {};
|
||||
}
|
||||
|
||||
const auto threadModel = dynamic_cast<ThreadModel *>(parent());
|
||||
if (threadModel == nullptr) {
|
||||
qWarning() << "ThreadChatBarModel created with incorrect parent, a ThreadModel must be set as the parent on creation.";
|
||||
return {};
|
||||
}
|
||||
|
||||
if (role == ComponentTypeRole) {
|
||||
return MessageComponentType::ChatBar;
|
||||
return m_room->threadCache()->threadId() == threadModel->threadRootId() ? MessageComponentType::ChatBar : MessageComponentType::ReplyButton;
|
||||
}
|
||||
if (role == ChatBarCacheRole) {
|
||||
if (m_room == nullptr) {
|
||||
@@ -187,20 +193,16 @@ QVariant ThreadChatBarModel::data(const QModelIndex &idx, int role) const
|
||||
}
|
||||
return QVariant::fromValue<ChatBarCache *>(m_room->threadCache());
|
||||
}
|
||||
if (role == ThreadRootRole) {
|
||||
return threadModel->threadRootId();
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
int ThreadChatBarModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent)
|
||||
if (m_room == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
const auto threadModel = dynamic_cast<ThreadModel *>(this->parent());
|
||||
if (threadModel != nullptr) {
|
||||
return m_room->threadCache()->threadId() == threadModel->threadRootId() ? 1 : 0;
|
||||
}
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
QHash<int, QByteArray> ThreadChatBarModel::roleNames() const
|
||||
@@ -208,6 +210,7 @@ QHash<int, QByteArray> ThreadChatBarModel::roleNames() const
|
||||
return {
|
||||
{ComponentTypeRole, "componentType"},
|
||||
{ChatBarCacheRole, "chatBarCache"},
|
||||
{ThreadRootRole, "threadRoot"},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ public:
|
||||
enum Roles {
|
||||
ComponentTypeRole = MessageContentModel::ComponentTypeRole, /**< The type of component to visualise the message. */
|
||||
ChatBarCacheRole = MessageContentModel::ChatBarCacheRole, /**< The ChatBarCache to use. */
|
||||
ThreadRootRole = MessageContentModel::ThreadRootRole, /**< The thread root event ID for the thread. */
|
||||
};
|
||||
Q_ENUM(Roles)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user