summaryrefslogtreecommitdiffstats
path: root/mobile-widgets/qml/DiveList.qml
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2018-11-22 22:10:38 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-11-23 13:22:24 -0800
commit68414531adeb68f7ad01c98bbac4d4d950409f02 (patch)
treeb1cf1d28c5d779c5e5e17b90b92b0ca03913b40f /mobile-widgets/qml/DiveList.qml
parenta863386cd4c6260d14b1d7f5fbf7e3a21e580aaa (diff)
downloadsubsurface-68414531adeb68f7ad01c98bbac4d4d950409f02.tar.gz
Mobile: don't format trip heading for all dives
QML's ListView uses the "section" property to test if items belong to the same section. Apparently, this must be a string and therefore we can't pass e.g. a dive-trip object. Therefore a specially formatted string was passed in, which was guaranteed to be unique (contained the dive-trip pointer value) and the fully formatted trip-title and short-date. The disadvantage of that approach is that the formatting is performed for every dive and not every trip. Perhaps not a problem now, but it makes it for example necessary to cache the number of filtered dives. To be more flexible, pass in only the pointer value formatted as hexadecimal string and provide a function to convert that string back to a trip-pointer (in the form of a QVariant, so that it can be passed to QML). Moreover provide two functions for formatting the title and the short-date. The three new functions are members of DiveListSortModel. This might not be the perfect place, but it is easy to reach from the DiveListView. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'mobile-widgets/qml/DiveList.qml')
-rw-r--r--mobile-widgets/qml/DiveList.qml26
1 files changed, 10 insertions, 16 deletions
diff --git a/mobile-widgets/qml/DiveList.qml b/mobile-widgets/qml/DiveList.qml
index f31a2ca8b..3d29a1ec4 100644
--- a/mobile-widgets/qml/DiveList.qml
+++ b/mobile-widgets/qml/DiveList.qml
@@ -58,7 +58,7 @@ Kirigami.ScrollablePage {
states: [
State {
name: "isHidden";
- when: dive.tripMeta !== activeTrip && ! diveOutsideTrip
+ when: dive.tripId !== activeTrip && ! diveOutsideTrip
PropertyChanges {
target: innerListItem
height: 0
@@ -67,7 +67,7 @@ Kirigami.ScrollablePage {
},
State {
name: "isVisible";
- when: dive.tripMeta === activeTrip || diveOutsideTrip
+ when: dive.tripId === activeTrip || diveOutsideTrip
PropertyChanges {
target: innerListItem
height: diveListEntry.height + Kirigami.Units.smallSpacing
@@ -130,7 +130,7 @@ Kirigami.ScrollablePage {
Item {
Rectangle {
id: leftBarDive
- width: dive.tripMeta == "" ? 0 : Kirigami.Units.smallSpacing
+ width: dive.tripId == "" ? 0 : Kirigami.Units.smallSpacing
height: diveListEntry.height * 0.8
color: subsurfaceTheme.lightPrimaryColor
anchors {
@@ -348,7 +348,10 @@ Kirigami.ScrollablePage {
leftMargin: Kirigami.Units.smallSpacing
}
Controls.Label {
- text: { section.replace(/.*\+\+/, "").replace(/::.*/, "").replace("@", "\n'") }
+ text: {
+ var trip = diveListView.model.tripIdToObject(section);
+ diveListView.model.tripShortDate(trip);
+ }
color: subsurfaceTheme.primaryTextColor
font.pointSize: subsurfaceTheme.smallPointSize
lineHeightMode: Text.FixedHeight
@@ -372,17 +375,8 @@ Kirigami.ScrollablePage {
Controls.Label {
id: sectionText
text: {
- // if the tripMeta (which we get as "section") ends in ::-- we know
- // that there's no trip -- otherwise strip the meta information before
- // the :: and show the trip location
- var shownText
- var endsWithDoubleDash = /::--$/;
- if (endsWithDoubleDash.test(section) || section === "--") {
- shownText = ""
- } else {
- shownText = section.replace(/.*::/, "")
- }
- shownText
+ var trip = diveListView.model.tripIdToObject(section);
+ diveListView.model.tripTitle(trip);
}
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
visible: text !== ""
@@ -526,7 +520,7 @@ Kirigami.ScrollablePage {
maximumFlickVelocity: parent.height * 5
bottomMargin: Kirigami.Units.iconSizes.medium + Kirigami.Units.gridUnit
cacheBuffer: 40 // this will increase memory use, but should help with scrolling
- section.property: "dive.tripMeta"
+ section.property: "dive.tripId"
section.criteria: ViewSection.FullString
section.delegate: tripHeading
section.labelPositioning: ViewSection.CurrentLabelAtStart | ViewSection.InlineLabels