From 12f84d7d2288adf1aadf7ba470403aaf0c705e6d Mon Sep 17 00:00:00 2001 From: AdenKoperczak Date: Thu, 29 Aug 2024 14:07:12 -0400 Subject: [PATCH] Added enable support and sorted keys for WFO audio method --- .../source/scwx/qt/config/county_database.cpp | 4 +-- .../source/scwx/qt/config/county_database.hpp | 3 ++- scwx-qt/source/scwx/qt/ui/settings_dialog.cpp | 26 +++++++++++++++++++ 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/scwx-qt/source/scwx/qt/config/county_database.cpp b/scwx-qt/source/scwx/qt/config/county_database.cpp index 6edcae4d..289025f3 100644 --- a/scwx-qt/source/scwx/qt/config/county_database.cpp +++ b/scwx-qt/source/scwx/qt/config/county_database.cpp @@ -31,7 +31,7 @@ typedef std::unordered_map FormatMap; static bool initialized_ {false}; static FormatMap countyDatabase_; static std::unordered_map stateMap_; -static std::unordered_map wfoMap_; +static std::map wfoMap_; void Initialize() { @@ -264,7 +264,7 @@ const std::unordered_map& GetStates() return stateMap_; } -const std::unordered_map& GetWFOs() +const std::map& GetWFOs() { return wfoMap_; } diff --git a/scwx-qt/source/scwx/qt/config/county_database.hpp b/scwx-qt/source/scwx/qt/config/county_database.hpp index e2d427c6..e135e7ae 100644 --- a/scwx-qt/source/scwx/qt/config/county_database.hpp +++ b/scwx-qt/source/scwx/qt/config/county_database.hpp @@ -4,6 +4,7 @@ #include #include #include +#include namespace scwx { @@ -19,7 +20,7 @@ std::string GetCountyName(const std::string& id); std::unordered_map GetCounties(const std::string& state); const std::unordered_map& GetStates(); -const std::unordered_map& GetWFOs(); +const std::map& GetWFOs(); const std::string& GetWFOName(const std::string& wfoId); } // namespace CountyDatabase diff --git a/scwx-qt/source/scwx/qt/ui/settings_dialog.cpp b/scwx-qt/source/scwx/qt/ui/settings_dialog.cpp index d3a0f73c..1d1a1d03 100644 --- a/scwx-qt/source/scwx/qt/ui/settings_dialog.cpp +++ b/scwx-qt/source/scwx/qt/ui/settings_dialog.cpp @@ -950,6 +950,8 @@ void SettingsDialogImpl::SetupAudioTab() locationMethod == types::LocationMethod::RadarSite; bool countyEntryEnabled = locationMethod == types::LocationMethod::County; + bool wfoEntryEnabled = + locationMethod == types::LocationMethod::WFO; self_->ui->alertAudioLatitudeSpinBox->setEnabled( coordinateEntryEnabled); @@ -976,6 +978,9 @@ void SettingsDialogImpl::SetupAudioTab() self_->ui->alertAudioCountySelectButton->setEnabled( countyEntryEnabled); self_->ui->resetAlertAudioCountyButton->setEnabled(countyEntryEnabled); + + self_->ui->alertAudioWFOComboBox->setEnabled(wfoEntryEnabled); + self_->ui->resetAlertAudioWFOButton->setEnabled(wfoEntryEnabled); }); settings::AudioSettings& audioSettings = settings::AudioSettings::Instance(); @@ -1203,6 +1208,27 @@ void SettingsDialogImpl::SetupAudioTab() self_->ui->alertAudioWFOComboBox->addItem( QString::fromStdString(pair.first)); } + /* + alertAudioWFO_.SetMapFromValueFunction([](const std::string& value) -> std::string { + if (value == "") { + return ""; + } + return config::CountyDatabase::GetWFOs().at(value); + }); + alertAudioWFO_.SetMapToValueFunction([](const std::string& value) -> std::string { + if (value == "") { + return ""; + } + for (const auto& pair : config::CountyDatabase::GetWFOs()) + { + if (value == pair.second) + { + return pair.first; + } + } + + return ""; + });*/ alertAudioWFO_.SetEditWidget(self_->ui->alertAudioWFOComboBox); alertAudioWFO_.SetResetButton(self_->ui->resetAlertAudioWFOButton);