Remove CP friend class

.. its a hack, and wasn't really needed

.. also reimplemented getBest() functions since they
   incorreclty assumed that bestsCache would never be NULL
This commit is contained in:
Mark Liversedge
2014-03-26 11:04:49 +00:00
parent 987176c50e
commit e275a74561
3 changed files with 30 additions and 18 deletions

View File

@@ -625,6 +625,22 @@ CPPlot::clearCurves()
}
}
// get bests or an empty set if it is null
QVector<double>
CPPlot::getBests()
{
if (bestsCache) return bestsCache->meanMaxArray(rideSeries);
else return QVector<double>();
}
// get bests dates or an empty set if it is null
QVector<QDate>
CPPlot::getBestDates()
{
if (bestsCache) return bestsCache->meanMaxDates(rideSeries);
else return QVector<QDate>();
}
// plot the bests curve and refresh the data if needed too
void
CPPlot::plotBests()

View File

@@ -59,6 +59,7 @@ class CPPlot : public QwtPlot
CPPlot(QWidget *parent, Context *, bool rangemode);
// setters
void setRide(RideItem *rideItem);
void setDateRange(const QDate &start, const QDate &end);
void setShowPercent(bool x);
void setShowHeat(bool x);
@@ -71,6 +72,18 @@ class CPPlot : public QwtPlot
void setModel(int sanI1, int sanI2, int anI1, int anI2,
int aeI1, int aeI2, int laeI1, int laeI2, int model);
// getters
QVector<double> getBests();
QVector<QDate> getBestDates();
const QwtPlotCurve *getThisCurve() const { return rideCurve; }
const QwtPlotCurve *getModelCurve() const { return modelCurve; }
// when rides saved/deleted/added CPWindow
// needs to know what range we have plotted
// to decide if it needs refreshing
QDate startDate;
QDate endDate;
public slots:
// colors/appearance changed
@@ -83,26 +96,9 @@ class CPPlot : public QwtPlot
void clearFilter();
void setFilter(QStringList);
protected:
friend class ::CriticalPowerWindow;
// when rides saved/deleted/added CPWindow
// needs to know what range we have plotted
// to decide if it needs refreshing
QDate startDate;
QDate endDate;
private:
// getters
QVector<double> getBests() { return bestsCache->meanMaxArray(rideSeries); }
QVector<QDate> getBestDates() { return bestsCache->meanMaxDates(rideSeries); }
const QwtPlotCurve *getThisCurve() const { return rideCurve; }
const QwtPlotCurve *getModelCurve() const { return modelCurve; }
// calculate / data setting
void setRide(RideItem *rideItem);
void calculateForDateRanges(QList<CompareDateRange> compareDateRanges);
void calculateForIntervals(QList<CompareInterval> compareIntervals);
void deriveCPParameters();

View File

@@ -1052,7 +1052,7 @@ CriticalPowerWindow::updateCpint(double minutes)
{
QString label;
int index = (int) ceil(minutes * 60);
if (index >= 0 && cpPlot->bestsCache && cpPlot->getBests().count() > index) {
if (index >= 0 && cpPlot->getBests().count() > index) {
QDate date = cpPlot->getBestDates()[index];
double value = cpPlot->getBests()[index];