diff --git a/CHANGELOG.md b/CHANGELOG.md index 3fe7e054f..2081d29cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,4 @@ +mobile: implement paging through dive computers desktop: remove divesite list from tab-widgets infobox: show an icon for warnings import: allow import of divesites without UUID diff --git a/mobile-widgets/qml/DiveDetailsView.qml b/mobile-widgets/qml/DiveDetailsView.qml index 3b5666b4e..eb43bb636 100644 --- a/mobile-widgets/qml/DiveDetailsView.qml +++ b/mobile-widgets/qml/DiveDetailsView.qml @@ -210,7 +210,6 @@ Item { color: subsurfaceTheme.textColor } } - } GridLayout { id: bottomLayout @@ -362,7 +361,44 @@ Item { horizontalAlignment: Text.AlignHCenter text: qsTr("No profile to show") } - + // under the profile + // ----------------- + Row { + TemplateButton { + id: prevDC + visible: qmlProfile.numDC > 1 + text: qsTr("prev.DC") + font.pointSize: subsurfaceTheme.smallPointSize + onClicked: { + qmlProfile.prevDC() + } + } + TemplateLabel { + text: " " + width: Kirigami.Units.largeSpacing + visible: qmlProfile.numDC > 1 + } + TemplateButton { + id: nextDC + visible: qmlProfile.numDC > 1 + text: qsTr("next DC") + font.pointSize: subsurfaceTheme.smallPointSize + onClicked: { + qmlProfile.nextDC() + } + } + } + // two empty entries + TemplateLabel { + text: " " + width: Kirigami.Units.largeSpacing + visible: qmlProfile.numDC > 1 + } + TemplateLabel { + text: " " + width: Kirigami.Units.largeSpacing + visible: qmlProfile.numDC > 1 + } // first row //----------- TemplateLabelSmall { diff --git a/profile-widget/profilescene.cpp b/profile-widget/profilescene.cpp index a38824ad4..4de13651f 100644 --- a/profile-widget/profilescene.cpp +++ b/profile-widget/profilescene.cpp @@ -576,11 +576,9 @@ void ProfileScene::plotDive(const struct dive *dIn, int dcIn, DivePlannerPointsM dcText = tr("Manually added dive"); else if (dcText.isEmpty()) dcText = tr("Unknown dive computer"); -#ifndef SUBSURFACE_MOBILE - int nr; - if ((nr = number_of_computers(d)) > 1) + int nr = number_of_computers(d); + if (nr > 1) dcText += tr(" (#%1 of %2)").arg(dc + 1).arg(nr); -#endif diveComputerText->set(dcText, getColor(TIME_TEXT, isGrayscale)); // Reset animation. diff --git a/profile-widget/qmlprofile.cpp b/profile-widget/qmlprofile.cpp index 121ba2911..b3076d2b5 100644 --- a/profile-widget/qmlprofile.cpp +++ b/profile-widget/qmlprofile.cpp @@ -11,6 +11,8 @@ QMLProfile::QMLProfile(QQuickItem *parent) : QQuickPaintedItem(parent), + m_diveId(0), + m_dc(0), m_devicePixelRatio(1.0), m_margin(0), m_xOffset(0.0), @@ -60,7 +62,7 @@ void QMLProfile::paint(QPainter *painter) struct dive *d = get_dive_by_uniq_id(m_diveId); if (!d) return; - m_profileWidget->draw(painter, painterRect, d, dc_number, nullptr, false); + m_profileWidget->draw(painter, painterRect, d, m_dc, nullptr, false); } void QMLProfile::setMargin(int margin) @@ -76,6 +78,7 @@ int QMLProfile::diveId() const void QMLProfile::setDiveId(int diveId) { m_diveId = diveId; + emit numDCChanged(); } qreal QMLProfile::devicePixelRatio() const @@ -126,3 +129,33 @@ void QMLProfile::divesChanged(const QVector &dives, DiveField) } } } + +void QMLProfile::nextDC() +{ + rotateDC(1); +} + +void QMLProfile::prevDC() +{ + rotateDC(-1); +} + +void QMLProfile::rotateDC(int dir) +{ + struct dive *d = get_dive_by_uniq_id(m_diveId); + if (!d) + return; + int numDC = number_of_computers(d); + if (numDC == 1) + return; + m_dc = (m_dc + dir) % numDC; + if (m_dc < 0) + m_dc += numDC; + triggerUpdate(); +} + +int QMLProfile::numDC() const +{ + struct dive *d = get_dive_by_uniq_id(m_diveId); + return d ? number_of_computers(d) : 0; +} diff --git a/profile-widget/qmlprofile.h b/profile-widget/qmlprofile.h index dcbde0309..ddff67f1f 100644 --- a/profile-widget/qmlprofile.h +++ b/profile-widget/qmlprofile.h @@ -12,6 +12,7 @@ class QMLProfile : public QQuickPaintedItem { Q_OBJECT Q_PROPERTY(int diveId MEMBER m_diveId WRITE setDiveId) + Q_PROPERTY(int numDC READ numDC NOTIFY numDCChanged) Q_PROPERTY(qreal devicePixelRatio READ devicePixelRatio WRITE setDevicePixelRatio NOTIFY devicePixelRatioChanged) Q_PROPERTY(qreal xOffset MEMBER m_xOffset WRITE setXOffset NOTIFY xOffsetChanged) Q_PROPERTY(qreal yOffset MEMBER m_yOffset WRITE setYOffset NOTIFY yOffsetChanged) @@ -28,6 +29,8 @@ public: void setDevicePixelRatio(qreal dpr); void setXOffset(qreal value); void setYOffset(qreal value); + Q_INVOKABLE void nextDC(); + Q_INVOKABLE void prevDC(); public slots: void setMargin(int margin); @@ -36,11 +39,14 @@ public slots: private: int m_diveId; + int m_dc; qreal m_devicePixelRatio; int m_margin; qreal m_xOffset, m_yOffset; std::unique_ptr m_profileWidget; void createProfileView(); + void rotateDC(int dir); + int numDC() const; private slots: void divesChanged(const QVector &dives, DiveField); @@ -50,6 +56,7 @@ signals: void devicePixelRatioChanged(); void xOffsetChanged(); void yOffsetChanged(); + void numDCChanged(); }; #endif // QMLPROFILE_H