PlacemarkDialog.qml 2.9 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
//
// This file is part of the Marble Virtual Globe.
//
// This program is free software licensed under the GNU LGPL. You can
// find a copy of this license in LICENSE.txt in the top directory of
// the source code.
//
// Copyright 2015      Dennis Nienhüser <nienhueser@kde.org>
//

import QtQuick 2.3
12
import QtQuick.Controls 1.3
13
import QtQuick.Window 2.2
14
import QtQuick.Layouts 1.1
15 16 17 18 19 20 21

import org.kde.edu.marble 0.20

Item {
    id: root

    property var placemark: null
22
    property string actionIconSource: routeEditor.currentProfileIcon
23

24
    height: placemark === null ? 0 : Screen.pixelDensity * 6 + infoLayout.height
25

26
    function addToRoute() {
27 28 29 30
        ensureRouteHasDeparture()
        routing.addViaByPlacemarkAtIndex(routing.waypointCount(), placemark)
        routing.clearSearchResultPlacemarks()
        placemark = null
31 32 33
        itemStack.state = "routing"
    }

34
    onPlacemarkChanged: {
35
        itemStack.state = placemark ? "place" : ""
36 37
    }

38 39 40 41 42 43 44 45 46 47 48 49 50
    SystemPalette {
        id: palette
        colorGroup: SystemPalette.Active
    }

    Rectangle {
        anchors.fill: parent
        color: palette.base
    }

    Column {
        id: infoLayout
        anchors {
Dennis Nienhüser's avatar
Dennis Nienhüser committed
51
            bottom: parent.bottom
52
            left: parent.left
53
            right: parent.right
54 55 56
            margins: Screen.pixelDensity * 2
        }

Dennis Nienhüser's avatar
Dennis Nienhüser committed
57
        IconText {
58 59 60
            width: parent.width
            text: placemark === null ? "" : placemark.name
            maximumLineCount: 2
61
            font.pointSize: 20
62 63
        }

Dennis Nienhüser's avatar
Dennis Nienhüser committed
64
        IconText {
65 66 67 68 69
            width: parent.width
            text: placemark === null ? "" : placemark.description
            maximumLineCount: 4
        }

Dennis Nienhüser's avatar
Dennis Nienhüser committed
70
        IconText {
71 72 73
            width: parent.width
            text: placemark === null ? "" : placemark.address
            maximumLineCount: 4
Dennis Nienhüser's avatar
Dennis Nienhüser committed
74 75 76
        }

        IconText {
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
            width: parent.width
            visible: placemark !== null && placemark.website !== ""
            text: placemark === null ? "" : "<a href=\"" + placemark.website + "\">" + placemark.website + "</a>"
            icon: "qrc:/material/browser.svg"
            maximumLineCount: 4
        }

        IconText {
            width: parent.width
            visible: placemark !== null && placemark.wikipedia !== ""
            text: placemark === null ? "" : "<a href=\"" + placemark.wikipedia + "\">Wikipedia</a>"
            icon: "qrc:/material/browser.svg"
            maximumLineCount: 4
        }

        IconText {
Dennis Nienhüser's avatar
Dennis Nienhüser committed
93 94 95 96
            width: parent.width
            visible: placemark !== null && placemark.fuelDetails !== ""
            text: placemark === null ? "" : placemark.fuelDetails
            icon: "qrc:/material/gas_station.svg"
97 98 99 100 101
        }
    }

    function ensureRouteHasDeparture() {
        if (routing.routeRequestModel.count === 0) {
102
            if (marbleMaps.positionAvailable) {
103
                routing.addViaByPlacemark(marbleMaps.currentPosition)
104
            }
105 106 107
        }
    }
}