diff --git a/src/gui/RideItem.cpp b/src/gui/RideItem.cpp
index 204b5aff8..abf96005f 100644
--- a/src/gui/RideItem.cpp
+++ b/src/gui/RideItem.cpp
@@ -121,146 +121,151 @@ RideItem::htmlSummary()
+ "
Summary
");
if (raw == NULL) {
summary += "Error: Can't read file.";
+ return summary;
}
- else if (errors.empty()) {
- double secs_moving = 0.0;
- double total_watts = 0.0;
- double secs_watts = 0.0;
- double avg_watts = 0.0;
- double secs_hr = 0.0;
- double total_hr = 0.0;
- double secs_cad = 0.0;
- double total_cad = 0.0;
- double last_secs = 0.0;
- QString intervals = "";
- unsigned last_interval = UINT_MAX;
- double int_watts_sum = 0.0;
- unsigned int_watts_cnt = 0;
- double int_hr_sum = 0.0;
- unsigned int_hr_cnt = 0;
- double int_cad_sum = 0.0;
- unsigned int_cad_cnt = 0;
- double int_mph_sum = 0.0;
- unsigned int_mph_cnt = 0;
+ double secs_moving_or_pedaling = 0.0;
+ double secs_moving = 0.0;
+ double total_watts = 0.0;
+ double secs_watts = 0.0;
+ double avg_watts = 0.0;
+ double secs_hr = 0.0;
+ double total_hr = 0.0;
+ double secs_cad = 0.0;
+ double total_cad = 0.0;
+ double last_secs = 0.0;
- double time_start, time_end, mile_start, mile_end;
+ QString intervals = "";
+ unsigned last_interval = UINT_MAX;
+ double int_watts_sum = 0.0;
+ unsigned int_watts_cnt = 0;
+ double int_hr_sum = 0.0;
+ unsigned int_hr_cnt = 0;
+ double int_cad_sum = 0.0;
+ unsigned int_cad_cnt = 0;
+ double int_mph_sum = 0.0;
+ unsigned int_mph_cnt = 0;
- QListIterator i(raw->points);
- while (i.hasNext()) {
- RawFilePoint *point = i.next();
+ double time_start, time_end, mile_start, mile_end;
- if (point->interval != last_interval) {
+ QListIterator i(raw->points);
+ while (i.hasNext()) {
+ RawFilePoint *point = i.next();
- if (last_interval != UINT_MAX) {
- summarize(intervals, last_interval, time_start,
- time_end, mile_start, mile_end,
- int_watts_cnt, int_watts_sum, int_hr_cnt,
- int_hr_sum, int_cad_cnt, int_cad_sum,
- int_mph_cnt, int_mph_sum);
- }
+ if (point->interval != last_interval) {
- last_interval = point->interval;
- time_start = point->secs;
- mile_start = point->miles;
+ if (last_interval != UINT_MAX) {
+ summarize(intervals, last_interval, time_start,
+ time_end, mile_start, mile_end,
+ int_watts_cnt, int_watts_sum, int_hr_cnt,
+ int_hr_sum, int_cad_cnt, int_cad_sum,
+ int_mph_cnt, int_mph_sum);
}
- double secs_delta = point->secs - last_secs;
- if (point->mph > 0.0)
- secs_moving += secs_delta;
- if (point->watts >= 0.0) {
- total_watts += point->watts * secs_delta;
- secs_watts += secs_delta;
- int_watts_sum += point->watts;
- int_watts_cnt += 1;
- }
- if (point->hr > 0) {
- total_hr += point->hr * secs_delta;
- secs_hr += secs_delta;
- int_hr_sum += point->hr;
- int_hr_cnt += 1;
- }
- if (point->cad > 0) {
- total_cad += point->cad * secs_delta;
- secs_cad += secs_delta;
- int_cad_sum += point->cad;
- int_cad_cnt += 1;
- }
- if (point->mph >= 0) {
- int_mph_sum += point->mph;
- int_mph_cnt += 1;
- }
-
- last_secs = point->secs;
- mile_end = point->miles;
- time_end = point->secs;
+ last_interval = point->interval;
+ time_start = point->secs;
+ mile_start = point->miles;
}
- summarize(intervals, last_interval, time_start,
- time_end, mile_start, mile_end,
- int_watts_cnt, int_watts_sum, int_hr_cnt,
- int_hr_sum, int_cad_cnt, int_cad_sum,
- int_mph_cnt, int_mph_sum);
+ double secs_delta = point->secs - last_secs;
+ if ((point->mph > 0.0) || (point->cad > 0.0))
+ secs_moving_or_pedaling += secs_delta;
+ if (point->mph > 0.0)
+ secs_moving += secs_delta;
+ if (point->watts >= 0.0) {
+ total_watts += point->watts * secs_delta;
+ secs_watts += secs_delta;
+ int_watts_sum += point->watts;
+ int_watts_cnt += 1;
+ }
+ if (point->hr > 0) {
+ total_hr += point->hr * secs_delta;
+ secs_hr += secs_delta;
+ int_hr_sum += point->hr;
+ int_hr_cnt += 1;
+ }
+ if (point->cad > 0) {
+ total_cad += point->cad * secs_delta;
+ secs_cad += secs_delta;
+ int_cad_sum += point->cad;
+ int_cad_cnt += 1;
+ }
+ if (point->mph >= 0) {
+ int_mph_sum += point->mph;
+ int_mph_cnt += 1;
+ }
- avg_watts = (secs_watts == 0.0) ? 0.0
- : round(total_watts / secs_watts);
+ last_secs = point->secs;
+ mile_end = point->miles;
+ time_end = point->secs;
+ }
- summary += "";
- summary += "| Total workout time: | " +
- time_to_string(raw->points.back()->secs);
- summary += " |
| Total time riding: | " +
- time_to_string(secs_moving) + " |
";
- summary += QString("| Total distance (miles): | "
- "%1 |
")
- .arg(raw->points.back()->miles, 0, 'f', 1);
- summary += QString("| Total work (kJ): | "
- "%1 |
")
- .arg((unsigned) (avg_watts / 1000.0 * secs_moving));
- summary += QString("| Average speed (mph): | "
- "%1 |
")
- .arg(((secs_moving == 0.0) ? 0.0
- : raw->points.back()->miles / secs_moving * 3600.0),
- 0, 'f', 1);
- summary += QString("| Average power (watts): | "
- "%1 |
")
- .arg((unsigned) avg_watts);
- summary +=QString("| Average heart rate (bpm): | "
- "%1 |
")
- .arg((unsigned) ((secs_hr == 0.0) ? 0.0
- : round(total_hr / secs_hr)));
- summary += QString("| Average cadence (rpm): | "
- "%1 |
")
- .arg((unsigned) ((secs_cad == 0.0) ? 0.0
- : round(total_cad / secs_cad)));
+ summarize(intervals, last_interval, time_start,
+ time_end, mile_start, mile_end,
+ int_watts_cnt, int_watts_sum, int_hr_cnt,
+ int_hr_sum, int_cad_cnt, int_cad_sum,
+ int_mph_cnt, int_mph_sum);
+
+ avg_watts = (secs_watts == 0.0) ? 0.0
+ : round(total_watts / secs_watts);
+
+ summary += "";
+ summary += "| Total workout time: | " +
+ time_to_string(raw->points.back()->secs);
+ summary += " |
| Total time riding: | " +
+ time_to_string(secs_moving_or_pedaling) + " |
";
+ summary += QString("| Total distance (miles): | "
+ "%1 |
")
+ .arg(raw->points.back()->miles, 0, 'f', 1);
+ summary += QString("| Total work (kJ): | "
+ "%1 |
")
+ .arg((unsigned) (avg_watts / 1000.0 * secs_moving_or_pedaling));
+ summary += QString("| Average speed (mph): | "
+ "%1 |
")
+ .arg(((secs_moving == 0.0) ? 0.0
+ : raw->points.back()->miles / secs_moving * 3600.0),
+ 0, 'f', 1);
+ summary += QString("| Average power (watts): | "
+ "%1 |
")
+ .arg((unsigned) avg_watts);
+ summary +=QString("| Average heart rate (bpm): | "
+ "%1 |
")
+ .arg((unsigned) ((secs_hr == 0.0) ? 0.0
+ : round(total_hr / secs_hr)));
+ summary += QString("| Average cadence (rpm): | "
+ "%1 |
")
+ .arg((unsigned) ((secs_cad == 0.0) ? 0.0
+ : round(total_cad / secs_cad)));
+ summary += "
";
+
+ if (last_interval > 0) {
+ summary += "Intervals
\n\n";
+ summary += "
";
+ summary += "| Interval | ";
+ summary += " | ";
+ summary += "Distance | ";
+ summary += "Work | ";
+ summary += "Avg Power | ";
+ summary += "Avg HR | ";
+ summary += "Avg Cadence | ";
+ summary += "Avg Speed | ";
+ summary += "
";
+ summary += "| Number | ";
+ summary += "Duration | ";
+ summary += "(miles) | ";
+ summary += "(kJ) | ";
+ summary += "(watts) | ";
+ summary += "(bpm) | ";
+ summary += "(rpm) | ";
+ summary += "(mph) | ";
+ summary += "
";
+ summary += intervals;
summary += "
";
-
- if (last_interval > 0) {
- summary += "Intervals
\n\n";
- summary += "
";
- summary += "| Interval | ";
- summary += " | ";
- summary += "Distance | ";
- summary += "Work | ";
- summary += "Avg Power | ";
- summary += "Avg HR | ";
- summary += "Avg Cadence | ";
- summary += "Avg Speed | ";
- summary += "
";
- summary += "| Number | ";
- summary += "Duration | ";
- summary += "(miles) | ";
- summary += "(kJ) | ";
- summary += "(watts) | ";
- summary += "(bpm) | ";
- summary += "(rpm) | ";
- summary += "(mph) | ";
- summary += "
";
- summary += intervals;
- summary += "
";
- }
}
- else {
- summary += "
Errors reading file:";
+
+ if (!errors.empty()) {
+ summary += "Errors reading file:
";
QStringListIterator i(errors);
while(i.hasNext())
summary += " - " + i.next();