mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Do not remove seconds from duration input field
This change deals with issue #554. If you enter a dive duration manually, the cell renderer cuts the seconds away when the changes are saved. I added the helper "render_seconds_to_string" as a counterpart to "parseDurationToSeconds". The helper keeps the seconds, if not null. The rendering of the cell is done at two places in the code, so I think it is cleaner to add a dedicated method for it. Signed-off-by: Oliver Schwaneberg <oliver.schwaneberg@gmail.com>
This commit is contained in:
parent
a32f12592b
commit
eb38a64149
3 changed files with 11 additions and 2 deletions
|
@ -36,6 +36,7 @@ int parseWeightToGrams(const QString &text);
|
|||
int parsePressureToMbar(const QString &text);
|
||||
int parseGasMixO2(const QString &text);
|
||||
int parseGasMixHE(const QString &text);
|
||||
QString render_seconds_to_string(int seconds);
|
||||
QString get_dive_duration_string(timestamp_t when, QString hoursText, QString minutesText, QString secondsText = QObject::tr("sec"), QString separator = ":", bool isFreeDive = false);
|
||||
QString get_dive_surfint_string(timestamp_t when, QString daysText, QString hoursText, QString minutesText, QString separator = " ", int maxdays = 4);
|
||||
QString get_dive_date_string(timestamp_t when);
|
||||
|
|
|
@ -743,6 +743,14 @@ int gettimezoneoffset(timestamp_t when)
|
|||
return dt2.secsTo(dt1);
|
||||
}
|
||||
|
||||
QString render_seconds_to_string(int seconds)
|
||||
{
|
||||
if (seconds % 60 == 0)
|
||||
return QDateTime::fromTime_t(seconds).toUTC().toString("h:mm");
|
||||
else
|
||||
return QDateTime::fromTime_t(seconds).toUTC().toString("h:mm:ss");
|
||||
}
|
||||
|
||||
int parseDurationToSeconds(const QString &text)
|
||||
{
|
||||
int secs;
|
||||
|
|
|
@ -393,7 +393,7 @@ void MainTab::updateDepthDuration()
|
|||
ui.depthLabel->setVisible(true);
|
||||
ui.duration->setVisible(true);
|
||||
ui.durationLabel->setVisible(true);
|
||||
ui.duration->setText(QDateTime::fromTime_t(displayed_dive.duration.seconds).toUTC().toString("h:mm"));
|
||||
ui.duration->setText(render_seconds_to_string(displayed_dive.duration.seconds));
|
||||
ui.depth->setText(get_depth_string(displayed_dive.maxdepth, true));
|
||||
}
|
||||
|
||||
|
@ -579,7 +579,7 @@ void MainTab::updateDiveInfo(bool clear)
|
|||
ui.durationLabel->setVisible(isManual);
|
||||
}
|
||||
}
|
||||
ui.duration->setText(QDateTime::fromTime_t(displayed_dive.duration.seconds).toUTC().toString("h:mm"));
|
||||
ui.duration->setText(render_seconds_to_string(displayed_dive.duration.seconds));
|
||||
ui.depth->setText(get_depth_string(displayed_dive.maxdepth, true));
|
||||
ui.DiveType->setCurrentIndex(get_dive_dc(&displayed_dive, dc_number)->divemode);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue