From a8863ca865b4a47d8778aa9eb6faa2a114dfacc5 Mon Sep 17 00:00:00 2001 From: Oscar Andreasson Date: Mon, 22 Jun 2015 23:21:49 -0700 Subject: [PATCH] Position.qml finished. Some more stuff done on the QmlMirror.qml page --- Position.qml | 54 ++++++++++++++++++++++++++++++++++++++++----------- QmlMirror.qml | 12 ++++++++++-- 2 files changed, 53 insertions(+), 13 deletions(-) diff --git a/Position.qml b/Position.qml index 17ff812..4595f8f 100644 --- a/Position.qml +++ b/Position.qml @@ -1,12 +1,13 @@ import QtPositioning 5.2 import QtQuick 2.3 - +import QtQuick.Layouts 1.1 +import QtQuick.XmlListModel 2.0 Rectangle { id: root + color: "black" PositionSource { id: positionSource - onPositionChanged: { } Component.onCompleted: { positionSource.update() } } @@ -14,22 +15,53 @@ Rectangle { XmlListModel { id: listModel property variant coordinate + property double lng: positionSource.position.coordinate.longitude + property double lat: positionSource.position.coordinate.latitude - source: "http://api.geonames.org/findNearbyPlaceName?" + - "lat=" + coordinate.latitude + - "&lng=" + coordinate.longitude + source: "http://api.geonames.org/findNearbyPlaceName?username=frznlogic&" + + "lat=" + lat + + "&lng=" + lng query: "/geonames/geoname" - XmlRole { name: "toponymName"; query: "toponymName/string()" } - XmlRole { name: "name"; query: "name/string()" } - XmlRole { name: "lat"; query: "lat/string()" } - XmlRole { name: "lng"; query: "lng/string()" } + XmlRole { name: "cityname"; query: "name/string()" } XmlRole { name: "geonameId"; query: "geonameId/string()" } - XmlRole { name: "countryCode"; query: "countryCode/string()" } XmlRole { name: "countryName"; query: "countryName/string()" } XmlRole { name: "distance"; query: "distance/string()" } + + onStatusChanged: { + if (status == XmlListModel.Ready) + { + locationName.text = listModel.get(0).cityname + locationCountry.text = listModel.get(0).countryName + } + } } + Rectangle { + id: positionId + anchors.top: parent.top + anchors.left: parent.left + anchors.right: parent.right + height: 100 + color:"black" + Text { + id: locationName + anchors.fill: parent + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignTop + text: "Unknown" + font.pointSize: 48 + color: "white" + } + Text { + id: locationCountry + anchors.fill: parent + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignBottom + text: "Unknown" + font.pointSize: 20 + color: "white" + } + } } - diff --git a/QmlMirror.qml b/QmlMirror.qml index c0d8402..7203626 100644 --- a/QmlMirror.qml +++ b/QmlMirror.qml @@ -8,9 +8,17 @@ ApplicationWindow { height: 1920 color: "black" - Clock { + Position { + id: positionId anchors.top: parent.top anchors.left: parent.left + anchors.right: parent.right + height: 100 + } + + Clock { + anchors.top: positionId.bottom + anchors.left: parent.left width: 360 height: 240 } @@ -19,7 +27,7 @@ ApplicationWindow { id: weatherId width: 360 height: 400 - anchors.top: parent.top + anchors.top: positionId.bottom anchors.right: parent.right Weather { width: 360