Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d0e0aabbe4 | ||
|
|
cb9129462c |
@ -49,6 +49,11 @@ bool GpsLocation::hasInstance()
|
||||
return m_Instance != NULL;
|
||||
}
|
||||
|
||||
QSettings *GpsLocation::getSettings()
|
||||
{
|
||||
return geoSettings;
|
||||
}
|
||||
|
||||
GpsLocation::~GpsLocation()
|
||||
{
|
||||
m_Instance = NULL;
|
||||
@ -404,6 +409,23 @@ void GpsLocation::deleteGpsFix(qint64 when)
|
||||
}
|
||||
|
||||
#ifdef SUBSURFACE_MOBILE
|
||||
extern "C"
|
||||
const char *gpsGetString(int idx, const char **name)
|
||||
{
|
||||
// check if we are supposed to store the data to the cloud and return
|
||||
// the nth GPS fix, if it exists
|
||||
if (!name || !prefs.store_gps_cloud ||
|
||||
!GpsLocation::hasInstance() || GpsLocation::instance()->getGpsNum() <= idx)
|
||||
return NULL;
|
||||
QSettings *geoSettings = GpsLocation::instance()->getSettings();
|
||||
QString text = QString("when %1 lat %2 lon %3").arg(geoSettings->value(QStringLiteral("gpsFix%1_time").arg(idx)).toString())
|
||||
.arg(geoSettings->value(QStringLiteral("gpsFix%1_lat").arg(idx)).toString())
|
||||
.arg(geoSettings->value(QStringLiteral("gpsFix%1_lon").arg(idx)).toString());
|
||||
QString fixName = geoSettings->value(QStringLiteral("gpsFix%1_name").arg(idx)).toString();
|
||||
*name = strdup(fixName.toUtf8().constData());
|
||||
return strdup(text.toUtf8().constData());
|
||||
}
|
||||
|
||||
void GpsLocation::clearGpsData()
|
||||
{
|
||||
m_trackers.clear();
|
||||
@ -411,8 +433,3 @@ void GpsLocation::clearGpsData()
|
||||
geoSettings->sync();
|
||||
}
|
||||
#endif
|
||||
|
||||
void GpsLocation::postError(QNetworkReply::NetworkError)
|
||||
{
|
||||
status(QStringLiteral("error when sending a GPS fix: %1").arg(reply->errorString()));
|
||||
}
|
||||
|
||||
@ -37,7 +37,7 @@ public:
|
||||
int getGpsNum() const;
|
||||
bool hasLocationsSource();
|
||||
QString currentPosition();
|
||||
|
||||
QSettings *getSettings();
|
||||
QMap<qint64, gpsTracker> currentGPSInfo() const;
|
||||
|
||||
private:
|
||||
@ -69,7 +69,6 @@ public slots:
|
||||
void newPosition(QGeoPositionInfo pos);
|
||||
void updateTimeout();
|
||||
void positionSourceError(QGeoPositionInfoSource::Error error);
|
||||
void postError(QNetworkReply::NetworkError error);
|
||||
void setGpsTimeThreshold(int seconds);
|
||||
#ifdef SUBSURFACE_MOBILE
|
||||
void clearGpsData();
|
||||
|
||||
@ -138,6 +138,7 @@ struct preferences {
|
||||
// ********** LocationService **********
|
||||
int time_threshold;
|
||||
int distance_threshold;
|
||||
int store_gps_cloud;
|
||||
|
||||
// ********** Network **********
|
||||
bool proxy_auth;
|
||||
|
||||
@ -916,6 +916,29 @@ static void save_divesites(git_repository *repo, struct dir *tree)
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(SUBSURFACE_MOBILE)
|
||||
// from gpslocation.cpp
|
||||
extern const char *gpsGetString(int idx, const char **name);
|
||||
|
||||
static void save_gps(git_repository *repo, struct dir *tree)
|
||||
{
|
||||
struct membuffer b = { 0 };
|
||||
int i = 0;
|
||||
const char *string;
|
||||
const char *name = NULL;
|
||||
do {
|
||||
string = gpsGetString(i++, &name);
|
||||
if (string) {
|
||||
put_string(&b, string);
|
||||
show_utf8(&b, " name ", name, "\n");
|
||||
free((void *)string);
|
||||
free((void *)name);
|
||||
}
|
||||
} while (string != NULL);
|
||||
blob_insert(repo, tree, &b, "02-Gps");
|
||||
}
|
||||
#endif
|
||||
|
||||
static int create_git_tree(git_repository *repo, struct dir *root, bool select_only, bool cached_ok)
|
||||
{
|
||||
int i;
|
||||
@ -927,6 +950,10 @@ static int create_git_tree(git_repository *repo, struct dir *root, bool select_o
|
||||
|
||||
save_divesites(repo, root);
|
||||
|
||||
#if defined(SUBSURFACE_MOBILE)
|
||||
save_gps(repo, root);
|
||||
#endif
|
||||
|
||||
for (i = 0; i < trip_table.nr; ++i)
|
||||
trip_table.trips[i]->saved = 0;
|
||||
|
||||
|
||||
@ -93,6 +93,7 @@ struct preferences default_prefs = {
|
||||
.vpmb_conservatism = 3,
|
||||
.distance_threshold = 100,
|
||||
.time_threshold = 300,
|
||||
.store_gps_cloud = 0,
|
||||
#if defined(SUBSURFACE_MOBILE)
|
||||
.cloud_timeout = 10,
|
||||
#else
|
||||
|
||||
@ -618,17 +618,43 @@ TemplatePage {
|
||||
TemplateLabel {
|
||||
text: qsTr("Display Developer menu")
|
||||
Layout.fillWidth: true
|
||||
//Layout.preferredWidth: gridWidth * 0.75
|
||||
}
|
||||
SsrfSwitch {
|
||||
id: developerButton
|
||||
checked: PrefDisplay.show_developer
|
||||
//sLayout.preferredWidth: gridWidth * 0.25
|
||||
onClicked: {
|
||||
PrefDisplay.show_developer = checked
|
||||
}
|
||||
}
|
||||
}
|
||||
TemplateLine {
|
||||
visible: sectionAdvanced.isExpanded
|
||||
}
|
||||
GridLayout {
|
||||
id: gpsToCloud
|
||||
visible: sectionAdvanced.isExpanded
|
||||
width: parent.width
|
||||
columns: 2
|
||||
TemplateLabel {
|
||||
text: qsTr("GPS data")
|
||||
font.pointSize: subsurfaceTheme.headingPointSize
|
||||
font.weight: Font.Light
|
||||
Layout.topMargin: Kirigami.Units.largeSpacing
|
||||
Layout.bottomMargin: Kirigami.Units.largeSpacing / 2
|
||||
Layout.columnSpan: 2
|
||||
}
|
||||
TemplateLabel {
|
||||
text: qsTr("Store data to cloud")
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
SsrfSwitch {
|
||||
checked: manager.storeGpsToCoud()
|
||||
onClicked: {
|
||||
manager.setStoreGpsToCloud(checked)
|
||||
if (checked)
|
||||
manager.saveChangesCloud(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2266,3 +2266,16 @@ QString QMLManager::getSyncState() const
|
||||
return tr("(changes synced locally)");
|
||||
return tr("(synced with cloud)");
|
||||
}
|
||||
|
||||
void QMLManager::setStoreGpsToCloud(int value)
|
||||
{
|
||||
prefs.store_gps_cloud = value;
|
||||
if (value)
|
||||
// that's not really true, but this way the Gps section gets written
|
||||
mark_divelist_changed(true);
|
||||
}
|
||||
|
||||
int QMLManager::storeGpsToCloud()
|
||||
{
|
||||
return prefs.store_gps_cloud;
|
||||
}
|
||||
|
||||
@ -241,6 +241,8 @@ public slots:
|
||||
QString getProductVendorConnectionIdx(android_usb_serial_device_descriptor descriptor);
|
||||
#endif
|
||||
void divesChanged(const QVector<dive *> &dives, DiveField field);
|
||||
int storeGpsToCloud();
|
||||
void setStoreGpsToCloud(int value);
|
||||
|
||||
private:
|
||||
BuddyCompletionModel buddyModel;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user