QML UI: DiveList: add date box to trip header

This way you can tell when a trip happened.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2017-06-24 13:13:04 -07:00
parent 29741f0ed2
commit d93280f1dc
2 changed files with 33 additions and 4 deletions

View file

@ -335,10 +335,12 @@ QString DiveObjectHelper::tripMeta() const
if (dt) { if (dt) {
QString numDives = tr("(%n dive(s))", "", dt->nrdives); QString numDives = tr("(%n dive(s))", "", dt->nrdives);
QString title(dt->location); QString title(dt->location);
if (title.isEmpty()) {
// so use the date range
QDateTime firstTime = QDateTime::fromMSecsSinceEpoch(1000*dt->when, Qt::UTC); QDateTime firstTime = QDateTime::fromMSecsSinceEpoch(1000*dt->when, Qt::UTC);
QString firstMonth = firstTime.toString("MMM"); QString firstMonth = firstTime.toString("MMM");
QString tripDate = QStringLiteral("%1@%2").arg(firstMonth,firstTime.toString("yy"));
;
if (title.isEmpty()) {
// so use the date range
QString firstYear = firstTime.toString("yyyy"); QString firstYear = firstTime.toString("yyyy");
QDateTime lastTime = QDateTime::fromMSecsSinceEpoch(1000*dt->dives->when, Qt::UTC); QDateTime lastTime = QDateTime::fromMSecsSinceEpoch(1000*dt->dives->when, Qt::UTC);
QString lastMonth = lastTime.toString("MMM"); QString lastMonth = lastTime.toString("MMM");
@ -350,7 +352,7 @@ QString DiveObjectHelper::tripMeta() const
else else
title = firstMonth + " " + firstYear + " - " + lastMonth + " " + lastYear; title = firstMonth + " " + firstYear + " - " + lastMonth + " " + lastYear;
} }
ret = QString::number((quint64)m_dive->divetrip, 16) + QLatin1Literal("::") + QStringLiteral("%1 %2").arg(title, numDives); ret = QString::number((quint64)m_dive->divetrip, 16) + QLatin1Literal("++") + tripDate + QLatin1Literal("::") + QStringLiteral("%1 %2").arg(title, numDives);
} }
return ret; return ret;
} }

View file

@ -194,6 +194,33 @@ Kirigami.ScrollablePage {
} }
color: subsurfaceTheme.lightPrimaryColor color: subsurfaceTheme.lightPrimaryColor
visible: section != "" visible: section != ""
Rectangle {
id: dateBox
visible: section != ""
height: section == "" ? 0 : 2 * Kirigami.Units.gridUnit
width: section == "" ? 0 : 2.5 * Kirigami.Units.gridUnit
color: subsurfaceTheme.primaryColor
radius: Kirigami.Units.smallSpacing * 2
antialiasing: true
anchors {
verticalCenter: parent.verticalCenter
left: parent.left
leftMargin: Kirigami.Units.smallSpacing
}
Label {
text: { section.replace(/.*\+\+/, "").replace(/::.*/, "").replace("@", "\n'") }
color: subsurfaceTheme.primaryTextColor
font.pointSize: subsurfaceTheme.smallPointSize
lineHeightMode: Text.FixedHeight
lineHeight: Kirigami.Units.gridUnit *.9
horizontalAlignment: Text.AlignHCenter
anchors {
horizontalCenter: parent.horizontalCenter
verticalCenter: parent.verticalCenter
}
}
}
Kirigami.Label { Kirigami.Label {
id: sectionText id: sectionText
text: { text: {
@ -214,7 +241,7 @@ Kirigami.ScrollablePage {
font.weight: Font.Bold font.weight: Font.Bold
anchors { anchors {
top: parent.top top: parent.top
left: parent.left left: dateBox.right
topMargin: Math.max(2, Kirigami.Units.gridUnit / 2) topMargin: Math.max(2, Kirigami.Units.gridUnit / 2)
leftMargin: horizontalPadding * 2 leftMargin: horizontalPadding * 2
right: parent.right right: parent.right