Diffstat (limited to 'core/pim/datebook/holiday/christian/chrisholiday.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/pim/datebook/holiday/christian/chrisholiday.cpp | 50 |
1 files changed, 49 insertions, 1 deletions
diff --git a/core/pim/datebook/holiday/christian/chrisholiday.cpp b/core/pim/datebook/holiday/christian/chrisholiday.cpp index ef6516e..f8e310f 100644 --- a/core/pim/datebook/holiday/christian/chrisholiday.cpp +++ b/core/pim/datebook/holiday/christian/chrisholiday.cpp | |||
@@ -3,2 +3,3 @@ | |||
3 | #include <qobject.h> | 3 | #include <qobject.h> |
4 | #include <qpe/event.h> | ||
4 | 5 | ||
@@ -89,5 +90,52 @@ void ChrisHoliday::calc_easter() | |||
89 | 90 | ||
90 | QMap<QDate,QStringList> ChrisHoliday::entries(const QDate&,const QDate&) | 91 | QMap<QDate,QStringList> ChrisHoliday::entries(const QDate&start,const QDate&end) |
91 | { | 92 | { |
92 | QMap<QDate,QStringList> ret; | 93 | QMap<QDate,QStringList> ret; |
94 | if (start==end) { | ||
95 | ret[start]=entries(start); | ||
96 | return ret; | ||
97 | } | ||
98 | QDate d; | ||
99 | int daysto; | ||
100 | if (end < start) { | ||
101 | d = end; | ||
102 | daysto = end.daysTo(start); | ||
103 | } else { | ||
104 | d = start; | ||
105 | daysto = start.daysTo(end); | ||
106 | } | ||
107 | QStringList temp; | ||
108 | for (int i=0;i<daysto;++i) { | ||
109 | temp = entries(d.addDays(i)); | ||
110 | if (temp.count()==0) continue; | ||
111 | ret[d.addDays(i)]+=temp; | ||
112 | temp.clear(); | ||
113 | } | ||
114 | return ret; | ||
115 | } | ||
116 | |||
117 | QValueList<EffectiveEvent> ChrisHoliday::events(const QDate&start,const QDate&end) | ||
118 | { | ||
119 | QValueList<EffectiveEvent> ret; | ||
120 | QDate d = (start<end?start:end); | ||
121 | int daysto = start.daysTo(end); | ||
122 | if (daysto < 0) { | ||
123 | daysto = end.daysTo(start); | ||
124 | } | ||
125 | |||
126 | QStringList temp; | ||
127 | for (int i =0; i<daysto;++i) { | ||
128 | temp = entries(d.addDays(i)); | ||
129 | if (temp.count()==0) { | ||
130 | continue; | ||
131 | } | ||
132 | for (unsigned j=0;j<temp.count();++j) { | ||
133 | Event ev; | ||
134 | ev.setDescription(temp[j]); | ||
135 | ev.setStart(d.addDays(i)); | ||
136 | ev.setAllDay(true); | ||
137 | ret.append(EffectiveEvent(ev,d.addDays(i))); | ||
138 | } | ||
139 | } | ||
140 | |||
93 | return ret; | 141 | return ret; |