From 5abf1eae97bff0727010eb832cdfd34d6d5004aa Mon Sep 17 00:00:00 2001 From: Mark Liversedge Date: Fri, 19 Jul 2013 18:08:07 +0100 Subject: [PATCH] A little less MainWindow .. trying to remove it from as many headers as possible. --- src/CriticalPowerWindow.h | 3 ++- src/GcCalendarModel.h | 2 +- src/HistogramWindow.h | 3 ++- src/LTMWindow.h | 2 +- src/LionFullScreen.h | 7 +++---- src/LionFullScreen.mm | 13 +++++++------ src/MainWindow.cpp | 4 ++-- src/MergeActivityWizard.cpp | 1 + src/MergeActivityWizard.h | 1 - src/PowerHist.h | 2 +- src/QTFullScreen.cpp | 12 ++++++------ src/QTFullScreen.h | 5 ++--- src/RideSummaryWindow.h | 2 +- src/RideWindow.h | 3 +-- src/TreeMapWindow.h | 2 +- 15 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/CriticalPowerWindow.h b/src/CriticalPowerWindow.h index 1fac3ddea..d0395ce3f 100644 --- a/src/CriticalPowerWindow.h +++ b/src/CriticalPowerWindow.h @@ -19,10 +19,11 @@ #ifndef _GC_CriticalPowerWindow_h #define _GC_CriticalPowerWindow_h 1 #include "GoldenCheetah.h" +#include "MainWindow.h" // for isfiltered and filters #include -#include "MainWindow.h" #include "Season.h" +#include "RideFile.h" #ifdef GC_HAVE_LUCENE #include "SearchFilterBox.h" #endif diff --git a/src/GcCalendarModel.h b/src/GcCalendarModel.h index ad7bd2527..676cca59f 100644 --- a/src/GcCalendarModel.h +++ b/src/GcCalendarModel.h @@ -35,13 +35,13 @@ #ifndef _GC_GcCalendarModel_h #define _GC_GcCalendarModel_h 1 #include "GoldenCheetah.h" +#include "MainWindow.h" #include #include #include "qxtscheduleview.h" #include "Context.h" #include "Athlete.h" -#include "MainWindow.h" #include "RideItem.h" #include "RideMetadata.h" #ifdef GC_HAVE_ICAL diff --git a/src/HistogramWindow.h b/src/HistogramWindow.h index aa52b39e0..4bb448e80 100644 --- a/src/HistogramWindow.h +++ b/src/HistogramWindow.h @@ -20,7 +20,8 @@ #ifndef _GC_HistogramWindow_h #define _GC_HistogramWindow_h 1 #include "GoldenCheetah.h" -#include "MainWindow.h" +#include "MainWindow.h" // for isfiltered and filters + #include "Context.h" #include "Athlete.h" #include "MetricAggregator.h" diff --git a/src/LTMWindow.h b/src/LTMWindow.h index 655919a3c..6aabf3f83 100644 --- a/src/LTMWindow.h +++ b/src/LTMWindow.h @@ -19,10 +19,10 @@ #ifndef _GC_LTMWindow_h #define _GC_LTMWindow_h 1 #include "GoldenCheetah.h" +#include "MainWindow.h" // for isfiltered and filters #include #include -#include "MainWindow.h" #include "Context.h" #include "MetricAggregator.h" #include "Season.h" diff --git a/src/LionFullScreen.h b/src/LionFullScreen.h index 2f74927e1..5fce16097 100644 --- a/src/LionFullScreen.h +++ b/src/LionFullScreen.h @@ -19,11 +19,10 @@ #ifndef _GC_LionFullScreen_h #define _GC_LionFullScreen_h 1 -#include "GoldenCheetah.h" +#include "Context.h" // QT stuff etc #include -#include "MainWindow.h" class LionFullScreen : public QObject { @@ -31,7 +30,7 @@ class LionFullScreen : public QObject public: - LionFullScreen(MainWindow *main); + LionFullScreen(Context *context); // found in the supplied directory void toggle(); @@ -40,7 +39,7 @@ class LionFullScreen : public QObject bool eventFilter(QObject *obj, QEvent *event); private: - MainWindow *main; + Context *context; }; #endif // _GC_LionFullScreen_h diff --git a/src/LionFullScreen.mm b/src/LionFullScreen.mm index 30508b00a..1d4b9d353 100644 --- a/src/LionFullScreen.mm +++ b/src/LionFullScreen.mm @@ -17,20 +17,21 @@ */ #include "LionFullScreen.h" +#include "MainWindow.h" // which version of the SDK? #include -LionFullScreen::LionFullScreen(MainWindow *main) : QObject(main), main(main) +LionFullScreen::LionFullScreen(Context *context) : QObject(context->mainWindow), context(context) { #ifdef GC_HAVE_LION // lets enable fullscreen stuff - NSView *nsview = (NSView *) main->winId(); + NSView *nsview = (NSView *) context->mainWindow->winId(); NSWindow *nswindow = [nsview window]; [nswindow setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary]; // watch for ESC key being hit when in full screen - main->installEventFilter(this); + context->mainWindow->installEventFilter(this); #endif } @@ -38,7 +39,7 @@ bool LionFullScreen::eventFilter(QObject *obj, QEvent *event) { #ifdef GC_HAVE_LION - if (obj != main) return false; + if (obj != context->mainWindow) return false; // Ctrl-Cmd-F toggles if (event->type() == QEvent::KeyPress && @@ -53,7 +54,7 @@ LionFullScreen::eventFilter(QObject *obj, QEvent *event) if (event->type() == QEvent::KeyPress && static_cast(event)->key() == Qt::Key_Escape) { // if in full screen then toggle, otherwise do nothing - NSView *nsview = (NSView *) main->winId(); + NSView *nsview = (NSView *) context->mainWindow->winId(); NSWindow *nswindow = [nsview window]; NSUInteger masks = [nswindow styleMask]; if (masks & NSFullScreenWindowMask) toggle(); @@ -69,7 +70,7 @@ LionFullScreen::toggle() { #ifdef GC_HAVE_LION // toggle full screen back - NSView *nsview = (NSView *) main->winId(); + NSView *nsview = (NSView *) context->mainWindow->winId(); NSWindow *nswindow = [nsview window]; [nswindow toggleFullScreen:nil]; #endif diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 8b9cf3508..8150ed087 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -160,10 +160,10 @@ MainWindow::MainWindow(const QDir &home) : static const QIcon fullIcon(":images/toolbar/main/togglefull.png"); #if (defined Q_OS_MAC) && (defined GC_HAVE_LION) - fullScreen = new LionFullScreen(this); + fullScreen = new LionFullScreen(context); #endif #ifndef Q_OS_MAC - fullScreen = new QTFullScreen(this); + fullScreen = new QTFullScreen(context); #endif // if no workout directory is configured, default to the diff --git a/src/MergeActivityWizard.cpp b/src/MergeActivityWizard.cpp index fcb0f63fa..95d82ab21 100644 --- a/src/MergeActivityWizard.cpp +++ b/src/MergeActivityWizard.cpp @@ -18,6 +18,7 @@ #include "MergeActivityWizard.h" #include "Context.h" +#include "MainWindow.h" /** * Wizard to merge 2 files from same ride diff --git a/src/MergeActivityWizard.h b/src/MergeActivityWizard.h index d4a7ba692..bd11b5eaa 100644 --- a/src/MergeActivityWizard.h +++ b/src/MergeActivityWizard.h @@ -19,7 +19,6 @@ #ifndef _MergeActivityWizard_h #define _MergeActivityWizard_h #include "GoldenCheetah.h" -#include "MainWindow.h" #include "RideItem.h" #include "RideFile.h" #include "RideFile.h" diff --git a/src/PowerHist.h b/src/PowerHist.h index 72428696b..12c83e6a4 100644 --- a/src/PowerHist.h +++ b/src/PowerHist.h @@ -20,8 +20,8 @@ #ifndef _GC_PowerHist_h #define _GC_PowerHist_h 1 #include "GoldenCheetah.h" -#include "MainWindow.h" #include "RideFile.h" +#include "RideItem.h" #include "Context.h" #include "Athlete.h" #include "Zones.h" diff --git a/src/QTFullScreen.cpp b/src/QTFullScreen.cpp index 4b3144dd7..3339115b9 100644 --- a/src/QTFullScreen.cpp +++ b/src/QTFullScreen.cpp @@ -18,16 +18,16 @@ #include "QTFullScreen.h" -QTFullScreen::QTFullScreen(MainWindow *mainWindow) : QObject(mainWindow), mainWindow(mainWindow), isFull(false) +QTFullScreen::QTFullScreen(Context *context) : QObject(context->mainWindow), context(context), isFull(false) { // watch for ESC key being hit when in full screen - mainWindow->installEventFilter(this); + context->mainWindow->installEventFilter(this); } bool QTFullScreen::eventFilter(QObject *obj, QEvent *event) { - if (obj != mainWindow) return false; + if (obj != context->mainWindow) return false; // F11 toggle full screen if (event->type() == QEvent::KeyPress && static_cast(event)->key() == Qt::Key_F11) { @@ -39,7 +39,7 @@ QTFullScreen::eventFilter(QObject *obj, QEvent *event) // if in full screen then toggle, otherwise do nothing if (isFull) { - mainWindow->showNormal(); + context->mainWindow->showNormal(); isFull = false; } return false; @@ -52,9 +52,9 @@ void QTFullScreen::toggle() { if (isFull) { - mainWindow->showNormal(); + context->mainWindow->showNormal(); } else { - mainWindow->showFullScreen(); + context->mainWindow->showFullScreen(); } isFull = !isFull; } diff --git a/src/QTFullScreen.h b/src/QTFullScreen.h index c4dc56af9..75aaeb30b 100644 --- a/src/QTFullScreen.h +++ b/src/QTFullScreen.h @@ -24,7 +24,6 @@ // QT stuff etc #include -#include "MainWindow.h" class QTFullScreen : public QObject { @@ -32,7 +31,7 @@ class QTFullScreen : public QObject public: - QTFullScreen(MainWindow *mainWindow); + QTFullScreen(Context *context); // found in the supplied directory void toggle(); @@ -41,7 +40,7 @@ class QTFullScreen : public QObject bool eventFilter(QObject *obj, QEvent *event); private: - MainWindow *mainWindow; + Context *context; bool isFull; }; diff --git a/src/RideSummaryWindow.h b/src/RideSummaryWindow.h index 5dd817b22..33e9e8301 100644 --- a/src/RideSummaryWindow.h +++ b/src/RideSummaryWindow.h @@ -19,7 +19,7 @@ #ifndef _GC_RideSummaryWindow_h #define _GC_RideSummaryWindow_h 1 #include "GoldenCheetah.h" -#include "MainWindow.h" +#include "MainWindow.h" // for isfiltered and filters #include "Context.h" #include diff --git a/src/RideWindow.h b/src/RideWindow.h index 9322c0e63..745f4a11f 100644 --- a/src/RideWindow.h +++ b/src/RideWindow.h @@ -28,7 +28,6 @@ #include #include "TrainSidebar.h" #include "RealtimeController.h" -#include "MainWindow.h" #include "RideItem.h" #include "RideFile.h" @@ -320,7 +319,7 @@ public: RealtimeRider(Context *context) { curPosition = 1; - connect(context->mainWindow,SIGNAL(telemetryUpdate(const RealtimeData &)), this,SLOT(telemetryUpdate(const RealtimeData &))); + connect(context,SIGNAL(telemetryUpdate(const RealtimeData &)), this,SLOT(telemetryUpdate(const RealtimeData &))); } }; diff --git a/src/TreeMapWindow.h b/src/TreeMapWindow.h index 1f01a6225..901a5a889 100644 --- a/src/TreeMapWindow.h +++ b/src/TreeMapWindow.h @@ -19,7 +19,7 @@ #ifndef _GC_TreeMapWindow_h #define _GC_TreeMapWindow_h 1 #include "GoldenCheetah.h" -#include "MainWindow.h" +#include "MainWindow.h" // or isfiltered and filters #include #include