mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Creation of dive duration string and surface interval string
Update the function to create the dive duration string in a way that it can be used also in info and stats tab and added some more flexibility. Changed layout for <1h freedives to "0:05:35" (w/o units) or "5:35min" (with units and :) or "5min 35sec" (with units with space). Add a new function to create the surface interval string. Completely remove old function get_time_string() and get_time_string_s(). Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
This commit is contained in:
parent
53a8075bd8
commit
e6d884cf26
13 changed files with 68 additions and 48 deletions
|
|
@ -703,7 +703,7 @@ QVariant DiveImportedModel::data(const QModelIndex &index, int role) const
|
|||
case 0:
|
||||
return QVariant(get_short_dive_date_string(d->when));
|
||||
case 1:
|
||||
return QVariant(get_dive_duration_string(d->duration.seconds, tr("h:"), tr("min")));
|
||||
return QVariant(get_dive_duration_string(d->duration.seconds, tr("h"), tr("min")));
|
||||
case 2:
|
||||
return QVariant(get_depth_string(d->maxdepth.mm, true, false));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -306,7 +306,7 @@ void SocialNetworkDialog::selectionChanged()
|
|||
}
|
||||
if (ui->duration->isChecked()) {
|
||||
fullText += tr("Duration: %1 \n").arg(get_dive_duration_string(d->duration.seconds,
|
||||
tr("h:", "abbreviation for hours plus separator"),
|
||||
tr("h", "abbreviation for hours"),
|
||||
tr("min", "abbreviation for minutes")));
|
||||
}
|
||||
if (ui->Location->isChecked()) {
|
||||
|
|
|
|||
|
|
@ -74,15 +74,15 @@ void TabDiveInformation::updateData()
|
|||
ui->gasUsedText->setText(volumes);
|
||||
ui->oxygenHeliumText->setText(gaslist);
|
||||
|
||||
int sum = displayed_dive.dc.divemode != FREEDIVE ? 30 : 0;
|
||||
ui->diveTimeText->setText(get_time_string_s(displayed_dive.duration.seconds + sum, 0, false));
|
||||
ui->diveTimeText->setText(get_dive_duration_string(displayed_dive.duration.seconds, tr("h"), tr("min"), tr("sec"),
|
||||
" ", displayed_dive.dc.divemode == FREEDIVE));
|
||||
|
||||
struct dive *prevd;
|
||||
process_all_dives(&displayed_dive, &prevd);
|
||||
|
||||
if (prevd)
|
||||
ui->surfaceIntervalText->setText(get_time_string_s(displayed_dive.when - (prevd->when + prevd->duration.seconds), 4,
|
||||
(displayed_dive.dc.divemode == FREEDIVE)));
|
||||
ui->surfaceIntervalText->setText(get_dive_surfint_string(displayed_dive.when - (prevd->when + prevd->duration.seconds), tr("d"), tr("h"), tr("min")));
|
||||
|
||||
else
|
||||
ui->surfaceIntervalText->clear();
|
||||
|
||||
|
|
|
|||
|
|
@ -84,14 +84,19 @@ void TabDiveStatistics::updateData()
|
|||
|
||||
|
||||
ui->divesAllText->setText(QString::number(stats_selection.selection_size));
|
||||
ui->totalTimeAllText->setText(get_time_string_s(stats_selection.total_time.seconds, 0, (displayed_dive.dc.divemode == FREEDIVE)));
|
||||
ui->totalTimeAllText->setText(get_dive_duration_string(stats_selection.total_time.seconds, tr("h"), tr("min"), tr("sec"),
|
||||
" ", 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_s(seconds, 0,(displayed_dive.dc.divemode == FREEDIVE)));
|
||||
ui->timeLimits->setAverage(get_dive_duration_string(seconds, tr("h"), tr("min"), tr("sec"),
|
||||
" ", displayed_dive.dc.divemode == FREEDIVE));
|
||||
if (amount_selected > 1) {
|
||||
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->setMaximum(get_dive_duration_string(stats_selection.longest_time.seconds, tr("h"), tr("min"), tr("sec"),
|
||||
" ", displayed_dive.dc.divemode == FREEDIVE));
|
||||
ui->timeLimits->setMinimum(get_dive_duration_string(stats_selection.shortest_time.seconds, tr("h"), tr("min"), tr("sec"),
|
||||
" ", displayed_dive.dc.divemode == FREEDIVE));
|
||||
} else {
|
||||
ui->timeLimits->setMaximum("");
|
||||
ui->timeLimits->setMinimum("");
|
||||
|
|
|
|||
|
|
@ -109,7 +109,8 @@ if (property == "year") {
|
|||
double temp = get_temp_units(object.year->max_temp, &unit);
|
||||
return object.year->max_temp == 0 ? "0" : QString::number(temp, 'g', 2) + unit;
|
||||
} else if (property == "total_time") {
|
||||
return get_time_string(object.year->total_time.seconds, 0);
|
||||
return get_dive_duration_string(object.year->total_time.seconds, QObject::tr("h"),
|
||||
QObject::tr("min"), QObject::tr("sec"), " ");
|
||||
} else if (property == "avg_time") {
|
||||
return get_minutes(object.year->total_time.seconds / object.year->selection_size);
|
||||
} else if (property == "shortest_time") {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue