2 Copyright (C) 2015-2022 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
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.
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.
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/>.
22 #include "lib/collator.h"
23 #include "lib/config.h"
24 #include <dcp/warnings.h>
25 LIBDCP_DISABLE_WARNINGS
26 #include <wx/srchctrl.h>
27 #include <wx/treelist.h>
29 LIBDCP_ENABLE_WARNINGS
30 #include <boost/signals2.hpp>
44 class ScreensPanel : public wxPanel
47 explicit ScreensPanel (wxWindow* parent);
50 std::vector<std::shared_ptr<dcpomatic::Screen>> screens () const;
51 void setup_sensitivity ();
53 boost::signals2::signal<void ()> ScreensChanged;
57 boost::optional<wxTreeListItem> add_cinema (std::shared_ptr<Cinema>, wxTreeListItem previous);
58 boost::optional<wxTreeListItem> add_screen (std::shared_ptr<Cinema>, std::shared_ptr<dcpomatic::Screen>);
59 void add_cinema_clicked ();
60 void edit_cinema_clicked ();
61 void edit_cinema(std::shared_ptr<Cinema> cinema);
62 void remove_cinema_clicked ();
63 void add_screen_clicked ();
64 void edit_screen_clicked ();
65 void edit_screen(std::shared_ptr<dcpomatic::Screen> screen);
66 void remove_screen_clicked ();
67 void selection_changed_shim (wxTreeListEvent &);
68 void selection_changed ();
69 void search_changed ();
70 void checkbox_changed (wxTreeListEvent& ev);
71 void item_activated(wxTreeListEvent& ev);
72 std::shared_ptr<Cinema> cinema_for_operation () const;
73 void set_screen_checked (wxTreeListItem item, bool checked);
74 void setup_cinema_checked_state (wxTreeListItem screen);
77 bool notify_cinemas_changed();
78 void clear_and_re_add();
79 void config_changed(Config::Property);
80 void convert_to_lower(std::string& s);
81 bool matches_search(std::shared_ptr<const Cinema> cinema, std::string search);
82 std::list<std::shared_ptr<Cinema>> sorted_cinemas() const;
84 std::shared_ptr<Cinema> item_to_cinema (wxTreeListItem item) const;
85 std::shared_ptr<dcpomatic::Screen> item_to_screen (wxTreeListItem item) const;
86 boost::optional<wxTreeListItem> cinema_to_item (std::shared_ptr<Cinema> cinema) const;
87 boost::optional<wxTreeListItem> screen_to_item (std::shared_ptr<dcpomatic::Screen> screen) const;
89 wxSearchCtrl* _search;
90 wxTreeListCtrl* _targets;
91 wxButton* _add_cinema;
92 wxButton* _edit_cinema;
93 wxButton* _remove_cinema;
94 wxButton* _add_screen;
95 wxButton* _edit_screen;
96 wxButton* _remove_screen;
98 wxButton* _uncheck_all;
100 /* We want to be able to search (and so remove selected things from the view)
101 * but not deselect them, so we maintain lists of selected cinemas and screens.
103 std::vector<std::shared_ptr<Cinema>> _selected_cinemas;
104 std::vector<std::shared_ptr<dcpomatic::Screen>> _selected_screens;
105 /* Likewise with checked screens, except that we can work out which cinemas
106 * are checked from which screens are checked, so we don't need to store the
109 std::set<std::shared_ptr<dcpomatic::Screen>> _checked_screens;
111 std::map<wxTreeListItem, std::shared_ptr<Cinema>> _item_to_cinema;
112 std::map<wxTreeListItem, std::shared_ptr<dcpomatic::Screen>> _item_to_screen;
113 std::map<std::shared_ptr<Cinema>, wxTreeListItem> _cinema_to_item;
114 std::map<std::shared_ptr<dcpomatic::Screen>, wxTreeListItem> _screen_to_item;
116 bool _ignore_selection_change = false;
117 bool _ignore_check_change = false;
121 boost::signals2::scoped_connection _config_connection;
122 bool _ignore_cinemas_changed = false;