fix performance manager to deal with descending ride list preference.

This commit is contained in:
Robert Carlsen
2009-10-25 19:58:46 -04:00
parent 476aa1b48b
commit e7f8f9cbd1
3 changed files with 28 additions and 4 deletions

View File

@@ -104,8 +104,14 @@ void PerformanceManagerWindow::replot(QDir home,QTreeWidgetItem *allRides)
// calculate the number of days to look at... for now
// use first ride in allRides to today. When Season stuff is hooked
// up, maybe use that, or will allRides reflect only current season?
firstRideItem = (RideItem*) allRides->child(0);
QVariant isAscending = settings->value(GC_ALLRIDES_ASCENDING,Qt::Checked);
if(isAscending.toInt() > 0 ){
firstRideItem = (RideItem*) allRides->child(0);
} else {
firstRideItem = (RideItem*) allRides->child(allRides->childCount()-1);
}
if (firstRideItem) {
newdays = firstRideItem->dateTime.daysTo(now.currentDateTime());

View File

@@ -29,6 +29,8 @@ StressCalculator::StressCalculator (
lte = (double)exp(-1.0/longTermDays);
ste = (double)exp(-1.0/shortTermDays);
settings = GetApplicationSettings();
}
@@ -95,9 +97,21 @@ void StressCalculator::calculateStress(QWidget *mw,
}
QString ridedatestring;
item = (RideItem*) rides->child(0);
QVariant isAscending = settings->value(GC_ALLRIDES_ASCENDING,Qt::Checked);
if(isAscending.toInt() > 0 ){
item = (RideItem*) rides->child(0);
} else {
item = (RideItem*) rides->child(rides->childCount()-1);
}
for (int i = 0; i < rides->childCount(); ++i) {
item = (RideItem*) rides->child(i);
if(isAscending.toInt() > 0 ){
item = (RideItem*) rides->child(i);
} else {
item = (RideItem*) rides->child(rides->childCount()-1-i);
}
// calculate using rides within date range
if (item->dateTime.daysTo(startDate) <= 0 &&
@@ -208,6 +222,7 @@ void StressCalculator::addRideData(double BS, QDateTime rideDate) {
calculate(d);
}
// do this ride (may be more than one ride in a day)
if(daysIndex < 0) return;
list[daysIndex] += BS;
calculate(daysIndex);
lastDaysIndex = daysIndex;

View File

@@ -14,6 +14,7 @@
#include <QList>
#include <QDateTime>
#include <QTreeWidgetItem>
#include "Settings.h"
class StressCalculator:public QObject {
@@ -41,6 +42,8 @@ class StressCalculator:public QObject {
void calculate(int daysIndex);
void addRideData(double BS, QDateTime rideDate);
boost::shared_ptr<QSettings> settings;
public:
StressCalculator(QDateTime startDate, QDateTime endDate,