mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
mobile/divelist: better handling of selection change
This still has an odd bug. When we swipe the dive details to change the selected dive and that action causes a trip to expand or collapse, then the color change / highlight in the dive list isn't updated correctly, even though the log file indicates that we made the necessary changes. This also changes the coloring of the selected dive; having the same coloring as a trip was very confusing. This is a bit stark, but it clearly communicates the distinction. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
58dcbfff13
commit
2009321894
1 changed files with 17 additions and 7 deletions
|
@ -35,18 +35,28 @@ Kirigami.ScrollablePage {
|
||||||
Kirigami.AbstractListItem {
|
Kirigami.AbstractListItem {
|
||||||
// this allows us to access properties of the currentItem from outside
|
// this allows us to access properties of the currentItem from outside
|
||||||
property variant myData: model
|
property variant myData: model
|
||||||
|
property var view: ListView.view
|
||||||
|
property bool selected: !isTrip && current // don't use 'checked' for this as that confuses QML as it tries
|
||||||
id: diveOrTripDelegateItem
|
id: diveOrTripDelegateItem
|
||||||
padding: 0
|
padding: 0
|
||||||
supportsMouseEvents: true
|
supportsMouseEvents: true
|
||||||
checked: !isTrip && current
|
|
||||||
anchors {
|
anchors {
|
||||||
left: parent.left
|
left: parent.left
|
||||||
right: parent.right
|
right: parent.right
|
||||||
}
|
}
|
||||||
height: (isTrip ? 9 : 11) * Kirigami.Units.smallSpacing // delegateInnerItem.height
|
height: (isTrip ? 9 : 11) * Kirigami.Units.smallSpacing // delegateInnerItem.height
|
||||||
|
|
||||||
|
onSelectedChanged: {
|
||||||
|
console.log("index " + index + " select changed to " + selected)
|
||||||
|
if (selected && index !== view.currentIndex) {
|
||||||
|
view.currentIndex = index;
|
||||||
|
console.log("updated view.currentIndex")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// When clicked, a trip expands / unexpands, a dive is opened in DiveDetails
|
// When clicked, a trip expands / unexpands, a dive is opened in DiveDetails
|
||||||
onClicked: {
|
onClicked: {
|
||||||
|
view.currentIndex = index
|
||||||
if (isTrip) {
|
if (isTrip) {
|
||||||
manager.appendTextToLog("clicked on trip " + tripTitle)
|
manager.appendTextToLog("clicked on trip " + tripTitle)
|
||||||
// toggle expand (backend to deal with unexpand other trip)
|
// toggle expand (backend to deal with unexpand other trip)
|
||||||
|
@ -141,7 +151,7 @@ Kirigami.ScrollablePage {
|
||||||
left: parent.left
|
left: parent.left
|
||||||
right: parent.right
|
right: parent.right
|
||||||
}
|
}
|
||||||
color: subsurfaceTheme.backgroundColor
|
color: selected ? subsurfaceTheme.darkerPrimaryColor : subsurfaceTheme.backgroundColor
|
||||||
visible: !isTrip
|
visible: !isTrip
|
||||||
Item {
|
Item {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
@ -149,7 +159,7 @@ Kirigami.ScrollablePage {
|
||||||
id: leftBarDive
|
id: leftBarDive
|
||||||
width: Kirigami.Units.smallSpacing
|
width: Kirigami.Units.smallSpacing
|
||||||
height: isTopLevel ? 0 : diveListEntry.height * 0.8
|
height: isTopLevel ? 0 : diveListEntry.height * 0.8
|
||||||
color: subsurfaceTheme.lightPrimaryColor
|
color: selected ? subsurfaceTheme.backgroundColor :subsurfaceTheme.darkerPrimaryColor // reverse of the diveBackground
|
||||||
anchors {
|
anchors {
|
||||||
left: parent.left
|
left: parent.left
|
||||||
top: parent.top
|
top: parent.top
|
||||||
|
@ -173,7 +183,7 @@ Kirigami.ScrollablePage {
|
||||||
font.pointSize: subsurfaceTheme.smallPointSize
|
font.pointSize: subsurfaceTheme.smallPointSize
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
maximumLineCount: 1 // needed for elide to work at all
|
maximumLineCount: 1 // needed for elide to work at all
|
||||||
color: subsurfaceTheme.textColor
|
color: selected ? subsurfaceTheme.darkerPrimaryTextColor : subsurfaceTheme.textColor
|
||||||
anchors {
|
anchors {
|
||||||
left: parent.left
|
left: parent.left
|
||||||
leftMargin: horizontalPadding * 2
|
leftMargin: horizontalPadding * 2
|
||||||
|
@ -194,7 +204,7 @@ Kirigami.ScrollablePage {
|
||||||
text: (undefined !== dateTime) ? dateTime : ""
|
text: (undefined !== dateTime) ? dateTime : ""
|
||||||
width: Math.max(locationText.width * 0.45, paintedWidth) // helps vertical alignment throughout listview
|
width: Math.max(locationText.width * 0.45, paintedWidth) // helps vertical alignment throughout listview
|
||||||
font.pointSize: subsurfaceTheme.smallPointSize
|
font.pointSize: subsurfaceTheme.smallPointSize
|
||||||
color: diveOrTripDelegateItem.checked ? subsurfaceTheme.darkerPrimaryTextColor : subsurfaceTheme.secondaryTextColor
|
color: selected ? subsurfaceTheme.darkerPrimaryTextColor : subsurfaceTheme.secondaryTextColor
|
||||||
}
|
}
|
||||||
// spacer, just in case
|
// spacer, just in case
|
||||||
Controls.Label {
|
Controls.Label {
|
||||||
|
@ -206,14 +216,14 @@ Kirigami.ScrollablePage {
|
||||||
text: (undefined !== depthDuration) ? depthDuration : ""
|
text: (undefined !== depthDuration) ? depthDuration : ""
|
||||||
width: Math.max(Kirigami.Units.gridUnit * 3, paintedWidth) // helps vertical alignment throughout listview
|
width: Math.max(Kirigami.Units.gridUnit * 3, paintedWidth) // helps vertical alignment throughout listview
|
||||||
font.pointSize: subsurfaceTheme.smallPointSize
|
font.pointSize: subsurfaceTheme.smallPointSize
|
||||||
color: diveOrTripDelegateItem.checked ? subsurfaceTheme.darkerPrimaryTextColor : subsurfaceTheme.secondaryTextColor
|
color: selected ? subsurfaceTheme.darkerPrimaryTextColor : subsurfaceTheme.secondaryTextColor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Controls.Label {
|
Controls.Label {
|
||||||
id: numberText
|
id: numberText
|
||||||
text: "#" + number
|
text: "#" + number
|
||||||
font.pointSize: subsurfaceTheme.smallPointSize
|
font.pointSize: subsurfaceTheme.smallPointSize
|
||||||
color: diveOrTripDelegateItem.checked ? subsurfaceTheme.darkerPrimaryTextColor : subsurfaceTheme.secondaryTextColor
|
color: selected ? subsurfaceTheme.darkerPrimaryTextColor : subsurfaceTheme.secondaryTextColor
|
||||||
anchors {
|
anchors {
|
||||||
right: parent.right
|
right: parent.right
|
||||||
rightMargin: Kirigami.Units.smallSpacing
|
rightMargin: Kirigami.Units.smallSpacing
|
||||||
|
|
Loading…
Add table
Reference in a new issue