diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2014-02-19 16:06:16 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-02-19 16:06:16 -0800 |
commit | 08490785b2bc9a40a3a65e2ae1b416f0089d629b (patch) | |
tree | 0e9167e28e25b89e2368a3b90c9cb5648ed7d079 /qt-ui | |
parent | 43997d3b363034e452931494f6567ff959529b62 (diff) | |
download | subsurface-08490785b2bc9a40a3a65e2ae1b416f0089d629b.tar.gz |
Only recalculate the tooltip if time has changed
Small optimization, but seems to make sense.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r-- | qt-ui/profile/divetooltipitem.cpp | 9 | ||||
-rw-r--r-- | qt-ui/profile/divetooltipitem.h | 1 |
2 files changed, 8 insertions, 2 deletions
diff --git a/qt-ui/profile/divetooltipitem.cpp b/qt-ui/profile/divetooltipitem.cpp index 0f7191474..b2b72ed58 100644 --- a/qt-ui/profile/divetooltipitem.cpp +++ b/qt-ui/profile/divetooltipitem.cpp @@ -144,7 +144,8 @@ ToolTipItem::ToolTipItem(QGraphicsItem* parent) : QGraphicsPathItem(parent), separator(new QGraphicsLineItem(this)), title(new QGraphicsSimpleTextItem(tr("Information"), this)), status(COLLAPSED), - timeAxis(0) + timeAxis(0), + lastTime(-1) { memset(&pInfo, 0, sizeof(pInfo)); @@ -231,8 +232,12 @@ void ToolTipItem::setTimeAxis(DiveCartesianAxis* axis) void ToolTipItem::refresh(const QPointF& pos) { - clear(); int time = timeAxis->valueAt( pos ); + if (time == lastTime) + return; + + lastTime = time; + clear(); struct membuffer mb = { 0 }; get_plot_details_new(&pInfo, time, &mb); diff --git a/qt-ui/profile/divetooltipitem.h b/qt-ui/profile/divetooltipitem.h index 860d79310..5deb0001a 100644 --- a/qt-ui/profile/divetooltipitem.h +++ b/qt-ui/profile/divetooltipitem.h @@ -56,6 +56,7 @@ private: QRectF nextRectangle; DiveCartesianAxis *timeAxis; plot_info pInfo; + int lastTime; }; #endif // DIVETOOLTIPITEM_H |