mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Add DiveListModel
This model will be used to show the dives in QML. This commit adds the model, and the means to link it to QML. Signed-off-by: Grace Karanja <gracie.karanja89@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
bf882416f9
commit
b7e4b35cde
6 changed files with 392 additions and 4 deletions
|
|
@ -37,4 +37,53 @@ ApplicationWindow {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
width: parent.width; height: parent.height
|
||||
anchors.fill: parent
|
||||
|
||||
Component {
|
||||
id: diveDelegate
|
||||
Item {
|
||||
id: wrapper
|
||||
width: parent.width; height: 55
|
||||
Column {
|
||||
Text { text: '#:' + diveNumber + "(" + location + ")" }
|
||||
Text { text: date }
|
||||
Text { text: duration + " " + depth }
|
||||
}
|
||||
MouseArea { anchors.fill: parent; onClicked: diveListView.currentIndex = index }
|
||||
|
||||
states: State {
|
||||
name: "Current"
|
||||
when: wrapper.ListView.isCurrentItem
|
||||
PropertyChanges { target: wrapper; x:20 }
|
||||
}
|
||||
transitions: Transition {
|
||||
NumberAnimation { properties: "x"; duration: 200 }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: highlightBar
|
||||
Rectangle {
|
||||
width: parent.width; height: 50
|
||||
color: "#FFFF88"
|
||||
y: diveListView.currentItem.y;
|
||||
Behavior on y { SpringAnimation { spring: 2; damping: 0.1 } }
|
||||
}
|
||||
}
|
||||
|
||||
ListView {
|
||||
id: diveListView
|
||||
width: parent.width; height: parent.height
|
||||
anchors.fill: parent
|
||||
model: diveModel
|
||||
delegate: diveDelegate
|
||||
focus: true
|
||||
highlight: highlightBar
|
||||
highlightFollowsCurrentItem: false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue