From cb330f076f72000d028b11e88702addb0a2ab480 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 5 Jan 2024 01:26:58 +0100 Subject: [PATCH] Add Choice::set_by_data(). --- src/lib/wscript | 1 + src/wx/dcpomatic_choice.cc | 14 ++++++++++++++ src/wx/dcpomatic_choice.h | 1 + 3 files changed, 16 insertions(+) diff --git a/src/lib/wscript b/src/lib/wscript index dad8947b1..ce36832be 100644 --- a/src/lib/wscript +++ b/src/lib/wscript @@ -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 diff --git a/src/wx/dcpomatic_choice.cc b/src/wx/dcpomatic_choice.cc index b639dd0f9..2f1a6f0e9 100644 --- a/src/wx/dcpomatic_choice.cc +++ b/src/wx/dcpomatic_choice.cc @@ -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(GetClientObject(i))) { + if (client_data->GetData() == data) { + set(i); + return; + } + } + } +} + + optional Choice::get() const { diff --git a/src/wx/dcpomatic_choice.h b/src/wx/dcpomatic_choice.h index e663c948d..dec0a3701 100644 --- a/src/wx/dcpomatic_choice.h +++ b/src/wx/dcpomatic_choice.h @@ -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 get() const; boost::optional get_data() const; -- 2.30.2