Commit 52d812dc authored by Volker Krause's avatar Volker Krause

Add weather forecast delegate

parent 86d4d341
......@@ -102,6 +102,7 @@ qml_lint(
TouristAttractionDelegate.qml
TrainDelegate.qml
TrainPage.qml
WeatherForecastDelegate.qml
)
install(TARGETS itinerary-app ${INSTALL_TARGETS_DEFAULT_ARGS})
......
......@@ -112,6 +112,12 @@ Kirigami.ScrollablePage {
countryInfo: modelData.countryInformation
}
}
Component {
id: weatherForecastDelegate
App.WeatherForecastDelegate {
weatherForecast: modelData.weatherForecast
}
}
Kirigami.CardsListView {
id: listView
......@@ -132,6 +138,7 @@ Kirigami.ScrollablePage {
case TimelineModel.TouristAttraction: return touristAttractionDelegate;
case TimelineModel.TodayMarker: return todayDelegate;
case TimelineModel.CountryInfo: return countryInfoDelegate;
case TimelineModel.WeatherForecast: return weatherForecastDelegate;
}
}
}
......
/*
Copyright (C) 2018 Volker Krause <vkrause@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 2.5
import QtQuick.Layouts 1.1
import QtQuick.Controls 2.1 as QQC2
import org.kde.kirigami 2.4 as Kirigami
import org.kde.itinerary 1.0
import "." as App
Kirigami.AbstractCard {
id: root
property var weatherForecast
visible: weatherForecast.valid
headerOrientation: Qt.Horizontal
header: Rectangle {
id: headerBackground
Kirigami.Theme.colorSet: Kirigami.Theme.Complementary
Kirigami.Theme.inherit: false
color: Kirigami.Theme.backgroundColor
implicitWidth: icon.implicitWidth + Kirigami.Units.largeSpacing * 2
Layout.minimumHeight: implicitWidth
Layout.fillHeight: true
anchors.leftMargin: -root.leftPadding
anchors.topMargin: -root.topPadding
anchors.bottomMargin: -root.rightPadding
Kirigami.Icon {
id: icon
anchors.fill: parent
anchors.margins: Kirigami.Units.largeSpacing
source: weatherForecast.symbolIconName
}
}
contentItem: ColumnLayout {
Layout.fillWidth: true
QQC2.Label {
text: qsTr("Temperature: %1 °C").arg(weatherForecast.temperature)
color: Kirigami.Theme.textColor
Layout.fillWidth: true
}
QQC2.Label {
text: qsTr("Precipitation: %1 mm").arg(weatherForecast.precipitation)
color: Kirigami.Theme.textColor
Layout.fillWidth: true
}
}
}
......@@ -21,5 +21,6 @@
<file>TouristAttractionDelegate.qml</file>
<file>TrainDelegate.qml</file>
<file>TrainPage.qml</file>
<file>WeatherForecastDelegate.qml</file>
</qresource>
</RCC>
......@@ -50,7 +50,8 @@ public:
Restaurant,
TouristAttraction,
TodayMarker,
CountryInfo
CountryInfo,
WeatherForecast
};
Q_ENUM(ElementType)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment