mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 23:30:05 +00:00 
			
		
		
		
	Add tornado possible to alert dock widget
This commit is contained in:
		
							parent
							
								
									49ba9b905b
								
							
						
					
					
						commit
						f0347da923
					
				
					 2 changed files with 45 additions and 10 deletions
				
			
		|  | @ -35,6 +35,7 @@ public: | ||||||
|    ~AlertModelImpl() = default; |    ~AlertModelImpl() = default; | ||||||
| 
 | 
 | ||||||
|    awips::ThreatCategory GetThreatCategory(const types::TextEventKey& key); |    awips::ThreatCategory GetThreatCategory(const types::TextEventKey& key); | ||||||
|  |    bool                  GetTornadoPossible(const types::TextEventKey& key); | ||||||
| 
 | 
 | ||||||
|    static std::string GetCounties(const types::TextEventKey& key); |    static std::string GetCounties(const types::TextEventKey& key); | ||||||
|    static std::string GetState(const types::TextEventKey& key); |    static std::string GetState(const types::TextEventKey& key); | ||||||
|  | @ -55,6 +56,10 @@ public: | ||||||
|                       awips::ThreatCategory, |                       awips::ThreatCategory, | ||||||
|                       types::TextEventHash<types::TextEventKey>> |                       types::TextEventHash<types::TextEventKey>> | ||||||
|       threatCategoryMap_; |       threatCategoryMap_; | ||||||
|  |    std::unordered_map<types::TextEventKey, | ||||||
|  |                       bool, | ||||||
|  |                       types::TextEventHash<types::TextEventKey>> | ||||||
|  |       tornadoPossibleMap_; | ||||||
|    std::unordered_map<types::TextEventKey, |    std::unordered_map<types::TextEventKey, | ||||||
|                       common::Coordinate, |                       common::Coordinate, | ||||||
|                       types::TextEventHash<types::TextEventKey>> |                       types::TextEventHash<types::TextEventKey>> | ||||||
|  | @ -131,6 +136,13 @@ QVariant AlertModel::data(const QModelIndex& index, int role) const | ||||||
|          return QString::fromStdString( |          return QString::fromStdString( | ||||||
|             awips::GetSignificanceText(textEventKey.significance_)); |             awips::GetSignificanceText(textEventKey.significance_)); | ||||||
| 
 | 
 | ||||||
|  |       case static_cast<int>(Column::TornadoPossible): | ||||||
|  |          if (p->GetTornadoPossible(textEventKey)) | ||||||
|  |          { | ||||||
|  |             return tr("Possible"); | ||||||
|  |          } | ||||||
|  |          break; | ||||||
|  | 
 | ||||||
|       case static_cast<int>(Column::ThreatCategory): |       case static_cast<int>(Column::ThreatCategory): | ||||||
|          if (role == Qt::DisplayRole) |          if (role == Qt::DisplayRole) | ||||||
|          { |          { | ||||||
|  | @ -224,6 +236,9 @@ AlertModel::headerData(int section, Qt::Orientation orientation, int role) const | ||||||
|          case static_cast<int>(Column::ThreatCategory): |          case static_cast<int>(Column::ThreatCategory): | ||||||
|             return tr("Category"); |             return tr("Category"); | ||||||
| 
 | 
 | ||||||
|  |          case static_cast<int>(Column::TornadoPossible): | ||||||
|  |             return tr("Tornado"); | ||||||
|  | 
 | ||||||
|          case static_cast<int>(Column::State): |          case static_cast<int>(Column::State): | ||||||
|             return tr("State"); |             return tr("State"); | ||||||
| 
 | 
 | ||||||
|  | @ -264,6 +279,10 @@ AlertModel::headerData(int section, Qt::Orientation orientation, int role) const | ||||||
|          contentsSize = fontMetrics.size(0, QString(6, 'W')); |          contentsSize = fontMetrics.size(0, QString(6, 'W')); | ||||||
|          break; |          break; | ||||||
| 
 | 
 | ||||||
|  |       case static_cast<int>(Column::TornadoPossible): | ||||||
|  |          contentsSize = fontMetrics.size(0, QString(4, 'W')); | ||||||
|  |          break; | ||||||
|  | 
 | ||||||
|       case static_cast<int>(Column::State): |       case static_cast<int>(Column::State): | ||||||
|          contentsSize = fontMetrics.size(0, "WW, WW"); |          contentsSize = fontMetrics.size(0, "WW, WW"); | ||||||
|          break; |          break; | ||||||
|  | @ -311,6 +330,8 @@ void AlertModel::HandleAlert(const types::TextEventKey& alertKey, | ||||||
| 
 | 
 | ||||||
|    p->threatCategoryMap_.insert_or_assign(alertKey, |    p->threatCategoryMap_.insert_or_assign(alertKey, | ||||||
|                                           alertSegment->threatCategory_); |                                           alertSegment->threatCategory_); | ||||||
|  |    p->tornadoPossibleMap_.insert_or_assign(alertKey, | ||||||
|  |                                            alertSegment->tornadoPossible_); | ||||||
| 
 | 
 | ||||||
|    if (alertSegment->codedLocation_.has_value()) |    if (alertSegment->codedLocation_.has_value()) | ||||||
|    { |    { | ||||||
|  | @ -406,6 +427,19 @@ AlertModelImpl::GetThreatCategory(const types::TextEventKey& key) | ||||||
|    return threatCategory; |    return threatCategory; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | bool AlertModelImpl::GetTornadoPossible(const types::TextEventKey& key) | ||||||
|  | { | ||||||
|  |    bool tornadoPossible = false; | ||||||
|  | 
 | ||||||
|  |    auto it = tornadoPossibleMap_.find(key); | ||||||
|  |    if (it != tornadoPossibleMap_.cend()) | ||||||
|  |    { | ||||||
|  |       tornadoPossible = it->second; | ||||||
|  |    } | ||||||
|  | 
 | ||||||
|  |    return tornadoPossible; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| std::string AlertModelImpl::GetCounties(const types::TextEventKey& key) | std::string AlertModelImpl::GetCounties(const types::TextEventKey& key) | ||||||
| { | { | ||||||
|    auto messageList = manager::TextEventManager::Instance()->message_list(key); |    auto messageList = manager::TextEventManager::Instance()->message_list(key); | ||||||
|  |  | ||||||
|  | @ -26,11 +26,12 @@ public: | ||||||
|       Phenomenon      = 2, |       Phenomenon      = 2, | ||||||
|       Significance    = 3, |       Significance    = 3, | ||||||
|       ThreatCategory  = 4, |       ThreatCategory  = 4, | ||||||
|       State          = 5, |       TornadoPossible = 5, | ||||||
|       Counties       = 6, |       State           = 6, | ||||||
|       StartTime      = 7, |       Counties        = 7, | ||||||
|       EndTime        = 8, |       StartTime       = 8, | ||||||
|       Distance       = 9 |       EndTime         = 9, | ||||||
|  |       Distance        = 10 | ||||||
|    }; |    }; | ||||||
| 
 | 
 | ||||||
|    explicit AlertModel(QObject* parent = nullptr); |    explicit AlertModel(QObject* parent = nullptr); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat