Cache alert hover text

This commit is contained in:
Dan Paulat 2024-07-17 22:17:33 -05:00
parent f9bb3e07c3
commit 2ab8f3a77a

View file

@ -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,
@ -534,13 +537,26 @@ void AlertLayer::Impl::AddLine(std::shared_ptr<gl::draw::GeoLines>& geoLines,
void AlertLayer::Impl::HandleGeoLinesHover( 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);
} }
} }