mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-11-01 13:20:04 +00:00
Add favorite selection to radar toolbox
This commit is contained in:
parent
9d673af291
commit
436a3e0a9f
5 changed files with 205 additions and 53 deletions
|
|
@ -224,7 +224,13 @@ void RadarSiteModel::ToggleFavorite(int row)
|
|||
{
|
||||
if (row >= 0 && row < p->favorites_.size())
|
||||
{
|
||||
p->favorites_.at(row) = !p->favorites_.at(row);
|
||||
bool isFavorite = !p->favorites_.at(row);
|
||||
p->favorites_.at(row) = isFavorite;
|
||||
|
||||
QModelIndex index = createIndex(row, static_cast<int>(Column::Favorite));
|
||||
Q_EMIT dataChanged(index, index);
|
||||
|
||||
Q_EMIT FavoriteToggled(p->radarSites_.at(row)->id(), isFavorite);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -248,6 +254,25 @@ RadarSiteModelImpl::RadarSiteModelImpl() :
|
|||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<RadarSiteModel> RadarSiteModel::Instance()
|
||||
{
|
||||
static std::weak_ptr<RadarSiteModel> radarSiteModelReference_ {};
|
||||
static std::mutex instanceMutex_ {};
|
||||
|
||||
std::unique_lock lock(instanceMutex_);
|
||||
|
||||
std::shared_ptr<RadarSiteModel> radarSiteModel =
|
||||
radarSiteModelReference_.lock();
|
||||
|
||||
if (radarSiteModel == nullptr)
|
||||
{
|
||||
radarSiteModel = std::make_shared<RadarSiteModel>();
|
||||
radarSiteModelReference_ = radarSiteModel;
|
||||
}
|
||||
|
||||
return radarSiteModel;
|
||||
}
|
||||
|
||||
} // namespace model
|
||||
} // namespace qt
|
||||
} // namespace scwx
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue