X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fwx%2Frecipients_panel.cc;h=58a986ca4aef2614e47f872546b2b542e4f64034;hb=7bc2134d658778e04f1756c255e604b4ab5a5831;hp=e4559742fe0ad330d9ecd75e149ce1494dfcabf1;hpb=3e96f929fdf740f414b114c5d9765e22fcc46de6;p=dcpomatic.git diff --git a/src/wx/recipients_panel.cc b/src/wx/recipients_panel.cc index e4559742f..58a986ca4 100644 --- a/src/wx/recipients_panel.cc +++ b/src/wx/recipients_panel.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2015-2020 Carl Hetherington + Copyright (C) 2015-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,42 +18,53 @@ */ + #include "recipients_panel.h" #include "wx_util.h" #include "recipient_dialog.h" #include "dcpomatic_button.h" #include "lib/config.h" -#include #include #include -using std::list; -using std::pair; + using std::cout; +using std::list; +using std::make_pair; using std::map; +using std::pair; +using std::shared_ptr; using std::string; -using std::make_pair; -using boost::shared_ptr; using boost::optional; using namespace dcpomatic; + RecipientsPanel::RecipientsPanel (wxWindow* parent) : wxPanel (parent, wxID_ANY) , _ignore_selection_change (false) { - wxBoxSizer* sizer = new wxBoxSizer (wxVERTICAL); + auto sizer = new wxBoxSizer (wxVERTICAL); + +#ifdef __WXGTK3__ + int const height = 30; +#else + int const height = -1; +#endif - _search = new wxSearchCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (200, -1)); + _search = new wxSearchCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (200, height)); +#ifndef __WXGTK3__ + /* The cancel button seems to be strangely broken in GTK3; clicking on it twice sometimes works */ _search->ShowCancelButton (true); +#endif sizer->Add (_search, 0, wxBOTTOM, DCPOMATIC_SIZER_GAP); - wxBoxSizer* targets = new wxBoxSizer (wxHORIZONTAL); + auto targets = new wxBoxSizer (wxHORIZONTAL); _targets = new wxTreeCtrl (this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTR_HIDE_ROOT | wxTR_MULTIPLE | wxTR_HAS_BUTTONS | wxTR_LINES_AT_ROOT); targets->Add (_targets, 1, wxEXPAND | wxRIGHT, DCPOMATIC_SIZER_GAP); add_recipients (); - wxBoxSizer* target_buttons = new wxBoxSizer (wxVERTICAL); + auto target_buttons = new wxBoxSizer (wxVERTICAL); _add_recipient = new Button (this, _("Add...")); target_buttons->Add (_add_recipient, 1, wxEXPAND | wxBOTTOM, DCPOMATIC_BUTTON_STACK_GAP); @@ -114,9 +125,9 @@ RecipientsPanel::add_recipient (shared_ptr r) void RecipientsPanel::add_recipient_clicked () { - RecipientDialog* d = new RecipientDialog (GetParent(), _("Add recipient")); + auto d = new RecipientDialog (GetParent(), _("Add recipient")); if (d->ShowModal() == wxID_OK) { - shared_ptr r (new DKDMRecipient(d->name(), d->notes(), d->recipient(), d->emails(), d->utc_offset_hour(), d->utc_offset_minute())); + auto r = std::make_shared(d->name(), d->notes(), d->recipient(), d->emails(), d->utc_offset_hour(), d->utc_offset_minute()); Config::instance()->add_dkdm_recipient (r); add_recipient (r); } @@ -132,9 +143,9 @@ RecipientsPanel::edit_recipient_clicked () return; } - pair > c = *_selected.begin(); + auto c = *_selected.begin(); - RecipientDialog* d = new RecipientDialog ( + auto d = new RecipientDialog ( GetParent(), _("Edit recipient"), c.second->name, c.second->notes, c.second->emails, c.second->utc_offset_hour, c.second->utc_offset_minute, c.second->recipient ); @@ -155,22 +166,22 @@ RecipientsPanel::edit_recipient_clicked () void RecipientsPanel::remove_recipient_clicked () { - for (RecipientMap::iterator i = _selected.begin(); i != _selected.end(); ++i) { - Config::instance()->remove_dkdm_recipient (i->second); - _targets->Delete (i->first); + for (auto const& i: _selected) { + Config::instance()->remove_dkdm_recipient (i.second); + _targets->Delete (i.first); } selection_changed (); } -list > +list> RecipientsPanel::recipients () const { - list > r; + list> r; - for (RecipientMap::const_iterator i = _selected.begin(); i != _selected.end(); ++i) { - r.push_back (i->second); + for (auto const& i: _selected) { + r.push_back (i.second); } r.sort (); @@ -216,7 +227,7 @@ RecipientsPanel::add_recipients () { _root = _targets->AddRoot ("Foo"); - BOOST_FOREACH (shared_ptr i, Config::instance()->dkdm_recipients()) { + for (auto i: Config::instance()->dkdm_recipients()) { add_recipient (i); } } @@ -232,10 +243,10 @@ RecipientsPanel::search_changed () _ignore_selection_change = true; - for (RecipientMap::const_iterator i = _selected.begin(); i != _selected.end(); ++i) { + for (auto const& i: _selected) { /* The wxTreeItemIds will now be different, so we must search by recipient */ - RecipientMap::const_iterator j = _recipients.begin (); - while (j != _recipients.end() && j->second != i->second) { + auto j = _recipients.begin (); + while (j != _recipients.end() && j->second != i.second) { ++j; }