summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-06-11 09:25:55 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-06-11 09:31:01 -0700
commitb42df1dab67d2f90934e24f428475ae5f5f88e86 (patch)
treefbcdd7864601999574a47aac138cc9e088bb1544
parent6ab95af9ac718874e8d2c0ed0b1381627ca59443 (diff)
downloadsubsurface-b42df1dab67d2f90934e24f428475ae5f5f88e86.tar.gz
Globe: do a better job detecting double clicks and setting GPS coordinates
For some reasons Marble appears to sometimes not detect double clicks and call the correct callback. With this commit we manually intercept the double clocks and route them to the right function. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--qt-ui/globe.cpp20
-rw-r--r--qt-ui/globe.h1
2 files changed, 18 insertions, 3 deletions
diff --git a/qt-ui/globe.cpp b/qt-ui/globe.cpp
index 8d234194e..c21417990 100644
--- a/qt-ui/globe.cpp
+++ b/qt-ui/globe.cpp
@@ -88,17 +88,25 @@ GlobeGPS::GlobeGPS(QWidget *parent) : MarbleWidget(parent),
bool GlobeGPS::eventFilter(QObject *obj, QEvent *ev)
{
+ // sometimes Marble seems not to notice double clicks and consequently not call
+ // the right callback - so let's remember here if the last 'click' is a 'double' or not
+ enum QEvent::Type type = ev->type();
+ if (type == QEvent::MouseButtonDblClick)
+ doubleClick = true;
+ else if (type == QEvent::MouseButtonPress)
+ doubleClick = false;
+
// This disables Zooming when a double click occours on the scene.
- if (ev->type() == QEvent::MouseButtonDblClick && !editingDiveLocation)
+ if (type == QEvent::MouseButtonDblClick && !editingDiveLocation)
return true;
// This disables the Marble's Context Menu
// we need to move this to our 'contextMenuEvent'
// if we plan to do a different one in the future.
- if (ev->type() == QEvent::ContextMenu) {
+ if (type == QEvent::ContextMenu) {
contextMenuEvent(static_cast<QContextMenuEvent *>(ev));
return true;
}
- if (ev->type() == QEvent::MouseButtonPress) {
+ if (type == QEvent::MouseButtonPress) {
QMouseEvent *e = static_cast<QMouseEvent *>(ev);
if (e->button() == Qt::RightButton)
return true;
@@ -116,6 +124,12 @@ void GlobeGPS::contextMenuEvent(QContextMenuEvent *ev)
void GlobeGPS::mouseClicked(qreal lon, qreal lat, GeoDataCoordinates::Unit unit)
{
+ if (doubleClick) {
+ // strangely sometimes we don't get the changeDiveGeoPosition callback
+ // and end up here instead
+ changeDiveGeoPosition(lon, lat, unit);
+ return;
+ }
// don't mess with the selection while the user is editing a dive
if (MainWindow::instance()->information()->isEditing() || messageWidget->isVisible())
return;
diff --git a/qt-ui/globe.h b/qt-ui/globe.h
index c40eefc46..bb8ace47b 100644
--- a/qt-ui/globe.h
+++ b/qt-ui/globe.h
@@ -34,6 +34,7 @@ private:
int currentZoomLevel;
bool needResetZoom;
bool editingDiveLocation;
+ bool doubleClick;
public
slots: