From: Carl Hetherington Date: Wed, 23 Nov 2022 20:03:59 +0000 (+0100) Subject: Cleanup: extract sorted_cinemas(). X-Git-Tag: v2.16.34~22 X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=493ed4867d46e03a08905dd7a938a90c3262b58f Cleanup: extract sorted_cinemas(). --- 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(dialog->name(), dialog->emails(), dialog->notes(), dialog->utc_offset_hour(), dialog->utc_offset_minute()); - auto cinemas = Config::instance()->cinemas(); - cinemas.sort( - [this](shared_ptr a, shared_ptr 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> +ScreensPanel::sorted_cinemas() const { auto cinemas = Config::instance()->cinemas(); + cinemas.sort( [this](shared_ptr a, shared_ptr 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 cinema, std::string lower_case_search); + std::list> sorted_cinemas() const; std::shared_ptr item_to_cinema (wxTreeListItem item) const; std::shared_ptr item_to_screen (wxTreeListItem item) const;