diff options
Diffstat (limited to 'qt-ui')
-rw-r--r-- | qt-ui/diveplanner.cpp | 27 | ||||
-rw-r--r-- | qt-ui/downloadfromdivecomputer.cpp | 5 | ||||
-rw-r--r-- | qt-ui/downloadfromdivecomputer.h | 2 | ||||
-rw-r--r-- | qt-ui/models.cpp | 4 |
4 files changed, 23 insertions, 15 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index 9edaac56a..c26aa9569 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -81,8 +81,8 @@ void DivePlannerPointsModel::loadFromDive(dive *d) CylindersModel::instance()->setDive(stagingDive); int lasttime = 0; // we start with the first gas and see if it was changed - int o2 = backupDive.cylinder[0].gasmix.o2.permille; - int he = backupDive.cylinder[0].gasmix.he.permille; + int o2 = get_o2(&backupDive.cylinder[0].gasmix); + int he = get_he(&backupDive.cylinder[0].gasmix); for (int i = 0; i < backupDive.dc.samples - 1; i++) { const sample &s = backupDive.dc.sample[i]; if (s.time.seconds == 0) @@ -120,7 +120,7 @@ QStringList &DivePlannerPointsModel::getGasList() cylinder_t *cyl = &activeDive->cylinder[i]; if (cylinder_nodata(cyl)) break; - list.push_back(gasToStr(cyl->gasmix.o2.permille, cyl->gasmix.he.permille)); + list.push_back(gasToStr(get_o2(&cyl->gasmix), get_he(&cyl->gasmix))); } } return list; @@ -441,13 +441,13 @@ DivePlannerPointsModel *DivePlannerPointsModel::instance() void DivePlannerPointsModel::setBottomSac(int sac) { - diveplan.bottomsac = sac; + diveplan.bottomsac = sac * 1000; emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, COLUMNS - 1)); } void DivePlannerPointsModel::setDecoSac(int sac) { - diveplan.decosac = sac; + diveplan.decosac = sac * 1000; emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, COLUMNS - 1)); } @@ -488,6 +488,12 @@ bool divePointsLessThan(const divedatapoint &p1, const divedatapoint &p2) bool DivePlannerPointsModel::addGas(int o2, int he) { + struct gasmix mix; + + mix.o2.permille = o2; + mix.he.permille = he; + sanitize_gasmix(&mix); + if (is_air(o2, he)) o2 = 0; @@ -497,6 +503,7 @@ bool DivePlannerPointsModel::addGas(int o2, int he) fill_default_cylinder(cyl); cyl->gasmix.o2.permille = o2; cyl->gasmix.he.permille = he; + sanitize_gasmix(&cyl->gasmix); /* The depth to change to that gas is given by the depth where its pO2 is 1.6 bar. * The user should be able to change this depth manually. */ pressure_t modppO2; @@ -505,7 +512,7 @@ bool DivePlannerPointsModel::addGas(int o2, int he) CylindersModel::instance()->setDive(stagingDive); return true; } - if (cyl->gasmix.o2.permille == o2 && cyl->gasmix.he.permille == he) + if (!gasmix_distance(&cyl->gasmix, &mix)) return true; } qDebug("too many gases"); @@ -540,8 +547,8 @@ int DivePlannerPointsModel::addStop(int milimeters, int seconds, int o2, int he, //Default to the first defined gas, if we got one. cylinder_t *cyl = &stagingDive->cylinder[0]; if (cyl) { - o2 = cyl->gasmix.o2.permille; - he = cyl->gasmix.he.permille; + o2 = get_o2(&cyl->gasmix); + he = get_he(&cyl->gasmix); } } if (o2 != -1) @@ -661,7 +668,7 @@ QVector<QPair<int, int> > DivePlannerPointsModel::collectGases(struct dive *d) for (int i = 0; i < MAX_CYLINDERS; i++) { cylinder_t *cyl = &d->cylinder[i]; if (!cylinder_nodata(cyl)) - l.push_back(qMakePair(cyl->gasmix.o2.permille, cyl->gasmix.he.permille)); + l.push_back(qMakePair(get_o2(&cyl->gasmix), get_he(&cyl->gasmix))); } return l; } @@ -761,7 +768,7 @@ void DivePlannerPointsModel::createTemporaryPlan() for (int i = 0; i < MAX_CYLINDERS; i++) { cylinder_t *cyl = &stagingDive->cylinder[i]; if (cyl->depth.mm) { - dp = create_dp(0, cyl->depth.mm, cyl->gasmix.o2.permille, cyl->gasmix.he.permille, 0); + dp = create_dp(0, cyl->depth.mm, get_o2(&cyl->gasmix), get_he(&cyl->gasmix), 0); if (diveplan.dp) { dp->next = diveplan.dp->next; diveplan.dp->next = dp; diff --git a/qt-ui/downloadfromdivecomputer.cpp b/qt-ui/downloadfromdivecomputer.cpp index 681b0d20c..71f428b14 100644 --- a/qt-ui/downloadfromdivecomputer.cpp +++ b/qt-ui/downloadfromdivecomputer.cpp @@ -72,7 +72,6 @@ DownloadFromDCWidget::DownloadFromDCWidget(QWidget *parent, Qt::WindowFlags f) : if (default_dive_computer_product) ui.product->setCurrentIndex(ui.product->findText(default_dive_computer_product)); } - connect(ui.product, SIGNAL(currentIndexChanged(int)), this, SLOT(on_product_currentIndexChanged()), Qt::UniqueConnection); if (default_dive_computer_device) ui.device->setEditText(default_dive_computer_device); @@ -190,11 +189,11 @@ void DownloadFromDCWidget::on_vendor_currentIndexChanged(const QString &vendor) //currentModel->deleteLater(); } -void DownloadFromDCWidget::on_product_currentIndexChanged() +void DownloadFromDCWidget::on_product_currentIndexChanged(const QString &product) { // Set up the DC descriptor dc_descriptor_t *descriptor = NULL; - descriptor = descriptorLookup[ui.vendor->currentText() + ui.product->currentText()]; + descriptor = descriptorLookup[ui.vendor->currentText() + product]; // call dc_descriptor_get_transport to see if the dc_transport_t is DC_TRANSPORT_SERIAL if (dc_descriptor_get_transport(descriptor) == DC_TRANSPORT_SERIAL) { diff --git a/qt-ui/downloadfromdivecomputer.h b/qt-ui/downloadfromdivecomputer.h index 955322232..3de102bfd 100644 --- a/qt-ui/downloadfromdivecomputer.h +++ b/qt-ui/downloadfromdivecomputer.h @@ -42,7 +42,7 @@ slots: void on_cancel_clicked(); void on_search_clicked(); void on_vendor_currentIndexChanged(const QString &vendor); - void on_product_currentIndexChanged(); + void on_product_currentIndexChanged(const QString &product); void onDownloadThreadFinished(); void updateProgressBar(); diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp index 5efcf5a34..4d9e19190 100644 --- a/qt-ui/models.cpp +++ b/qt-ui/models.cpp @@ -249,7 +249,9 @@ bool CylindersModel::setData(const QModelIndex &index, const QVariant &value, in case O2: if (CHANGED()) { cyl->gasmix.o2 = string_to_fraction(vString.toUtf8().data()); - cyl->depth.mm = 1600 * 1000 / cyl->gasmix.o2.permille * 10 - 10000; + pressure_t modppO2; + modppO2.mbar = 1600; + cyl->depth = gas_mod(&cyl->gasmix, modppO2); changed = true; } break; |