| 222 | } |
| 223 | |
| 224 | void 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 | |
| 281 | void SearchPanel::OnSearchModeChanged(int mode) |
nothing calls this directly
no test coverage detected