File indexing completed on 2024-05-05 16:49:23
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 #pragma once 0008 #include <QDateTime> 0009 #include <QJsonObject> 0010 #include <QObject> 0011 #include <QPair> 0012 #include <kweathercore/kweathercore_export.h> 0013 #include <memory> 0014 namespace KWeatherCore 0015 { 0016 /** 0017 * @short The Sunrise class contains the information of sunrise/set on a day and 0018 * more 0019 * 0020 * @see SunriseSource 0021 * 0022 * @author Han Young <hanyoung@protonmail.com> 0023 */ 0024 class KWEATHERCORE_EXPORT Sunrise 0025 { 0026 Q_GADGET 0027 Q_PROPERTY(QDateTime highMoonTime READ highMoonTime) 0028 Q_PROPERTY(QDateTime lowMoonTime READ lowMoonTime) 0029 Q_PROPERTY(QDateTime solarMidnightTime READ solarMidnightTime) 0030 Q_PROPERTY(QDateTime solarNoonTime READ solarNoonTime) 0031 Q_PROPERTY(QDateTime sunRise READ sunRise WRITE setSunRise) 0032 Q_PROPERTY(QDateTime sunSet READ sunSet WRITE setSunSet) 0033 Q_PROPERTY(QDateTime moonRise READ moonRise WRITE setMoonRise) 0034 Q_PROPERTY(QDateTime moonSet READ moonSet WRITE setMoonSet) 0035 Q_PROPERTY(qreal moonPhase READ moonPhase WRITE setMoonPhase) 0036 Q_PROPERTY(qreal highMoon READ highMoon) 0037 Q_PROPERTY(qreal lowMoon READ lowMoon) 0038 Q_PROPERTY(qreal solarNoon READ solarNoon) 0039 Q_PROPERTY(qreal solarMidnight READ solarMidnight) 0040 0041 public: 0042 Sunrise(); 0043 Sunrise(const Sunrise &other); 0044 Sunrise(Sunrise &&other); 0045 ~Sunrise(); 0046 Sunrise &operator=(const Sunrise &other); 0047 Sunrise &operator=(Sunrise &&other); 0048 /** 0049 * construct from json 0050 */ 0051 static Sunrise fromJson(QJsonObject obj); 0052 /** 0053 * convert to json 0054 */ 0055 QJsonObject toJson() const; 0056 QDateTime highMoonTime() const; 0057 double highMoon() const; 0058 QDateTime lowMoonTime() const; 0059 double lowMoon() const; 0060 QDateTime solarMidnightTime() const; 0061 QDateTime solarNoonTime() const; 0062 double solarMidnight() const; 0063 double solarNoon() const; 0064 const QDateTime &sunRise() const; 0065 const QDateTime &sunSet() const; 0066 const QDateTime &moonRise() const; 0067 const QDateTime &moonSet() const; 0068 double moonPhase() const; 0069 /** 0070 * set high moon time and elevation 0071 */ 0072 void setHighMoon(const QPair<QDateTime, double> &highMoon); 0073 /** 0074 * set solar midnight time and elevation 0075 */ 0076 void setSolarMidnight(const QPair<QDateTime, double> &solarMidnight); 0077 /** 0078 * set solar noon time and elevation 0079 */ 0080 void setSolarNoon(const QPair<QDateTime, double> &solarNoon); 0081 /** 0082 * set low moon time time and elevation 0083 */ 0084 void setLowMoon(const QPair<QDateTime, double> &lowMoon); 0085 /** 0086 * sun rise time 0087 */ 0088 void setSunRise(const QDateTime &sunRise); 0089 /** 0090 * set sun set time 0091 */ 0092 void setSunSet(const QDateTime &sunSet); 0093 /** 0094 * set moon rise time 0095 */ 0096 void setMoonRise(const QDateTime &moonRise); 0097 /** 0098 * set moon set time 0099 */ 0100 void setMoonSet(const QDateTime &moonSet); 0101 /** 0102 * set moon phase 0103 * @param moonPhase 0104 * 0..25: "waxing crescent"; 0105 * 25..50: "waxing gibbous"; 0106 * 50..75: "waning gibbous"; 0107 * 75..100: "waning crescent"; 0108 */ 0109 void setMoonPhase(double moonPhase); 0110 0111 private: 0112 class SunrisePrivate; 0113 std::unique_ptr<SunrisePrivate> d; 0114 }; 0115 }