* Selects the specified group in the list * * @param g_id The ID of the group to be selected */
| 1160 | * @param g_id The ID of the group to be selected |
| 1161 | */ |
| 1162 | void SelectGroup(const GroupID g_id) |
| 1163 | { |
| 1164 | if (g_id == GroupID::Invalid() || g_id == this->vli.ToGroupID()) return; |
| 1165 | |
| 1166 | this->vli.SetIndex(g_id); |
| 1167 | if (g_id != ALL_GROUP && g_id != DEFAULT_GROUP) { |
| 1168 | const Group *g = Group::Get(g_id); |
| 1169 | |
| 1170 | auto found = std::ranges::find(this->groups, g, &GUIGroupListItem::group); |
| 1171 | if (found == std::end(this->groups)) { |
| 1172 | /* The group's branch is maybe collapsed, so try to expand it. */ |
| 1173 | for (auto pg = Group::GetIfValid(g->parent); pg != nullptr; pg = Group::GetIfValid(pg->parent)) { |
| 1174 | pg->folded = false; |
| 1175 | } |
| 1176 | this->groups.ForceRebuild(); |
| 1177 | this->BuildGroupList(this->owner); |
| 1178 | this->group_sb->SetCount(this->groups.size()); |
| 1179 | found = std::ranges::find(this->groups, g, &GUIGroupListItem::group); |
| 1180 | } |
| 1181 | if (found != std::end(this->groups)) this->group_sb->ScrollTowards(std::distance(std::begin(this->groups), found)); |
| 1182 | } |
| 1183 | this->vehgroups.ForceRebuild(); |
| 1184 | this->SetDirty(); |
| 1185 | } |
| 1186 | |
| 1187 | }; |
| 1188 |
no test coverage detected