Hi,

this set of patches allows the user to set a dive mode (OC, PSCR, CCR, 
Freedive).

OC is what we used to do,

PSCR should use the oxygen drop formula (please test!!!!)

CCR should start the dive with a default set-point (can be set in preferences)

Freedive is not really implemented, yet.

Since we introduced two ways to tell if a dive is CCR in the past (dive 
computer.dctype and the existence of a non-zero set-point), this not only sets 
dctype but also inserts a manual set-point change at time zero (with value 0 
for all non-CCR-modes).

Finally, the element dctype is renamed to a more appropriate divemode in a last 
patch.

I had been working on this since before christmas thus mailing this required an 
extensive rebase (thanks to all you guys coding like mad!), so there is also 
some repair done in the last patch. Sorry about this.

Best
Robert
From 56470c330aad05a3bbc40c3904879a2c0a07cdf6 Mon Sep 17 00:00:00 2001
From: "Robert C. Helling" <[email protected]>
Date: Fri, 26 Dec 2014 15:09:18 +0100
Subject: [PATCH 1/7] Rebreather type selector UI

Signed-off-by: Robert C. Helling <[email protected]>
---
 planner.c                |  2 +-
 qt-ui/diveplanner.cpp    | 16 ++++++++++
 qt-ui/diveplanner.h      |  1 +
 qt-ui/plannerSettings.ui | 82 +++++++++++++++++++++++++++---------------------
 4 files changed, 64 insertions(+), 37 deletions(-)

diff --git a/planner.c b/planner.c
index 27781f6..322bd25 100644
--- a/planner.c
+++ b/planner.c
@@ -251,7 +251,7 @@ static void create_dive_from_plan(struct diveplan 
*diveplan, bool track_gas)
        int oldpo2 = 0;
        int lasttime = 0;
        int lastdepth = 0;
-       enum dive_comp_type type = OC;
+       enum dive_comp_type type = displayed_dive.dc.dctype;
 
        if (!diveplan || !diveplan->dp)
                return;
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp
index 84dec0c..d9aa381 100644
--- a/qt-ui/diveplanner.cpp
+++ b/qt-ui/diveplanner.cpp
@@ -394,6 +394,7 @@ PlannerSettingsWidget::PlannerSettingsWidget(QWidget 
*parent, Qt::WindowFlags f)
        ui.setupUi(this);
 
        QSettings s;
+       QStringList rebreater_modes;
        s.beginGroup("Planner");
        prefs.ascrate75 = s.value("ascrate75", prefs.ascrate75).toInt();
        prefs.ascrate50 = s.value("ascrate50", prefs.ascrate50).toInt();
@@ -415,6 +416,8 @@ PlannerSettingsWidget::PlannerSettingsWidget(QWidget 
*parent, Qt::WindowFlags f)
        ui.decopo2->setValue(prefs.decopo2 / 1000.0);
        ui.backgasBreaks->setChecked(prefs.doo2breaks);
        ui.drop_stone_mode->setChecked(prefs.drop_stone_mode);
+       rebreater_modes << "Open circuit" << "pSCR" << "CCR";
+       ui.rebreathermode->insertItems(0, rebreater_modes);
 
        connect(ui.lastStop, SIGNAL(toggled(bool)), plannerModel, 
SLOT(setLastStop6m(bool)));
        connect(ui.verbatim_plan, SIGNAL(toggled(bool)), plannerModel, 
SLOT(setVerbatim(bool)));
@@ -441,6 +444,7 @@ PlannerSettingsWidget::PlannerSettingsWidget(QWidget 
*parent, Qt::WindowFlags f)
        connect(ui.gfhigh, SIGNAL(editingFinished()), plannerModel, 
SLOT(triggerGFHigh()));
        connect(ui.gflow, SIGNAL(editingFinished()), plannerModel, 
SLOT(triggerGFLow()));
        connect(ui.backgasBreaks, SIGNAL(toggled(bool)), this, 
SLOT(setBackgasBreaks(bool)));
+       connect(ui.rebreathermode, SIGNAL(currentIndexChanged(QString)), 
plannerModel, SLOT(setRebreatherMode(QString)));
        settingsChanged();
        ui.gflow->setValue(prefs.gflow);
        ui.gfhigh->setValue(prefs.gfhigh);
@@ -779,6 +783,18 @@ void DivePlannerPointsModel::setGFLow(const int ghflow)
        triggerGFLow();
 }
 
+void DivePlannerPointsModel::setRebreatherMode(QString mode)
+{
+       qDebug() << mode << "selected, was" << displayed_dive.dc.dctype;
+       if (mode == "OC")
+               displayed_dive.dc.dctype = OC;
+       else if (mode == "pSCR")
+               displayed_dive.dc.dctype = PSCR;
+       else if (mode == "CCR")
+               displayed_dive.dc.dctype = CCR;
+       plannerModel->emitDataChanged();
+}
+
 void DivePlannerPointsModel::triggerGFLow()
 {
        if (diveplan.gflow != tempGFLow) {
diff --git a/qt-ui/diveplanner.h b/qt-ui/diveplanner.h
index bca0deb..6ff4d0f 100644
--- a/qt-ui/diveplanner.h
+++ b/qt-ui/diveplanner.h
@@ -90,6 +90,7 @@ slots:
        void deleteTemporaryPlan();
        void loadFromDive(dive *d);
        void emitDataChanged();
+       void setRebreatherMode(QString mode);
 
 signals:
        void planCreated();
diff --git a/qt-ui/plannerSettings.ui b/qt-ui/plannerSettings.ui
index f99be98..af03fd1 100644
--- a/qt-ui/plannerSettings.ui
+++ b/qt-ui/plannerSettings.ui
@@ -30,8 +30,8 @@
        <rect>
         <x>0</x>
         <y>0</y>
-        <width>1084</width>
-        <height>424</height>
+        <width>1078</width>
+        <height>418</height>
        </rect>
       </property>
       <layout class="QHBoxLayout" name="horizontalLayout">
@@ -262,14 +262,7 @@
           <property name="spacing">
            <number>2</number>
           </property>
-          <item row="0" column="0">
-           <widget class="QLabel" name="label_15">
-            <property name="text">
-             <string>GF low</string>
-            </property>
-           </widget>
-          </item>
-          <item row="0" column="1">
+          <item row="0" column="2">
            <widget class="QSpinBox" name="gflow">
             <property name="suffix">
              <string>%</string>
@@ -282,14 +275,48 @@
             </property>
            </widget>
           </item>
-          <item row="1" column="0">
+          <item row="0" column="1">
+           <widget class="QLabel" name="label_15">
+            <property name="text">
+             <string>GF low</string>
+            </property>
+           </widget>
+          </item>
+          <item row="1" column="1">
            <widget class="QLabel" name="label_16">
             <property name="text">
              <string>GF high</string>
             </property>
            </widget>
           </item>
-          <item row="1" column="1">
+          <item row="4" column="1" colspan="2">
+           <widget class="QCheckBox" name="backgasBreaks">
+            <property name="text">
+             <string>Plan backgas breaks</string>
+            </property>
+           </widget>
+          </item>
+          <item row="6" column="1">
+           <spacer name="verticalSpacer_2">
+            <property name="orientation">
+             <enum>Qt::Vertical</enum>
+            </property>
+            <property name="sizeHint" stdset="0">
+             <size>
+              <width>20</width>
+              <height>40</height>
+             </size>
+            </property>
+           </spacer>
+          </item>
+          <item row="3" column="1" colspan="2">
+           <widget class="QCheckBox" name="lastStop">
+            <property name="text">
+             <string>Last stop at 6m</string>
+            </property>
+           </widget>
+          </item>
+          <item row="1" column="2">
            <widget class="QSpinBox" name="gfhigh">
             <property name="suffix">
              <string>%</string>
@@ -302,40 +329,23 @@
             </property>
            </widget>
           </item>
-          <item row="2" column="0" colspan="2">
+          <item row="2" column="1" colspan="2">
            <widget class="QCheckBox" name="drop_stone_mode">
             <property name="text">
              <string>Drop to first depth</string>
             </property>
            </widget>
           </item>
-          <item row="3" column="0" colspan="2">
-           <widget class="QCheckBox" name="lastStop">
-            <property name="text">
-             <string>Last stop at 6m</string>
+          <item row="5" column="1">
+           <widget class="QComboBox" name="rebreathermode">
+            <property name="currentText">
+             <string/>
             </property>
-           </widget>
-          </item>
-          <item row="4" column="0" colspan="2">
-           <widget class="QCheckBox" name="backgasBreaks">
-            <property name="text">
-             <string>Plan backgas breaks</string>
+            <property name="maxVisibleItems">
+             <number>6</number>
             </property>
            </widget>
           </item>
-          <item row="5" column="0">
-           <spacer name="verticalSpacer_2">
-            <property name="orientation">
-             <enum>Qt::Vertical</enum>
-            </property>
-            <property name="sizeHint" stdset="0">
-             <size>
-              <width>20</width>
-              <height>40</height>
-             </size>
-            </property>
-           </spacer>
-          </item>
          </layout>
         </widget>
        </item>
-- 
1.9.3 (Apple Git-50)

From 6a6369d9aa3c382107786c6de2162d712caf3d49 Mon Sep 17 00:00:00 2001
From: "Robert C. Helling" <[email protected]>
Date: Tue, 30 Dec 2014 23:28:55 +0100
Subject: [PATCH 2/7] Prepare for PSCR calculations

Calculations for passive semi-closed rebreathers are pretty much like OC except
the pO2 is lower bey a certain (SAC dependent) factor. This patch introduces the
corresponding calculations in case dctype == PSCR which is so far never set and
there is currently no UI for these calculations. As pO2 is SAC dependent it 
takes
a certain attempt at getting it and drops to defaults from the prefs otherwise.

Signed-off-by: Robert C. Helling <[email protected]>
---
 dive.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/dive.c b/dive.c
index 711392c..17b67a5 100644
--- a/dive.c
+++ b/dive.c
@@ -1663,10 +1663,17 @@ extern void fill_pressures(struct gas_pressures 
*pressures, const double amb_pre
                                pressures->n2 = amb_pressure - pressures->o2 - 
pressures->he;
                        }
                }
-       } else {        // Open circuit dives: no gas pressure values 
available, they need to be calculated
+       } else {
+               if (dctype == PSCR) { /* The steady state approximation should 
be good enough */
+                       pressures->o2 = get_o2(mix) / 1000.0 * amb_pressure - 
(1.0 - get_o2(mix) / 1000.0) * prefs.o2consumption / (sac * prefs.pscr_ratio / 
1000.0);
+                       pressures->he = (amb_pressure - pressures->o2) * 
get_he(mix) / (1000.0 - get_o2(mix));
+                       pressures->n2 = (amb_pressure - pressures->o2) * (1000 
- get_o2(mix) - get_he(mix)) / (1000.0 - get_o2(mix));
+               } else {
+               // Open circuit dives: no gas pressure values available, they 
need to be calculated
                pressures->o2 = get_o2(mix) / 1000.0 * amb_pressure; // These 
calculations are also used if the CCR calculation above..
                pressures->he = get_he(mix) / 1000.0 * amb_pressure; // 
..returned a po2 of zero (i.e. o2 sensor data not resolvable)
                pressures->n2 = (1000 - get_o2(mix) - get_he(mix)) / 1000.0 * 
amb_pressure;
+               }
        }
 }
 
