From 69326e73b29be371dacbdacd741a0a88a5ef1a5b Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Thu, 1 Sep 2022 20:42:01 +0200 Subject: [PATCH] Fix two more badly-adapted instantiations of EditableList and make it harder to make similar errors in the future. --- src/tools/dcpomatic_combiner.cc | 2 +- src/tools/dcpomatic_disk.cc | 2 +- src/tools/dcpomatic_editor.cc | 2 +- src/wx/cinema_dialog.cc | 2 +- src/wx/editable_list.h | 11 +++++++++-- src/wx/extra_kdm_email_dialog.cc | 2 +- src/wx/full_config_dialog.cc | 6 +++--- src/wx/metadata_dialog.cc | 2 +- src/wx/recipient_dialog.cc | 3 ++- src/wx/screen_dialog.cc | 4 ++-- src/wx/smpte_metadata_dialog.cc | 4 ++-- 11 files changed, 24 insertions(+), 16 deletions(-) diff --git a/src/tools/dcpomatic_combiner.cc b/src/tools/dcpomatic_combiner.cc index 5a6457d46..2ef58bb85 100644 --- a/src/tools/dcpomatic_combiner.cc +++ b/src/tools/dcpomatic_combiner.cc @@ -100,7 +100,7 @@ public: boost::bind(&DOMFrame::inputs, this), boost::bind(&DOMFrame::set_inputs, this, _1), &display_string, - true, + EditableListTitle::VISIBLE, EditableListButton::NEW | EditableListButton::REMOVE ); diff --git a/src/tools/dcpomatic_disk.cc b/src/tools/dcpomatic_disk.cc index a517dde65..115dabe46 100644 --- a/src/tools/dcpomatic_disk.cc +++ b/src/tools/dcpomatic_disk.cc @@ -135,7 +135,7 @@ public: boost::bind(&DOMFrame::dcp_paths, this), boost::bind(&DOMFrame::set_dcp_paths, this, _1), [](boost::filesystem::path p, int) { return p.filename().string(); }, - false, + EditableListTitle::INVISIBLE, EditableListButton::NEW | EditableListButton::REMOVE ); diff --git a/src/tools/dcpomatic_editor.cc b/src/tools/dcpomatic_editor.cc index 075cf177f..6bb3c2785 100644 --- a/src/tools/dcpomatic_editor.cc +++ b/src/tools/dcpomatic_editor.cc @@ -221,7 +221,7 @@ public: [](shared_ptr reel, int) { return reel->id(); }, - false, + EditableListTitle::INVISIBLE, EditableListButton::EDIT ); sizer->Add(_reels, wxGBPosition(r, 1), wxDefaultSpan, wxEXPAND); diff --git a/src/wx/cinema_dialog.cc b/src/wx/cinema_dialog.cc index f6007d235..8c7194c4a 100644 --- a/src/wx/cinema_dialog.cc +++ b/src/wx/cinema_dialog.cc @@ -71,7 +71,7 @@ CinemaDialog::CinemaDialog (wxWindow* parent, wxString title, string name, list< _email_list = new EditableList ( this, columns, bind (&CinemaDialog::get_emails, this), bind (&CinemaDialog::set_emails, this, _1), [](string s, int) { return s; - }, false, EditableListButton::NEW | EditableListButton::EDIT | EditableListButton::REMOVE + }, EditableListTitle::INVISIBLE, EditableListButton::NEW | EditableListButton::EDIT | EditableListButton::REMOVE ); sizer->Add (_email_list, wxGBPosition(r, 0), wxGBSpan(1, 2), wxEXPAND); diff --git a/src/wx/editable_list.h b/src/wx/editable_list.h index bd8909048..902d1ccbb 100644 --- a/src/wx/editable_list.h +++ b/src/wx/editable_list.h @@ -61,6 +61,13 @@ namespace EditableListButton }; +enum class EditableListTitle +{ + VISIBLE, + INVISIBLE +}; + + /** @param T type of things being edited. * @param S dialog to edit a thing. * @param get Function to get a std::vector of the things being edited. @@ -77,7 +84,7 @@ public: std::function ()> get, std::function)> set, std::function column, - bool title, + EditableListTitle title, int buttons ) : wxPanel (parent) @@ -91,7 +98,7 @@ public: SetSizer (_sizer); long style = wxLC_REPORT | wxLC_SINGLE_SEL; - if (!title) { + if (title == EditableListTitle::INVISIBLE) { style |= wxLC_NO_HEADER; } diff --git a/src/wx/extra_kdm_email_dialog.cc b/src/wx/extra_kdm_email_dialog.cc index 8a8a37f0a..de11825f4 100644 --- a/src/wx/extra_kdm_email_dialog.cc +++ b/src/wx/extra_kdm_email_dialog.cc @@ -48,7 +48,7 @@ ExtraKDMEmailDialog::ExtraKDMEmailDialog (wxWindow* parent, vector email _email_list = new EditableList ( this, columns, bind(&ExtraKDMEmailDialog::get, this), bind(&ExtraKDMEmailDialog::set, this, _1), [](string s, int) { return s; - }, false, EditableListButton::NEW | EditableListButton::EDIT | EditableListButton::REMOVE + }, EditableListTitle::INVISIBLE, EditableListButton::NEW | EditableListButton::EDIT | EditableListButton::REMOVE ); sizer->Add (_email_list, wxGBPosition(r, 0), wxGBSpan(1, 2), wxEXPAND); diff --git a/src/wx/full_config_dialog.cc b/src/wx/full_config_dialog.cc index 0f99d85d8..40cb0c285 100644 --- a/src/wx/full_config_dialog.cc +++ b/src/wx/full_config_dialog.cc @@ -633,7 +633,7 @@ private: boost::bind (&Config::servers, Config::instance()), boost::bind (&Config::set_servers, Config::instance(), _1), boost::bind (&EncodingServersPage::server_column, this, _1), - false, + EditableListTitle::INVISIBLE, EditableListButton::NEW | EditableListButton::EDIT | EditableListButton::REMOVE ); @@ -991,7 +991,7 @@ private: [] (string s, int) { return s; }, - true, + EditableListTitle::VISIBLE, EditableListButton::NEW | EditableListButton::EDIT | EditableListButton::REMOVE ); table->Add (_cc, 1, wxEXPAND | wxALL); @@ -1128,7 +1128,7 @@ private: [] (string s, int) { return s; }, - true, + EditableListTitle::VISIBLE, EditableListButton::NEW | EditableListButton::EDIT | EditableListButton::REMOVE ); table->Add (_cc, 1, wxEXPAND | wxALL); diff --git a/src/wx/metadata_dialog.cc b/src/wx/metadata_dialog.cc index b1c58a27e..7e0d304f8 100644 --- a/src/wx/metadata_dialog.cc +++ b/src/wx/metadata_dialog.cc @@ -207,7 +207,7 @@ MetadataDialog::setup_standard (wxPanel* panel, wxSizer* sizer) } return r.label; }, - true, + EditableListTitle::VISIBLE, EditableListButton::NEW | EditableListButton::EDIT | EditableListButton::REMOVE ); _ratings->SetMinSize(wxSize(600, -1)); diff --git a/src/wx/recipient_dialog.cc b/src/wx/recipient_dialog.cc index 66b7f0e19..688dcafbd 100644 --- a/src/wx/recipient_dialog.cc +++ b/src/wx/recipient_dialog.cc @@ -91,7 +91,8 @@ RecipientDialog::RecipientDialog ( columns.push_back (EditableListColumn(_("Address"))); _email_list = new EditableList ( this, columns, bind(&RecipientDialog::get_emails, this), bind(&RecipientDialog::set_emails, this, _1), bind(&column, _1), - EditableListButton::NEW | EditableListButton::EDIT | EditableListButton::REMOVE, true + EditableListTitle::VISIBLE, + EditableListButton::NEW | EditableListButton::EDIT | EditableListButton::REMOVE ); _sizer->Add (_email_list, wxGBPosition (r, 0), wxGBSpan (1, 2), wxEXPAND); diff --git a/src/wx/screen_dialog.cc b/src/wx/screen_dialog.cc index 58ea8a328..38e6a85bf 100644 --- a/src/wx/screen_dialog.cc +++ b/src/wx/screen_dialog.cc @@ -178,8 +178,8 @@ ScreenDialog::ScreenDialog ( [] (TrustedDevice const& d, int) { return d.thumbprint(); }, - EditableListButton::NEW | EditableListButton::EDIT | EditableListButton::REMOVE, - false + EditableListTitle::INVISIBLE, + EditableListButton::NEW | EditableListButton::EDIT | EditableListButton::REMOVE ); _sizer->Add (_trusted_device_list, wxGBPosition (r, 0), wxGBSpan (1, 3), wxEXPAND); diff --git a/src/wx/smpte_metadata_dialog.cc b/src/wx/smpte_metadata_dialog.cc index a31b9ad76..afcbfafce 100644 --- a/src/wx/smpte_metadata_dialog.cc +++ b/src/wx/smpte_metadata_dialog.cc @@ -112,8 +112,8 @@ SMPTEMetadataDialog::setup_advanced (wxPanel* panel, wxSizer* sizer) boost::bind(&SMPTEMetadataDialog::content_versions, this), boost::bind(&SMPTEMetadataDialog::set_content_versions, this, _1), boost::bind(&content_versions_column, _1, _2), - true, - false + EditableListTitle::INVISIBLE, + EditableListButton::NEW | EditableListButton::REMOVE ); sizer->Add (_content_versions, 1, wxEXPAND); } -- 2.30.2