Release threads removing the feature flag.
This mr performs some final cleanup to make sure the threads are sized correctly and it all works with the new chatbar
This commit is contained in:
committed by
Joshua Goins
parent
85b731e9fb
commit
7e6b79d5d4
@@ -207,10 +207,6 @@
|
|||||||
</entry>
|
</entry>
|
||||||
</group>
|
</group>
|
||||||
<group name="FeatureFlags">
|
<group name="FeatureFlags">
|
||||||
<entry name="Threads" type="bool">
|
|
||||||
<label>Enable threads</label>
|
|
||||||
<default>false</default>
|
|
||||||
</entry>
|
|
||||||
<entry name="Phone3PId" type="bool">
|
<entry name="Phone3PId" type="bool">
|
||||||
<label>Enable add phone numbers as 3PIDs</label>
|
<label>Enable add phone numbers as 3PIDs</label>
|
||||||
<default>false</default>
|
<default>false</default>
|
||||||
|
|||||||
@@ -129,15 +129,6 @@ RoomManager::RoomManager(QObject *parent)
|
|||||||
m_messageFilterModel->invalidate();
|
m_messageFilterModel->invalidate();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
ContentProvider::self().setThreadsEnabled(NeoChatConfig::threads());
|
|
||||||
MessageModel::setThreadsEnabled(NeoChatConfig::threads());
|
|
||||||
connect(NeoChatConfig::self(), &NeoChatConfig::ThreadsChanged, this, [this] {
|
|
||||||
ContentProvider::self().setThreadsEnabled(NeoChatConfig::threads());
|
|
||||||
MessageModel::setThreadsEnabled(NeoChatConfig::threads());
|
|
||||||
if (m_timelineModel) {
|
|
||||||
Q_EMIT m_timelineModel->threadsEnabledChanged();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
connect(NeoChatConfig::self(), &NeoChatConfig::SortOrderChanged, this, [this]() {
|
connect(NeoChatConfig::self(), &NeoChatConfig::SortOrderChanged, this, [this]() {
|
||||||
m_sortFilterRoomTreeModel->invalidate();
|
m_sortFilterRoomTreeModel->invalidate();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -99,7 +99,6 @@ RowLayout {
|
|||||||
|
|
||||||
visible: root.maxAvailableWidth < root.overflowWidth && (root.contentModel?.type ?? true) === LibNeoChat.ChatBarType.Room
|
visible: root.maxAvailableWidth < root.overflowWidth && (root.contentModel?.type ?? true) === LibNeoChat.ChatBarType.Room
|
||||||
icon.name: "overflow-menu"
|
icon.name: "overflow-menu"
|
||||||
enabled: root.chatButtonHelper.richFormatEnabled
|
|
||||||
text: i18nc("@action:button", "Format Text")
|
text: i18nc("@action:button", "Format Text")
|
||||||
display: QQC2.AbstractButton.IconOnly
|
display: QQC2.AbstractButton.IconOnly
|
||||||
checkable: true
|
checkable: true
|
||||||
@@ -153,7 +152,9 @@ RowLayout {
|
|||||||
}
|
}
|
||||||
QQC2.ToolButton {
|
QQC2.ToolButton {
|
||||||
id: attachmentButton
|
id: attachmentButton
|
||||||
visible: !root.contentModel.hasAttachment && (root.contentModel?.type ?? true) === LibNeoChat.ChatBarType.Room && root.maxAvailableWidth >= root.overflowWidth
|
visible: !root.contentModel.hasAttachment &&
|
||||||
|
((root.contentModel?.type ?? true) === LibNeoChat.ChatBarType.Room || (root.contentModel?.type ?? true) === LibNeoChat.ChatBarType.Thread) &&
|
||||||
|
root.maxAvailableWidth >= root.overflowWidth
|
||||||
icon.name: "mail-attachment"
|
icon.name: "mail-attachment"
|
||||||
text: i18nc("@action:button", "Attach an image or file")
|
text: i18nc("@action:button", "Attach an image or file")
|
||||||
display: QQC2.AbstractButton.IconOnly
|
display: QQC2.AbstractButton.IconOnly
|
||||||
|
|||||||
@@ -14,13 +14,6 @@ FormCard.FormCard {
|
|||||||
|
|
||||||
Layout.topMargin: Kirigami.Units.largeSpacing
|
Layout.topMargin: Kirigami.Units.largeSpacing
|
||||||
|
|
||||||
FormCard.FormCheckDelegate {
|
|
||||||
id: roomAccountDataVisibleCheck
|
|
||||||
text: i18nc("@option:check Enable the matrix 'threads' feature", "Threads")
|
|
||||||
checked: NeoChatConfig.threads
|
|
||||||
|
|
||||||
onToggled: NeoChatConfig.threads = checked
|
|
||||||
}
|
|
||||||
FormCard.FormCheckDelegate {
|
FormCard.FormCheckDelegate {
|
||||||
text: i18nc("@option:check Enable the matrix feature to add a phone number as a third party ID", "Add phone numbers as 3PIDs")
|
text: i18nc("@option:check Enable the matrix feature to add a phone number as a third party ID", "Add phone numbers as 3PIDs")
|
||||||
checked: NeoChatConfig.phone3PId
|
checked: NeoChatConfig.phone3PId
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ ecm_add_qml_module(MessageContent GENERATE_PLUGIN_SOURCE
|
|||||||
BaseMessageComponentChooser.qml
|
BaseMessageComponentChooser.qml
|
||||||
MessageComponentChooser.qml
|
MessageComponentChooser.qml
|
||||||
ReplyMessageComponentChooser.qml
|
ReplyMessageComponentChooser.qml
|
||||||
|
ThreadBodyMessageComponentChooser.qml
|
||||||
AuthorComponent.qml
|
AuthorComponent.qml
|
||||||
AudioComponent.qml
|
AudioComponent.qml
|
||||||
CodeComponent.qml
|
CodeComponent.qml
|
||||||
|
|||||||
@@ -29,10 +29,16 @@ BaseMessageComponentChooser {
|
|||||||
DelegateChoice {
|
DelegateChoice {
|
||||||
roleValue: MessageComponentType.ChatBar
|
roleValue: MessageComponentType.ChatBar
|
||||||
delegate: ChatBarCore {
|
delegate: ChatBarCore {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The ChatBarCache to use.
|
||||||
|
*/
|
||||||
|
required property ChatBarCache chatBarCache
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.maximumWidth: Message.maxContentWidth
|
Layout.maximumWidth: Message.maxContentWidth
|
||||||
room: Message.room
|
room: Message.room
|
||||||
chatBarType: LibNeoChat.ChatBarType.Edit
|
chatBarType: chatBarCache.isEditing ? LibNeoChat.ChatBarType.Edit : LibNeoChat.ChatBarType.Thread
|
||||||
maxAvailableWidth: Message.maxContentWidth
|
maxAvailableWidth: Message.maxContentWidth
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ ColumnLayout {
|
|||||||
id: threadRepeater
|
id: threadRepeater
|
||||||
model: root.Message.contentModel.modelForThread(root.threadRoot);
|
model: root.Message.contentModel.modelForThread(root.threadRoot);
|
||||||
|
|
||||||
delegate: BaseMessageComponentChooser {
|
delegate: ThreadBodyMessageComponentChooser {
|
||||||
onSelectedTextChanged: selectedText => {
|
onSelectedTextChanged: selectedText => {
|
||||||
root.selectedTextChanged(selectedText);
|
root.selectedTextChanged(selectedText);
|
||||||
}
|
}
|
||||||
|
|||||||
27
src/messagecontent/ThreadBodyMessageComponentChooser.qml
Normal file
27
src/messagecontent/ThreadBodyMessageComponentChooser.qml
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
// SPDX-FileCopyrightText: 2026 James Graham <james.h.graham@protonmail.com>
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
||||||
|
|
||||||
|
import QtQuick
|
||||||
|
import QtQuick.Layouts
|
||||||
|
import Qt.labs.qmlmodels
|
||||||
|
|
||||||
|
import org.kde.neochat
|
||||||
|
import org.kde.neochat.libneochat as LibNeoChat
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Select a message component based on a MessageComponentType.
|
||||||
|
*/
|
||||||
|
BaseMessageComponentChooser {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
DelegateChoice {
|
||||||
|
roleValue: MessageComponentType.ChatBar
|
||||||
|
delegate: ChatBarCore {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.maximumWidth: Message.maxContentWidth
|
||||||
|
room: Message.room
|
||||||
|
chatBarType: LibNeoChat.ChatBarType.Thread
|
||||||
|
maxAvailableWidth: Message.maxContentWidth
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -113,13 +113,4 @@ PollHandler *ContentProvider::handlerForPoll(NeoChatRoom *room, const QString &e
|
|||||||
return m_pollHandlers.object(eventId);
|
return m_pollHandlers.object(eventId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentProvider::setThreadsEnabled(bool enableThreads)
|
|
||||||
{
|
|
||||||
EventMessageContentModel::setThreadsEnabled(enableThreads);
|
|
||||||
|
|
||||||
for (const auto &key : m_eventContentModels.keys()) {
|
|
||||||
m_eventContentModels.object(key)->threadsEnabledChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#include "moc_contentprovider.cpp"
|
#include "moc_contentprovider.cpp"
|
||||||
|
|||||||
@@ -81,8 +81,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
Q_INVOKABLE PollHandler *handlerForPoll(NeoChatRoom *room, const QString &eventId);
|
Q_INVOKABLE PollHandler *handlerForPoll(NeoChatRoom *room, const QString &eventId);
|
||||||
|
|
||||||
void setThreadsEnabled(bool enableThreads);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit ContentProvider(QObject *parent = nullptr);
|
explicit ContentProvider(QObject *parent = nullptr);
|
||||||
|
|
||||||
|
|||||||
@@ -22,8 +22,6 @@
|
|||||||
|
|
||||||
using namespace Quotient;
|
using namespace Quotient;
|
||||||
|
|
||||||
bool EventMessageContentModel::m_threadsEnabled = false;
|
|
||||||
|
|
||||||
EventMessageContentModel::EventMessageContentModel(NeoChatRoom *room, const QString &eventId, bool isReply, bool isPending, MessageContentModel *parent)
|
EventMessageContentModel::EventMessageContentModel(NeoChatRoom *room, const QString &eventId, bool isReply, bool isPending, MessageContentModel *parent)
|
||||||
: MessageContentModel(room, eventId, parent)
|
: MessageContentModel(room, eventId, parent)
|
||||||
, m_currentState(isPending ? Pending : Unknown)
|
, m_currentState(isPending ? Pending : Unknown)
|
||||||
@@ -104,9 +102,6 @@ void EventMessageContentModel::initializeModel()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
connect(this, &EventMessageContentModel::threadsEnabledChanged, this, [this]() {
|
|
||||||
resetModel();
|
|
||||||
});
|
|
||||||
connect(m_room, &Room::updatedEvent, this, [this](const QString &eventId) {
|
connect(m_room, &Room::updatedEvent, this, [this](const QString &eventId) {
|
||||||
if (eventId == m_eventId) {
|
if (eventId == m_eventId) {
|
||||||
updateReactionModel();
|
updateReactionModel();
|
||||||
@@ -304,7 +299,7 @@ QList<MessageComponent> EventMessageContentModel::messageContentComponents(bool
|
|||||||
}
|
}
|
||||||
|
|
||||||
const auto roomMessageEvent = eventCast<const Quotient::RoomMessageEvent>(event.first);
|
const auto roomMessageEvent = eventCast<const Quotient::RoomMessageEvent>(event.first);
|
||||||
if (m_threadsEnabled && roomMessageEvent
|
if (roomMessageEvent
|
||||||
&& ((roomMessageEvent->isThreaded() && roomMessageEvent->id() == roomMessageEvent->threadRootEventId())
|
&& ((roomMessageEvent->isThreaded() && roomMessageEvent->id() == roomMessageEvent->threadRootEventId())
|
||||||
|| m_room->threads().contains(roomMessageEvent->id()))) {
|
|| m_room->threads().contains(roomMessageEvent->id()))) {
|
||||||
newComponents += MessageComponent{MessageComponentType::Separator, {}, {}};
|
newComponents += MessageComponent{MessageComponentType::Separator, {}, {}};
|
||||||
@@ -328,14 +323,14 @@ std::optional<QString> EventMessageContentModel::getReplyEventId()
|
|||||||
if (roomMessageEvent == nullptr) {
|
if (roomMessageEvent == nullptr) {
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
if (!roomMessageEvent->isReply(!m_threadsEnabled)) {
|
if (!roomMessageEvent->isReply()) {
|
||||||
if (m_replyModel) {
|
if (m_replyModel) {
|
||||||
m_replyModel->disconnect(this);
|
m_replyModel->disconnect(this);
|
||||||
m_replyModel->deleteLater();
|
m_replyModel->deleteLater();
|
||||||
}
|
}
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
return roomMessageEvent->isReply(!m_threadsEnabled) ? std::make_optional(roomMessageEvent->replyEventId(!m_threadsEnabled)) : std::nullopt;
|
return roomMessageEvent->isReply() ? std::make_optional(roomMessageEvent->replyEventId()) : std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<MessageComponent> EventMessageContentModel::componentsForType(MessageComponentType::Type type)
|
QList<MessageComponent> EventMessageContentModel::componentsForType(MessageComponentType::Type type)
|
||||||
@@ -475,9 +470,4 @@ ThreadModel *EventMessageContentModel::modelForThread(const QString &threadRootI
|
|||||||
return ContentProvider::self().modelForThread(m_room, threadRootId);
|
return ContentProvider::self().modelForThread(m_room, threadRootId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventMessageContentModel::setThreadsEnabled(bool enableThreads)
|
|
||||||
{
|
|
||||||
m_threadsEnabled = enableThreads;
|
|
||||||
}
|
|
||||||
|
|
||||||
#include "moc_eventmessagecontentmodel.cpp"
|
#include "moc_eventmessagecontentmodel.cpp"
|
||||||
|
|||||||
@@ -43,11 +43,8 @@ public:
|
|||||||
*/
|
*/
|
||||||
Q_INVOKABLE ThreadModel *modelForThread(const QString &threadRootId);
|
Q_INVOKABLE ThreadModel *modelForThread(const QString &threadRootId);
|
||||||
|
|
||||||
static void setThreadsEnabled(bool enableThreads);
|
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void eventUpdated();
|
void eventUpdated();
|
||||||
void threadsEnabledChanged();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initializeModel();
|
void initializeModel();
|
||||||
@@ -74,6 +71,4 @@ private:
|
|||||||
void updateItineraryModel();
|
void updateItineraryModel();
|
||||||
|
|
||||||
void updateReactionModel();
|
void updateReactionModel();
|
||||||
|
|
||||||
static bool m_threadsEnabled;
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ KirigamiComponents.ConvergentContextMenu {
|
|||||||
|
|
||||||
Kirigami.Action {
|
Kirigami.Action {
|
||||||
id: replyThreadAction
|
id: replyThreadAction
|
||||||
visible: (root.messageComponentType !== MessageComponentType.Other || NeoChatConfig.relateAnyEvent) && NeoChatConfig.threads
|
visible: (root.messageComponentType !== MessageComponentType.Other || NeoChatConfig.relateAnyEvent)
|
||||||
text: i18nc("@action:inmenu", "Reply in Thread")
|
text: i18nc("@action:inmenu", "Reply in Thread")
|
||||||
icon.name: "dialog-messages"
|
icon.name: "dialog-messages"
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
|
|||||||
@@ -87,7 +87,6 @@ void MessageDelegateBase::setIsThreaded(bool isThreaded)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_isThreaded = isThreaded;
|
m_isThreaded = isThreaded;
|
||||||
setAlwaysFillWidth(m_isThreaded || m_compactMode);
|
|
||||||
setPercentageValues(m_isThreaded || m_compactMode);
|
setPercentageValues(m_isThreaded || m_compactMode);
|
||||||
updateAvatar();
|
updateAvatar();
|
||||||
Q_EMIT isThreadedChanged();
|
Q_EMIT isThreadedChanged();
|
||||||
@@ -138,11 +137,8 @@ void MessageDelegateBase::setPercentageValues(bool fillWidth)
|
|||||||
|
|
||||||
void MessageDelegateBase::setContentPadding()
|
void MessageDelegateBase::setContentPadding()
|
||||||
{
|
{
|
||||||
qreal selectionOffset = (m_showSelection && m_selectionItem) ? m_selectionItem->implicitWidth() + (m_spacing * 2) : 0;
|
m_contentSizeHelper.setLeftPadding(m_sizeHelper.leftX());
|
||||||
qreal avatarOffset = (leaveAvatarSpace() ? m_avatarSize + m_spacing : 0);
|
m_contentSizeHelper.setRightPadding(m_compactMode ? m_sizeHelper.rightPadding() : 0);
|
||||||
|
|
||||||
m_contentSizeHelper.setLeftPadding(m_sizeHelper.leftX() + selectionOffset + avatarOffset);
|
|
||||||
m_contentSizeHelper.setRightPadding(m_sizeHelper.rightPadding());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal MessageDelegateBase::maxContentWidth() const
|
qreal MessageDelegateBase::maxContentWidth() const
|
||||||
@@ -229,7 +225,7 @@ bool MessageDelegateBase::leaveAvatarSpace() const
|
|||||||
|
|
||||||
bool MessageDelegateBase::showAvatar() const
|
bool MessageDelegateBase::showAvatar() const
|
||||||
{
|
{
|
||||||
return m_enableAvatars && m_showAuthor && !showMessageOnRight();
|
return m_enableAvatars && (m_showAuthor || m_isThreaded) && !showMessageOnRight();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageDelegateBase::updateAvatar()
|
void MessageDelegateBase::updateAvatar()
|
||||||
@@ -434,7 +430,7 @@ void MessageDelegateBase::setCompactMode(bool compactMode)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_compactMode = compactMode;
|
m_compactMode = compactMode;
|
||||||
setAlwaysFillWidth(m_isThreaded || m_compactMode);
|
setAlwaysFillWidth(m_compactMode);
|
||||||
setPercentageValues(m_isThreaded || m_compactMode);
|
setPercentageValues(m_isThreaded || m_compactMode);
|
||||||
setBaseRightPadding();
|
setBaseRightPadding();
|
||||||
|
|
||||||
@@ -669,7 +665,7 @@ void MessageDelegateBase::updateImplicitHeight()
|
|||||||
|
|
||||||
bool MessageDelegateBase::showMessageOnRight() const
|
bool MessageDelegateBase::showMessageOnRight() const
|
||||||
{
|
{
|
||||||
return m_showLocalMessagesOnRight && !m_alwaysFillWidth && m_author && m_author->isLocalMember();
|
return m_showLocalMessagesOnRight && !m_compactMode && !m_isThreaded && m_author && m_author->isLocalMember();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageDelegateBase::resizeContent()
|
void MessageDelegateBase::resizeContent()
|
||||||
@@ -697,22 +693,25 @@ void MessageDelegateBase::resizeContent()
|
|||||||
nextY += m_sectionItem->implicitHeight() + m_spacing;
|
nextY += m_sectionItem->implicitHeight() + m_spacing;
|
||||||
}
|
}
|
||||||
qreal yAdd = 0.0;
|
qreal yAdd = 0.0;
|
||||||
|
qreal nextX = m_sizeHelper.leftX();
|
||||||
if (m_showSelection && m_selectionItem) {
|
if (m_showSelection && m_selectionItem) {
|
||||||
m_selectionItem->setPosition(QPointF(m_sizeHelper.leftX(), nextY));
|
m_selectionItem->setPosition(QPointF(nextX, nextY));
|
||||||
m_selectionItem->setSize(QSizeF(m_selectionItem->implicitWidth(), m_selectionItem->implicitHeight()));
|
m_selectionItem->setSize(QSizeF(m_selectionItem->implicitWidth(), m_selectionItem->implicitHeight()));
|
||||||
yAdd = m_selectionItem->implicitHeight();
|
yAdd = m_selectionItem->implicitHeight();
|
||||||
|
nextX += m_selectionItem->implicitWidth() + m_spacing;
|
||||||
}
|
}
|
||||||
if (showAvatar() && m_avatarItem) {
|
if (showAvatar() && m_avatarItem) {
|
||||||
m_avatarItem->setPosition(
|
m_avatarItem->setPosition(QPointF(nextX, nextY));
|
||||||
QPointF(m_showSelection && m_selectionItem ? m_sizeHelper.leftX() + m_selectionItem->implicitWidth() + (m_spacing * 2) : m_sizeHelper.leftX(),
|
|
||||||
nextY));
|
|
||||||
m_avatarItem->setSize(QSizeF(m_avatarItem->implicitWidth(), m_avatarItem->implicitHeight()));
|
m_avatarItem->setSize(QSizeF(m_avatarItem->implicitWidth(), m_avatarItem->implicitHeight()));
|
||||||
yAdd = std::max(yAdd, m_avatarItem->implicitHeight());
|
yAdd = std::max(yAdd, m_avatarItem->implicitHeight());
|
||||||
|
nextX += m_avatarItem->implicitWidth() + m_spacing;
|
||||||
|
} else if (leaveAvatarSpace()) {
|
||||||
|
nextX += m_avatarSize + m_spacing;
|
||||||
}
|
}
|
||||||
if (m_contentItem) {
|
if (m_contentItem) {
|
||||||
const auto contentItemWidth =
|
const auto contentItemWidth = m_compactMode || m_isThreaded ? m_contentSizeHelper.availableWidth() - nextX
|
||||||
m_alwaysFillWidth ? m_contentSizeHelper.availableWidth() : std::min(m_contentItem->implicitWidth(), m_contentSizeHelper.availableWidth());
|
: std::min(m_contentItem->implicitWidth(), m_contentSizeHelper.availableWidth());
|
||||||
const auto contentX = showMessageOnRight() ? m_sizeHelper.rightX() - contentItemWidth - 1 : m_contentSizeHelper.leftPadding();
|
const auto contentX = showMessageOnRight() ? m_sizeHelper.rightX() - contentItemWidth - 1 : nextX;
|
||||||
m_contentItem->setPosition(QPointF(contentX, nextY));
|
m_contentItem->setPosition(QPointF(contentX, nextY));
|
||||||
m_contentItem->setSize(QSizeF(contentItemWidth, m_contentItem->implicitHeight()));
|
m_contentItem->setSize(QSizeF(contentItemWidth, m_contentItem->implicitHeight()));
|
||||||
yAdd = std::max(yAdd, m_contentItem->implicitHeight());
|
yAdd = std::max(yAdd, m_contentItem->implicitHeight());
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ using namespace Quotient;
|
|||||||
std::function<bool(const Quotient::RoomEvent *)> MessageModel::m_hiddenFilter = [](const Quotient::RoomEvent *) -> bool {
|
std::function<bool(const Quotient::RoomEvent *)> MessageModel::m_hiddenFilter = [](const Quotient::RoomEvent *) -> bool {
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
bool MessageModel::m_threadsEnabled = false;
|
|
||||||
|
|
||||||
MessageModel::MessageModel(QObject *parent)
|
MessageModel::MessageModel(QObject *parent)
|
||||||
: QAbstractListModel(parent)
|
: QAbstractListModel(parent)
|
||||||
@@ -40,10 +39,6 @@ MessageModel::MessageModel(QObject *parent)
|
|||||||
connect(this, &MessageModel::modelReset, this, [this]() {
|
connect(this, &MessageModel::modelReset, this, [this]() {
|
||||||
m_resetting = false;
|
m_resetting = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(this, &MessageModel::threadsEnabledChanged, this, [this]() {
|
|
||||||
Q_EMIT dataChanged(index(0), index(rowCount() - 1), {DelegateTypeRole, ContentModelRole, IsThreadedRole, SpecialMarksRole});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NeoChatRoom *MessageModel::room() const
|
NeoChatRoom *MessageModel::room() const
|
||||||
@@ -151,7 +146,7 @@ QVariant MessageModel::data(const QModelIndex &idx, int role) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto roomMessageEvent = eventCast<const RoomMessageEvent>(&event.value().get());
|
auto roomMessageEvent = eventCast<const RoomMessageEvent>(&event.value().get());
|
||||||
if (m_threadsEnabled && roomMessageEvent && roomMessageEvent->isThreaded()) {
|
if (roomMessageEvent && roomMessageEvent->isThreaded()) {
|
||||||
return QVariant::fromValue<EventMessageContentModel *>(
|
return QVariant::fromValue<EventMessageContentModel *>(
|
||||||
ContentProvider::self().contentModelForEvent(eventRoom, roomMessageEvent->threadRootEventId()));
|
ContentProvider::self().contentModelForEvent(eventRoom, roomMessageEvent->threadRootEventId()));
|
||||||
}
|
}
|
||||||
@@ -200,7 +195,7 @@ QVariant MessageModel::data(const QModelIndex &idx, int role) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto roomMessageEvent = eventCast<const RoomMessageEvent>(&event.value().get());
|
auto roomMessageEvent = eventCast<const RoomMessageEvent>(&event.value().get());
|
||||||
if (m_threadsEnabled && roomMessageEvent && (roomMessageEvent->isThreaded() || eventRoom->threads().contains(event.value().get().id()))) {
|
if (roomMessageEvent && (roomMessageEvent->isThreaded() || eventRoom->threads().contains(event.value().get().id()))) {
|
||||||
const auto &thread = eventRoom->threads().value(roomMessageEvent->isThreaded() ? roomMessageEvent->threadRootEventId() : event.value().get().id());
|
const auto &thread = eventRoom->threads().value(roomMessageEvent->isThreaded() ? roomMessageEvent->threadRootEventId() : event.value().get().id());
|
||||||
if (thread.latestEventId != event.value().get().id()) {
|
if (thread.latestEventId != event.value().get().id()) {
|
||||||
return EventStatus::Hidden;
|
return EventStatus::Hidden;
|
||||||
@@ -231,9 +226,6 @@ QVariant MessageModel::data(const QModelIndex &idx, int role) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (role == IsThreadedRole) {
|
if (role == IsThreadedRole) {
|
||||||
if (!m_threadsEnabled) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (auto roomMessageEvent = eventCast<const RoomMessageEvent>(&event.value().get())) {
|
if (auto roomMessageEvent = eventCast<const RoomMessageEvent>(&event.value().get())) {
|
||||||
return roomMessageEvent->isThreaded();
|
return roomMessageEvent->isThreaded();
|
||||||
}
|
}
|
||||||
@@ -559,9 +551,4 @@ void MessageModel::setHiddenFilter(std::function<bool(const Quotient::RoomEvent
|
|||||||
MessageModel::m_hiddenFilter = hiddenFilter;
|
MessageModel::m_hiddenFilter = hiddenFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageModel::setThreadsEnabled(bool enableThreads)
|
|
||||||
{
|
|
||||||
MessageModel::m_threadsEnabled = enableThreads;
|
|
||||||
}
|
|
||||||
|
|
||||||
#include "moc_messagemodel.cpp"
|
#include "moc_messagemodel.cpp"
|
||||||
|
|||||||
@@ -124,8 +124,6 @@ public:
|
|||||||
|
|
||||||
static void setHiddenFilter(std::function<bool(const Quotient::RoomEvent *)> hiddenFilter);
|
static void setHiddenFilter(std::function<bool(const Quotient::RoomEvent *)> hiddenFilter);
|
||||||
|
|
||||||
static void setThreadsEnabled(bool enableThreads);
|
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
/**
|
/**
|
||||||
* @brief Emitted when the room is changed.
|
* @brief Emitted when the room is changed.
|
||||||
@@ -170,8 +168,6 @@ Q_SIGNALS:
|
|||||||
*/
|
*/
|
||||||
void newLocalUserEventAdded();
|
void newLocalUserEventAdded();
|
||||||
|
|
||||||
void threadsEnabledChanged();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QPointer<NeoChatRoom> m_room;
|
QPointer<NeoChatRoom> m_room;
|
||||||
QPersistentModelIndex m_lastReadEventIndex;
|
QPersistentModelIndex m_lastReadEventIndex;
|
||||||
@@ -200,5 +196,4 @@ private:
|
|||||||
void createEventObjects(const Quotient::RoomEvent *event);
|
void createEventObjects(const Quotient::RoomEvent *event);
|
||||||
|
|
||||||
static std::function<bool(const Quotient::RoomEvent *)> m_hiddenFilter;
|
static std::function<bool(const Quotient::RoomEvent *)> m_hiddenFilter;
|
||||||
static bool m_threadsEnabled;
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -16,8 +16,6 @@ TimelineModel::TimelineModel(QObject *parent)
|
|||||||
addSourceModel(m_timelineMessageModel);
|
addSourceModel(m_timelineMessageModel);
|
||||||
m_timelineEndModel = new TimelineEndModel(this);
|
m_timelineEndModel = new TimelineEndModel(this);
|
||||||
addSourceModel(m_timelineEndModel);
|
addSourceModel(m_timelineEndModel);
|
||||||
|
|
||||||
connect(this, &TimelineModel::threadsEnabledChanged, m_timelineMessageModel, &TimelineMessageModel::threadsEnabledChanged);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NeoChatRoom *TimelineModel::room() const
|
NeoChatRoom *TimelineModel::room() const
|
||||||
|
|||||||
@@ -156,7 +156,6 @@ public:
|
|||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void roomChanged();
|
void roomChanged();
|
||||||
void threadsEnabledChanged();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TimelineMessageModel *m_timelineMessageModel = nullptr;
|
TimelineMessageModel *m_timelineMessageModel = nullptr;
|
||||||
|
|||||||
Reference in New Issue
Block a user