mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
remove Marble from the source tree
In desktop-widgets, remove globe.cpp, globe.h and also remove the NO_MARBLE macro usage. At this point the MapWidget will always be created and there will always be a map in the application. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
This commit is contained in:
parent
a7d8e0d187
commit
4bb180b117
8 changed files with 0 additions and 642 deletions
|
@ -1,398 +0,0 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0
|
|
||||||
#include "desktop-widgets/globe.h"
|
|
||||||
#ifndef NO_MARBLE
|
|
||||||
#include "desktop-widgets/mainwindow.h"
|
|
||||||
#include "core/helpers.h"
|
|
||||||
#include "desktop-widgets/divelistview.h"
|
|
||||||
#include "desktop-widgets/tab-widgets/maintab.h"
|
|
||||||
#include "core/display.h"
|
|
||||||
|
|
||||||
#include <QTimer>
|
|
||||||
#include <QContextMenuEvent>
|
|
||||||
#include <QMouseEvent>
|
|
||||||
|
|
||||||
#include <marble/AbstractFloatItem.h>
|
|
||||||
#include <marble/GeoDataPlacemark.h>
|
|
||||||
#include <marble/GeoDataDocument.h>
|
|
||||||
#include <marble/MarbleModel.h>
|
|
||||||
#include <marble/MarbleDirs.h>
|
|
||||||
#include <marble/MapThemeManager.h>
|
|
||||||
#include <marble/GeoDataStyle.h>
|
|
||||||
#include <marble/GeoDataIconStyle.h>
|
|
||||||
#include <marble/GeoDataTreeModel.h>
|
|
||||||
|
|
||||||
#ifdef MARBLE_SUBSURFACE_BRANCH
|
|
||||||
#include <marble/MarbleDebug.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
GlobeGPS *GlobeGPS::instance()
|
|
||||||
{
|
|
||||||
static GlobeGPS *self = new GlobeGPS();
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
|
|
||||||
GlobeGPS::GlobeGPS(QWidget *parent) : MarbleWidget(parent),
|
|
||||||
loadedDives(0),
|
|
||||||
messageWidget(new KMessageWidget(this)),
|
|
||||||
fixZoomTimer(new QTimer(this)),
|
|
||||||
needResetZoom(false),
|
|
||||||
editingDiveLocation(false),
|
|
||||||
doubleClick(false)
|
|
||||||
{
|
|
||||||
#ifdef MARBLE_SUBSURFACE_BRANCH
|
|
||||||
// we need to make sure this gets called after the command line arguments have
|
|
||||||
// been processed but before we initialize the rest of Marble
|
|
||||||
Marble::MarbleDebug::setEnabled(verbose);
|
|
||||||
#endif
|
|
||||||
currentZoomLevel = -1;
|
|
||||||
// check if Google Sat Maps are installed
|
|
||||||
// if not, check if they are in a known location
|
|
||||||
MapThemeManager mtm;
|
|
||||||
QStringList list = mtm.mapThemeIds();
|
|
||||||
QString subsurfaceDataPath;
|
|
||||||
QDir marble;
|
|
||||||
if (!list.contains("earth/googlesat/googlesat.dgml")) {
|
|
||||||
subsurfaceDataPath = getSubsurfaceDataPath("marbledata");
|
|
||||||
if (subsurfaceDataPath.size()) {
|
|
||||||
MarbleDirs::setMarbleDataPath(subsurfaceDataPath);
|
|
||||||
} else {
|
|
||||||
subsurfaceDataPath = getSubsurfaceDataPath("data");
|
|
||||||
if (subsurfaceDataPath.size())
|
|
||||||
MarbleDirs::setMarbleDataPath(subsurfaceDataPath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
messageWidget->setCloseButtonVisible(false);
|
|
||||||
messageWidget->setHidden(true);
|
|
||||||
|
|
||||||
setMapThemeId("earth/googlesat/googlesat.dgml");
|
|
||||||
//setMapThemeId("earth/openstreetmap/openstreetmap.dgml");
|
|
||||||
setProjection(Marble::Spherical);
|
|
||||||
|
|
||||||
setAnimationsEnabled(true);
|
|
||||||
Q_FOREACH (AbstractFloatItem *i, floatItems()) {
|
|
||||||
i->setVisible(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
setShowClouds(false);
|
|
||||||
setShowBorders(false);
|
|
||||||
setShowPlaces(true);
|
|
||||||
setShowCrosshairs(false);
|
|
||||||
setShowGrid(false);
|
|
||||||
setShowOverviewMap(false);
|
|
||||||
setShowScaleBar(true);
|
|
||||||
setShowCompass(false);
|
|
||||||
connect(this, SIGNAL(mouseClickGeoPosition(qreal, qreal, GeoDataCoordinates::Unit)),
|
|
||||||
this, SLOT(mouseClicked(qreal, qreal, GeoDataCoordinates::Unit)));
|
|
||||||
|
|
||||||
setMinimumHeight(0);
|
|
||||||
setMinimumWidth(0);
|
|
||||||
connect(fixZoomTimer, SIGNAL(timeout()), this, SLOT(fixZoom()));
|
|
||||||
fixZoomTimer->setSingleShot(true);
|
|
||||||
installEventFilter(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
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 (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 (type == QEvent::ContextMenu) {
|
|
||||||
contextMenuEvent(static_cast<QContextMenuEvent *>(ev));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (type == QEvent::MouseButtonPress) {
|
|
||||||
QMouseEvent *e = static_cast<QMouseEvent *>(ev);
|
|
||||||
if (e->button() == Qt::RightButton)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return QObject::eventFilter(obj, ev);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GlobeGPS::contextMenuEvent(QContextMenuEvent *ev)
|
|
||||||
{
|
|
||||||
QMenu m;
|
|
||||||
QAction *a = m.addAction(tr("Edit selected dive locations"), this, SLOT(prepareForGetDiveCoordinates()));
|
|
||||||
a->setData(QVariant::fromValue<void *>(&m));
|
|
||||||
a->setEnabled(current_dive);
|
|
||||||
m.exec(ev->globalPos());
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
GeoDataCoordinates here(lon, lat, unit);
|
|
||||||
long lon_udeg = lrint(1000000 * here.longitude(GeoDataCoordinates::Degree));
|
|
||||||
long lat_udeg = lrint(1000000 * here.latitude(GeoDataCoordinates::Degree));
|
|
||||||
|
|
||||||
// distance() is in km above the map.
|
|
||||||
// We're going to use that to decide how
|
|
||||||
// approximate the dives have to be.
|
|
||||||
//
|
|
||||||
// Totally arbitrarily I say that 1km
|
|
||||||
// distance means that we can resolve
|
|
||||||
// to about 100m. Which in turn is about
|
|
||||||
// 1000 udeg.
|
|
||||||
//
|
|
||||||
// Trigonometry is hard, but sin x == x
|
|
||||||
// for small x, so let's just do this as
|
|
||||||
// a linear thing.
|
|
||||||
long resolve = lrint(distance() * 1000);
|
|
||||||
|
|
||||||
int idx;
|
|
||||||
struct dive *dive;
|
|
||||||
bool clear = !(QApplication::keyboardModifiers() & Qt::ControlModifier);
|
|
||||||
QList<int> selectedDiveIds;
|
|
||||||
for_each_dive (idx, dive) {
|
|
||||||
long lat_diff, lon_diff;
|
|
||||||
struct dive_site *ds = get_dive_site_for_dive(dive);
|
|
||||||
if (!dive_site_has_gps_location(ds))
|
|
||||||
continue;
|
|
||||||
lat_diff = labs(ds->latitude.udeg - lat_udeg);
|
|
||||||
lon_diff = labs(ds->longitude.udeg - lon_udeg);
|
|
||||||
if (lat_diff > 180000000)
|
|
||||||
lat_diff = 360000000 - lat_diff;
|
|
||||||
if (lon_diff > 180000000)
|
|
||||||
lon_diff = 180000000 - lon_diff;
|
|
||||||
if (lat_diff > resolve || lon_diff > resolve)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
selectedDiveIds.push_back(idx);
|
|
||||||
}
|
|
||||||
if (selectedDiveIds.empty())
|
|
||||||
return;
|
|
||||||
if (clear)
|
|
||||||
MainWindow::instance()->dive_list()->unselectDives();
|
|
||||||
MainWindow::instance()->dive_list()->selectDives(selectedDiveIds);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GlobeGPS::repopulateLabels()
|
|
||||||
{
|
|
||||||
static GeoDataStyle otherSite, currentSite;
|
|
||||||
static GeoDataIconStyle darkFlag(QImage(":flagDark")), lightFlag(QImage(":flagLight"));
|
|
||||||
struct dive_site *ds;
|
|
||||||
int idx;
|
|
||||||
QMap<QString, GeoDataPlacemark *> locationMap;
|
|
||||||
if (loadedDives) {
|
|
||||||
model()->treeModel()->removeDocument(loadedDives);
|
|
||||||
delete loadedDives;
|
|
||||||
}
|
|
||||||
loadedDives = new GeoDataDocument;
|
|
||||||
otherSite.setIconStyle(darkFlag);
|
|
||||||
currentSite.setIconStyle(lightFlag);
|
|
||||||
|
|
||||||
if (displayed_dive_site.uuid && dive_site_has_gps_location(&displayed_dive_site)) {
|
|
||||||
GeoDataPlacemark *place = new GeoDataPlacemark(displayed_dive_site.name);
|
|
||||||
place->setStyle(¤tSite);
|
|
||||||
place->setCoordinate(displayed_dive_site.longitude.udeg / 1000000.0,
|
|
||||||
displayed_dive_site.latitude.udeg / 1000000.0, 0, GeoDataCoordinates::Degree);
|
|
||||||
locationMap[QString(displayed_dive_site.name)] = place;
|
|
||||||
loadedDives->append(place);
|
|
||||||
}
|
|
||||||
for_each_dive_site(idx, ds) {
|
|
||||||
if (ds->uuid == displayed_dive_site.uuid)
|
|
||||||
continue;
|
|
||||||
if (dive_site_has_gps_location(ds)) {
|
|
||||||
GeoDataPlacemark *place = new GeoDataPlacemark(ds->name);
|
|
||||||
place->setStyle(&otherSite);
|
|
||||||
place->setCoordinate(ds->longitude.udeg / 1000000.0, ds->latitude.udeg / 1000000.0, 0, GeoDataCoordinates::Degree);
|
|
||||||
|
|
||||||
// don't add dive locations twice, unless they are at least 50m apart
|
|
||||||
if (locationMap[QString(ds->name)]) {
|
|
||||||
GeoDataCoordinates existingLocation = locationMap[QString(ds->name)]->coordinate();
|
|
||||||
GeoDataLineString segment = GeoDataLineString();
|
|
||||||
segment.append(existingLocation);
|
|
||||||
GeoDataCoordinates newLocation = place->coordinate();
|
|
||||||
segment.append(newLocation);
|
|
||||||
double dist = segment.length(6371);
|
|
||||||
// the dist is scaled to the radius given - so with 6371km as radius
|
|
||||||
// 50m turns into 0.05 as threashold
|
|
||||||
if (dist < 0.05)
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
locationMap[QString(ds->name)] = place;
|
|
||||||
loadedDives->append(place);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
model()->treeModel()->addDocument(loadedDives);
|
|
||||||
|
|
||||||
struct dive_site *center = displayed_dive_site.uuid != 0 ?
|
|
||||||
&displayed_dive_site : current_dive ?
|
|
||||||
get_dive_site_by_uuid(current_dive->dive_site_uuid) : NULL;
|
|
||||||
if(dive_site_has_gps_location(&displayed_dive_site) && center)
|
|
||||||
centerOn(displayed_dive_site.longitude.udeg / 1000000.0, displayed_dive_site.latitude.udeg / 1000000.0, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GlobeGPS::reload()
|
|
||||||
{
|
|
||||||
editingDiveLocation = false;
|
|
||||||
messageWidget->hide();
|
|
||||||
repopulateLabels();
|
|
||||||
}
|
|
||||||
|
|
||||||
void GlobeGPS::centerOnDiveSite(struct dive_site *ds)
|
|
||||||
{
|
|
||||||
if (!dive_site_has_gps_location(ds)) {
|
|
||||||
// this is not intuitive and at times causes trouble - let's comment it out for now
|
|
||||||
// zoomOutForNoGPS();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
qreal longitude = ds->longitude.udeg / 1000000.0;
|
|
||||||
qreal latitude = ds->latitude.udeg / 1000000.0;
|
|
||||||
|
|
||||||
if(IS_FP_SAME(longitude, centerLongitude()) && IS_FP_SAME(latitude,centerLatitude())) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if no zoom is set up, set the zoom as seen from 3km above
|
|
||||||
// if we come back from a dive without GPS data, reset to the last zoom value
|
|
||||||
// otherwise check to make sure we aren't still running an animation and then remember
|
|
||||||
// the current zoom level
|
|
||||||
if (currentZoomLevel == -1) {
|
|
||||||
currentZoomLevel = lrint(zoomFromDistance(3.0));
|
|
||||||
centerOn(longitude, latitude);
|
|
||||||
fixZoom(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!fixZoomTimer->isActive()) {
|
|
||||||
if (needResetZoom) {
|
|
||||||
needResetZoom = false;
|
|
||||||
fixZoom();
|
|
||||||
} else if (zoom() >= 1200) {
|
|
||||||
currentZoomLevel = zoom();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// From the marble source code, the maximum time of
|
|
||||||
// 'spin and fit' is 2000 miliseconds so wait a bit them zoom again.
|
|
||||||
fixZoomTimer->stop();
|
|
||||||
if (zoom() < 1200 && IS_FP_SAME(centerLatitude(), latitude) && IS_FP_SAME(centerLongitude(), longitude)) {
|
|
||||||
// create a tiny movement
|
|
||||||
centerOn(longitude + 0.00001, latitude + 0.00001);
|
|
||||||
fixZoomTimer->start(300);
|
|
||||||
} else {
|
|
||||||
fixZoomTimer->start(2100);
|
|
||||||
}
|
|
||||||
centerOn(longitude, latitude, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GlobeGPS::fixZoom(bool now)
|
|
||||||
{
|
|
||||||
setZoom(currentZoomLevel, now ? Marble::Instant : Marble::Linear);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GlobeGPS::zoomOutForNoGPS()
|
|
||||||
{
|
|
||||||
// this is called if the dive has no GPS location.
|
|
||||||
// zoom out quite a bit to show the globe and remember that the next time
|
|
||||||
// we show a dive with GPS location we need to zoom in again
|
|
||||||
if (!needResetZoom) {
|
|
||||||
needResetZoom = true;
|
|
||||||
if (!fixZoomTimer->isActive() && zoom() >= 1500) {
|
|
||||||
currentZoomLevel = zoom();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (fixZoomTimer->isActive())
|
|
||||||
fixZoomTimer->stop();
|
|
||||||
// 1000 is supposed to make sure you see the whole globe
|
|
||||||
setZoom(1000, Marble::Linear);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GlobeGPS::endGetDiveCoordinates()
|
|
||||||
{
|
|
||||||
messageWidget->animatedHide();
|
|
||||||
editingDiveLocation = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GlobeGPS::prepareForGetDiveCoordinates()
|
|
||||||
{
|
|
||||||
messageWidget->setMessageType(KMessageWidget::Warning);
|
|
||||||
messageWidget->setText(QObject::tr("Move the map and double-click to set the dive location"));
|
|
||||||
messageWidget->setWordWrap(true);
|
|
||||||
messageWidget->setCloseButtonVisible(false);
|
|
||||||
messageWidget->animatedShow();
|
|
||||||
editingDiveLocation = true;
|
|
||||||
// this is not intuitive and at times causes trouble - let's comment it out for now
|
|
||||||
// if (!dive_has_gps_location(current_dive))
|
|
||||||
// zoomOutForNoGPS();
|
|
||||||
}
|
|
||||||
|
|
||||||
void GlobeGPS::changeDiveGeoPosition(qreal lon, qreal lat, GeoDataCoordinates::Unit unit)
|
|
||||||
{
|
|
||||||
if (!editingDiveLocation)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// convert to degrees if in radian.
|
|
||||||
if (unit == GeoDataCoordinates::Radian) {
|
|
||||||
lon = lon * 180 / M_PI;
|
|
||||||
lat = lat * 180 / M_PI;
|
|
||||||
}
|
|
||||||
centerOn(lon, lat, true);
|
|
||||||
|
|
||||||
// change the location of the displayed_dive and put the UI in edit mode
|
|
||||||
displayed_dive_site.latitude.udeg = llrint(lat * 1000000.0);
|
|
||||||
displayed_dive_site.longitude.udeg = llrint(lon * 1000000.0);
|
|
||||||
emit coordinatesChanged();
|
|
||||||
repopulateLabels();
|
|
||||||
}
|
|
||||||
|
|
||||||
void GlobeGPS::mousePressEvent(QMouseEvent *event)
|
|
||||||
{
|
|
||||||
if (event->type() != QEvent::MouseButtonDblClick)
|
|
||||||
return;
|
|
||||||
|
|
||||||
qreal lat, lon;
|
|
||||||
bool clickOnGlobe = geoCoordinates(event->pos().x(), event->pos().y(), lon, lat, GeoDataCoordinates::Degree);
|
|
||||||
|
|
||||||
// there could be two scenarios that got us here; let's check if we are editing a dive
|
|
||||||
if (MainWindow::instance()->information()->isEditing() && clickOnGlobe) {
|
|
||||||
//
|
|
||||||
// FIXME
|
|
||||||
// TODO
|
|
||||||
//
|
|
||||||
// this needs to do this on the dive site screen
|
|
||||||
// MainWindow::instance()->information()->updateCoordinatesText(lat, lon);
|
|
||||||
repopulateLabels();
|
|
||||||
} else if (clickOnGlobe) {
|
|
||||||
changeDiveGeoPosition(lon, lat, GeoDataCoordinates::Degree);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void GlobeGPS::resizeEvent(QResizeEvent *event)
|
|
||||||
{
|
|
||||||
int size = event->size().width();
|
|
||||||
MarbleWidget::resizeEvent(event);
|
|
||||||
if (size > 600)
|
|
||||||
messageWidget->setGeometry((size - 600) / 2, 5, 600, 0);
|
|
||||||
else
|
|
||||||
messageWidget->setGeometry(5, 5, size - 10, 0);
|
|
||||||
messageWidget->setMaximumHeight(500);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GlobeGPS::centerOnIndex(const QModelIndex& idx)
|
|
||||||
{
|
|
||||||
struct dive_site *ds = get_dive_site_by_uuid(idx.model()->index(idx.row(), 0).data().toInt());
|
|
||||||
if (!ds || !dive_site_has_gps_location(ds))
|
|
||||||
centerOnDiveSite(&displayed_dive_site);
|
|
||||||
else
|
|
||||||
centerOnDiveSite(ds);
|
|
||||||
}
|
|
||||||
#endif
|
|
|
@ -1,64 +0,0 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0
|
|
||||||
#ifndef GLOBE_H
|
|
||||||
#define GLOBE_H
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#ifndef NO_MARBLE
|
|
||||||
#include <marble/MarbleWidget.h>
|
|
||||||
#include <marble/GeoDataCoordinates.h>
|
|
||||||
|
|
||||||
#include <QHash>
|
|
||||||
|
|
||||||
namespace Marble{
|
|
||||||
class GeoDataDocument;
|
|
||||||
}
|
|
||||||
|
|
||||||
class KMessageWidget;
|
|
||||||
using namespace Marble;
|
|
||||||
struct dive;
|
|
||||||
|
|
||||||
class GlobeGPS : public MarbleWidget {
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
using MarbleWidget::centerOn;
|
|
||||||
static GlobeGPS *instance();
|
|
||||||
void reload();
|
|
||||||
bool eventFilter(QObject *, QEvent *);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
/* reimp */ void resizeEvent(QResizeEvent *event);
|
|
||||||
/* reimp */ void mousePressEvent(QMouseEvent *event);
|
|
||||||
/* reimp */ void contextMenuEvent(QContextMenuEvent *);
|
|
||||||
|
|
||||||
private:
|
|
||||||
GeoDataDocument *loadedDives;
|
|
||||||
KMessageWidget *messageWidget;
|
|
||||||
QTimer *fixZoomTimer;
|
|
||||||
int currentZoomLevel;
|
|
||||||
bool needResetZoom;
|
|
||||||
bool editingDiveLocation;
|
|
||||||
bool doubleClick;
|
|
||||||
GlobeGPS(QWidget *parent = 0);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void coordinatesChanged();
|
|
||||||
|
|
||||||
public
|
|
||||||
slots:
|
|
||||||
void repopulateLabels();
|
|
||||||
void changeDiveGeoPosition(qreal lon, qreal lat, GeoDataCoordinates::Unit);
|
|
||||||
void mouseClicked(qreal lon, qreal lat, GeoDataCoordinates::Unit);
|
|
||||||
void fixZoom(bool now = false);
|
|
||||||
void zoomOutForNoGPS();
|
|
||||||
void prepareForGetDiveCoordinates();
|
|
||||||
void endGetDiveCoordinates();
|
|
||||||
void centerOnDiveSite(struct dive_site *ds);
|
|
||||||
void centerOnIndex(const QModelIndex& idx);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // NO_MARBLE
|
|
||||||
|
|
||||||
extern "C" double getDistance(int lat1, int lon1, int lat2, int lon2);
|
|
||||||
|
|
||||||
#endif // GLOBE_H
|
|
|
@ -4,7 +4,6 @@
|
||||||
#include "desktop-widgets/mainwindow.h"
|
#include "desktop-widgets/mainwindow.h"
|
||||||
#include "desktop-widgets/divelistview.h"
|
#include "desktop-widgets/divelistview.h"
|
||||||
#include "core/qthelper.h"
|
#include "core/qthelper.h"
|
||||||
#include "desktop-widgets/globe.h"
|
|
||||||
#include "desktop-widgets/mapwidget.h"
|
#include "desktop-widgets/mapwidget.h"
|
||||||
#include "qt-models/filtermodels.h"
|
#include "qt-models/filtermodels.h"
|
||||||
#include "qt-models/divelocationmodel.h"
|
#include "qt-models/divelocationmodel.h"
|
||||||
|
@ -45,16 +44,6 @@ LocationInformationWidget::LocationInformationWidget(QWidget *parent) : QGroupBo
|
||||||
ui.diveSiteListView->setModelColumn(LocationInformationModel::NAME);
|
ui.diveSiteListView->setModelColumn(LocationInformationModel::NAME);
|
||||||
ui.diveSiteListView->installEventFilter(this);
|
ui.diveSiteListView->installEventFilter(this);
|
||||||
// Map Management Code.
|
// Map Management Code.
|
||||||
#ifndef NO_MARBLE
|
|
||||||
connect(this, &LocationInformationWidget::requestCoordinates,
|
|
||||||
GlobeGPS::instance(), &GlobeGPS::prepareForGetDiveCoordinates);
|
|
||||||
connect(this, &LocationInformationWidget::endRequestCoordinates,
|
|
||||||
GlobeGPS::instance(), &GlobeGPS::endGetDiveCoordinates);
|
|
||||||
connect(GlobeGPS::instance(), &GlobeGPS::coordinatesChanged,
|
|
||||||
this, &LocationInformationWidget::updateGpsCoordinates);
|
|
||||||
connect(this, &LocationInformationWidget::endEditDiveSite,
|
|
||||||
GlobeGPS::instance(), &GlobeGPS::repopulateLabels);
|
|
||||||
#else
|
|
||||||
connect(this, &LocationInformationWidget::requestCoordinates,
|
connect(this, &LocationInformationWidget::requestCoordinates,
|
||||||
MapWidget::instance(), &MapWidget::prepareForGetDiveCoordinates);
|
MapWidget::instance(), &MapWidget::prepareForGetDiveCoordinates);
|
||||||
connect(this, &LocationInformationWidget::endRequestCoordinates,
|
connect(this, &LocationInformationWidget::endRequestCoordinates,
|
||||||
|
@ -63,7 +52,6 @@ LocationInformationWidget::LocationInformationWidget(QWidget *parent) : QGroupBo
|
||||||
this, &LocationInformationWidget::updateGpsCoordinates);
|
this, &LocationInformationWidget::updateGpsCoordinates);
|
||||||
connect(this, &LocationInformationWidget::endEditDiveSite,
|
connect(this, &LocationInformationWidget::endEditDiveSite,
|
||||||
MapWidget::instance(), &MapWidget::repopulateLabels);
|
MapWidget::instance(), &MapWidget::repopulateLabels);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LocationInformationWidget::eventFilter(QObject *, QEvent *ev)
|
bool LocationInformationWidget::eventFilter(QObject *, QEvent *ev)
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
#include "core/planner.h"
|
#include "core/planner.h"
|
||||||
#include "qt-models/filtermodels.h"
|
#include "qt-models/filtermodels.h"
|
||||||
#include "profile-widget/profilewidget2.h"
|
#include "profile-widget/profilewidget2.h"
|
||||||
#include "desktop-widgets/globe.h"
|
|
||||||
#include "core/divecomputer.h"
|
#include "core/divecomputer.h"
|
||||||
#include "desktop-widgets/tab-widgets/maintab.h"
|
#include "desktop-widgets/tab-widgets/maintab.h"
|
||||||
#include "desktop-widgets/diveplanner.h"
|
#include "desktop-widgets/diveplanner.h"
|
||||||
|
@ -104,12 +103,7 @@ MainWindow::MainWindow() : QMainWindow(),
|
||||||
MainTab *mainTab = new MainTab();
|
MainTab *mainTab = new MainTab();
|
||||||
DiveListView *diveListView = new DiveListView();
|
DiveListView *diveListView = new DiveListView();
|
||||||
ProfileWidget2 *profileWidget = new ProfileWidget2();
|
ProfileWidget2 *profileWidget = new ProfileWidget2();
|
||||||
|
|
||||||
#ifndef NO_MARBLE
|
|
||||||
GlobeGPS *mapWidget = GlobeGPS::instance();
|
|
||||||
#else
|
|
||||||
MapWidget *mapWidget = MapWidget::instance();
|
MapWidget *mapWidget = MapWidget::instance();
|
||||||
#endif
|
|
||||||
|
|
||||||
PlannerSettingsWidget *plannerSettings = new PlannerSettingsWidget();
|
PlannerSettingsWidget *plannerSettings = new PlannerSettingsWidget();
|
||||||
DivePlannerWidget *plannerWidget = new DivePlannerWidget();
|
DivePlannerWidget *plannerWidget = new DivePlannerWidget();
|
||||||
|
@ -216,11 +210,7 @@ MainWindow::MainWindow() : QMainWindow(),
|
||||||
diveListView->reload(DiveTripModel::TREE);
|
diveListView->reload(DiveTripModel::TREE);
|
||||||
diveListView->reloadHeaderActions();
|
diveListView->reloadHeaderActions();
|
||||||
diveListView->setFocus();
|
diveListView->setFocus();
|
||||||
#ifndef NO_MARBLE
|
|
||||||
GlobeGPS::instance()->reload();
|
|
||||||
#else
|
|
||||||
MapWidget::instance()->reload();
|
MapWidget::instance()->reload();
|
||||||
#endif
|
|
||||||
diveListView->expand(dive_list()->model()->index(0, 0));
|
diveListView->expand(dive_list()->model()->index(0, 0));
|
||||||
diveListView->scrollTo(dive_list()->model()->index(0, 0), QAbstractItemView::PositionAtCenter);
|
diveListView->scrollTo(dive_list()->model()->index(0, 0), QAbstractItemView::PositionAtCenter);
|
||||||
divePlannerWidget()->settingsChanged();
|
divePlannerWidget()->settingsChanged();
|
||||||
|
@ -429,11 +419,7 @@ void MainWindow::refreshDisplay(bool doRecreateDiveList)
|
||||||
getNotificationWidget()->showNotification(get_error_string(), KMessageWidget::Error);
|
getNotificationWidget()->showNotification(get_error_string(), KMessageWidget::Error);
|
||||||
information()->reload();
|
information()->reload();
|
||||||
TankInfoModel::instance()->update();
|
TankInfoModel::instance()->update();
|
||||||
#ifndef NO_MARBLE
|
|
||||||
GlobeGPS::instance()->reload();
|
|
||||||
#else
|
|
||||||
MapWidget::instance()->reload();
|
MapWidget::instance()->reload();
|
||||||
#endif
|
|
||||||
if (doRecreateDiveList)
|
if (doRecreateDiveList)
|
||||||
recreateDiveList();
|
recreateDiveList();
|
||||||
|
|
||||||
|
@ -504,11 +490,7 @@ void MainWindow::current_dive_changed(int divenr)
|
||||||
graphics()->plotDive();
|
graphics()->plotDive();
|
||||||
information()->updateDiveInfo();
|
information()->updateDiveInfo();
|
||||||
configureToolbar();
|
configureToolbar();
|
||||||
#ifndef NO_MARBLE
|
|
||||||
GlobeGPS::instance()->reload();
|
|
||||||
#else
|
|
||||||
MapWidget::instance()->reload();
|
MapWidget::instance()->reload();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionNew_triggered()
|
void MainWindow::on_actionNew_triggered()
|
||||||
|
@ -664,11 +646,7 @@ void MainWindow::cleanUpEmpty()
|
||||||
information()->updateDiveInfo(true);
|
information()->updateDiveInfo(true);
|
||||||
graphics()->setEmptyState();
|
graphics()->setEmptyState();
|
||||||
dive_list()->reload(DiveTripModel::TREE);
|
dive_list()->reload(DiveTripModel::TREE);
|
||||||
#ifndef NO_MARBLE
|
|
||||||
GlobeGPS::instance()->reload();
|
|
||||||
#else
|
|
||||||
MapWidget::instance()->reload();
|
MapWidget::instance()->reload();
|
||||||
#endif
|
|
||||||
if (!existing_filename)
|
if (!existing_filename)
|
||||||
setTitle(MWTF_DEFAULT);
|
setTitle(MWTF_DEFAULT);
|
||||||
disableShortcuts();
|
disableShortcuts();
|
||||||
|
@ -1032,11 +1010,7 @@ void MainWindow::on_actionEditDive_triggered()
|
||||||
disableShortcuts();
|
disableShortcuts();
|
||||||
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::ADD);
|
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::ADD);
|
||||||
graphics()->setAddState();
|
graphics()->setAddState();
|
||||||
#ifndef NO_MARBLE
|
|
||||||
GlobeGPS::instance()->endGetDiveCoordinates();
|
|
||||||
#else
|
|
||||||
MapWidget::instance()->endGetDiveCoordinates();
|
MapWidget::instance()->endGetDiveCoordinates();
|
||||||
#endif
|
|
||||||
setApplicationState("EditDive");
|
setApplicationState("EditDive");
|
||||||
DivePlannerPointsModel::instance()->loadFromDive(current_dive);
|
DivePlannerPointsModel::instance()->loadFromDive(current_dive);
|
||||||
information()->enableEdition(MainTab::MANUALLY_ADDED_DIVE);
|
information()->enableEdition(MainTab::MANUALLY_ADDED_DIVE);
|
||||||
|
|
|
@ -1,119 +0,0 @@
|
||||||
// SPDX-License-Identifier: LGPL-2.1+
|
|
||||||
//
|
|
||||||
// This file is part of the Marble Virtual Globe.
|
|
||||||
//
|
|
||||||
// This program is free software licensed under the GNU LGPL. You can
|
|
||||||
// find a copy of this license in LICENSE.txt in the top directory of
|
|
||||||
// the source code.
|
|
||||||
//
|
|
||||||
// Copyright 2010 Thibaut Gridel <tgridel@free.fr>
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef MARBLE_GEODATATREEMODEL_H
|
|
||||||
#define MARBLE_GEODATATREEMODEL_H
|
|
||||||
|
|
||||||
// -> does not appear to be needed #include "marble_export.h"
|
|
||||||
|
|
||||||
#include <QAbstractItemModel>
|
|
||||||
|
|
||||||
class QItemSelectionModel;
|
|
||||||
|
|
||||||
namespace Marble
|
|
||||||
{
|
|
||||||
class GeoDataObject;
|
|
||||||
class GeoDataDocument;
|
|
||||||
class GeoDataFeature;
|
|
||||||
class GeoDataContainer;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @short The representation of GeoData in a model
|
|
||||||
* This class represents all available data given by kml-data files.
|
|
||||||
*/
|
|
||||||
class MARBLE_EXPORT GeoDataTreeModel : public QAbstractItemModel
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new GeoDataTreeModel.
|
|
||||||
*
|
|
||||||
* @param parent The parent object.
|
|
||||||
*/
|
|
||||||
explicit GeoDataTreeModel( QObject *parent = 0 );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Destroys the GeoDataModel.
|
|
||||||
*/
|
|
||||||
~GeoDataTreeModel();
|
|
||||||
|
|
||||||
virtual bool hasChildren( const QModelIndex &parent ) const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the number of Items in the Model.
|
|
||||||
*/
|
|
||||||
int rowCount( const QModelIndex &parent = QModelIndex() ) const;
|
|
||||||
|
|
||||||
QVariant headerData(int section, Qt::Orientation orientation,
|
|
||||||
int role = Qt::DisplayRole) const;
|
|
||||||
|
|
||||||
QVariant data( const QModelIndex &index, int role ) const;
|
|
||||||
|
|
||||||
QModelIndex index( int row, int column,
|
|
||||||
const QModelIndex &parent = QModelIndex() ) const;
|
|
||||||
|
|
||||||
QModelIndex index( GeoDataObject* object );
|
|
||||||
|
|
||||||
QModelIndex parent( const QModelIndex &index ) const;
|
|
||||||
|
|
||||||
int columnCount( const QModelIndex &parent = QModelIndex() ) const;
|
|
||||||
|
|
||||||
Qt::ItemFlags flags ( const QModelIndex & index ) const;
|
|
||||||
|
|
||||||
bool setData ( const QModelIndex & index, const QVariant & value, int role = Qt::EditRole );
|
|
||||||
|
|
||||||
void reset();
|
|
||||||
|
|
||||||
QItemSelectionModel *selectionModel();
|
|
||||||
|
|
||||||
public Q_SLOTS:
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the root document to use. This replaces previously loaded data, if any.
|
|
||||||
* @param document The new root document. Ownership retains with the caller,
|
|
||||||
* i.e. GeoDataTreeModel will not delete the passed document at its destruction.
|
|
||||||
*/
|
|
||||||
void setRootDocument( GeoDataDocument *document );
|
|
||||||
GeoDataDocument* rootDocument();
|
|
||||||
|
|
||||||
int addFeature( GeoDataContainer *parent, GeoDataFeature *feature, int row = -1 );
|
|
||||||
|
|
||||||
bool removeFeature( GeoDataContainer *parent, int index );
|
|
||||||
|
|
||||||
int removeFeature( const GeoDataFeature *feature );
|
|
||||||
|
|
||||||
void updateFeature( GeoDataFeature *feature );
|
|
||||||
|
|
||||||
int addDocument( GeoDataDocument *document );
|
|
||||||
|
|
||||||
void removeDocument( int index );
|
|
||||||
|
|
||||||
void removeDocument( GeoDataDocument* document );
|
|
||||||
|
|
||||||
void update();
|
|
||||||
|
|
||||||
Q_SIGNALS:
|
|
||||||
/// insert and remove row don't trigger any signal that proxies forward
|
|
||||||
/// this signal will refresh geometry layer and placemark layout
|
|
||||||
void removed( GeoDataObject *object );
|
|
||||||
void added( GeoDataObject *object );
|
|
||||||
private:
|
|
||||||
Q_DISABLE_COPY( GeoDataTreeModel )
|
|
||||||
class Private;
|
|
||||||
Private* const d;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // MARBLE_GEODATATREEMODEL_H
|
|
|
@ -12,9 +12,6 @@
|
||||||
#include "qt-models/weightmodel.h"
|
#include "qt-models/weightmodel.h"
|
||||||
#include "qt-models/divetripmodel.h"
|
#include "qt-models/divetripmodel.h"
|
||||||
#include "core/qthelper.h"
|
#include "core/qthelper.h"
|
||||||
#ifndef NO_MARBLE
|
|
||||||
#include "desktop-widgets/globe.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <QCompleter>
|
#include <QCompleter>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
#include "desktop-widgets/mainwindow.h"
|
#include "desktop-widgets/mainwindow.h"
|
||||||
#include "desktop-widgets/usersurvey.h"
|
#include "desktop-widgets/usersurvey.h"
|
||||||
#include "core/divelist.h"
|
#include "core/divelist.h"
|
||||||
#include "desktop-widgets/globe.h"
|
|
||||||
#include "desktop-widgets/mapwidget.h"
|
#include "desktop-widgets/mapwidget.h"
|
||||||
#include "desktop-widgets/tab-widgets/maintab.h"
|
#include "desktop-widgets/tab-widgets/maintab.h"
|
||||||
#include "core/display.h"
|
#include "core/display.h"
|
||||||
|
@ -482,13 +481,8 @@ void SubsurfaceWebServices::buttonClicked(QAbstractButton *button)
|
||||||
// finally now that all the extra GPS fixes that weren't used have been deleted
|
// finally now that all the extra GPS fixes that weren't used have been deleted
|
||||||
// we can update the map
|
// we can update the map
|
||||||
if (changed) {
|
if (changed) {
|
||||||
#ifndef NO_MARBLE
|
|
||||||
GlobeGPS::instance()->repopulateLabels();
|
|
||||||
GlobeGPS::instance()->centerOnDiveSite(get_dive_site_by_uuid(current_dive->dive_site_uuid));
|
|
||||||
#else
|
|
||||||
MapWidget::instance()->repopulateLabels();
|
MapWidget::instance()->repopulateLabels();
|
||||||
MapWidget::instance()->centerOnDiveSite(get_dive_site_by_uuid(current_dive->dive_site_uuid));
|
MapWidget::instance()->centerOnDiveSite(get_dive_site_by_uuid(current_dive->dive_site_uuid));
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
*/
|
*/
|
||||||
#include "desktop-widgets/tab-widgets/maintab.h"
|
#include "desktop-widgets/tab-widgets/maintab.h"
|
||||||
#include "desktop-widgets/mainwindow.h"
|
#include "desktop-widgets/mainwindow.h"
|
||||||
#include "desktop-widgets/globe.h"
|
|
||||||
#include "desktop-widgets/mapwidget.h"
|
#include "desktop-widgets/mapwidget.h"
|
||||||
#include "core/helpers.h"
|
#include "core/helpers.h"
|
||||||
#include "core/statistics.h"
|
#include "core/statistics.h"
|
||||||
|
@ -72,13 +71,8 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
|
||||||
closeMessage();
|
closeMessage();
|
||||||
|
|
||||||
connect(ui.editDiveSiteButton, SIGNAL(clicked()), MainWindow::instance(), SIGNAL(startDiveSiteEdit()));
|
connect(ui.editDiveSiteButton, SIGNAL(clicked()), MainWindow::instance(), SIGNAL(startDiveSiteEdit()));
|
||||||
#ifndef NO_MARBLE
|
|
||||||
connect(ui.location, &DiveLocationLineEdit::entered, GlobeGPS::instance(), &GlobeGPS::centerOnIndex);
|
|
||||||
connect(ui.location, &DiveLocationLineEdit::currentChanged, GlobeGPS::instance(), &GlobeGPS::centerOnIndex);
|
|
||||||
#else
|
|
||||||
connect(ui.location, &DiveLocationLineEdit::entered, MapWidget::instance(), &MapWidget::centerOnIndex);
|
connect(ui.location, &DiveLocationLineEdit::entered, MapWidget::instance(), &MapWidget::centerOnIndex);
|
||||||
connect(ui.location, &DiveLocationLineEdit::currentChanged, MapWidget::instance(), &MapWidget::centerOnIndex);
|
connect(ui.location, &DiveLocationLineEdit::currentChanged, MapWidget::instance(), &MapWidget::centerOnIndex);
|
||||||
#endif
|
|
||||||
|
|
||||||
QAction *action = new QAction(tr("Apply changes"), this);
|
QAction *action = new QAction(tr("Apply changes"), this);
|
||||||
connect(action, SIGNAL(triggered(bool)), this, SLOT(acceptChanges()));
|
connect(action, SIGNAL(triggered(bool)), this, SLOT(acceptChanges()));
|
||||||
|
@ -911,11 +905,7 @@ void MainTab::acceptChanges()
|
||||||
qDebug() << "delete now unused dive site" << ((ds && ds->name) ? ds->name : "without name");
|
qDebug() << "delete now unused dive site" << ((ds && ds->name) ? ds->name : "without name");
|
||||||
}
|
}
|
||||||
delete_dive_site(oldUuid);
|
delete_dive_site(oldUuid);
|
||||||
#ifndef NO_MARBLE
|
|
||||||
GlobeGPS::instance()->reload();
|
|
||||||
#else
|
|
||||||
MapWidget::instance()->reload();
|
MapWidget::instance()->reload();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
// the code above can change the correct uuid for the displayed dive site - and the
|
// the code above can change the correct uuid for the displayed dive site - and the
|
||||||
// code below triggers an update of the display without re-initializing displayed_dive
|
// code below triggers an update of the display without re-initializing displayed_dive
|
||||||
|
@ -1047,11 +1037,7 @@ void MainTab::rejectChanges()
|
||||||
}
|
}
|
||||||
// the user could have edited the location and then canceled the edit
|
// the user could have edited the location and then canceled the edit
|
||||||
// let's get the correct location back in view
|
// let's get the correct location back in view
|
||||||
#ifndef NO_MARBLE
|
|
||||||
GlobeGPS::instance()->centerOnDiveSite(get_dive_site_by_uuid(displayed_dive.dive_site_uuid));
|
|
||||||
#else
|
|
||||||
MapWidget::instance()->centerOnDiveSite(get_dive_site_by_uuid(displayed_dive.dive_site_uuid));
|
MapWidget::instance()->centerOnDiveSite(get_dive_site_by_uuid(displayed_dive.dive_site_uuid));
|
||||||
#endif
|
|
||||||
// show the profile and dive info
|
// show the profile and dive info
|
||||||
MainWindow::instance()->graphics()->replot();
|
MainWindow::instance()->graphics()->replot();
|
||||||
MainWindow::instance()->setEnabledToolbar(true);
|
MainWindow::instance()->setEnabledToolbar(true);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue