diff options
author | Grace Karanja <gracie.karanja89@gmail.com> | 2015-07-17 18:28:01 +0300 |
---|---|---|
committer | Grace Karanja <gracie.karanja89@gmail.com> | 2015-07-17 19:12:39 +0300 |
commit | df1a1f7034c6c332f7f71a64ab45955c089cd56b (patch) | |
tree | 0e52c44cdf4231a4d82e1ff91ae81dfd48e40706 /qt-mobile/qmlmanager.cpp | |
parent | aae27629c4b6f524911f869694da27dcd2533adb (diff) | |
download | subsurface-df1a1f7034c6c332f7f71a64ab45955c089cd56b.tar.gz |
QML UI: Implement saving of dives
This implements saving of some dive details to the cloud service. When the
user closes an open dives, any changed details will be cached, and when they
click on the 'Save Changes' button is pressed, the changes will be saved to
the cloud.
Signed-off-by: Grace Karanja <gracie.karanja89@gmail.com>
Diffstat (limited to 'qt-mobile/qmlmanager.cpp')
-rw-r--r-- | qt-mobile/qmlmanager.cpp | 48 |
1 files changed, 47 insertions, 1 deletions
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 |