double Status::getAverageDuration() const {
quint64 time = getTimeSpentCycling();
quint64 count = Status::getJourneyCount();
+ double average = 0.0;
- return ((double)time / (double)count);
+ if (count > 0) {
+ average = ((double)time / (double)count);
+ }
+ else {
+ average = 0.0;
+ }
+
+ return average;
}
double Status::getSpeedPercentile() const {
overtakenby += journey.getOvertakenBy();
}
- percentile = (double)overtook / (double)(overtook + overtakenby);
+ if (overtook + overtakenby > 0.0) {
+ percentile = (double)overtook / (double)(overtook + overtakenby);
+ }
+ else {
+ percentile = 0.0;
+ }
return percentile;
}
portion = (unit == max - 1) ? remaining : remaining % base[unit];
portions << portion;
remaining /= base[unit];
- qDebug() << plural[unit] << ": " << portion;
}
formatted = "";
}
}
+ if (formatted == "") {
+ formatted = "None";
+ }
+
return formatted;
}
+QList<float> Status::getGraphData() {
+ static QList<float> data({0.1, 0.2, 0.3, 0.4, 1.0, 0.8, 0.7, 0.9, 0.5, 1.0});
+
+ return data;
+}