From 4c4c93cad1cc17b7a4b7729c45c70f17a5f5f3ef Mon Sep 17 00:00:00 2001 From: Dan Paulat Date: Mon, 19 Sep 2022 23:46:15 -0500 Subject: [PATCH] Connecting Radar Product Manager creation to Radar Product Model --- scwx-qt/scwx-qt.cmake | 2 ++ scwx-qt/source/scwx/qt/main/main_window.cpp | 5 +-- .../scwx/qt/manager/radar_product_manager.cpp | 3 ++ .../radar_product_manager_notifier.cpp | 34 ++++++++++++++++++ .../radar_product_manager_notifier.hpp | 35 +++++++++++++++++++ .../scwx/qt/model/radar_product_model.cpp | 29 ++++++++++----- 6 files changed, 98 insertions(+), 10 deletions(-) create mode 100644 scwx-qt/source/scwx/qt/manager/radar_product_manager_notifier.cpp create mode 100644 scwx-qt/source/scwx/qt/manager/radar_product_manager_notifier.hpp diff --git a/scwx-qt/scwx-qt.cmake b/scwx-qt/scwx-qt.cmake index ce097ef8..00abbaf4 100644 --- a/scwx-qt/scwx-qt.cmake +++ b/scwx-qt/scwx-qt.cmake @@ -50,9 +50,11 @@ set(HDR_GL_DRAW source/scwx/qt/gl/draw/draw_item.hpp set(SRC_GL_DRAW source/scwx/qt/gl/draw/draw_item.cpp source/scwx/qt/gl/draw/rectangle.cpp) set(HDR_MANAGER source/scwx/qt/manager/radar_product_manager.hpp + source/scwx/qt/manager/radar_product_manager_notifier.hpp source/scwx/qt/manager/resource_manager.hpp source/scwx/qt/manager/settings_manager.hpp) set(SRC_MANAGER source/scwx/qt/manager/radar_product_manager.cpp + source/scwx/qt/manager/radar_product_manager_notifier.cpp source/scwx/qt/manager/resource_manager.cpp source/scwx/qt/manager/settings_manager.cpp) set(HDR_MAP source/scwx/qt/map/color_table_layer.hpp diff --git a/scwx-qt/source/scwx/qt/main/main_window.cpp b/scwx-qt/source/scwx/qt/main/main_window.cpp index 1f8287fe..ce5db8a9 100644 --- a/scwx-qt/source/scwx/qt/main/main_window.cpp +++ b/scwx-qt/source/scwx/qt/main/main_window.cpp @@ -124,8 +124,6 @@ MainWindow::MainWindow(QWidget* parent) : ui->vcpValueLabel->setVisible(false); ui->vcpDescriptionLabel->setVisible(false); - p->ConfigureMapLayout(); - // Configure Menu ui->menuView->insertAction(ui->actionRadarToolbox, ui->radarToolboxDock->toggleViewAction()); @@ -143,6 +141,9 @@ MainWindow::MainWindow(QWidget* parent) : ui->resourceTreeView->setModel(new model::RadarProductModel()); + // Configure Map + p->ConfigureMapLayout(); + // Add Level 2 Products p->level2ProductsWidget_ = new ui::Level2ProductsWidget(this); ui->radarProductGroupBox->layout()->replaceWidget(ui->level2ProductFrame, diff --git a/scwx-qt/source/scwx/qt/manager/radar_product_manager.cpp b/scwx-qt/source/scwx/qt/manager/radar_product_manager.cpp index 8a626476..7c60e933 100644 --- a/scwx-qt/source/scwx/qt/manager/radar_product_manager.cpp +++ b/scwx-qt/source/scwx/qt/manager/radar_product_manager.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -943,6 +944,8 @@ RadarProductManager::Instance(const std::string& radarSite) { instanceMap_[radarSite] = std::make_shared(radarSite); + emit RadarProductManagerNotifier::Instance().RadarProductManagerCreated( + radarSite); } return instanceMap_[radarSite]; diff --git a/scwx-qt/source/scwx/qt/manager/radar_product_manager_notifier.cpp b/scwx-qt/source/scwx/qt/manager/radar_product_manager_notifier.cpp new file mode 100644 index 00000000..b5c0a89b --- /dev/null +++ b/scwx-qt/source/scwx/qt/manager/radar_product_manager_notifier.cpp @@ -0,0 +1,34 @@ +#include + +namespace scwx +{ +namespace qt +{ +namespace manager +{ + +static const std::string logPrefix_ = + "scwx::qt::manager::radar_product_manager_notifier"; + +class RadarProductManagerNotifierImpl +{ +public: + explicit RadarProductManagerNotifierImpl() {} + ~RadarProductManagerNotifierImpl() {} +}; + +RadarProductManagerNotifier::RadarProductManagerNotifier() : + p(std::make_unique()) +{ +} +RadarProductManagerNotifier::~RadarProductManagerNotifier() = default; + +RadarProductManagerNotifier& RadarProductManagerNotifier::Instance() +{ + static RadarProductManagerNotifier instance_ {}; + return instance_; +} + +} // namespace manager +} // namespace qt +} // namespace scwx diff --git a/scwx-qt/source/scwx/qt/manager/radar_product_manager_notifier.hpp b/scwx-qt/source/scwx/qt/manager/radar_product_manager_notifier.hpp new file mode 100644 index 00000000..163ba29f --- /dev/null +++ b/scwx-qt/source/scwx/qt/manager/radar_product_manager_notifier.hpp @@ -0,0 +1,35 @@ +#pragma once + +#include + +#include + +namespace scwx +{ +namespace qt +{ +namespace manager +{ + +class RadarProductManagerNotifierImpl; + +class RadarProductManagerNotifier : public QObject +{ + Q_OBJECT + +public: + explicit RadarProductManagerNotifier(); + ~RadarProductManagerNotifier(); + + static RadarProductManagerNotifier& Instance(); + +signals: + void RadarProductManagerCreated(const std::string& radarSite); + +private: + std::unique_ptr p; +}; + +} // namespace manager +} // namespace qt +} // namespace scwx diff --git a/scwx-qt/source/scwx/qt/model/radar_product_model.cpp b/scwx-qt/source/scwx/qt/model/radar_product_model.cpp index 49453572..b5c33400 100644 --- a/scwx-qt/source/scwx/qt/model/radar_product_model.cpp +++ b/scwx-qt/source/scwx/qt/model/radar_product_model.cpp @@ -1,4 +1,5 @@ #include +#include #include namespace scwx @@ -11,16 +12,12 @@ namespace model static const std::string logPrefix_ = "scwx::qt::model::radar_product_model"; static const auto logger_ = scwx::util::Logger::Create(logPrefix_); -class RadarProductModelImpl +class RadarProductModelImpl : public QObject { + Q_OBJECT + public: - explicit RadarProductModelImpl() : - rootItem_ {std::make_shared( - std::vector {QObject::tr("Name"), QObject::tr("Info")})} - { - rootItem_->AppendChild(new TreeItem( - std::vector {QObject::tr("MyItem"), QObject::tr("Data")})); - } + explicit RadarProductModelImpl(); ~RadarProductModelImpl() = default; std::shared_ptr rootItem_; @@ -37,6 +34,22 @@ const std::shared_ptr RadarProductModel::root_item() const return p->rootItem_; } +RadarProductModelImpl::RadarProductModelImpl() : + rootItem_ {std::make_shared( + std::vector {QObject::tr("Name"), QObject::tr("Info")})} +{ + connect(&manager::RadarProductManagerNotifier::Instance(), + &manager::RadarProductManagerNotifier::RadarProductManagerCreated, + this, + [=](const std::string& radarSite) + { + rootItem_->AppendChild(new TreeItem( + std::vector {QString::fromStdString(radarSite)})); + }); +} + +#include "radar_product_model.moc" + } // namespace model } // namespace qt } // namespace scwx