mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-04-15 05:32:21 +00:00
fix performance manager to deal with descending ride list preference.
This commit is contained in:
@@ -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());
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user