Cleaned up weatherinfo and removed some visible stuff

Cleaned up the Transport module
Started adding a Position module
This commit is contained in:
Oscar Andreasson 2015-06-20 10:00:08 -07:00
parent 7f3d543711
commit 021547f3df
9 changed files with 63 additions and 42 deletions

1
.gitignore vendored
View file

@ -1,2 +1,3 @@
*.user *.user
*.autosave
build/ build/

35
Position.qml Normal file
View file

@ -0,0 +1,35 @@
import QtPositioning 5.2
import QtQuick 2.3
Rectangle {
id: root
PositionSource {
id: positionSource
onPositionChanged: { }
Component.onCompleted: { positionSource.update() }
}
XmlListModel {
id: listModel
property variant coordinate
source: "http://api.geonames.org/findNearbyPlaceName?" +
"lat=" + coordinate.latitude +
"&lng=" + coordinate.longitude
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: "geonameId"; query: "geonameId/string()" }
XmlRole { name: "countryCode"; query: "countryCode/string()" }
XmlRole { name: "countryName"; query: "countryName/string()" }
XmlRole { name: "distance"; query: "distance/string()" }
}
}

View file

@ -6,5 +6,5 @@ SUBDIRS = weatherinfo
SOURCES = QmlMirror.qml \ SOURCES = QmlMirror.qml \
Clock.qml \ Clock.qml \
Weather.qml \ Weather.qml \
Transport.qml Transport.qml \
Position.qml

View file

@ -15,12 +15,16 @@ ApplicationWindow {
height: 240 height: 240
} }
Weather { Rectangle {
id: weatherId id: weatherId
width: 360
height: 400
anchors.top: parent.top anchors.top: parent.top
anchors.right: parent.right anchors.right: parent.right
Weather {
width: 360 width: 360
height: 240 height: 400
}
} }
Transport { Transport {
@ -28,7 +32,7 @@ ApplicationWindow {
anchors.top: weatherId.bottom anchors.top: weatherId.bottom
anchors.right: parent.right anchors.right: parent.right
width: 360 width: 360
height: 480 height: 400
color: "black" color: "black"
} }

View file

@ -4,9 +4,10 @@ import QtQuick.Controls 1.3
import QtQuick.Controls.Styles 1.2 import QtQuick.Controls.Styles 1.2
Rectangle { Rectangle {
id: root
color: "black" color: "black"
width: 360 width: 360
height: 480 height: 400
ListModel { ListModel {
id: lineModel id: lineModel
@ -47,7 +48,7 @@ Rectangle {
headerDelegate: Rectangle { headerDelegate: Rectangle {
height: textItem.implicitHeight * 1.2 height: textItem.implicitHeight * 1.2
width: textItem.implicitWidth // width: textItem.implicitWidth
color: "black" color: "black"
Text { Text {
id: textItem id: textItem
@ -64,8 +65,8 @@ Rectangle {
anchors.right: parent.right anchors.right: parent.right
anchors.top: parent.top anchors.top: parent.top
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.bottomMargin: 1 anchors.bottomMargin: 0
anchors.topMargin: 1 anchors.topMargin: 0
width:1 width:1
color: "black" color: "black"
} }
@ -85,22 +86,22 @@ Rectangle {
TableViewColumn { TableViewColumn {
role: "number" role: "number"
title: "No" title: "No"
width: parent.width / 6 width: root.width / 6
} }
TableViewColumn { TableViewColumn {
role: "destination" role: "destination"
title: "Destination" title: "Destination"
width: (parent.width / 6) * 3 width: (root.width / 6) * 3
} }
TableViewColumn { TableViewColumn {
role: "arriving" role: "arriving"
title: "Arriving" title: "Arriving"
width: parent.width / 6 width: root.width / 6
} }
TableViewColumn { TableViewColumn {
role: "next" role: "next"
title: "Next" title: "Next"
width: (parent.width / 6)-2 width: (root.width / 6)-2
} }
} }
} }

View file

@ -3,8 +3,6 @@ import net.frozentux.weatherinfo 1.0
Rectangle { Rectangle {
width: 360
height: 600
color: "black" color: "black"
WeatherInfo { WeatherInfo {

View file

@ -42,11 +42,12 @@ import QtQuick 2.0
import net.frozentux.weatherinfo 1.0 import net.frozentux.weatherinfo 1.0
//! [0] //! [0]
Item { Rectangle {
id: window id: window
//! [0] //! [0]
width: 360 width: parent.width
height: 640 height: parent.height
color: "black"
state: "loading" state: "loading"
@ -97,7 +98,6 @@ Item {
} }
//! [3]
BigForecastIcon { BigForecastIcon {
id: current id: current
@ -107,13 +107,9 @@ Item {
weatherIcon: (model.hasValidWeather weatherIcon: (model.hasValidWeather
? model.weather.weatherIcon ? model.weather.weatherIcon
: "01d") : "01d")
//! [3]
topText: (model.hasValidWeather topText: (model.hasValidWeather
? model.weather.temperature ? model.weather.temperature
: "??") : "??")
bottomText: (model.hasValidWeather
? model.weather.weatherDescription
: "No weather data")
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
@ -121,9 +117,7 @@ Item {
model.refreshWeather() model.refreshWeather()
} }
} }
//! [4]
} }
//! [4]
Row { Row {
id: iconRow id: iconRow

View file

@ -44,7 +44,6 @@ Item {
id: current id: current
property string topText: "20*" property string topText: "20*"
property string bottomText: "Mostly cloudy"
property string weatherIcon: "01d" property string weatherIcon: "01d"
property real smallSide: (current.width < current.height ? current.width : current.height) property real smallSide: (current.width < current.height ? current.width : current.height)
@ -69,17 +68,4 @@ Item {
height: current.smallSide height: current.smallSide
} }
Text {
text: current.bottomText
color: "white"
font.pointSize: 23
wrapMode: Text.WordWrap
width: parent.width
horizontalAlignment: Text.AlignRight
anchors {
bottom: current.bottom
right: current.right
rightMargin: 5
}
}
} }

View file

@ -12,9 +12,11 @@ SOURCES += appmodel.cpp \
HEADERS += appmodel.h \ HEADERS += appmodel.h \
weatherplugin.h weatherplugin.h
target.path = $$[QT_INSTALL_QML]/net/frozentux/weatherinfo
qmldirfile.path = $$[QT_INSTALL_QML]/net/frozentux/weatherinfo qmldirfile.path = $$[QT_INSTALL_QML]/net/frozentux/weatherinfo
qmldirfile.files = qmldir qmldirfile.files = qmldir
INSTALLS += qmldirfile INSTALLS += qmldirfile target
RESOURCES += \ RESOURCES += \
images.qrc images.qrc