Add action to user detail dialog to search for their messages in room
In other messaging applications (e.g. Discord) this is possible through text modifiers like "from:@user". We don't support that, and I'm not super keen on implementing yet-another-parsing-thing, so an action in the user detail dialog should work for now. Very useful to sift through large rooms but when you only care about a specific person's messages (maybe your own?)
This commit is contained in:
@@ -51,6 +51,9 @@ void SearchModel::search()
|
||||
filter.notRooms = QStringList();
|
||||
filter.rooms = QStringList{m_room->id()};
|
||||
filter.containsUrl = false;
|
||||
if (!m_senderId.isEmpty()) {
|
||||
filter.senders = {m_senderId};
|
||||
}
|
||||
|
||||
SearchJob::RoomEventsCriteria criteria{
|
||||
.searchTerm = m_searchText,
|
||||
@@ -112,4 +115,15 @@ void SearchModel::setSearching(bool searching)
|
||||
Q_EMIT searchingChanged();
|
||||
}
|
||||
|
||||
QString SearchModel::senderId() const
|
||||
{
|
||||
return m_senderId;
|
||||
}
|
||||
|
||||
void SearchModel::setSenderId(const QString &sender)
|
||||
{
|
||||
m_senderId = sender;
|
||||
Q_EMIT senderIdChanged();
|
||||
}
|
||||
|
||||
#include "moc_searchmodel.cpp"
|
||||
|
||||
@@ -37,6 +37,11 @@ class SearchModel : public MessageModel
|
||||
*/
|
||||
Q_PROPERTY(bool searching READ searching NOTIFY searchingChanged)
|
||||
|
||||
/**
|
||||
* @brief If set, limits the search to this specific sender.
|
||||
*/
|
||||
Q_PROPERTY(QString senderId READ senderId WRITE setSenderId NOTIFY senderIdChanged)
|
||||
|
||||
public:
|
||||
explicit SearchModel(QObject *parent = nullptr);
|
||||
|
||||
@@ -45,6 +50,9 @@ public:
|
||||
|
||||
bool searching() const;
|
||||
|
||||
QString senderId() const;
|
||||
void setSenderId(const QString &sender);
|
||||
|
||||
/**
|
||||
* @brief Number of rows in the model.
|
||||
*
|
||||
@@ -61,6 +69,7 @@ Q_SIGNALS:
|
||||
void searchTextChanged();
|
||||
void roomChanged();
|
||||
void searchingChanged();
|
||||
void senderIdChanged();
|
||||
|
||||
private:
|
||||
std::optional<std::reference_wrapper<const Quotient::RoomEvent>> getEventForIndex(QModelIndex index) const override;
|
||||
@@ -71,4 +80,5 @@ private:
|
||||
std::optional<Quotient::SearchJob::ResultRoomEvents> m_result = std::nullopt;
|
||||
Quotient::SearchJob *m_job = nullptr;
|
||||
bool m_searching = false;
|
||||
QString m_senderId;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user