mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Added ability to ignore hidden rows while searching to PeerListContent.
This commit is contained in:
parent
3699439506
commit
7aa1141ba5
2 changed files with 23 additions and 5 deletions
|
@ -547,6 +547,10 @@ rpl::producer<int> PeerListBox::multiSelectHeightValue() const {
|
||||||
return _select ? _select->heightValue() : rpl::single(0);
|
return _select ? _select->heightValue() : rpl::single(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PeerListBox::setIgnoreHiddenRowsOnSearch(bool value) {
|
||||||
|
content()->setIgnoreHiddenRowsOnSearch(value);
|
||||||
|
}
|
||||||
|
|
||||||
PeerListRow::PeerListRow(not_null<PeerData*> peer)
|
PeerListRow::PeerListRow(not_null<PeerData*> peer)
|
||||||
: PeerListRow(peer, peer->id.value) {
|
: PeerListRow(peer, peer->id.value) {
|
||||||
}
|
}
|
||||||
|
@ -1389,10 +1393,12 @@ int PeerListContent::labelHeight() const {
|
||||||
|
|
||||||
void PeerListContent::refreshRows() {
|
void PeerListContent::refreshRows() {
|
||||||
if (!_hiddenRows.empty()) {
|
if (!_hiddenRows.empty()) {
|
||||||
_filterResults.clear();
|
if (!_ignoreHiddenRowsOnSearch || _normalizedSearchQuery.isEmpty()) {
|
||||||
for (const auto &row : _rows) {
|
_filterResults.clear();
|
||||||
if (!row->hidden()) {
|
for (const auto &row : _rows) {
|
||||||
_filterResults.push_back(row.get());
|
if (!row->hidden()) {
|
||||||
|
_filterResults.push_back(row.get());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2057,10 +2063,13 @@ void PeerListContent::checkScrollForPreload() {
|
||||||
void PeerListContent::searchQueryChanged(QString query) {
|
void PeerListContent::searchQueryChanged(QString query) {
|
||||||
const auto searchWordsList = TextUtilities::PrepareSearchWords(query);
|
const auto searchWordsList = TextUtilities::PrepareSearchWords(query);
|
||||||
const auto normalizedQuery = searchWordsList.join(' ');
|
const auto normalizedQuery = searchWordsList.join(' ');
|
||||||
|
if (_ignoreHiddenRowsOnSearch && !normalizedQuery.isEmpty()) {
|
||||||
|
_filterResults.clear();
|
||||||
|
}
|
||||||
if (_normalizedSearchQuery != normalizedQuery) {
|
if (_normalizedSearchQuery != normalizedQuery) {
|
||||||
setSearchQuery(query, normalizedQuery);
|
setSearchQuery(query, normalizedQuery);
|
||||||
if (_controller->searchInLocal() && !searchWordsList.isEmpty()) {
|
if (_controller->searchInLocal() && !searchWordsList.isEmpty()) {
|
||||||
Assert(_hiddenRows.empty());
|
Assert(_hiddenRows.empty() || _ignoreHiddenRowsOnSearch);
|
||||||
|
|
||||||
auto minimalList = (const std::vector<not_null<PeerListRow*>>*)nullptr;
|
auto minimalList = (const std::vector<not_null<PeerListRow*>>*)nullptr;
|
||||||
for (const auto &searchWord : searchWordsList) {
|
for (const auto &searchWord : searchWordsList) {
|
||||||
|
@ -2196,6 +2205,10 @@ void PeerListContent::dragLeft() {
|
||||||
clearSelection();
|
clearSelection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PeerListContent::setIgnoreHiddenRowsOnSearch(bool value) {
|
||||||
|
_ignoreHiddenRowsOnSearch = value;
|
||||||
|
}
|
||||||
|
|
||||||
void PeerListContent::visibleTopBottomUpdated(
|
void PeerListContent::visibleTopBottomUpdated(
|
||||||
int visibleTop,
|
int visibleTop,
|
||||||
int visibleBottom) {
|
int visibleBottom) {
|
||||||
|
|
|
@ -658,6 +658,8 @@ public:
|
||||||
PeerListRowId updateFromParentDrag(QPoint globalPosition);
|
PeerListRowId updateFromParentDrag(QPoint globalPosition);
|
||||||
void dragLeft();
|
void dragLeft();
|
||||||
|
|
||||||
|
void setIgnoreHiddenRowsOnSearch(bool value);
|
||||||
|
|
||||||
// Interface for the controller.
|
// Interface for the controller.
|
||||||
void appendRow(std::unique_ptr<PeerListRow> row);
|
void appendRow(std::unique_ptr<PeerListRow> row);
|
||||||
void appendSearchRow(std::unique_ptr<PeerListRow> row);
|
void appendSearchRow(std::unique_ptr<PeerListRow> row);
|
||||||
|
@ -879,6 +881,7 @@ private:
|
||||||
int _aboveHeight = 0;
|
int _aboveHeight = 0;
|
||||||
int _belowHeight = 0;
|
int _belowHeight = 0;
|
||||||
bool _hideEmpty = false;
|
bool _hideEmpty = false;
|
||||||
|
bool _ignoreHiddenRowsOnSearch = false;
|
||||||
object_ptr<Ui::RpWidget> _aboveWidget = { nullptr };
|
object_ptr<Ui::RpWidget> _aboveWidget = { nullptr };
|
||||||
object_ptr<Ui::RpWidget> _aboveSearchWidget = { nullptr };
|
object_ptr<Ui::RpWidget> _aboveSearchWidget = { nullptr };
|
||||||
object_ptr<Ui::RpWidget> _belowWidget = { nullptr };
|
object_ptr<Ui::RpWidget> _belowWidget = { nullptr };
|
||||||
|
@ -1104,6 +1107,8 @@ public:
|
||||||
[[nodiscard]] std::vector<not_null<PeerData*>> collectSelectedRows();
|
[[nodiscard]] std::vector<not_null<PeerData*>> collectSelectedRows();
|
||||||
[[nodiscard]] rpl::producer<int> multiSelectHeightValue() const;
|
[[nodiscard]] rpl::producer<int> multiSelectHeightValue() const;
|
||||||
|
|
||||||
|
void setIgnoreHiddenRowsOnSearch(bool value);
|
||||||
|
|
||||||
void peerListSetTitle(rpl::producer<QString> title) override {
|
void peerListSetTitle(rpl::producer<QString> title) override {
|
||||||
setTitle(std::move(title));
|
setTitle(std::move(title));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue