Now that the new release is out, could we consider adding those patches to the next minor?
G ---------- Forwarded message ---------- From: Giorgio Marzano <marzano.gior...@gmail.com> Date: 2015-10-11 23:40 GMT+02:00 Subject: minor [PATCHES] for freediving To: Subsurface Mailing List <subsurface@subsurface-divelog.org> Hi, I know that this is something which won't be merged before the next release, but I would like to propose those patches for a (low priority) review. They are all easy, cosmetic and freedive specific (no impact on scuba) 0001-Change-plot-scaling-to-handle-FREEDIVE-mode hacks the autoscaling function to produce better result for the usually very short freedives 0001-Display-day-number-in-trips-longer-than-1-day is the old patch to add some info in the trip header. I only rebased it to the last master 0001-Display-divetime-according-to-dive-mode-and-translat changes, for freedive mode, the time strings in the info and statistics tab. For us seconds may be very relevant. 0001-Enable-Disable-toolbar-element-in-freedive-mode disable some toolbar element for freedive mode. I found very disturbing those buttons which are, for me, of no use. I would like, in the future, to understand how ppO2 and similar are different in scuba and freediving. It would be important to represent them in a correct way, to profile the risk of "taravana" (something like the decompression disease but for freedivers) G
From 6c91115e393c6dfa7743072c0f5e868ad260e09e Mon Sep 17 00:00:00 2001 From: Giorgio Marzano <marzano.gior...@gmail.com> Date: Tue, 6 Oct 2015 21:08:27 +0200 Subject: [PATCH] Display day number in trips longer than 1 day Signed-off-by: Giorgio Marzano <marzano.gior...@gmail.com> --- helpers.h | 3 ++- qt-models/divetripmodel.cpp | 6 ++++-- qthelper.cpp | 37 +++++++++++++++++++++++++++++-------- 3 files changed, 35 insertions(+), 11 deletions(-) diff --git a/helpers.h b/helpers.h index 6c5c31c..760d962 100644 --- a/helpers.h +++ b/helpers.h @@ -33,7 +33,8 @@ int parseTemperatureToMkelvin(const QString &text); QString get_dive_duration_string(timestamp_t when, QString hourText, QString minutesText); QString get_dive_date_string(timestamp_t when); QString get_short_dive_date_string(timestamp_t when); -QString get_trip_date_string(timestamp_t when, int nr); +bool is_same_day (timestamp_t trip_when, timestamp_t dive_when); +QString get_trip_date_string(timestamp_t when, int nr, bool getday); QString uiLanguage(QLocale *callerLoc); QLocale getLocale(); QString getDateFormat(); diff --git a/qt-models/divetripmodel.cpp b/qt-models/divetripmodel.cpp index 819bb54..78a7a74 100644 --- a/qt-models/divetripmodel.cpp +++ b/qt-models/divetripmodel.cpp @@ -43,6 +43,7 @@ static QVariant dive_table_alignment(int column) QVariant TripItem::data(int column, int role) const { QVariant ret; + bool oneDayTrip=true; if (role == DiveTripModel::TRIP_ROLE) return QVariant::fromValue<void *>(trip); @@ -59,14 +60,15 @@ QVariant TripItem::data(int column, int role) const while (d) { if (!d->hidden_by_filter) countShown++; + oneDayTrip &= is_same_day (trip->when, d->when); d = d->next; } if (countShown < trip->nrdives) shownText = tr("(%1 shown)").arg(countShown); if (trip->location && *trip->location) - ret = QString(trip->location) + ", " + get_trip_date_string(trip->when, trip->nrdives) + " " + shownText; + ret = QString(trip->location) + ", " + get_trip_date_string(trip->when, trip->nrdives, oneDayTrip) + " "+ shownText; else - ret = get_trip_date_string(trip->when, trip->nrdives) + shownText; + ret = get_trip_date_string(trip->when, trip->nrdives, oneDayTrip) + shownText; break; } } diff --git a/qthelper.cpp b/qthelper.cpp index a963ad7..dd5f974 100644 --- a/qthelper.cpp +++ b/qthelper.cpp @@ -1011,20 +1011,41 @@ const char *get_dive_date_c_string(timestamp_t when) return strdup(text.toUtf8().data()); } -QString get_trip_date_string(timestamp_t when, int nr) +bool is_same_day(timestamp_t trip_when, timestamp_t dive_when) +{ + static timestamp_t twhen = (timestamp_t) 0; + static struct tm tmt; + struct tm tmd; + + utc_mkdate(dive_when, &tmd); + + if (twhen != trip_when) { + twhen = trip_when; + utc_mkdate(twhen, &tmt); + } + + return ((tmd.tm_mday == tmt.tm_mday) && (tmd.tm_mon == tmt.tm_mon) && (tmd.tm_year == tmt.tm_year)); +} + +QString get_trip_date_string(timestamp_t when, int nr, bool getday) { struct tm tm; utc_mkdate(when, &tm); + QDateTime localTime = QDateTime::fromTime_t(when); + localTime.setTimeSpec(Qt::UTC); + QString ret ; + if (nr != 1) { - QString ret = translate("gettextFromC", "%1 %2 (%3 dives)"); - return ret.arg(monthname(tm.tm_mon)) - .arg(tm.tm_year + 1900) - .arg(nr); + if (getday) { + ret = localTime.date().toString(dateFormat).append(" (%1 dives)").arg(nr); + } else { + ret = localTime.date().toString("MMM yy").append(" (%1 dives)").arg(nr); + } } else { - QString ret = translate("gettextFromC", "%1 %2 (1 dive)"); - return ret.arg(monthname(tm.tm_mon)) - .arg(tm.tm_year + 1900); + ret = localTime.date().toString(dateFormat).append(" (1 dive)"); } + return ret; + } extern "C" void reverseGeoLookup(degrees_t latitude, degrees_t longitude, uint32_t uuid) -- 1.9.1
From d271c1c31ee63c7425371e004e75d42364ce00fa Mon Sep 17 00:00:00 2001 From: Giorgio Marzano <marzano.gior...@gmail.com> Date: Sun, 11 Oct 2015 22:24:35 +0200 Subject: [PATCH] Enable/Disable toolbar element in freedive mode Signed-off-by: Giorgio Marzano <marzano.gior...@gmail.com> --- qt-ui/mainwindow.cpp | 49 ++++++++++++++++++++++++++++++++++++++++++++++++- qt-ui/mainwindow.h | 1 + 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index f9bfd77..14c604e 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -114,7 +114,6 @@ MainWindow::MainWindow() : QMainWindow(), toolBar->addAction(a); toolBar->setOrientation(Qt::Vertical); toolBar->setIconSize(QSize(24,24)); - QWidget *profileContainer = new QWidget(); QHBoxLayout *profLayout = new QHBoxLayout(); profLayout->setSpacing(0); @@ -249,6 +248,7 @@ MainWindow::MainWindow() : QMainWindow(), ui.actionFacebook->setEnabled(false); #endif + ui.menubar->show(); set_git_update_cb(&updateProgress); } @@ -333,6 +333,48 @@ void MainWindow::recreateDiveList() SuitsFilterModel::instance()->repopulate(); } +void MainWindow::configureToolbar() { + if (selected_dive>0) { + if (current_dive->dc.divemode == FREEDIVE) { + ui.profCalcCeiling->setDisabled(true); + ui.profCalcAllTissues ->setDisabled(true); + ui.profIncrement3m->setDisabled(true); + ui.profDcCeiling->setDisabled(true); + ui.profPhe->setDisabled(true); + ui.profPn2->setDisabled(true); //TODO is the same as scuba? + ui.profPO2->setDisabled(true); //TODO is the same as scuba? + ui.profRuler->setDisabled(false); + ui.profScaled->setDisabled(false); // measuring and scaling + ui.profTogglePicture->setDisabled(false); + ui.profTankbar->setDisabled(true); + ui.profMod->setDisabled(true); + ui.profNdl_tts->setDisabled(true); + ui.profEad->setDisabled(true); + ui.profSAC->setDisabled(true); + ui.profHR->setDisabled(false); + ui.profTissues->setDisabled(true); + } else { + ui.profCalcCeiling->setDisabled(false); + ui.profCalcAllTissues ->setDisabled(false); + ui.profIncrement3m->setDisabled(false); + ui.profDcCeiling->setDisabled(false); + ui.profPhe->setDisabled(false); + ui.profPn2->setDisabled(false); + ui.profPO2->setDisabled(false); // partial pressure graphs + ui.profRuler->setDisabled(false); + ui.profScaled->setDisabled(false); // measuring and scaling + ui.profTogglePicture->setDisabled(false); + ui.profTankbar->setDisabled(false); + ui.profMod->setDisabled(false); + ui.profNdl_tts->setDisabled(false); // various values that a user is either interested in or not + ui.profEad->setDisabled(false); + ui.profSAC->setDisabled(false); + ui.profHR->setDisabled(false); // very few dive computers support this + ui.profTissues->setDisabled(false);; // maybe less frequently used + } + } +} + void MainWindow::current_dive_changed(int divenr) { if (divenr >= 0) { @@ -340,6 +382,7 @@ void MainWindow::current_dive_changed(int divenr) } graphics()->plotDive(); information()->updateDiveInfo(); + configureToolbar(); GlobeGPS::instance()->reload(); } @@ -652,6 +695,7 @@ bool MainWindow::plannerStateClean() void MainWindow::refreshProfile() { showProfile(); + configureToolbar(); graphics()->replot(get_dive(selected_dive)); DivePictureModel::instance()->updateDivePictures(); } @@ -787,6 +831,7 @@ void MainWindow::on_actionAddDive_triggered() graphics()->setAddState(); DivePlannerPointsModel::instance()->createSimpleDive(); + configureToolbar(); graphics()->plotDive(); } @@ -965,6 +1010,7 @@ void MainWindow::on_actionPreviousDC_triggered() { unsigned nrdc = number_of_computers(current_dive); dc_number = (dc_number + nrdc - 1) % nrdc; + configureToolbar(); graphics()->plotDive(); information()->updateDiveInfo(); } @@ -973,6 +1019,7 @@ void MainWindow::on_actionNextDC_triggered() { unsigned nrdc = number_of_computers(current_dive); dc_number = (dc_number + 1) % nrdc; + configureToolbar(); graphics()->plotDive(); information()->updateDiveInfo(); } diff --git a/qt-ui/mainwindow.h b/qt-ui/mainwindow.h index 14aa22f..02ec247 100644 --- a/qt-ui/mainwindow.h +++ b/qt-ui/mainwindow.h @@ -224,6 +224,7 @@ private: bool plannerStateClean(); void setupForAddAndPlan(const char *model); + void configureToolbar(); QDialog *survey; struct dive copyPasteDive; struct dive_components what; -- 1.9.1
From 6cfd5fa473517d8187929f36ce9b2528a7cf75dd Mon Sep 17 00:00:00 2001 From: Giorgio Marzano <marzano.gior...@gmail.com> Date: Sun, 11 Oct 2015 15:37:28 +0200 Subject: [PATCH] Display divetime according to dive mode and translation Many time stats in maintab display also seconds in short freediving Signed-off-by: Giorgio Marzano <marzano.gior...@gmail.com> --- qt-ui/maintab.cpp | 15 +++++++++------ statistics.c | 8 ++++++-- statistics.h | 5 ++++- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index e97812c..bebebe4 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -609,9 +609,12 @@ void MainTab::updateDiveInfo(bool clear) ui.gasUsedText->setText(volumes); ui.oxygenHeliumText->setText(gaslist); ui.dateText->setText(get_short_dive_date_string(displayed_dive.when)); - ui.diveTimeText->setText(QString::number((int)((displayed_dive.duration.seconds + 30) / 60))); + if (displayed_dive.dc.divemode != FREEDIVE) + ui.diveTimeText->setText(get_time_string_s(displayed_dive.duration.seconds + 30, 0, false)); + else + ui.diveTimeText->setText(get_time_string_s(displayed_dive.duration.seconds, 0, true)); if (prevd) - ui.surfaceIntervalText->setText(get_time_string(displayed_dive.when - (prevd->when + prevd->duration.seconds), 4)); + ui.surfaceIntervalText->setText(get_time_string_s(displayed_dive.when - (prevd->when + prevd->duration.seconds), 4,(displayed_dive.dc.divemode == FREEDIVE))); else ui.surfaceIntervalText->clear(); if (mean[0]) @@ -662,14 +665,14 @@ void MainTab::updateDiveInfo(bool clear) ui.tempLimits->overrideMaxToolTipText(tr("Highest temperature")); ui.tempLimits->overrideMinToolTipText(tr("Lowest temperature")); ui.tempLimits->overrideAvgToolTipText(tr("Average temperature of all selected dives")); - ui.totalTimeAllText->setText(get_time_string(stats_selection.total_time.seconds, 0)); + ui.totalTimeAllText->setText(get_time_string_s(stats_selection.total_time.seconds, 0,(displayed_dive.dc.divemode == FREEDIVE))); int seconds = stats_selection.total_time.seconds; if (stats_selection.selection_size) seconds /= stats_selection.selection_size; - ui.timeLimits->setAverage(get_time_string(seconds, 0)); + ui.timeLimits->setAverage(get_time_string_s(seconds, 0,(displayed_dive.dc.divemode == FREEDIVE))); if (amount_selected > 1) { - ui.timeLimits->setMaximum(get_time_string(stats_selection.longest_time.seconds, 0)); - ui.timeLimits->setMinimum(get_time_string(stats_selection.shortest_time.seconds, 0)); + ui.timeLimits->setMaximum(get_time_string_s(stats_selection.longest_time.seconds, 0,(displayed_dive.dc.divemode == FREEDIVE))); + ui.timeLimits->setMinimum(get_time_string_s(stats_selection.shortest_time.seconds, 0,(displayed_dive.dc.divemode == FREEDIVE))); } ui.timeLimits->overrideMaxToolTipText(tr("Longest dive")); ui.timeLimits->overrideMinToolTipText(tr("Shortest dive")); diff --git a/statistics.c b/statistics.c index 1b2a1a6..19fd350 100644 --- a/statistics.c +++ b/statistics.c @@ -207,7 +207,7 @@ void process_selected_dives(void) stats_selection.selection_size = nr; } -char *get_time_string(int seconds, int maxdays) +char *get_time_string_s(int seconds, int maxdays, bool freediving) { static char buf[80]; if (maxdays && seconds > 3600 * 24 * maxdays) { @@ -216,10 +216,14 @@ char *get_time_string(int seconds, int maxdays) int days = seconds / 3600 / 24; int hours = (seconds - days * 3600 * 24) / 3600; int minutes = (seconds - days * 3600 * 24 - hours * 3600) / 60; + int secs = (seconds - days * 3600 * 24 - hours * 3600 - minutes*60); if (days > 0) snprintf(buf, sizeof(buf), translate("gettextFromC", "%dd %dh %dmin"), days, hours, minutes); else - snprintf(buf, sizeof(buf), translate("gettextFromC", "%dh %dmin"), hours, minutes); + if (freediving && seconds < 3600) + snprintf(buf, sizeof(buf), translate("gettextFromC", "%dmin %dsecs"), minutes, secs); + else + snprintf(buf, sizeof(buf), translate("gettextFromC", "%dh %dmin"), hours, minutes); } return buf; } diff --git a/statistics.h b/statistics.h index 4d14139..dbab257 100644 --- a/statistics.h +++ b/statistics.h @@ -40,7 +40,7 @@ extern stats_t *stats_yearly; extern stats_t *stats_monthly; extern stats_t *stats_by_trip; -extern char *get_time_string(int seconds, int maxdays); +extern char *get_time_string_s(int seconds, int maxdays, bool freediving); extern char *get_minutes(int seconds); extern void process_all_dives(struct dive *dive, struct dive **prev_dive); extern void get_selected_dives_text(char *buffer, int size); @@ -48,6 +48,9 @@ extern void get_gas_used(struct dive *dive, volume_t gases[MAX_CYLINDERS]); extern void process_selected_dives(void); void selected_dives_gas_parts(volume_t *o2_tot, volume_t *he_tot); +inline char *get_time_string(int seconds, int maxdays) { + return get_time_string_s( seconds, maxdays, false); +} #ifdef __cplusplus } #endif -- 1.9.1
From 372547c7e1749fc3b320b7b9f11b10ae8345c8b5 Mon Sep 17 00:00:00 2001 From: Giorgio Marzano <marzano.gior...@gmail.com> Date: Sun, 11 Oct 2015 12:16:48 +0200 Subject: [PATCH] Change plot scaling to handle FREEDIVE mode Add FREEDIVING value to plot_info::plot_type Signed-off-by: Giorgio Marzano <marzano.gior...@gmail.com> --- display.h | 2 +- profile.c | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/display.h b/display.h index 59dd97e..9e3e1d1 100644 --- a/display.h +++ b/display.h @@ -21,7 +21,7 @@ struct plot_info { int minpressure, maxpressure; int minhr, maxhr; int mintemp, maxtemp; - enum {AIR, NITROX, TRIMIX} dive_type; + enum {AIR, NITROX, TRIMIX, FREEDIVING} dive_type; double endtempcoord; double maxpp; bool has_ndl; diff --git a/profile.c b/profile.c index cad7687..8b190d3 100644 --- a/profile.c +++ b/profile.c @@ -64,6 +64,10 @@ static void dump_pi(struct plot_info *pi) int get_maxtime(struct plot_info *pi) { int seconds = pi->maxtime; + + int DURATION_THR = (pi->dive_type == FREEDIVING ? 60 : 600); + int CEILING = (pi->dive_type == FREEDIVING ? 30 : 60); + if (prefs.zoomed_plot) { /* Rounded up to one minute, with at least 2.5 minutes to * spare. @@ -71,13 +75,13 @@ int get_maxtime(struct plot_info *pi) * calculate the space dynamically. * This is seamless since 600/4 = 150. */ - if (seconds < 600) - return ROUND_UP(seconds + seconds / 4, 60); + if (seconds < DURATION_THR) + return ROUND_UP(seconds + seconds / 4, CEILING); else - return ROUND_UP(seconds + 150, 60); + return ROUND_UP(seconds + DURATION_THR/4, CEILING); } else { /* min 30 minutes, rounded up to 5 minutes, with at least 2.5 minutes to spare */ - return MAX(30 * 60, ROUND_UP(seconds + 150, 60 * 5)); + return MAX(30 * 60, ROUND_UP(seconds + DURATION_THR/4, CEILING * 5)); } } @@ -1067,7 +1071,9 @@ void create_plot_info_new(struct dive *dive, struct divecomputer *dc, struct plo free((void *)last_pi_entry_new); get_dive_gas(dive, &o2, &he, &o2max); - if (he > 0) { + if (dc->divemode == FREEDIVE){ + pi->dive_type = FREEDIVE; + } else if (he > 0) { pi->dive_type = TRIMIX; } else { if (o2) @@ -1075,6 +1081,7 @@ void create_plot_info_new(struct dive *dive, struct divecomputer *dc, struct plo else pi->dive_type = AIR; } + last_pi_entry_new = populate_plot_entries(dive, dc, pi); check_gas_change_events(dive, dc, pi); /* Populate the gas index from the gas change events */ -- 1.9.1
_______________________________________________ subsurface mailing list subsurface@subsurface-divelog.org http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface