diff --git a/src/LTMPlot.h b/src/LTMPlot.h index 54734c30b..a93cd415b 100644 --- a/src/LTMPlot.h +++ b/src/LTMPlot.h @@ -186,6 +186,7 @@ class LTMScaleDraw: public QwtScaleDraw case LTM_TOD: break; + } } @@ -197,13 +198,13 @@ class LTMScaleDraw: public QwtScaleDraw switch (groupBy) { case LTM_DAY: upTime = baseTime.addDays((int)v); - label = upTime.toString("MMM dd\nyyyy"); + label = upTime.toString(QObject::tr("MMM dd\nyyyy")); /* 2 line display of date - keep \n in translation */ break; case LTM_WEEK: { QDate week = baseTime.date().addDays((int)v*7); - label = week.toString("MMM dd\nyyyy"); + label = week.toString(QObject::tr("MMM dd\nyyyy")); /* 2 line display of date - keep \n in translation */ } break; @@ -223,6 +224,11 @@ class LTMScaleDraw: public QwtScaleDraw case LTM_TOD: label = QString("%1:00").arg((int)v); break; + + case LTM_ALL: + label = QString(QObject::tr("All")); + break; + } return label; } diff --git a/src/LTMPopup.cpp b/src/LTMPopup.cpp index 32ec493b4..8653a75ec 100644 --- a/src/LTMPopup.cpp +++ b/src/LTMPopup.cpp @@ -19,15 +19,13 @@ #include "LTMPopup.h" #include "MainWindow.h" #include "Athlete.h" -#include -#include LTMPopup::LTMPopup(Context *context) : QWidget(context->mainWindow), context(context) { // get application settings setAutoFillBackground(false); setContentsMargins(0,0,0,0); - setFixedWidth(800); + setMinimumWidth(800); QVBoxLayout *mainLayout = new QVBoxLayout(this); mainLayout->setContentsMargins(0,0,0,0); @@ -100,6 +98,7 @@ LTMPopup::LTMPopup(Context *context) : QWidget(context->mainWindow), context(con mainLayout->addWidget(notes); connect(rides, SIGNAL(itemSelectionChanged()), this, SLOT(rideSelected())); + } void @@ -140,6 +139,7 @@ LTMPopup::setData(QListdata, const RideMetric *metric, QString t // date/time QTableWidgetItem *t = new QTableWidgetItem(rideDate.toString(tr("ddd, dd MMM yy hh:mmA"))); t->setFlags(t->flags() & (~Qt::ItemIsEditable)); + t->setTextAlignment(Qt::AlignHCenter); rides->setRowCount(count+1); rides->setItem(count, 0, t); rides->setRowHeight(count, 14); @@ -155,31 +155,27 @@ LTMPopup::setData(QListdata, const RideMetric *metric, QString t count++; } - // make em all visible! + // make em all visible! - also show rides if only 1 ride selected rides->resizeColumnsToContents(); + rides->setFixedHeight((count > 10 ? 10 : count) * 14 + rides->horizontalHeader()->height()); + // select the first one only if more than 1 rows exist ! if (count > 1) { - rides->setFixedHeight((count > 10 ? 10 : count) * 14 + rides->horizontalHeader()->height()); + rides->setRangeSelected(QTableWidgetSelectionRange(0,0,0,1), true); } - - // select the first one - rides->setRangeSelected(QTableWidgetSelectionRange(0,0,0,1), true); - - // for now at least, if multiple rides then show the table - // if single ride show the summary, show all if we're grouping by - // days tho, since we're interested in specific rides... - if (count > 1) { - //int size = ((count+1)*14) + rides->horizontalHeader()->height() + 4; - //rides->setFixedHeight(size > 100 ? 100 : size); - - rides->show(); - metrics->show(); - notes->show(); - + // show rides and metrics if at least 1 rides is selected - + // and even if only 1 Rides (since without the Ride we have not date/time) + // and the metrics for which the ride was selected + if (count == 0) { + // no ride + rides->hide(); + metrics->hide(); + notes->hide(); + title = tr("No ride selected"); } else { - - rides->hide(); - metrics->show(); - notes->show(); + // one or more rides + rides->show(); + metrics->show(); + notes->show(); } setTitle(title); @@ -188,7 +184,7 @@ LTMPopup::setData(QListdata, const RideMetric *metric, QString t } void -LTMPopup::setData(LTMSettings &settings, QDate start, QDate end) +LTMPopup::setData(LTMSettings &settings, QDate start, QDate end, QTime time) { // set the title QString _title; @@ -208,10 +204,29 @@ LTMPopup::setData(LTMSettings &settings, QDate start, QDate end) .arg(end.toString(tr("dd MMMM yyyy"))); break; case LTM_TOD: + case LTM_ALL: _title = QString(tr("%1 to %2")) .arg(settings.start.date().toString(tr("dd MMMM yy"))) .arg(settings.end.date().toString(tr("dd MMMM yy"))); break; + + } + + // add Search/Filter info to Title + if (context->isfiltered || context->ishomefiltered) + _title = tr("Search/Filter: ") + _title; + + + // For LTM_ALL show all Rides which are done in the active/selected Date Range + if (settings.groupBy == LTM_ALL) { + start = settings.start.date(); + end = settings.end.date(); + } + + // For LTM_TOD show all Rides which are done in the active/selected Date Range considering the Ride Time + QTime end_time; + if (settings.groupBy == LTM_TOD) { + end_time = time.addSecs(3599); // full hour to 1 second before next (this also avoids reaching 00:00:00) } // create the ride list @@ -231,7 +246,14 @@ LTMPopup::setData(LTMSettings &settings, QDate start, QDate end) foreach(SummaryMetrics x, (*settings.data)) { QDateTime rideDate = x.getRideDate(); - if (rideDate.date() >= start && rideDate.date() <= end) { + + // check either RideDate (for all Date related groupBy's) or RideTime (for LTM_TOD only) + if (((settings.groupBy != LTM_TOD) && (rideDate.date() >= start && rideDate.date() <= end)) + ||((settings.groupBy == LTM_TOD) && (rideDate.time() >= time && rideDate.time() <= end_time))) { + + // apply filters + if (context->isfiltered && !context->filters.contains(x.getFileName())) continue; + if (context->ishomefiltered && !context->homeFilters.contains(x.getFileName())) continue; // we'll select it for summary aggregation selected << x; @@ -239,6 +261,7 @@ LTMPopup::setData(LTMSettings &settings, QDate start, QDate end) // date/time QTableWidgetItem *t = new QTableWidgetItem(rideDate.toString(tr("ddd, dd MMM yy hh:mmA"))); t->setFlags(t->flags() & (~Qt::ItemIsEditable)); + t->setTextAlignment(Qt::AlignHCenter); rides->setRowCount(count+1); rides->setItem(count, 0, t); rides->setRowHeight(count, 14); @@ -258,35 +281,29 @@ LTMPopup::setData(LTMSettings &settings, QDate start, QDate end) // make em all visible! rides->resizeColumnsToContents(); + rides->setFixedHeight((count > 10 ? 10 : count) * 14 + rides->horizontalHeader()->height()); + + // select the first one only if more than 1 rows exist ! if (count > 1) { - rides->setFixedHeight((count > 10 ? 10 : count) * 14 + - rides->horizontalHeader()->height()); + rides->setRangeSelected(QTableWidgetSelectionRange(0,0,0,settings.metrics.count()), true); } - // select the first one - rides->setRangeSelected(QTableWidgetSelectionRange(0,0,0,settings.metrics.count()), true); - - // for now at least, if multiple rides then show the table - // if single ride show the summary, show all if we're grouping by - // days tho, since we're interested in specific rides... - if (count > 1) { - //int size = ((count+1)*14) + rides->horizontalHeader()->height() + 4; - //rides->setFixedHeight(size > 100 ? 100 : size); - - if (settings.groupBy != LTM_DAY) { - rides->show(); - metrics->show(); - notes->show(); - } else { - rides->show(); - metrics->show(); - notes->show(); - } - _title += QString(tr(" (%1 rides)")).arg(count); + // show rides and metrics if at least 1 rides is selected - + // and even if only 1 Rides (since without the Ride we have not date/time) + // and the metrics for which the ride was selected + if (count == 0) { + // no ride + rides->hide(); + metrics->hide(); + notes->hide(); + _title = tr("No ride selected"); } else { - rides->hide(); - metrics->show(); - notes->show(); + // one or more rides + rides->show(); + metrics->show(); + notes->show(); + // give some extrat info + if (count > 1) _title += QString(tr(" (%1 rides)")).arg(count); } setTitle(_title); @@ -463,6 +480,10 @@ LTMPopup::eventFilter(QObject * /*object*/, QEvent *e) //if (object != (QObject *)plot()->canvas() ) //return false; + //if only 1 Ride in list, ignore any mouse activities + if (rides->rowCount() == 1) return false; + + // process mouse switch (e->type()) { case QEvent::MouseMove: { diff --git a/src/LTMPopup.h b/src/LTMPopup.h index 9aeaab919..d2c91eaf3 100644 --- a/src/LTMPopup.h +++ b/src/LTMPopup.h @@ -48,8 +48,8 @@ class LTMPopup : public QWidget LTMPopup(Context *context); void setTitle(QString); - // when called from LTM chart - void setData(LTMSettings &settings, QDate start, QDate end); + // when called from LTM chart (time only relevant for LTM_TOD) + void setData(LTMSettings &settings, QDate start, QDate end, QTime time); // when called from a TreeMap chart void setData(QListdata, const RideMetric *metric, QString title); diff --git a/src/LTMWindow.cpp b/src/LTMWindow.cpp index 956e86aa0..36f0b91e0 100644 --- a/src/LTMWindow.cpp +++ b/src/LTMWindow.cpp @@ -860,13 +860,24 @@ LTMWindow::groupForDate(QDate date) void LTMWindow::pointClicked(QwtPlotCurve*curve, int index) { - // get the date range for this point - QDate start, end; - LTMScaleDraw *lsd = new LTMScaleDraw(settings.start, - groupForDate(settings.start.date()), - settings.groupBy); - lsd->dateRange((int)round(curve->sample(index).x()), start, end); - ltmPopup->setData(settings, start, end); + // initialize date and time to sensefull boundaries + QDate start = QDate(1900,1,1); + QDate end = QDate(2999,12,31); + QTime time = QTime(0, 0, 0, 0); + + // now fill the correct values for context + if (settings.groupBy != LTM_TOD) { + // get the date range for this point (for all date-dependent grouping) + LTMScaleDraw *lsd = new LTMScaleDraw(settings.start, + groupForDate(settings.start.date()), + settings.groupBy); + lsd->dateRange((int)round(curve->sample(index).x()), start, end); } + else { + // special treatment for LTM_TOD as time dependent grouping + time = QTime((int)round(curve->sample(index).x()), 0, 0, 0); + } + // feed the popup with data + ltmPopup->setData(settings, start, end, time); popup->show(); } diff --git a/src/RideSummaryWindow.cpp b/src/RideSummaryWindow.cpp index 737258d44..b42ac4e95 100644 --- a/src/RideSummaryWindow.cpp +++ b/src/RideSummaryWindow.cpp @@ -917,7 +917,7 @@ RideSummaryWindow::htmlSummary() // "n of x activities" shown in header of list when filtered summary += ("

" + - QString("%1 of %2").arg(activities).arg(data.count()) + QString(tr("%1 of %2")).arg(activities).arg(data.count()) + (data.count() == 1 ? tr(" ride") : tr(" rides")) + "

"); } else {