summaryrefslogtreecommitdiffstats
path: root/qt-ui/models.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'qt-ui/models.cpp')
-rw-r--r--qt-ui/models.cpp39
1 files changed, 18 insertions, 21 deletions
diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp
index 68603e735..2bc690eb9 100644
--- a/qt-ui/models.cpp
+++ b/qt-ui/models.cpp
@@ -68,7 +68,7 @@ CylindersModel::CylindersModel(QObject *parent) : current(0), rows(0)
// enum {REMOVE, TYPE, SIZE, WORKINGPRESS, START, END, O2, HE, DEPTH};
setHeaderDataStrings(QStringList() << "" << tr("Type") << tr("Size") << tr("WorkPress") << tr("StartPress") << tr("EndPress") << trUtf8("O" UTF8_SUBSCRIPT_2 "%") << tr("He%")
#ifdef ENABLE_PLANNER
- << tr("Switch at")
+ << tr("Switch at")
#endif
);
}
@@ -253,11 +253,9 @@ bool CylindersModel::setData(const QModelIndex &index, const QVariant &value, in
case O2:
if (CHANGED()) {
cyl->gasmix.o2 = string_to_fraction(vString.toUtf8().data());
- if (!cyl->gasmix.o2.permille) {
- cyl->gasmix.o2.permille = 210;
- cyl->gasmix.he.permille = 0;
- }
- 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;
@@ -368,11 +366,10 @@ void CylindersModel::remove(const QModelIndex &index)
cylinder_t *cyl = &current->cylinder[index.row()];
if ((DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING &&
DivePlannerPointsModel::instance()->tankInUse(cyl->gasmix.o2.permille, cyl->gasmix.he.permille)) ||
- (DivePlannerPointsModel::instance()->currentMode() == DivePlannerPointsModel::NOTHING && cyl->used))
- {
+ (DivePlannerPointsModel::instance()->currentMode() == DivePlannerPointsModel::NOTHING && cyl->used)) {
QMessageBox::warning(MainWindow::instance(), TITLE_OR_TEXT(
- tr("Cylinder cannot be removed"),
- tr("This gas in use. Only cylinders that are not used in the dive can be removed.")),
+ tr("Cylinder cannot be removed"),
+ tr("This gas in use. Only cylinders that are not used in the dive can be removed.")),
QMessageBox::Ok);
return;
}
@@ -1060,7 +1057,7 @@ static int nitrox_sort_value(struct dive *dive)
QVariant DiveItem::data(int column, int role) const
{
QVariant retVal;
- struct dive *dive = get_dive_by_diveid(diveId);
+ struct dive *dive = get_dive_by_uniq_id(diveId);
switch (role) {
case Qt::TextAlignmentRole:
@@ -1203,11 +1200,11 @@ bool DiveItem::setData(const QModelIndex &index, const QVariant &value, int role
int i;
struct dive *d;
- for_each_dive(i, d) {
+ for_each_dive (i, d) {
if (d->number == v)
return false;
}
- d = get_dive_by_diveid(diveId);
+ d = get_dive_by_uniq_id(diveId);
d->number = value.toInt();
mark_divelist_changed(true);
return true;
@@ -1215,7 +1212,7 @@ bool DiveItem::setData(const QModelIndex &index, const QVariant &value, int role
QString DiveItem::displayDate() const
{
- struct dive *dive = get_dive_by_diveid(diveId);
+ struct dive *dive = get_dive_by_uniq_id(diveId);
return get_dive_date_string(dive->when);
}
@@ -1223,7 +1220,7 @@ QString DiveItem::displayDepth() const
{
QString fract, str;
const int scale = 1000;
- struct dive *dive = get_dive_by_diveid(diveId);
+ struct dive *dive = get_dive_by_uniq_id(diveId);
if (get_units()->length == units::METERS) {
fract = QString::number((unsigned)(dive->maxdepth.mm % scale) / 100);
str = QString("%1.%2").arg((unsigned)(dive->maxdepth.mm / scale)).arg(fract, 1, QChar('0'));
@@ -1237,7 +1234,7 @@ QString DiveItem::displayDepth() const
QString DiveItem::displayDuration() const
{
int hrs, mins, secs;
- struct dive *dive = get_dive_by_diveid(diveId);
+ struct dive *dive = get_dive_by_uniq_id(diveId);
secs = dive->duration.seconds % 60;
mins = dive->duration.seconds / 60;
hrs = mins / 60;
@@ -1255,7 +1252,7 @@ QString DiveItem::displayDuration() const
QString DiveItem::displayTemperature() const
{
QString str;
- struct dive *dive = get_dive_by_diveid(diveId);
+ struct dive *dive = get_dive_by_uniq_id(diveId);
if (!dive->watertemp.mkelvin)
return str;
if (get_units()->temperature == units::CELSIUS)
@@ -1268,7 +1265,7 @@ QString DiveItem::displayTemperature() const
QString DiveItem::displaySac() const
{
QString str;
- struct dive *dive = get_dive_by_diveid(diveId);
+ struct dive *dive = get_dive_by_uniq_id(diveId);
if (get_units()->volume == units::LITER)
str = QString::number(dive->sac / 1000.0, 'f', 1).append(tr(" l/min"));
else
@@ -1284,7 +1281,7 @@ QString DiveItem::displayWeight() const
int DiveItem::weight() const
{
- struct dive *dive = get_dive_by_diveid(diveId);
+ struct dive *dive = get_dive_by_uniq_id(diveId);
weight_t tw = { total_weight(dive) };
return tw.grams;
}
@@ -1904,7 +1901,7 @@ QVariant ProfilePrintModel::data(const QModelIndex &index, int role) const
switch (role) {
case Qt::DisplayRole: {
- struct dive *dive = get_dive_by_diveid(diveId);
+ struct dive *dive = get_dive_by_uniq_id(diveId);
struct DiveItem di;
di.diveId = diveId;
@@ -2060,7 +2057,7 @@ LanguageModel::LanguageModel(QObject *parent) : QAbstractListModel(parent)
QSettings s;
QDir d(getSubsurfaceDataPath("translations"));
QStringList result = d.entryList();
- Q_FOREACH(const QString & s, result) {
+ Q_FOREACH (const QString &s, result) {
if (s.startsWith("subsurface_") && s.endsWith(".qm")) {
languages.push_back((s == "subsurface_source.qm") ? "English" : s);
}