diff options
-rw-r--r-- | qt-ui/globe.cpp | 16 | ||||
-rw-r--r-- | qt-ui/globe.h | 9 |
2 files changed, 22 insertions, 3 deletions
diff --git a/qt-ui/globe.cpp b/qt-ui/globe.cpp index 966edda17..c2ae56536 100644 --- a/qt-ui/globe.cpp +++ b/qt-ui/globe.cpp @@ -7,6 +7,7 @@ #include "../helpers.h" #include <QDebug> +#include <QTimer> #include <marble/AbstractFloatItem.h> #include <marble/GeoDataPlacemark.h> @@ -63,6 +64,9 @@ GlobeGPS::GlobeGPS(QWidget* parent) : MarbleWidget(parent), loadedDives(0) setMinimumHeight(0); setMinimumWidth(0); editingDiveCoords = 0; + fixZoomTimer = new QTimer(); + connect(fixZoomTimer, SIGNAL(timeout()), this, SLOT(fixZoom())); + fixZoomTimer->setSingleShot(true); } void GlobeGPS::mouseClicked(qreal lon, qreal lat, GeoDataCoordinates::Unit unit) @@ -178,9 +182,21 @@ void GlobeGPS::centerOn(dive* dive) if (!zoom()) zoomView(zoomFromDistance(3)); + if (!fixZoomTimer->isActive()) + currentZoomLevel = zoom(); + // From the marble source code, the maximum time of + // 'spin and fit' is 2 seconds, so wait a bit them zoom again. + fixZoomTimer->start(2100); + centerOn(longitude,latitude, true); } +void GlobeGPS::fixZoom() +{ + zoomView(currentZoomLevel, Marble::Linear); +} + + void GlobeGPS::prepareForGetDiveCoordinates(dive* dive) { if (!messageWidget->isVisible()) { diff --git a/qt-ui/globe.h b/qt-ui/globe.h index eef01244b..cab42cefc 100644 --- a/qt-ui/globe.h +++ b/qt-ui/globe.h @@ -13,25 +13,28 @@ struct dive; class GlobeGPS : public MarbleWidget{ Q_OBJECT - void prepareForGetDiveCoordinates(struct dive* dive); public: using MarbleWidget::centerOn; GlobeGPS(QWidget *parent); void reload(); void centerOn(struct dive* dive); - void resizeEvent(QResizeEvent *event); protected: - virtual void mousePressEvent(QMouseEvent* event); + /* reimp */ void resizeEvent(QResizeEvent *event); + /* reimp */ void mousePressEvent(QMouseEvent* event); private: + void prepareForGetDiveCoordinates(struct dive* dive); GeoDataDocument *loadedDives; struct dive* editingDiveCoords; KMessageWidget* messageWidget; + QTimer *fixZoomTimer; + int currentZoomLevel; public slots: void changeDiveGeoPosition(qreal lon,qreal lat,GeoDataCoordinates::Unit); void mouseClicked(qreal lon, qreal lat, GeoDataCoordinates::Unit); + void fixZoom(); }; #endif |