mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-04-15 05:32:21 +00:00
UI Nits: Introducing GcWindow property Daterange
To allow charts to have a property set for the date range to plot a new property is added. This will work in the same manner as the "ride" property. No functional enhancement.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -18,9 +18,10 @@
|
||||
|
||||
#ifndef _TimeUtils_h
|
||||
#define _TimeUtils_h
|
||||
#include "GoldenCheetah.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QDateTime>
|
||||
#include <QDate>
|
||||
#include <QString>
|
||||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user