| 377 | } |
| 378 | |
| 379 | void UpdateDialog::FillTreeImpl(QTreeWidgetItem * parent, CountryId const & countryId, optional<Filter> const & filter) |
| 380 | { |
| 381 | CountriesVec children; |
| 382 | GetStorage().GetChildren(countryId, children); |
| 383 | |
| 384 | size_t posInRanking = kInvalidPos; |
| 385 | string matchedBy; |
| 386 | if (filter) |
| 387 | { |
| 388 | auto const it = filter->find(countryId); |
| 389 | if (it != filter->end()) |
| 390 | { |
| 391 | posInRanking = it->second.first; |
| 392 | matchedBy = it->second.second; |
| 393 | } |
| 394 | } |
| 395 | else |
| 396 | { |
| 397 | posInRanking = kIrrelevantPos; |
| 398 | } |
| 399 | |
| 400 | if (children.empty()) |
| 401 | { |
| 402 | if (filter && posInRanking == kInvalidPos) |
| 403 | return; |
| 404 | |
| 405 | QTreeWidgetItem * item = CreateTreeItem(countryId, posInRanking, matchedBy, parent); |
| 406 | UpdateRowWithCountryInfo(item, countryId); |
| 407 | return; |
| 408 | } |
| 409 | |
| 410 | QTreeWidgetItem * item = CreateTreeItem(countryId, posInRanking, matchedBy, parent); |
| 411 | UpdateRowWithCountryInfo(item, countryId); |
| 412 | |
| 413 | if (filter && posInRanking != kInvalidPos) |
| 414 | { |
| 415 | // Filter matches to the group name, do not filter the group. |
| 416 | for (auto const & child : children) |
| 417 | FillTreeImpl(item, child, {} /* filter */); |
| 418 | |
| 419 | return; |
| 420 | } |
| 421 | |
| 422 | // Filter does not match to the group, but children can. |
| 423 | for (auto const & child : children) |
| 424 | FillTreeImpl(item, child, filter); |
| 425 | |
| 426 | // Drop the item if it has no children. |
| 427 | if (filter && item->childCount() == 0 && parent != nullptr) |
| 428 | { |
| 429 | parent->removeChild(item); |
| 430 | item = nullptr; |
| 431 | } |
| 432 | } |
| 433 | |
| 434 | /// Changes row's text color |
| 435 | void SetRowColor(QTreeWidgetItem & item, QColor const & color) |
nothing calls this directly
no test coverage detected