mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
mobile: flip through dive computers on mobile
UI fixed by Dirk. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
d66376a8f3
commit
7c8dc016b5
5 changed files with 82 additions and 7 deletions
|
@ -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<dive *> &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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue