std::shared_ptr
[dcpomatic.git] / src / wx / recipients_panel.h
1 /*
2     Copyright (C) 2015-2020 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 #include "lib/dkdm_recipient.h"
22 #include "lib/warnings.h"
23 DCPOMATIC_DISABLE_WARNINGS
24 #include <wx/wx.h>
25 #include <wx/srchctrl.h>
26 #include <wx/treectrl.h>
27 DCPOMATIC_ENABLE_WARNINGS
28 #include <boost/signals2.hpp>
29 #include <list>
30 #include <map>
31
32 class DKDMRecipient;
33
34 class RecipientsPanel : public wxPanel
35 {
36 public:
37         explicit RecipientsPanel (wxWindow* parent);
38         ~RecipientsPanel ();
39
40         void setup_sensitivity ();
41
42         std::list<std::shared_ptr<DKDMRecipient> > recipients () const;
43         boost::signals2::signal<void ()> RecipientsChanged;
44
45 private:
46         void add_recipients ();
47         void add_recipient (std::shared_ptr<DKDMRecipient>);
48         void add_recipient_clicked ();
49         void edit_recipient_clicked ();
50         void remove_recipient_clicked ();
51         void selection_changed_shim (wxTreeEvent &);
52         void selection_changed ();
53         void search_changed ();
54
55         wxSearchCtrl* _search;
56         wxTreeCtrl* _targets;
57         wxButton* _add_recipient;
58         wxButton* _edit_recipient;
59         wxButton* _remove_recipient;
60         wxTreeItemId _root;
61
62         typedef std::map<wxTreeItemId, std::shared_ptr<DKDMRecipient> > RecipientMap;
63         RecipientMap _recipients;
64         RecipientMap _selected;
65
66         bool _ignore_selection_change;
67 };