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:
Dan Paulat 2023-04-10 23:17:21 -05:00
parent 0c8047b1f4
commit 92bb5154a4
4 changed files with 81 additions and 7 deletions

View file

@ -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();