Warning, /education/marble/src/apps/marble-maps/Bookmarks.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-License-Identifier: LGPL-2.1-or-later
0002 //
0003 // SPDX-FileCopyrightText: 2016 Dennis Nienhüser <nienhueser@kde.org>
0004 //
0005
0006 import QtQuick 2.8
0007 import QtQuick.Controls 2.2
0008 import QtQuick.Window 2.2
0009 import QtQuick.Layouts 1.3
0010 import QtQml.Models 2.1
0011 import QtQuick.Controls.Material 2.1
0012 import QtGraphicalEffects 1.0
0013
0014 import org.kde.kirigami 2.0 as Kirigami
0015
0016 import org.kde.marble 0.20
0017
0018 Kirigami.Page {
0019 id: bookmarkPage
0020 title: "Bookmarks"
0021
0022 property variant marbleQuickItem
0023 signal backTriggered()
0024
0025 Flickable {
0026 id: root
0027 anchors.fill: parent
0028 property int currentIndex: 0
0029
0030 SystemPalette {
0031 id: palette
0032 colorGroup: SystemPalette.Active
0033 }
0034
0035 Column {
0036 id: column
0037 anchors {
0038 fill: parent
0039 margins: Screen.pixelDensity * 2
0040 }
0041
0042 Text {
0043 text: "<h3>Bookmarks</h3>"
0044 }
0045
0046 ListView {
0047 id: bookmarksView
0048 interactive: false
0049 width: parent.width
0050 spacing: 5
0051 height: contentHeight
0052
0053 model: DelegateModel {
0054 id: visualModel
0055 model: bookmarks.model
0056
0057 delegate:
0058 MouseArea {
0059 id: delegateRoot
0060 propagateComposedEvents: true
0061 property int visualIndex: DelegateModel.itemsIndex
0062 width: bookmarksView.width
0063 height: 100
0064 drag.target: icon
0065 drag.axis: Drag.YAxis
0066
0067 SwipeDelegate {
0068 id: delegate
0069 text: model.display
0070 width: parent.width
0071 height: Screen.pixelDensity * 2 + Math.max(bookmarkText.height, imageButton.height)
0072
0073 contentItem: Rectangle {
0074 id: icon
0075 width: parent.width
0076 height: Screen.pixelDensity + Math.max(bookmarkText.height, imageButton.height)
0077
0078 anchors {
0079 horizontalCenter: parent.horizontalCenter;
0080 verticalCenter: parent.verticalCenter
0081 }
0082
0083 Drag.active: delegateRoot.drag.active
0084 Drag.source: delegateRoot
0085 Drag.hotSpot.x: 50
0086 Drag.hotSpot.y: 50
0087 color: "transparent"
0088
0089 Text{
0090 id: bookmarkText
0091 anchors.left: imageButton.right
0092 leftPadding: 5
0093 text: delegate.text
0094 elide: Text.ElideRight
0095 horizontalAlignment: Text.AlignLeft
0096 anchors.verticalCenter: parent.verticalCenter
0097 font.pointSize: 12
0098 color: palette.text
0099 }
0100
0101 Image {
0102 id: imageButton
0103 anchors {
0104 left: bookmarksView.left
0105 verticalCenter: parent.verticalCenter
0106 }
0107 source: "qrc:///material/place.svg"
0108 width: Screen.pixelDensity * 6
0109 verticalAlignment: Qt.AlignVCenter
0110
0111 height: width
0112 smooth: true
0113 }
0114
0115 ColorOverlay{
0116 anchors.fill: imageButton
0117 source: imageButton
0118 color: palette.highlight
0119 }
0120 }
0121
0122 swipe.behind: Item {
0123 width: parent.width
0124 height: parent.height
0125
0126 Rectangle{
0127 width: parent.width
0128 color: "#333333"
0129 height: parent.height
0130 z: 200
0131 Text {
0132 font.pointSize: 10
0133 text: qsTr("Removed")
0134 color: "white"
0135
0136 padding: 20
0137 anchors.fill: parent
0138 horizontalAlignment: Qt.AlignRight
0139 verticalAlignment: Qt.AlignVCenter
0140
0141 opacity: delegate.swipe.complete ? 1 : 0
0142 Behavior on opacity {
0143 NumberAnimation {}
0144 }
0145 }
0146 }
0147
0148 SwipeDelegate.onClicked: delegate.swipe.close()
0149 SwipeDelegate.onPressedChanged: undoTimer.stop()
0150 }
0151
0152
0153 Timer {
0154 id: undoTimer
0155 interval: 1600
0156 onTriggered: {
0157 var currentBookmark = bookmarks.placemark(index)
0158 bookmarks.removeBookmark(currentBookmark.longitude, currentBookmark.latitude)
0159 }
0160 }
0161
0162 swipe.onCompleted: undoTimer.start()
0163 swipe.onClosed: delegate.swipe.close()
0164 swipe.transition: Transition {
0165 SmoothedAnimation { velocity: 3; easing.type: Easing.InOutCubic }
0166 }
0167
0168 states: [
0169 State {
0170 when: icon.Drag.active
0171 ParentChange {
0172 target: icon
0173 parent: root
0174 }
0175
0176 AnchorChanges {
0177 target: icon;
0178 anchors.horizontalCenter: undefined;
0179 anchors.verticalCenter: undefined
0180 }
0181 }
0182 ]
0183
0184 background: Rectangle {
0185 color: "transparent"
0186 }
0187 }
0188
0189 DropArea {
0190 anchors.fill: parent
0191 onEntered: visualModel.items.move(drag.source.visualIndex, delegateRoot.visualIndex)
0192 }
0193 }
0194 }
0195
0196 remove: Transition {
0197 SequentialAnimation {
0198 PauseAnimation { duration: 125 }
0199 NumberAnimation { property: "height"; to: 0; easing.type: Easing.InOutQuad }
0200 }
0201 }
0202
0203 displaced: Transition {
0204 SequentialAnimation {
0205 PauseAnimation { duration: 125 }
0206 NumberAnimation { property: "y"; easing.type: Easing.InOutQuad }
0207 }
0208 }
0209 }
0210
0211 Column {
0212 visible: bookmarksView.model.count === 0
0213 width: parent.width
0214
0215 Text {
0216 width: 0.8 * parent.width
0217 font.pointSize: 18
0218 color: paletteDisabled.text
0219 text: qsTr("Your bookmarks will appear here.")
0220 wrapMode: Text.WrapAtWordBoundaryOrAnywhere
0221 elide: Text.ElideRight
0222 }
0223
0224 Image {
0225 anchors.right: parent.right
0226 anchors.bottom: column.bottom
0227 width: 0.3 * parent.width
0228 fillMode: Image.PreserveAspectFit
0229 source: "qrc:/konqi/books.png"
0230 }
0231 }
0232 }
0233
0234 }
0235
0236 Bookmarks {
0237 id: bookmarks
0238 map: marbleQuickItem
0239 }
0240 }