diff options
| author | Carl Hetherington <cth@carlh.net> | 2025-02-20 23:06:59 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2025-02-22 23:05:14 +0100 |
| commit | b29a0f4bc67f6f8cc84c3d88cdbb9582e35d3fed (patch) | |
| tree | 8e518d1300e96ea7385c84a490015bf54ad998d6 /src/wx | |
| parent | 674b74173d2d0ec8e178fa0938a4c48c2863c38b (diff) | |
Return std::vector instead of boost::optional from the EditableList dialog.
It's a bit clumsy, as returning more than one thing only makes sense
when adding (not when editing), but allowing both optional and vector
with template voodoo seems awkward (at least with C++11).
Diffstat (limited to 'src/wx')
| -rw-r--r-- | src/wx/content_version_dialog.cc | 5 | ||||
| -rw-r--r-- | src/wx/content_version_dialog.h | 2 | ||||
| -rw-r--r-- | src/wx/editable_list.h | 24 | ||||
| -rw-r--r-- | src/wx/email_dialog.cc | 10 | ||||
| -rw-r--r-- | src/wx/email_dialog.h | 2 | ||||
| -rw-r--r-- | src/wx/rating_dialog.cc | 4 | ||||
| -rw-r--r-- | src/wx/rating_dialog.h | 2 | ||||
| -rw-r--r-- | src/wx/screen_dialog.cc | 6 | ||||
| -rw-r--r-- | src/wx/server_dialog.cc | 12 | ||||
| -rw-r--r-- | src/wx/server_dialog.h | 2 |
10 files changed, 37 insertions, 32 deletions
diff --git a/src/wx/content_version_dialog.cc b/src/wx/content_version_dialog.cc index 876f43838..bf94e1e53 100644 --- a/src/wx/content_version_dialog.cc +++ b/src/wx/content_version_dialog.cc @@ -24,6 +24,7 @@ using std::string; +using std::vector; using boost::optional; @@ -47,8 +48,8 @@ ContentVersionDialog::set (string r) } -optional<string> +vector<string> ContentVersionDialog::get () const { - return wx_to_std(_version->GetValue()); + return { wx_to_std(_version->GetValue()) }; } diff --git a/src/wx/content_version_dialog.h b/src/wx/content_version_dialog.h index 8407c0475..aec235411 100644 --- a/src/wx/content_version_dialog.h +++ b/src/wx/content_version_dialog.h @@ -30,7 +30,7 @@ public: ContentVersionDialog (wxWindow* parent); void set (std::string); - boost::optional<std::string> get () const; + std::vector<std::string> get() const; private: wxTextCtrl* _version; diff --git a/src/wx/editable_list.h b/src/wx/editable_list.h index 0cb4c841f..f1b74b193 100644 --- a/src/wx/editable_list.h +++ b/src/wx/editable_list.h @@ -235,14 +235,14 @@ private: S dialog(this); if (dialog.ShowModal() == wxID_OK) { - auto const v = dialog.get(); - static_assert(std::is_same<typename std::remove_const<decltype(v)>::type, boost::optional<T>>::value, "get() must return boost::optional<T>"); - if (v) { - add_to_control (v.get ()); - auto all = _get (); - all.push_back (v.get ()); - _set (all); + auto const values = dialog.get(); + static_assert(std::is_same<typename std::remove_const<decltype(values)>::type, std::vector<T>>::value, "get() must return std::vector<T>"); + auto all = _get(); + for (auto item: values) { + add_to_control(item); + all.push_back(item); } + _set(all); } } @@ -259,13 +259,13 @@ private: S dialog(this); dialog.set(all[item]); if (dialog.ShowModal() == wxID_OK) { - auto const v = dialog.get(); - static_assert(std::is_same<typename std::remove_const<decltype(v)>::type, boost::optional<T>>::value, "get() must return boost::optional<T>"); - if (!v) { + auto const value = dialog.get(); + static_assert(std::is_same<typename std::remove_const<decltype(value)>::type, std::vector<T>>::value, "get() must return std::vector<T>"); + if (value.empty()) { return; } - - all[item] = v.get (); + DCPOMATIC_ASSERT(value.size() == 1); + all[item] = value[0]; } for (size_t i = 0; i < _columns.size(); ++i) { diff --git a/src/wx/email_dialog.cc b/src/wx/email_dialog.cc index 50fa66dcc..4f33f9a5a 100644 --- a/src/wx/email_dialog.cc +++ b/src/wx/email_dialog.cc @@ -23,9 +23,9 @@ #include "wx_util.h" -using std::string; using std::shared_ptr; -using boost::optional; +using std::string; +using std::vector; EmailDialog::EmailDialog (wxWindow* parent) @@ -47,8 +47,8 @@ EmailDialog::set (string address) } -optional<string> -EmailDialog::get () const +vector<string> +EmailDialog::get() const { auto s = wx_to_std (_email->GetValue ()); if (s.empty()) { @@ -56,5 +56,5 @@ EmailDialog::get () const return {}; } - return s; + return { s }; } diff --git a/src/wx/email_dialog.h b/src/wx/email_dialog.h index 3f622f87d..e613bb021 100644 --- a/src/wx/email_dialog.h +++ b/src/wx/email_dialog.h @@ -29,7 +29,7 @@ public: explicit EmailDialog (wxWindow *); void set (std::string); - boost::optional<std::string> get () const; + std::vector<std::string> get() const; private: wxTextCtrl* _email; diff --git a/src/wx/rating_dialog.cc b/src/wx/rating_dialog.cc index 083c927c7..d9c432f5e 100644 --- a/src/wx/rating_dialog.cc +++ b/src/wx/rating_dialog.cc @@ -92,10 +92,10 @@ RatingDialog::set (dcp::Rating rating) } -optional<dcp::Rating> +vector<dcp::Rating> RatingDialog::get () const { - return _active_page->get(); + return { _active_page->get() }; } diff --git a/src/wx/rating_dialog.h b/src/wx/rating_dialog.h index 97a56f52e..e8dfc2d9c 100644 --- a/src/wx/rating_dialog.h +++ b/src/wx/rating_dialog.h @@ -90,7 +90,7 @@ public: RatingDialog (wxWindow* parent); void set (dcp::Rating r); - boost::optional<dcp::Rating> get () const; + std::vector<dcp::Rating> get() const; private: void setup_sensitivity (bool ok_valid); diff --git a/src/wx/screen_dialog.cc b/src/wx/screen_dialog.cc index d0cf499e9..21786b8a2 100644 --- a/src/wx/screen_dialog.cc +++ b/src/wx/screen_dialog.cc @@ -86,13 +86,13 @@ public: setup_sensitivity(); } - optional<TrustedDevice> get () + vector<TrustedDevice> get() { auto const t = wx_to_std (_thumbprint->GetValue()); if (_certificate && _certificate->thumbprint() == t) { - return TrustedDevice (*_certificate); + return { TrustedDevice(*_certificate) }; } else if (t.length() == 28) { - return TrustedDevice (t); + return { TrustedDevice(t) }; } return {}; diff --git a/src/wx/server_dialog.cc b/src/wx/server_dialog.cc index ef03609ba..ffc757faa 100644 --- a/src/wx/server_dialog.cc +++ b/src/wx/server_dialog.cc @@ -18,14 +18,18 @@ */ -#include "lib/encode_server.h" + #include "server_dialog.h" #include "wx_util.h" +#include "lib/encode_server.h" + -using std::string; using std::shared_ptr; +using std::string; +using std::vector; using boost::optional; + ServerDialog::ServerDialog (wxWindow* parent) : TableDialog (parent, _("Server"), 2, 1, true) { @@ -51,8 +55,8 @@ ServerDialog::set (string server) _host->SetValue (std_to_wx (server)); } -optional<string> +vector<string> ServerDialog::get () const { - return wx_to_std (_host->GetValue ()); + return { wx_to_std(_host->GetValue()) }; } diff --git a/src/wx/server_dialog.h b/src/wx/server_dialog.h index 92b417a4c..0ff032fc4 100644 --- a/src/wx/server_dialog.h +++ b/src/wx/server_dialog.h @@ -27,7 +27,7 @@ public: explicit ServerDialog (wxWindow *); void set (std::string); - boost::optional<std::string> get () const; + std::vector<std::string> get() const; private: wxTextCtrl* _host; |
