mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 22:50:05 +00:00
Add text event pruning
- Still need to prune AlertLayer - Still need to test alerts reload after being pruned
This commit is contained in:
parent
4719badc54
commit
f37a77a9f7
6 changed files with 158 additions and 8 deletions
|
|
@ -338,7 +338,7 @@ void AlertModel::HandleAlert(const types::TextEventKey& alertKey,
|
|||
auto alertMessages = p->textEventManager_->message_list(alertKey);
|
||||
|
||||
// Skip alert if this is not the most recent message
|
||||
if (messageIndex + 1 < alertMessages.size())
|
||||
if (alertMessages.empty() || messageIndex + 1 < alertMessages.size())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
@ -393,6 +393,35 @@ void AlertModel::HandleAlert(const types::TextEventKey& alertKey,
|
|||
}
|
||||
}
|
||||
|
||||
void AlertModel::HandleAlertsRemoved(
|
||||
const std::unordered_set<types::TextEventKey,
|
||||
types::TextEventHash<types::TextEventKey>>&
|
||||
alertKeys)
|
||||
{
|
||||
logger_->trace("Handle alerts removed");
|
||||
|
||||
for (const auto& alertKey : alertKeys)
|
||||
{
|
||||
// Remove from the list of text event keys
|
||||
auto it = std::find(
|
||||
p->textEventKeys_.begin(), p->textEventKeys_.end(), alertKey);
|
||||
if (it != p->textEventKeys_.end())
|
||||
{
|
||||
int row = std::distance(p->textEventKeys_.begin(), it);
|
||||
beginRemoveRows(QModelIndex(), row, row);
|
||||
p->textEventKeys_.erase(it);
|
||||
endRemoveRows();
|
||||
}
|
||||
|
||||
// Remove from internal maps
|
||||
p->observedMap_.erase(alertKey);
|
||||
p->threatCategoryMap_.erase(alertKey);
|
||||
p->tornadoPossibleMap_.erase(alertKey);
|
||||
p->centroidMap_.erase(alertKey);
|
||||
p->distanceMap_.erase(alertKey);
|
||||
}
|
||||
}
|
||||
|
||||
void AlertModel::HandleMapUpdate(double latitude, double longitude)
|
||||
{
|
||||
logger_->trace("Handle map update: {}, {}", latitude, longitude);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue