diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt index 92abf53..31100c9 100644 --- a/src/app/CMakeLists.txt +++ b/src/app/CMakeLists.txt @@ -1,87 +1,110 @@ set(itinerary_srcs countryinformation.cpp pkpassmanager.cpp reservationmanager.cpp timelinemodel.cpp ) ecm_qt_declare_logging_category(itinerary_srcs HEADER logging.h IDENTIFIER Log CATEGORY_NAME org.kde.itinerary ) add_library(itinerary STATIC ${itinerary_srcs}) target_link_libraries(itinerary PUBLIC KPim::Itinerary KPim::PkPass KF5::I18n Qt5::Network ) add_executable(itinerary-app main.cpp applicationcontroller.cpp localizer.cpp pkpassimageprovider.cpp settings.cpp qml.qrc ) target_include_directories(itinerary-app PRIVATE ${CMAKE_BINARY_DIR}) target_link_libraries(itinerary-app PRIVATE itinerary itinerary-weather Qt5::Quick KF5::Contacts ) if (ANDROID) # explicitly add runtime dependencies and transitive link dependencies, # so androiddeployqt picks them up target_link_libraries(itinerary-app PRIVATE KF5::Archive KF5::Kirigami2 Qt5::AndroidExtras Qt5::Svg KF5::Prison ) kirigami_package_breeze_icons(ICONS document-open edit-delete go-next-symbolic map-symbolic settings-configure view-calendar-day view-refresh + + weather-clear + weather-clear-night + weather-few-clouds + weather-few-clouds-night + weather-clouds + weather-clouds-night + weather-showers-day + weather-showers-night + weather-showers-scattered-day + weather-showers-scattered-night + weather-snow-scattered-day + weather-snow-scattered-night + weather-storm-day + weather-storm-night + weather-many-clouds + weather-fog + weather-showers + weather-showers-scattered + weather-hail + weather-snow + weather-snow-scattered + weather-storm ) else () target_link_libraries(itinerary-app PRIVATE Qt5::Positioning) set_target_properties(itinerary-app PROPERTIES OUTPUT_NAME "itinerary") endif() qml_lint( main.qml BoardingPass.qml BusDelegate.qml BusPage.qml CountryInfoDelegate.qml DetailsPage.qml FlightDelegate.qml FlightPage.qml HotelDelegate.qml HotelPage.qml PkPassPage.qml PlaceDelegate.qml RestaurantDelegate.qml RestaurantPage.qml SettingsPage.qml TicketTokenDelegate.qml TimelineDelegate.qml TimelinePage.qml TouristAttractionDelegate.qml TrainDelegate.qml TrainPage.qml ) install(TARGETS itinerary-app ${INSTALL_TARGETS_DEFAULT_ARGS}) if (NOT ANDROID) install(PROGRAMS org.kde.itinerary.desktop DESTINATION ${KDE_INSTALL_APPDIR}) endif() diff --git a/src/weather/weatherforecast.cpp b/src/weather/weatherforecast.cpp index 56a8e64..69a8d7e 100644 --- a/src/weather/weatherforecast.cpp +++ b/src/weather/weatherforecast.cpp @@ -1,90 +1,111 @@ /* Copyright (C) 2018 Volker Krause 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 . */ #include "weatherforecast.h" #include class WeatherForecastPrivate : public QSharedData { public: QDateTime m_dt; float m_temp = -300; WeatherForecast::SymbolType m_symbol = WeatherForecast::Unknown; }; WeatherForecast::WeatherForecast() : d(new WeatherForecastPrivate) { } WeatherForecast::WeatherForecast(const WeatherForecast&) = default; WeatherForecast::~WeatherForecast() = default; WeatherForecast& WeatherForecast::operator=(const WeatherForecast&) = default; bool WeatherForecast::isValid() const { return d->m_dt.isValid(); } QDateTime WeatherForecast::dateTime() const { return d->m_dt; } void WeatherForecast::setDateTime(const QDateTime &dt) { d.detach(); d->m_dt = dt; } float WeatherForecast::temperature() const { return d->m_temp; } void WeatherForecast::setTemperature(float t) { d.detach(); d->m_temp = t; } WeatherForecast::SymbolType WeatherForecast::symbolType() const { return d->m_symbol; } void WeatherForecast::setSymbolType(WeatherForecast::SymbolType type) { d.detach(); d->m_symbol = type; } QString WeatherForecast::symbolIconName() const { - return {}; // TODO map to breeze icons and determine day/night version + // TODO night icon handling + switch (symbolType()) { + case Unknown: return {}; + case Clear: return QStringLiteral("weather-clear"); + case LightClouds: return QStringLiteral("weather-few-clouds"); + case PartlyCloudy: return QStringLiteral("weather-clouds"); + case RainShowers: return QStringLiteral("weather-showers-day"); + case LightRainShowers: return QStringLiteral("weather-showers-scattered-day"); + case LightSnowShowers: return QStringLiteral("weather-snow-scattered-day"); + case ThunderStormShowers: return QStringLiteral("weather-storm-day"); + // ^ have day and night variants + // v only universal variants + case Clouds: return QStringLiteral("weather-many-clouds"); + case Fog: return QStringLiteral("weather-fog"); + case Rain: return QStringLiteral("weather-showers"); + case LightRain: return QStringLiteral("weather-showers-scattered"); + case Hail: return QStringLiteral("weather-hail"); + case Snow: return QStringLiteral("weather-snow"); + case LightSnow: return QStringLiteral("weather-snow-scattered"); + case ThunderStorm: return QStringLiteral("weather-storm"); + } + return {}; } void WeatherForecast::merge(WeatherForecast &other) { d.detach(); if (d->m_temp < -273.15) { d->m_temp = other.temperature(); } if (d->m_symbol == Unknown) { d->m_symbol = other.symbolType(); } } diff --git a/src/weather/weatherforecast.h b/src/weather/weatherforecast.h index 82245f0..8407eb5 100644 --- a/src/weather/weatherforecast.h +++ b/src/weather/weatherforecast.h @@ -1,89 +1,93 @@ /* Copyright (C) 2018 Volker Krause 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 . */ #ifndef WEATHERFORECAST_H #define WEATHERFORECAST_H #include #include #include class QDateTime; class WeatherForecastPrivate; /** Weather forecast data */ class WeatherForecast { Q_GADGET + Q_PROPERTY(bool valid READ isValid CONSTANT) + Q_PROPERTY(float temperature READ temperature CONSTANT) + Q_PROPERTY(QString symbolIconName READ symbolIconName CONSTANT) + public: /** Weather symbol, aligned with the Breeze icon theme, not the data source symbols. */ enum SymbolType : uint8_t { Unknown, Clear, LightClouds, PartlyCloudy, RainShowers, LightRainShowers, LightSnowShowers, ThunderStormShowers, // ^ have day and night variants // v only universal variants Clouds, Fog, Rain, LightRain, Hail, Snow, LightSnow, ThunderStorm }; Q_ENUM(SymbolType) WeatherForecast(); WeatherForecast(const WeatherForecast&); ~WeatherForecast(); WeatherForecast& operator=(const WeatherForecast&); bool isValid() const; /** The time this data is valid for. */ QDateTime dateTime() const; void setDateTime(const QDateTime &dt); // TODO is this enough or do we need min/max ranges? float temperature() const; void setTemperature(float t); SymbolType symbolType() const; void setSymbolType(SymbolType type); QString symbolIconName() const; // TODO precipitation probability /** Merge with @p other. */ void merge(WeatherForecast &other); private: QExplicitlySharedDataPointer d; }; Q_DECLARE_METATYPE(WeatherForecast) #endif // WEATHERFORECAST_H