mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 01:10:04 +00:00 
			
		
		
		
	Calculate distance to each radar site from current location
This commit is contained in:
		
							parent
							
								
									6e7a13494a
								
							
						
					
					
						commit
						3a4819aeff
					
				
					 7 changed files with 192 additions and 70 deletions
				
			
		|  | @ -3,6 +3,7 @@ | |||
| 
 | ||||
| #include <scwx/qt/common/types.hpp> | ||||
| #include <scwx/qt/model/radar_site_model.hpp> | ||||
| #include <scwx/common/geographic.hpp> | ||||
| #include <scwx/util/logger.hpp> | ||||
| 
 | ||||
| #include <QSortFilterProxyModel> | ||||
|  | @ -23,7 +24,9 @@ public: | |||
|    explicit RadarSiteDialogImpl(RadarSiteDialog* self) : | ||||
|        self_ {self}, | ||||
|        radarSiteModel_ {new model::RadarSiteModel(self_)}, | ||||
|        proxyModel_ {new QSortFilterProxyModel(self_)} | ||||
|        proxyModel_ {new QSortFilterProxyModel(self_)}, | ||||
|        mapPosition_ {}, | ||||
|        mapUpdateDeferred_ {false} | ||||
|    { | ||||
|       proxyModel_->setSourceModel(radarSiteModel_); | ||||
|       proxyModel_->setSortRole(common::SortRole); | ||||
|  | @ -35,6 +38,9 @@ public: | |||
|    RadarSiteDialog*       self_; | ||||
|    model::RadarSiteModel* radarSiteModel_; | ||||
|    QSortFilterProxyModel* proxyModel_; | ||||
| 
 | ||||
|    scwx::common::Coordinate mapPosition_; | ||||
|    bool                     mapUpdateDeferred_; | ||||
| }; | ||||
| 
 | ||||
| RadarSiteDialog::RadarSiteDialog(QWidget* parent) : | ||||
|  | @ -63,6 +69,32 @@ RadarSiteDialog::~RadarSiteDialog() | |||
|    delete ui; | ||||
| } | ||||
| 
 | ||||
| void RadarSiteDialog::showEvent(QShowEvent* event) | ||||
| { | ||||
|    if (p->mapUpdateDeferred_) | ||||
|    { | ||||
|       p->radarSiteModel_->HandleMapUpdate(p->mapPosition_.latitude_, | ||||
|                                           p->mapPosition_.longitude_); | ||||
|       p->mapUpdateDeferred_ = false; | ||||
|    } | ||||
| 
 | ||||
|    QDialog::showEvent(event); | ||||
| } | ||||
| 
 | ||||
| void RadarSiteDialog::HandleMapUpdate(double latitude, double longitude) | ||||
| { | ||||
|    p->mapPosition_ = {latitude, longitude}; | ||||
| 
 | ||||
|    if (isVisible()) | ||||
|    { | ||||
|       p->radarSiteModel_->HandleMapUpdate(latitude, longitude); | ||||
|    } | ||||
|    else | ||||
|    { | ||||
|       p->mapUpdateDeferred_ = true; | ||||
|    } | ||||
| } | ||||
| 
 | ||||
| } // namespace ui
 | ||||
| } // namespace qt
 | ||||
| } // namespace scwx
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat