mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 08:20: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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue