Use the rich text char format to store mentions rather than a separate structure in ChatBarCache.

This removes mentions from ChatBarCache and instead sets mentions as an anchor using the QTextCursor. Saving and restoring the chatbar text content is then done using QTextDocumentFragments which retain the rich text formatting.
This commit is contained in:
James Graham
2026-02-19 16:08:35 +00:00
parent a235f39c84
commit d2d48110cb
16 changed files with 128 additions and 198 deletions

View File

@@ -30,16 +30,6 @@ class CompletionModel : public QAbstractListModel
Q_OBJECT
QML_ELEMENT
/**
* @brief The current room that the text document is being handled for.
*/
Q_PROPERTY(NeoChatRoom *room READ room WRITE setRoom NOTIFY roomChanged)
/**
* @brief The ChatBarType::Type of the chat bar.
*/
Q_PROPERTY(ChatBarType::Type type READ type WRITE setType NOTIFY typeChanged)
/**
* @brief The QML text Item that completions are being provided for.
*/
@@ -94,12 +84,6 @@ public:
explicit CompletionModel(QObject *parent = nullptr);
NeoChatRoom *room() const;
void setRoom(NeoChatRoom *room);
ChatBarType::Type type() const;
void setType(ChatBarType::Type type);
ChatTextItemHelper *textItem() const;
void setTextItem(ChatTextItemHelper *textItem);
@@ -140,8 +124,6 @@ public:
Q_INVOKABLE void insertCompletion(const QString &text, const QUrl &link);
Q_SIGNALS:
void roomChanged();
void typeChanged();
void textItemChanged();
void autoCompletionTypeChanged();
void roomListModelChanged();
@@ -149,8 +131,6 @@ Q_SIGNALS:
void isCompletingChanged();
private:
QPointer<NeoChatRoom> m_room;
ChatBarType::Type m_type = ChatBarType::None;
QPointer<ChatTextItemHelper> m_textItem;
bool m_ignoreCurrentCompletion = false;
@@ -165,6 +145,4 @@ private:
UserListModel *m_userListModel;
RoomListModel *m_roomListModel;
QConcatenateTablesProxyModel *m_emojiModel;
void pushMention(const Mention mention) const;
};