diff --git a/src/CpintPlot.cpp b/src/CpintPlot.cpp index a8c469b16..8bad4f583 100644 --- a/src/CpintPlot.cpp +++ b/src/CpintPlot.cpp @@ -256,6 +256,17 @@ read_one(const QDir& dir, const QString &filename, QVector &bests, return 0; } +void +CpintPlot::changeSeason(const QDate &start, const QDate &end) +{ + startDate = start; + endDate = end; + needToScanRides = true; + delete CPCurve; + CPCurve = NULL; + clear_CP_Curves(); +} + void CpintPlot::setEnergyMode(bool value) { diff --git a/src/CpintPlot.h b/src/CpintPlot.h index b5f202e99..5e0b53d82 100644 --- a/src/CpintPlot.h +++ b/src/CpintPlot.h @@ -47,8 +47,7 @@ class CpintPlot : public QwtPlot double cp, tau, t0; // CP model parameters void deriveCPParameters(); bool deleteCpiFile(QString filename); - void setStartDate(QDate date) { startDate = date; } - void setEndDate(QDate date) { endDate = date; } + void changeSeason(const QDate &start, const QDate &end); void setEnergyMode(bool value); bool energyMode() const { return energyMode_; } diff --git a/src/CriticalPowerWindow.cpp b/src/CriticalPowerWindow.cpp index 9a6965386..e628f5522 100644 --- a/src/CriticalPowerWindow.cpp +++ b/src/CriticalPowerWindow.cpp @@ -238,17 +238,14 @@ void CriticalPowerWindow::addSeasons() if (!seasons.empty()) { cComboSeason->setCurrentIndex(cComboSeason->count() - 1); Season season = seasons.last(); - cpintPlot->setStartDate(season.getStart()); - cpintPlot->setEndDate(season.getEnd()); + cpintPlot->changeSeason(season.getStart(), season.getEnd()); } } void CriticalPowerWindow::seasonSelected(int iSeason) { Season season = seasons.at(iSeason); - cpintPlot->setStartDate(season.getStart()); - cpintPlot->setEndDate(season.getEnd()); - cpintPlot->needToScanRides = true; + cpintPlot->changeSeason(season.getStart(), season.getEnd()); cpintPlot->calculate(currentRide); }