From c79f4e6497dfb17ccb89b3678026d18a76cf15c1 Mon Sep 17 00:00:00 2001 From: Sean Rhea Date: Sun, 13 Dec 2009 10:06:28 -0500 Subject: [PATCH] remove global mainwindow pointer from PowerHist --- src/HistogramWindow.cpp | 2 +- src/PowerHist.cpp | 9 +++++---- src/PowerHist.h | 4 +++- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/HistogramWindow.cpp b/src/HistogramWindow.cpp index 6fc8ea90e..14c52e7b4 100644 --- a/src/HistogramWindow.cpp +++ b/src/HistogramWindow.cpp @@ -52,7 +52,7 @@ HistogramWindow::HistogramWindow(MainWindow *mainWindow) : histParameterCombo = new QComboBox(); binWidthLayout->addWidget(histParameterCombo); - powerHist = new PowerHist(); + powerHist = new PowerHist(mainWindow); setHistTextValidator(); lnYHistCheckBox->setChecked(powerHist->islnY()); diff --git a/src/PowerHist.cpp b/src/PowerHist.cpp index 9be74abca..80c64653a 100644 --- a/src/PowerHist.cpp +++ b/src/PowerHist.cpp @@ -197,9 +197,10 @@ public: } }; -PowerHist::PowerHist(): +PowerHist::PowerHist(MainWindow *mainWindow): selected(wattsShaded), rideItem(NULL), + mainWindow(mainWindow), binw(20), withz(true), settings(NULL), @@ -706,9 +707,9 @@ bool PowerHist::shadeZones() const } bool PowerHist::isSelected(const RideFilePoint *p) { - if (mainwindow!= NULL && mainwindow->allIntervalItems() != NULL) { - for (int i=0; iallIntervalItems()->childCount(); i++) { - IntervalItem *current = (IntervalItem *)mainwindow->allIntervalItems()->child(i); + if (mainWindow->allIntervalItems() != NULL) { + for (int i=0; iallIntervalItems()->childCount(); i++) { + IntervalItem *current = dynamic_cast(mainWindow->allIntervalItems()->child(i)); if (current != NULL) { if (current->isSelected() && p->secs>=current->start && p->secs<=current->stop) { return true; diff --git a/src/PowerHist.h b/src/PowerHist.h index 3db5dbb1d..c8f3e5f22 100644 --- a/src/PowerHist.h +++ b/src/PowerHist.h @@ -25,6 +25,7 @@ class QwtPlotCurve; class QwtPlotGrid; +class MainWindow; class RideItem; class RideFilePoint; class PowerHistBackground; @@ -40,7 +41,7 @@ class PowerHist : public QwtPlot QwtPlotCurve *curve, *curveSelected; QList zoneLabels; - PowerHist(); + PowerHist(MainWindow *mainWindow); ~PowerHist(); int binWidth() const { return binw; } @@ -80,6 +81,7 @@ class PowerHist : public QwtPlot protected: + MainWindow *mainWindow; QwtPlotGrid *grid; // storage for data counts