MCPcopy Create free account
hub / github.com/TDesktop-x64/tdesktop / cancelSearch

Method cancelSearch

Telegram/SourceFiles/dialogs/dialogs_widget.cpp:4448–4529  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4446}
4447
4448bool Widget::cancelSearch(CancelSearchOptions options) {
4449 const auto clearingSuggestionsQuery = _suggestions
4450 && _suggestions->consumeSearchQuery(QString());
4451 if (clearingSuggestionsQuery) {
4452 setSearchQuery(QString());
4453 if (!options.forceFullCancel) {
4454 return true;
4455 }
4456 }
4457 cancelSearchRequest();
4458 auto updatedState = _searchState;
4459 const auto clearingQuery = clearingSuggestionsQuery
4460 || !updatedState.query.isEmpty();
4461 const auto forceFullCancel = options.forceFullCancel;
4462 auto clearingInChat = (forceFullCancel || !clearingQuery)
4463 && (updatedState.inChat
4464 || updatedState.fromPeer
4465 || !updatedState.tags.empty());
4466 if (clearingQuery) {
4467 updatedState.query = QString();
4468 }
4469 if (clearingInChat) {
4470 if (options.jumpBackToSearchedChat
4471 && updatedState.inChat
4472 && controller()->adaptive().isOneColumn()) {
4473 if (const auto thread = updatedState.inChat.thread()) {
4474 controller()->showThread(thread);
4475 } else {
4476 Unexpected("Empty key in cancelSearch().");
4477 }
4478 }
4479 updatedState.inChat = {};
4480 updatedState.fromPeer = nullptr;
4481 updatedState.tags = {};
4482 }
4483 if (!clearingQuery
4484 && _subsectionTopBar
4485 && _subsectionTopBar->toggleSearch(false, anim::type::normal)) {
4486 setInnerFocus(true);
4487 clearingInChat = true;
4488 }
4489 const auto clearSearchFocus = (forceFullCancel || !updatedState.inChat)
4490 && (_searchHasFocus || _searchSuggestionsLocked);
4491 if (!updatedState.inChat && _suggestions) {
4492 _suggestions->clearPersistance();
4493 _searchSuggestionsLocked = false;
4494 }
4495 if (!_suggestions && clearSearchFocus) {
4496 // Don't create suggestions in unfocus case.
4497 setInnerFocus(true);
4498 }
4499 _searchProcess.lastPeer = nullptr;
4500 _searchProcess.lastId = 0;
4501 _migratedProcess.lastPeer = nullptr;
4502 _migratedProcess.lastId = 0;
4503 _postsProcess.lastPeer = nullptr;
4504 _postsProcess.lastId = 0;
4505 _inner->clearFilter();

Callers

nothing calls this directly

Calls 15

consumeSearchQueryMethod · 0.80
showThreadMethod · 0.80
clearPersistanceMethod · 0.80
clearFilterMethod · 0.80
shownForumMethod · 0.80
closeForumMethod · 0.80
QStringClass · 0.50
isEmptyMethod · 0.45
emptyMethod · 0.45
isOneColumnMethod · 0.45
threadMethod · 0.45
toggleSearchMethod · 0.45

Tested by

no test coverage detected