diff options
-rw-r--r-- | Rules.mk | 2 | ||||
-rw-r--r-- | dive.c | 24 | ||||
-rw-r--r-- | dive.h | 8 | ||||
-rw-r--r-- | profile.c | 6 | ||||
-rw-r--r-- | qt-gui.cpp | 5 | ||||
-rw-r--r-- | qt-ui/maintab.cpp | 8 | ||||
-rw-r--r-- | qt-ui/maintab.h | 4 | ||||
-rw-r--r-- | qt-ui/mainwindow.cpp | 5 | ||||
-rw-r--r-- | qt-ui/modeldelegates.cpp | 2 | ||||
-rw-r--r-- | qt-ui/models.cpp | 3 | ||||
-rw-r--r-- | qt-ui/preferences.cpp | 4 | ||||
-rw-r--r-- | qt-ui/preferences.ui | 54 | ||||
-rw-r--r-- | xslt/SuuntoSDM.xslt | 4 |
13 files changed, 97 insertions, 32 deletions
@@ -185,7 +185,7 @@ MOCFLAGS = $(filter -I%, $(CXXFLAGS) $(EXTRA_FLAGS)) $(filter -D%, $(CXXFLAGS) $ @mkdir -p .dep/$(@D) $(COMPILE_PREFIX)$(CC) $(CFLAGS) $(EXTRA_FLAGS) -MD -MF .dep/$@.dep -c -o $@ $< -%.o: %.cpp uicables +%.o: %.cpp $(UIC_HEADERS) @$(PRETTYECHO) ' CXX' $< @mkdir -p .dep/$(@D) $(COMPILE_PREFIX)$(CXX) $(CXXFLAGS) $(EXTRA_FLAGS) -I.uic -Iqt-ui -MD -MF .dep/$@.dep -c -o $@ $< @@ -127,6 +127,30 @@ double get_depth_units(unsigned int mm, int *frac, const char **units) return d; } +double get_vertical_speed_units(unsigned int mms, int *frac, const char **units) +{ + double d; + const char *unit; + const struct units *units_p = get_units(); + const double time_factor = units_p->vertical_speed_time == MINUTES ? 60.0 : 1.0; + + switch (units_p->length) { + case METERS: + d = mms / 1000.0 * time_factor; + unit = _((units_p->vertical_speed_time == MINUTES) ? "m/min" : "m/s"); + break; + case FEET: + d = mm_to_feet(mms) * time_factor; + unit = _((units_p->vertical_speed_time == MINUTES) ? "ft/min" : "ft/s"); + break; + } + if (frac) + *frac = d < 10; + if (units) + *units = unit; + return d; +} + double get_weight_units(unsigned int grams, int *frac, const char **units) { int decimals; @@ -160,6 +160,7 @@ extern double get_depth_units(unsigned int mm, int *frac, const char **units); extern double get_volume_units(unsigned int ml, int *frac, const char **units); extern double get_temp_units(unsigned int mk, const char **units); extern double get_weight_units(unsigned int grams, int *frac, const char **units); +extern double get_vertical_speed_units(unsigned int mms, int *frac, const char **units); static inline double grams_to_lbs(int grams) { @@ -476,6 +477,7 @@ struct units { enum { BAR, PSI, PASCAL } pressure; enum { CELSIUS, FAHRENHEIT, KELVIN } temperature; enum { KG, LBS } weight; + enum { SECONDS, MINUTES } vertical_speed_time; }; /* @@ -490,7 +492,8 @@ struct units { .volume = LITER, \ .pressure = BAR, \ .temperature = CELSIUS, \ - .weight = KG \ + .weight = KG, \ + .vertical_speed_time = MINUTES \ } #define IMPERIAL_UNITS { \ @@ -498,7 +501,8 @@ struct units { .volume = CUFT, \ .pressure = PSI, \ .temperature = FAHRENHEIT, \ - .weight = LBS \ + .weight = LBS, \ + .vertical_speed_time = MINUTES \ } extern const struct units SI_units, IMPERIAL_units; extern struct units xml_parsing_units; @@ -1213,7 +1213,7 @@ static void plot_string(struct plot_data *entry, char *buf, int bufsize, int depth, int pressure, int temp, gboolean has_ndl) { int pressurevalue, mod, ead, end, eadd; - const char *depth_unit, *pressure_unit, *temp_unit; + const char *depth_unit, *pressure_unit, *temp_unit, *vertical_speed_unit; char *buf2 = malloc(bufsize); double depthvalue, tempvalue, speedvalue; @@ -1236,12 +1236,12 @@ static void plot_string(struct plot_data *entry, char *buf, int bufsize, snprintf(buf, bufsize, _("%s\nT:%.1f %s"), buf2, tempvalue, temp_unit); } - speedvalue = get_depth_units(abs(entry->speed), NULL, &depth_unit)*60; + speedvalue = get_vertical_speed_units(abs(entry->speed), NULL, &vertical_speed_unit); memcpy(buf2, buf, bufsize); /* Ascending speeds are positive, descending are negative */ if (entry->speed > 0) speedvalue *= -1; - snprintf(buf, bufsize, _("%s\nV:%.1f %s/min"), buf2, speedvalue, depth_unit); + snprintf(buf, bufsize, _("%s\nV:%.2f %s"), buf2, speedvalue, vertical_speed_unit); if (entry->ceiling) { depthvalue = get_depth_units(entry->ceiling, NULL, &depth_unit); diff --git a/qt-gui.cpp b/qt-gui.cpp index 64a125dcb..78138ad3a 100644 --- a/qt-gui.cpp +++ b/qt-gui.cpp @@ -217,8 +217,9 @@ QString get_depth_unit() QString get_weight_string(weight_t weight, bool showunit) { if (prefs.units.weight == units::KG) { - double kg = weight.grams / 1000.0; - return QString("%1%2").arg(kg, 0, 'f', kg >= 20.0 ? 0 : 1 ).arg(showunit ? _("kg") : ""); + int gr = weight.grams % 1000; + int kg = weight.grams / 1000; + return QString("%1.%2%3").arg(kg).arg((unsigned)(gr) / 100).arg(showunit ? _("kg") : ""); } else { double lbs = grams_to_lbs(weight.grams); return QString("%1%2").arg(lbs, 0, 'f', lbs >= 40.0 ? 0 : 1 ).arg(showunit ? _("lbs") : ""); diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index ae0de914f..2498a0d97 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -74,7 +74,7 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent), connect(ui.weights, SIGNAL(addButtonClicked()), this, SLOT(addWeight_clicked())); connect(ui.cylinders->view(), SIGNAL(clicked(QModelIndex)), this, SLOT(editCylinderWidget(QModelIndex))); - connect(ui.weights->view(), SIGNAL(clicked(QModelIndex)), this, SLOT(editWeigthWidget(QModelIndex))); + connect(ui.weights->view(), SIGNAL(clicked(QModelIndex)), this, SLOT(editWeightWidget(QModelIndex))); connect(ui.notesButtonBox, SIGNAL(accepted()), this, SLOT(acceptChanges())); connect(ui.notesButtonBox, SIGNAL(rejected()), this, SLOT(rejectChanges())); connect(ui.equipmentButtonBox, SIGNAL(accepted()), this, SLOT(acceptChanges())); @@ -167,7 +167,7 @@ void MainTab::enableEdition() notesBackup[mydive].cylinders[i] = mydive->cylinder[i]; } for (int i = 0; i < MAX_WEIGHTSYSTEMS; i++) { - notesBackup[mydive].weigthsystem[i] = mydive->weightsystem[i]; + notesBackup[mydive].weightsystem[i] = mydive->weightsystem[i]; } } editMode = DIVE; @@ -561,7 +561,7 @@ void MainTab::rejectChanges() mydive->cylinder[i] = notesBackup[mydive].cylinders[i]; } for (int i = 0; i < MAX_WEIGHTSYSTEMS; i++) { - mydive->weightsystem[i] = notesBackup[mydive].weigthsystem[i]; + mydive->weightsystem[i] = notesBackup[mydive].weightsystem[i]; } } multiEditEquipmentPlaceholder = *get_dive(selected_dive); @@ -726,7 +726,7 @@ void MainTab::editCylinderWidget(const QModelIndex& index) ui.cylinders->edit(index); } -void MainTab::editWeigthWidget(const QModelIndex& index) +void MainTab::editWeightWidget(const QModelIndex& index) { if (editMode == NONE) enableEdition(); diff --git a/qt-ui/maintab.h b/qt-ui/maintab.h index 8afa5ff02..2a588bad8 100644 --- a/qt-ui/maintab.h +++ b/qt-ui/maintab.h @@ -32,7 +32,7 @@ struct NotesBackup{ int visibility; QString divemaster; cylinder_t cylinders[MAX_CYLINDERS]; - weightsystem_t weigthsystem[MAX_WEIGHTSYSTEMS ]; + weightsystem_t weightsystem[MAX_WEIGHTSYSTEMS ]; }; struct Completers{ @@ -72,7 +72,7 @@ public slots: void on_rating_valueChanged(int value); void on_visibility_valueChanged(int value); void editCylinderWidget(const QModelIndex& index); - void editWeigthWidget(const QModelIndex& index); + void editWeightWidget(const QModelIndex& index); void addDiveStarted(); private: diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index bbacc74a1..84b1bc50b 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -416,7 +416,7 @@ void MainWindow::on_actionUserManual_triggered() QString MainWindow::filter() { QString f; - f += "ALL ( *.xml *.XML *.uddf *.udcf *.UDFC *.jlb *.JLB "; + f += "ALL ( *.ssrf *.xml *.XML *.uddf *.udcf *.UDFC *.jlb *.JLB "; #ifdef LIBZIP f += "*.sde *.SDE *.dld *.DLD "; #endif @@ -425,6 +425,7 @@ QString MainWindow::filter() #endif f += ");;"; + f += "Subsurface (*.ssrf);;"; f += "XML (*.xml *.XML);;"; f += "UDDF (*.uddf);;"; f += "UDCF (*.udcf *.UDCF);;"; @@ -567,6 +568,7 @@ void MainWindow::readSettings() GET_UNIT("temperature", temperature, units::FAHRENHEIT, units::CELSIUS); GET_UNIT("weight", weight, units::LBS, units::KG); } + GET_UNIT("vertical_speed_time", vertical_speed_time, units::MINUTES, units::SECONDS); s.endGroup(); s.beginGroup("TecDetails"); GET_BOOL("po2graph", pp_graphs.po2); @@ -624,6 +626,7 @@ void MainWindow::writeSettings() SAVE_VALUE("volume", units.volume); SAVE_VALUE("temperature", units.temperature); SAVE_VALUE("weight", units.weight); + SAVE_VALUE("vertical_speed_time", units.vertical_speed_time); settings.endGroup(); settings.beginGroup("TecDetails"); SAVE_VALUE("po2graph", pp_graphs.po2); diff --git a/qt-ui/modeldelegates.cpp b/qt-ui/modeldelegates.cpp index e80afab59..5304313b3 100644 --- a/qt-ui/modeldelegates.cpp +++ b/qt-ui/modeldelegates.cpp @@ -117,7 +117,7 @@ QWidget* ComboBoxDelegate::createEditor(QWidget* parent, const QStyleOptionViewI /* This Method is being called when the user *writes* something and press enter or tab, * and it`s also called when the mouse walks over the list of choices from the ComboBox, - * One thing is important, if the user writes a *new* cylinder or weigth type, it will + * One thing is important, if the user writes a *new* cylinder or weight type, it will * be ADDED to the list, and the user will need to fill the other data. */ void ComboBoxDelegate::testActivation(const QString& currText) diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp index 6831b9271..752f3ddf3 100644 --- a/qt-ui/models.cpp +++ b/qt-ui/models.cpp @@ -1114,7 +1114,8 @@ QString DiveItem::displayWeight() const int kg = weight() / 1000; str = QString("%1.%2").arg(kg).arg((unsigned)(gr) / 100); } else { - str = QString("%1").arg((unsigned)(grams_to_lbs(weight()))); + double lbs = grams_to_lbs(weight()); + str = QString("%1").arg(lbs, 0, 'f', lbs >= 40.0 ? 0 : 1 ); } return str; diff --git a/qt-ui/preferences.cpp b/qt-ui/preferences.cpp index b996bf2df..e188cdba7 100644 --- a/qt-ui/preferences.cpp +++ b/qt-ui/preferences.cpp @@ -73,6 +73,8 @@ void PreferencesDialog::setUiFromPrefs() ui.defaultfilename->setText(prefs.default_filename); ui.displayinvalid->setChecked(prefs.show_invalid); ui.show_time->setChecked(prefs.show_time); + ui.vertical_speed_minutes->setChecked(prefs.units.vertical_speed_time == units::MINUTES); + ui.vertical_speed_seconds->setChecked(prefs.units.vertical_speed_time == units::SECONDS); } void PreferencesDialog::restorePrefs() @@ -109,6 +111,7 @@ void PreferencesDialog::setPrefsFromUi() prefs.units.pressure = ui.psi->isChecked() ? units::PSI : units::BAR; prefs.units.volume = ui.cuft->isChecked() ? units::CUFT : units::LITER; prefs.units.weight = ui.lbs->isChecked() ? units::LBS : units::KG; + prefs.units.vertical_speed_time = ui.vertical_speed_minutes->isChecked() ? units::MINUTES : units::SECONDS; prefs.divelist_font = strdup(ui.font->font().family().toUtf8().data()); prefs.font_size = ui.fontsize->value(); prefs.default_filename = strdup(ui.defaultfilename->text().toUtf8().data()); @@ -151,6 +154,7 @@ void PreferencesDialog::syncSettings() s.setValue("pressure", ui.psi->isChecked() ? units::PSI : units::BAR); s.setValue("volume", ui.cuft->isChecked() ? units::CUFT : units::LITER); s.setValue("weight", ui.lbs->isChecked() ? units::LBS : units::KG); + s.setValue("vertical_speed_time", ui.vertical_speed_minutes->isChecked() ? units::MINUTES : units::SECONDS); s.endGroup(); // Defaults s.beginGroup("GeneralSettings"); diff --git a/qt-ui/preferences.ui b/qt-ui/preferences.ui index 55076235d..18767a790 100644 --- a/qt-ui/preferences.ui +++ b/qt-ui/preferences.ui @@ -402,6 +402,46 @@ </widget> </item> <item> + <layout class="QHBoxLayout"> + <item> + <widget class="QGroupBox"> + <property name="title"> + <string>Time units</string> + </property> + <layout class="QGridLayout"> + <item row="0" column="0"> + <widget class="QLabel"> + <property name="text"> + <string>Ascent/Descent speed denominator</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QRadioButton" name="vertical_speed_minutes"> + <property name="text"> + <string>Minutes</string> + </property> + <attribute name="buttonGroup"> + <string notr="true">verticalSpeed</string> + </attribute> + </widget> + </item> + <item row="0" column="2"> + <widget class="QRadioButton" name="vertical_speed_seconds"> + <property name="text"> + <string>Seconds</string> + </property> + <attribute name="buttonGroup"> + <string notr="true">verticalSpeed</string> + </attribute> + </widget> + </item> + </layout> + </widget> + </item> + </layout> + </item> + <item> <spacer name="verticalSpacer"> <property name="orientation"> <enum>Qt::Vertical</enum> @@ -414,19 +454,6 @@ </property> </spacer> </item> - <item> - <spacer name="horizontalSpacer"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> </layout> </widget> <widget class="QWidget" name="page_3"> @@ -999,5 +1026,6 @@ <buttongroup name="buttonGroup_5"/> <buttongroup name="buttonGroup"/> <buttongroup name="buttonGroup_6"/> + <buttongroup name="verticalSpeed"/> </buttongroups> </ui> diff --git a/xslt/SuuntoSDM.xslt b/xslt/SuuntoSDM.xslt index 7256952de..5c3b17373 100644 --- a/xslt/SuuntoSDM.xslt +++ b/xslt/SuuntoSDM.xslt @@ -62,10 +62,10 @@ </xsl:otherwise> </xsl:choose> - <xsl:if test="WEIGTH != ''"> + <xsl:if test="WEIGHT != ''"> <weightsystem> <xsl:attribute name="weight"> - <xsl:value-of select="concat(translate(WEIGTH, ',', '.'), ' kg')"/> + <xsl:value-of select="concat(translate(WEIGHT, ',', '.'), ' kg')"/> </xsl:attribute> </weightsystem> </xsl:if> |