From ce426bacc9225444c89be34d8623a7be56405b98 Mon Sep 17 00:00:00 2001 From: Dan Paulat Date: Sun, 5 Nov 2023 07:52:59 -0600 Subject: [PATCH] Remove resource explorer --- scwx-qt/scwx-qt.cmake | 2 - scwx-qt/source/scwx/qt/main/main_window.cpp | 93 ------------- scwx-qt/source/scwx/qt/main/main_window.hpp | 3 - scwx-qt/source/scwx/qt/main/main_window.ui | 80 ----------- .../scwx/qt/model/radar_product_model.cpp | 127 ------------------ .../scwx/qt/model/radar_product_model.hpp | 30 ----- 6 files changed, 335 deletions(-) delete mode 100644 scwx-qt/source/scwx/qt/model/radar_product_model.cpp delete mode 100644 scwx-qt/source/scwx/qt/model/radar_product_model.hpp diff --git a/scwx-qt/scwx-qt.cmake b/scwx-qt/scwx-qt.cmake index 50767c34..ddbb93cb 100644 --- a/scwx-qt/scwx-qt.cmake +++ b/scwx-qt/scwx-qt.cmake @@ -122,7 +122,6 @@ set(HDR_MODEL source/scwx/qt/model/alert_model.hpp source/scwx/qt/model/imgui_context_model.hpp source/scwx/qt/model/layer_model.hpp source/scwx/qt/model/placefile_model.hpp - source/scwx/qt/model/radar_product_model.hpp source/scwx/qt/model/radar_site_model.hpp source/scwx/qt/model/tree_item.hpp source/scwx/qt/model/tree_model.hpp) @@ -131,7 +130,6 @@ set(SRC_MODEL source/scwx/qt/model/alert_model.cpp source/scwx/qt/model/imgui_context_model.cpp source/scwx/qt/model/layer_model.cpp source/scwx/qt/model/placefile_model.cpp - source/scwx/qt/model/radar_product_model.cpp source/scwx/qt/model/radar_site_model.cpp source/scwx/qt/model/tree_item.cpp source/scwx/qt/model/tree_model.cpp) diff --git a/scwx-qt/source/scwx/qt/main/main_window.cpp b/scwx-qt/source/scwx/qt/main/main_window.cpp index 5c2a94fc..f628f367 100644 --- a/scwx-qt/source/scwx/qt/main/main_window.cpp +++ b/scwx-qt/source/scwx/qt/main/main_window.cpp @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include @@ -84,7 +83,6 @@ public: radarSiteDialog_ {nullptr}, settingsDialog_ {nullptr}, updateDialog_ {nullptr}, - radarProductModel_ {nullptr}, placefileManager_ {manager::PlacefileManager::Instance()}, textEventManager_ {manager::TextEventManager::Instance()}, timelineManager_ {manager::TimelineManager::Instance()}, @@ -175,7 +173,6 @@ public: ui::SettingsDialog* settingsDialog_; ui::UpdateDialog* updateDialog_; - std::unique_ptr radarProductModel_; std::shared_ptr placefileManager_; std::shared_ptr textEventManager_; std::shared_ptr timelineManager_; @@ -222,13 +219,6 @@ MainWindow::MainWindow(QWidget* parent) : ui->radarToolboxDock->toggleViewAction()->setText(tr("Radar &Toolbox")); ui->actionRadarToolbox->setVisible(false); - ui->menuView->insertAction(ui->actionResourceExplorer, - ui->resourceExplorerDock->toggleViewAction()); - ui->resourceExplorerDock->toggleViewAction()->setText( - tr("&Resource Explorer")); - ui->actionResourceExplorer->setVisible(false); - ui->resourceExplorerDock->toggleViewAction()->setVisible(false); - ui->menuView->insertAction(ui->actionAlerts, p->alertDockWidget_->toggleViewAction()); p->alertDockWidget_->toggleViewAction()->setText(tr("&Alerts")); @@ -237,12 +227,6 @@ MainWindow::MainWindow(QWidget* parent) : ui->menuDebug->menuAction()->setVisible( settings::GeneralSettings::Instance().debug_enabled().GetValue()); - // Configure Resource Explorer Dock - ui->resourceExplorerDock->setVisible(false); - - p->radarProductModel_ = std::make_unique(); - ui->resourceTreeView->setModel(p->radarProductModel_->model()); - // Configure Map p->ConfigureMapLayout(); @@ -529,83 +513,6 @@ void MainWindow::on_radarSiteSelectButton_clicked() p->radarSiteDialog_->show(); } -void MainWindow::on_resourceTreeCollapseAllButton_clicked() -{ - ui->resourceTreeView->collapseAll(); -} - -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"}; - - using namespace std::chrono; - -#if !defined(_MSC_VER) - using namespace date; -#endif - - std::istringstream in {selectedString}; - in >> 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::AsyncSetup() { auto& generalSettings = settings::GeneralSettings::Instance(); diff --git a/scwx-qt/source/scwx/qt/main/main_window.hpp b/scwx-qt/source/scwx/qt/main/main_window.hpp index f4532f44..82bda744 100644 --- a/scwx-qt/source/scwx/qt/main/main_window.hpp +++ b/scwx-qt/source/scwx/qt/main/main_window.hpp @@ -47,9 +47,6 @@ private slots: void on_actionCheckForUpdates_triggered(); void on_actionAboutSupercellWx_triggered(); void on_radarSiteSelectButton_clicked(); - void on_resourceTreeCollapseAllButton_clicked(); - void on_resourceTreeExpandAllButton_clicked(); - void on_resourceTreeView_doubleClicked(const QModelIndex& index); private: std::unique_ptr p; diff --git a/scwx-qt/source/scwx/qt/main/main_window.ui b/scwx-qt/source/scwx/qt/main/main_window.ui index 628d6ddc..9cd627eb 100644 --- a/scwx-qt/source/scwx/qt/main/main_window.ui +++ b/scwx-qt/source/scwx/qt/main/main_window.ui @@ -76,7 +76,6 @@ &View - @@ -268,80 +267,6 @@ - - - Resource Explorer - - - 2 - - - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Qt::Horizontal - - - - 193 - 20 - - - - - - - - Expand All - - - - :/res/icons/font-awesome-6/square-plus-regular.svg:/res/icons/font-awesome-6/square-plus-regular.svg - - - - - - - Collapse All - - - - :/res/icons/font-awesome-6/square-minus-regular.svg:/res/icons/font-awesome-6/square-minus-regular.svg - - - - - - - - - - - - E&xit @@ -357,11 +282,6 @@ Radar &Toolbox - - - &Resource Explorer - - &NEXRAD Product... diff --git a/scwx-qt/source/scwx/qt/model/radar_product_model.cpp b/scwx-qt/source/scwx/qt/model/radar_product_model.cpp deleted file mode 100644 index 9b4a0ebe..00000000 --- a/scwx-qt/source/scwx/qt/model/radar_product_model.cpp +++ /dev/null @@ -1,127 +0,0 @@ -#include -#include -#include -#include -#include -#include - -namespace scwx -{ -namespace qt -{ -namespace model -{ - -static const std::string logPrefix_ = "scwx::qt::model::radar_product_model"; -static const auto logger_ = scwx::util::Logger::Create(logPrefix_); - -class RadarProductModelImpl : public QObject -{ - Q_OBJECT - -public: - explicit RadarProductModelImpl(RadarProductModel* self); - ~RadarProductModelImpl() = default; - - RadarProductModel* self_; - std::unique_ptr model_; -}; - -RadarProductModel::RadarProductModel() : - p(std::make_unique(this)) -{ -} -RadarProductModel::~RadarProductModel() = default; - -QAbstractItemModel* RadarProductModel::model() -{ - return p->model_.get(); -} - -RadarProductModelImpl::RadarProductModelImpl(RadarProductModel* self) : - self_ {self}, - model_ {std::make_unique( - std::vector {QObject::tr("Product")})} -{ - connect( - &manager::RadarProductManagerNotifier::Instance(), - &manager::RadarProductManagerNotifier::RadarProductManagerCreated, - this, - [this](const std::string& radarSite) - { - logger_->debug("Adding radar site: {}", radarSite); - - const QString radarSiteName {QString::fromStdString(radarSite)}; - - // Find existing radar site item (e.g., KLSX, KEAX) - TreeItem* radarSiteItem = - model_->root_item()->FindChild(0, radarSiteName); - - if (radarSiteItem == nullptr) - { - radarSiteItem = new TreeItem({radarSiteName}); - model_->AppendRow(model_->root_item(), radarSiteItem); - } - - connect( - manager::RadarProductManager::Instance(radarSite).get(), - &manager::RadarProductManager::NewDataAvailable, - this, - [=, this](common::RadarProductGroup group, - const std::string& product, - std::chrono::system_clock::time_point latestTime) - { - const QString groupName {QString::fromStdString( - common::GetRadarProductGroupName(group))}; - - // Find existing group item (e.g., Level 2, Level 3) - TreeItem* groupItem = radarSiteItem->FindChild(0, groupName); - - if (groupItem == nullptr) - { - // Existing group item was not found, create it - groupItem = new TreeItem({groupName}); - model_->AppendRow(radarSiteItem, groupItem); - } - - TreeItem* productItem = nullptr; - - if (group == common::RadarProductGroup::Level2) - { - // Level 2 items are not separated by product - productItem = groupItem; - } - else - { - // Find existing product item (e.g., N0B, N0Q) - const QString productName {QString::fromStdString(product)}; - productItem = groupItem->FindChild(0, productName); - - if (productItem == nullptr) - { - // Existing product item was not found, create it - productItem = new TreeItem({productName}); - model_->AppendRow(groupItem, productItem); - } - } - - // Find existing time item (e.g., 2023-04-10 10:11:12) - const QString timeString = - QString::fromStdString(util::TimeString(latestTime)); - TreeItem* timeItem = productItem->FindChild(0, timeString); - - if (timeItem == nullptr) - { - // Create leaf item for product time - model_->AppendRow(productItem, new TreeItem {timeString}); - } - }, - Qt::QueuedConnection); - }); -} - -#include "radar_product_model.moc" - -} // namespace model -} // namespace qt -} // namespace scwx diff --git a/scwx-qt/source/scwx/qt/model/radar_product_model.hpp b/scwx-qt/source/scwx/qt/model/radar_product_model.hpp deleted file mode 100644 index 20ac0d2c..00000000 --- a/scwx-qt/source/scwx/qt/model/radar_product_model.hpp +++ /dev/null @@ -1,30 +0,0 @@ -#pragma once - -#include - -namespace scwx -{ -namespace qt -{ -namespace model -{ - -class RadarProductModelImpl; - -class RadarProductModel -{ -public: - explicit RadarProductModel(); - ~RadarProductModel(); - - QAbstractItemModel* model(); - -private: - std::unique_ptr p; - - friend class RadarProductModelImpl; -}; - -} // namespace model -} // namespace qt -} // namespace scwx