diff --git a/src/GoldenCheetah.cpp b/src/GoldenCheetah.cpp index f94424c34..56f6d96a9 100644 --- a/src/GoldenCheetah.cpp +++ b/src/GoldenCheetah.cpp @@ -87,6 +87,16 @@ void GcWindow::setRideItem(RideItem* x) emit rideItemChanged(_rideItem); } +void GcWindow::setDateRange(DateRange dr) +{ + _dr = dr; +} + +DateRange GcWindow::dateRange() const +{ + return _dr; +} + double GcWindow::widthFactor() const { return _widthFactor; diff --git a/src/GoldenCheetah.h b/src/GoldenCheetah.h index ad9c49f8e..f6e0c25be 100644 --- a/src/GoldenCheetah.h +++ b/src/GoldenCheetah.h @@ -18,6 +18,7 @@ #ifndef _GC_GoldenCheetah_h #define _GC_GoldenCheetah_h +#include "TimeUtils.h" #define G_OBJECT Q_PROPERTY(QString instanceName READ instanceName WRITE setInstanceName) #define setInstanceName(x) setProperty("instanceName", x) @@ -42,6 +43,7 @@ class GcWindow; Q_DECLARE_METATYPE(QWidget*); Q_DECLARE_METATYPE(RideItem*); Q_DECLARE_METATYPE(GcWinID); +Q_DECLARE_METATYPE(DateRange); class GcWindow : public QFrame @@ -68,9 +70,12 @@ private: // informed by the layout manager Q_PROPERTY(RideItem* ride READ rideItem WRITE setRideItem NOTIFY rideItemChanged) + // all charts have a date range, they don't all implement it + Q_PROPERTY(DateRange dateRange READ dateRange WRITE setDateRange NOTIFY dateRangeChanged); + // geometry factor Q_PROPERTY(double widthFactor READ widthFactor WRITE setWidthFactor NOTIFY widthFactorChanged USER true); - Q_PROPERTY(double heightFactor READ heightFactor WRITE setHeightFactor NOTIFY widthFactorChanged USER true); + Q_PROPERTY(double heightFactor READ heightFactor WRITE setHeightFactor NOTIFY heightFactorChanged USER true); // can be resized Q_PROPERTY(bool resizable READ resizable WRITE setResizable USER true); @@ -82,6 +87,7 @@ private: QString _instanceName; RideItem *_rideItem; GcWinID _type; + DateRange _dr; double _widthFactor; double _heightFactor; bool _resizable; @@ -104,6 +110,7 @@ signals: void rideItemChanged(RideItem*); void heightFactorChanged(double); void widthFactorChanged(double); + void dateRangeChanged(DateRange); void resizing(GcWindow*); void moving(GcWindow*); void resized(GcWindow*); // finished resizing @@ -134,6 +141,9 @@ public: void setRideItem(RideItem *); RideItem *rideItem() const; + void setDateRange(DateRange); + DateRange dateRange() const; + void setWidthFactor(double); double widthFactor() const; diff --git a/src/TimeUtils.cpp b/src/TimeUtils.cpp index a9dba1cfd..7590103de 100644 --- a/src/TimeUtils.cpp +++ b/src/TimeUtils.cpp @@ -97,3 +97,23 @@ QDateTime convertToLocalTime(QString timestamp) } } +DateRange::DateRange(QDate from, QDate to) : QObject() +{ + this->from=from; + this->to=to; +} + +DateRange::DateRange(const DateRange &other) : QObject() +{ + from=other.from; + to=other.to; +} + +DateRange& DateRange::operator=(const DateRange &other) +{ + from=other.from; + to=other.to; + emit changed(from, to); + + return *this; +} diff --git a/src/TimeUtils.h b/src/TimeUtils.h index 46dd42117..7f6a061f7 100644 --- a/src/TimeUtils.h +++ b/src/TimeUtils.h @@ -18,9 +18,10 @@ #ifndef _TimeUtils_h #define _TimeUtils_h -#include "GoldenCheetah.h" +#include #include +#include #include QString interval_to_str(double secs); // output like 1h 2m 3s @@ -31,5 +32,18 @@ QString time_to_string(double secs); // output like 1:02:03 */ QDateTime convertToLocalTime(QString timestamp); -#endif // _TimeUtils_h +class DateRange : QObject +{ + Q_OBJECT + public: + DateRange(const DateRange& other); + DateRange(QDate from = QDate(), QDate to = QDate()); + DateRange& operator=(const DateRange &); + QDate from, to; + + signals: + void changed(QDate from, QDate to); +}; + +#endif // _TimeUtils_h