diff options
Diffstat (limited to 'qt-ui')
-rw-r--r-- | qt-ui/globe.cpp | 45 | ||||
-rw-r--r-- | qt-ui/globe.h | 10 | ||||
-rw-r--r-- | 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 <QDebug> + #include <marble/AbstractFloatItem.h> +#include <marble/GeoDataPlacemark.h> +#include <marble/GeoDataDocument.h> +#include <marble/MarbleModel.h> +#include <marble/GeoDataTreeModel.h> 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 <marble/MarbleWidget.h> +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(); } |