Merge branch 'release_3.0.0dev' of github.com:/srhea/GoldenCheetah into release_3.0.0dev

This commit is contained in:
Mark Liversedge
2012-02-02 07:14:16 +00:00
9 changed files with 106 additions and 35 deletions

View File

@@ -29,6 +29,8 @@ static const int spikeMargin = 40;
#include "MetricAggregator.h"
#include "SummaryMetrics.h"
#include "DBAccess.h"
#include "Settings.h"
#include "Units.h"
GcBubble::GcBubble(MainWindow *parent) : QWidget(parent, Qt::FramelessWindowHint), borderWidth(3), parent(parent), orientation(Qt::Horizontal)
{
@@ -416,6 +418,10 @@ void
GcBubble::setText(QString filename)
{
SummaryMetrics metrics = parent->metricDB->getAllMetricsFor(filename);
unit = appsettings->value(this, GC_UNIT);
useMetricUnits = (unit.toString() == "Metric");
//
// Workout code
@@ -458,7 +464,12 @@ GcBubble::setText(QString filename)
// Metrics 1,2,3,4
m1->setText(QTime(0,0,0,0).addSecs(metrics.getForSymbol("workout_time")).toString("hh:mm:ss")); //duration
m3->setText(QString("%1 km").arg(metrics.getForSymbol("total_distance"), 0, 'f', 2)); //distance
if (useMetricUnits) {
m3->setText(QString("%1 km").arg(metrics.getForSymbol("total_distance"), 0, 'f', 2));
} else {
m3->setText(QString("%1 mi").arg(metrics.getForSymbol("total_distance")*MILES_PER_KM, 0, 'f', 2));
} //distance
m2->setText(QString("%1 TSS").arg(metrics.getForSymbol("coggan_tss"), 0, 'f', 0));
m4->setText(QString("%1 IF").arg(metrics.getForSymbol("coggan_if"), 0, 'f', 3));

View File

@@ -33,7 +33,11 @@ class GcBubble : public QWidget
GcBubble(MainWindow *parent = NULL);
void setText(QString); // set the text displayed according to filename
protected:
protected:
// cached state
QSettings *settings;
QVariant unit;
bool useMetricUnits;
signals:

View File

@@ -203,6 +203,18 @@ GcCalendar::GcCalendar(MainWindow *mainWindow) : mainWindow(mainWindow)
}
}
connect(signalMapper, SIGNAL(mapped(int)), this, SLOT(dayClicked(int)));
// refresh on these events...
connect(mainWindow, SIGNAL(rideAdded(RideItem*)), this, SLOT(refresh()));
connect(mainWindow, SIGNAL(rideDeleted(RideItem*)), this, SLOT(refresh()));
connect(mainWindow, SIGNAL(configChanged()), this, SLOT(refresh()));
}
void
GcCalendar::refresh()
{
calendarModel->setMonth(month, year);
repaint();
}
void
@@ -342,11 +354,6 @@ GcCalendar::setRide(RideItem *ride)
repaint();
}
void
GcCalendar::configChanged()
{
}
void
GcLabel::paintEvent(QPaintEvent *e)
{

View File

@@ -50,7 +50,7 @@ public slots:
bool getBg() { return bg; }
void setBgColor(QColor bg) { bgColor = bg; }
void setSelected(bool x) { selected = x; }
protected:
void mouseReleaseEvent(QMouseEvent *) {
emit clicked();
@@ -71,7 +71,7 @@ class GcCalendar : public QWidget // not a GcWindow - belongs on sidebar
public slots:
void setRide(RideItem *ride);
void configChanged();
void refresh();
void dayClicked(int num); // for when a day is selected
void next();

View File

@@ -41,7 +41,9 @@
#include "qxtscheduleview.h"
#include "MainWindow.h"
#include "RideMetadata.h"
#ifdef GC_HAVE_ICAL
#include "ICalendar.h"
#endif
#include "Colors.h"
#include "Settings.h"
@@ -147,7 +149,9 @@ public:
connect(model, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(refresh()));
connect(model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)), this, SLOT(refresh()));
connect(model, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(refresh()));
#ifdef GC_HAVE_ICAL
connect(mainWindow->rideCalendar, SIGNAL(dataChanged()), this, SLOT(refresh()));
#endif
refresh();
}
@@ -211,10 +215,11 @@ public:
else
colors << QColor(sourceModel()->data(index(i, colorIndex, QModelIndex())).toString());
#ifdef GC_HAVE_ICAL
// added planned workouts
for (int k= mainWindow->rideCalendar->data(date(proxyIndex), EventCountRole).toInt(); k>0; k--)
colors.append(GColor(CCALPLANNED));
#endif
return QVariant::fromValue<QList<QColor> >(colors);
}
@@ -262,11 +267,13 @@ public:
foreach (int i, *arr)
filenames << sourceModel()->data(index(i, filenameIndex, QModelIndex())).toString();
#ifdef GC_HAVE_ICAL
// fold in planned workouts
if (mainWindow->rideCalendar->data(date(proxyIndex), EventCountRole).toInt()) {
foreach(QString x, mainWindow->rideCalendar->data(date(proxyIndex), Qt::DisplayRole).toStringList())
filenames << "calendar";
}
#endif
return filenames;
}
@@ -282,12 +289,14 @@ public:
foreach (int i, *arr)
strings << sourceModel()->data(index(i, textIndex, QModelIndex())).toString();
#ifdef GC_HAVE_ICAL
// fold in planned workouts
if (mainWindow->rideCalendar->data(date(proxyIndex), EventCountRole).toInt()) {
QStringList planned;
planned = mainWindow->rideCalendar->data(date(proxyIndex), Qt::DisplayRole).toStringList();
strings << planned;
}
#endif
return strings;
}
break;

