Compare commits
1 Commits
master
...
work/redst
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
de6e588981 |
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
import QtQuick
|
import QtQuick
|
||||||
|
|
||||||
|
import org.kde.kirigami as Kirigami
|
||||||
import org.kde.neochat.libneochat
|
import org.kde.neochat.libneochat
|
||||||
import org.kde.neochat.timeline
|
import org.kde.neochat.timeline
|
||||||
|
|
||||||
@@ -39,4 +40,15 @@ SearchPage {
|
|||||||
noResultPlaceholderMessage: i18n("No messages found")
|
noResultPlaceholderMessage: i18n("No messages found")
|
||||||
|
|
||||||
listVerticalLayoutDirection: ListView.BottomToTop
|
listVerticalLayoutDirection: ListView.BottomToTop
|
||||||
|
|
||||||
|
actions: [
|
||||||
|
Kirigami.Action {
|
||||||
|
text: "Search All Rooms"
|
||||||
|
checkable: true
|
||||||
|
onToggled: {
|
||||||
|
root.model.allRooms = checked;
|
||||||
|
root.updateSearch();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,8 +5,6 @@
|
|||||||
|
|
||||||
using namespace Quotient;
|
using namespace Quotient;
|
||||||
|
|
||||||
// TODO search only in the current room
|
|
||||||
|
|
||||||
SearchModel::SearchModel(QObject *parent)
|
SearchModel::SearchModel(QObject *parent)
|
||||||
: MessageModel(parent)
|
: MessageModel(parent)
|
||||||
{
|
{
|
||||||
@@ -37,7 +35,9 @@ void SearchModel::search()
|
|||||||
filter.lazyLoadMembers = true;
|
filter.lazyLoadMembers = true;
|
||||||
filter.includeRedundantMembers = false;
|
filter.includeRedundantMembers = false;
|
||||||
filter.notRooms = QStringList();
|
filter.notRooms = QStringList();
|
||||||
filter.rooms = QStringList{m_room->id()};
|
if (!m_allRooms) {
|
||||||
|
filter.rooms = QStringList{m_room->id()};
|
||||||
|
}
|
||||||
filter.containsUrl = false;
|
filter.containsUrl = false;
|
||||||
|
|
||||||
SearchJob::RoomEventsCriteria criteria{
|
SearchJob::RoomEventsCriteria criteria{
|
||||||
@@ -101,4 +101,18 @@ void SearchModel::setSearching(bool searching)
|
|||||||
Q_EMIT searchingChanged();
|
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"
|
#include "moc_searchmodel.cpp"
|
||||||
|
|||||||
@@ -37,12 +37,20 @@ class SearchModel : public MessageModel
|
|||||||
*/
|
*/
|
||||||
Q_PROPERTY(bool searching READ searching NOTIFY searchingChanged)
|
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:
|
public:
|
||||||
explicit SearchModel(QObject *parent = nullptr);
|
explicit SearchModel(QObject *parent = nullptr);
|
||||||
|
|
||||||
QString searchText() const;
|
QString searchText() const;
|
||||||
void setSearchText(const QString &searchText);
|
void setSearchText(const QString &searchText);
|
||||||
|
|
||||||
|
bool allRooms() const;
|
||||||
|
void setAllRooms(bool allRooms);
|
||||||
|
|
||||||
bool searching() const;
|
bool searching() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -61,6 +69,7 @@ Q_SIGNALS:
|
|||||||
void searchTextChanged();
|
void searchTextChanged();
|
||||||
void roomChanged();
|
void roomChanged();
|
||||||
void searchingChanged();
|
void searchingChanged();
|
||||||
|
void allRoomsChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::optional<std::reference_wrapper<const Quotient::RoomEvent>> getEventForIndex(QModelIndex index) const override;
|
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;
|
std::optional<Quotient::SearchJob::ResultRoomEvents> m_result = std::nullopt;
|
||||||
Quotient::SearchJob *m_job = nullptr;
|
Quotient::SearchJob *m_job = nullptr;
|
||||||
bool m_searching = false;
|
bool m_searching = false;
|
||||||
|
bool m_allRooms = false;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user