Only recalculate the tooltip if time has changed

Small optimization, but seems to make sense.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2014-02-19 16:06:16 -08:00
parent 43997d3b36
commit 08490785b2
2 changed files with 8 additions and 2 deletions

View file

@ -144,7 +144,8 @@ ToolTipItem::ToolTipItem(QGraphicsItem* parent) : QGraphicsPathItem(parent),
separator(new QGraphicsLineItem(this)), separator(new QGraphicsLineItem(this)),
title(new QGraphicsSimpleTextItem(tr("Information"), this)), title(new QGraphicsSimpleTextItem(tr("Information"), this)),
status(COLLAPSED), status(COLLAPSED),
timeAxis(0) timeAxis(0),
lastTime(-1)
{ {
memset(&pInfo, 0, sizeof(pInfo)); memset(&pInfo, 0, sizeof(pInfo));
@ -231,8 +232,12 @@ void ToolTipItem::setTimeAxis(DiveCartesianAxis* axis)
void ToolTipItem::refresh(const QPointF& pos) void ToolTipItem::refresh(const QPointF& pos)
{ {
clear();
int time = timeAxis->valueAt( pos ); int time = timeAxis->valueAt( pos );
if (time == lastTime)
return;
lastTime = time;
clear();
struct membuffer mb = { 0 }; struct membuffer mb = { 0 };
get_plot_details_new(&pInfo, time, &mb); get_plot_details_new(&pInfo, time, &mb);

View file

@ -56,6 +56,7 @@ private:
QRectF nextRectangle; QRectF nextRectangle;
DiveCartesianAxis *timeAxis; DiveCartesianAxis *timeAxis;
plot_info pInfo; plot_info pInfo;
int lastTime;
}; };
#endif // DIVETOOLTIPITEM_H #endif // DIVETOOLTIPITEM_H