summaryrefslogtreecommitdiffstats
path: root/qt-mobile/qmlmanager.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-12-26 22:57:47 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-12-26 22:57:47 -0800
commit99a5a743c48e88d94bce96a78bc9bea9d8f4343e (patch)
treed479334671c548bcca14ea5cb60500642c67459c /qt-mobile/qmlmanager.cpp
parent9be42fff813ab959e23a813b37319ebf75a1951b (diff)
downloadsubsurface-99a5a743c48e88d94bce96a78bc9bea9d8f4343e.tar.gz
QML UI: change the way we extract input data from dive edit
Instead of doing the silly "onEditingFinished" we get the strings from the QML components at the time we commit the change. Much more logical, much more straight forward, no issues with the TextArea not having an onEditingFinished signal. This still has a few open todos: the temperatures aren't parsed, the edit screen is missing depth and duration, we can't edit the dive time (and it isn't passed in on the commit). But it's progress. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-mobile/qmlmanager.cpp')
-rw-r--r--qt-mobile/qmlmanager.cpp37
1 files changed, 28 insertions, 9 deletions
diff --git a/qt-mobile/qmlmanager.cpp b/qt-mobile/qmlmanager.cpp
index cdf844492..c0a2149b3 100644
--- a/qt-mobile/qmlmanager.cpp
+++ b/qt-mobile/qmlmanager.cpp
@@ -276,7 +276,8 @@ void QMLManager::loadDivesWithValidCredentials()
setLoadFromCloud(true);
}
-void QMLManager::commitChanges(QString diveId, QString suit, QString buddy, QString diveMaster, QString notes)
+void QMLManager::commitChanges(QString diveId, 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());
qDebug() << diveId.toInt() << (d != 0 ? d->number : -1);
@@ -287,25 +288,43 @@ void QMLManager::commitChanges(QString diveId, QString suit, QString buddy, QStr
}
bool diveChanged = false;
- if (!same_string(d->suit, suit.toUtf8().data())) {
+ struct dive_site *ds = get_dive_site_by_uuid(d->dive_site_uuid);
+ char *locationtext = NULL;
+ if (ds)
+ locationtext = ds->name;
+ if (!same_string(locationtext, qPrintable(location))) {
+ diveChanged = true;
+ // this is not ideal - and it's missing the gps information
+ // but for now let's just create a new dive site
+ ds = get_dive_site_by_uuid(create_dive_site(qPrintable(location), d->when));
+ d->dive_site_uuid = ds->uuid;
+ }
+ // now we need to handle the string representations of duration, depth, airtemp and watertemp
+ // and do something useful...
+ //
+ // FIXME
+ //
+ // TODO
+
+ if (!same_string(d->suit, qPrintable(suit))) {
diveChanged = true;
free(d->suit);
- d->suit = strdup(suit.toUtf8().data());
+ d->suit = strdup(qPrintable(suit));
}
- if (!same_string(d->buddy, buddy.toUtf8().data())) {
+ if (!same_string(d->buddy, qPrintable(buddy))) {
diveChanged = true;
free(d->buddy);
- d->buddy = strdup(buddy.toUtf8().data());
+ d->buddy = strdup(qPrintable(buddy));
}
- if (!same_string(d->divemaster, diveMaster.toUtf8().data())) {
+ if (!same_string(d->divemaster, qPrintable(diveMaster))) {
diveChanged = true;
free(d->divemaster);
- d->divemaster = strdup(diveMaster.toUtf8().data());
+ d->divemaster = strdup(qPrintable(diveMaster));
}
- if (!same_string(d->notes, notes.toUtf8().data())) {
+ if (!same_string(d->notes, qPrintable(notes))) {
diveChanged = true;
free(d->notes);
- d->notes = strdup(notes.toUtf8().data());
+ d->notes = strdup(qPrintable(notes));
}
if (diveChanged) {
DiveListModel::instance()->updateDive(d);