From b6fbad69c827f26ae1f133236360a1285e8aa6c4 Mon Sep 17 00:00:00 2001 From: Arseniy-Movshev Date: Tue, 30 May 2023 17:11:41 +0100 Subject: Add some useful properties to hrgraph --- qmlplugin/hrGraph.cpp | 27 +++++++++++++++++++++++++++ qmlplugin/hrGraph.h | 12 ++++++++++++ 2 files changed, 39 insertions(+) diff --git a/qmlplugin/hrGraph.cpp b/qmlplugin/hrGraph.cpp index 0ecb39c..34a3224 100644 --- a/qmlplugin/hrGraph.cpp +++ b/qmlplugin/hrGraph.cpp @@ -53,6 +53,9 @@ void HrGraph::paint(QPainter *painter) } int j = m_filedata.count(); QPointF points[j]; + if (!graphRelative) { + minHrValue = 0; + } float valueDelta = maxHrValue - minHrValue; float timeDelta = maxTime - minTime; float calculatedValue = 0; @@ -126,3 +129,27 @@ void HrGraph::setLineWidth(float width) { float HrGraph::lineWidth() { return m_lineWidth; } + +int HrGraph::getMaxHrValue() { + return maxHrValue; +} + +int HrGraph::getMinHrValue() { + return minHrValue; +} + +QDateTime HrGraph::getMaxTime() { + return QDateTime::fromSecsSinceEpoch(maxTime); +} + +QDateTime HrGraph::getMinTime() { + return QDateTime::fromSecsSinceEpoch(minTime); +} + +bool HrGraph::relative() { + return graphRelative; +} + +void HrGraph::setRelative(bool newRelative) { + graphRelative = newRelative; +} diff --git a/qmlplugin/hrGraph.h b/qmlplugin/hrGraph.h index 55f4219..5811689 100644 --- a/qmlplugin/hrGraph.h +++ b/qmlplugin/hrGraph.h @@ -41,6 +41,11 @@ class HrGraph : public QQuickPaintedItem Q_PROPERTY(float lineWidth READ lineWidth WRITE setLineWidth) Q_PROPERTY(QColor lineColor READ lineColor WRITE setLineColor NOTIFY lineColorChanged) + Q_PROPERTY(int maxValue READ getMaxHrValue NOTIFY loadingDone) + Q_PROPERTY(int minValue READ getMinHrValue NOTIFY loadingDone) + Q_PROPERTY(QDateTime maxTime READ getMaxTime NOTIFY loadingDone) + Q_PROPERTY(QDateTime minTime READ getMinTime NOTIFY loadingDone) + Q_PROPERTY(bool relativeMode READ relative WRITE setRelative) struct HrDatapoint { qint64 time; @@ -60,6 +65,12 @@ public slots: void setLineWidth(float width); QColor lineColor(); void setLineColor(QColor color); + int getMaxHrValue(); + int getMinHrValue(); + QDateTime getMaxTime(); + QDateTime getMinTime(); + bool relative(); + void setRelative(bool newRelative); private: void updateBasePixmap(); @@ -74,6 +85,7 @@ private: int maxHrValue = 0; int minTime; int maxTime; + bool graphRelative; }; #endif // ICON_H -- cgit v1.2.3-70-g09d2