aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--qt-mobile/qml/DiveDetails.qml3
-rw-r--r--qt-mobile/qmlmanager.cpp21
-rw-r--r--qt-mobile/qmlmanager.h2
3 files changed, 23 insertions, 3 deletions
diff --git a/qt-mobile/qml/DiveDetails.qml b/qt-mobile/qml/DiveDetails.qml
index a99aa628c..27a8996da 100644
--- a/qt-mobile/qml/DiveDetails.qml
+++ b/qt-mobile/qml/DiveDetails.qml
@@ -52,9 +52,10 @@ MobileComponents.Page {
iconName: checked ? "view-readermode" : "document-edit"
onTriggered: {
if (diveDetailsWindow.state == "edit") {
- manager.commitChanges(dive_id, detailsEdit.locationText, detailsEdit.gpsText, detailsEdit.durationText,
+ manager.commitChanges(dive_id, detailsEdit.dateText, detailsEdit.locationText, detailsEdit.gpsText, detailsEdit.durationText,
detailsEdit.depthText, detailsEdit.airtempText, detailsEdit.watertempText, detailsEdit.suitText,
detailsEdit.buddyText, detailsEdit.divemasterText, detailsEdit.notesText)
+ date = detailsEdit.dateText
location = detailsEdit.locationText
// gps = detailsEdit.gps
duration = detailsEdit.durationText
diff --git a/qt-mobile/qmlmanager.cpp b/qt-mobile/qmlmanager.cpp
index 90293e8bf..9b6911b3a 100644
--- a/qt-mobile/qmlmanager.cpp
+++ b/qt-mobile/qmlmanager.cpp
@@ -303,7 +303,7 @@ void QMLManager::loadDivesWithValidCredentials()
setLoadFromCloud(true);
}
-void QMLManager::commitChanges(QString diveId, QString location, QString gps, QString duration, QString depth,
+void QMLManager::commitChanges(QString diveId, QString date, QString location, QString gps, QString duration, QString depth,
QString airtemp, QString watertemp, QString suit, QString buddy, QString diveMaster, QString notes)
{
struct dive *d = get_dive_by_uniq_id(diveId.toInt());
@@ -315,6 +315,25 @@ void QMLManager::commitChanges(QString diveId, QString location, QString gps, QS
}
bool diveChanged = false;
+ if (date != get_dive_date_string(d->when)) {
+ diveChanged = true;
+ QDateTime newDate;
+ // what a pain - Qt will not parse dates if the day of the week is incorrect
+ // so if the user changed the date but didn't update the day of the week (most likely behavior, actually),
+ // we need to make sure we don't try to parse that
+ QString format(QString(prefs.date_format) + " " + prefs.time_format);
+ if (format.contains("ddd") || format.contains("dddd")) {
+ QString dateFormatToDrop = format.contains("ddd") ? "ddd" : "dddd";
+ QDateTime ts;
+ QLocale loc = getLocale();
+ ts.setMSecsSinceEpoch(d->when * 1000L);
+ QString drop = loc.toString(ts.toUTC(), dateFormatToDrop);
+ format.replace(dateFormatToDrop, "");
+ date.replace(drop, "");
+ }
+ newDate = QDateTime::fromString(date, format);
+ d->when = newDate.toMSecsSinceEpoch() / 1000 + gettimezoneoffset(newDate.toMSecsSinceEpoch() / 1000);
+ }
struct dive_site *ds = get_dive_site_by_uuid(d->dive_site_uuid);
char *locationtext = NULL;
if (ds)
diff --git a/qt-mobile/qmlmanager.h b/qt-mobile/qmlmanager.h
index 097aca3a2..24ca265e6 100644
--- a/qt-mobile/qmlmanager.h
+++ b/qt-mobile/qmlmanager.h
@@ -71,7 +71,7 @@ public slots:
void loadDivesWithValidCredentials();
void loadDiveProgress(int percent);
void provideAuth(QNetworkReply *reply, QAuthenticator *auth);
- void commitChanges(QString diveId, QString location, QString gps, QString duration, QString depth,
+ void commitChanges(QString diveId, QString date, QString location, QString gps, QString duration, QString depth,
QString airtemp, QString watertemp, QString suit, QString buddy, QString diveMaster, QString notes);
void saveChanges();
QString addDive();