summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--qt-mobile/DiveList.qml11
-rw-r--r--qt-mobile/main.qml8
-rw-r--r--qt-mobile/qmlmanager.cpp48
-rw-r--r--qt-mobile/qmlmanager.h2
4 files changed, 67 insertions, 2 deletions
diff --git a/qt-mobile/DiveList.qml b/qt-mobile/DiveList.qml
index 40507e26a..0f358081d 100644
--- a/qt-mobile/DiveList.qml
+++ b/qt-mobile/DiveList.qml
@@ -109,7 +109,16 @@ Rectangle {
opacity: dive.detailsOpacity
text: "Close"
- onClicked: dive.state = '';
+ onClicked: {
+ manager.commitChanges(
+ id,
+ txtSuit.text,
+ txtBuddy.text,
+ txtDiveMaster.text,
+ txtNotes.text
+ )
+ dive.state = '';
+ }
}
states: State {
diff --git a/qt-mobile/main.qml b/qt-mobile/main.qml
index dac37e09b..d64c27760 100644
--- a/qt-mobile/main.qml
+++ b/qt-mobile/main.qml
@@ -54,6 +54,14 @@ ApplicationWindow {
manager.loadDives();
}
}
+
+ Button {
+ id: saveChanges
+ text: "Save Changes"
+ onClicked: {
+ manager.saveChanges();
+ }
+ }
}
}
diff --git a/qt-mobile/qmlmanager.cpp b/qt-mobile/qmlmanager.cpp
index 118465a2d..a1c64191b 100644
--- a/qt-mobile/qmlmanager.cpp
+++ b/qt-mobile/qmlmanager.cpp
@@ -66,7 +66,53 @@ void QMLManager::loadDives()
struct dive *d;
for_each_dive(i, d)
- DiveListModel::instance()->addDive(d);
+ DiveListModel::instance()->addDive(d);
+}
+
+void QMLManager::commitChanges(QString diveId, QString suit, QString buddy, QString diveMaster, QString notes)
+{
+ struct dive *d = get_dive_by_uniq_id(diveId.toInt());
+ bool diveChanged = false;
+
+ if (d->suit != suit.toUtf8().data()) {
+ diveChanged = true;
+ free(d->suit);
+ d->suit = strdup(suit.toUtf8().data());
+ }
+ if (d->buddy != buddy.toUtf8().data()) {
+ diveChanged = true;
+ free(d->buddy);
+ d->buddy = strdup(buddy.toUtf8().data());
+ }
+ if (d->divemaster != diveMaster.toUtf8().data()) {
+ diveChanged = true;
+ free(d->divemaster);
+ d->divemaster = strdup(diveMaster.toUtf8().data());
+ }
+ if (d->notes != notes.toUtf8().data()) {
+ diveChanged = true;
+ free(d->notes);
+ d->notes = strdup(notes.toUtf8().data());
+ }
+}
+
+void QMLManager::saveChanges()
+{
+ showMessage("Saving dives.");
+ QString fileName;
+ if (getCloudURL(fileName)) {
+ showMessage(get_error_string());
+ return;
+ }
+
+ if (save_dives(fileName.toUtf8().data())) {
+ showMessage(get_error_string());
+ return;
+ }
+
+ showMessage("Dives saved.");
+ set_filename(fileName.toUtf8().data(), true);
+ mark_divelist_changed(false);
}
QString QMLManager::cloudPassword() const
diff --git a/qt-mobile/qmlmanager.h b/qt-mobile/qmlmanager.h
index 558249e4e..2f5ac2894 100644
--- a/qt-mobile/qmlmanager.h
+++ b/qt-mobile/qmlmanager.h
@@ -22,6 +22,8 @@ public:
public slots:
void savePreferences();
void loadDives();
+ void commitChanges(QString diveId, QString suit, QString buddy, QString diveMaster, QString notes);
+ void saveChanges();
private:
QString m_cloudUserName;
QString m_cloudPassword;