RideFile reading refactoring

With the introduction of the rideSelected signal the RideFile was
opened (as previously) by the RideSummaryWindow::htmlSummary()
member. In some cases, this signal was processed by RideSummary window
AFTER the other charts (AllPlot etc) this results in 'No data' being
shown on other charts.

This patch moves the file reading to RideItem::ride() which was previously
a public RideFile * (that is now a protected member ride_). As a happy by
product it removes the need to check if the file has already been read
across all other functions ensuring in-core values are not accidentally
overwritten. The read errors are made available by a new RideItem::errors()
member.

This modification is required to support the RideImportWizard in freeing
loaded RideFiles during batch import to ensure virtual memory is not
exhausted when large numbers of files are imported at once. This modification
is also included in this patch.
This commit is contained in:
Mark Liversedge
2009-12-18 19:05:13 +00:00
committed by Sean Rhea
parent 71d67e2203
commit feb111a4ff
12 changed files with 68 additions and 60 deletions

View File

@@ -232,8 +232,8 @@ AllPlotWindow::setSmoothingFromLineEdit()
void
AllPlotWindow::setAllPlotWidgets(RideItem *ride)
{
if (ride->ride && ride->ride->deviceType() != QString("Manual CSV")) {
const RideFileDataPresent *dataPresent = ride->ride->areDataPresent();
if (ride->ride() && ride->ride()->deviceType() != QString("Manual CSV")) {
const RideFileDataPresent *dataPresent = ride->ride()->areDataPresent();
showPower->setEnabled(dataPresent->watts);
showHr->setEnabled(dataPresent->hr);
showSpeed->setEnabled(dataPresent->kph);
@@ -345,7 +345,7 @@ AllPlotWindow::setEndSelection(double xValue, bool newInterval, QString name)
x2 *= KM_PER_MILE;
}
foreach (const RideFilePoint *point, ride->ride->dataPoints()) {
foreach (const RideFilePoint *point, ride->ride()->dataPoints()) {
if ((allPlot->byDistance()==true && point->km>=x1 && point->km<x2) ||
(allPlot->byDistance()==false && point->secs/60>=x1 && point->secs/60<x2)) {
@@ -356,7 +356,7 @@ AllPlotWindow::setEndSelection(double xValue, bool newInterval, QString name)
duration2 = point->secs;
if (point->kph > 0.0)
secsMoving += ride->ride->recIntSecs();
secsMoving += ride->ride()->recIntSecs();
wattsTotal += point->watts;
bpmTotal += point->hr;
++arrayLength;
@@ -405,7 +405,7 @@ AllPlotWindow::setEndSelection(double xValue, bool newInterval, QString name)
// add average power to the end of the selection name
name += QString("(%1 watts)").arg(round((wattsTotal && arrayLength) ? wattsTotal/arrayLength : 0));
QTreeWidgetItem *last = new IntervalItem(ride->ride, name, duration1, duration2, distance1, distance2);
QTreeWidgetItem *last = new IntervalItem(ride->ride(), name, duration1, duration2, distance1, distance2);
allIntervals->addChild(last);
// now update the RideFileIntervals and all the plots etc