MCPcopy Create free account
hub / github.com/comaps/comaps / OnSearchTextChanged

Method OnSearchTextChanged

qt/search_panel.cpp:224–279  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

222}
223
224void SearchPanel::OnSearchTextChanged(QString const & str)
225{
226 // Pass input query as-is without any normalization.
227 // Otherwise № -> No, and it's unexpectable for the search index.
228 // QString const normalized = str.normalized(QString::NormalizationForm_KC);
229 std::string const normalized = str.toStdString();
230
231 if (Try3dModeCmd(normalized))
232 return;
233 if (TryTrafficSimplifiedColorsCmd(normalized))
234 return;
235
236 ClearResults();
237
238 if (normalized.empty())
239 {
240 GetFramework().GetSearchAPI().CancelAllSearches();
241
242 // hide X button
243 m_pClearButton->setVisible(false);
244 return;
245 }
246
247 bool const isCategory = m_isCategory->isChecked();
248 auto const timestamp = ++m_timestamp;
249
250 using namespace search;
251 if (m_mode == Mode::Everywhere)
252 {
253 EverywhereSearchParams params{normalized,
254 GetCurrentInputLocale(),
255 {} /* timeout */,
256 isCategory,
257 // m_onResults
258 [this, timestamp](Results results, std::vector<ProductInfo> /* productInfo */)
259 { OnSearchResults(timestamp, std::move(results)); }};
260
261 if (GetFramework().GetSearchAPI().SearchEverywhere(std::move(params)))
262 StartBusyIndicator();
263 }
264 else if (m_mode == Mode::Viewport)
265 {
266 ViewportSearchParams params{normalized,
267 GetCurrentInputLocale(),
268 {} /* timeout */,
269 isCategory,
270 // m_onStarted
271 [this]() { StartBusyIndicator(); },
272 // m_onCompleted
273 [this, timestamp](search::Results results)
274 { OnSearchResults(timestamp, std::move(results)); }};
275
276 if (GetFramework().GetSearchAPI().SearchInViewport(std::move(params)))
277 StartBusyIndicator();
278 }
279}
280
281void SearchPanel::OnSearchModeChanged(int mode)

Callers

nothing calls this directly

Calls 6

CancelAllSearchesMethod · 0.80
setVisibleMethod · 0.80
SearchEverywhereMethod · 0.80
SearchInViewportMethod · 0.80
emptyMethod · 0.45
isCheckedMethod · 0.45

Tested by

no test coverage detected