mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-14 16:39:57 +00:00
Refactor MainWindow Part 2 of 5
Decoupled classes from MainWindow to reference Context
and Athlete (and introduced a couple of new headers).
We no longer pass around a MainWindow pointer to children
but pass a context instead.
There are still a few pieces left in MainWindow that need
to move to a better place;
* Setting/clearing filter selection
* Working with Intervals
* Adding/Deleting Rides
* Save on Exit
As mentioned previously there are lots of other parts to
this refactor left to do;
* break MainWindow Gui elements into Toolbar and Views
* migrate from RideItem and Ridelist to ActivityCollection
and Activity classes that are not tied into gui elements.
* introduce Application Context and AthleteCollection
This commit is contained in:
@@ -19,10 +19,12 @@
|
||||
|
||||
#include "GoogleMapControl.h"
|
||||
|
||||
#include "MainWindow.h"
|
||||
#include "RideItem.h"
|
||||
#include "RideFile.h"
|
||||
#include "IntervalItem.h"
|
||||
#include "MainWindow.h"
|
||||
#include "Context.h"
|
||||
#include "Athlete.h"
|
||||
#include "Zones.h"
|
||||
#include "Settings.h"
|
||||
#include "Colors.h"
|
||||
@@ -31,7 +33,7 @@
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
GoogleMapControl::GoogleMapControl(MainWindow *mw) : GcChartWindow(mw), main(mw), range(-1), current(NULL)
|
||||
GoogleMapControl::GoogleMapControl(Context *context) : GcChartWindow(context), context(context), range(-1), current(NULL)
|
||||
{
|
||||
setInstanceName("Google Map");
|
||||
setControls(NULL);
|
||||
@@ -41,7 +43,7 @@ GoogleMapControl::GoogleMapControl(MainWindow *mw) : GcChartWindow(mw), main(mw)
|
||||
layout->setContentsMargins(2,0,2,2);
|
||||
setChartLayout(layout);
|
||||
|
||||
parent = mw;
|
||||
//XXX ???? parent = context->mainWindow;;
|
||||
view = new QWebView();
|
||||
view->setPage(new myWebPage());
|
||||
view->setContentsMargins(0,0,0,0);
|
||||
@@ -50,16 +52,16 @@ GoogleMapControl::GoogleMapControl(MainWindow *mw) : GcChartWindow(mw), main(mw)
|
||||
view->setAcceptDrops(false);
|
||||
layout->addWidget(view);
|
||||
|
||||
webBridge = new WebBridge(mw, this);
|
||||
webBridge = new WebBridge(context, this);
|
||||
|
||||
//
|
||||
// connects
|
||||
//
|
||||
connect(this, SIGNAL(rideItemChanged(RideItem*)), this, SLOT(rideSelected()));
|
||||
connect(view->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(updateFrame()));
|
||||
connect(mw, SIGNAL(intervalsChanged()), webBridge, SLOT(intervalsChanged()));
|
||||
connect(mw, SIGNAL(intervalSelected()), webBridge, SLOT(intervalsChanged()));
|
||||
connect(mw, SIGNAL(intervalZoom(IntervalItem*)), this, SLOT(zoomInterval(IntervalItem*)));
|
||||
connect(context->mainWindow, SIGNAL(intervalsChanged()), webBridge, SLOT(intervalsChanged()));
|
||||
connect(context->mainWindow, SIGNAL(intervalSelected()), webBridge, SLOT(intervalsChanged()));
|
||||
connect(context->mainWindow, SIGNAL(intervalZoom(IntervalItem*)), this, SLOT(zoomInterval(IntervalItem*)));
|
||||
|
||||
first = true;
|
||||
}
|
||||
@@ -276,7 +278,7 @@ void GoogleMapControl::createHtml()
|
||||
QColor GoogleMapControl::GetColor(int watts)
|
||||
{
|
||||
if (range < 0) return Qt::red;
|
||||
else return zoneColor(main->athlete->zones()->whichZone(range, watts), 7);
|
||||
else return zoneColor(context->athlete->zones()->whichZone(range, watts), 7);
|
||||
}
|
||||
|
||||
// create the ride line
|
||||
@@ -446,7 +448,7 @@ GoogleMapControl::createMarkers()
|
||||
//
|
||||
// INTERVAL MARKERS
|
||||
//
|
||||
if (main->allIntervalItems() == NULL) return; // none to do, we are all done then
|
||||
if (context->mainWindow->allIntervalItems() == NULL) return; // none to do, we are all done then
|
||||
|
||||
int interval=0;
|
||||
foreach (const RideFileInterval x, myRideItem->ride()->intervals()) {
|
||||
@@ -529,11 +531,11 @@ WebBridge::intervalCount()
|
||||
highlighted = 0;
|
||||
RideItem *rideItem = gm->property("ride").value<RideItem*>();
|
||||
|
||||
if (mainWindow->allIntervalItems() == NULL ||
|
||||
if (context->mainWindow->allIntervalItems() == NULL ||
|
||||
rideItem == NULL || rideItem->ride() == NULL) return 0; // not inited yet!
|
||||
|
||||
for (int i=0; i<mainWindow->allIntervalItems()->childCount(); i++) {
|
||||
IntervalItem *current = dynamic_cast<IntervalItem *>(mainWindow->allIntervalItems()->child(i));
|
||||
for (int i=0; i<context->mainWindow->allIntervalItems()->childCount(); i++) {
|
||||
IntervalItem *current = dynamic_cast<IntervalItem *>(context->mainWindow->allIntervalItems()->child(i));
|
||||
if (current != NULL) {
|
||||
if (current->isSelected() == true) {
|
||||
++highlighted;
|
||||
@@ -551,14 +553,14 @@ WebBridge::getLatLons(int i)
|
||||
int highlighted=0;
|
||||
RideItem *rideItem = gm->property("ride").value<RideItem*>();
|
||||
|
||||
if (mainWindow->allIntervalItems() == NULL ||
|
||||
if (context->mainWindow->allIntervalItems() == NULL ||
|
||||
rideItem ==NULL || rideItem->ride() == NULL) return latlons; // not inited yet!
|
||||
|
||||
if (i) {
|
||||
|
||||
// get for specific interval
|
||||
for (int j=0; j<mainWindow->allIntervalItems()->childCount(); j++) {
|
||||
IntervalItem *current = dynamic_cast<IntervalItem *>(mainWindow->allIntervalItems()->child(j));
|
||||
for (int j=0; j<context->mainWindow->allIntervalItems()->childCount(); j++) {
|
||||
IntervalItem *current = dynamic_cast<IntervalItem *>(context->mainWindow->allIntervalItems()->child(j));
|
||||
if (current != NULL) {
|
||||
if (current->isSelected() == true) {
|
||||
++highlighted;
|
||||
@@ -612,6 +614,6 @@ void
|
||||
WebBridge::toggleInterval(int x)
|
||||
{
|
||||
return;
|
||||
IntervalItem *current = dynamic_cast<IntervalItem *>(mainWindow->allIntervalItems()->child(x));
|
||||
IntervalItem *current = dynamic_cast<IntervalItem *>(context->mainWindow->allIntervalItems()->child(x));
|
||||
if (current) current->setSelected(!current->isSelected());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user