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>
45 class ScreensPanel : public wxPanel
48 explicit ScreensPanel (wxWindow* parent);
51 std::vector<std::shared_ptr<dcpomatic::Screen>> screens () const;
52 void setup_sensitivity ();
54 boost::signals2::signal<void ()> ScreensChanged;
58 boost::optional<wxTreeListItem> add_cinema (std::shared_ptr<Cinema>, wxTreeListItem previous);
59 boost::optional<wxTreeListItem> add_screen (std::shared_ptr<Cinema>, std::shared_ptr<dcpomatic::Screen>);
60 void add_cinema_clicked ();
61 void edit_cinema_clicked ();
62 void edit_cinema(std::shared_ptr<Cinema> cinema);
63 void remove_cinema_clicked ();
64 void add_screen_clicked ();
65 void edit_screen_clicked ();
66 void edit_screen(std::shared_ptr<dcpomatic::Screen> screen);
67 void remove_screen_clicked ();
68 void selection_changed_shim (wxTreeListEvent &);
69 void selection_changed ();
70 void display_filter_changed();
71 void checkbox_changed (wxTreeListEvent& ev);
72 void item_activated(wxTreeListEvent& ev);
73 std::shared_ptr<Cinema> cinema_for_operation () const;
74 void set_screen_checked (wxTreeListItem item, bool checked);
75 void setup_cinema_checked_state (wxTreeListItem screen);
78 bool notify_cinemas_changed();
79 void clear_and_re_add();
80 void config_changed(Config::Property);
81 void convert_to_lower(std::string& s);
82 bool matches_search(std::shared_ptr<const Cinema> cinema, std::string search);
83 std::list<std::shared_ptr<Cinema>> sorted_cinemas() const;
84 void setup_show_only_checked();
86 std::shared_ptr<Cinema> item_to_cinema (wxTreeListItem item) const;
87 std::shared_ptr<dcpomatic::Screen> item_to_screen (wxTreeListItem item) const;
88 boost::optional<wxTreeListItem> cinema_to_item (std::shared_ptr<Cinema> cinema) const;
89 boost::optional<wxTreeListItem> screen_to_item (std::shared_ptr<dcpomatic::Screen> screen) const;
91 wxBoxSizer* _overall_sizer;
92 wxSearchCtrl* _search;
93 CheckBox* _show_only_checked;
94 wxTreeListCtrl* _targets;
95 wxButton* _add_cinema;
96 wxButton* _edit_cinema;
97 wxButton* _remove_cinema;
98 wxButton* _add_screen;
99 wxButton* _edit_screen;
100 wxButton* _remove_screen;
101 wxButton* _check_all;
102 wxButton* _uncheck_all;
104 /* We want to be able to search (and so remove selected things from the view)
105 * but not deselect them, so we maintain lists of selected cinemas and screens.
107 std::vector<std::shared_ptr<Cinema>> _selected_cinemas;
108 std::vector<std::shared_ptr<dcpomatic::Screen>> _selected_screens;
109 /* Likewise with checked screens, except that we can work out which cinemas
110 * are checked from which screens are checked, so we don't need to store the
113 std::set<std::shared_ptr<dcpomatic::Screen>> _checked_screens;
115 std::map<wxTreeListItem, std::shared_ptr<Cinema>> _item_to_cinema;
116 std::map<wxTreeListItem, std::shared_ptr<dcpomatic::Screen>> _item_to_screen;
117 std::map<std::shared_ptr<Cinema>, wxTreeListItem> _cinema_to_item;
118 std::map<std::shared_ptr<dcpomatic::Screen>, wxTreeListItem> _screen_to_item;
120 bool _ignore_selection_change = false;
121 bool _ignore_check_change = false;
125 boost::signals2::scoped_connection _config_connection;
126 bool _ignore_cinemas_changed = false;