1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2010 Dennis Nienhüser <nienhueser@kde.org>
4//
5
6import Qt 4.7
7import org.kde.marble 0.20
8
9Rectangle {
10    width: 700
11    height: 700
12
13    SystemPalette { id: activePalette }
14
15    Image {
16        x: 113
17        y: 0
18        source: "marble.png"
19        anchors.horizontalCenter: parent.horizontalCenter
20    }
21
22    Rectangle {
23        id: searchinput
24        x: 38
25        y: 117
26        width: 565
27        height: 49
28        border.color: "black"
29        border.width: 1
30        anchors.horizontalCenter: parent.horizontalCenter
31
32        TextInput {
33            anchors.fill: parent
34            anchors.margins: 10
35            id: searchterm
36            text: ""
37            font.pointSize: 18
38            focus: true
39        }
40    }
41
42    Item {
43        id: buttonlayouter
44        anchors.top: searchinput.bottom
45        anchors.horizontalCenter: parent.horizontalCenter
46        anchors.margins: 10
47        height: button1.height
48
49        Button {
50            id: button1
51            anchors.right: buttonlayouter.horizontalCenter
52            anchors.margins: 10
53            width: 126
54            height: 25
55            label: "Marble Search"
56
57            onClicked: { map.search.find( searchterm.text ) }
58        }
59
60        Button {
61            id: button2
62            anchors.left: buttonlayouter.horizontalCenter
63            anchors.margins: 10
64            width: 140
65            height: 25
66            label: "I'm Feeling Lucky"
67        }
68    }
69
70    Item {
71        id: mapcontainer
72        width: 600
73        height: 400
74        anchors.horizontalCenter: buttonlayouter.horizontalCenter
75        anchors.top: buttonlayouter.bottom
76        anchors.margins: 30
77        clip: true
78
79        MarbleWidget {
80            id: map
81            width: 600
82            height: 400
83            activeRenderPlugins: [ "navigation", "scalebar" ]
84
85            property Search search: Search {
86                map: map
87                placemarkDelegate: myDelegate
88            }
89        }
90
91        Component {
92            id: myDelegate
93
94            Image {
95                source: "marker.svg"
96                fillMode: Image.PreserveAspectFit
97                width: 64;
98                height: 64
99
100                property bool showDetails: false
101
102                Text {
103                    anchors.horizontalCenter: parent.horizontalCenter
104                    anchors.bottom: parent.bottom
105                    width: parent.width
106                    height: parent.height
107                    wrapMode: Text.WrapAtWordBoundaryOrAnywhere
108                    color: "white"
109                    text: index+1
110                    horizontalAlignment: Text.AlignHCenter
111                }
112
113                Rectangle
114                {
115                    anchors.left: parent.right
116                    id: itemdetails
117                    scale: 0.75
118                    width: 140
119                    height: 60
120                    color: "yellow"
121                    radius: 10
122                    border.width: 1
123                    border.color: "gray"
124                    z: 42
125
126                    visible: parent.showDetails
127
128                    Text {
129                        id: itemdetailtext
130                        x: 10
131                        y: 5
132                        width: parent.width - 20
133                        height: parent.height - 10
134                        text: display
135                        wrapMode: "WrapAtWordBoundaryOrAnywhere"
136                        clip: true
137                    }
138
139                    states: State {
140                        name: "back"
141                        PropertyChanges { target: itemdetails; scale: 1 }
142                        when: itemdetailtext.visible
143                    }
144
145                    transitions: Transition {
146                        NumberAnimation { properties: "scale"; duration: 100 }
147                    }
148                }
149
150                MouseArea {
151                    anchors.fill: parent
152                    onClicked: showDetails = !showDetails
153                }
154            }
155        }
156    }
157}
158