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 | |
| parent | 210b3e7f82ce4da354174b40ec7b7a3f572cae4e (diff) | |
Cleanup: extract sorted_cinemas().
| -rw-r--r-- | src/wx/screens_panel.cc | 20 | ||||
| -rw-r--r-- | src/wx/screens_panel.h | 1 |
2 files changed, 14 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); } } diff --git a/src/wx/screens_panel.h b/src/wx/screens_panel.h index 73da029d0..b469c19e3 100644 --- a/src/wx/screens_panel.h +++ b/src/wx/screens_panel.h @@ -76,6 +76,7 @@ private: void config_changed(Config::Property); void convert_to_lower(std::string& s); bool matches_search(std::shared_ptr<const Cinema> cinema, std::string lower_case_search); + std::list<std::shared_ptr<Cinema>> sorted_cinemas() const; std::shared_ptr<Cinema> item_to_cinema (wxTreeListItem item) const; std::shared_ptr<dcpomatic::Screen> item_to_screen (wxTreeListItem item) const; |
