Changeset View
Changeset View
Standalone View
Standalone View
kstars/widgets/moonphasecalendarwidget.h
Context not available. | |||||
15 | * * | 15 | * * | ||
---|---|---|---|---|---|
16 | ***************************************************************************/ | 16 | ***************************************************************************/ | ||
17 | 17 | | |||
18 | #ifndef _MOONPHASECALENDARWIDGET_H_ | 18 | #pragma once | ||
19 | #define _MOONPHASECALENDARWIDGET_H_ | 19 | | ||
20 | #include <KColorScheme> | ||||
20 | 21 | | |||
21 | #include <QWidget> | 22 | #include <QWidget> | ||
22 | #include <QCalendarWidget> | 23 | #include <QCalendarWidget> | ||
23 | 24 | | |||
24 | #include <KColorScheme> | | |||
25 | | ||||
26 | class KSMoon; | 25 | class KSMoon; | ||
27 | class KSSun; | 26 | class KSSun; | ||
28 | class KStarsDateTime; | 27 | class KStarsDateTime; | ||
Context not available. | |||||
33 | 32 | | |||
34 | public: | 33 | public: | ||
35 | /** | 34 | /** | ||
36 | * Constructor | 35 | * Constructor | ||
37 | * @param moon A reference to a (non-const) KSMoon object, that will be updated | 36 | * @param moon A reference to a (non-const) KSMoon object, that will be updated | ||
38 | * @param sun A reference to a (non-const) KSSun object, that will be updated | 37 | * @param sun A reference to a (non-const) KSSun object, that will be updated | ||
39 | */ | 38 | */ | ||
40 | explicit MoonPhaseCalendar(KSMoon &moon, KSSun &sun, QWidget *parent = 0); | 39 | explicit MoonPhaseCalendar(KSMoon &moon, KSSun &sun, QWidget *parent = nullptr); | ||
41 | 40 | | |||
42 | ~MoonPhaseCalendar(); | 41 | ~MoonPhaseCalendar(); | ||
43 | 42 | | |||
44 | /** | 43 | /** @return a suggested size for the widget */ | ||
45 | * @return a suggested size for the widget | | |||
46 | */ | | |||
47 | virtual QSize sizeHint() const; | 44 | virtual QSize sizeHint() const; | ||
48 | 45 | | |||
49 | public slots: | 46 | public slots: | ||
50 | 47 | | |||
51 | /** | 48 | /** | ||
52 | * Set the geometry of the moon phase calendar (overloaded from QWidget). | 49 | * Set the geometry of the moon phase calendar (overloaded from QWidget). | ||
53 | * Resizes the cells so as to fill the space of the calendar. | 50 | * Resizes the cells so as to fill the space of the calendar. | ||
54 | * @note This is called automatically by resize events. | 51 | * @note This is called automatically by resize events. | ||
55 | * @p x the x-position of the widget | 52 | * @p x the x-position of the widget | ||
56 | * @p y the y-position of the widget | 53 | * @p y the y-position of the widget | ||
57 | * @p w the width of the widget | 54 | * @p w the width of the widget | ||
58 | * @p h the height of the widget | 55 | * @p h the height of the widget | ||
59 | */ | 56 | */ | ||
60 | | ||||
61 | virtual void setGeometry(int x, int y, int w, int h); | 57 | virtual void setGeometry(int x, int y, int w, int h); | ||
62 | 58 | | |||
63 | virtual void setGeometry(const QRect &r); | 59 | virtual void setGeometry(const QRect &r); | ||
64 | 60 | | |||
65 | protected: | 61 | protected: | ||
66 | /** | 62 | /** | ||
67 | * Overrides KDateTable::paintEvent() to draw moon phases on the | 63 | * Overrides KDateTable::paintEvent() to draw moon phases on the | ||
68 | * calendar cells by calling this->paintCell() | 64 | * calendar cells by calling this->paintCell() | ||
69 | * @note Most of this code is copied from KDateTable::paintEvent() | 65 | * @note Most of this code is copied from KDateTable::paintEvent() | ||
70 | */ | 66 | */ | ||
71 | virtual void paintEvent(QPaintEvent *e); | 67 | virtual void paintEvent(QPaintEvent *e); | ||
72 | 68 | | |||
73 | /** | 69 | /** | ||
74 | * Replaces KDateTable::paintCell() to draw moon phases on the calendar cells | 70 | * Replaces KDateTable::paintCell() to draw moon phases on the calendar cells | ||
75 | * @note Most of this code is copied from KDateTable::paintCell() | 71 | * @note Most of this code is copied from KDateTable::paintCell() | ||
76 | */ | 72 | */ | ||
77 | void paintCell(QPainter *painter, int row, int col, const KColorScheme &colorScheme); | 73 | void paintCell(QPainter *painter, int row, int col, const KColorScheme &colorScheme); | ||
78 | 74 | | |||
79 | /** | 75 | /** | ||
80 | * @short Loads the moon images, appropriately resized depending | 76 | * @short Loads the moon images, appropriately resized depending | ||
81 | * on the current cell size. | 77 | * on the current cell size. | ||
82 | * | 78 | * | ||
83 | * @note This method is very slow and one must avoid calling it more than once. | 79 | * @note This method is very slow and one must avoid calling it more than once. | ||
84 | */ | 80 | */ | ||
85 | void loadImages(); | 81 | void loadImages(); | ||
86 | 82 | | |||
87 | /** | 83 | /** @short Computes the optimum moon image size */ | ||
88 | * @short Computes the optimum moon image size | | |||
89 | */ | | |||
90 | void computeMoonImageSize(); | 84 | void computeMoonImageSize(); | ||
91 | 85 | | |||
92 | private: | 86 | private: | ||
93 | /** | 87 | /** | ||
94 | * @short Computes the moon phase for the given date. | 88 | * @short Computes the moon phase for the given date. | ||
95 | * @param date Date / Time of the computation | 89 | * @param date Date / Time of the computation | ||
96 | * @return the _integer_ phase for the given date | 90 | * @return the _integer_ phase for the given date | ||
97 | */ | 91 | */ | ||
98 | unsigned short computeMoonPhase(const KStarsDateTime &date); | 92 | unsigned short computeMoonPhase(const KStarsDateTime &date); | ||
99 | 93 | | |||
100 | QPixmap m_Images[36]; // Array storing moon images against integer phase | 94 | QPixmap m_Images[36]; // Array storing moon images against integer phase | ||
101 | 95 | | |||
102 | double cellWidth, cellHeight; | 96 | double cellWidth { 0 }; | ||
103 | int numWeekRows; | 97 | double cellHeight { 0 }; | ||
104 | int numDayColumns; | 98 | int numWeekRows { 0 }; | ||
105 | int MoonImageSize; | 99 | int numDayColumns { 0 }; | ||
106 | bool imagesLoaded; | 100 | int MoonImageSize { 0 }; | ||
101 | bool imagesLoaded { false }; | ||||
107 | 102 | | |||
108 | KSMoon &m_Moon; | 103 | KSMoon &m_Moon; | ||
109 | KSSun &m_Sun; | 104 | KSSun &m_Sun; | ||
110 | }; | 105 | }; | ||
111 | | ||||
112 | #endif | | |||
Context not available. |