Add Choice::set_by_data().
authorCarl Hetherington <cth@carlh.net>
Fri, 5 Jan 2024 00:26:58 +0000 (01:26 +0100)
committerCarl Hetherington <cth@carlh.net>
Fri, 5 Jan 2024 16:06:21 +0000 (17:06 +0100)
src/lib/wscript
src/wx/dcpomatic_choice.cc
src/wx/dcpomatic_choice.h

index dad8947b19d670fa50ace23264026669300e3cce..ce36832bebe13174f833c7b52b6f183a0df7c8d3 100644 (file)
@@ -184,6 +184,7 @@ sources = """
           string_text_file_decoder.cc
           subtitle_analysis.cc
           subtitle_encoder.cc
+          territory_type.cc
           text_ring_buffers.cc
           text_type.cc
           timer.cc
index b639dd0f912540c5e8e060784970dac16599764a..2f1a6f0e9b782b34d006912afd71b9cc5350fc13 100644 (file)
@@ -89,6 +89,20 @@ Choice::set(int index)
 }
 
 
+void
+Choice::set_by_data(wxString const& data)
+{
+       for (unsigned int i = 0; i < GetCount(); ++i) {
+               if (auto client_data = dynamic_cast<wxStringClientData*>(GetClientObject(i))) {
+                       if (client_data->GetData() == data) {
+                               set(i);
+                               return;
+                       }
+               }
+       }
+}
+
+
 optional<int>
 Choice::get() const
 {
index e663c948dd96dd2a1fa656082a23ed2f2c4da3ef..dec0a3701684bbdff6d4bb1114929bc5fc980b1e 100644 (file)
@@ -37,6 +37,7 @@ public:
        void add(wxString const& entry, wxString const& data);
        void add(std::string const& entry);
        void set(int index);
+       void set_by_data(wxString const& data);
        boost::optional<int> get() const;
        boost::optional<wxString> get_data() const;