diff options
| author | Carl Hetherington <cth@carlh.net> | 2025-01-17 01:05:17 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2025-01-22 14:34:25 +0100 |
| commit | c29ba2526337b486d4a3b1a1468513a22293bc87 (patch) | |
| tree | b7687a60a19160f0f5c6beaa46e735ebfb4f6f61 | |
| parent | 01a4a87366493d90b4a85ae354c2502f6572407e (diff) | |
Add screens with one query, not one per cinema.
| -rw-r--r-- | src/wx/screens_panel.cc | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/wx/screens_panel.cc b/src/wx/screens_panel.cc index 630e69494..221af30b7 100644 --- a/src/wx/screens_panel.cc +++ b/src/wx/screens_panel.cc @@ -206,8 +206,6 @@ ScreensPanel::add_cinema(CinemaID cinema_id, Cinema const& cinema, wxTreeListIte return {}; } - auto screens = _cinema_list.screens(cinema_id); - if (_show_only_checked->get()) { auto iter = std::find_if(_checked_screens.begin(), _checked_screens.end(), [cinema_id](pair<CinemaID, ScreenID> const& checked) { return checked.first == cinema_id; @@ -223,10 +221,6 @@ ScreensPanel::add_cinema(CinemaID cinema_id, Cinema const& cinema, wxTreeListIte _item_to_cinema.emplace(make_pair(id, cinema_id)); _cinema_to_item[cinema_id] = id; - for (auto screen: screens) { - add_screen(cinema_id, screen.first, screen.second); - } - return id; } @@ -530,9 +524,17 @@ ScreensPanel::selection_changed () void ScreensPanel::add_cinemas () { - for (auto cinema: _cinema_list.cinemas()) { - add_cinema(cinema.first, cinema.second, wxTLI_LAST); + auto previous = wxTLI_LAST; + + for (auto const& cinema: _cinema_list.cinemas()) { + if (auto next = add_cinema(cinema.first, cinema.second, wxTLI_LAST)) { + previous = *next; + } } + + _cinema_list.screens([this](CinemaID cinema_id, ScreenID screen_id, Screen const& screen) { + add_screen(cinema_id, screen_id, screen); + }); } |
