From 8f53e1c2da68a433ce4fa8838d50cc80b0582183 Mon Sep 17 00:00:00 2001 From: Mark Liversedge Date: Sun, 7 Aug 2011 09:39:13 +0100 Subject: [PATCH] Refresh CP curve when rides added/deleted This patch forces a refresh of the CP curve plot (if it is visible) when rides are added or deleted. Fixes #400. --- src/CriticalPowerWindow.cpp | 15 +++++++++++++-- src/CriticalPowerWindow.h | 2 +- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/CriticalPowerWindow.cpp b/src/CriticalPowerWindow.cpp index 40bbd58ac..7dfe08035 100644 --- a/src/CriticalPowerWindow.cpp +++ b/src/CriticalPowerWindow.cpp @@ -101,12 +101,23 @@ CriticalPowerWindow::CriticalPowerWindow(const QDir &home, MainWindow *parent) : // redraw on config change -- this seems the simplest approach connect(mainWindow, SIGNAL(configChanged()), this, SLOT(rideSelected())); + connect(mainWindow, SIGNAL(rideAdded(RideItem*)), this, SLOT(newRideAdded(RideItem*))); + connect(mainWindow, SIGNAL(rideDeleted(RideItem*)), this, SLOT(newRideAdded(RideItem*))); } void -CriticalPowerWindow::newRideAdded() +CriticalPowerWindow::newRideAdded(RideItem *here) { - // XXX + Season season = seasons.at(cComboSeason->currentIndex()); + + // Refresh global curve if a ride is added during those dates + if ((here->dateTime.date() >= season.getStart() || season.getStart() == QDate()) + && (here->dateTime.date() <= season.getEnd() || season.getEnd() == QDate())) + cpintPlot->changeSeason(season.getStart(), season.getEnd()); + + // if visible make the changes visible + // rideSelected is easiest way + if (amVisible()) rideSelected(); } void diff --git a/src/CriticalPowerWindow.h b/src/CriticalPowerWindow.h index ec225162b..8b03abf2d 100644 --- a/src/CriticalPowerWindow.h +++ b/src/CriticalPowerWindow.h @@ -41,7 +41,6 @@ class CriticalPowerWindow : public GcWindow CriticalPowerWindow(const QDir &home, MainWindow *parent); - void newRideAdded(); void deleteCpiFile(QString filename); // set/get properties @@ -56,6 +55,7 @@ class CriticalPowerWindow : public GcWindow } protected slots: + void newRideAdded(RideItem*); void cpintTimeValueEntered(); void cpintSetCPButtonClicked(); void pickerMoved(const QPoint &pos);