mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Mobile: use the CollapsedDiveListSortModel for dive list
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
c759157331
commit
8b0f4e65d3
1 changed files with 12 additions and 48 deletions
|
@ -17,8 +17,7 @@ Kirigami.ScrollablePage {
|
||||||
property color textColor: subsurfaceTheme.textColor
|
property color textColor: subsurfaceTheme.textColor
|
||||||
property color secondaryTextColor: subsurfaceTheme.secondaryTextColor
|
property color secondaryTextColor: subsurfaceTheme.secondaryTextColor
|
||||||
property int horizontalPadding: Kirigami.Units.gridUnit / 2 - Kirigami.Units.smallSpacing + 1
|
property int horizontalPadding: Kirigami.Units.gridUnit / 2 - Kirigami.Units.smallSpacing + 1
|
||||||
property string activeTrip
|
property QtObject diveListModel: diveTripModel
|
||||||
property QtObject diveListModel: diveModel
|
|
||||||
property string numShownText
|
property string numShownText
|
||||||
|
|
||||||
supportsRefreshing: true
|
supportsRefreshing: true
|
||||||
|
@ -39,8 +38,6 @@ Kirigami.ScrollablePage {
|
||||||
Component {
|
Component {
|
||||||
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
|
|
||||||
property bool diveOutsideTrip: tripNrDives === 0
|
|
||||||
// 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
|
||||||
|
|
||||||
|
@ -49,10 +46,10 @@ Kirigami.ScrollablePage {
|
||||||
id: innerListItem
|
id: innerListItem
|
||||||
enabled: true
|
enabled: true
|
||||||
supportsMouseEvents: true
|
supportsMouseEvents: true
|
||||||
checked: diveListView.currentIndex === model.index
|
checked: model.selected
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: diveOutsideTrip ? diveListEntry.height + Kirigami.Units.smallSpacing : 0
|
height: (collapsed & 1) ? diveListEntry.height + Kirigami.Units.smallSpacing : 0
|
||||||
visible: diveOutsideTrip
|
visible: collapsed & 1
|
||||||
backgroundColor: checked ? subsurfaceTheme.primaryColor : subsurfaceTheme.backgroundColor
|
backgroundColor: checked ? subsurfaceTheme.primaryColor : subsurfaceTheme.backgroundColor
|
||||||
activeBackgroundColor: subsurfaceTheme.primaryColor
|
activeBackgroundColor: subsurfaceTheme.primaryColor
|
||||||
textColor: checked ? subsurfaceTheme.primaryTextColor : subsurfaceTheme.textColor
|
textColor: checked ? subsurfaceTheme.primaryTextColor : subsurfaceTheme.textColor
|
||||||
|
@ -60,7 +57,7 @@ Kirigami.ScrollablePage {
|
||||||
states: [
|
states: [
|
||||||
State {
|
State {
|
||||||
name: "isHidden";
|
name: "isHidden";
|
||||||
when: tripId !== activeTrip && ! diveOutsideTrip
|
when: (collapsed & 1) == 0
|
||||||
PropertyChanges {
|
PropertyChanges {
|
||||||
target: innerListItem
|
target: innerListItem
|
||||||
height: 0
|
height: 0
|
||||||
|
@ -69,7 +66,7 @@ Kirigami.ScrollablePage {
|
||||||
},
|
},
|
||||||
State {
|
State {
|
||||||
name: "isVisible";
|
name: "isVisible";
|
||||||
when: tripId === activeTrip || diveOutsideTrip
|
when: (collapsed & 1) == 1
|
||||||
PropertyChanges {
|
PropertyChanges {
|
||||||
target: innerListItem
|
target: innerListItem
|
||||||
height: diveListEntry.height + Kirigami.Units.smallSpacing
|
height: diveListEntry.height + Kirigami.Units.smallSpacing
|
||||||
|
@ -77,44 +74,11 @@ Kirigami.ScrollablePage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
transitions: [
|
|
||||||
Transition {
|
|
||||||
from: "isHidden"
|
|
||||||
to: "isVisible"
|
|
||||||
SequentialAnimation {
|
|
||||||
NumberAnimation {
|
|
||||||
property: "visible"
|
|
||||||
duration: 1
|
|
||||||
}
|
|
||||||
NumberAnimation {
|
|
||||||
property: "height"
|
|
||||||
duration: 200 + 20 * tripNrDives
|
|
||||||
easing.type: Easing.InOutQuad
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
Transition {
|
|
||||||
from: "isVisible"
|
|
||||||
to: "isHidden"
|
|
||||||
SequentialAnimation {
|
|
||||||
NumberAnimation {
|
|
||||||
property: "height"
|
|
||||||
duration: 200 + 20 * tripNrDives
|
|
||||||
easing.type: Easing.InOutQuad
|
|
||||||
}
|
|
||||||
NumberAnimation {
|
|
||||||
property: "visible"
|
|
||||||
duration: 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
// When clicked, the mode changes to details view
|
// When clicked, the mode changes to details view
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (detailsWindow.state === "view") {
|
if (detailsWindow.state === "view") {
|
||||||
diveListView.currentIndex = index
|
//diveListView.currentIndex = index
|
||||||
detailsWindow.showDiveIndex(index);
|
detailsWindow.showDiveIndex(id);
|
||||||
// switch to detailsWindow (or push it if it's not in the stack)
|
// switch to detailsWindow (or push it if it's not in the stack)
|
||||||
var i = rootItem.pageIndex(detailsWindow)
|
var i = rootItem.pageIndex(detailsWindow)
|
||||||
if (i === -1)
|
if (i === -1)
|
||||||
|
@ -377,10 +341,10 @@ Kirigami.ScrollablePage {
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: headingBackground
|
anchors.fill: headingBackground
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (activeTrip === section)
|
if (diveTripModel.activeTrip() === section)
|
||||||
activeTrip = ""
|
diveTripModel.setActiveTrip("")
|
||||||
else
|
else
|
||||||
activeTrip = section
|
diveTripModel.setActiveTrip(section)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Controls.Label {
|
Controls.Label {
|
||||||
|
@ -609,7 +573,7 @@ Kirigami.ScrollablePage {
|
||||||
function setCurrentDiveListIndex(idx, noScroll) {
|
function setCurrentDiveListIndex(idx, noScroll) {
|
||||||
// pick the dive in the dive list and make sure its trip is expanded
|
// pick the dive in the dive list and make sure its trip is expanded
|
||||||
diveListView.currentIndex = idx
|
diveListView.currentIndex = idx
|
||||||
activeTrip = diveListView.currentItem.myData.tripId
|
diveTripModel.setActiveTrip(diveListView.currentItem.myData.tripId)
|
||||||
|
|
||||||
// update the diveDetails page to also show that dive
|
// update the diveDetails page to also show that dive
|
||||||
detailsWindow.showDiveIndex(idx)
|
detailsWindow.showDiveIndex(idx)
|
||||||
|
|
Loading…
Add table
Reference in a new issue