mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-13 16:18:42 +00:00
LTM Popup - further enhancements
... make window "minimumSize" - so that resize in case of many columns works ... handle LTM_TOD when called from LTM-Chart (list the rides in the hour, considering DateRange) ... consider HomeFilter and Search/Filter in result list ... also show Rides of only 1 ride is selected (since Rides contain Date/Time) and the Metrics (which mostly are not part of the Summary HTML) ... do not allow MouseSelection of only 1 Ride is shown ... some more tr()
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
123
src/LTMPopup.cpp
123
src/LTMPopup.cpp
@@ -19,15 +19,13 @@
|
||||
#include "LTMPopup.h"
|
||||
#include "MainWindow.h"
|
||||
#include "Athlete.h"
|
||||
#include <QStyle>
|
||||
#include <QScrollBar>
|
||||
|
||||
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(QList<SummaryMetrics>data, 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(QList<SummaryMetrics>data, 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(QList<SummaryMetrics>data, 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:
|
||||
{
|
||||
|
||||
@@ -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(QList<SummaryMetrics>data, const RideMetric *metric, QString title);
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -917,7 +917,7 @@ RideSummaryWindow::htmlSummary()
|
||||
|
||||
// "n of x activities" shown in header of list when filtered
|
||||
summary += ("<p><h3>" +
|
||||
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")) +
|
||||
"</h3><p>");
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user