mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 13:30:06 +00:00
Update L3 product category selection to work better for tdwr
This commit is contained in:
parent
504cde0e8b
commit
6509fc7043
3 changed files with 38 additions and 6 deletions
|
|
@ -60,7 +60,9 @@ public:
|
|||
categoryButtons_ {},
|
||||
productTiltMap_ {},
|
||||
awipsProductMap_ {},
|
||||
awipsProductMutex_ {}
|
||||
awipsProductMutex_ {},
|
||||
categoryMap_ {},
|
||||
categoryMapMutex_ {}
|
||||
{
|
||||
layout_->setContentsMargins(0, 0, 0, 0);
|
||||
layout_->addWidget(productsWidget_);
|
||||
|
|
@ -183,6 +185,9 @@ public:
|
|||
std::unordered_map<QAction*, std::string> awipsProductMap_;
|
||||
std::shared_mutex awipsProductMutex_;
|
||||
|
||||
common::Level3ProductCategoryMap categoryMap_;
|
||||
std::shared_mutex categoryMapMutex_;
|
||||
|
||||
std::string currentAwipsId_ {};
|
||||
QAction* currentProductTiltAction_ {nullptr};
|
||||
|
||||
|
|
@ -322,9 +327,11 @@ void Level3ProductsWidgetImpl::SelectProductCategory(
|
|||
{
|
||||
UpdateCategorySelection(category);
|
||||
|
||||
std::shared_lock lock {categoryMapMutex_};
|
||||
|
||||
Q_EMIT self_->RadarProductSelected(
|
||||
common::RadarProductGroup::Level3,
|
||||
common::GetLevel3CategoryDefaultProduct(category),
|
||||
common::GetLevel3CategoryDefaultProduct(category, categoryMap_),
|
||||
0);
|
||||
}
|
||||
|
||||
|
|
@ -333,6 +340,12 @@ void Level3ProductsWidget::UpdateAvailableProducts(
|
|||
{
|
||||
logger_->trace("UpdateAvailableProducts()");
|
||||
|
||||
// Save the category map
|
||||
{
|
||||
std::unique_lock lock {p->categoryMapMutex_};
|
||||
p->categoryMap_ = updatedCategoryMap;
|
||||
}
|
||||
|
||||
// Iterate through each category tool button
|
||||
std::for_each(
|
||||
p->categoryButtons_.cbegin(),
|
||||
|
|
|
|||
|
|
@ -73,8 +73,9 @@ Level2Product GetLevel2Product(const std::string& name);
|
|||
|
||||
const std::string& GetLevel3CategoryName(Level3ProductCategory category);
|
||||
const std::string& GetLevel3CategoryDescription(Level3ProductCategory category);
|
||||
const std::string&
|
||||
GetLevel3CategoryDefaultProduct(Level3ProductCategory category);
|
||||
std::string
|
||||
GetLevel3CategoryDefaultProduct(Level3ProductCategory category,
|
||||
const Level3ProductCategoryMap& categoryMap);
|
||||
Level3ProductCategory GetLevel3Category(const std::string& categoryName);
|
||||
Level3ProductCategory
|
||||
GetLevel3CategoryByProduct(const std::string& productName);
|
||||
|
|
|
|||
|
|
@ -298,9 +298,27 @@ const std::string& GetLevel3CategoryDescription(Level3ProductCategory category)
|
|||
return level3CategoryDescription_.at(category);
|
||||
}
|
||||
|
||||
const std::string&
|
||||
GetLevel3CategoryDefaultProduct(Level3ProductCategory category)
|
||||
std::string
|
||||
GetLevel3CategoryDefaultProduct(Level3ProductCategory category,
|
||||
const Level3ProductCategoryMap& categoryMap)
|
||||
{
|
||||
const auto& productsIt = categoryMap.find(category);
|
||||
if (productsIt == categoryMap.cend())
|
||||
{
|
||||
return level3CategoryDefaultAwipsId_.at(category);
|
||||
}
|
||||
|
||||
const auto& productsSiteHas = productsIt->second;
|
||||
const auto& productList = level3CategoryProductList_.at(category);
|
||||
for (auto& product : productList)
|
||||
{
|
||||
const auto& tiltsIt = productsSiteHas.find(product);
|
||||
if (tiltsIt != productsSiteHas.cend() && tiltsIt->second.size() > 0)
|
||||
{
|
||||
return tiltsIt->second[0];
|
||||
}
|
||||
}
|
||||
|
||||
return level3CategoryDefaultAwipsId_.at(category);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue