diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2014-11-19 22:31:28 +0000 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-11-19 22:40:42 +0000 |
commit | 639e079131126015dff0f745d1b5d3fc51adcecc (patch) | |
tree | 81a9874fc4cd39e5b1227a2d467d2ba78ecd3068 /qt-ui | |
parent | 21658383e5c188b588aecab46e827cb90a88bc26 (diff) | |
download | subsurface-639e079131126015dff0f745d1b5d3fc51adcecc.tar.gz |
Profile: add helper function to get the sample entry for a mouse position
This seems quite useful to have.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r-- | qt-ui/profile/profilewidget2.cpp | 14 | ||||
-rw-r--r-- | qt-ui/profile/profilewidget2.h | 1 |
2 files changed, 15 insertions, 0 deletions
diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp index 14ae7ca5b..8d4d24ef2 100644 --- a/qt-ui/profile/profilewidget2.cpp +++ b/qt-ui/profile/profilewidget2.cpp @@ -1060,6 +1060,20 @@ bool ProfileWidget2::isAddOrPlanner() return currentState == PLAN || currentState == ADD; } +struct plot_data *ProfileWidget2::getEntryFromPos(QPointF pos) +{ + // find the time stamp corresponding to the mouse position + int seconds = timeAxis->valueAt(pos); + struct plot_data *entry; + + for (int i = 0; i < plotInfo.nr; i++) { + entry = plotInfo.entry + i; + if (entry->sec >= seconds) + break; + } + return entry; +} + void ProfileWidget2::contextMenuEvent(QContextMenuEvent *event) { if (currentState == ADD || currentState == PLAN) { diff --git a/qt-ui/profile/profilewidget2.h b/qt-ui/profile/profilewidget2.h index 477ddf4a7..4c7951533 100644 --- a/qt-ui/profile/profilewidget2.h +++ b/qt-ui/profile/profilewidget2.h @@ -134,6 +134,7 @@ private: /*methods*/ void addItemsToScene(); void setupItemOnScene(); void disconnectTemporaryConnections(); + struct plot_data *getEntryFromPos(QPointF pos); private: DivePlotDataModel *dataModel; |