-- 
1.9.3 (Apple Git-50)

From a0ebb1938054c31f89148a40d4080aef16bb6e56 Mon Sep 17 00:00:00 2001
From: "Robert C. Helling" <[email protected]>
Date: Thu, 1 Jan 2015 17:00:46 +0100
Subject: [PATCH 3/7] Maintab combobox to set dive type

still needs some work

Signed-off-by: Robert C. Helling <[email protected]>
---
 dive.c                | 22 +++++++++++++++++++++-
 dive.h                |  3 ++-
 pref.h                |  1 +
 qt-ui/maintab.cpp     | 23 +++++++++++++++++++++++
 qt-ui/maintab.h       |  1 +
 qt-ui/maintab.ui      | 35 ++++++++++++++++++++++-------------
 qt-ui/preferences.cpp |  1 +
 subsurfacestartup.c   |  1 +
 8 files changed, 72 insertions(+), 15 deletions(-)

diff --git a/dive.c b/dive.c
index 17b67a5..680ceeb 100644
--- a/dive.c
+++ b/dive.c
@@ -29,7 +29,7 @@ static const char *default_tags[] = {
 const char *cylinderuse_text[] = {
        QT_TRANSLATE_NOOP("gettextFromC", "OC-gas"), 
QT_TRANSLATE_NOOP("gettextFromC", "diluent"), QT_TRANSLATE_NOOP("gettextFromC", 
"oxygen")
 };
-const char *dctype_text[] = { "OC", "CCR", "PSCR" };
+const char *dctype_text[] = { "OC", "CCR", "PSCR", "Freedive" };
 
 int event_is_gaschange(struct event *ev)
 {
@@ -872,6 +872,26 @@ int explicit_first_cylinder(struct dive *dive, struct 
divecomputer *dc)
                return 0;
 }
 
+void update_setpoint_events(struct divecomputer *dc)
+{
+       struct event *ev = get_next_event(dc->events, "SP change");
+       bool changed = false;
+       int new_setpoint = 0;
+
+       if (dc->dctype == CCR)
+           new_setpoint = prefs.defaultsetpoint;
+
+       while (ev) {
+               if (ev->time.seconds == 0) {
+                       ev->value = new_setpoint;
+                       changed = true;
+               }
+               ev = get_next_event(ev->next, "SP change");
+       }
+       if (!changed)
+               add_event(dc, 0, SAMPLE_EVENT_PO2, 0, new_setpoint, "SP 
change");
+}
+
 void sanitize_gasmix(struct gasmix *mix)
 {
        unsigned int o2, he;
diff --git a/dive.h b/dive.h
index d99f900..bcae405 100644
--- a/dive.h
+++ b/dive.h
@@ -47,7 +47,7 @@ extern "C" {
 #include <stdbool.h>
 #endif
 
-enum dive_comp_type {OC, CCR, PSCR, NUM_DC_TYPE};      // Flags (Open-circuit 
and Closed-circuit-rebreather) for setting dive computer type
+enum dive_comp_type {OC, CCR, PSCR, FREEDIVE, NUM_DC_TYPE};    // Flags 
(Open-circuit and Closed-circuit-rebreather) for setting dive computer type
 enum cylinderuse {OC_GAS, DILUENT, OXYGEN, NUM_GAS_USE}; // The different uses 
for cylinders
 
 extern const char *cylinderuse_text[];
@@ -850,6 +850,7 @@ extern void set_save_userid_local(short value);
 extern void set_userid(char *user_id);
 
 extern const char *get_dive_date_c_string(timestamp_t when);
+extern void update_setpoint_events(struct divecomputer *dc);
 #ifdef __cplusplus
 }
 #endif
diff --git a/pref.h b/pref.h
index 49e1afa..8a8802c 100644
--- a/pref.h
+++ b/pref.h
@@ -76,6 +76,7 @@ struct preferences {
        int decosac;
        int o2consumption; // ml per min
        int pscr_ratio; // dump ratio times 1000
+       int defaultsetpoint; // default setpoint in mbar
        bool show_pictures_in_profile;
        bool use_default_file;
        facebook_prefs_t facebook;
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp
index e6e530d..1a25f19 100644
--- a/qt-ui/maintab.cpp
+++ b/qt-ui/maintab.cpp
@@ -86,6 +86,7 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
        ui.dateEdit->installEventFilter(this);
        ui.timeEdit->installEventFilter(this);
        ui.tagWidget->installEventFilter(this);
+       ui.DiveType->installEventFilter(this);
 
        Q_FOREACH (QObject *obj, ui.statisticsTab->children()) {
                QLabel *label = qobject_cast<QLabel *>(obj);
@@ -100,6 +101,10 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
        ui.weights->setBtnToolTip(tr("Add weight system"));
        connect(ui.weights, SIGNAL(addButtonClicked()), this, 
SLOT(addWeight_clicked()));
 
+       // This needs to be the same order as enum dive_comp_type in dive.h!
+       ui.DiveType->insertItems(0, QStringList() << "OC" << "CCR" << "pSCR" << 
"Freedive");
+       connect(ui.DiveType, SIGNAL(currentIndexChanged(int)), this, 
SLOT(on_divetype_Changed(int)));
+
        connect(ui.cylinders->view(), SIGNAL(clicked(QModelIndex)), this, 
SLOT(editCylinderWidget(QModelIndex)));
        connect(ui.weights->view(), SIGNAL(clicked(QModelIndex)), this, 
SLOT(editWeightWidget(QModelIndex)));
 
@@ -425,6 +430,7 @@ void MainTab::updateDiveInfo(bool clear)
        UPDATE_TEXT(displayed_dive, buddy);
        UPDATE_TEMP(displayed_dive, airtemp);
        UPDATE_TEMP(displayed_dive, watertemp);
+       ui.DiveType->setCurrentIndex(displayed_dive.dc.dctype);
 
        if (!clear) {
                updateGpsCoordinates(&displayed_dive);
@@ -454,6 +460,8 @@ void MainTab::updateDiveInfo(bool clear)
                        ui.TagLabel->setVisible(false);
                        ui.airTempLabel->setVisible(false);
                        ui.airtemp->setVisible(false);
+                       ui.DiveType->setVisible(false);
+                       ui.TypeLabel->setVisible(false);
                        ui.waterTempLabel->setVisible(false);
                        ui.watertemp->setVisible(false);
                        // rename the remaining fields and fill data from 
selected trip
@@ -483,6 +491,8 @@ void MainTab::updateDiveInfo(bool clear)
                        ui.tagWidget->setVisible(true);
                        ui.airTempLabel->setVisible(true);
                        ui.airtemp->setVisible(true);
+                       ui.TypeLabel->setVisible(true);
+                       ui.DiveType->setVisible(true);
                        ui.waterTempLabel->setVisible(true);
                        ui.watertemp->setVisible(true);
                        /* and fill them from the dive */
@@ -504,6 +514,7 @@ void MainTab::updateDiveInfo(bool clear)
                ui.otuText->setText(QString("%1").arg(displayed_dive.otu));
                
ui.waterTemperatureText->setText(get_temperature_string(displayed_dive.watertemp,
 true));
                
ui.airTemperatureText->setText(get_temperature_string(displayed_dive.airtemp, 
true));
+               ui.DiveType->setCurrentIndex(current_dc->dctype);
                volume_t gases[MAX_CYLINDERS] = {};
                get_gas_used(&displayed_dive, gases);
                QString volumes;
@@ -761,6 +772,8 @@ void MainTab::acceptChanges()
                        MODIFY_SELECTED_DIVES(EDIT_VALUE(visibility));
                if (displayed_dive.airtemp.mkelvin != cd->airtemp.mkelvin)
                        MODIFY_SELECTED_DIVES(EDIT_VALUE(airtemp.mkelvin));
+               if (displayed_dive.dc.dctype != cd->dc.dctype)
+                       MODIFY_SELECTED_DIVES(EDIT_VALUE(dc.dctype));
                if (displayed_dive.watertemp.mkelvin != cd->watertemp.mkelvin)
                        MODIFY_SELECTED_DIVES(EDIT_VALUE(watertemp.mkelvin));
                if (displayed_dive.when != cd->when) {
@@ -887,6 +900,7 @@ void MainTab::resetPallete()
        ui.divemaster->setPalette(p);
        ui.suit->setPalette(p);
        ui.airtemp->setPalette(p);
+       ui.DiveType->setPalette(p);
        ui.watertemp->setPalette(p);
        ui.dateEdit->setPalette(p);
        ui.timeEdit->setPalette(p);
@@ -998,6 +1012,15 @@ void MainTab::on_airtemp_textChanged(const QString &text)
        validate_temp_field(ui.airtemp, text);
 }
 
+void MainTab::on_divetype_Changed(const int &index)
+{
+       if (editMode == IGNORE)
+               return;
+       displayed_dive.dc.dctype = (enum dive_comp_type) index;
+       update_setpoint_events(&displayed_dive.dc);
+       markChangedWidget(ui.DiveType);
+}
+
 void MainTab::on_watertemp_textChanged(const QString &text)
 {
        if (editMode == IGNORE || acceptingEdit == true)
diff --git a/qt-ui/maintab.h b/qt-ui/maintab.h
index 668ed02..8b98119 100644
--- a/qt-ui/maintab.h
+++ b/qt-ui/maintab.h
@@ -71,6 +71,7 @@ slots:
        void on_suit_textChanged(const QString &text);
        void on_notes_textChanged();
        void on_airtemp_textChanged(const QString &text);
+       void on_divetype_Changed(const int &index);
        void on_watertemp_textChanged(const QString &text);
        void validate_temp_field(QLineEdit *tempField, const QString &text);
        void on_dateEdit_dateChanged(const QDate &date);
diff --git a/qt-ui/maintab.ui b/qt-ui/maintab.ui
index ac0f1a7..226442f 100644
--- a/qt-ui/maintab.ui
+++ b/qt-ui/maintab.ui
@@ -175,28 +175,28 @@
            <number>0</number>
           </property>
           <item>
-           <widget class="QLabel" name="RatingLabel">
+           <widget class="StarWidget" name="rating" native="true">
             <property name="sizePolicy">
              <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
               <horstretch>0</horstretch>
               <verstretch>0</verstretch>
              </sizepolicy>
             </property>
-            <property name="text">
-             <string>Rating</string>
+            <property name="focusPolicy">
+             <enum>Qt::StrongFocus</enum>
             </property>
            </widget>
           </item>
           <item>
-           <widget class="QLabel" name="visibilityLabel">
+           <widget class="StarWidget" name="visibility" native="true">
             <property name="sizePolicy">
              <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
               <horstretch>0</horstretch>
               <verstretch>0</verstretch>
              </sizepolicy>
             </property>
-            <property name="text">
-             <string>Visibility</string>
+            <property name="focusPolicy">
+             <enum>Qt::StrongFocus</enum>
             </property>
            </widget>
           </item>
@@ -236,28 +236,28 @@
            <number>0</number>
           </property>
           <item>
-           <widget class="StarWidget" name="rating" native="true">
+           <widget class="QLabel" name="RatingLabel">
             <property name="sizePolicy">
              <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
               <horstretch>0</horstretch>
               <verstretch>0</verstretch>
              </sizepolicy>
             </property>
-            <property name="focusPolicy">
-             <enum>Qt::StrongFocus</enum>
+            <property name="text">
+             <string>Rating</string>
             </property>
            </widget>
           </item>
           <item>
-           <widget class="StarWidget" name="visibility" native="true">
+           <widget class="QLabel" name="visibilityLabel">
             <property name="sizePolicy">
              <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
               <horstretch>0</horstretch>
               <verstretch>0</verstretch>
              </sizepolicy>
             </property>
-            <property name="focusPolicy">
-             <enum>Qt::StrongFocus</enum>
+            <property name="text">
+             <string>Visibility</string>
             </property>
            </widget>
           </item>
@@ -301,6 +301,16 @@
            <bool>false</bool>
           </property>
          </widget>
+          <item>
+           <widget class="QComboBox" name="DiveType">
+            <property name="sizePolicy">
+             <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+              <horstretch>0</horstretch>
+              <verstretch>0</verstretch>
+             </sizepolicy>
+            </property>
+           </widget>
+          </item>
         </item>
         <item row="13" column="0" colspan="3">
          <layout class="QHBoxLayout" name="notesAndSocialNetworksLayout">
@@ -1019,7 +1029,6 @@
   <tabstop>airtemp</tabstop>
   <tabstop>watertemp</tabstop>
   <tabstop>location</tabstop>
-  <tabstop>coordinates</tabstop>
   <tabstop>divemaster</tabstop>
   <tabstop>buddy</tabstop>
   <tabstop>rating</tabstop>
diff --git a/qt-ui/preferences.cpp b/qt-ui/preferences.cpp
index 80bd3e4..32237ae 100644
--- a/qt-ui/preferences.cpp
+++ b/qt-ui/preferences.cpp
@@ -367,6 +367,7 @@ void PreferencesDialog::loadSettings()
        GET_BOOL("show_sac", show_sac);
        GET_BOOL("display_unused_tanks", display_unused_tanks);
        GET_BOOL("show_average_depth", show_average_depth);
+       GET_INT("default_setpoint", defaultsetpoint);
        s.endGroup();
 
        s.beginGroup("GeneralSettings");
diff --git a/subsurfacestartup.c b/subsurfacestartup.c
index 1e3a2c1..c673813 100644
--- a/subsurfacestartup.c
+++ b/subsurfacestartup.c
@@ -55,6 +55,7 @@ struct preferences default_prefs = {
                .album_id = NULL,
                .access_token = NULL
        }
+       .defaultsetpoint = 1100
 };
 
 int run_survey;
-- 
1.9.3 (Apple Git-50)

From 492f794897128d61082e40e419c7a25214de7198 Mon Sep 17 00:00:00 2001
From: "Robert C. Helling" <[email protected]>
Date: Thu, 8 Jan 2015 14:42:07 +0100
Subject: [PATCH 4/7] Add setpoint events according to divetype

When changing to a CCR dive, add a setpoint change to the default setpoint
at the beginning of the dive. Otherwise add an explicit setpoint change to 0
.
Signed-off-by: Robert C. Helling <[email protected]>
---
 dive.c            | 6 ++++--
 qt-ui/maintab.cpp | 9 ++++++---
 qt-ui/maintab.h   | 2 +-
 3 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/dive.c b/dive.c
index 680ceeb..c464e7e 100644
--- a/dive.c
+++ b/dive.c
@@ -888,8 +888,10 @@ void update_setpoint_events(struct divecomputer *dc)
                }
                ev = get_next_event(ev->next, "SP change");
        }
-       if (!changed)
-               add_event(dc, 0, SAMPLE_EVENT_PO2, 0, new_setpoint, "SP 
change");
+       if (!changed) {
+               if (!add_event(dc, 0, SAMPLE_EVENT_PO2, 0, new_setpoint, "SP 
change"))
+                       printf("Could not add setpoint change event\n");
+       }
 }
 
 void sanitize_gasmix(struct gasmix *mix)
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp
index 1a25f19..2c92447 100644
--- a/qt-ui/maintab.cpp
+++ b/qt-ui/maintab.cpp
@@ -103,7 +103,7 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
 
        // This needs to be the same order as enum dive_comp_type in dive.h!
        ui.DiveType->insertItems(0, QStringList() << "OC" << "CCR" << "pSCR" << 
"Freedive");
-       connect(ui.DiveType, SIGNAL(currentIndexChanged(int)), this, 
SLOT(on_divetype_Changed(int)));
+       connect(ui.DiveType, SIGNAL(currentIndexChanged(int)), this, 
SLOT(divetype_Changed(int)));
 
        connect(ui.cylinders->view(), SIGNAL(clicked(QModelIndex)), this, 
SLOT(editCylinderWidget(QModelIndex)));
        connect(ui.weights->view(), SIGNAL(clicked(QModelIndex)), this, 
SLOT(editWeightWidget(QModelIndex)));
@@ -772,8 +772,10 @@ void MainTab::acceptChanges()
                        MODIFY_SELECTED_DIVES(EDIT_VALUE(visibility));
                if (displayed_dive.airtemp.mkelvin != cd->airtemp.mkelvin)
                        MODIFY_SELECTED_DIVES(EDIT_VALUE(airtemp.mkelvin));
-               if (displayed_dive.dc.dctype != cd->dc.dctype)
+               if (displayed_dive.dc.dctype != cd->dc.dctype) {
                        MODIFY_SELECTED_DIVES(EDIT_VALUE(dc.dctype));
+                       
MODIFY_SELECTED_DIVES(update_setpoint_events(&mydive->dc));
+               }
                if (displayed_dive.watertemp.mkelvin != cd->watertemp.mkelvin)
                        MODIFY_SELECTED_DIVES(EDIT_VALUE(watertemp.mkelvin));
                if (displayed_dive.when != cd->when) {
@@ -1012,10 +1014,11 @@ void MainTab::on_airtemp_textChanged(const QString 
&text)
        validate_temp_field(ui.airtemp, text);
 }
 
-void MainTab::on_divetype_Changed(const int &index)
+void MainTab::divetype_Changed(int index)
 {
        if (editMode == IGNORE)
                return;
+       qDebug() << "Changing divetype to " << dctype_text[index];
        displayed_dive.dc.dctype = (enum dive_comp_type) index;
        update_setpoint_events(&displayed_dive.dc);
        markChangedWidget(ui.DiveType);
diff --git a/qt-ui/maintab.h b/qt-ui/maintab.h
index 8b98119..2f7277b 100644
--- a/qt-ui/maintab.h
+++ b/qt-ui/maintab.h
@@ -71,7 +71,7 @@ slots:
        void on_suit_textChanged(const QString &text);
        void on_notes_textChanged();
        void on_airtemp_textChanged(const QString &text);
-       void on_divetype_Changed(const int &index);
+       void divetype_Changed(int);
        void on_watertemp_textChanged(const QString &text);
        void validate_temp_field(QLineEdit *tempField, const QString &text);
        void on_dateEdit_dateChanged(const QDate &date);
-- 
1.9.3 (Apple Git-50)

From 6d0c0ad5ac5fb92da5f84895c6ad4386945eaf30 Mon Sep 17 00:00:00 2001
From: "Robert C. Helling" <[email protected]>
Date: Sat, 10 Jan 2015 23:32:36 +0100
Subject: [PATCH 5/7] Add preferences field for default set-point

Signed-off-by: Robert C. Helling <[email protected]>
---
 qt-ui/preferences.cpp |  7 ++++++-
 qt-ui/preferences.ui  | 29 ++++++++++++++++++++++++++---
 2 files changed, 32 insertions(+), 4 deletions(-)

diff --git a/qt-ui/preferences.cpp b/qt-ui/preferences.cpp
index 32237ae..7e71865 100644
--- a/qt-ui/preferences.cpp
+++ b/qt-ui/preferences.cpp
@@ -1,6 +1,7 @@
 #include "preferences.h"
 #include "mainwindow.h"
 #include <QSettings>
+#include <QDebug>
 #include <QFileDialog>
 #include <QMessageBox>
 #include <QShortcut>
@@ -42,6 +43,7 @@ PreferencesDialog::PreferencesDialog(QWidget *parent, 
Qt::WindowFlags f) : QDial
        connect(ui.buttonBox, SIGNAL(clicked(QAbstractButton *)), this, 
SLOT(buttonClicked(QAbstractButton *)));
        connect(ui.gflow, SIGNAL(valueChanged(int)), this, 
SLOT(gflowChanged(int)));
        connect(ui.gfhigh, SIGNAL(valueChanged(int)), this, 
SLOT(gfhighChanged(int)));
+//     connect(ui.defaultSetpoint, SIGNAL(valueChanged(double)), this, 
SLOT(defaultSetpointChanged(double)));
        QShortcut *close = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_W), 
this);
        connect(close, SIGNAL(activated()), this, SLOT(close()));
        QShortcut *quit = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q), 
this);
@@ -96,6 +98,7 @@ void PreferencesDialog::setUiFromPrefs()
        ui.gfhigh->setValue(prefs.gfhigh);
        ui.gf_low_at_maxdepth->setChecked(prefs.gf_low_at_maxdepth);
        ui.show_ccr_setpoint->setChecked(prefs.show_ccr_setpoint);
+       ui.defaultSetpoint->setValue((double)prefs.defaultsetpoint / 1000.0);
 
        // units
        if (prefs.unit_system == METRIC)
@@ -270,6 +273,7 @@ void PreferencesDialog::syncSettings()
        s.setValue("default_filename", ui.defaultfilename->text());
        s.setValue("default_cylinder", ui.default_cylinder->currentText());
        s.setValue("use_default_file", ui.btnUseDefaultFile->isChecked());
+       s.setValue("defaultsetpoint", (int) (ui.defaultSetpoint->value() * 
1000.0));
        s.endGroup();
 
        s.beginGroup("Display");
@@ -312,7 +316,7 @@ void PreferencesDialog::syncSettings()
 
 void PreferencesDialog::loadSettings()
 {
-       // This code was on the mainwindow, it should belong nowhere, but since 
we dind't
+       // This code was on the mainwindow, it should belong nowhere, but since 
we didn't
        // correctly fixed this code yet ( too much stuff on the code calling 
preferences )
        // force this here.
 
@@ -374,6 +378,7 @@ void PreferencesDialog::loadSettings()
        GET_TXT("default_filename", default_filename);
        GET_TXT("default_cylinder", default_cylinder);
        GET_BOOL("use_default_file", use_default_file);
+       GET_INT("defaultsetpoint", defaultsetpoint);
        s.endGroup();
 
        s.beginGroup("Display");
diff --git a/qt-ui/preferences.ui b/qt-ui/preferences.ui
index b716efa..65075b0 100644
--- a/qt-ui/preferences.ui
+++ b/qt-ui/preferences.ui
@@ -151,7 +151,7 @@
         </sizepolicy>
        </property>
        <property name="currentIndex">
-        <number>5</number>
+        <number>2</number>
        </property>
        <widget class="QWidget" name="page_2">
         <layout class="QVBoxLayout" name="verticalLayout_3">
@@ -782,7 +782,7 @@
               </property>
              </widget>
             </item>
-            <item row="2" column="0" colspan="2">
+            <item row="3" column="0" colspan="2">
              <widget class="QCheckBox" name="gf_low_at_maxdepth">
               <property name="text">
                <string>GFLow at max depth</string>
@@ -796,6 +796,29 @@
               </property>
              </widget>
             </item>
+            <item row="4" column="0">
+             <widget class="QLabel" name="label_26">
+              <property name="text">
+               <string>Default CCR set-point</string>
+              </property>
+             </widget>
+            </item>
+            <item row="4" column="1">
+             <widget class="QDoubleSpinBox" name="defaultSetpoint">
+              <property name="suffix">
+               <string>bar</string>
+              </property>
+              <property name="decimals">
+               <number>2</number>
+              </property>
+              <property name="maximum">
+               <double>10.000000000000000</double>
+              </property>
+              <property name="singleStep">
+               <double>0.100000000000000</double>
+              </property>
+             </widget>
+            </item>
            </layout>
           </widget>
          </item>
@@ -1394,7 +1417,7 @@
   <buttongroup name="buttonGroup_3"/>
   <buttongroup name="buttonGroup_4"/>
   <buttongroup name="buttonGroup_5"/>
-  <buttongroup name="buttonGroup_6"/>
   <buttongroup name="buttonGroup"/>
+  <buttongroup name="buttonGroup_6"/>
  </buttongroups>
 </ui>
-- 
1.9.3 (Apple Git-50)

From 113bf550a91e44b5261388f9f8c4dc3acd05a3d7 Mon Sep 17 00:00:00 2001
From: "Robert C. Helling" <[email protected]>
Date: Sat, 10 Jan 2015 23:42:21 +0100
Subject: [PATCH 6/7] Replot after changing divetype

Signed-off-by: Robert C. Helling <[email protected]>
---
 qt-ui/maintab.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp
index 2c92447..3e49086 100644
--- a/qt-ui/maintab.cpp
+++ b/qt-ui/maintab.cpp
@@ -775,6 +775,7 @@ void MainTab::acceptChanges()
                if (displayed_dive.dc.dctype != cd->dc.dctype) {
                        MODIFY_SELECTED_DIVES(EDIT_VALUE(dc.dctype));
                        
MODIFY_SELECTED_DIVES(update_setpoint_events(&mydive->dc));
+                       do_replot = true;
                }
                if (displayed_dive.watertemp.mkelvin != cd->watertemp.mkelvin)
                        MODIFY_SELECTED_DIVES(EDIT_VALUE(watertemp.mkelvin));
@@ -1018,7 +1019,6 @@ void MainTab::divetype_Changed(int index)
 {
        if (editMode == IGNORE)
                return;
-       qDebug() << "Changing divetype to " << dctype_text[index];
        displayed_dive.dc.dctype = (enum dive_comp_type) index;
        update_setpoint_events(&displayed_dive.dc);
        markChangedWidget(ui.DiveType);
-- 
1.9.3 (Apple Git-50)

From cc71c102e4f5fde7e4f8fc22b0080269186ee986 Mon Sep 17 00:00:00 2001
From: "Robert C. Helling" <[email protected]>
Date: Sun, 11 Jan 2015 00:01:15 +0100
Subject: [PATCH 7/7] Refactor dctype -> divemode

... and repair a failed rebase (sorry).

Signed-off-by: Robert C. Helling <[email protected]>
---
 dive.c                            |  14 +--
 dive.h                            |   4 +-
 file.c                            |   2 +-
 libdivecomputer.c                 |   4 +-
 load-git.c                        |   4 +-
 parse-xml.c                       |  24 +++---
 planner.c                         |   6 +-
 profile.c                         |  11 +--
 qt-ui/diveplanner.cpp             |   8 +-
 qt-ui/maintab.cpp                 |  12 +--
 qt-ui/maintab.ui                  | 177 +++++++++++++++++++++-----------------
 qt-ui/preferences.ui              |  34 ++++----
 qt-ui/profile/diveprofileitem.cpp |   6 +-
 qt-ui/profile/profilewidget2.cpp  |   4 +-
 save-git.c                        |   4 +-
 save-xml.c                        |   6 +-
 statistics.c                      |   2 +-
 subsurfacestartup.c               |   2 +-
 18 files changed, 172 insertions(+), 152 deletions(-)

diff --git a/dive.c b/dive.c
index c464e7e..33e3fb2 100644
--- a/dive.c
+++ b/dive.c
@@ -29,7 +29,7 @@ static const char *default_tags[] = {
 const char *cylinderuse_text[] = {
        QT_TRANSLATE_NOOP("gettextFromC", "OC-gas"), 
QT_TRANSLATE_NOOP("gettextFromC", "diluent"), QT_TRANSLATE_NOOP("gettextFromC", 
"oxygen")
 };
-const char *dctype_text[] = { "OC", "CCR", "PSCR", "Freedive" };
+const char *divemode_text[] = { "OC", "CCR", "PSCR", "Freedive" };
 
 int event_is_gaschange(struct event *ev)
 {
@@ -736,7 +736,7 @@ void per_cylinder_mean_depth(struct dive *dive, struct 
divecomputer *dc, int *me
                mean[explicit_first_cylinder(dive, dc)] = dc->meandepth.mm;
                duration[explicit_first_cylinder(dive, dc)] = 
dc->duration.seconds;
 
-               if (dc->dctype == CCR) {
+               if (dc->divemode == CCR) {
                        // Do the same for the  O2 cylinder
                        int o2_cyl = get_cylinder_idx_by_use(dive, OXYGEN);
                        if (o2_cyl < 0)
@@ -866,7 +866,7 @@ int explicit_first_cylinder(struct dive *dive, struct 
divecomputer *dc)
        struct event *ev = get_next_event(dc->events, "gaschange");
        if (ev && dc && dc->sample && ev->time.seconds == 
dc->sample[0].time.seconds)
                return get_cylinder_index(dive, ev);
-       else if (dc->dctype == CCR)
+       else if (dc->divemode == CCR)
                return MAX(get_cylinder_idx_by_use(dive, DILUENT), 0);
        else
                return 0;
@@ -878,7 +878,7 @@ void update_setpoint_events(struct divecomputer *dc)
        bool changed = false;
        int new_setpoint = 0;
 
-       if (dc->dctype == CCR)
+       if (dc->divemode == CCR)
            new_setpoint = prefs.defaultsetpoint;
 
        while (ev) {
@@ -1271,7 +1271,7 @@ static void fixup_dive_dc(struct dive *dive, struct 
divecomputer *dc)
                }
 
                fixup_pressure(dive, sample, OC_GAS);
-               if (dive->dc.dctype == CCR)
+               if (dive->dc.divemode == CCR)
                        fixup_pressure(dive, sample, OXYGEN);
 
                if (temp) {
@@ -1665,7 +1665,7 @@ int gasmix_distance(const struct gasmix *a, const struct 
gasmix *b)
  *                     *mix = structure containing cylinder gas mixture 
information.
  * This function called by: calculate_gas_information_new() in profile.c; 
add_segment() in deco.c.
  */
-extern void fill_pressures(struct gas_pressures *pressures, const double 
amb_pressure, const struct gasmix *mix, double po2, enum dive_comp_type dctype, 
int sac)
+extern void fill_pressures(struct gas_pressures *pressures, const double 
amb_pressure, const struct gasmix *mix, double po2, enum dive_comp_type 
divemode, int sac)
 {
        if (!sac) {
                /* The SAC has not yet been computer, so use the default *
@@ -1686,7 +1686,7 @@ extern void fill_pressures(struct gas_pressures 
*pressures, const double amb_pre
                        }
                }
        } else {
-               if (dctype == PSCR) { /* The steady state approximation should 
be good enough */
+               if (divemode == PSCR) { /* The steady state approximation 
should be good enough */
                        pressures->o2 = get_o2(mix) / 1000.0 * amb_pressure - 
(1.0 - get_o2(mix) / 1000.0) * prefs.o2consumption / (sac * prefs.pscr_ratio / 
1000.0);
                        pressures->he = (amb_pressure - pressures->o2) * 
get_he(mix) / (1000.0 - get_o2(mix));
                        pressures->n2 = (amb_pressure - pressures->o2) * (1000 
- get_o2(mix) - get_he(mix)) / (1000.0 - get_o2(mix));
diff --git a/dive.h b/dive.h
index bcae405..46b3d39 100644
--- a/dive.h
+++ b/dive.h
@@ -51,7 +51,7 @@ enum dive_comp_type {OC, CCR, PSCR, FREEDIVE, NUM_DC_TYPE};   
// Flags (Open-circu
 enum cylinderuse {OC_GAS, DILUENT, OXYGEN, NUM_GAS_USE}; // The different uses 
for cylinders
 
 extern const char *cylinderuse_text[];
-extern const char *dctype_text[];
+extern const char *divemode_text[];
 
 struct gasmix {
        fraction_t o2;
@@ -267,7 +267,7 @@ struct divecomputer {
        depth_t maxdepth, meandepth;
        temperature_t airtemp, watertemp;
        pressure_t surface_pressure;
-       enum dive_comp_type dctype;     // dive computer type: OC(default) or 
CCR
+       enum dive_comp_type divemode;   // dive computer type: OC(default) or 
CCR
        uint8_t no_o2sensors;           // rebreathers: number of O2 sensors 
used
        int salinity;                   // kg per 10000 l
        const char *model, *serial, *fw_version;
diff --git a/file.c b/file.c
index 42f4339..60de64d 100644
--- a/file.c
+++ b/file.c
@@ -540,7 +540,7 @@ int parse_txt_file(const char *filename, const char *csv)
                value = parse_mkvi_value(memtxt.buffer, "Rig Serial number");
                dive->dc.deviceid = atoi(value);
                free(value);
-               dive->dc.dctype = CCR;
+               dive->dc.divemode = CCR;
                dive->dc.no_o2sensors = 2;
 
                dive->cylinder[cur_cylinder_index].cylinder_use = OXYGEN;
diff --git a/libdivecomputer.c b/libdivecomputer.c
index 70be23f..a78f53c 100644
--- a/libdivecomputer.c
+++ b/libdivecomputer.c
@@ -556,10 +556,10 @@ static int dive_cb(const unsigned char *data, unsigned 
int size,
                case DC_DIVEMODE_FREEDIVE:
                case DC_DIVEMODE_GAUGE:
                case DC_DIVEMODE_OC: /* Open circuit */
-                       dive->dc.dctype = OC;
+                       dive->dc.divemode = OC;
                        break;
                case DC_DIVEMODE_CC:  /* Closed circuit */
-                       dive->dc.dctype = CCR;
+                       dive->dc.divemode = CCR;
                        break;
                }
 #endif
diff --git a/load-git.c b/load-git.c
index 02fc98b..1cdb44c 100644
--- a/load-git.c
+++ b/load-git.c
@@ -133,7 +133,7 @@ static duration_t get_duration(const char *line)
 static enum dive_comp_type get_dctype(const char *line)
 {
        for (enum dive_comp_type i = 0; i < NUM_DC_TYPE; i++) {
-               if (strcmp(line, dctype_text[i]) == 0)
+               if (strcmp(line, divemode_text[i]) == 0)
                        return i;
        }
        return 0;
@@ -528,7 +528,7 @@ static void parse_dc_duration(char *line, struct membuffer 
*str, void *_dc)
 { struct divecomputer *dc = _dc; dc->duration = get_duration(line); }
 
 static void parse_dc_dctype(char *line, struct membuffer *str, void *_dc)
-{ struct divecomputer *dc = _dc; dc->dctype = get_dctype(line); }
+{ struct divecomputer *dc = _dc; dc->divemode = get_dctype(line); }
 
 static void parse_dc_maxdepth(char *line, struct membuffer *str, void *_dc)
 { struct divecomputer *dc = _dc; dc->maxdepth = get_depth(line); }
diff --git a/parse-xml.c b/parse-xml.c
index bd6e21b..92e470c 100644
--- a/parse-xml.c
+++ b/parse-xml.c
@@ -570,7 +570,7 @@ static void get_dc_type(char *buffer, enum dive_comp_type 
*dct)
 {
        if (trimspace(buffer)) {
                for (enum dive_comp_type i = 0; i < NUM_DC_TYPE; i++) {
-                       if (strcmp(buffer, dctype_text[i]) == 0)
+                       if (strcmp(buffer, divemode_text[i]) == 0)
                                *dct = i;
                }
        }
@@ -875,7 +875,7 @@ static void try_to_fill_dc(struct divecomputer *dc, const 
char *name, char *buf)
                return;
        if (MATCH("diveid", hex_value, &dc->diveid))
                return;
-       if (MATCH("dctype", get_dc_type, &dc->dctype))
+       if (MATCH("dctype", get_dc_type, &dc->divemode))
                return;
        if (MATCH("no_o2sensors", get_sensor, &dc->no_o2sensors))
                return;
@@ -934,7 +934,7 @@ static void try_to_fill_sample(struct sample *sample, const 
char *name, char *bu
        if (MATCH("sensor3.sample", double_to_o2pressure, 
&sample->o2sensor[2])) // up to 3 CCR sensors
                return;
        if (MATCH("po2.sample", double_to_o2pressure, &sample->setpoint)) {
-               cur_dive->dc.dctype = CCR;
+               cur_dive->dc.divemode = CCR;
                return;
        }
        if (MATCH("heartbeat", get_uint8, &sample->heartbeat))
@@ -2256,7 +2256,7 @@ extern int shearwater_profile_sample(void *handle, int 
columns, char **data, cha
                cur_sample->temperature.mkelvin = metric ? 
C_to_mkelvin(atof(data[2])) : F_to_mkelvin(atof(data[2]));
        if (data[3]) {
                cur_sample->setpoint.mbar = atof(data[3]) * 1000;
-               cur_dive->dc.dctype = CCR;
+               cur_dive->dc.divemode = CCR;
        }
        if (data[4])
                cur_sample->ndl.seconds = atoi(data[4]) * 60;
@@ -2571,19 +2571,19 @@ int parse_dlf_buffer(unsigned char *buffer, size_t size)
 
        // ptr[15] is dive type
        if (0xc8 <= ptr[15] && ptr[15] <= 0xcf)
-               cur_dc->dctype = OC;
+               cur_dc->divemode = OC;
        else if (0xd0 <= ptr[15] && ptr[15] <= 0xd7)
-               cur_dc->dctype = CCR;
+               cur_dc->divemode = CCR;
        else if (0xd8 <= ptr[15] && ptr[15] <= 0xdf)
-               cur_dc->dctype = CCR; // mCCR
+               cur_dc->divemode = CCR; // mCCR
        else if (0xe0 <= ptr[15] && ptr[15] <= 0xe7)
-               cur_dc->dctype = OC; // Free diving
+               cur_dc->divemode = OC; // Free diving
        else if (0xe8 <= ptr[15] && ptr[15] <= 0xef)
-               cur_dc->dctype = OC; // Gauge
+               cur_dc->divemode = OC; // Gauge
        else if (0xf0 <= ptr[15] && ptr[15] <= 0xf7)
-               cur_dc->dctype = PSCR; // ASCR
+               cur_dc->divemode = PSCR; // ASCR
        else if (0xf8 <= ptr[15] && ptr[15] <= 0xff)
-               cur_dc->dctype = PSCR;
+               cur_dc->divemode = PSCR;
 
        cur_dc->maxdepth.mm = ((ptr[21] << 8) + ptr[20]) * 10;
 
@@ -2604,7 +2604,7 @@ int parse_dlf_buffer(unsigned char *buffer, size_t size)
                        // Crazy precision on these stored values...
                        // Only store value if we're in CCR/PSCR mode,
                        // because we rather calculate ppo2 our selfs.
-                       if (cur_dc->dctype == CCR || cur_dc->dctype == PSCR)
+                       if (cur_dc->divemode == CCR || cur_dc->divemode == PSCR)
                                cur_sample->o2sensor[0].mbar = ((ptr[7] << 8) + 
ptr[6]) / 10;
                        if (!ptr[8] && ptr[9])
                                cur_sample->in_deco = true;
diff --git a/planner.c b/planner.c
index 322bd25..e6bd088 100644
--- a/planner.c
+++ b/planner.c
@@ -251,7 +251,7 @@ static void create_dive_from_plan(struct diveplan 
*diveplan, bool track_gas)
        int oldpo2 = 0;
        int lasttime = 0;
        int lastdepth = 0;
-       enum dive_comp_type type = displayed_dive.dc.dctype;
+       enum dive_comp_type type = displayed_dive.dc.divemode;
 
        if (!diveplan || !diveplan->dp)
                return;
@@ -346,7 +346,7 @@ static void create_dive_from_plan(struct diveplan 
*diveplan, bool track_gas)
                finish_sample(dc);
                dp = dp->next;
        }
-       dc->dctype = type;
+       dc->divemode = type;
 #if DEBUG_PLAN & 32
        save_dive(stdout, &displayed_dive);
 #endif
@@ -699,7 +699,7 @@ static void add_plan_to_notes(struct diveplan *diveplan, 
struct dive *dive, bool
        snprintf(temp, sizeof(temp), "%s", translate("gettextFromC", "OTU"));
        len += snprintf(buffer + len, sizeof(buffer) - len, "<br>%s: %i</div>", 
temp, dive->otu);
 
-       if (dive->dc.dctype == CCR)
+       if (dive->dc.divemode == CCR)
                snprintf(temp, sizeof(temp), "%s", translate("gettextFromC", 
"Gas consumption (CCR legs excluded):"));
        else
                snprintf(temp, sizeof(temp), "%s", translate("gettextFromC", 
"Gas consumption:"));
diff --git a/profile.c b/profile.c
index a09268b..205663b 100644
--- a/profile.c
+++ b/profile.c
@@ -435,7 +435,7 @@ static void check_setpoint_events(struct dive *dive, struct 
divecomputer *dc, st
                i = set_setpoint(pi, i, setpoint.mbar, ev->time.seconds);
                setpoint.mbar = ev->value;
                if (setpoint.mbar)
-                       dc->dctype = CCR;
+                       dc->divemode = CCR;
                ev = get_next_event(ev->next, "SP change");
        } while (ev);
        set_setpoint(pi, i, setpoint.mbar, ~0u);
@@ -607,7 +607,7 @@ struct plot_data *populate_plot_entries(struct dive *dive, 
struct divecomputer *
                pi->has_ndl |= sample->ndl.seconds;
                entry->in_deco = sample->in_deco;
                entry->cns = sample->cns;
-               if (dc->dctype == CCR) {
+               if (dc->divemode == CCR) {
                        entry->o2pressure.mbar = entry->o2setpoint.mbar = 
sample->setpoint.mbar;     // for rebreathers
                        entry->o2sensor[0].mbar = sample->o2sensor[0].mbar; // 
for up to three rebreather O2 sensors
                        entry->o2sensor[1].mbar = sample->o2sensor[1].mbar;
@@ -940,7 +940,7 @@ static void calculate_gas_information_new(struct dive 
*dive, struct plot_info *p
 
                amb_pressure = depth_to_mbar(entry->depth, dive) / 1000.0;
 
-               fill_pressures(&entry->pressures, amb_pressure, 
&dive->cylinder[cylinderindex].gasmix, entry->o2pressure.mbar / 1000.0, 
dive->dc.dctype, entry->sac);
+               fill_pressures(&entry->pressures, amb_pressure, 
&dive->cylinder[cylinderindex].gasmix, entry->o2pressure.mbar / 1000.0, 
dive->dc.divemode, entry->sac);
                fn2 = (int)(1000.0 * entry->pressures.n2 / amb_pressure);
                fhe = (int)(1000.0 * entry->pressures.he / amb_pressure);
 
@@ -984,7 +984,8 @@ void fill_o2_values(struct divecomputer *dc, struct 
plot_info *pi, struct dive *
 
        for (i = 0; i < pi->nr; i++) {
                struct plot_data *entry = pi->entry + i;
-               if (dc->dctype == CCR) {
+
+               if (dc->divemode == CCR) {
                        if (i == 0) { // For 1st iteration, initialise the 
last_sensor values
                                for (j = 0; j < dc->no_o2sensors; j++)
                                        last_sensor[j].mbar = 
pi->entry->o2sensor[j].mbar;
@@ -1058,7 +1059,7 @@ void create_plot_info_new(struct dive *dive, struct 
divecomputer *dc, struct plo
        setup_gas_sensor_pressure(dive, dc, pi); /* Try to populate our gas 
pressure knowledge */
        if (!fast) {
                populate_pressure_information(dive, dc, pi, false);     /* .. 
calculate missing pressure entries for all gasses except o2 */
-               if (dc->dctype == CCR)                                     /* 
For CCR dives.. */
+               if (dc->divemode == CCR)                                        
/* For CCR dives.. */
                        populate_pressure_information(dive, dc, pi, true); /* 
.. calculate missing o2 gas pressure entries */
        }
        fill_o2_values(dc, pi, dive);                    /* .. and insert the 
O2 sensor data having 0 values. */
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp
index d9aa381..1e10734 100644
--- a/qt-ui/diveplanner.cpp
+++ b/qt-ui/diveplanner.cpp
@@ -785,13 +785,13 @@ void DivePlannerPointsModel::setGFLow(const int ghflow)
 
 void DivePlannerPointsModel::setRebreatherMode(QString mode)
 {
-       qDebug() << mode << "selected, was" << displayed_dive.dc.dctype;
+       qDebug() << mode << "selected, was" << displayed_dive.dc.divemode;
        if (mode == "OC")
-               displayed_dive.dc.dctype = OC;
+               displayed_dive.dc.divemode = OC;
        else if (mode == "pSCR")
-               displayed_dive.dc.dctype = PSCR;
+               displayed_dive.dc.divemode = PSCR;
        else if (mode == "CCR")
-               displayed_dive.dc.dctype = CCR;
+               displayed_dive.dc.divemode = CCR;
        plannerModel->emitDataChanged();
 }
 
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp
index 3e49086..d930cbf 100644
--- a/qt-ui/maintab.cpp
+++ b/qt-ui/maintab.cpp
@@ -430,7 +430,7 @@ void MainTab::updateDiveInfo(bool clear)
        UPDATE_TEXT(displayed_dive, buddy);
        UPDATE_TEMP(displayed_dive, airtemp);
        UPDATE_TEMP(displayed_dive, watertemp);
-       ui.DiveType->setCurrentIndex(displayed_dive.dc.dctype);
+       ui.DiveType->setCurrentIndex(displayed_dive.dc.divemode);
 
        if (!clear) {
                updateGpsCoordinates(&displayed_dive);
@@ -514,7 +514,7 @@ void MainTab::updateDiveInfo(bool clear)
                ui.otuText->setText(QString("%1").arg(displayed_dive.otu));
                
ui.waterTemperatureText->setText(get_temperature_string(displayed_dive.watertemp,
 true));
                
ui.airTemperatureText->setText(get_temperature_string(displayed_dive.airtemp, 
true));
-               ui.DiveType->setCurrentIndex(current_dc->dctype);
+               ui.DiveType->setCurrentIndex(current_dc->divemode);
                volume_t gases[MAX_CYLINDERS] = {};
                get_gas_used(&displayed_dive, gases);
                QString volumes;
@@ -650,7 +650,7 @@ void MainTab::updateDiveInfo(bool clear)
        }
        editMode = NONE;
        ui.cylinders->view()->hideColumn(CylindersModel::DEPTH);
-       if (get_dive_dc(&displayed_dive, dc_number)->dctype == CCR)
+       if (get_dive_dc(&displayed_dive, dc_number)->divemode == CCR)
                ui.cylinders->view()->showColumn(CylindersModel::USE);
        else
                ui.cylinders->view()->hideColumn(CylindersModel::USE);
@@ -772,8 +772,8 @@ void MainTab::acceptChanges()
                        MODIFY_SELECTED_DIVES(EDIT_VALUE(visibility));
                if (displayed_dive.airtemp.mkelvin != cd->airtemp.mkelvin)
                        MODIFY_SELECTED_DIVES(EDIT_VALUE(airtemp.mkelvin));
-               if (displayed_dive.dc.dctype != cd->dc.dctype) {
-                       MODIFY_SELECTED_DIVES(EDIT_VALUE(dc.dctype));
+               if (displayed_dive.dc.divemode != cd->dc.divemode) {
+                       MODIFY_SELECTED_DIVES(EDIT_VALUE(dc.divemode));
                        
MODIFY_SELECTED_DIVES(update_setpoint_events(&mydive->dc));
                        do_replot = true;
                }
@@ -1019,7 +1019,7 @@ void MainTab::divetype_Changed(int index)
 {
        if (editMode == IGNORE)
                return;
-       displayed_dive.dc.dctype = (enum dive_comp_type) index;
+       displayed_dive.dc.divemode = (enum dive_comp_type) index;
        update_setpoint_events(&displayed_dive.dc);
        markChangedWidget(ui.DiveType);
 }
diff --git a/qt-ui/maintab.ui b/qt-ui/maintab.ui
index 226442f..937dec4 100644
--- a/qt-ui/maintab.ui
+++ b/qt-ui/maintab.ui
@@ -22,7 +22,9 @@
      <number>0</number>
     </property>
     <item row="2" column="1">
-     <widget class="KMessageWidget" name="diveNotesMessage" native="true"/>
+     <widget class="KMessageWidget" name="diveNotesMessage" native="true">
+      <zorder>scrollArea</zorder>
+     </widget>
     </item>
     <item row="3" column="1">
      <widget class="QScrollArea" name="scrollArea">
@@ -40,14 +42,41 @@
         <rect>
          <x>0</x>
          <y>0</y>
-         <width>435</width>
-         <height>770</height>
+         <width>397</width>
+         <height>744</height>
         </rect>
        </property>
        <layout class="QGridLayout" name="diveNotesScrollAreaLayout">
         <property name="spacing">
          <number>0</number>
         </property>
+        <item row="4" column="0" colspan="3">
+         <layout class="QHBoxLayout" name="horizontalLayout">
+          <property name="sizeConstraint">
+           <enum>QLayout::SetNoConstraint</enum>
+          </property>
+          <item>
+           <widget class="QLabel" name="CoordinatedLabel">
+            <property name="sizePolicy">
+             <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+              <horstretch>0</horstretch>
+              <verstretch>0</verstretch>
+             </sizepolicy>
+            </property>
+            <property name="text">
+             <string>Coordinates</string>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <widget class="QLabel" name="TypeLabel">
+            <property name="text">
+             <string>Dive mode</string>
+            </property>
+           </widget>
+          </item>
+         </layout>
+        </item>
         <item row="0" column="0">
          <widget class="QLabel" name="label_2">
           <property name="text">
@@ -83,16 +112,6 @@
           </item>
          </layout>
         </item>
-        <item row="1" column="0">
-         <widget class="QDateEdit" name="dateEdit">
-          <property name="calendarPopup">
-           <bool>true</bool>
-          </property>
-          <property name="timeSpec">
-           <enum>Qt::UTC</enum>
-          </property>
-         </widget>
-        </item>
         <item row="1" column="1">
          <widget class="QTimeEdit" name="timeEdit">
           <property name="sizePolicy">
@@ -106,6 +125,16 @@
           </property>
          </widget>
         </item>
+        <item row="1" column="0">
+         <widget class="QDateEdit" name="dateEdit">
+          <property name="calendarPopup">
+           <bool>true</bool>
+          </property>
+          <property name="timeSpec">
+           <enum>Qt::UTC</enum>
+          </property>
+         </widget>
+        </item>
         <item row="1" column="2">
          <layout class="QHBoxLayout" name="airWaterTempLayout">
           <property name="spacing">
@@ -134,136 +163,129 @@
           </property>
          </widget>
         </item>
-        <item row="4" column="0">
-         <widget class="QLabel" name="CoordinatedLabel">
-          <property name="text">
-           <string>Coordinates</string>
-          </property>
-         </widget>
-        </item>
-        <item row="6" column="0">
+        <item row="10" column="0">
          <widget class="QLabel" name="DivemasterLabel">
           <property name="text">
            <string>Divemaster</string>
           </property>
          </widget>
         </item>
-        <item row="6" column="2">
+        <item row="10" column="2">
          <widget class="QLabel" name="BuddyLabel">
           <property name="text">
            <string>Buddy</string>
           </property>
          </widget>
         </item>
-        <item row="7" column="0" colspan="2">
+        <item row="11" column="0" colspan="2">
          <widget class="TagWidget" name="divemaster">
           <property name="readOnly">
            <bool>false</bool>
           </property>
          </widget>
         </item>
-        <item row="7" column="2">
+        <item row="11" column="2">
          <widget class="TagWidget" name="buddy">
           <property name="readOnly">
            <bool>false</bool>
           </property>
          </widget>
         </item>
-        <item row="8" column="0" colspan="2">
+        <item row="12" column="0" colspan="2">
          <layout class="QHBoxLayout" name="ratingVisibilityLabels">
           <property name="spacing">
            <number>0</number>
           </property>
           <item>
-           <widget class="StarWidget" name="rating" native="true">
+           <widget class="QLabel" name="RatingLabel">
             <property name="sizePolicy">
              <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
               <horstretch>0</horstretch>
               <verstretch>0</verstretch>
              </sizepolicy>
             </property>
-            <property name="focusPolicy">
-             <enum>Qt::StrongFocus</enum>
+            <property name="text">
+             <string>Rating</string>
             </property>
            </widget>
           </item>
           <item>
-           <widget class="StarWidget" name="visibility" native="true">
+           <widget class="QLabel" name="visibilityLabel">
             <property name="sizePolicy">
              <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
               <horstretch>0</horstretch>
               <verstretch>0</verstretch>
              </sizepolicy>
             </property>
-            <property name="focusPolicy">
-             <enum>Qt::StrongFocus</enum>
+            <property name="text">
+             <string>Visibility</string>
             </property>
            </widget>
           </item>
          </layout>
         </item>
-        <item row="8" column="2">
+        <item row="12" column="2">
          <widget class="QLabel" name="SuitLabel">
           <property name="text">
            <string>Suit</string>
           </property>
          </widget>
         </item>
-        <item row="9" column="2">
+        <item row="13" column="2">
          <widget class="QLineEdit" name="suit">
           <property name="readOnly">
            <bool>false</bool>
           </property>
          </widget>
         </item>
-        <item row="10" column="0">
-         <widget class="QLabel" name="TagLabel">
-          <property name="text">
-           <string>Tags</string>
-          </property>
-         </widget>
-        </item>
-        <item row="12" column="0">
-         <widget class="QLabel" name="NotesLabel">
-          <property name="text">
-           <string>Notes</string>
-          </property>
-         </widget>
-        </item>
-        <item row="9" column="0" colspan="2">
+        <item row="13" column="0" colspan="2">
          <layout class="QHBoxLayout" name="ratingVisibilityWidgets">
           <property name="spacing">
            <number>0</number>
           </property>
           <item>
-           <widget class="QLabel" name="RatingLabel">
+           <widget class="StarWidget" name="rating" native="true">
             <property name="sizePolicy">
              <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
               <horstretch>0</horstretch>
               <verstretch>0</verstretch>
              </sizepolicy>
             </property>
-            <property name="text">
-             <string>Rating</string>
+            <property name="focusPolicy">
+             <enum>Qt::StrongFocus</enum>
             </property>
            </widget>
           </item>
           <item>
-           <widget class="QLabel" name="visibilityLabel">
+           <widget class="StarWidget" name="visibility" native="true">
             <property name="sizePolicy">
              <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
               <horstretch>0</horstretch>
               <verstretch>0</verstretch>
              </sizepolicy>
             </property>
-            <property name="text">
-             <string>Visibility</string>
+            <property name="focusPolicy">
+             <enum>Qt::StrongFocus</enum>
             </property>
            </widget>
           </item>
          </layout>
         </item>
-        <item row="11" column="0" colspan="3">
+        <item row="14" column="0">
+         <widget class="QLabel" name="TagLabel">
+          <property name="text">
+           <string>Tags</string>
+          </property>
+         </widget>
+        </item>
+        <item row="16" column="0">
+         <widget class="QLabel" name="NotesLabel">
+          <property name="text">
+           <string>Notes</string>
+          </property>
+         </widget>
+        </item>
+        <item row="15" column="0" colspan="3">
          <widget class="TagWidget" name="tagWidget">
           <property name="sizePolicy">
            <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
@@ -295,24 +317,7 @@
           </property>
          </widget>
         </item>
-        <item row="5" column="0" colspan="3">
-         <widget class="QLineEdit" name="coordinates">
-          <property name="readOnly">
-           <bool>false</bool>
-          </property>
-         </widget>
-          <item>
-           <widget class="QComboBox" name="DiveType">
-            <property name="sizePolicy">
-             <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
-              <horstretch>0</horstretch>
-              <verstretch>0</verstretch>
-             </sizepolicy>
-            </property>
-           </widget>
-          </item>
-        </item>
-        <item row="13" column="0" colspan="3">
+        <item row="17" column="0" colspan="3">
          <layout class="QHBoxLayout" name="notesAndSocialNetworksLayout">
           <property name="spacing">
            <number>0</number>
@@ -368,6 +373,20 @@
           </item>
          </layout>
         </item>
+        <item row="7" column="0" colspan="3">
+         <layout class="QHBoxLayout" name="horizontalLayout_2">
+          <item>
+           <widget class="QLineEdit" name="coordinates">
+            <property name="readOnly">
+             <bool>false</bool>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <widget class="QComboBox" name="DiveType"/>
+          </item>
+         </layout>
+        </item>
        </layout>
       </widget>
      </widget>
@@ -398,8 +417,8 @@
         <rect>
          <x>0</x>
          <y>0</y>
-         <width>423</width>
-         <height>752</height>
+         <width>397</width>
+         <height>734</height>
         </rect>
        </property>
        <layout class="QGridLayout" name="equipmentTabScrollAreaLayout">
@@ -454,8 +473,8 @@
         <rect>
          <x>0</x>
          <y>0</y>
-         <width>423</width>
-         <height>752</height>
+         <width>397</width>
+         <height>734</height>
         </rect>
        </property>
        <layout class="QGridLayout" name="diveInfoScrollAreaLayout">
@@ -771,8 +790,8 @@
         <rect>
          <x>0</x>
          <y>0</y>
-         <width>423</width>
-         <height>752</height>
+         <width>397</width>
+         <height>734</height>
         </rect>
        </property>
        <layout class="QGridLayout" name="statsScrollAreaLayout">
diff --git a/qt-ui/preferences.ui b/qt-ui/preferences.ui
index 65075b0..2572990 100644
--- a/qt-ui/preferences.ui
+++ b/qt-ui/preferences.ui
@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>924</width>
-    <height>742</height>
+    <width>940</width>
+    <height>756</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -748,14 +748,14 @@
             <string>Misc</string>
            </property>
            <layout class="QFormLayout" name="formLayout_3">
-            <item row="0" column="0">
+            <item row="1" column="0">
              <widget class="QLabel" name="label_19">
               <property name="text">
                <string>GFLow</string>
               </property>
              </widget>
             </item>
-            <item row="0" column="1">
+            <item row="1" column="1">
              <widget class="QSpinBox" name="gflow">
               <property name="minimum">
                <number>1</number>
@@ -765,14 +765,14 @@
               </property>
              </widget>
             </item>
-            <item row="1" column="0">
+            <item row="2" column="0">
              <widget class="QLabel" name="label_20">
               <property name="text">
                <string>GFHigh</string>
               </property>
              </widget>
             </item>
-            <item row="1" column="1">
+            <item row="2" column="1">
              <widget class="QSpinBox" name="gfhigh">
               <property name="minimum">
                <number>1</number>
@@ -782,28 +782,21 @@
               </property>
              </widget>
             </item>
-            <item row="3" column="0" colspan="2">
+            <item row="4" column="0" colspan="2">
              <widget class="QCheckBox" name="gf_low_at_maxdepth">
               <property name="text">
                <string>GFLow at max depth</string>
               </property>
              </widget>
             </item>
-            <item row="3" column="0" colspan="2">
-             <widget class="QCheckBox" name="show_ccr_setpoint">
-              <property name="text">
-               <string>CCR: Show setpoints when viewing pO₂</string>
-              </property>
-             </widget>
-            </item>
-            <item row="4" column="0">
+            <item row="6" column="0">
              <widget class="QLabel" name="label_26">
               <property name="text">
                <string>Default CCR set-point</string>
               </property>
              </widget>
             </item>
-            <item row="4" column="1">
+            <item row="6" column="1">
              <widget class="QDoubleSpinBox" name="defaultSetpoint">
               <property name="suffix">
                <string>bar</string>
@@ -819,6 +812,13 @@
               </property>
              </widget>
             </item>
+            <item row="5" column="0">
+             <widget class="QCheckBox" name="show_ccr_setpoint">
+              <property name="text">
+               <string>CCR: Show setpoints when viewing pO₂</string>
+              </property>
+             </widget>
+            </item>
            </layout>
           </widget>
          </item>
@@ -1413,11 +1413,11 @@
  </connections>
  <buttongroups>
   <buttongroup name="verticalSpeed"/>
+  <buttongroup name="buttonGroup"/>
   <buttongroup name="buttonGroup_2"/>
   <buttongroup name="buttonGroup_3"/>
   <buttongroup name="buttonGroup_4"/>
   <buttongroup name="buttonGroup_5"/>
-  <buttongroup name="buttonGroup"/>
   <buttongroup name="buttonGroup_6"/>
  </buttongroups>
 </ui>
diff --git a/qt-ui/profile/diveprofileitem.cpp 
b/qt-ui/profile/diveprofileitem.cpp
index c049d91..60a030b 100644
--- a/qt-ui/profile/diveprofileitem.cpp
+++ b/qt-ui/profile/diveprofileitem.cpp
@@ -624,14 +624,14 @@ void DiveGasPressureItem::modelDataChanged(const 
QModelIndex &topLeft, const QMo
        int o2mbar;
        QPolygonF boundingPoly, o2Poly; // This is the "Whole Item", but a 
pressure can be divided in N Polygons.
        polygons.clear();
-       if (displayed_dive.dc.dctype == CCR)
+       if (displayed_dive.dc.divemode == CCR)
                polygons.append(o2Poly);
 
        for (int i = 0, count = dataModel->rowCount(); i < count; i++) {
                o2mbar = 0;
                plot_data *entry = dataModel->data().entry + i;
                int mbar = GET_PRESSURE(entry);
-               if (displayed_dive.dc.dctype == CCR)
+               if (displayed_dive.dc.divemode == CCR)
                        o2mbar = GET_O2CYLINDER_PRESSURE(entry);
 
                if (entry->cylinderindex != last_index) {
@@ -665,7 +665,7 @@ void DiveGasPressureItem::modelDataChanged(const 
QModelIndex &topLeft, const QMo
        for (int i = 0, count = dataModel->rowCount(); i < count; i++) {
                entry = dataModel->data().entry + i;
                mbar = GET_PRESSURE(entry);
-               if (displayed_dive.dc.dctype == CCR && 
displayed_dive.oxygen_cylinder_index >= 0)
+               if (displayed_dive.dc.divemode == CCR && 
displayed_dive.oxygen_cylinder_index >= 0)
                        o2mbar = GET_O2CYLINDER_PRESSURE(entry);
 
                if (o2mbar) {
diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp
index 7ccc7cf..f24e17d 100644
--- a/qt-ui/profile/profilewidget2.cpp
+++ b/qt-ui/profile/profilewidget2.cpp
@@ -531,7 +531,7 @@ void ProfileWidget2::plotDive(struct dive *d, bool force)
                currentdc = fake_dc(currentdc);
        }
 
-       o2SetpointGasItem->setVisible(current_dive && (currentdc->dctype == 
CCR) && prefs.show_ccr_setpoint && prefs.pp_graphs.po2);
+       o2SetpointGasItem->setVisible(current_dive && (currentdc->divemode == 
CCR) && prefs.show_ccr_setpoint && prefs.pp_graphs.po2);
 
        /* This struct holds all the data that's about to be plotted.
         * I'm not sure this is the best approach ( but since we are
@@ -988,7 +988,7 @@ void ProfileWidget2::setProfileState()
        }
        pn2GasItem->setVisible(prefs.pp_graphs.pn2);
        po2GasItem->setVisible(prefs.pp_graphs.po2);
-       o2SetpointGasItem->setVisible(current_dive && prefs.pp_graphs.po2 && 
(current_dc->dctype == CCR) && (prefs.show_ccr_setpoint));
+       o2SetpointGasItem->setVisible(current_dive && prefs.pp_graphs.po2 && 
(current_dc->divemode == CCR) && (prefs.show_ccr_setpoint));
        pheGasItem->setVisible(prefs.pp_graphs.phe);
 
        timeAxis->setPos(itemPos.time.pos.on);
diff --git a/save-git.c b/save-git.c
index f9f5943..a8f745c 100644
--- a/save-git.c
+++ b/save-git.c
@@ -355,8 +355,8 @@ static void save_dc(struct membuffer *b, struct dive *dive, 
struct divecomputer
                show_date(b, dc->when);
        if (dc->duration.seconds && dc->duration.seconds != 
dive->dc.duration.seconds)
                put_duration(b, dc->duration, "duration ", "min\n");
-       if (dc->dctype != OC) {
-               put_format(b, "dctype %s\n", dctype_text[dc->dctype]);
+       if (dc->divemode != OC) {
+               put_format(b, "dctype %s\n", divemode_text[dc->divemode]);
        put_format(b, "numberofoxygensensors %d\n",dc->no_o2sensors);
        }
 
diff --git a/save-xml.c b/save-xml.c
index 29e09dc..053b8fc 100644
--- a/save-xml.c
+++ b/save-xml.c
@@ -369,10 +369,10 @@ static void save_dc(struct membuffer *b, struct dive 
*dive, struct divecomputer
                show_date(b, dc->when);
        if (dc->duration.seconds && dc->duration.seconds != 
dive->dc.duration.seconds)
                put_duration(b, dc->duration, " duration='", " min'");
-       if (dc->dctype != OC) {
+       if (dc->divemode != OC) {
                for (enum dive_comp_type i = 0; i < NUM_DC_TYPE; i++)
-                       if (dc->dctype == i)
-                               show_utf8(b, dctype_text[i], " dctype='", "'", 
1);
+                       if (dc->divemode == i)
+                               show_utf8(b, divemode_text[i], " dctype='", 
"'", 1);
                if (dc->no_o2sensors)
                        put_format(b," no_o2sensors='%d'", dc->no_o2sensors);
        }
diff --git a/statistics.c b/statistics.c
index 96d6a65..bca9e65 100644
--- a/statistics.c
+++ b/statistics.c
@@ -308,7 +308,7 @@ bool is_cylinder_used(struct dive *dive, int idx)
                                return true;
                        event = get_next_event(event->next, "gaschange");
                }
-               if (dc->dctype == CCR && (idx == dive->diluent_cylinder_index 
|| idx == dive->oxygen_cylinder_index))
+               if (dc->divemode == CCR && (idx == dive->diluent_cylinder_index 
|| idx == dive->oxygen_cylinder_index))
                        return true;
        }
        if (idx == 0 && !firstGasExplicit)
diff --git a/subsurfacestartup.c b/subsurfacestartup.c
index c673813..4b8428e 100644
--- a/subsurfacestartup.c
+++ b/subsurfacestartup.c
@@ -54,7 +54,7 @@ struct preferences default_prefs = {
                .user_id = NULL,
                .album_id = NULL,
                .access_token = NULL
-       }
+       },
        .defaultsetpoint = 1100
 };
 
-- 
1.9.3 (Apple Git-50)

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

_______________________________________________
subsurface mailing list
[email protected]
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to