Warning, /plasma-mobile/mycroft-plasmoid-mobile/plasmoid/contents/ui/PlacesDelegate.qml is written in an unsupported language. File is not indexed.

0001 /* Copyright 2016 Aditya Mehra <aix.m@outlook.com>                            
0002 
0003     This library is free software; you can redistribute it and/or
0004     modify it under the terms of the GNU Lesser General Public
0005     License as published by the Free Software Foundation; either
0006     version 2.1 of the License, or (at your option) version 3, or any
0007     later version accepted by the membership of KDE e.V. (or its
0008     successor approved by the membership of KDE e.V.), which shall
0009     act as a proxy defined in Section 6 of version 3 of the license.
0010     
0011     This library is distributed in the hope that it will be useful,
0012     but WITHOUT ANY WARRANTY; without even the implied warranty of
0013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0014     Lesser General Public License for more details.
0015     
0016     You should have received a copy of the GNU Lesser General Public
0017     License along with this library.  If not, see <http://www.gnu.org/licenses/>.
0018 */
0019 
0020 import QtQuick 2.9
0021 import QtQml.Models 2.2
0022 import QtQuick.Controls 2.2
0023 import QtQuick.Layouts 1.3
0024 import org.kde.plasma.core 2.0 as PlasmaCore
0025 import org.kde.plasma.plasmoid 2.0
0026 import org.kde.plasma.components 2.0 as PlasmaComponents
0027 import QtGraphicalEffects 1.0
0028 
0029 Rectangle {
0030         id: nearbyDelegateItm
0031         height: units.gridUnit * 6
0032         anchors.left: parent.left
0033         anchors.right: parent.right
0034         width: cbwidth
0035         border.color: Qt.darker(PlasmaCore.ColorScope.backgroundColor, 1.2)
0036         color: Qt.darker(PlasmaCore.ColorScope.backgroundColor, 1.2) 
0037         layer.enabled: true
0038         layer.effect: DropShadow {
0039             horizontalOffset: 0
0040             verticalOffset: 1
0041             radius: 10
0042             samples: 32
0043             spread: 0.1
0044             color: Qt.rgba(0, 0, 0, 0.3)
0045         }
0046         
0047         function getRouteInformation(llat, llong, dlat, dlong, oappid, oappcode){
0048             var routedoc = new XMLHttpRequest()
0049             var url = "https://route.cit.api.here.com/routing/7.2/calculateroute.json?waypoint0=" + llat + "," + llong + "&waypoint1=" + dlat + "," + dlong + "&mode=fastest;car;&app_id=" + oappid + "&app_code=" + oappcode + "&depature=now"
0050             routedoc.open("GET", url, true);
0051             routedoc.send()
0052 
0053             routedoc.onreadystatechange = function() {
0054                  if (routedoc.readyState === XMLHttpRequest.DONE && routedoc.responseText !== "undefined") {
0055                      var reqroute = routedoc.responseText
0056                      if (reqroute !== "undefined") {
0057                             var filterRouteDict = JSON.parse(reqroute)
0058                             for (var i = 0; i<filterRouteDict.response.route[0].leg[0].maneuver.length; i++){
0059                             var getRouteDict = filterRouteDict.response.route[0].leg[0].maneuver[i].instruction
0060                             console.log(JSON.stringify(getRouteDict))
0061                             routeLmodel.append({navInstruction: getRouteDict});
0062                           }
0063                        }
0064                     }
0065                 }
0066             }
0067 
0068         Item {
0069             id: contentdlgtitem
0070             anchors.fill: parent
0071 
0072             Item {
0073             id: skillTopRowLayout
0074             anchors.top: parent.top
0075             anchors.left: parent.left
0076             anchors.right: parent.right 
0077             height: plcname.height + units.gridUnit * 0.25
0078 
0079             PlasmaComponents.Label {
0080                 id: plcname
0081                 anchors.verticalCenter: parent.verticalCenter
0082                 anchors.left: parent.left
0083                 anchors.leftMargin: units.gridUnit * 0.15
0084                 wrapMode: Text.WordWrap;
0085                 font.bold: true;
0086                 font.pointSize: theme.defaultFont.pointSize
0087                 font.letterSpacing: theme.defaultFont.letterSpacing
0088                 font.wordSpacing: theme.defaultFont.wordSpacing
0089                 font.family: theme.defaultFont.family
0090                 renderType: Text.NativeRendering 
0091                 text: i18n(placetitle.replace(/["']/g, ""))
0092                 }
0093             
0094             PlasmaComponents.Label {
0095                 id: plcdistance
0096                 anchors.verticalCenter: parent.verticalCenter
0097                 anchors.right: parent.right
0098                 anchors.rightMargin: units.gridUnit * 0.15
0099                 wrapMode: Text.WordWrap;
0100                 font.bold: true;
0101                 font.pointSize: theme.defaultFont.pointSize
0102                 font.letterSpacing: theme.defaultFont.letterSpacing
0103                 font.wordSpacing: theme.defaultFont.wordSpacing
0104                 font.family: theme.defaultFont.family
0105                 renderType: Text.NativeRendering 
0106                 text: i18nc("mtrs stands for meters", "Distance: %1 <i>mtrs</i>", placedistance)
0107                 }
0108             }
0109                 
0110             Rectangle {
0111                 id: placesCrdSeptHeader
0112                     height: 1
0113                     anchors {
0114                         left: parent.left
0115                         right: parent.right
0116                         top: skillTopRowLayout.bottom
0117                         topMargin: units.gridUnit * 0.2
0118                        }
0119                     color: theme.linkColor
0120             }
0121 
0122             Item {
0123                 id: plcinner
0124                 anchors.top: placesCrdSeptHeader.bottom
0125                 anchors.topMargin: units.gridUnit * 0.15
0126                 anchors.left: parent.left
0127                 anchors.right: parent.right
0128                 anchors.bottom: parent.bottom
0129 
0130             Item {
0131                 id: plcinnerdetails
0132                 anchors.left: parent.left
0133                 anchors.right: parent.right
0134                 anchors.top: parent.top
0135                 height: navbbtn.height
0136                 
0137                 Image {
0138                     id: placeIconType
0139                     anchors.left: parent.left
0140                     anchors.leftMargin: units.gridUnit * 0.05
0141                     anchors.verticalCenter: parent.verticalCenter
0142                     source: placeicon.replace(/["']/g, "")
0143                     width: units.gridUnit * 2
0144                     height: units.gridUnit * 2
0145                 }
0146 
0147                 PlasmaComponents.Label {
0148                     id: placeAddressLabel
0149                     anchors.left: placeIconType.right
0150                     anchors.leftMargin: units.gridUnit * 0.05
0151                     wrapMode: Text.WordWrap;
0152                     font.bold: true;
0153                     font.pointSize: theme.defaultFont.pointSize
0154                     font.letterSpacing: theme.defaultFont.letterSpacing
0155                     font.wordSpacing: theme.defaultFont.wordSpacing
0156                     font.family: theme.defaultFont.family
0157                     renderType: Text.NativeRendering 
0158                     text: i18n("Address: %1", placeloc.replace(/["']/g, ""))
0159                 }
0160 
0161                 Image {
0162                     id: navbbtn
0163                     anchors.right: parent.right
0164                     anchors.margins: units.gridUnit * 0.5
0165                     source: "../images/up.png"
0166                     width: units.gridUnit * 2
0167                     height: units.gridUnit * 2
0168 
0169                     MouseArea {
0170                        anchors.fill: parent
0171 
0172                        onClicked: {
0173                          var navpos = placeposition.replace(/[[\]]/g,'').split(",");
0174                          getRouteInformation(placelocallat, placelocallong, navpos[0], navpos[1], placeappid, placeappcode)
0175                          var formatedurl =   "https://image.maps.cit.api.here.com/mia/1.6/mapview?c=" + placelocallat + "," + placelocallong + "&z=16&poi=" + navpos[0] + "," + navpos[1] + "&poithm=0&app_id=" + placeappid + "&app_code=" + placeappcode + "&h=" + cbheight / 2 + "&w=" + cbwidth + "&ppi=500ppi=120&t=7&f=2&i=true"
0176                          navMapDrawer.open()
0177                          navMapDrawer.getURL = formatedurl
0178                        }
0179                     }
0180                 }
0181             }
0182 
0183             Rectangle {
0184                 id: placesCrdSeptFooter
0185                     height: apiCreds.height
0186                     anchors {
0187                         left: parent.left
0188                         right: parent.right
0189                         bottom: parent.bottom
0190                        }
0191                     color: theme.linkColor
0192 
0193                 PlasmaComponents.Label {
0194                     id: tagsplccs
0195                     anchors.left: parent.left
0196                     anchors.leftMargin: units.gridUnit * 0.15
0197                     anchors.right: apiCreds.left
0198                     anchors.verticalCenter: parent.verticalCenter
0199                     wrapMode: Text.WordWrap;
0200                     font.pointSize: theme.defaultFont.pointSize - 2
0201                     text: placetags
0202                     }
0203                 
0204                 PlasmaComponents.Label {
0205                     id: apiCreds
0206                     anchors.right: parent.right
0207                     anchors.rightMargin: units.gridUnit * 0.15
0208                     anchors.verticalCenter: parent.verticalCenter
0209                     wrapMode: Text.WordWrap;
0210                     font.bold: true
0211                     font.pointSize: theme.defaultFont.pointSize - 2
0212                     text: i18n("<i>Powered By: Here.API</i>")
0213                     }
0214                 }
0215             }             
0216         }
0217     }
0218