Add support for copying & deleting multiple messages at once

BUG: 496458
This commit is contained in:
Azhar Momin
2026-02-11 18:30:09 +05:30
committed by Joshua Goins
parent 0f634ff795
commit f5d726989f
10 changed files with 357 additions and 15 deletions

View File

@@ -220,6 +220,16 @@ class NeoChatRoom : public Quotient::Room
*/
Q_PROPERTY(bool spaceHasUnreadMessages READ spaceHasUnreadMessages NOTIFY spaceHasUnreadMessagesChanged)
/**
* @brief The number of selected messages in the room.
*/
Q_PROPERTY(int selectedMessageCount READ selectedMessageCount NOTIFY selectionChanged)
/**
* @brief Whether the user can delete the selected messages.
*/
Q_PROPERTY(bool canDeleteSelectedMessages READ canDeleteSelectedMessages NOTIFY selectionChanged)
public:
explicit NeoChatRoom(Quotient::Connection *connection, QString roomId, Quotient::JoinState joinState = {});
@@ -676,6 +686,41 @@ public:
*/
QList<QString> sortedMemberIds() const;
/**
* @brief The number of selected messages in the room.
*/
int selectedMessageCount() const;
/**
* @brief Whether the user can delete the selected messages.
*/
bool canDeleteSelectedMessages() const;
/**
* @brief Whether the given message is selected.
*/
Q_INVOKABLE bool isMessageSelected(const QString &eventId) const;
/**
* @brief Toggle the selection state of the given message.
*/
Q_INVOKABLE void toggleMessageSelection(const QString &eventId);
/**
* @brief Get the content of the selected messages formatted as a single string.
*/
Q_INVOKABLE QString getFormattedSelectedMessages() const;
/**
* @brief Delete the selected messages with an optional reason.
*/
Q_INVOKABLE void deleteSelectedMessages(const QString &reason = QString());
/**
* @brief Clear the selection of messages.
*/
Q_INVOKABLE void clearSelectedMessages();
private:
bool m_visible = false;
@@ -693,7 +738,7 @@ private:
void onAddHistoricalTimelineEvents(rev_iter_t from) override;
void onRedaction(const Quotient::RoomEvent &prevEvent, const Quotient::RoomEvent &after) override;
QCoro::Task<void> doDeleteMessagesByUser(const QString &user, QString reason);
QCoro::Task<void> doDeleteMessageIds(const QStringList eventIds, QString reason);
QCoro::Task<void> doUploadFile(QUrl url, QString body = QString(), std::optional<Quotient::EventRelation> relatesTo = std::nullopt);
std::unique_ptr<Quotient::RoomEvent> m_cachedEvent;
@@ -713,6 +758,7 @@ private:
QString m_lastUnreadHighlightId;
QList<QString> m_sortedMemberIds;
QSet<QString> m_selectedMessageIds;
private Q_SLOTS:
void updatePushNotificationState(QString type);
@@ -752,6 +798,7 @@ Q_SIGNALS:
void pinnedMessageChanged();
void highlightCycleStartedChanged();
void spaceHasUnreadMessagesChanged();
void selectionChanged();
/**
* @brief Request a message be shown to the user of the given type.