mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 13:30:06 +00:00
Open alert dialog when an alert is selected on the map
This commit is contained in:
parent
efb03ab9cc
commit
aec52f940d
7 changed files with 37 additions and 4 deletions
|
|
@ -830,6 +830,10 @@ void MainWindowImpl::ConnectMapSignals()
|
|||
{
|
||||
for (const auto& mapWidget : maps_)
|
||||
{
|
||||
connect(mapWidget,
|
||||
&map::MapWidget::AlertSelected,
|
||||
alertDockWidget_,
|
||||
&ui::AlertDockWidget::SelectAlert);
|
||||
connect(mapWidget,
|
||||
&map::MapWidget::MapParametersChanged,
|
||||
this,
|
||||
|
|
|
|||
|
|
@ -109,8 +109,10 @@ signals:
|
|||
class AlertLayer::Impl
|
||||
{
|
||||
public:
|
||||
explicit Impl(std::shared_ptr<MapContext> context,
|
||||
explicit Impl(AlertLayer* self,
|
||||
std::shared_ptr<MapContext> context,
|
||||
awips::Phenomenon phenomenon) :
|
||||
self_ {self},
|
||||
phenomenon_ {phenomenon},
|
||||
geoLines_ {{false, std::make_shared<gl::draw::GeoLines>(context)},
|
||||
{true, std::make_shared<gl::draw::GeoLines>(context)}}
|
||||
|
|
@ -165,6 +167,8 @@ public:
|
|||
boost::container::stable_vector<
|
||||
std::shared_ptr<gl::draw::GeoLineDrawItem>>& drawItems);
|
||||
|
||||
AlertLayer* self_;
|
||||
|
||||
const awips::Phenomenon phenomenon_;
|
||||
|
||||
std::unique_ptr<QObject> receiver_ {std::make_unique<QObject>()};
|
||||
|
|
@ -190,7 +194,7 @@ public:
|
|||
|
||||
AlertLayer::AlertLayer(std::shared_ptr<MapContext> context,
|
||||
awips::Phenomenon phenomenon) :
|
||||
DrawLayer(context), p(std::make_unique<Impl>(context, phenomenon))
|
||||
DrawLayer(context), p(std::make_unique<Impl>(this, context, phenomenon))
|
||||
{
|
||||
for (auto alertActive : {false, true})
|
||||
{
|
||||
|
|
@ -536,7 +540,9 @@ void AlertLayer::Impl::HandleGeoLinesEvent(
|
|||
auto it = segmentsByLine_.find(di);
|
||||
if (it != segmentsByLine_.cend())
|
||||
{
|
||||
logger_->info("Selected alert: {}", it->second->key_.ToString());
|
||||
// Display alert dialog
|
||||
logger_->debug("Selected alert: {}", it->second->key_.ToString());
|
||||
Q_EMIT self_->AlertSelected(it->second->key_);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include <scwx/awips/phenomenon.hpp>
|
||||
#include <scwx/qt/map/draw_layer.hpp>
|
||||
#include <scwx/qt/types/text_event_key.hpp>
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
|
@ -16,6 +17,7 @@ namespace map
|
|||
|
||||
class AlertLayer : public DrawLayer
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY_MOVE(AlertLayer)
|
||||
|
||||
public:
|
||||
|
|
@ -27,6 +29,9 @@ public:
|
|||
void Render(const QMapLibre::CustomLayerRenderParameters&) override final;
|
||||
void Deinitialize() override final;
|
||||
|
||||
signals:
|
||||
void AlertSelected(const types::TextEventKey& key);
|
||||
|
||||
private:
|
||||
class Impl;
|
||||
std::unique_ptr<Impl> p;
|
||||
|
|
|
|||
|
|
@ -1180,9 +1180,15 @@ void MapWidgetImpl::AddLayer(types::LayerType type,
|
|||
{
|
||||
auto phenomenon = std::get<awips::Phenomenon>(description);
|
||||
|
||||
std::shared_ptr<AlertLayer> alertLayer =
|
||||
std::make_shared<AlertLayer>(context_, phenomenon);
|
||||
AddLayer(fmt::format("alert.{}", awips::GetPhenomenonCode(phenomenon)),
|
||||
std::make_shared<AlertLayer>(context_, phenomenon),
|
||||
alertLayer,
|
||||
before);
|
||||
connect(alertLayer.get(),
|
||||
&AlertLayer::AlertSelected,
|
||||
widget_,
|
||||
&MapWidget::AlertSelected);
|
||||
}
|
||||
else if (type == types::LayerType::Placefile)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
#include <scwx/qt/config/radar_site.hpp>
|
||||
#include <scwx/qt/types/map_types.hpp>
|
||||
#include <scwx/qt/types/radar_product_record.hpp>
|
||||
#include <scwx/qt/types/text_event_key.hpp>
|
||||
|
||||
#include <chrono>
|
||||
#include <memory>
|
||||
|
|
@ -150,6 +151,7 @@ private slots:
|
|||
void mapChanged(QMapLibre::Map::MapChange);
|
||||
|
||||
signals:
|
||||
void AlertSelected(const types::TextEventKey& key);
|
||||
void Level3ProductsChanged();
|
||||
void MapParametersChanged(double latitude,
|
||||
double longitude,
|
||||
|
|
|
|||
|
|
@ -114,6 +114,13 @@ void AlertDockWidget::HandleMapUpdate(double latitude, double longitude)
|
|||
}
|
||||
}
|
||||
|
||||
void AlertDockWidget::SelectAlert(const types::TextEventKey& key)
|
||||
{
|
||||
// View alert
|
||||
p->alertDialog_->SelectAlert(key);
|
||||
p->alertDialog_->show();
|
||||
}
|
||||
|
||||
void AlertDockWidgetImpl::ConnectSignals()
|
||||
{
|
||||
connect(self_->ui->alertFilter,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <scwx/qt/types/text_event_key.hpp>
|
||||
|
||||
#include <QDockWidget>
|
||||
|
||||
namespace Ui
|
||||
|
|
@ -32,6 +34,7 @@ signals:
|
|||
|
||||
public slots:
|
||||
void HandleMapUpdate(double latitude, double longitude);
|
||||
void SelectAlert(const types::TextEventKey& key);
|
||||
|
||||
private:
|
||||
friend class AlertDockWidgetImpl;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue