remove global ptr to main window from ErgFile

This commit is contained in:
Sean Rhea
2009-12-13 12:41:14 -05:00
parent 890151a696
commit eb257e0746
3 changed files with 9 additions and 10 deletions

View File

@@ -19,11 +19,10 @@
#include "ErgFile.h"
ErgFile::ErgFile(QString filename, int &mode)
ErgFile::ErgFile(QString filename, int &mode, double Cp)
{
QFile ergFile(filename);
int section = NOMANSLAND; // section 0=init, 1=header data, 2=course data
double Cp=285; // default to 285 if zones are not set
leftPoint=rightPoint=0;
MaxWatts = Ftp = 0;
int lapcounter = 0;
@@ -33,11 +32,6 @@ ErgFile::ErgFile(QString filename, int &mode)
long rdist = 0; // running total for distance
long ralt = 200; // always start at 200 meters just to prettify the graph
// Get users CP for relative watts calculations
QDate today = QDate::currentDate();
int range = mainwindow->zones()->whichRange(today);
if (range != -1) Cp = mainwindow->zones()->getCP(range);
// open the file
if (ergFile.open(QIODevice::ReadOnly | QIODevice::Text) == false) {
valid = false;

View File

@@ -29,7 +29,6 @@
#include <QTextStream>
#include <QRegExp>
#include "Zones.h" // For zones ... see below vvvv
#include "MainWindow.h" // gets access to mainwindow to read zones info
// which section of the file are we in?
#define NOMANSLAND 0
@@ -61,7 +60,7 @@ class ErgFileLap
class ErgFile
{
public:
ErgFile(QString, int&); // constructor uses filename
ErgFile(QString, int&, double Cp); // constructor uses filename
~ErgFile(); // delete the contents
bool isValid(); // is the file valid or not?

View File

@@ -716,7 +716,13 @@ RealtimeWindow::SelectWorkout(int index)
tr("Open Workout File"), home.dirName(), tr("Workout Files (*.erg *.mrc *.crs)"));
if (!filename.isEmpty()) {
ergFile = new ErgFile(filename, mode);
// Get users CP for relative watts calculations
QDate today = QDate::currentDate();
double Cp=285; // default to 285 if zones are not set
int range = main->zones()->whichRange(today);
if (range != -1) Cp = main->zones()->getCP(range);
ergFile = new ErgFile(filename, mode, Cp);
if (ergFile->isValid()) {
// success! we have a load file