| 736 | Scrollbar *vscroll = nullptr; |
| 737 | |
| 738 | void BuildSortTownList() |
| 739 | { |
| 740 | if (this->towns.NeedRebuild()) { |
| 741 | this->towns.clear(); |
| 742 | this->towns.reserve(Town::GetNumItems()); |
| 743 | |
| 744 | for (const Town *t : Town::Iterate()) { |
| 745 | if (this->string_filter.IsEmpty()) { |
| 746 | this->towns.push_back(t); |
| 747 | continue; |
| 748 | } |
| 749 | this->string_filter.ResetState(); |
| 750 | this->string_filter.AddLine(t->GetCachedName()); |
| 751 | if (this->string_filter.GetState()) this->towns.push_back(t); |
| 752 | } |
| 753 | |
| 754 | this->towns.RebuildDone(); |
| 755 | this->vscroll->SetCount(this->towns.size()); // Update scrollbar as well. |
| 756 | } |
| 757 | /* Always sort the towns. */ |
| 758 | this->towns.Sort(); |
| 759 | this->SetWidgetDirty(WID_TD_LIST); // Force repaint of the displayed towns. |
| 760 | } |
| 761 | |
| 762 | /** Sort by town name */ |
| 763 | static bool TownNameSorter(const Town * const &a, const Town * const &b, const bool &) |
no test coverage detected