mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Mobile: return depthDuration directly from DiveListModel
We don't want to generate a DiveObjectHelper numerous times for every item in the dive list. Therefore, return this data directly from the model. In this case, don't remove from DiveObjectHelper, as these data might be used by grantlee templates. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
c4831d7ace
commit
a79c45e401
3 changed files with 5 additions and 1 deletions
|
@ -178,7 +178,7 @@ Kirigami.ScrollablePage {
|
|||
}
|
||||
// let's try to show the depth / duration very compact
|
||||
Controls.Label {
|
||||
text: dive.depth + ' / ' + dive.duration
|
||||
text: depthDuration
|
||||
width: Math.max(Kirigami.Units.gridUnit * 3, paintedWidth) // helps vertical alignment throughout listview
|
||||
font.pointSize: subsurfaceTheme.smallPointSize
|
||||
color: innerListItem.checked ? subsurfaceTheme.darkerPrimaryTextColor : secondaryTextColor
|
||||
|
|
|
@ -257,6 +257,8 @@ QVariant DiveListModel::data(const QModelIndex &index, int role) const
|
|||
case IdRole: return d->id;
|
||||
case NumberRole: return d->number;
|
||||
case LocationRole: return get_dive_location(d);
|
||||
case DepthDurationRole: return QStringLiteral("%1 / %2").arg(get_depth_string(d->dc.maxdepth.mm, true, true),
|
||||
get_dive_duration_string(d->duration.seconds, gettextFromC::tr("h"), gettextFromC::tr("min")));
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
@ -272,6 +274,7 @@ QHash<int, QByteArray> DiveListModel::roleNames() const
|
|||
roles[IdRole] = "id";
|
||||
roles[NumberRole] = "number";
|
||||
roles[LocationRole] = "location";
|
||||
roles[DepthDurationRole] = "depthDuration";
|
||||
return roles;
|
||||
}
|
||||
|
||||
|
|
|
@ -44,6 +44,7 @@ public:
|
|||
IdRole,
|
||||
NumberRole,
|
||||
LocationRole,
|
||||
DepthDurationRole,
|
||||
};
|
||||
|
||||
static DiveListModel *instance();
|
||||
|
|
Loading…
Add table
Reference in a new issue