Fix display of fractional seconds in block hover cursor.

There are two paths to displaying the power/time overlay on a workout block:
* Hover over the block
* Select the qwkcode line corresponding to the block

Both of these paths had their own uniquely flawed method of calculating the block duration to display. The first path stored the previous time point as a truncated integer number of seconds, then subtracted it from the current, double precision time point. This resulted in occasional over-reported durations. The second path took the double precision difference between the current and previous time points, then truncated that difference for display. This resulted in occasional under-reported durations.

Both of these paths now consistently report the same value. The value shown will take the format ss.s for times less than 60s, or hh:mm:ss for times 60s or more.
This commit is contained in:
bgrabow
2016-11-29 03:48:35 -06:00
parent f7f1b600f3
commit 5fa68063b4

View File

@@ -795,8 +795,8 @@ WorkoutWidget::setBlockCursor()
bool returning=false;
QPointF last(0,0);
int lastx=0;
int lasty=0;
double lastx=0;
double lasty=0;
int hoveri=-1;
foreach(WWPoint *p, points_) {
@@ -1917,7 +1917,7 @@ WorkoutWidget::hoverQwkcode()
for (int i=from; i<=to; i++) {
if (i>from) {
int time= points_[i]->x - points_[i-1]->x;
double time = points_[i]->x - points_[i-1]->x;
sumTime += time;
sumJoules += time * ((points_[i]->y + points_[i-1]->y)/2);
}