KWeatherCore

sunrise.h
1 /*
2  * SPDX-FileCopyrightText: 2020-2021 Han Young <[email protected]>
3  * SPDX-FileCopyrightText: 2020 Devin Lin <[email protected]>
4  *
5  * SPDX-License-Identifier: LGPL-2.0-or-later
6  */
7 #pragma once
8 #include <QDateTime>
9 #include <QJsonObject>
10 #include <QObject>
11 #include <QPair>
12 #include <kweathercore/kweathercore_export.h>
13 #include <memory>
14 namespace KWeatherCore
15 {
16 /**
17  * @short The Sunrise class contains the information of sunrise/set on a day and
18  * more
19  *
20  * @see SunriseSource
21  *
22  * @author Han Young <[email protected]>
23  */
24 class KWEATHERCORE_EXPORT Sunrise
25 {
26  Q_GADGET
27  Q_PROPERTY(QDateTime highMoonTime READ highMoonTime)
28  Q_PROPERTY(QDateTime lowMoonTime READ lowMoonTime)
29  Q_PROPERTY(QDateTime solarMidnightTime READ solarMidnightTime)
30  Q_PROPERTY(QDateTime solarNoonTime READ solarNoonTime)
31  Q_PROPERTY(QDateTime sunRise READ sunRise WRITE setSunRise)
32  Q_PROPERTY(QDateTime sunSet READ sunSet WRITE setSunSet)
33  Q_PROPERTY(QDateTime moonRise READ moonRise WRITE setMoonRise)
34  Q_PROPERTY(QDateTime moonSet READ moonSet WRITE setMoonSet)
35  Q_PROPERTY(qreal moonPhase READ moonPhase WRITE setMoonPhase)
36  Q_PROPERTY(QString moonPhaseString READ moonPhaseString)
37  Q_PROPERTY(qreal highMoon READ highMoon)
38  Q_PROPERTY(qreal lowMoon READ lowMoon)
39  Q_PROPERTY(qreal solarNoon READ solarNoon)
40  Q_PROPERTY(qreal solarMidnight READ solarMidnight)
41 
42 public:
43  Sunrise();
44  Sunrise(const Sunrise &other);
45  ~Sunrise();
46  Sunrise &operator=(const Sunrise &other);
47  /**
48  * construct from json
49  */
50  static Sunrise fromJson(QJsonObject obj);
51  /**
52  * convert to json
53  */
54  QJsonObject toJson() const;
55  QDateTime highMoonTime() const;
56  double highMoon() const;
57  QDateTime lowMoonTime() const;
58  double lowMoon() const;
59  QDateTime solarMidnightTime() const;
60  QDateTime solarNoonTime() const;
61  double solarMidnight() const;
62  double solarNoon() const;
63  const QDateTime &sunRise() const;
64  const QDateTime &sunSet() const;
65  const QDateTime &moonRise() const;
66  const QDateTime &moonSet() const;
67  double moonPhase() const;
68  /**
69  * set high moon time and elevation
70  */
71  void setHighMoon(const QPair<QDateTime, double> &highMoon);
72  /**
73  * set solar midnight time and elevation
74  */
75  void setSolarMidnight(const QPair<QDateTime, double> &solarMidnight);
76  /**
77  * set solar noon time and elevation
78  */
79  void setSolarNoon(const QPair<QDateTime, double> &solarNoon);
80  /**
81  * set low moon time time and elevation
82  */
83  void setLowMoon(const QPair<QDateTime, double> &lowMoon);
84  /**
85  * sun rise time
86  */
87  void setSunRise(const QDateTime &sunRise);
88  /**
89  * set sun set time
90  */
91  void setSunSet(const QDateTime &sunSet);
92  /**
93  * set moon rise time
94  */
95  void setMoonRise(const QDateTime &moonRise);
96  /**
97  * set moon set time
98  */
99  void setMoonSet(const QDateTime &moonSet);
100  /**
101  * set moon phase
102  * @param moonPhase
103  * 0..25: "waxing crescent";
104  * 25..50: "waxing gibbous";
105  * 50..75: "waning gibbous";
106  * 75..100: "waning crescent";
107  */
108  void setMoonPhase(double moonPhase);
109 
110  QString moonPhaseString() const;
111 
112 private:
113  class SunrisePrivate;
115 };
116 }
The Sunrise class contains the information of sunrise/set on a day and more.
Definition: sunrise.h:24
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Thu Oct 21 2021 23:05:33 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.