aboutsummaryrefslogtreecommitdiffstats
path: root/mobile-widgets
diff options
context:
space:
mode:
authorGravatar Jocke <j.bygdell@gmail.com>2018-07-16 18:01:56 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-08-11 11:19:07 -0700
commit94428b9a1823fd7df9f2f0f7815900efca2213a4 (patch)
tree995486e8dc3301ed8c0d4808fe856ab9c8fcebff /mobile-widgets
parent6b93e5fe272dd9ee67973c0eec6e3310dcee1b19 (diff)
downloadsubsurface-94428b9a1823fd7df9f2f0f7815900efca2213a4.tar.gz
Mobile: save edited cylinders
Save the edited cylinder in the correct slot. Since the cylinder number and the used cylinder number need not be the same we first need to test if the cylinder are used. Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
Diffstat (limited to 'mobile-widgets')
-rw-r--r--mobile-widgets/qml/DiveDetailsEdit.qml21
-rw-r--r--mobile-widgets/qmlmanager.cpp37
-rw-r--r--mobile-widgets/qmlmanager.h2
3 files changed, 40 insertions, 20 deletions
diff --git a/mobile-widgets/qml/DiveDetailsEdit.qml b/mobile-widgets/qml/DiveDetailsEdit.qml
index 7a05975a5..7de718b82 100644
--- a/mobile-widgets/qml/DiveDetailsEdit.qml
+++ b/mobile-widgets/qml/DiveDetailsEdit.qml
@@ -70,14 +70,30 @@ Item {
function saveData() {
diveDetailsPage.state = "view" // run the transition
+ // join cylinder info from separate string into a list.
+ if (usedCyl[0] != null) {
+ usedCyl[0] = cylinderBox0.currentText
+ }
+ if (usedCyl[1] != null) {
+ usedCyl[1] = cylinderBox1.currentText
+ }
+ if (usedCyl[2] != null) {
+ usedCyl[2] = cylinderBox2.currentText
+ }
+ if (usedCyl[3] != null) {
+ usedCyl[3] = cylinderBox3.currentText
+ }
+ if (usedCyl[4] != null) {
+ usedCyl[4] = cylinderBox4.currentText
+ }
+
// apply the changes to the dive_table
manager.commitChanges(dive_id, detailsEdit.dateText, locationBox.editText, detailsEdit.gpsText, detailsEdit.durationText,
detailsEdit.depthText, detailsEdit.airtempText, detailsEdit.watertempText,
suitBox.currentText != "" ? suitBox.currentText : suitBox.editText, buddyBox.editText,
divemasterBox.currentText != "" ? divemasterBox.currentText : divemasterBox.editText,
detailsEdit.weightText, detailsEdit.notesText, detailsEdit.startpressureText,
- detailsEdit.endpressureText, detailsEdit.gasmixText,
- cylinderBox.currentText != "" ? cylinderBox.currentText : cylinderBox.editText,
+ detailsEdit.endpressureText, detailsEdit.gasmixText, usedCyl ,
detailsEdit.rating,
detailsEdit.visibility)
// trigger the profile to be redrawn
@@ -97,7 +113,6 @@ Item {
diveDetailsListView.currentItem.modelData.suit = suitBox.currentText
diveDetailsListView.currentItem.modelData.buddy = buddyBox.currentText
diveDetailsListView.currentItem.modelData.divemaster = divemasterBox.currentText
- diveDetailsListView.currentItem.modelData.cylinder = cylinderBox.currentText
diveDetailsListView.currentItem.modelData.notes = detailsEdit.notesText
diveDetailsListView.currentItem.modelData.rating = detailsEdit.rating
diveDetailsListView.currentItem.modelData.visibility = detailsEdit.visibility
diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp
index 645ddd152..8bc9026e6 100644
--- a/mobile-widgets/qmlmanager.cpp
+++ b/mobile-widgets/qmlmanager.cpp
@@ -1004,7 +1004,7 @@ bool QMLManager::checkDepth(DiveObjectHelper *myDive, dive *d, QString depth)
// update the dive and return the notes field, stripped of the HTML junk
void QMLManager::commitChanges(QString diveId, QString date, QString location, QString gps, QString duration, QString depth,
QString airtemp, QString watertemp, QString suit, QString buddy, QString diveMaster, QString weight, QString notes,
- QString startpressure, QString endpressure, QString gasmix, QString cylinder, int rating, int visibility)
+ QString startpressure, QString endpressure, QString gasmix, QStringList usedCylinder, int rating, int visibility)
{
struct dive *d = get_dive_by_uniq_id(diveId.toInt());
@@ -1069,26 +1069,31 @@ void QMLManager::commitChanges(QString diveId, QString date, QString location, Q
}
}
// info for first cylinder
- if (myDive->getCylinder() != cylinder) {
+ if (myDive->getCylinder() != usedCylinder) {
diveChanged = true;
unsigned long i;
- int size = 0, wp = 0;
- for (i = 0; i < MAX_TANK_INFO && tank_info[i].name != NULL; i++) {
- if (tank_info[i].name == cylinder ) {
- if (tank_info[i].ml > 0){
- size = tank_info[i].ml;
- wp = tank_info[i].bar * 1000;
- } else {
- size = (int) (cuft_to_l(tank_info[i].cuft) * 1000 / bar_to_atm(psi_to_bar(tank_info[i].psi)));
- wp = psi_to_mbar(tank_info[i].psi);
+ int size = 0, wp = 0, j = 0, k = 0;
+ for (j = 0; k < usedCylinder.length() ; j++) {
+ if (!is_cylinder_used(d, j))
+ continue;
+
+ for (i = 0; i < MAX_TANK_INFO && tank_info[i].name != NULL; i++) {
+ if (tank_info[i].name == usedCylinder[k] ) {
+ if (tank_info[i].ml > 0){
+ size = tank_info[i].ml;
+ wp = tank_info[i].bar * 1000;
+ } else {
+ size = (int) (cuft_to_l(tank_info[i].cuft) * 1000 / bar_to_atm(psi_to_bar(tank_info[i].psi)));
+ wp = psi_to_mbar(tank_info[i].psi);
+ }
+ break;
}
- break;
}
-
+ d->cylinder[j].type.description = copy_qstring(usedCylinder[k]);
+ d->cylinder[j].type.size.mliter = size;
+ d->cylinder[j].type.workingpressure.mbar = wp;
+ k++;
}
- d->cylinder[0].type.description = copy_qstring(cylinder);
- d->cylinder[0].type.size.mliter = size;
- d->cylinder[0].type.workingpressure.mbar = wp;
}
if (myDive->suit() != suit) {
diveChanged = true;
diff --git a/mobile-widgets/qmlmanager.h b/mobile-widgets/qmlmanager.h
index baecfea88..3f8633f22 100644
--- a/mobile-widgets/qmlmanager.h
+++ b/mobile-widgets/qmlmanager.h
@@ -158,7 +158,7 @@ public slots:
QString duration, QString depth, QString airtemp,
QString watertemp, QString suit, QString buddy,
QString diveMaster, QString weight, QString notes, QString startpressure,
- QString endpressure, QString gasmix, QString cylinder, int rating, int visibility);
+ QString endpressure, QString gasmix, QStringList usedCylinder, int rating, int visibility);
void changesNeedSaving();
void openNoCloudRepo();
void saveChangesLocal();