From a0b6fd620809326d56e8e0a43e13367260e575b8 Mon Sep 17 00:00:00 2001 From: Mark Liversedge Date: Mon, 30 Jan 2012 18:54:40 +0000 Subject: [PATCH 1/6] Libical is optional. Gets me every time. libical is optional and the new minicalendar uses the GcCalendarModel which assumed rideCalendar was available in MainWindow. --- src/GcCalendarModel.h | 11 ++++++++++- src/src.pro | 3 ++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/GcCalendarModel.h b/src/GcCalendarModel.h index a8e256e03..214e53bbb 100644 --- a/src/GcCalendarModel.h +++ b/src/GcCalendarModel.h @@ -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 >(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; diff --git a/src/src.pro b/src/src.pro index 94c739b9f..dd7bbcf28 100644 --- a/src/src.pro +++ b/src/src.pro @@ -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 \ From 911b52cfc37f510006d9de6167b450d986af5017 Mon Sep 17 00:00:00 2001 From: Mark Liversedge Date: Mon, 30 Jan 2012 20:07:35 +0000 Subject: [PATCH 2/6] Refresh mini calendar When; * ride added * ride deleted * color config changes --- src/GcCalendar.cpp | 17 ++++++++++++----- src/GcCalendar.h | 4 ++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/GcCalendar.cpp b/src/GcCalendar.cpp index 06e0f2662..ae2afa6f1 100644 --- a/src/GcCalendar.cpp +++ b/src/GcCalendar.cpp @@ -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) { diff --git a/src/GcCalendar.h b/src/GcCalendar.h index c27721241..8399043aa 100644 --- a/src/GcCalendar.h +++ b/src/GcCalendar.h @@ -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(); From 1fd8626fca73f407f0a1c9944398687ddb29469e Mon Sep 17 00:00:00 2001 From: Tom Weichmann Date: Tue, 31 Jan 2012 08:30:15 -0500 Subject: [PATCH 3/6] Changes to make TPUpload dialog honor user unit preferences --- src/TPDownloadDialog.cpp | 12 ++++++++++-- src/TPDownloadDialog.h | 6 ++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/TPDownloadDialog.cpp b/src/TPDownloadDialog.cpp index 28aec7c0d..9dd82c584 100644 --- a/src/TPDownloadDialog.cpp +++ b/src/TPDownloadDialog.cpp @@ -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 >workouts) { + + unit = appsettings->value(this, GC_UNIT); + useMetricUnits = (unit.toString() == "Metric"); // // Setup the upload list @@ -369,8 +373,12 @@ TPDownloadDialog::completedWorkout(QList >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 ) diff --git a/src/TPDownloadDialog.h b/src/TPDownloadDialog.h index b6b355dbe..237ead1f0 100644 --- a/src/TPDownloadDialog.h +++ b/src/TPDownloadDialog.h @@ -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 >); From 6e7d39415d3da93620fe454def691822fae44eb8 Mon Sep 17 00:00:00 2001 From: Tom Weichmann Date: Sun, 29 Jan 2012 12:42:15 -0500 Subject: [PATCH 4/6] Makes GcBubble honor user unit preference for distance --- src/GcBubble.cpp | 13 ++++++++++++- src/GcBubble.h | 6 +++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/GcBubble.cpp b/src/GcBubble.cpp index c2f32b0cc..31f65829b 100644 --- a/src/GcBubble.cpp +++ b/src/GcBubble.cpp @@ -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)); diff --git a/src/GcBubble.h b/src/GcBubble.h index 105fa2d08..ad8e002c3 100644 --- a/src/GcBubble.h +++ b/src/GcBubble.h @@ -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: From 192ebc1fac3029c13ca9f6d1e61cb9c1e07004f2 Mon Sep 17 00:00:00 2001 From: Gareth Coco Date: Tue, 31 Jan 2012 23:18:07 -0500 Subject: [PATCH 5/6] Fixes for Manual Ride Entry Includes: - Resize dialog for Mac users to display all fields - Modify display of data in fields - Add Average HR check - Base code formatting to remove tabs Fixes #622 --- src/ManualRideDialog.cpp | 56 ++++++++++++++++++++++++++++------------ 1 file changed, 40 insertions(+), 16 deletions(-) diff --git a/src/ManualRideDialog.cpp b/src/ManualRideDialog.cpp index e327e97df..f2fe24488 100644 --- a/src/ManualRideDialog.cpp +++ b/src/ManualRideDialog.cpp @@ -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,10 @@ ManualRideDialog::ManualRideDialog(MainWindow *mainWindow, glayout->addWidget(enterButton,row,1); glayout->addWidget(cancelButton,row,2); - this->resize(QSize(400,275)); +#ifdef Q_OS_MAC + setMinimumHeight(275); + setMinimumWidth(400); +#endif connect(enterButton, SIGNAL(clicked()), this, SLOT(enterClicked())); connect(cancelButton, SIGNAL(clicked()), this, SLOT(cancelClicked())); @@ -283,12 +304,15 @@ 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 " : "") + +((!HRentry->hasAcceptableInput()) + ? " Average HR (30-199 bpm)\n " : "") +((!BSentry->hasAcceptableInput() && !BSentry->text().isEmpty() ) ? " BikeScore (max 9999)\n " : "") +((!DPentry->hasAcceptableInput() && !DPentry->text().isEmpty() ) From 6d6eb27afe2ccf2ffa32c86fa56590c98832c92c Mon Sep 17 00:00:00 2001 From: Gareth Coco Date: Wed, 1 Feb 2012 10:10:12 -0500 Subject: [PATCH 6/6] Comment added and replace tabs with spaces --- src/ManualRideDialog.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/ManualRideDialog.cpp b/src/ManualRideDialog.cpp index f2fe24488..a0d792fe6 100644 --- a/src/ManualRideDialog.cpp +++ b/src/ManualRideDialog.cpp @@ -222,6 +222,7 @@ ManualRideDialog::ManualRideDialog(MainWindow *mainWindow, glayout->addWidget(enterButton,row,1); glayout->addWidget(cancelButton,row,2); +// Mac has sizing issues. This allows it to grow bigger to fit things in. #ifdef Q_OS_MAC setMinimumHeight(275); setMinimumWidth(400); @@ -309,14 +310,14 @@ ManualRideDialog::enterClicked() 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 " : "") - +((!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 " : "") + +((!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;