mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
9be42fff81
commit
99a5a743c4
4 changed files with 49 additions and 28 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue