mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-01 00:53:24 +00:00
Mobile: move tripNrDive from DiveObjectHelper to DiveListModel
We don't want to generate a DiveObjectHelper numerous times for every item in the dive list. Therefore, return this datum directly from the model. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
1b9581369a
commit
54720e6cff
5 changed files with 6 additions and 11 deletions
|
@ -315,12 +315,6 @@ QVector<CylinderObjectHelper> DiveObjectHelper::cylinderObjects() const
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
int DiveObjectHelper::tripNrDives() const
|
|
||||||
{
|
|
||||||
struct dive_trip *dt = m_dive->divetrip;
|
|
||||||
return dt ? dt->dives.nr : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int DiveObjectHelper::maxcns() const
|
int DiveObjectHelper::maxcns() const
|
||||||
{
|
{
|
||||||
return m_dive->maxcns;
|
return m_dive->maxcns;
|
||||||
|
|
|
@ -40,7 +40,6 @@ class DiveObjectHelper : public QObject {
|
||||||
Q_PROPERTY(QStringList cylinderList READ cylinderList CONSTANT)
|
Q_PROPERTY(QStringList cylinderList READ cylinderList CONSTANT)
|
||||||
Q_PROPERTY(QStringList cylinders READ cylinders CONSTANT)
|
Q_PROPERTY(QStringList cylinders READ cylinders CONSTANT)
|
||||||
Q_PROPERTY(QVector<CylinderObjectHelper> cylinderObjects READ cylinderObjects CONSTANT)
|
Q_PROPERTY(QVector<CylinderObjectHelper> cylinderObjects READ cylinderObjects CONSTANT)
|
||||||
Q_PROPERTY(int tripNrDives READ tripNrDives CONSTANT)
|
|
||||||
Q_PROPERTY(int maxcns READ maxcns CONSTANT)
|
Q_PROPERTY(int maxcns READ maxcns CONSTANT)
|
||||||
Q_PROPERTY(int otu READ otu CONSTANT)
|
Q_PROPERTY(int otu READ otu CONSTANT)
|
||||||
Q_PROPERTY(QString sumWeight READ sumWeight CONSTANT)
|
Q_PROPERTY(QString sumWeight READ sumWeight CONSTANT)
|
||||||
|
@ -82,7 +81,6 @@ public:
|
||||||
QStringList cylinders() const;
|
QStringList cylinders() const;
|
||||||
QString cylinder(int idx) const;
|
QString cylinder(int idx) const;
|
||||||
QVector<CylinderObjectHelper> cylinderObjects() const;
|
QVector<CylinderObjectHelper> cylinderObjects() const;
|
||||||
int tripNrDives() const;
|
|
||||||
int maxcns() const;
|
int maxcns() const;
|
||||||
int otu() const;
|
int otu() const;
|
||||||
QString sumWeight() const;
|
QString sumWeight() const;
|
||||||
|
|
|
@ -40,7 +40,7 @@ Kirigami.ScrollablePage {
|
||||||
id: diveDelegate
|
id: diveDelegate
|
||||||
Kirigami.AbstractListItem {
|
Kirigami.AbstractListItem {
|
||||||
// this looks weird, but it's how we can tell that this dive isn't in a trip
|
// this looks weird, but it's how we can tell that this dive isn't in a trip
|
||||||
property bool diveOutsideTrip: dive.tripNrDives === 0
|
property bool diveOutsideTrip: tripNrDives === 0
|
||||||
leftPadding: 0
|
leftPadding: 0
|
||||||
topPadding: 0
|
topPadding: 0
|
||||||
id: innerListItem
|
id: innerListItem
|
||||||
|
@ -85,7 +85,7 @@ Kirigami.ScrollablePage {
|
||||||
}
|
}
|
||||||
NumberAnimation {
|
NumberAnimation {
|
||||||
property: "height"
|
property: "height"
|
||||||
duration: 200 + 20 * dive.tripNrDives
|
duration: 200 + 20 * tripNrDives
|
||||||
easing.type: Easing.InOutQuad
|
easing.type: Easing.InOutQuad
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,7 @@ Kirigami.ScrollablePage {
|
||||||
SequentialAnimation {
|
SequentialAnimation {
|
||||||
NumberAnimation {
|
NumberAnimation {
|
||||||
property: "height"
|
property: "height"
|
||||||
duration: 200 + 20 * dive.tripNrDives
|
duration: 200 + 20 * tripNrDives
|
||||||
easing.type: Easing.InOutQuad
|
easing.type: Easing.InOutQuad
|
||||||
}
|
}
|
||||||
NumberAnimation {
|
NumberAnimation {
|
||||||
|
|
|
@ -245,6 +245,7 @@ QVariant DiveListModel::data(const QModelIndex &index, int role) const
|
||||||
case DiveRole: return QVariant::fromValue<QObject*>(curr_dive);
|
case DiveRole: return QVariant::fromValue<QObject*>(curr_dive);
|
||||||
case DiveDateRole: return (qlonglong)curr_dive->timestamp();
|
case DiveDateRole: return (qlonglong)curr_dive->timestamp();
|
||||||
case TripIdRole: return d->divetrip ? QString::number((quint64)d->divetrip, 16) : QString();
|
case TripIdRole: return d->divetrip ? QString::number((quint64)d->divetrip, 16) : QString();
|
||||||
|
case TripNrDivesRole: return d->divetrip ? d->divetrip->dives.nr : 0;
|
||||||
}
|
}
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
|
@ -256,6 +257,7 @@ QHash<int, QByteArray> DiveListModel::roleNames() const
|
||||||
roles[DiveRole] = "dive";
|
roles[DiveRole] = "dive";
|
||||||
roles[DiveDateRole] = "date";
|
roles[DiveDateRole] = "date";
|
||||||
roles[TripIdRole] = "tripId";
|
roles[TripIdRole] = "tripId";
|
||||||
|
roles[TripNrDivesRole] = "tripNrDives";
|
||||||
return roles;
|
return roles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,7 @@ public:
|
||||||
DiveRole = Qt::UserRole + 1,
|
DiveRole = Qt::UserRole + 1,
|
||||||
DiveDateRole,
|
DiveDateRole,
|
||||||
TripIdRole,
|
TripIdRole,
|
||||||
|
TripNrDivesRole,
|
||||||
};
|
};
|
||||||
|
|
||||||
static DiveListModel *instance();
|
static DiveListModel *instance();
|
||||||
|
|
Loading…
Add table
Reference in a new issue