mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-04-15 05:32:21 +00:00
Manual ride entry updates
fix to use last N days worth of rides for BiksScore estimates fix for skipping some rides in BikeScore estimates skips rides with zero Bikescore for BikeScore estimates hitting enter on ManualRide entry dialog doesn't write file better checking for inputs on ManualRide dialog Signed-off-by: Robert Carlsen <robert@robertcarlsen.net>
This commit is contained in:
committed by
Robert Carlsen
parent
e8a7a4bf4d
commit
e3e1f8fe82
@@ -1109,6 +1109,7 @@ void MainWindow::getBSFactors(float &timeBS, float &distanceBS)
|
||||
|
||||
int rides;
|
||||
double seconds, distance, bs, convertUnit;
|
||||
RideItem * lastRideItem;
|
||||
seconds = rides = 0;
|
||||
distance = bs = 0;
|
||||
timeBS = distanceBS = 0.0;
|
||||
@@ -1117,30 +1118,40 @@ void MainWindow::getBSFactors(float &timeBS, float &distanceBS)
|
||||
if (BSdays.isNull() || BSdays.toInt() == 0)
|
||||
BSdays.setValue(30); // by default look back no more than 30 days
|
||||
|
||||
// if there are rides, find most recent ride so we count back from there:
|
||||
if (allRides->childCount() > 0)
|
||||
lastRideItem = (RideItem*) allRides->child(allRides->childCount() - 1);
|
||||
else
|
||||
lastRideItem = ride; // not enough rides, use current ride
|
||||
|
||||
for (int i = 0; i < allRides->childCount(); ++i) {
|
||||
RideItem *item = (RideItem*) allRides->child(i);
|
||||
int days = item->dateTime.daysTo(ride->dateTime);
|
||||
int days = item->dateTime.daysTo(lastRideItem->dateTime);
|
||||
if (
|
||||
(item->type() == RIDE_TYPE) &&
|
||||
(item->ride) &&
|
||||
// (item->ride) &&
|
||||
(days >= 0) &&
|
||||
(days < BSdays.toInt())
|
||||
) {
|
||||
|
||||
RideMetric *m;
|
||||
item->htmlSummary(); // compute metrics
|
||||
if ((m = item->metrics.value("time_riding"))) {
|
||||
seconds += m->value(true);
|
||||
}
|
||||
|
||||
if ((m = item->metrics.value("total_distance"))) {
|
||||
distance += m->value(true);
|
||||
}
|
||||
|
||||
if ((m = item->metrics.value("skiba_bike_score"))) {
|
||||
// only count rides with BS > 0
|
||||
if ((m = item->metrics.value("skiba_bike_score")) &&
|
||||
m->value(true)) {
|
||||
bs += m->value(true);
|
||||
|
||||
if ((m = item->metrics.value("time_riding"))) {
|
||||
seconds += m->value(true);
|
||||
}
|
||||
|
||||
if ((m = item->metrics.value("total_distance"))) {
|
||||
distance += m->value(true);
|
||||
}
|
||||
|
||||
rides++;
|
||||
}
|
||||
rides++;
|
||||
}
|
||||
}
|
||||
if (rides) {
|
||||
|
||||
@@ -55,21 +55,26 @@ ManualRideDialog::ManualRideDialog(MainWindow *mainWindow,
|
||||
hrslbl = new QLabel(tr("hours"),this);
|
||||
hrslbl->setFrameStyle(QFrame::Panel | QFrame::Sunken);
|
||||
hrsentry = new QLineEdit(this);
|
||||
hrsentry->setInputMask("00");
|
||||
QIntValidator * hoursValidator = new QIntValidator(0,99,this);
|
||||
//hrsentry->setInputMask("09");
|
||||
hrsentry->setValidator(hoursValidator);
|
||||
manualLengthLayout->addWidget(hrslbl);
|
||||
manualLengthLayout->addWidget(hrsentry);
|
||||
|
||||
minslbl = new QLabel(tr("mins"),this);
|
||||
minslbl->setFrameStyle(QFrame::Panel | QFrame::Sunken);
|
||||
minsentry = new QLineEdit(this);
|
||||
minsentry->setInputMask("00");
|
||||
QIntValidator * secsValidator = new QIntValidator(0,60,this);
|
||||
//minsentry->setInputMask("00");
|
||||
minsentry->setValidator(secsValidator);
|
||||
manualLengthLayout->addWidget(minslbl);
|
||||
manualLengthLayout->addWidget(minsentry);
|
||||
|
||||
secslbl = new QLabel(tr("secs"),this);
|
||||
secslbl->setFrameStyle(QFrame::Panel | QFrame::Sunken);
|
||||
secsentry = new QLineEdit(this);
|
||||
secsentry->setInputMask("00");
|
||||
//secsentry->setInputMask("00");
|
||||
secsentry->setValidator(secsValidator);
|
||||
manualLengthLayout->addWidget(secslbl);
|
||||
manualLengthLayout->addWidget(secsentry);
|
||||
|
||||
@@ -81,13 +86,17 @@ ManualRideDialog::ManualRideDialog(MainWindow *mainWindow,
|
||||
DistanceString->append("(" + tr("miles") + "):");
|
||||
|
||||
QLabel *DistanceLabel = new QLabel(*DistanceString, this);
|
||||
QDoubleValidator * distanceValidator = new QDoubleValidator(0,1000,2,this);
|
||||
distanceentry = new QLineEdit(this);
|
||||
distanceentry->setInputMask("009.00");
|
||||
//distanceentry->setInputMask("009.00");
|
||||
distanceentry->setValidator(distanceValidator);
|
||||
|
||||
// AvgHR
|
||||
QLabel *HRLabel = new QLabel(tr("Average HR: "), this);
|
||||
HRentry = new QLineEdit(this);
|
||||
HRentry->setInputMask("099");
|
||||
QIntValidator *hrValidator = new QIntValidator(0,200,this);
|
||||
//HRentry->setInputMask("099");
|
||||
HRentry->setValidator(hrValidator);
|
||||
|
||||
// how to estimate BikeScore:
|
||||
QLabel *BSEstLabel;
|
||||
@@ -125,10 +134,14 @@ ManualRideDialog::ManualRideDialog(MainWindow *mainWindow,
|
||||
QLabel *ManualBSLabel = new QLabel(tr("BikeScore: "), this);
|
||||
BSentry = new QLineEdit(this);
|
||||
BSentry->setInputMask("009");
|
||||
BSentry->clear();
|
||||
|
||||
// buttons
|
||||
enterButton = new QPushButton(tr("&OK"), this);
|
||||
cancelButton = new QPushButton(tr("&Cancel"), this);
|
||||
// don't let Enter write a new (and possibly incomplete) manual file:
|
||||
enterButton->setDefault(false);
|
||||
cancelButton->setDefault(true);
|
||||
|
||||
// Set up the layout:
|
||||
QGridLayout *glayout = new QGridLayout(this);
|
||||
|
||||
Reference in New Issue
Block a user