mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
mobile/profile: listen to dive changes and redraw profile
If a dive changes, we should simply redraw the profile. This could be improved by checking for the fields that might impact the profile at all, but this is definitely a step in the right direction. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
1228dec19f
commit
a3e0d1ceb4
2 changed files with 18 additions and 0 deletions
|
@ -25,6 +25,7 @@ QMLProfile::QMLProfile(QQuickItem *parent) :
|
||||||
m_profileWidget->setFontPrintScale(fontScale);
|
m_profileWidget->setFontPrintScale(fontScale);
|
||||||
connect(QMLManager::instance(), &QMLManager::sendScreenChanged, this, &QMLProfile::screenChanged);
|
connect(QMLManager::instance(), &QMLManager::sendScreenChanged, this, &QMLProfile::screenChanged);
|
||||||
connect(this, &QMLProfile::scaleChanged, this, &QMLProfile::triggerUpdate);
|
connect(this, &QMLProfile::scaleChanged, this, &QMLProfile::triggerUpdate);
|
||||||
|
connect(&diveListNotifier, &DiveListNotifier::divesChanged, this, &QMLProfile::divesChanged);
|
||||||
setDevicePixelRatio(QMLManager::instance()->lastDevicePixelRatio());
|
setDevicePixelRatio(QMLManager::instance()->lastDevicePixelRatio());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,3 +183,16 @@ void QMLProfile::screenChanged(QScreen *screen)
|
||||||
{
|
{
|
||||||
setDevicePixelRatio(screen->devicePixelRatio());
|
setDevicePixelRatio(screen->devicePixelRatio());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QMLProfile::divesChanged(const QVector<dive *> &dives, DiveField)
|
||||||
|
{
|
||||||
|
for (struct dive *d: dives) {
|
||||||
|
if (d->id == m_diveId) {
|
||||||
|
qDebug() << "dive #" << d->number << "changed, trigger profile update";
|
||||||
|
m_profileWidget->plotDive(d, true);
|
||||||
|
triggerUpdate();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#define QMLPROFILE_H
|
#define QMLPROFILE_H
|
||||||
|
|
||||||
#include "profilewidget2.h"
|
#include "profilewidget2.h"
|
||||||
|
#include "core/subsurface-qt/divelistnotifier.h"
|
||||||
#include <QQuickPaintedItem>
|
#include <QQuickPaintedItem>
|
||||||
|
|
||||||
class QMLProfile : public QQuickPaintedItem
|
class QMLProfile : public QQuickPaintedItem
|
||||||
|
@ -38,6 +39,9 @@ private:
|
||||||
QScopedPointer<ProfileWidget2> m_profileWidget;
|
QScopedPointer<ProfileWidget2> m_profileWidget;
|
||||||
void updateProfile();
|
void updateProfile();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void divesChanged(const QVector<dive *> &dives, DiveField);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void rightAlignedChanged();
|
void rightAlignedChanged();
|
||||||
void devicePixelRatioChanged();
|
void devicePixelRatioChanged();
|
||||||
|
|
Loading…
Add table
Reference in a new issue