Skip to content

Commit

Permalink
Fix display of fractional seconds in block hover cursor.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bgrabow committed Nov 29, 2016
1 parent f7f1b60 commit 5fa6806
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Train/WorkoutWidget.cpp
Expand Up @@ -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_) {
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 5fa6806

Please sign in to comment.