summaryrefslogtreecommitdiff
path: root/src/wx/editable_list.h
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2025-02-20 23:06:59 +0100
committerCarl Hetherington <cth@carlh.net>2025-02-22 23:05:14 +0100
commitb29a0f4bc67f6f8cc84c3d88cdbb9582e35d3fed (patch)
tree8e518d1300e96ea7385c84a490015bf54ad998d6 /src/wx/editable_list.h
parent674b74173d2d0ec8e178fa0938a4c48c2863c38b (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/editable_list.h')
-rw-r--r--src/wx/editable_list.h24
1 files changed, 12 insertions, 12 deletions
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) {