From 9038b3aa6e89a1015d8dd50d772c995b2997fd1a Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Fri, 17 May 2013 13:28:02 -0300 Subject: Added real support for the marble widget The marble widget now shows the dive locations and also will center on the dive that the user clicked in the dive list. Signed-off-by: Tomaz Canabrava --- qt-ui/globe.cpp | 45 ++++++++++++++++++++++++++++++++++++++++++--- qt-ui/globe.h | 10 +++++++++- qt-ui/mainwindow.cpp | 4 +++- 3 files changed, 54 insertions(+), 5 deletions(-) diff --git a/qt-ui/globe.cpp b/qt-ui/globe.cpp index 770e51b02..77fd8b3b6 100644 --- a/qt-ui/globe.cpp +++ b/qt-ui/globe.cpp @@ -1,16 +1,27 @@ #include "globe.h" +#include "../dive.h" + +#include + #include +#include +#include +#include +#include using namespace Marble; -GlobeGPS::GlobeGPS(QWidget* parent) : MarbleWidget(parent) +GlobeGPS::GlobeGPS(QWidget* parent) : MarbleWidget(parent), loadedDives(0) { setMapThemeId("earth/bluemarble/bluemarble.dgml"); setProjection( Marble::Spherical ); // Enable the cloud cover and enable the country borders - setShowClouds( true ); - setShowBorders( true ); + setShowClouds( false ); + setShowBorders( false ); + setShowPlaces( false ); + setShowCrosshairs( false ); + setShowGrid( false ); // Hide the FloatItems: Compass and StatusBar setShowOverviewMap(false); @@ -23,3 +34,31 @@ GlobeGPS::GlobeGPS(QWidget* parent) : MarbleWidget(parent) } } } + +void GlobeGPS::reload() +{ + if (loadedDives){ + model()->treeModel()->removeDocument(loadedDives); + delete loadedDives; + } + + + loadedDives = new GeoDataDocument; + + int idx = 0; + struct dive *dive; + for_each_dive(idx, dive) { + if (dive_has_gps_location(dive)) { + GeoDataPlacemark *place = new GeoDataPlacemark( dive->location ); + place->setDescription(dive->notes); + place->setCoordinate(dive->longitude.udeg / 1000000.0,dive->latitude.udeg / 1000000.0 , 0, GeoDataCoordinates::Degree ); + loadedDives->append( place ); + } + } + model()->treeModel()->addDocument( loadedDives ); +} + +void GlobeGPS::centerOn(dive* dive) +{ + centerOn(dive->longitude.udeg / 1000000.0,dive->latitude.udeg / 1000000.0); +} diff --git a/qt-ui/globe.h b/qt-ui/globe.h index bdf40fb1a..8e8b9bec1 100644 --- a/qt-ui/globe.h +++ b/qt-ui/globe.h @@ -3,11 +3,19 @@ #include +namespace Marble{ + class GeoDataDocument; +} class GlobeGPS : public Marble::MarbleWidget{ Q_OBJECT public: + using Marble::MarbleWidget::centerOn; GlobeGPS(QWidget *parent); - + void reload(); + void centerOn(struct dive* dive); + +private: + Marble::GeoDataDocument *loadedDives; }; #endif diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index e555473ca..c5a4e5ce3 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -35,11 +35,13 @@ MainWindow::MainWindow() : ui(new Ui::MainWindow()) ui->ProfileWidget->setFocusProxy(ui->ListWidget); ui->ListWidget->reload(); ui->ListWidget->setFocus(); + ui->widget->reload(); } void MainWindow::current_dive_changed(int divenr) { select_dive(divenr); + ui->widget->centerOn(get_dive(selected_dive)); redrawProfile(); ui->InfoWidget->updateDiveInfo(divenr); } @@ -77,7 +79,7 @@ void MainWindow::on_actionOpen_triggered() process_dives(FALSE, FALSE); ui->InfoWidget->reload(); - + ui->widget->reload(); ui->ListWidget->reload(); ui->ListWidget->setFocus(); } -- cgit v1.2.3-70-g09d2