Refactor MainWindow Part 2 of 5

Decoupled classes from MainWindow to reference Context
and Athlete (and introduced a couple of new headers).

We no longer pass around a MainWindow pointer to children
but pass a context instead.

There are still a few pieces left in MainWindow that need
to move to a better place;
    * Setting/clearing filter selection
    * Working with Intervals
    * Adding/Deleting Rides
    * Save on Exit

As mentioned previously there are lots of other parts to
this refactor left to do;
    * break MainWindow Gui elements into Toolbar and Views

    * migrate from RideItem and Ridelist to ActivityCollection
      and Activity classes that are not tied into gui elements.

    * introduce Application Context and AthleteCollection
This commit is contained in:
Mark Liversedge
2013-07-10 13:57:30 +01:00
parent e256783f73
commit 0fcbbe1b77
235 changed files with 2196 additions and 1948 deletions

View File

@@ -21,7 +21,8 @@
#include "TcxParser.h"
#include <QDomDocument>
#include "MainWindow.h"
#include "Context.h"
#include "Athlete.h"
#include "RideMetric.h"
#ifndef GC_VERSION
@@ -51,7 +52,7 @@ RideFile *TcxFileReader::openRideFile(QFile &file, QStringList &errors, QList<Ri
}
QByteArray
TcxFileReader::toByteArray(MainWindow *mainWindow, const RideFile *ride, bool withAlt, bool withWatts, bool withHr, bool withCad) const
TcxFileReader::toByteArray(Context *context, const RideFile *ride, bool withAlt, bool withWatts, bool withHr, bool withCad) const
{
QDomText text;
QDomDocument doc;
@@ -104,7 +105,7 @@ TcxFileReader::toByteArray(MainWindow *mainWindow, const RideFile *ride, bool wi
QStringList worklist = QStringList();
for (int i=0; metrics[i];i++) worklist << metrics[i];
QHash<QString, RideMetricPtr> computed = RideMetric::computeMetrics(mainWindow, ride, mainWindow->athlete->zones(), mainWindow->athlete->hrZones(), worklist);
QHash<QString, RideMetricPtr> computed = RideMetric::computeMetrics(context, ride, context->athlete->zones(), context->athlete->hrZones(), worklist);
QDomElement lap_time = doc.createElement("TotalTimeSeconds");
text = doc.createTextNode(QString("%1").arg(computed.value("workout_time")->value(true)));
@@ -397,9 +398,9 @@ TcxFileReader::toByteArray(MainWindow *mainWindow, const RideFile *ride, bool wi
}
bool
TcxFileReader::writeRideFile(MainWindow *mainWindow, const RideFile *ride, QFile &file) const
TcxFileReader::writeRideFile(Context *context, const RideFile *ride, QFile &file) const
{
QByteArray xml = toByteArray(mainWindow, ride, true, true, true, true);
QByteArray xml = toByteArray(context, ride, true, true, true, true);
if (!file.open(QIODevice::WriteOnly)) return(false);
if (file.write(xml) != xml.size()) return(false);