mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Desktop: Import dive coordinates directly from GPS
This allows Subsurface to obtain the coordinates of a dive directly from a GPS track. It parses a GPX file (GPX V1.0 or V1.1) from a GPS to locate the trackpoint immediatedly after the start of a dive. There is an additional "Use GPS file" button in the Edit Dive Site panel that is selected from the Notes tab. Image: This allows one to select a GPX file, bringing up the Import GPS dialog. There is extensive provision for cross-checking that the dive track synchronises with the dive start and end. If the Save button in the dialog is pressed the dive coordinates are copied into the Dive Coordinates text box in the Edit Dive Site panel. The map moves to indicate the location of the dive site. The bulk of the work is done in importgps.cpp. The code is pretty intergrated: I tried to break it up in smaller commits but that was not feasible. The code includes responses to the comments by @neolit123 and @bstoeger. The C-based file input was replaced with Qt-based code using QChar, QString and QFile. [Dirk Hohndel: fixed several small issues in the .ui file, removed various headers includes that weren't needed and fixed printing of minutes as zero padded] Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
1f51251f1b
commit
1ecd5065a0
11 changed files with 977 additions and 12 deletions
|
@ -1,5 +1,6 @@
|
|||
// SPDX-License-Identifier: GPL-2.0
|
||||
#include "desktop-widgets/locationinformation.h"
|
||||
#include "desktop-widgets/importgps.h"
|
||||
#include "core/subsurface-string.h"
|
||||
#include "desktop-widgets/mainwindow.h"
|
||||
#include "desktop-widgets/divelistview.h"
|
||||
|
@ -13,12 +14,12 @@
|
|||
#include "core/settings/qPrefUnit.h"
|
||||
#include "commands/command.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QShowEvent>
|
||||
#include <QItemSelectionModel>
|
||||
#include <qmessagebox.h>
|
||||
#include <cstdlib>
|
||||
#include <QDesktopWidget>
|
||||
#include <QFileDialog>
|
||||
#include <QScrollBar>
|
||||
|
||||
LocationInformationWidget::LocationInformationWidget(QWidget *parent) : QGroupBox(parent), diveSite(nullptr), closeDistance(0)
|
||||
|
@ -220,6 +221,27 @@ void LocationInformationWidget::initFields(dive_site *ds)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void LocationInformationWidget::on_GPSbutton_clicked()
|
||||
{
|
||||
QFileInfo finfo(system_default_directory());
|
||||
QString fileName = QFileDialog::getOpenFileName(this,
|
||||
tr("Select GPS file to open"),
|
||||
finfo.absolutePath(),
|
||||
tr("GPS files (*.gpx *.GPX)"));
|
||||
if (fileName.isEmpty())
|
||||
return;
|
||||
|
||||
ImportGPS GPSDialog(this, fileName, &ui); // Create a GPS import QDialog
|
||||
GPSDialog.coords.start_dive = current_dive->when; // initialise
|
||||
GPSDialog.coords.end_dive = dive_endtime(current_dive);
|
||||
if (!GPSDialog.getCoordsFromFile()) { // Get coordinates from GPS file
|
||||
GPSDialog.updateUI(); // If successful, put results in Dialog
|
||||
if (!GPSDialog.exec()) // and show QDialog
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void LocationInformationWidget::on_diveSiteCoordinates_editingFinished()
|
||||
{
|
||||
if (diveSite)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue