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