mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-09-01 15:05:56 +00:00
Added simple colorizing of query in found messages from compose search.
This commit is contained in:
@@ -54,7 +54,9 @@ using SearchRequest = Api::MessagesSearchMerged::Request;
|
|||||||
|
|
||||||
class Row final : public PeerListRow {
|
class Row final : public PeerListRow {
|
||||||
public:
|
public:
|
||||||
explicit Row(std::unique_ptr<Dialogs::FakeRow> fakeRow);
|
explicit Row(
|
||||||
|
std::unique_ptr<Dialogs::FakeRow> fakeRow,
|
||||||
|
not_null<QString*> query);
|
||||||
|
|
||||||
[[nodiscard]] FullMsgId fullId() const;
|
[[nodiscard]] FullMsgId fullId() const;
|
||||||
|
|
||||||
@@ -73,15 +75,17 @@ public:
|
|||||||
private:
|
private:
|
||||||
const std::unique_ptr<Dialogs::FakeRow> _fakeRow;
|
const std::unique_ptr<Dialogs::FakeRow> _fakeRow;
|
||||||
|
|
||||||
|
not_null<QString*> _query;
|
||||||
int _outerWidth = 0;
|
int _outerWidth = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Row::Row(std::unique_ptr<Dialogs::FakeRow> fakeRow)
|
Row::Row(std::unique_ptr<Dialogs::FakeRow> fakeRow, not_null<QString*> query)
|
||||||
: PeerListRow(
|
: PeerListRow(
|
||||||
fakeRow->searchInChat().history()->peer,
|
fakeRow->searchInChat().history()->peer,
|
||||||
fakeRow->item()->fullId().msg.bare)
|
fakeRow->item()->fullId().msg.bare)
|
||||||
, _fakeRow(std::move(fakeRow)) {
|
, _fakeRow(std::move(fakeRow))
|
||||||
|
, _query(query) {
|
||||||
}
|
}
|
||||||
|
|
||||||
FullMsgId Row::fullId() const {
|
FullMsgId Row::fullId() const {
|
||||||
@@ -116,9 +120,11 @@ void Row::elementsPaint(
|
|||||||
.st = &st::defaultDialogRow,
|
.st = &st::defaultDialogRow,
|
||||||
.currentBg = st::dialogsBg,
|
.currentBg = st::dialogsBg,
|
||||||
.now = crl::now(),
|
.now = crl::now(),
|
||||||
|
.searchLowerText = QStringView(*_query),
|
||||||
.width = outerWidth,
|
.width = outerWidth,
|
||||||
.selected = selected,
|
.selected = selected,
|
||||||
.paused = p.inactive(),
|
.paused = p.inactive(),
|
||||||
|
.search = true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,6 +140,7 @@ public:
|
|||||||
void loadMoreRows() override;
|
void loadMoreRows() override;
|
||||||
|
|
||||||
void addItems(const MessageIdsList &ids, bool clear);
|
void addItems(const MessageIdsList &ids, bool clear);
|
||||||
|
void setQuery(const QString &query);
|
||||||
|
|
||||||
[[nodiscard]] rpl::producer<FullMsgId> showItemRequests() const;
|
[[nodiscard]] rpl::producer<FullMsgId> showItemRequests() const;
|
||||||
[[nodiscard]] rpl::producer<> searchMoreRequests() const;
|
[[nodiscard]] rpl::producer<> searchMoreRequests() const;
|
||||||
@@ -145,6 +152,8 @@ private:
|
|||||||
rpl::event_stream<> _searchMoreRequests;
|
rpl::event_stream<> _searchMoreRequests;
|
||||||
rpl::event_stream<> _resetScrollRequests;
|
rpl::event_stream<> _resetScrollRequests;
|
||||||
|
|
||||||
|
QString _query;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
ListController::ListController(not_null<History*> history)
|
ListController::ListController(not_null<History*> history)
|
||||||
@@ -201,7 +210,8 @@ void ListController::addItems(const MessageIdsList &ids, bool clear) {
|
|||||||
std::make_unique<Dialogs::FakeRow>(
|
std::make_unique<Dialogs::FakeRow>(
|
||||||
key,
|
key,
|
||||||
item,
|
item,
|
||||||
[=] { delegate()->peerListUpdateRow(*shared); }));
|
[=] { delegate()->peerListUpdateRow(*shared); }),
|
||||||
|
&_query);
|
||||||
*shared = row.get();
|
*shared = row.get();
|
||||||
delegate()->peerListAppendRow(std::move(row));
|
delegate()->peerListAppendRow(std::move(row));
|
||||||
}
|
}
|
||||||
@@ -214,6 +224,10 @@ void ListController::addItems(const MessageIdsList &ids, bool clear) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ListController::setQuery(const QString &query) {
|
||||||
|
_query = query;
|
||||||
|
}
|
||||||
|
|
||||||
struct List {
|
struct List {
|
||||||
base::unique_qptr<Ui::RpWidget> container;
|
base::unique_qptr<Ui::RpWidget> container;
|
||||||
std::unique_ptr<ListController> controller;
|
std::unique_ptr<ListController> controller;
|
||||||
@@ -913,6 +927,9 @@ ComposeSearch::Inner::Inner(
|
|||||||
search.topMsgId = _topMsgId;
|
search.topMsgId = _topMsgId;
|
||||||
_apiSearch.clear();
|
_apiSearch.clear();
|
||||||
_apiSearch.search(search);
|
_apiSearch.search(search);
|
||||||
|
|
||||||
|
_list.controller->addItems({}, true);
|
||||||
|
_list.controller->setQuery(_apiSearch.request().query);
|
||||||
}, _topBar->lifetime());
|
}, _topBar->lifetime());
|
||||||
|
|
||||||
_topBar->queryChanges(
|
_topBar->queryChanges(
|
||||||
|
Reference in New Issue
Block a user