mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-13 16:18:42 +00:00
Code Cleaning: LTM sources
Addressing or removing 'XXX' code alerts across the Long Term Metrics source files. This is part of a code cleanup prior to V3.0 release.
This commit is contained in:
@@ -116,7 +116,7 @@ static QString unprotect(QString buffer)
|
||||
s.replace( "™", tm );
|
||||
|
||||
// html special chars are automatically handled
|
||||
// XXX other special characters will not work
|
||||
// other special characters will not work
|
||||
// cross-platform but will work locally, so not a biggie
|
||||
// i.e. if thedefault charts.xml has a special character
|
||||
// in it it should be added here
|
||||
|
||||
145
src/LTMPlot.cpp
145
src/LTMPlot.cpp
@@ -201,10 +201,13 @@ LTMPlot::setData(LTMSettings *set)
|
||||
// of a stack, when in fact its just bars of descending
|
||||
// order (with values aggregated)
|
||||
|
||||
// stack - first just get all curve data
|
||||
stackX.clear();//XXX mem leak - need to delete the xdata and ydata
|
||||
stackY.clear();//XXX mem leak - need to delete the xdata and ydata
|
||||
// free stack memory
|
||||
foreach(QVector<double>*p, stackX) delete p;
|
||||
foreach(QVector<double>*q, stackY) delete q;
|
||||
stackX.clear();
|
||||
stackY.clear();
|
||||
stacks.clear();
|
||||
|
||||
int r=0;
|
||||
foreach (MetricDetail metricDetail, settings->metrics) {
|
||||
if (metricDetail.stack == true) {
|
||||
@@ -329,7 +332,7 @@ LTMPlot::setData(LTMSettings *set)
|
||||
current->setSymbol(new QwtSymbol(sym));
|
||||
|
||||
// fudge for date ranges, not for time of day graph
|
||||
// XXX FUDGE QWT's LACK OF A BAR CHART
|
||||
// and fudge qwt'S lack of a decent bar chart
|
||||
// add a zero point at the head and tail so the
|
||||
// histogram columns look nice.
|
||||
// and shift all the x-values left by 0.5 so that
|
||||
@@ -407,9 +410,6 @@ LTMPlot::setData(LTMSettings *set)
|
||||
else
|
||||
createTODCurveData(settings, metricDetail, xdata, ydata, count);
|
||||
|
||||
// no data to plot!
|
||||
// if (count <= 0) continue; //XXX
|
||||
|
||||
// Create a curve
|
||||
QwtPlotCurve *current = new QwtPlotCurve(metricDetail.uname);
|
||||
curves.insert(metricDetail.symbol, current);
|
||||
@@ -615,7 +615,7 @@ LTMPlot::setData(LTMSettings *set)
|
||||
current->setSymbol(new QwtSymbol(sym));
|
||||
|
||||
// fudge for date ranges, not for time of day graph
|
||||
// XXX FUDGE QWT's LACK OF A BAR CHART
|
||||
// fudge qwt'S lack of a decent bar chart
|
||||
// add a zero point at the head and tail so the
|
||||
// histogram columns look nice.
|
||||
// and shift all the x-values left by 0.5 so that
|
||||
@@ -1119,119 +1119,6 @@ LTMPlot::pointClicked(QwtPlotCurve *curve, int index)
|
||||
}
|
||||
}
|
||||
|
||||
// start of date range selection
|
||||
void
|
||||
LTMPlot::pickerAppended(QPoint pos)
|
||||
{ Q_UNUSED( pos )
|
||||
#if 0 //XXX deprecating using the ltm plot to create a date range for now...
|
||||
|
||||
// ony work once we have a chart to do it on
|
||||
if (settings == NULL || settings->groupBy == LTM_TOD) return;
|
||||
|
||||
// allow user to select a date range across the plot
|
||||
if (highlighter) {
|
||||
// detach and delete
|
||||
highlighter->detach();
|
||||
delete highlighter;
|
||||
}
|
||||
highlighter = new QwtPlotCurve("Date Selection");
|
||||
double curveDataX[4]; // simple 4 point line
|
||||
double curveDataY[4]; // simple 4 point line
|
||||
|
||||
// get x
|
||||
int x = invTransform(xBottom, pos.x());
|
||||
|
||||
// trying to select a range on anull plot
|
||||
if (maxY[yLeft] == 0) {
|
||||
enableAxis(yLeft, true);
|
||||
setAxisTitle(yLeft, tr("watts")); // as good as any
|
||||
setAxisScale(yLeft, 0, 1000);
|
||||
maxY[yLeft] = 1000;
|
||||
}
|
||||
|
||||
// get min/max y
|
||||
curveDataX[0]=x;
|
||||
curveDataY[0]=minY[yLeft];
|
||||
curveDataX[1]=x;
|
||||
curveDataY[1]=maxY[yLeft];
|
||||
|
||||
// no right then down - updated by pickerMoved
|
||||
curveDataX[2]=curveDataX[1];
|
||||
curveDataY[2]=curveDataY[1];
|
||||
curveDataX[3]=curveDataX[0];
|
||||
curveDataY[3]=curveDataY[3];
|
||||
|
||||
// color
|
||||
QColor ccol(GColor(CINTERVALHIGHLIGHTER));
|
||||
ccol.setAlpha(64);
|
||||
QPen cpen = QPen(ccol);
|
||||
cpen.setWidth(1.0);
|
||||
QBrush cbrush = QBrush(ccol);
|
||||
highlighter->setPen(cpen);
|
||||
highlighter->setBrush(cbrush);
|
||||
highlighter->setStyle(QwtPlotCurve::Lines);
|
||||
|
||||
highlighter->setData(curveDataX,curveDataY, 4);
|
||||
|
||||
// axis etc
|
||||
highlighter->setYAxis(QwtPlot::yLeft);
|
||||
highlighter->attach(this);
|
||||
highlighter->show();
|
||||
|
||||
// what is the start date?
|
||||
LTMScaleDraw *lsd = new LTMScaleDraw(settings->start,
|
||||
groupForDate(settings->start.date(),
|
||||
settings->groupBy),
|
||||
settings->groupBy);
|
||||
start = lsd->toDate((int)x);
|
||||
end = start.addYears(10);
|
||||
name = QString("%1 - ").arg(start.toString("d MMM yy"));
|
||||
seasonid = settings->ltmTool->newSeason(name, start, end, Season::adhoc);
|
||||
|
||||
replot();
|
||||
#endif
|
||||
}
|
||||
|
||||
// end of date range selection
|
||||
void
|
||||
LTMPlot::pickerMoved(QPoint pos)
|
||||
{ Q_UNUSED( pos )
|
||||
#if 0
|
||||
if (settings == NULL || settings->groupBy == LTM_TOD) return;
|
||||
|
||||
// allow user to select a date range across the plot
|
||||
double curveDataX[4]; // simple 4 point line
|
||||
double curveDataY[4]; // simple 4 point line
|
||||
|
||||
// get x
|
||||
int x = invTransform(xBottom, pos.x());
|
||||
|
||||
// update to reflect new x position
|
||||
curveDataX[0]=highlighter->sample(0).x();
|
||||
curveDataY[0]=highlighter->sample(0).y();
|
||||
curveDataX[1]=highlighter->sample(0).x();
|
||||
curveDataY[1]=highlighter->sample(1).y();
|
||||
curveDataX[2]=x;
|
||||
curveDataY[2]=curveDataY[1];
|
||||
curveDataX[3]=x;
|
||||
curveDataY[3]=curveDataY[3];
|
||||
|
||||
// what is the end date?
|
||||
LTMScaleDraw *lsd = new LTMScaleDraw(settings->start,
|
||||
groupForDate(settings->start.date(),
|
||||
settings->groupBy),
|
||||
settings->groupBy);
|
||||
end = lsd->toDate((int)x);
|
||||
name = QString("%1 - %2").arg(start.toString("d MMM yy"))
|
||||
.arg(end.toString("d MMM yy"));
|
||||
settings->ltmTool->updateSeason(seasonid, name, start, end, Season::adhoc);
|
||||
|
||||
// update and replot highlighter
|
||||
highlighter->setData(curveDataX,curveDataY, 4);
|
||||
replot();
|
||||
#endif
|
||||
}
|
||||
|
||||
// aggregate curve data, adds w to a and
|
||||
// updates a directly. arrays MUST be of
|
||||
// equal dimensions
|
||||
@@ -1244,13 +1131,6 @@ LTMPlot::aggregateCurves(QVector<double> &a, QVector<double>&w)
|
||||
for(int i=0; i<a.size(); i++) a[i] += w[i];
|
||||
}
|
||||
|
||||
void
|
||||
LTMPlot::changeValue(QwtPlotCurve*, int, double)
|
||||
{
|
||||
// point moved, so emit signal with curve name, date and value
|
||||
// XXX does nothing right now
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
* Draw Power Zone Shading on Background (here to end of source file)
|
||||
*
|
||||
@@ -1285,18 +1165,11 @@ class LTMPlotBackground: public QwtPlotItem
|
||||
const Zones *zones = parent->parent->main->zones();
|
||||
int zone_range_size = parent->parent->main->zones()->getRangeSize();
|
||||
|
||||
//fprintf(stderr, "size: %d\n",zone_range_size);
|
||||
if (zone_range_size >= 0) { //parent->shadeZones() &&
|
||||
for (int i = 0; i < zone_range_size; i ++) {
|
||||
int zone_range = i;
|
||||
//int zone_range = zones->whichRange(parent->settings->start.addDays((parent->settings->end.date().toJulianDay()-parent->settings->start.date().toJulianDay())/2).date()); // XXX Damien fixup
|
||||
|
||||
int left = xMap.transform(parent->groupForDate(zones->getStartDate(zone_range), parent->settings->groupBy)- parent->groupForDate(parent->settings->start.date(), parent->settings->groupBy));
|
||||
|
||||
//fprintf(stderr, "%d left: %d\n",i,left);
|
||||
//int right = xMap.transform(parent->groupForDate(zones->getEndDate(zone_range), parent->settings->groupBy)- parent->groupForDate(parent->settings->start.date(), parent->settings->groupBy));
|
||||
//fprintf(stderr, "%d right: %d\n",i,right);
|
||||
|
||||
/* The +50 pixels is for a QWT bug? cover the little gap on the right? */
|
||||
int right = xMap.transform(parent->maxX + 0.5) + 50;
|
||||
|
||||
@@ -1348,7 +1221,7 @@ class LTMPlotZoneLabel: public QwtPlotItem
|
||||
|
||||
const Zones *zones = parent->parent->main->zones();
|
||||
//int zone_range = 0; //parent->parent->mainWindow->zoneRange();
|
||||
int zone_range = zones->whichRange(settings->start.addDays((settings->end.date().toJulianDay()-settings->start.date().toJulianDay())/2).date()); // XXX Damien Fixup
|
||||
int zone_range = zones->whichRange(settings->start.addDays((settings->end.date().toJulianDay()-settings->start.date().toJulianDay())/2).date());
|
||||
|
||||
// which axis has watts?
|
||||
//setAxis(QwtPlot::xBottom, axisid);
|
||||
|
||||
@@ -53,9 +53,6 @@ class LTMPlot : public QwtPlot
|
||||
public slots:
|
||||
void pointHover(QwtPlotCurve*, int);
|
||||
void pointClicked(QwtPlotCurve*, int); // point clicked
|
||||
void changeValue(QwtPlotCurve*, int, double); // point moved
|
||||
void pickerMoved(QPoint);
|
||||
void pickerAppended(QPoint);
|
||||
void configUpdate();
|
||||
|
||||
protected:
|
||||
|
||||
@@ -49,7 +49,7 @@ LTMPopup::LTMPopup(MainWindow *parent) : QWidget(parent), main(parent)
|
||||
|
||||
// ride list...
|
||||
rides = new QTableWidget(this);
|
||||
#ifdef Q_OS_LINUX // XXX QT 4.7 bug, selection-background-color ignored
|
||||
#ifdef Q_OS_LINUX // QT 4.7 bug on Linux, selection-background-color is ignored (no transparency)
|
||||
QWindowsStyle *style = new QWindowsStyle();
|
||||
rides->setStyle(style);
|
||||
#endif
|
||||
|
||||
@@ -220,10 +220,7 @@ LTMSidebar::resetSeasons()
|
||||
}
|
||||
|
||||
// get current back!
|
||||
if (now != "") ; //XXX
|
||||
else {
|
||||
allDateRanges->child(0)->setSelected(true); // just select first child
|
||||
}
|
||||
if (now == "") allDateRanges->child(0)->setSelected(true); // just select first child
|
||||
active = false;
|
||||
}
|
||||
|
||||
@@ -336,14 +333,6 @@ LTMSidebar::eventPopup(QPoint pos)
|
||||
menu.exec(eventTree->mapToGlobal(pos));
|
||||
}
|
||||
|
||||
void
|
||||
LTMSidebar::renameRange() //XXX deprecated
|
||||
{
|
||||
// go edit the name
|
||||
activeDateRange->setFlags(activeDateRange->flags() | Qt::ItemIsEditable);
|
||||
dateRangeTree->editItem(activeDateRange, 0);
|
||||
}
|
||||
|
||||
void
|
||||
LTMSidebar::dateRangeChanged(QTreeWidgetItem*item, int)
|
||||
{
|
||||
@@ -568,7 +557,7 @@ LTMSidebar::setSummary(DateRange dateRange)
|
||||
"<body>"
|
||||
"<center>");
|
||||
|
||||
for (int i=0; i<4; i++) { //XXX taken out maximums -- too much info -- looks ugly
|
||||
for (int i=0; i<4; i++) {
|
||||
|
||||
QString aggname;
|
||||
QStringList list;
|
||||
|
||||
@@ -69,7 +69,6 @@ class LTMSidebar : public QWidget
|
||||
void dateRangeChanged(QTreeWidgetItem *, int);
|
||||
void dateRangeMoved(QTreeWidgetItem *, int, int);
|
||||
void addRange();
|
||||
void renameRange();
|
||||
void editRange();
|
||||
void deleteRange();
|
||||
|
||||
|
||||
@@ -477,7 +477,7 @@ LTMTool::LTMTool(MainWindow *parent, const QDir &home, bool multi) : QWidget(par
|
||||
MetricDetail metametric;
|
||||
metametric.type = METRIC_META;
|
||||
QString underscored = field.name;
|
||||
metametric.symbol = underscored.replace(" ", "_"); //XXX other special chars!!!
|
||||
metametric.symbol = underscored.replace(" ", "_");
|
||||
metametric.metric = NULL; // not a factory metric
|
||||
metametric.penColor = QColor(Qt::blue);
|
||||
metametric.curveStyle = QwtPlotCurve::Lines;
|
||||
|
||||
@@ -153,13 +153,7 @@ LTMWindow::LTMWindow(MainWindow *parent, bool useMetricUnits, const QDir &home)
|
||||
// connect pickers to ltmPlot
|
||||
connect(_canvasPicker, SIGNAL(pointHover(QwtPlotCurve*, int)), ltmPlot, SLOT(pointHover(QwtPlotCurve*, int)));
|
||||
connect(_canvasPicker, SIGNAL(pointClicked(QwtPlotCurve*, int)), ltmPlot, SLOT(pointClicked(QwtPlotCurve*, int)));
|
||||
connect(picker, SIGNAL(moved(QPoint)), ltmPlot, SLOT(pickerMoved(QPoint)));
|
||||
connect(picker, SIGNAL(appended(const QPoint &)), ltmPlot, SLOT(pickerAppended(const QPoint &)));
|
||||
|
||||
// config changes or ride file activities cause a redraw/refresh (but only if visible)
|
||||
//connect(main, SIGNAL(rideSelected()), this, SLOT(rideSelected(void)));
|
||||
//XXX no longer needed since we use dateRange not rideItem for LTM plots on home view
|
||||
//XXX connect(this, SIGNAL(rideItemChanged(RideItem*)), this, SLOT(rideSelected()));
|
||||
connect(main, SIGNAL(rideAdded(RideItem*)), this, SLOT(refresh(void)));
|
||||
connect(main, SIGNAL(rideDeleted(RideItem*)), this, SLOT(refresh(void)));
|
||||
connect(main, SIGNAL(configChanged()), this, SLOT(refresh()));
|
||||
@@ -167,8 +161,6 @@ LTMWindow::LTMWindow(MainWindow *parent, bool useMetricUnits, const QDir &home)
|
||||
|
||||
LTMWindow::~LTMWindow()
|
||||
{
|
||||
//qDebug()<<"delete metricdb... crash!!!";
|
||||
//if (metricDB != NULL) delete metricDB; //XXX CRASH!!!! -- needs fixing
|
||||
delete popup;
|
||||
}
|
||||
|
||||
@@ -278,12 +270,8 @@ LTMWindow::dateRangeChanged(DateRange range)
|
||||
settings.data = &results;
|
||||
settings.measures = &measures;
|
||||
|
||||
// apply filter to new date range too -- will refresh plot
|
||||
// apply filter to new date range too -- will also refresh plot
|
||||
filterChanged();
|
||||
|
||||
//XXX not needed since filter changed will also
|
||||
//XXX call refreshPlot();
|
||||
//refreshPlot();
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -82,7 +82,10 @@ class LTMWindow : public GcChartWindow
|
||||
Q_OBJECT
|
||||
G_OBJECT
|
||||
|
||||
Q_PROPERTY(int chart READ chart WRITE setChart USER true) //XXX hack for now (chart list can change!)
|
||||
Q_PROPERTY(int chart READ chart WRITE setChart USER true) // adding/deleting charts will cause this index to fail
|
||||
// not a big issue since the preset is APPLIED when it is
|
||||
// selected. We don't really need to remember what was used
|
||||
// but it may be helpful to some users
|
||||
Q_PROPERTY(int bin READ bin WRITE setBin USER true)
|
||||
Q_PROPERTY(bool shade READ shade WRITE setShade USER true)
|
||||
Q_PROPERTY(bool legend READ legend WRITE setLegend USER true)
|
||||
|
||||
Reference in New Issue
Block a user