617ff9adc7cfd0a5674f3a758bf003adcad09910
[dcpomatic.git] / src / wx / screens_panel.cc
1 /*
2     Copyright (C) 2015-2022 Carl Hetherington <cth@carlh.net>
3
4     This file is part of DCP-o-matic.
5
6     DCP-o-matic is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     DCP-o-matic is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
18
19 */
20
21
22 #include "cinema_dialog.h"
23 #include "dcpomatic_button.h"
24 #include "screen_dialog.h"
25 #include "screens_panel.h"
26 #include "wx_util.h"
27 #include "lib/cinema.h"
28 #include "lib/config.h"
29 #include "lib/scope_guard.h"
30 #include "lib/screen.h"
31 #include "lib/timer.h"
32
33
34 using std::cout;
35 using std::list;
36 using std::make_pair;
37 using std::make_shared;
38 using std::map;
39 using std::pair;
40 using std::shared_ptr;
41 using std::string;
42 using std::vector;
43 using boost::optional;
44 #if BOOST_VERSION >= 106100
45 using namespace boost::placeholders;
46 #endif
47 using namespace dcpomatic;
48
49
50 ScreensPanel::ScreensPanel (wxWindow* parent)
51         : wxPanel (parent, wxID_ANY)
52 {
53         auto sizer = new wxBoxSizer (wxVERTICAL);
54
55         _search = new wxSearchCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(200, search_ctrl_height()));
56 #ifndef __WXGTK3__
57         /* The cancel button seems to be strangely broken in GTK3; clicking on it twice sometimes works */
58         _search->ShowCancelButton (true);
59 #endif
60         sizer->Add (_search, 0, wxBOTTOM, DCPOMATIC_SIZER_GAP);
61
62         auto targets = new wxBoxSizer (wxHORIZONTAL);
63         _targets = new wxTreeListCtrl (this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTL_MULTIPLE | wxTL_3STATE | wxTL_NO_HEADER);
64         _targets->AppendColumn (wxT("foo"));
65
66         targets->Add (_targets, 1, wxEXPAND | wxRIGHT, DCPOMATIC_SIZER_GAP);
67
68         add_cinemas ();
69
70         auto side_buttons = new wxBoxSizer (wxVERTICAL);
71
72         auto target_buttons = new wxBoxSizer (wxVERTICAL);
73
74         _add_cinema = new Button (this, _("Add Cinema..."));
75         target_buttons->Add (_add_cinema, 1, wxEXPAND | wxBOTTOM, DCPOMATIC_BUTTON_STACK_GAP);
76         _edit_cinema = new Button (this, _("Edit Cinema..."));
77         target_buttons->Add (_edit_cinema, 1, wxEXPAND | wxBOTTOM, DCPOMATIC_BUTTON_STACK_GAP);
78         _remove_cinema = new Button (this, _("Remove Cinema"));
79         target_buttons->Add (_remove_cinema, 1, wxEXPAND | wxBOTTOM, DCPOMATIC_BUTTON_STACK_GAP);
80         _add_screen = new Button (this, _("Add Screen..."));
81         target_buttons->Add (_add_screen, 1, wxEXPAND | wxBOTTOM, DCPOMATIC_BUTTON_STACK_GAP);
82         _edit_screen = new Button (this, _("Edit Screen..."));
83         target_buttons->Add (_edit_screen, 1, wxEXPAND | wxBOTTOM, DCPOMATIC_BUTTON_STACK_GAP);
84         _remove_screen = new Button (this, _("Remove Screen"));
85         target_buttons->Add (_remove_screen, 1, wxEXPAND | wxBOTTOM, DCPOMATIC_BUTTON_STACK_GAP);
86
87         side_buttons->Add (target_buttons, 0, 0);
88
89         auto check_buttons = new wxBoxSizer (wxVERTICAL);
90
91         _check_all = new Button (this, _("Check all"));
92         check_buttons->Add (_check_all, 1, wxEXPAND | wxBOTTOM, DCPOMATIC_BUTTON_STACK_GAP);
93         _uncheck_all = new Button (this, _("Uncheck all"));
94         check_buttons->Add (_uncheck_all, 1, wxEXPAND | wxBOTTOM, DCPOMATIC_BUTTON_STACK_GAP);
95
96         side_buttons->Add (check_buttons, 1, wxEXPAND | wxTOP, DCPOMATIC_BUTTON_STACK_GAP * 8);
97
98         targets->Add (side_buttons, 0, 0);
99
100         sizer->Add (targets, 1, wxEXPAND);
101
102         _search->Bind        (wxEVT_TEXT, boost::bind (&ScreensPanel::search_changed, this));
103         _targets->Bind       (wxEVT_TREELIST_SELECTION_CHANGED, &ScreensPanel::selection_changed_shim, this);
104         _targets->Bind       (wxEVT_TREELIST_ITEM_CHECKED, &ScreensPanel::checkbox_changed, this);
105         _targets->Bind       (wxEVT_TREELIST_ITEM_ACTIVATED, &ScreensPanel::item_activated, this);
106
107         _add_cinema->Bind    (wxEVT_BUTTON, boost::bind (&ScreensPanel::add_cinema_clicked, this));
108         _edit_cinema->Bind   (wxEVT_BUTTON, boost::bind (&ScreensPanel::edit_cinema_clicked, this));
109         _remove_cinema->Bind (wxEVT_BUTTON, boost::bind (&ScreensPanel::remove_cinema_clicked, this));
110
111         _add_screen->Bind    (wxEVT_BUTTON, boost::bind (&ScreensPanel::add_screen_clicked, this));
112         _edit_screen->Bind   (wxEVT_BUTTON, boost::bind (&ScreensPanel::edit_screen_clicked, this));
113         _remove_screen->Bind (wxEVT_BUTTON, boost::bind (&ScreensPanel::remove_screen_clicked, this));
114
115         _check_all->Bind     (wxEVT_BUTTON, boost::bind(&ScreensPanel::check_all, this));
116         _uncheck_all->Bind   (wxEVT_BUTTON, boost::bind(&ScreensPanel::uncheck_all, this));
117
118         SetSizer (sizer);
119
120         _config_connection = Config::instance()->Changed.connect(boost::bind(&ScreensPanel::config_changed, this, _1));
121 }
122
123
124 ScreensPanel::~ScreensPanel ()
125 {
126         _targets->Unbind (wxEVT_TREELIST_SELECTION_CHANGED, &ScreensPanel::selection_changed_shim, this);
127         _targets->Unbind (wxEVT_TREELIST_ITEM_CHECKED, &ScreensPanel::checkbox_changed, this);
128 }
129
130
131 void
132 ScreensPanel::check_all ()
133 {
134         for (auto cinema = _targets->GetFirstChild(_targets->GetRootItem()); cinema.IsOk();  cinema = _targets->GetNextSibling(cinema)) {
135                 _targets->CheckItem(cinema, wxCHK_CHECKED);
136                 for (auto screen = _targets->GetFirstChild(cinema); screen.IsOk(); screen = _targets->GetNextSibling(screen)) {
137                         _targets->CheckItem(screen, wxCHK_CHECKED);
138                         set_screen_checked(screen, true);
139                 }
140         }
141 }
142
143
144 void
145 ScreensPanel::uncheck_all ()
146 {
147         for (auto cinema = _targets->GetFirstChild(_targets->GetRootItem()); cinema.IsOk();  cinema = _targets->GetNextSibling(cinema)) {
148                 _targets->CheckItem(cinema, wxCHK_UNCHECKED);
149                 for (auto screen = _targets->GetFirstChild(cinema); screen.IsOk(); screen = _targets->GetNextSibling(screen)) {
150                         _targets->CheckItem(screen, wxCHK_UNCHECKED);
151                         set_screen_checked(screen, false);
152                 }
153         }
154 }
155
156
157 void
158 ScreensPanel::setup_sensitivity ()
159 {
160         bool const sc = _selected_cinemas.size() == 1;
161         bool const ss = _selected_screens.size() == 1;
162
163         _edit_cinema->Enable (sc || ss);
164         _remove_cinema->Enable (_selected_cinemas.size() >= 1);
165
166         _add_screen->Enable (sc || ss);
167         _edit_screen->Enable (ss);
168         _remove_screen->Enable (_selected_screens.size() >= 1);
169 }
170
171
172 void
173 ScreensPanel::convert_to_lower(string& s)
174 {
175         transform(s.begin(), s.end(), s.begin(), ::tolower);
176 }
177
178
179 bool
180 ScreensPanel::matches_search(shared_ptr<const Cinema> cinema, string lower_case_search)
181 {
182         if (lower_case_search.empty()) {
183                 return true;
184         }
185
186         auto name = cinema->name;
187         convert_to_lower(name);
188         return name.find(lower_case_search) != string::npos;
189 }
190
191
192 optional<wxTreeListItem>
193 ScreensPanel::add_cinema (shared_ptr<Cinema> cinema, wxTreeListItem previous)
194 {
195         auto search = wx_to_std (_search->GetValue ());
196         convert_to_lower(search);
197         if (!matches_search(cinema, search)) {
198                 return {};
199         }
200
201         auto id = _targets->InsertItem(_targets->GetRootItem(), previous, std_to_wx(cinema->name));
202
203         _item_to_cinema[id] = cinema;
204         _cinema_to_item[cinema] = id;
205
206         for (auto screen: cinema->screens()) {
207                 add_screen (cinema, screen);
208         }
209
210         return id;
211 }
212
213
214 optional<wxTreeListItem>
215 ScreensPanel::add_screen (shared_ptr<Cinema> cinema, shared_ptr<Screen> screen)
216 {
217         auto item = cinema_to_item(cinema);
218         if (!item) {
219                 return {};
220         }
221
222         auto id = _targets->AppendItem(*item, std_to_wx(screen->name));
223
224         _item_to_screen[id] = screen;
225         _screen_to_item[screen] = id;
226
227         return item;
228 }
229
230
231 void
232 ScreensPanel::add_cinema_clicked ()
233 {
234         CinemaDialog dialog(GetParent(), _("Add Cinema"));
235
236         if (dialog.ShowModal() == wxID_OK) {
237                 auto cinema = make_shared<Cinema>(dialog.name(), dialog.emails(), dialog.notes(), dialog.utc_offset_hour(), dialog.utc_offset_minute());
238
239                 auto cinemas = sorted_cinemas();
240
241                 try {
242                         _ignore_cinemas_changed = true;
243                         ScopeGuard sg = [this]() { _ignore_cinemas_changed = false; };
244                         Config::instance()->add_cinema(cinema);
245                 } catch (FileError& e) {
246                         error_dialog(GetParent(), _("Could not write cinema details to the cinemas.xml file.  Check that the location of cinemas.xml is valid in DCP-o-matic's preferences."), std_to_wx(e.what()));
247                         return;
248                 }
249
250                 wxTreeListItem previous = wxTLI_FIRST;
251                 bool found = false;
252                 auto search = wx_to_std(_search->GetValue());
253                 convert_to_lower(search);
254                 for (auto existing_cinema: cinemas) {
255                         if (!matches_search(existing_cinema, search)) {
256                                 continue;
257                         }
258                         if (_collator.compare(dialog.name(), existing_cinema->name) < 0) {
259                                 /* existing_cinema should be after the one we're inserting */
260                                 found = true;
261                                 break;
262                         }
263                         auto item = cinema_to_item(existing_cinema);
264                         DCPOMATIC_ASSERT(item);
265                         previous = *item;
266                 }
267
268                 auto item = add_cinema(cinema, found ? previous : wxTLI_LAST);
269
270                 if (item) {
271                         _targets->UnselectAll ();
272                         _targets->Select (*item);
273                 }
274         }
275
276         selection_changed ();
277 }
278
279
280 shared_ptr<Cinema>
281 ScreensPanel::cinema_for_operation () const
282 {
283         if (_selected_cinemas.size() == 1) {
284                 return _selected_cinemas[0];
285         } else if (_selected_screens.size() == 1) {
286                 return _selected_screens[0]->cinema;
287         }
288
289         return {};
290 }
291
292
293 void
294 ScreensPanel::edit_cinema_clicked ()
295 {
296         auto cinema = cinema_for_operation ();
297         if (cinema) {
298                 edit_cinema(cinema);
299         }
300 }
301
302
303 void
304 ScreensPanel::edit_cinema(shared_ptr<Cinema> cinema)
305 {
306         CinemaDialog dialog(
307                 GetParent(), _("Edit cinema"), cinema->name, cinema->emails, cinema->notes, cinema->utc_offset_hour(), cinema->utc_offset_minute()
308                 );
309
310         if (dialog.ShowModal() == wxID_OK) {
311                 cinema->name = dialog.name();
312                 cinema->emails = dialog.emails();
313                 cinema->notes = dialog.notes();
314                 cinema->set_utc_offset_hour(dialog.utc_offset_hour());
315                 cinema->set_utc_offset_minute(dialog.utc_offset_minute());
316                 notify_cinemas_changed();
317                 auto item = cinema_to_item(cinema);
318                 DCPOMATIC_ASSERT(item);
319                 _targets->SetItemText (*item, std_to_wx(dialog.name()));
320         }
321 }
322
323
324 void
325 ScreensPanel::remove_cinema_clicked ()
326 {
327         if (_selected_cinemas.size() == 1) {
328                 if (!confirm_dialog(this, wxString::Format(_("Are you sure you want to remove the cinema '%s'?"), std_to_wx(_selected_cinemas[0]->name)))) {
329                         return;
330                 }
331         } else {
332                 if (!confirm_dialog(this, wxString::Format(_("Are you sure you want to remove %d cinemas?"), int(_selected_cinemas.size())))) {
333                         return;
334                 }
335         }
336
337         for (auto const& cinema: _selected_cinemas) {
338                 _ignore_cinemas_changed = true;
339                 ScopeGuard sg = [this]() { _ignore_cinemas_changed = false; };
340                 Config::instance()->remove_cinema(cinema);
341                 auto item = cinema_to_item(cinema);
342                 DCPOMATIC_ASSERT(item);
343                 _targets->DeleteItem(*item);
344         }
345
346         selection_changed ();
347 }
348
349
350 void
351 ScreensPanel::add_screen_clicked ()
352 {
353         auto cinema = cinema_for_operation ();
354         if (!cinema) {
355                 return;
356         }
357
358         ScreenDialog dialog(GetParent(), _("Add Screen"));
359
360         if (dialog.ShowModal () != wxID_OK) {
361                 return;
362         }
363
364         for (auto screen: cinema->screens()) {
365                 if (screen->name == dialog.name()) {
366                         error_dialog (
367                                 GetParent(),
368                                 wxString::Format (
369                                         _("You cannot add a screen called '%s' as the cinema already has a screen with this name."),
370                                         std_to_wx(dialog.name()).data()
371                                         )
372                                 );
373                         return;
374                 }
375         }
376
377         auto screen = std::make_shared<Screen>(dialog.name(), dialog.notes(), dialog.recipient(), dialog.recipient_file(), dialog.trusted_devices());
378         cinema->add_screen (screen);
379         notify_cinemas_changed();
380
381         auto id = add_screen (cinema, screen);
382         if (id) {
383                 _targets->Expand (id.get ());
384         }
385 }
386
387
388 void
389 ScreensPanel::edit_screen_clicked ()
390 {
391         if (_selected_screens.size() == 1) {
392                 edit_screen(_selected_screens[0]);
393         }
394 }
395
396
397 void
398 ScreensPanel::edit_screen(shared_ptr<Screen> edit_screen)
399 {
400         ScreenDialog dialog(
401                 GetParent(), _("Edit screen"),
402                 edit_screen->name,
403                 edit_screen->notes,
404                 edit_screen->recipient,
405                 edit_screen->recipient_file,
406                 edit_screen->trusted_devices
407                 );
408
409         if (dialog.ShowModal() != wxID_OK) {
410                 return;
411         }
412
413         auto cinema = edit_screen->cinema;
414         for (auto screen: cinema->screens()) {
415                 if (screen != edit_screen && screen->name == dialog.name()) {
416                         error_dialog (
417                                 GetParent(),
418                                 wxString::Format (
419                                         _("You cannot change this screen's name to '%s' as the cinema already has a screen with this name."),
420                                         std_to_wx(dialog.name()).data()
421                                         )
422                                 );
423                         return;
424                 }
425         }
426
427         edit_screen->name = dialog.name();
428         edit_screen->notes = dialog.notes();
429         edit_screen->recipient = dialog.recipient();
430         edit_screen->recipient_file = dialog.recipient_file();
431         edit_screen->trusted_devices = dialog.trusted_devices();
432         notify_cinemas_changed();
433
434         auto item = screen_to_item(edit_screen);
435         DCPOMATIC_ASSERT (item);
436         _targets->SetItemText(*item, std_to_wx(dialog.name()));
437 }
438
439
440 void
441 ScreensPanel::remove_screen_clicked ()
442 {
443         if (_selected_screens.size() == 1) {
444                 if (!confirm_dialog(this, wxString::Format(_("Are you sure you want to remove the screen '%s'?"), std_to_wx(_selected_screens[0]->name)))) {
445                         return;
446                 }
447         } else {
448                 if (!confirm_dialog(this, wxString::Format(_("Are you sure you want to remove %d screens?"), int(_selected_screens.size())))) {
449                         return;
450                 }
451         }
452
453         for (auto const& screen: _selected_screens) {
454                 screen->cinema->remove_screen(screen);
455                 auto item = screen_to_item(screen);
456                 DCPOMATIC_ASSERT(item);
457                 _targets->DeleteItem(*item);
458         }
459
460         /* This is called by the signal on Linux, but not it seems on Windows, so we call it ourselves
461          * as well.
462          */
463         selection_changed();
464         notify_cinemas_changed();
465 }
466
467
468 vector<shared_ptr<Screen>>
469 ScreensPanel::screens () const
470 {
471         vector<shared_ptr<Screen>> output;
472         std::copy (_checked_screens.begin(), _checked_screens.end(), std::back_inserter(output));
473         return output;
474 }
475
476
477 void
478 ScreensPanel::selection_changed_shim (wxTreeListEvent &)
479 {
480         selection_changed ();
481 }
482
483
484 void
485 ScreensPanel::selection_changed ()
486 {
487         if (_ignore_selection_change) {
488                 return;
489         }
490
491         wxTreeListItems selection;
492         _targets->GetSelections (selection);
493
494         _selected_cinemas.clear ();
495         _selected_screens.clear ();
496
497         for (size_t i = 0; i < selection.size(); ++i) {
498                 if (auto cinema = item_to_cinema(selection[i])) {
499                         _selected_cinemas.push_back(cinema);
500                 }
501                 if (auto screen = item_to_screen(selection[i])) {
502                         _selected_screens.push_back(screen);
503                 }
504         }
505
506         setup_sensitivity ();
507 }
508
509
510 list<shared_ptr<Cinema>>
511 ScreensPanel::sorted_cinemas() const
512 {
513         auto cinemas = Config::instance()->cinemas();
514
515         cinemas.sort(
516                 [this](shared_ptr<Cinema> a, shared_ptr<Cinema> b) { return _collator.compare(a->name, b->name) < 0; }
517                 );
518
519         return cinemas;
520 }
521
522
523 void
524 ScreensPanel::add_cinemas ()
525 {
526         for (auto cinema: sorted_cinemas()) {
527                 add_cinema (cinema, wxTLI_LAST);
528         }
529 }
530
531
532 void
533 ScreensPanel::clear_and_re_add()
534 {
535         _targets->DeleteAllItems ();
536
537         _item_to_cinema.clear ();
538         _cinema_to_item.clear ();
539         _item_to_screen.clear ();
540         _screen_to_item.clear ();
541
542         add_cinemas ();
543 }
544
545
546 void
547 ScreensPanel::search_changed ()
548 {
549         clear_and_re_add();
550
551         _ignore_selection_change = true;
552
553         for (auto const& selection: _selected_cinemas) {
554                 if (auto item = cinema_to_item(selection)) {
555                         _targets->Select (*item);
556                 }
557         }
558
559         for (auto const& selection: _selected_screens) {
560                 if (auto item = screen_to_item(selection)) {
561                         _targets->Select (*item);
562                 }
563         }
564
565         _ignore_selection_change = false;
566
567         _ignore_check_change = true;
568
569         for (auto const& checked: _checked_screens) {
570                 if (auto item = screen_to_item(checked)) {
571                         _targets->CheckItem(*item, wxCHK_CHECKED);
572                         setup_cinema_checked_state(*item);
573                 }
574         }
575
576         _ignore_check_change = false;
577 }
578
579
580 void
581 ScreensPanel::set_screen_checked (wxTreeListItem item, bool checked)
582 {
583         auto screen = item_to_screen(item);
584         DCPOMATIC_ASSERT(screen);
585         if (checked) {
586                 _checked_screens.insert(screen);
587         } else {
588                 _checked_screens.erase(screen);
589         }
590 }
591
592
593 void
594 ScreensPanel::setup_cinema_checked_state (wxTreeListItem screen)
595 {
596         auto cinema = _targets->GetItemParent(screen);
597         DCPOMATIC_ASSERT (cinema.IsOk());
598         int checked = 0;
599         int unchecked = 0;
600         for (auto child = _targets->GetFirstChild(cinema); child.IsOk(); child = _targets->GetNextSibling(child)) {
601                 if (_targets->GetCheckedState(child) == wxCHK_CHECKED) {
602                     ++checked;
603                 } else {
604                     ++unchecked;
605                 }
606         }
607         if (checked == 0) {
608                 _targets->CheckItem(cinema, wxCHK_UNCHECKED);
609         } else if (unchecked == 0) {
610                 _targets->CheckItem(cinema, wxCHK_CHECKED);
611         } else {
612                 _targets->CheckItem(cinema, wxCHK_UNDETERMINED);
613         }
614 }
615
616
617 void
618 ScreensPanel::checkbox_changed (wxTreeListEvent& ev)
619 {
620         if (_ignore_check_change) {
621                 return;
622         }
623
624         if (item_to_cinema(ev.GetItem())) {
625                 /* Cinema: check/uncheck all children */
626                 auto const checked = _targets->GetCheckedState(ev.GetItem());
627                 for (auto child = _targets->GetFirstChild(ev.GetItem()); child.IsOk(); child = _targets->GetNextSibling(child)) {
628                         _targets->CheckItem(child, checked);
629                         set_screen_checked(child, checked);
630                 }
631         } else {
632                 set_screen_checked(ev.GetItem(), _targets->GetCheckedState(ev.GetItem()));
633                 setup_cinema_checked_state(ev.GetItem());
634         }
635
636         ScreensChanged ();
637 }
638
639
640 shared_ptr<Cinema>
641 ScreensPanel::item_to_cinema (wxTreeListItem item) const
642 {
643         auto iter = _item_to_cinema.find (item);
644         if (iter == _item_to_cinema.end()) {
645                 return {};
646         }
647
648         return iter->second;
649 }
650
651
652 shared_ptr<Screen>
653 ScreensPanel::item_to_screen (wxTreeListItem item) const
654 {
655         auto iter = _item_to_screen.find (item);
656         if (iter == _item_to_screen.end()) {
657                 return {};
658         }
659
660         return iter->second;
661 }
662
663
664 optional<wxTreeListItem>
665 ScreensPanel::cinema_to_item (shared_ptr<Cinema> cinema) const
666 {
667         auto iter = _cinema_to_item.find (cinema);
668         if (iter == _cinema_to_item.end()) {
669                 return {};
670         }
671
672         return iter->second;
673 }
674
675
676 optional<wxTreeListItem>
677 ScreensPanel::screen_to_item (shared_ptr<Screen> screen) const
678 {
679         auto iter = _screen_to_item.find (screen);
680         if (iter == _screen_to_item.end()) {
681                 return {};
682         }
683
684         return iter->second;
685 }
686
687
688 bool
689 ScreensPanel::notify_cinemas_changed()
690 {
691         _ignore_cinemas_changed = true;
692         ScopeGuard sg = [this]() { _ignore_cinemas_changed = false; };
693
694         try {
695                 Config::instance()->changed(Config::CINEMAS);
696         } catch (FileError& e) {
697                 error_dialog(GetParent(), _("Could not write cinema details to the cinemas.xml file.  Check that the location of cinemas.xml is valid in DCP-o-matic's preferences."), std_to_wx(e.what()));
698                 return false;
699         }
700
701         return true;
702 }
703
704
705 void
706 ScreensPanel::config_changed(Config::Property property)
707 {
708         if (property == Config::Property::CINEMAS && !_ignore_cinemas_changed) {
709                 clear_and_re_add();
710         }
711 }
712
713
714 void
715 ScreensPanel::item_activated(wxTreeListEvent& ev)
716 {
717         auto iter = _item_to_cinema.find(ev.GetItem());
718         if (iter != _item_to_cinema.end()) {
719                 edit_cinema(iter->second);
720         } else {
721                 auto iter = _item_to_screen.find(ev.GetItem());
722                 if (iter != _item_to_screen.end()) {
723                         edit_screen(iter->second);
724                 }
725         }
726 }
727
728