using std::cout;
+using std::list;
using std::make_pair;
using std::make_shared;
using std::map;
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;
wxTreeListItem previous = wxTLI_FIRST;
bool found = false;
+ auto search = wx_to_std(_search->GetValue());
+ convert_to_lower(search);
for (auto existing_cinema: cinemas) {
+ if (!matches_search(existing_cinema, search)) {
+ continue;
+ }
if (_collator.compare(dialog->name(), existing_cinema->name) < 0) {
/* existing_cinema should be after the one we're inserting */
found = true;
}
-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);
}
}