diff options
| author | Carl Hetherington <cth@carlh.net> | 2022-11-23 21:03:59 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2022-11-23 21:23:25 +0100 |
| commit | 493ed4867d46e03a08905dd7a938a90c3262b58f (patch) | |
| tree | 377296c696c713c32d9f28db2b4dc7714e4e2550 /src/wx/screens_panel.cc | |
| parent | 210b3e7f82ce4da354174b40ec7b7a3f572cae4e (diff) | |
Cleanup: extract sorted_cinemas().
Diffstat (limited to 'src/wx/screens_panel.cc')
| -rw-r--r-- | src/wx/screens_panel.cc | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/wx/screens_panel.cc b/src/wx/screens_panel.cc index 272b983d9..b7defe0e9 100644 --- a/src/wx/screens_panel.cc +++ b/src/wx/screens_panel.cc @@ -32,6 +32,7 @@ using std::cout; +using std::list; using std::make_pair; using std::make_shared; using std::map; @@ -235,10 +236,7 @@ ScreensPanel::add_cinema_clicked () if (dialog->ShowModal() == wxID_OK) { auto cinema = make_shared<Cinema>(dialog->name(), dialog->emails(), dialog->notes(), dialog->utc_offset_hour(), dialog->utc_offset_minute()); - auto cinemas = Config::instance()->cinemas(); - cinemas.sort( - [this](shared_ptr<Cinema> a, shared_ptr<Cinema> b) { return _collator.compare(a->name, b->name) < 0; } - ); + auto cinemas = sorted_cinemas(); try { _ignore_cinemas_changed = true; @@ -495,15 +493,23 @@ ScreensPanel::selection_changed () } -void -ScreensPanel::add_cinemas () +list<shared_ptr<Cinema>> +ScreensPanel::sorted_cinemas() const { auto cinemas = Config::instance()->cinemas(); + cinemas.sort( [this](shared_ptr<Cinema> a, shared_ptr<Cinema> b) { return _collator.compare(a->name, b->name) < 0; } ); - for (auto cinema: cinemas) { + return cinemas; +} + + +void +ScreensPanel::add_cinemas () +{ + for (auto cinema: sorted_cinemas()) { add_cinema (cinema, wxTLI_LAST); } } |
