diff --git a/src/Charts/GoldenCheetah.cpp b/src/Charts/GoldenCheetah.cpp index 87c3b210d..312813b74 100644 --- a/src/Charts/GoldenCheetah.cpp +++ b/src/Charts/GoldenCheetah.cpp @@ -25,6 +25,7 @@ #include "Utils.h" #include "mvjson.h" #include "LTMSettings.h" +#include "Perspective.h" #ifdef GC_HAS_CLOUD_DB #include "CloudDBChart.h" @@ -195,11 +196,13 @@ GcWindow::GcWindow(Context *context) : QFrame(context->mainWindow), dragState(No qRegisterMetaType("type"); qRegisterMetaType("color"); qRegisterMetaType("dateRange"); + qRegisterMetaType("perspective"); nomenu = false; revealed = false; setParent(context->mainWindow); setControls(NULL); setRideItem(NULL); + setPerspective(NULL); setTitle(""); showtitle=true; setContentsMargins(0,0,0,0); diff --git a/src/Charts/GoldenCheetah.h b/src/Charts/GoldenCheetah.h index 6c67a5d37..242bfdb39 100644 --- a/src/Charts/GoldenCheetah.h +++ b/src/Charts/GoldenCheetah.h @@ -57,6 +57,7 @@ private: // what kind of window is this? Q_PROPERTY(GcWinID type READ type WRITE setType) // not a user modifiable property + Q_PROPERTY(Perspective *perspective READ getPerspective WRITE setPerspective USER false) // each window has an instance name - default set // by the widget constructor but overide from layou manager @@ -104,6 +105,7 @@ private: bool _gripped; int _style; bool _noevents; // don't work with events + Perspective *_perspective; enum drag { None, Close, Flip, Move, Left, Right, Top, Bottom, TLCorner, TRCorner, BLCorner, BRCorner }; typedef enum drag DragState; @@ -147,6 +149,9 @@ public: void addAction(QAction *act) { actions << act; } void setNoEvents(bool x) { _noevents = x; } + void setPerspective(Perspective *x) { _perspective=x; } + Perspective *getPerspective() const { return _perspective; } + void virtual setControls(QWidget *x); QWidget *controls() const; diff --git a/src/Charts/OverviewItems.cpp b/src/Charts/OverviewItems.cpp index f06322c99..02d34615e 100644 --- a/src/Charts/OverviewItems.cpp +++ b/src/Charts/OverviewItems.cpp @@ -84,7 +84,7 @@ static void setFilter(ChartSpaceItem *item, Specification &spec) // property gets set after chartspace is initialised, so when we start up its not // available, but comes later... - if (item->parent->window->property("perspective").isValid()) + if (item->parent->window->myPerspective != NULL) fs.addFilter(item->parent->window->myPerspective->isFiltered(), item->parent->window->myPerspective->filterlist(item->parent->myDateRange)); // local filter diff --git a/src/Charts/UserChart.cpp b/src/Charts/UserChart.cpp index 5a3a103f1..5bde84644 100644 --- a/src/Charts/UserChart.cpp +++ b/src/Charts/UserChart.cpp @@ -51,6 +51,9 @@ UserChart::UserChart(QWidget *parent, Context *context, bool rangemode) main->setSpacing(0); main->setContentsMargins(0,0,0,0); + // we don't know our perspective yet... + setPerspective(NULL); + // the chart chart = new GenericChart(this, context); main->addWidget(chart); @@ -184,6 +187,7 @@ UserChart::setRide(const RideItem *item) // cast so we can work with it UserChartData *ucd = static_cast(series.user1); + // NOTE: specification is blank so doesn't honor perspective or filters, use activity {} in program for that (!!) ucd->compute(const_cast(ride), Specification(), dr); series.xseries = ucd->x.asNumeric(); series.yseries = ucd->y.asNumeric(); diff --git a/src/Charts/UserChart.h b/src/Charts/UserChart.h index a2e69d81c..f798e9ea4 100644 --- a/src/Charts/UserChart.h +++ b/src/Charts/UserChart.h @@ -41,6 +41,8 @@ class UserChart : public QWidget { Q_OBJECT + Q_PROPERTY (Perspective* perspective READ getPerspective WRITE setPerspective USER false) + friend class ::Leaf; // data filter eval accessing our curve data public: @@ -54,6 +56,9 @@ class UserChart : public QWidget { QString settings() const; void applySettings(QString); + Perspective *getPerspective() const { return perspective_; } + void setPerspective(Perspective *x) { perspective_ = x; } + // set background for all charts, legends etc void setBackgroundColor(QColor bgcolor); void setGraphicsItem(QGraphicsItem *); @@ -95,6 +100,7 @@ class UserChart : public QWidget { private: + Perspective *perspective_; Context *context; bool rangemode; bool stale; diff --git a/src/Charts/UserChartOverviewItem.cpp b/src/Charts/UserChartOverviewItem.cpp index fe8b27324..4d571b65b 100644 --- a/src/Charts/UserChartOverviewItem.cpp +++ b/src/Charts/UserChartOverviewItem.cpp @@ -22,7 +22,6 @@ UserChartOverviewItem::UserChartOverviewItem(ChartSpace *parent, QString name, QString settings) : ChartSpaceItem(parent, name), space_(parent) { - // a META widget, "RPE" using the FOSTER modified 0-10 scale this->type = OverviewItemType::USERCHART; // default is a bit bigger diff --git a/src/Charts/UserChartWindow.cpp b/src/Charts/UserChartWindow.cpp index f1d95dddc..e3a49e5c4 100644 --- a/src/Charts/UserChartWindow.cpp +++ b/src/Charts/UserChartWindow.cpp @@ -74,6 +74,7 @@ UserChartWindow::configChanged() QColor bgcolor = rangemode ? GColor(CTRENDPLOTBACKGROUND) : GColor(CPLOTBACKGROUND); setProperty("color", bgcolor); + chart->setProperty("perspective", QVariant::fromValue(myPerspective)); chart->setBackgroundColor(bgcolor); update(); @@ -85,18 +86,23 @@ UserChartWindow::configChanged() void UserChartWindow::setRide(RideItem *item) { + chart->setProperty("perspective", QVariant::fromValue(myPerspective)); chart->setRide(item); } void UserChartWindow::setDateRange(DateRange d) { + chart->setProperty("perspective", QVariant::fromValue(myPerspective)); chart->setDateRange(d); } void UserChartWindow::refresh() { + // we get called when filters and perspectives change so lets set the property + chart->setProperty("perspective", QVariant::fromValue(myPerspective)); + if (!amVisible()) { stale=true; return; } chart->refresh();