Compare commits

...

1 Commits

Author SHA1 Message Date
Joshua Goins
de6e588981 Allow searching messages in all rooms 2025-08-23 17:31:45 -04:00
3 changed files with 39 additions and 3 deletions

View File

@@ -3,6 +3,7 @@
import QtQuick
import org.kde.kirigami as Kirigami
import org.kde.neochat.libneochat
import org.kde.neochat.timeline
@@ -39,4 +40,15 @@ SearchPage {
noResultPlaceholderMessage: i18n("No messages found")
listVerticalLayoutDirection: ListView.BottomToTop
actions: [
Kirigami.Action {
text: "Search All Rooms"
checkable: true
onToggled: {
root.model.allRooms = checked;
root.updateSearch();
}
}
]
}

View File

@@ -5,8 +5,6 @@
using namespace Quotient;
// TODO search only in the current room
SearchModel::SearchModel(QObject *parent)
: MessageModel(parent)
{
@@ -37,7 +35,9 @@ void SearchModel::search()
filter.lazyLoadMembers = true;
filter.includeRedundantMembers = false;
filter.notRooms = QStringList();
filter.rooms = QStringList{m_room->id()};
if (!m_allRooms) {
filter.rooms = QStringList{m_room->id()};
}
filter.containsUrl = false;
SearchJob::RoomEventsCriteria criteria{
@@ -101,4 +101,18 @@ void SearchModel::setSearching(bool searching)
Q_EMIT searchingChanged();
}
bool SearchModel::allRooms() const
{
return m_allRooms;
}
void SearchModel::setAllRooms(bool allRooms)
{
if (m_allRooms == allRooms) {
return;
}
m_allRooms = allRooms;
Q_EMIT allRoomsChanged();
}
#include "moc_searchmodel.cpp"

View File

@@ -37,12 +37,20 @@ class SearchModel : public MessageModel
*/
Q_PROPERTY(bool searching READ searching NOTIFY searchingChanged)
/**
* @brief Whether to search the current room or all of them.
*/
Q_PROPERTY(bool allRooms READ allRooms WRITE setAllRooms NOTIFY allRoomsChanged)
public:
explicit SearchModel(QObject *parent = nullptr);
QString searchText() const;
void setSearchText(const QString &searchText);
bool allRooms() const;
void setAllRooms(bool allRooms);
bool searching() const;
/**
@@ -61,6 +69,7 @@ Q_SIGNALS:
void searchTextChanged();
void roomChanged();
void searchingChanged();
void allRoomsChanged();
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;
bool m_allRooms = false;
};