mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 18:50:05 +00:00
Enable loading of product by double clicking in the resource explorer
- Doesn't work if radar product manager is expired for the site (time not present in record map) - Need to fix going back to expired (garbage collected) live data
This commit is contained in:
parent
0c8047b1f4
commit
92bb5154a4
4 changed files with 81 additions and 7 deletions
|
|
@ -397,6 +397,67 @@ void MainWindow::on_resourceTreeExpandAllButton_clicked()
|
|||
ui->resourceTreeView->expandAll();
|
||||
}
|
||||
|
||||
void MainWindow::on_resourceTreeView_doubleClicked(const QModelIndex& index)
|
||||
{
|
||||
std::string selectedString {index.data().toString().toStdString()};
|
||||
std::chrono::system_clock::time_point time {};
|
||||
|
||||
logger_->debug("Selecting resource: {}",
|
||||
index.data().toString().toStdString());
|
||||
|
||||
static const std::string timeFormat {"%Y-%m-%d %H:%M:%S"};
|
||||
|
||||
std::istringstream in {selectedString};
|
||||
in >> std::chrono::parse(timeFormat, time);
|
||||
|
||||
if (in.fail())
|
||||
{
|
||||
// Not a time string, ignore double-click
|
||||
return;
|
||||
}
|
||||
|
||||
QModelIndex parent1 = index.parent();
|
||||
QModelIndex parent2 = parent1.parent();
|
||||
QModelIndex parent3 = parent2.parent();
|
||||
|
||||
std::string radarSite {};
|
||||
std::string groupName {};
|
||||
std::string product {};
|
||||
|
||||
if (!parent2.isValid())
|
||||
{
|
||||
// A time entry should be at the third or fourth level
|
||||
logger_->error("Unexpected resource data");
|
||||
return;
|
||||
}
|
||||
|
||||
if (parent3.isValid())
|
||||
{
|
||||
// Level 3 Product
|
||||
radarSite = parent3.data().toString().toStdString();
|
||||
groupName = parent2.data().toString().toStdString();
|
||||
product = parent1.data().toString().toStdString();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Level 2 Product
|
||||
radarSite = parent2.data().toString().toStdString();
|
||||
groupName = parent1.data().toString().toStdString();
|
||||
// No product index
|
||||
}
|
||||
|
||||
common::RadarProductGroup group = common::GetRadarProductGroup(groupName);
|
||||
|
||||
// Update radar site if different from currently selected
|
||||
if (p->activeMap_->GetRadarSite()->id() != radarSite)
|
||||
{
|
||||
p->activeMap_->SelectRadarSite(radarSite);
|
||||
}
|
||||
|
||||
// Select the updated radar product
|
||||
p->activeMap_->SelectRadarProduct(group, product, 0, time);
|
||||
}
|
||||
|
||||
void MainWindowImpl::ConfigureMapLayout()
|
||||
{
|
||||
auto& generalSettings = manager::SettingsManager::general_settings();
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ private slots:
|
|||
void on_radarSiteSelectButton_clicked();
|
||||
void on_resourceTreeCollapseAllButton_clicked();
|
||||
void on_resourceTreeExpandAllButton_clicked();
|
||||
void on_resourceTreeView_doubleClicked(const QModelIndex& index);
|
||||
|
||||
private:
|
||||
std::unique_ptr<MainWindowImpl> p;
|
||||
|
|
|
|||
|
|
@ -307,7 +307,7 @@ std::shared_ptr<config::RadarSite> MapWidget::GetRadarSite() const
|
|||
return radarSite;
|
||||
}
|
||||
|
||||
uint16_t MapWidget::GetVcp() const
|
||||
std::uint16_t MapWidget::GetVcp() const
|
||||
{
|
||||
auto radarProductView = p->context_->radar_product_view();
|
||||
|
||||
|
|
@ -317,7 +317,7 @@ uint16_t MapWidget::GetVcp() const
|
|||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
return 0u;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -334,7 +334,8 @@ void MapWidget::SelectElevation(float elevation)
|
|||
|
||||
void MapWidget::SelectRadarProduct(common::RadarProductGroup group,
|
||||
const std::string& product,
|
||||
int16_t productCode)
|
||||
std::int16_t productCode,
|
||||
std::chrono::system_clock::time_point time)
|
||||
{
|
||||
bool radarProductViewCreated = false;
|
||||
|
||||
|
|
@ -384,8 +385,8 @@ void MapWidget::SelectRadarProduct(common::RadarProductGroup group,
|
|||
|
||||
if (radarProductView != nullptr)
|
||||
{
|
||||
// Always select the latest product available
|
||||
radarProductView->SelectTime({});
|
||||
// Select the time associated with the request
|
||||
radarProductView->SelectTime(time);
|
||||
|
||||
if (radarProductViewCreated)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -41,12 +41,23 @@ public:
|
|||
common::RadarProductGroup GetRadarProductGroup() const;
|
||||
std::string GetRadarProductName() const;
|
||||
std::shared_ptr<config::RadarSite> GetRadarSite() const;
|
||||
uint16_t GetVcp() const;
|
||||
std::uint16_t GetVcp() const;
|
||||
|
||||
void SelectElevation(float elevation);
|
||||
|
||||
/**
|
||||
* @brief Selects a radar product.
|
||||
*
|
||||
* @param [in] group Radar product group
|
||||
* @param [in] product Radar product name
|
||||
* @param [in] productCode Radar product code (optional)
|
||||
* @paran [in] time Product time. Default is the latest available.
|
||||
*/
|
||||
void SelectRadarProduct(common::RadarProductGroup group,
|
||||
const std::string& product,
|
||||
int16_t productCode);
|
||||
std::int16_t productCode = 0,
|
||||
std::chrono::system_clock::time_point time = {});
|
||||
|
||||
void SelectRadarProduct(std::shared_ptr<types::RadarProductRecord> record);
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue