Cleanup: replace some list with vector.
[dcpomatic.git] / src / wx / recipient_dialog.cc
index eecb7c04085cc3d41298d120ededf4ca2f58186e..b166f265d0f5f1a5543046e1098944515fa4d8ac 100644 (file)
 #include "lib/util.h"
 #include <dcp/exceptions.h>
 #include <dcp/certificate_chain.h>
-#include "lib/warnings.h"
-DCPOMATIC_DISABLE_WARNINGS
+#include <dcp/warnings.h>
+LIBDCP_DISABLE_WARNINGS
 #include <wx/filepicker.h>
 #include <wx/validate.h>
-DCPOMATIC_ENABLE_WARNINGS
+LIBDCP_ENABLE_WARNINGS
 #include <iostream>
 
 
 using std::cout;
-using std::list;
 using std::string;
 using std::vector;
 using boost::bind;
@@ -56,12 +55,12 @@ column (string s)
 
 
 RecipientDialog::RecipientDialog (
-       wxWindow* parent, wxString title, string name, string notes, list<string> emails, int utc_offset_hour, int utc_offset_minute, optional<dcp::Certificate> recipient
+       wxWindow* parent, wxString title, string name, string notes, vector<string> emails, int utc_offset_hour, int utc_offset_minute, optional<dcp::Certificate> recipient
        )
        : wxDialog (parent, wxID_ANY, title)
        , _recipient (recipient)
 {
-       wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL);
+       auto overall_sizer = new wxBoxSizer (wxVERTICAL);
        SetSizer (overall_sizer);
 
        _sizer = new wxGridBagSizer (DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
@@ -90,21 +89,23 @@ RecipientDialog::RecipientDialog (
        vector<EditableListColumn> columns;
        columns.push_back (EditableListColumn(_("Address")));
        _email_list = new EditableList<string, EmailDialog> (
-               this, columns, bind(&RecipientDialog::get_emails, this), bind(&RecipientDialog::set_emails, this, _1), bind(&column, _1)
+               this, columns, bind(&RecipientDialog::get_emails, this), bind(&RecipientDialog::set_emails, this, _1), bind(&column, _1),
+               EditableListTitle::VISIBLE,
+               EditableListButton::NEW | EditableListButton::EDIT | EditableListButton::REMOVE
                );
 
        _sizer->Add (_email_list, wxGBPosition (r, 0), wxGBSpan (1, 2), wxEXPAND);
        ++r;
 
         wxClientDC dc (this);
-       wxFont font = _name->GetFont ();
+       auto font = _name->GetFont ();
        font.SetFamily (wxFONTFAMILY_TELETYPE);
        dc.SetFont (font);
-        wxSize size = dc.GetTextExtent (wxT ("1234567890123456789012345678"));
-        size.SetHeight (-1);
+       auto size = dc.GetTextExtent(wxT("1234567890123456789012345678"));
+       size.SetHeight (-1);
 
        add_label_to_sizer (_sizer, this, _("Recipient certificate"), true, wxGBPosition (r, 0));
-       wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
+       auto s = new wxBoxSizer (wxHORIZONTAL);
        _recipient_thumbprint = new StaticText (this, wxT (""), wxDefaultPosition, size);
        _recipient_thumbprint->SetFont (font);
        set_recipient (recipient);
@@ -122,7 +123,7 @@ RecipientDialog::RecipientDialog (
 
        overall_sizer->Add (_sizer, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER);
 
-       wxSizer* buttons = CreateSeparatedButtonSizer (wxOK | wxCANCEL);
+       auto buttons = CreateSeparatedButtonSizer (wxOK | wxCANCEL);
        if (buttons) {
                overall_sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder());
        }
@@ -186,11 +187,10 @@ RecipientDialog::load_recipient (boost::filesystem::path file)
 void
 RecipientDialog::get_recipient_from_file ()
 {
-       wxFileDialog* d = new wxFileDialog (this, _("Select Certificate File"));
+       auto d = make_wx<wxFileDialog>(this, _("Select Certificate File"));
        if (d->ShowModal () == wxID_OK) {
                load_recipient (boost::filesystem::path (wx_to_std (d->GetPath ())));
        }
-       d->Destroy ();
 
        setup_sensitivity ();
 }
@@ -199,7 +199,7 @@ RecipientDialog::get_recipient_from_file ()
 void
 RecipientDialog::setup_sensitivity ()
 {
-       wxButton* ok = dynamic_cast<wxButton*> (FindWindowById (wxID_OK, this));
+       auto ok = dynamic_cast<wxButton*> (FindWindowById (wxID_OK, this));
        if (ok) {
                ok->Enable (static_cast<bool>(_recipient) && !_name->GetValue().IsEmpty());
        }
@@ -232,12 +232,10 @@ RecipientDialog::set_emails (vector<string> e)
 }
 
 
-list<string>
+vector<string>
 RecipientDialog::emails () const
 {
-       list<string> e;
-       copy (_emails.begin(), _emails.end(), back_inserter(e));
-       return e;
+       return _emails;
 }