Thread View

So at the moment this remains behind the feature flag as this only adds a threadmodel and a basic visualisation. There is much more to come to get it ready for full release.
This commit is contained in:
James Graham
2024-08-18 15:19:03 +00:00
parent 149013d2ff
commit 56d790dda9
17 changed files with 347 additions and 23 deletions

View File

@@ -30,6 +30,7 @@
#include "neochatroommember.h"
#include "readmarkermodel.h"
#include "texthandler.h"
#include "threadmodel.h"
using namespace Quotient;
@@ -71,6 +72,11 @@ MessageEventModel::MessageEventModel(QObject *parent)
connect(this, &MessageEventModel::modelReset, this, [this]() {
resetting = false;
});
connect(NeoChatConfig::self(), &NeoChatConfig::ThreadsChanged, this, [this]() {
beginResetModel();
endResetModel();
});
}
NeoChatRoom *MessageEventModel::room() const
@@ -497,6 +503,10 @@ QVariant MessageEventModel::data(const QModelIndex &idx, int role) const
return EventStatus::Hidden;
}
if (eventHandler.isThreaded() && eventHandler.threadRoot() != eventHandler.getId() && NeoChatConfig::threads()) {
return EventStatus::Hidden;
}
return EventStatus::Normal;
}
@@ -646,6 +656,11 @@ void MessageEventModel::createEventObjects(const Quotient::RoomEvent *event)
}
}
const auto eventHandler = EventHandler(m_currentRoom, event);
if (eventHandler.isThreaded() && !m_threadModels.contains(eventHandler.threadRoot())) {
m_threadModels[eventHandler.threadRoot()] = QSharedPointer<ThreadModel>(new ThreadModel(eventHandler.threadRoot(), m_currentRoom));
}
// ReadMarkerModel handles updates to add and remove markers, we only need to
// handle adding and removing whole models here.
if (m_readMarkerModels.contains(eventId)) {
@@ -705,4 +720,9 @@ bool MessageEventModel::event(QEvent *event)
return QObject::event(event);
}
ThreadModel *MessageEventModel::threadModelForRootId(const QString &threadRootId) const
{
return m_threadModels[threadRootId].data();
}
#include "moc_messageeventmodel.cpp"