mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 22:33:24 +00:00
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.giorgio@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
166d587197
commit
44bdcffcd4
3 changed files with 20 additions and 9 deletions
|
@ -609,9 +609,13 @@ void MainTab::updateDiveInfo(bool clear)
|
||||||
ui.gasUsedText->setText(volumes);
|
ui.gasUsedText->setText(volumes);
|
||||||
ui.oxygenHeliumText->setText(gaslist);
|
ui.oxygenHeliumText->setText(gaslist);
|
||||||
ui.dateText->setText(get_short_dive_date_string(displayed_dive.when));
|
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)
|
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
|
else
|
||||||
ui.surfaceIntervalText->clear();
|
ui.surfaceIntervalText->clear();
|
||||||
if (mean[0])
|
if (mean[0])
|
||||||
|
@ -662,14 +666,14 @@ void MainTab::updateDiveInfo(bool clear)
|
||||||
ui.tempLimits->overrideMaxToolTipText(tr("Highest temperature"));
|
ui.tempLimits->overrideMaxToolTipText(tr("Highest temperature"));
|
||||||
ui.tempLimits->overrideMinToolTipText(tr("Lowest temperature"));
|
ui.tempLimits->overrideMinToolTipText(tr("Lowest temperature"));
|
||||||
ui.tempLimits->overrideAvgToolTipText(tr("Average temperature of all selected dives"));
|
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;
|
int seconds = stats_selection.total_time.seconds;
|
||||||
if (stats_selection.selection_size)
|
if (stats_selection.selection_size)
|
||||||
seconds /= 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) {
|
if (amount_selected > 1) {
|
||||||
ui.timeLimits->setMaximum(get_time_string(stats_selection.longest_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(stats_selection.shortest_time.seconds, 0));
|
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->overrideMaxToolTipText(tr("Longest dive"));
|
||||||
ui.timeLimits->overrideMinToolTipText(tr("Shortest dive"));
|
ui.timeLimits->overrideMinToolTipText(tr("Shortest dive"));
|
||||||
|
|
|
@ -207,7 +207,7 @@ void process_selected_dives(void)
|
||||||
stats_selection.selection_size = nr;
|
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];
|
static char buf[80];
|
||||||
if (maxdays && seconds > 3600 * 24 * maxdays) {
|
if (maxdays && seconds > 3600 * 24 * maxdays) {
|
||||||
|
@ -216,10 +216,14 @@ char *get_time_string(int seconds, int maxdays)
|
||||||
int days = seconds / 3600 / 24;
|
int days = seconds / 3600 / 24;
|
||||||
int hours = (seconds - days * 3600 * 24) / 3600;
|
int hours = (seconds - days * 3600 * 24) / 3600;
|
||||||
int minutes = (seconds - days * 3600 * 24 - hours * 3600) / 60;
|
int minutes = (seconds - days * 3600 * 24 - hours * 3600) / 60;
|
||||||
|
int secs = (seconds - days * 3600 * 24 - hours * 3600 - minutes*60);
|
||||||
if (days > 0)
|
if (days > 0)
|
||||||
snprintf(buf, sizeof(buf), translate("gettextFromC", "%dd %dh %dmin"), days, hours, minutes);
|
snprintf(buf, sizeof(buf), translate("gettextFromC", "%dd %dh %dmin"), days, hours, minutes);
|
||||||
else
|
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;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ extern stats_t *stats_yearly;
|
||||||
extern stats_t *stats_monthly;
|
extern stats_t *stats_monthly;
|
||||||
extern stats_t *stats_by_trip;
|
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 char *get_minutes(int seconds);
|
||||||
extern void process_all_dives(struct dive *dive, struct dive **prev_dive);
|
extern void process_all_dives(struct dive *dive, struct dive **prev_dive);
|
||||||
extern void get_selected_dives_text(char *buffer, int size);
|
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);
|
extern void process_selected_dives(void);
|
||||||
void selected_dives_gas_parts(volume_t *o2_tot, volume_t *he_tot);
|
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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Reference in a new issue