mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +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
|
@ -53,9 +53,13 @@ MobileComponents.Page {
|
|||
iconName: checked ? "view-readermode" : "document-edit"
|
||||
onTriggered: {
|
||||
if (diveDetailsWindow.state == "edit") {
|
||||
manager.commitChanges(dive_id, suit, buddy, divemaster, notes);
|
||||
manager.commitChanges(dive_id, detailsEdit.locationText, detailsEdit.gpsText, detailsEdit.durationText,
|
||||
detailsEdit.depthText, detailsEdit.airtempText, detailsEdit.watertempText, detailsEdit.suitText,
|
||||
detailsEdit.buddyText, detailsEdit.divemasterText, detailsEdit.notesText);
|
||||
diveDetailsWindow.state = "view";
|
||||
} else {
|
||||
diveDetailsWindow.state = "edit";
|
||||
}
|
||||
diveDetailsWindow.state = checked ? "edit" : "view";
|
||||
contextDrawer.close();
|
||||
// close drawer?
|
||||
}
|
||||
|
|
|
@ -7,7 +7,14 @@ import org.subsurfacedivelog.mobile 1.0
|
|||
import org.kde.plasma.mobilecomponents 0.2 as MobileComponents
|
||||
|
||||
Item {
|
||||
|
||||
property alias locationText: txtLocation.text
|
||||
property string gpsText
|
||||
property alias airtempText: txtAirTemp.text
|
||||
property alias watertempText: txtWaterTemp.text
|
||||
property alias suitText: txtSuit.text
|
||||
property alias buddyText: txtBuddy.text
|
||||
property alias divemasterText: txtDiveMaster.text
|
||||
property alias notesText: txtNotes.text
|
||||
ColumnLayout {
|
||||
anchors {
|
||||
left: parent.left
|
||||
|
@ -36,6 +43,11 @@ Item {
|
|||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
// we should add a checkbox here that allows the user
|
||||
// to add the current location as the dive location
|
||||
// (think of someone adding a dive while on the boat or
|
||||
// at the dive site)
|
||||
|
||||
MobileComponents.Label {
|
||||
Layout.alignment: Qt.AlignRight
|
||||
text: "Air Temp:"
|
||||
|
@ -59,15 +71,11 @@ Item {
|
|||
MobileComponents.Label {
|
||||
Layout.alignment: Qt.AlignRight
|
||||
text: "Suit:"
|
||||
|
||||
}
|
||||
TextField {
|
||||
id: txtSuit
|
||||
text: suit
|
||||
Layout.fillWidth: true
|
||||
onEditingFinished: {
|
||||
suit = text;
|
||||
}
|
||||
}
|
||||
|
||||
MobileComponents.Label {
|
||||
|
@ -78,9 +86,6 @@ Item {
|
|||
id: txtBuddy
|
||||
text: buddy
|
||||
Layout.fillWidth: true
|
||||
onEditingFinished: {
|
||||
buddy = text;
|
||||
}
|
||||
}
|
||||
|
||||
MobileComponents.Label {
|
||||
|
@ -91,9 +96,6 @@ Item {
|
|||
id: txtDiveMaster
|
||||
text: divemaster
|
||||
Layout.fillWidth: true
|
||||
onEditingFinished: {
|
||||
divemaster = text;
|
||||
}
|
||||
}
|
||||
|
||||
MobileComponents.Label {
|
||||
|
@ -109,11 +111,6 @@ Item {
|
|||
Layout.minimumHeight: MobileComponents.Units.gridUnit * 6
|
||||
selectByMouse: true
|
||||
wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere
|
||||
// there is no onEditingFinished signal... not sure how to get the value
|
||||
// out of this field when we're done editing
|
||||
// onEditingFinished: {
|
||||
// diveDetailsWindow.notes = text;
|
||||
// }
|
||||
}
|
||||
}
|
||||
Item {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -71,7 +71,8 @@ public slots:
|
|||
void loadDivesWithValidCredentials();
|
||||
void loadDiveProgress(int percent);
|
||||
void provideAuth(QNetworkReply *reply, QAuthenticator *auth);
|
||||
void commitChanges(QString diveId, QString suit, QString buddy, QString diveMaster, QString notes);
|
||||
void commitChanges(QString diveId, QString location, QString gps, QString duration, QString depth,
|
||||
QString airtemp, QString watertemp, QString suit, QString buddy, QString diveMaster, QString notes);
|
||||
void saveChanges();
|
||||
QString addDive();
|
||||
void applyGpsData();
|
||||
|
|
Loading…
Reference in a new issue