File indexing completed on 2024-04-28 04:42:43
0001 /* 0002 * SPDX-FileCopyrightText: 2020-2021 Han Young <hanyoung@protonmail.com> 0003 * SPDX-FileCopyrightText: 2020 Devin Lin <espidev@gmail.com> 0004 * 0005 * SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #pragma once 0009 0010 #include <kweathercore/kweathercore_export.h> 0011 0012 #include "weatherforecast.h" 0013 0014 class QTimeZone; 0015 0016 namespace KWeatherCore 0017 { 0018 0019 /** Parser for api.met.no replies. 0020 * @internal only exported for unit tests 0021 */ 0022 class MetNoParser 0023 { 0024 public: 0025 KWEATHERCORE_EXPORT void parseLocationForecast(const QByteArray &data); 0026 KWEATHERCORE_EXPORT void applySunriseToForecast(const QTimeZone &timezone); 0027 0028 WeatherForecast forecast; 0029 0030 inline bool hasData() const 0031 { 0032 return !hourlyForecast.empty(); 0033 } 0034 0035 private: 0036 void parseOneElement(const QJsonObject &obj); 0037 bool isDayTime(const QDateTime &dt) const; 0038 0039 std::vector<HourlyWeatherForecast> hourlyForecast; 0040 }; 0041 }