View File

@@ -44,6 +44,7 @@ ManualRideDialog::ManualRideDialog(MainWindow *mainWindow,
dateTimeEdit = new QDateTimeEdit( QDateTime::currentDateTime(), this );
// Wed 6/24/09 6:55 AM
dateTimeEdit->setDisplayFormat(tr("ddd MMM d, yyyy h:mm AP"));
dateTimeEdit->setAlignment(Qt::AlignCenter);
dateTimeEdit->setCalendarPopup(true);
// ride length
@@ -55,15 +56,21 @@ ManualRideDialog::ManualRideDialog(MainWindow *mainWindow,
QIntValidator * hoursValidator = new QIntValidator(0,99,this);
//hrsentry->setInputMask("09");
hrsentry->setValidator(hoursValidator);
hrsentry->setPlaceholderText("00");
hrsentry->setMaxLength(2);
hrsentry->setAlignment(Qt::AlignCenter);
manualLengthLayout->addWidget(hrslbl);
manualLengthLayout->addWidget(hrsentry);
minslbl = new QLabel(tr("mins"),this);
minslbl->setFrameStyle(QFrame::Panel | QFrame::Sunken);
minsentry = new QLineEdit(this);
QIntValidator * secsValidator = new QIntValidator(0,60,this);
QIntValidator * mins_secsValidator = new QIntValidator(0,59,this);
//minsentry->setInputMask("00");
minsentry->setValidator(secsValidator);
minsentry->setValidator(mins_secsValidator);
minsentry->setPlaceholderText("00");
minsentry->setMaxLength(2);
minsentry->setAlignment(Qt::AlignCenter);
manualLengthLayout->addWidget(minslbl);
manualLengthLayout->addWidget(minsentry);
@@ -71,7 +78,10 @@ ManualRideDialog::ManualRideDialog(MainWindow *mainWindow,
secslbl->setFrameStyle(QFrame::Panel | QFrame::Sunken);
secsentry = new QLineEdit(this);
//secsentry->setInputMask("00");
secsentry->setValidator(secsValidator);
secsentry->setValidator(mins_secsValidator);
secsentry->setPlaceholderText("00");
secsentry->setMaxLength(2);
secsentry->setAlignment(Qt::AlignCenter);
manualLengthLayout->addWidget(secslbl);
manualLengthLayout->addWidget(secsentry);
@@ -90,26 +100,30 @@ ManualRideDialog::ManualRideDialog(MainWindow *mainWindow,
distanceentry = new QLineEdit(this);
//distanceentry->setInputMask("009.00");
distanceentry->setValidator(distanceValidator);
distanceentry->setMaxLength(6);
distanceentry->setMaxLength(6);
distanceentry->setPlaceholderText("0");
distanceentry->setAlignment(Qt::AlignCenter);
QLabel *manualDistanceHint = new QLabel(tr("(0-9999) "), this);
QHBoxLayout *distanceLayout = new QHBoxLayout;
distanceLayout->addWidget(distanceentry);
distanceLayout->addWidget(manualDistanceHint);
distanceLayout->addWidget(distanceentry);
distanceLayout->addWidget(manualDistanceHint);
// AvgHR
QLabel *HRLabel = new QLabel(tr("Average HR: "), this);
QIntValidator * hrValidator = new QIntValidator(30,199,this);
HRentry = new QLineEdit(this);
QIntValidator *hrValidator = new QIntValidator(30,200,this);
//HRentry->setInputMask("099");
HRentry->setValidator(hrValidator);
HRentry->setPlaceholderText("0");
HRentry->setAlignment(Qt::AlignCenter);
QLabel *manualHRHint = new QLabel(tr("(30-199) "), this);
QHBoxLayout *hrLayout = new QHBoxLayout;
hrLayout->addWidget(HRentry);
hrLayout->addWidget(manualHRHint);
hrLayout->addWidget(HRentry);
hrLayout->addWidget(manualHRHint);
// how to estimate BikeScore:
QLabel *BSEstLabel = NULL;
@@ -138,25 +152,29 @@ ManualRideDialog::ManualRideDialog(MainWindow *mainWindow,
QDoubleValidator * bsValidator = new QDoubleValidator(0,9999,2,this);
BSentry = new QLineEdit(this);
BSentry->setValidator(bsValidator);
BSentry->setMaxLength(6);
BSentry->setMaxLength(6);
BSentry->setPlaceholderText("0");
BSentry->setAlignment(Qt::AlignCenter);
BSentry->clear();
QLabel *manualBSHint = new QLabel(tr("(0-9999) "), this);
QHBoxLayout *bsLayout = new QHBoxLayout;
bsLayout->addWidget(BSentry);
bsLayout->addWidget(manualBSHint);
bsLayout->addWidget(BSentry);
bsLayout->addWidget(manualBSHint);
// DanielsPoints
QLabel *ManualDPLabel = new QLabel(tr("Daniels Points: "), this);
QDoubleValidator * dpValidator = new QDoubleValidator(0,9999,2,this);
DPentry = new QLineEdit(this);
DPentry->setValidator(dpValidator);
DPentry->setMaxLength(6);
DPentry->setMaxLength(6);
DPentry->setPlaceholderText("0");
DPentry->setAlignment(Qt::AlignCenter);
DPentry->clear();
QLabel *manualDPHint = new QLabel(tr("(0-9999) "), this);
QHBoxLayout *dpLayout = new QHBoxLayout;
dpLayout->addWidget(DPentry);
dpLayout->addWidget(manualDPHint);
dpLayout->addWidget(DPentry);
dpLayout->addWidget(manualDPHint);
// buttons
enterButton = new QPushButton(tr("&OK"), this);
@@ -204,7 +222,11 @@ ManualRideDialog::ManualRideDialog(MainWindow *mainWindow,
glayout->addWidget(enterButton,row,1);
glayout->addWidget(cancelButton,row,2);
this->resize(QSize(400,275));
// Mac has sizing issues. This allows it to grow bigger to fit things in.
#ifdef Q_OS_MAC
setMinimumHeight(275);
setMinimumWidth(400);
#endif
connect(enterButton, SIGNAL(clicked()), this, SLOT(enterClicked()));
connect(cancelButton, SIGNAL(clicked()), this, SLOT(cancelClicked()));
@@ -283,16 +305,19 @@ ManualRideDialog::enterClicked()
if (!( ( BSentry->text().isEmpty() || BSentry->hasAcceptableInput() ) &&
( DPentry->text().isEmpty() || DPentry->hasAcceptableInput() ) &&
( HRentry->hasAcceptableInput() ) &&
( distanceentry->text().isEmpty() || distanceentry->hasAcceptableInput() ) ) ) {
QMessageBox::warning( this,
tr("Values out of range"),
tr("The values you've entered in:\n ")
+((!distanceentry->hasAcceptableInput() && !distanceentry->text().isEmpty() )
? " Distance (max 9999)\n " : "")
+((!BSentry->hasAcceptableInput() && !BSentry->text().isEmpty() )
? " BikeScore (max 9999)\n " : "")
+((!DPentry->hasAcceptableInput() && !DPentry->text().isEmpty() )
? " Daniels Points (max 9999)\n " : "")
+((!distanceentry->hasAcceptableInput() && !distanceentry->text().isEmpty() )
? " Distance (max 9999)\n " : "")
+((!HRentry->hasAcceptableInput())
? " Average HR (30-199 bpm)\n " : "")
+((!BSentry->hasAcceptableInput() && !BSentry->text().isEmpty() )
? " BikeScore (max 9999)\n " : "")
+((!DPentry->hasAcceptableInput() && !DPentry->text().isEmpty() )
? " Daniels Points (max 9999)\n " : "")
+ tr("are invalid, please fix.")
);
return;

View File

@@ -23,6 +23,7 @@
#include "RideFile.h"
#include "Settings.h"
#include "MetricAggregator.h"
#include "Units.h"
TPDownloadDialog::TPDownloadDialog(MainWindow *main) : QDialog(main, Qt::Dialog), main(main), downloading(false), aborted(false)
{
@@ -334,6 +335,9 @@ TPDownloadDialog::tabChanged(int idx)
void
TPDownloadDialog::completedWorkout(QList<QMap<QString, QString> >workouts)
{
unit = appsettings->value(this, GC_UNIT);
useMetricUnits = (unit.toString() == "Metric");
//
// Setup the upload list
@@ -369,8 +373,12 @@ TPDownloadDialog::completedWorkout(QList<QMap<QString, QString> >workouts)
add->setTextAlignment(4, Qt::AlignCenter);
double distance = workouts[i].value("DistanceInMeters").toDouble() / 1000.00;
add->setText(5, QString("%1 km").arg(distance, 0, 'f', 1));
add->setTextAlignment(5, Qt::AlignRight);
if (useMetricUnits) {
add->setText(5, QString("%1 km").arg(distance, 0, 'f', 1));
} else {
add->setText(5, QString("%1 mi").arg(distance*MILES_PER_KM, 0, 'f', 1));
}
add->setTextAlignment(5, Qt::AlignRight);
QString targetnosuffix = QString ( "%1_%2_%3_%4_%5_%6" )
.arg ( ridedatetime.date().year(), 4, 10, zero )

View File

@@ -37,6 +37,12 @@ class TPDownloadDialog : public QDialog
public:
TPDownloadDialog(MainWindow *main);
protected:
// cached state
QSettings *settings;
QVariant unit;
bool useMetricUnits;
public slots:
void completedAthlete(QList<QMap<QString,QString> >);

View File

@@ -67,7 +67,7 @@ qwt3d {
}
!isEmpty( ICAL_INSTALL) {
HEADERS += ICalendar.h DiaryWindow.h GcCalendarModel.h CalDAV.h
HEADERS += ICalendar.h DiaryWindow.h CalDAV.h
SOURCES += ICalendar.cpp DiaryWindow.cpp CalDAV.cpp
ICAL_INCLUDE = $${ICAL_INSTALL}/include
ICAL_LIBS = $${ICAL_INSTALL}/lib/libical.a
@@ -223,6 +223,7 @@ HEADERS += \
FitRideFile.h \
GcBubble.h \
GcCalendar.h \
GcCalendarModel.h \
GcPane.h \
GcRideFile.h \
GcToolBar.h \