From 19b8c9a33ae8d29b189d06264d1e60c409373439 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Mon, 23 Dec 2019 20:52:41 +0100 Subject: Cleanup: Turn QMLProfile::diveId from QString to int This property is used to render the profile of a given dive. Weirdly, even though the diveId is an integer, it was stored as a string. It is not clear why that is the case. Therefore, turn into the more natural int and avoid unnecessary conversion. Signed-off-by: Berthold Stoeger --- profile-widget/qmlprofile.cpp | 8 ++++---- profile-widget/qmlprofile.h | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'profile-widget') diff --git a/profile-widget/qmlprofile.cpp b/profile-widget/qmlprofile.cpp index 323dad6ce..2a92340b5 100644 --- a/profile-widget/qmlprofile.cpp +++ b/profile-widget/qmlprofile.cpp @@ -80,17 +80,17 @@ void QMLProfile::setMargin(int margin) m_margin = margin; } -QString QMLProfile::diveId() const +int QMLProfile::diveId() const { return m_diveId; } -void QMLProfile::setDiveId(const QString &diveId) +void QMLProfile::setDiveId(int diveId) { m_diveId = diveId; - struct dive *d = get_dive_by_uniq_id(m_diveId.toInt()); - if (m_diveId.toInt() < 1) + if (m_diveId < 0) return; + struct dive *d = get_dive_by_uniq_id(diveId); if (!d) return; if (verbose) diff --git a/profile-widget/qmlprofile.h b/profile-widget/qmlprofile.h index 07c3e77cc..17a88ba04 100644 --- a/profile-widget/qmlprofile.h +++ b/profile-widget/qmlprofile.h @@ -8,7 +8,7 @@ class QMLProfile : public QQuickPaintedItem { Q_OBJECT - Q_PROPERTY(QString diveId MEMBER m_diveId WRITE setDiveId) + Q_PROPERTY(int diveId MEMBER m_diveId WRITE setDiveId) Q_PROPERTY(qreal devicePixelRatio READ devicePixelRatio WRITE setDevicePixelRatio NOTIFY devicePixelRatioChanged) public: @@ -16,8 +16,8 @@ public: void paint(QPainter *painter); - QString diveId() const; - void setDiveId(const QString &diveId); + int diveId() const; + void setDiveId(int diveId); qreal devicePixelRatio() const; void setDevicePixelRatio(qreal dpr); @@ -25,7 +25,7 @@ public slots: void setMargin(int margin); void screenChanged(QScreen *screen); private: - QString m_diveId; + int m_diveId; qreal m_devicePixelRatio; int m_margin; QScopedPointer m_profileWidget; -- cgit v1.2.3-70-g09d2