diff --git a/src/IntervalSummaryWindow.cpp b/src/IntervalSummaryWindow.cpp
index 6556dead1..1227cef86 100644
--- a/src/IntervalSummaryWindow.cpp
+++ b/src/IntervalSummaryWindow.cpp
@@ -74,7 +74,7 @@ void IntervalSummaryWindow::intervalSelected()
html += "
";
// summarise all the intervals selected - this is painful!
- //if (rideItem->intervalsSelected().count()>1) summarise(rideItem->intervalsSelected(), html);
+ if (rideItem->intervalsSelected().count()>1) html += summary(rideItem->intervalsSelected());
// summary for each of the currently selected intervals
foreach(IntervalItem *interval, rideItem->intervalsSelected()) html += summary(interval);
@@ -123,8 +123,7 @@ static bool contains(const RideFile*ride, QList intervals, int in
return false;
}
-#if 0
-void IntervalSummaryWindow::calcInterval(QList intervals, QString &html)
+QString IntervalSummaryWindow::summary(QList intervals)
{
// We need to create a special ridefile just for the selected intervals
// to calculate the aggregated metrics because intervals can OVERLAP!
@@ -171,11 +170,42 @@ void IntervalSummaryWindow::calcInterval(QList intervals, QString
}
}
- // EEK this is getting complicated !
- // WE NEED TO CREATE A TEMPORARY INTERVALITEM TOO..............
- //XXX REFACTOR summary(QString("%1 intervals").arg(intervals.count()), html);
+ QString s;
+ if (appsettings->contains(GC_SETTINGS_INTERVAL_METRICS))
+ s = appsettings->value(this, GC_SETTINGS_INTERVAL_METRICS).toString();
+ else
+ s = GC_SETTINGS_INTERVAL_METRICS_DEFAULT;
+ QStringList intervalMetrics = s.split(",");
+
+ const RideMetricFactory &factory = RideMetricFactory::instance();
+ QHash metrics =
+ RideMetric::computeMetrics(context, &f, context->athlete->zones(), context->athlete->hrZones(), intervalMetrics);
+
+ // create temp interval item to use by interval summary
+ IntervalItem temp;
+
+ // pack the metrics away and clean up if needed
+ temp.metrics().fill(0, factory.metricCount());
+
+ // snaffle away all the computed values into the array
+ QHashIterator i(metrics);
+ while (i.hasNext()) {
+ i.next();
+ temp.metrics()[i.value()->index()] = i.value()->value();
+ }
+
+ // clean any bad values
+ for(int j=0; jrideItem_;
+
+ // use standard method from above
+ return summary(&temp);
}
-#endif
QString IntervalSummaryWindow::summary(IntervalItem *interval)
{
@@ -224,81 +254,3 @@ QString IntervalSummaryWindow::summary(IntervalItem *interval)
return html;
}
-
-#if 0
-void IntervalSummaryWindow::calcInterval(RideFileInterval interval, QString& html)
-{
- const RideFile* ride = context->ride ? context->ride->ride() : NULL;
-
- bool metricUnits = context->athlete->useMetricUnits;
-
- RideFile f(const_cast(ride));
- int start = ride->timeIndex(interval.start);
- int end = ride->timeIndex(interval.stop);
- for (int i = start; i <= end; ++i) {
- const RideFilePoint *p = ride->dataPoints()[i];
- f.appendPoint(p->secs, p->cad, p->hr, p->km, p->kph, p->nm,
- p->watts, p->alt, p->lon, p->lat, p->headwind, p->slope, p->temp, p->lrbalance,
- p->lte, p->rte, p->lps, p->rps,
- p->lpco, p->rpco,
- p->lppb, p->rppb, p->lppe, p->rppe,
- p->lpppb, p->rpppb, p->lpppe, p->rpppe,
- p->smo2, p->thb,
- p->rvert, p->rcad, p->rcontact, 0);
-
- // derived data
- RideFilePoint *l = f.dataPoints().last();
- l->np = p->np;
- l->xp = p->xp;
- l->apower = p->apower;
- }
- if (f.dataPoints().size() == 0) {
- // Interval empty, do not compute any metrics
- html += "" + tr("empty interval") + "";
- }
-
- QString s;
- if (appsettings->contains(GC_SETTINGS_INTERVAL_METRICS))
- s = appsettings->value(this, GC_SETTINGS_INTERVAL_METRICS).toString();
- else
- s = GC_SETTINGS_INTERVAL_METRICS_DEFAULT;
- QStringList intervalMetrics = s.split(",");
-
- QHash metrics =
- RideMetric::computeMetrics(context, &f, context->athlete->zones(), context->athlete->hrZones(), intervalMetrics);
-
- html += "" + interval.name + "";
- html += "";
-
- RideItem *rideItem = const_cast(context->currentRideItem());
-
- foreach (QString symbol, intervalMetrics) {
- RideMetricPtr m = metrics.value(symbol);
- if (!m) continue;
-
- // skip metrics that are not relevant for this ride
- if (!rideItem || m->isRelevantForRide(rideItem) == false) continue;
-
-
- html += "";
- // left column (names)
- html += "| " + m->name() + " | ";
-
- // right column (values)
- QString s("%1 | ");
- html += s.arg(m->toString(metricUnits));
- html += "";
- if (m->units(metricUnits) == "seconds" ||
- m->units(metricUnits) == tr("seconds"))
- ; // don't do anything
- else if (m->units(metricUnits).size() > 0)
- html += m->units(metricUnits);
- html += " | ";
-
- html += "
";
-
- }
- html += "
";
-}
-#endif
diff --git a/src/IntervalSummaryWindow.h b/src/IntervalSummaryWindow.h
index 8d2ecbb6b..7e6d3625b 100644
--- a/src/IntervalSummaryWindow.h
+++ b/src/IntervalSummaryWindow.h
@@ -40,7 +40,7 @@ public slots:
void intervalHover(IntervalItem*);
protected:
- //XXX refactor void summarise(QList, QString& html); // summarise for all intervals
+ QString summary(QList);
QString summary(IntervalItem *);
Context *context;