mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 23:30:04 +00:00
Cache alert hover text
This commit is contained in:
parent
f9bb3e07c3
commit
2ab8f3a77a
1 changed files with 21 additions and 5 deletions
|
|
@ -181,6 +181,9 @@ public:
|
||||||
std::unordered_map<bool, boost::gil::rgba32f_pixel_t> lineColor_;
|
std::unordered_map<bool, boost::gil::rgba32f_pixel_t> lineColor_;
|
||||||
|
|
||||||
std::chrono::system_clock::time_point selectedTime_ {};
|
std::chrono::system_clock::time_point selectedTime_ {};
|
||||||
|
|
||||||
|
std::shared_ptr<const gl::draw::GeoLineDrawItem> lastHoverDi_ {nullptr};
|
||||||
|
std::string tooltip_ {};
|
||||||
};
|
};
|
||||||
|
|
||||||
AlertLayer::AlertLayer(std::shared_ptr<MapContext> context,
|
AlertLayer::AlertLayer(std::shared_ptr<MapContext> context,
|
||||||
|
|
@ -535,12 +538,25 @@ void AlertLayer::Impl::HandleGeoLinesHover(
|
||||||
std::shared_ptr<const gl::draw::GeoLineDrawItem>& di,
|
std::shared_ptr<const gl::draw::GeoLineDrawItem>& di,
|
||||||
const QPointF& mouseGlobalPos)
|
const QPointF& mouseGlobalPos)
|
||||||
{
|
{
|
||||||
|
if (di != lastHoverDi_)
|
||||||
|
{
|
||||||
auto it = segmentsByLine_.find(di);
|
auto it = segmentsByLine_.find(di);
|
||||||
if (it != segmentsByLine_.cend())
|
if (it != segmentsByLine_.cend())
|
||||||
{
|
{
|
||||||
util::tooltip::Show(
|
tooltip_ =
|
||||||
boost::algorithm::join(it->second->segment_->productContent_, "\n"),
|
boost::algorithm::join(it->second->segment_->productContent_, "\n");
|
||||||
mouseGlobalPos);
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tooltip_.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
lastHoverDi_ = di;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!tooltip_.empty())
|
||||||
|
{
|
||||||
|
util::tooltip::Show(tooltip_, mouseGlobalPos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue