mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 23:20:05 +00:00
Handle selection of items in the alert view
This commit is contained in:
parent
f8021b00bf
commit
c117078335
5 changed files with 60 additions and 4 deletions
|
|
@ -66,6 +66,25 @@ AlertModel::AlertModel(QObject* parent) :
|
|||
}
|
||||
AlertModel::~AlertModel() = default;
|
||||
|
||||
types::TextEventKey AlertModel::key(const QModelIndex& index) const
|
||||
{
|
||||
return index.isValid() ? p->textEventKeys_[index.row()] :
|
||||
types::TextEventKey {};
|
||||
}
|
||||
|
||||
common::Coordinate AlertModel::centroid(const types::TextEventKey& key) const
|
||||
{
|
||||
common::Coordinate centroid {};
|
||||
|
||||
const auto& it = p->centroidMap_.find(key);
|
||||
if (it != p->centroidMap_.cend())
|
||||
{
|
||||
centroid = it->second;
|
||||
}
|
||||
|
||||
return centroid;
|
||||
}
|
||||
|
||||
int AlertModel::rowCount(const QModelIndex& parent) const
|
||||
{
|
||||
return parent.isValid() ? 0 : p->textEventKeys_.size();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <scwx/qt/types/text_event_key.hpp>
|
||||
#include <scwx/common/geographic.hpp>
|
||||
|
||||
#include <memory>
|
||||
|
||||
|
|
@ -21,6 +22,9 @@ public:
|
|||
explicit AlertModel(QObject* parent = nullptr);
|
||||
~AlertModel();
|
||||
|
||||
types::TextEventKey key(const QModelIndex& index) const;
|
||||
common::Coordinate centroid(const types::TextEventKey& key) const;
|
||||
|
||||
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
|
||||
int columnCount(const QModelIndex& parent = QModelIndex()) const override;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue