author | zautrix <zautrix> | 2005-04-10 13:17:21 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-04-10 13:17:21 (UTC) |
commit | ef11b9d4de01d601bfcfb8efacb0aeff1e657edb (patch) (unidiff) | |
tree | 5f4e6aa51ef357c6d9ecbe4d9a2908b8c2ca1228 /libkcal | |
parent | 04fe8f3523c46511e846a42e4bb92d6b8d33758b (diff) | |
download | kdepimpi-ef11b9d4de01d601bfcfb8efacb0aeff1e657edb.zip kdepimpi-ef11b9d4de01d601bfcfb8efacb0aeff1e657edb.tar.gz kdepimpi-ef11b9d4de01d601bfcfb8efacb0aeff1e657edb.tar.bz2 |
fix
-rw-r--r-- | libkcal/calendar.cpp | 10 | ||||
-rw-r--r-- | libkcal/calendar.h | 5 | ||||
-rw-r--r-- | libkcal/incidence.cpp | 14 | ||||
-rw-r--r-- | libkcal/incidence.h | 1 |
4 files changed, 27 insertions, 3 deletions
diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp index 406cd48..ed39ddb 100644 --- a/libkcal/calendar.cpp +++ b/libkcal/calendar.cpp | |||
@@ -1,467 +1,475 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 1998 Preston Brown | 3 | Copyright (c) 1998 Preston Brown |
4 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <stdlib.h> | 22 | #include <stdlib.h> |
23 | #include <time.h> | 23 | #include <time.h> |
24 | 24 | ||
25 | #include <kdebug.h> | 25 | #include <kdebug.h> |
26 | #include <kglobal.h> | 26 | #include <kglobal.h> |
27 | #include <klocale.h> | 27 | #include <klocale.h> |
28 | 28 | ||
29 | #include "exceptions.h" | 29 | #include "exceptions.h" |
30 | #include "calfilter.h" | 30 | #include "calfilter.h" |
31 | 31 | ||
32 | #include "calendar.h" | 32 | #include "calendar.h" |
33 | #include "syncdefines.h" | 33 | #include "syncdefines.h" |
34 | 34 | ||
35 | using namespace KCal; | 35 | using namespace KCal; |
36 | 36 | ||
37 | Calendar::Calendar() | 37 | Calendar::Calendar() |
38 | { | 38 | { |
39 | 39 | ||
40 | init(); | 40 | init(); |
41 | setTimeZoneId( " 00:00 Europe/London(UTC)" ); | 41 | setTimeZoneId( " 00:00 Europe/London(UTC)" ); |
42 | } | 42 | } |
43 | 43 | ||
44 | Calendar::Calendar( const QString &timeZoneId ) | 44 | Calendar::Calendar( const QString &timeZoneId ) |
45 | { | 45 | { |
46 | 46 | ||
47 | init(); | 47 | init(); |
48 | setTimeZoneId(timeZoneId); | 48 | setTimeZoneId(timeZoneId); |
49 | } | 49 | } |
50 | 50 | ||
51 | void Calendar::init() | 51 | void Calendar::init() |
52 | { | 52 | { |
53 | mObserver = 0; | 53 | mObserver = 0; |
54 | mNewObserver = false; | 54 | mNewObserver = false; |
55 | mUndoIncidence = 0; | 55 | mUndoIncidence = 0; |
56 | mModified = false; | 56 | mModified = false; |
57 | 57 | ||
58 | // Setup default filter, which does nothing | 58 | // Setup default filter, which does nothing |
59 | mDefaultFilter = new CalFilter; | 59 | mDefaultFilter = new CalFilter; |
60 | mFilter = mDefaultFilter; | 60 | mFilter = mDefaultFilter; |
61 | mFilter->setEnabled(false); | 61 | mFilter->setEnabled(false); |
62 | 62 | ||
63 | // initialize random numbers. This is a hack, and not | 63 | // initialize random numbers. This is a hack, and not |
64 | // even that good of one at that. | 64 | // even that good of one at that. |
65 | // srandom(time(0)); | 65 | // srandom(time(0)); |
66 | 66 | ||
67 | // user information... | 67 | // user information... |
68 | setOwner(i18n("Unknown Name")); | 68 | setOwner(i18n("Unknown Name")); |
69 | setEmail(i18n("unknown@nowhere")); | 69 | setEmail(i18n("unknown@nowhere")); |
70 | 70 | ||
71 | #if 0 | 71 | #if 0 |
72 | tmpStr = KOPrefs::instance()->mTimeZone; | 72 | tmpStr = KOPrefs::instance()->mTimeZone; |
73 | // kdDebug(5800) << "Calendar::Calendar(): TimeZone: " << tmpStr << endl; | 73 | // kdDebug(5800) << "Calendar::Calendar(): TimeZone: " << tmpStr << endl; |
74 | int dstSetting = KOPrefs::instance()->mDaylightSavings; | 74 | int dstSetting = KOPrefs::instance()->mDaylightSavings; |
75 | extern long int timezone; | 75 | extern long int timezone; |
76 | struct tm *now; | 76 | struct tm *now; |
77 | time_t curtime; | 77 | time_t curtime; |
78 | curtime = time(0); | 78 | curtime = time(0); |
79 | now = localtime(&curtime); | 79 | now = localtime(&curtime); |
80 | int hourOff = - ((timezone / 60) / 60); | 80 | int hourOff = - ((timezone / 60) / 60); |
81 | if (now->tm_isdst) | 81 | if (now->tm_isdst) |
82 | hourOff += 1; | 82 | hourOff += 1; |
83 | QString tzStr; | 83 | QString tzStr; |
84 | tzStr.sprintf("%.2d%.2d", | 84 | tzStr.sprintf("%.2d%.2d", |
85 | hourOff, | 85 | hourOff, |
86 | abs((timezone / 60) % 60)); | 86 | abs((timezone / 60) % 60)); |
87 | 87 | ||
88 | // if no time zone was in the config file, write what we just discovered. | 88 | // if no time zone was in the config file, write what we just discovered. |
89 | if (tmpStr.isEmpty()) { | 89 | if (tmpStr.isEmpty()) { |
90 | // KOPrefs::instance()->mTimeZone = tzStr; | 90 | // KOPrefs::instance()->mTimeZone = tzStr; |
91 | } else { | 91 | } else { |
92 | tzStr = tmpStr; | 92 | tzStr = tmpStr; |
93 | } | 93 | } |
94 | 94 | ||
95 | // if daylight savings has changed since last load time, we need | 95 | // if daylight savings has changed since last load time, we need |
96 | // to rewrite these settings to the config file. | 96 | // to rewrite these settings to the config file. |
97 | if ((now->tm_isdst && !dstSetting) || | 97 | if ((now->tm_isdst && !dstSetting) || |
98 | (!now->tm_isdst && dstSetting)) { | 98 | (!now->tm_isdst && dstSetting)) { |
99 | KOPrefs::instance()->mTimeZone = tzStr; | 99 | KOPrefs::instance()->mTimeZone = tzStr; |
100 | KOPrefs::instance()->mDaylightSavings = now->tm_isdst; | 100 | KOPrefs::instance()->mDaylightSavings = now->tm_isdst; |
101 | } | 101 | } |
102 | 102 | ||
103 | setTimeZone(tzStr); | 103 | setTimeZone(tzStr); |
104 | #endif | 104 | #endif |
105 | 105 | ||
106 | // KOPrefs::instance()->writeConfig(); | 106 | // KOPrefs::instance()->writeConfig(); |
107 | } | 107 | } |
108 | 108 | ||
109 | Calendar::~Calendar() | 109 | Calendar::~Calendar() |
110 | { | 110 | { |
111 | delete mDefaultFilter; | 111 | delete mDefaultFilter; |
112 | if ( mUndoIncidence ) | 112 | if ( mUndoIncidence ) |
113 | delete mUndoIncidence; | 113 | delete mUndoIncidence; |
114 | } | 114 | } |
115 | 115 | ||
116 | const QString &Calendar::getOwner() const | 116 | const QString &Calendar::getOwner() const |
117 | { | 117 | { |
118 | return mOwner; | 118 | return mOwner; |
119 | } | 119 | } |
120 | 120 | ||
121 | bool Calendar::undoDeleteIncidence() | 121 | bool Calendar::undoDeleteIncidence() |
122 | { | 122 | { |
123 | if (!mUndoIncidence) | 123 | if (!mUndoIncidence) |
124 | return false; | 124 | return false; |
125 | addIncidence(mUndoIncidence); | 125 | addIncidence(mUndoIncidence); |
126 | mUndoIncidence = 0; | 126 | mUndoIncidence = 0; |
127 | return true; | 127 | return true; |
128 | } | 128 | } |
129 | void Calendar::setOwner(const QString &os) | 129 | void Calendar::setOwner(const QString &os) |
130 | { | 130 | { |
131 | int i; | 131 | int i; |
132 | mOwner = os; | 132 | mOwner = os; |
133 | i = mOwner.find(','); | 133 | i = mOwner.find(','); |
134 | if (i != -1) | 134 | if (i != -1) |
135 | mOwner = mOwner.left(i); | 135 | mOwner = mOwner.left(i); |
136 | 136 | ||
137 | setModified( true ); | 137 | setModified( true ); |
138 | } | 138 | } |
139 | 139 | ||
140 | void Calendar::setTimeZone(const QString & tz) | 140 | void Calendar::setTimeZone(const QString & tz) |
141 | { | 141 | { |
142 | bool neg = FALSE; | 142 | bool neg = FALSE; |
143 | int hours, minutes; | 143 | int hours, minutes; |
144 | QString tmpStr(tz); | 144 | QString tmpStr(tz); |
145 | 145 | ||
146 | if (tmpStr.left(1) == "-") | 146 | if (tmpStr.left(1) == "-") |
147 | neg = TRUE; | 147 | neg = TRUE; |
148 | if (tmpStr.left(1) == "-" || tmpStr.left(1) == "+") | 148 | if (tmpStr.left(1) == "-" || tmpStr.left(1) == "+") |
149 | tmpStr.remove(0, 1); | 149 | tmpStr.remove(0, 1); |
150 | hours = tmpStr.left(2).toInt(); | 150 | hours = tmpStr.left(2).toInt(); |
151 | if (tmpStr.length() > 2) | 151 | if (tmpStr.length() > 2) |
152 | minutes = tmpStr.right(2).toInt(); | 152 | minutes = tmpStr.right(2).toInt(); |
153 | else | 153 | else |
154 | minutes = 0; | 154 | minutes = 0; |
155 | mTimeZone = (60*hours+minutes); | 155 | mTimeZone = (60*hours+minutes); |
156 | if (neg) | 156 | if (neg) |
157 | mTimeZone = -mTimeZone; | 157 | mTimeZone = -mTimeZone; |
158 | mLocalTime = false; | 158 | mLocalTime = false; |
159 | 159 | ||
160 | setModified( true ); | 160 | setModified( true ); |
161 | } | 161 | } |
162 | 162 | ||
163 | QString Calendar::getTimeZoneStr() const | 163 | QString Calendar::getTimeZoneStr() const |
164 | { | 164 | { |
165 | if (mLocalTime) | 165 | if (mLocalTime) |
166 | return ""; | 166 | return ""; |
167 | QString tmpStr; | 167 | QString tmpStr; |
168 | int hours = abs(mTimeZone / 60); | 168 | int hours = abs(mTimeZone / 60); |
169 | int minutes = abs(mTimeZone % 60); | 169 | int minutes = abs(mTimeZone % 60); |
170 | bool neg = mTimeZone < 0; | 170 | bool neg = mTimeZone < 0; |
171 | 171 | ||
172 | tmpStr.sprintf("%c%.2d%.2d", | 172 | tmpStr.sprintf("%c%.2d%.2d", |
173 | (neg ? '-' : '+'), | 173 | (neg ? '-' : '+'), |
174 | hours, minutes); | 174 | hours, minutes); |
175 | return tmpStr; | 175 | return tmpStr; |
176 | } | 176 | } |
177 | 177 | ||
178 | void Calendar::setTimeZone(int tz) | 178 | void Calendar::setTimeZone(int tz) |
179 | { | 179 | { |
180 | mTimeZone = tz; | 180 | mTimeZone = tz; |
181 | mLocalTime = false; | 181 | mLocalTime = false; |
182 | 182 | ||
183 | setModified( true ); | 183 | setModified( true ); |
184 | } | 184 | } |
185 | 185 | ||
186 | int Calendar::getTimeZone() const | 186 | int Calendar::getTimeZone() const |
187 | { | 187 | { |
188 | return mTimeZone; | 188 | return mTimeZone; |
189 | } | 189 | } |
190 | 190 | ||
191 | void Calendar::setTimeZoneId(const QString &id) | 191 | void Calendar::setTimeZoneId(const QString &id) |
192 | { | 192 | { |
193 | mTimeZoneId = id; | 193 | mTimeZoneId = id; |
194 | mLocalTime = false; | 194 | mLocalTime = false; |
195 | mTimeZone = KGlobal::locale()->timezoneOffset(mTimeZoneId); | 195 | mTimeZone = KGlobal::locale()->timezoneOffset(mTimeZoneId); |
196 | if ( mTimeZone > 1000) | 196 | if ( mTimeZone > 1000) |
197 | setLocalTime(); | 197 | setLocalTime(); |
198 | //qDebug("Calendar::setTimeZoneOffset %s %d ",mTimeZoneId.latin1(), mTimeZone); | 198 | //qDebug("Calendar::setTimeZoneOffset %s %d ",mTimeZoneId.latin1(), mTimeZone); |
199 | setModified( true ); | 199 | setModified( true ); |
200 | } | 200 | } |
201 | 201 | ||
202 | QString Calendar::timeZoneId() const | 202 | QString Calendar::timeZoneId() const |
203 | { | 203 | { |
204 | return mTimeZoneId; | 204 | return mTimeZoneId; |
205 | } | 205 | } |
206 | 206 | ||
207 | void Calendar::setLocalTime() | 207 | void Calendar::setLocalTime() |
208 | { | 208 | { |
209 | //qDebug("Calendar::setLocalTime() "); | 209 | //qDebug("Calendar::setLocalTime() "); |
210 | mLocalTime = true; | 210 | mLocalTime = true; |
211 | mTimeZone = 0; | 211 | mTimeZone = 0; |
212 | mTimeZoneId = ""; | 212 | mTimeZoneId = ""; |
213 | 213 | ||
214 | setModified( true ); | 214 | setModified( true ); |
215 | } | 215 | } |
216 | 216 | ||
217 | bool Calendar::isLocalTime() const | 217 | bool Calendar::isLocalTime() const |
218 | { | 218 | { |
219 | return mLocalTime; | 219 | return mLocalTime; |
220 | } | 220 | } |
221 | 221 | ||
222 | const QString &Calendar::getEmail() | 222 | const QString &Calendar::getEmail() |
223 | { | 223 | { |
224 | return mOwnerEmail; | 224 | return mOwnerEmail; |
225 | } | 225 | } |
226 | 226 | ||
227 | void Calendar::setEmail(const QString &e) | 227 | void Calendar::setEmail(const QString &e) |
228 | { | 228 | { |
229 | mOwnerEmail = e; | 229 | mOwnerEmail = e; |
230 | 230 | ||
231 | setModified( true ); | 231 | setModified( true ); |
232 | } | 232 | } |
233 | 233 | ||
234 | void Calendar::setFilter(CalFilter *filter) | 234 | void Calendar::setFilter(CalFilter *filter) |
235 | { | 235 | { |
236 | mFilter = filter; | 236 | mFilter = filter; |
237 | } | 237 | } |
238 | 238 | ||
239 | CalFilter *Calendar::filter() | 239 | CalFilter *Calendar::filter() |
240 | { | 240 | { |
241 | return mFilter; | 241 | return mFilter; |
242 | } | 242 | } |
243 | 243 | ||
244 | QPtrList<Incidence> Calendar::incidences() | 244 | QPtrList<Incidence> Calendar::incidences() |
245 | { | 245 | { |
246 | QPtrList<Incidence> incidences; | 246 | QPtrList<Incidence> incidences; |
247 | 247 | ||
248 | Incidence *i; | 248 | Incidence *i; |
249 | 249 | ||
250 | QPtrList<Event> e = events(); | 250 | QPtrList<Event> e = events(); |
251 | for( i = e.first(); i; i = e.next() ) incidences.append( i ); | 251 | for( i = e.first(); i; i = e.next() ) incidences.append( i ); |
252 | 252 | ||
253 | QPtrList<Todo> t = todos(); | 253 | QPtrList<Todo> t = todos(); |
254 | for( i = t.first(); i; i = t.next() ) incidences.append( i ); | 254 | for( i = t.first(); i; i = t.next() ) incidences.append( i ); |
255 | 255 | ||
256 | QPtrList<Journal> j = journals(); | 256 | QPtrList<Journal> j = journals(); |
257 | for( i = j.first(); i; i = j.next() ) incidences.append( i ); | 257 | for( i = j.first(); i; i = j.next() ) incidences.append( i ); |
258 | 258 | ||
259 | return incidences; | 259 | return incidences; |
260 | } | 260 | } |
261 | 261 | ||
262 | void Calendar::resetPilotStat(int id ) | 262 | void Calendar::resetPilotStat(int id ) |
263 | { | 263 | { |
264 | QPtrList<Incidence> incidences; | 264 | QPtrList<Incidence> incidences; |
265 | 265 | ||
266 | Incidence *i; | 266 | Incidence *i; |
267 | 267 | ||
268 | QPtrList<Event> e = rawEvents(); | 268 | QPtrList<Event> e = rawEvents(); |
269 | for( i = e.first(); i; i = e.next() ) i->setPilotId( id ); | 269 | for( i = e.first(); i; i = e.next() ) i->setPilotId( id ); |
270 | 270 | ||
271 | QPtrList<Todo> t = rawTodos(); | 271 | QPtrList<Todo> t = rawTodos(); |
272 | for( i = t.first(); i; i = t.next() ) i->setPilotId( id ); | 272 | for( i = t.first(); i; i = t.next() ) i->setPilotId( id ); |
273 | 273 | ||
274 | QPtrList<Journal> j = journals(); | 274 | QPtrList<Journal> j = journals(); |
275 | for( i = j.first(); i; i = j.next() ) i->setPilotId( id ); | 275 | for( i = j.first(); i; i = j.next() ) i->setPilotId( id ); |
276 | } | 276 | } |
277 | void Calendar::resetTempSyncStat() | 277 | void Calendar::resetTempSyncStat() |
278 | { | 278 | { |
279 | QPtrList<Incidence> incidences; | 279 | QPtrList<Incidence> incidences; |
280 | 280 | ||
281 | Incidence *i; | 281 | Incidence *i; |
282 | 282 | ||
283 | QPtrList<Event> e = rawEvents(); | 283 | QPtrList<Event> e = rawEvents(); |
284 | for( i = e.first(); i; i = e.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 284 | for( i = e.first(); i; i = e.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
285 | 285 | ||
286 | QPtrList<Todo> t = rawTodos(); | 286 | QPtrList<Todo> t = rawTodos(); |
287 | for( i = t.first(); i; i = t.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 287 | for( i = t.first(); i; i = t.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
288 | 288 | ||
289 | QPtrList<Journal> j = journals(); | 289 | QPtrList<Journal> j = journals(); |
290 | for( i = j.first(); i; i = j.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 290 | for( i = j.first(); i; i = j.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
291 | } | 291 | } |
292 | QPtrList<Incidence> Calendar::rawIncidences() | 292 | QPtrList<Incidence> Calendar::rawIncidences() |
293 | { | 293 | { |
294 | QPtrList<Incidence> incidences; | 294 | QPtrList<Incidence> incidences; |
295 | 295 | ||
296 | Incidence *i; | 296 | Incidence *i; |
297 | 297 | ||
298 | QPtrList<Event> e = rawEvents(); | 298 | QPtrList<Event> e = rawEvents(); |
299 | for( i = e.first(); i; i = e.next() ) incidences.append( i ); | 299 | for( i = e.first(); i; i = e.next() ) incidences.append( i ); |
300 | 300 | ||
301 | QPtrList<Todo> t = rawTodos(); | 301 | QPtrList<Todo> t = rawTodos(); |
302 | for( i = t.first(); i; i = t.next() ) incidences.append( i ); | 302 | for( i = t.first(); i; i = t.next() ) incidences.append( i ); |
303 | 303 | ||
304 | QPtrList<Journal> j = journals(); | 304 | QPtrList<Journal> j = journals(); |
305 | for( i = j.first(); i; i = j.next() ) incidences.append( i ); | 305 | for( i = j.first(); i; i = j.next() ) incidences.append( i ); |
306 | 306 | ||
307 | return incidences; | 307 | return incidences; |
308 | } | 308 | } |
309 | 309 | ||
310 | QPtrList<Event> Calendar::events( const QDate &date, bool sorted ) | 310 | QPtrList<Event> Calendar::events( const QDate &date, bool sorted ) |
311 | { | 311 | { |
312 | QPtrList<Event> el = rawEventsForDate(date,sorted); | 312 | QPtrList<Event> el = rawEventsForDate(date,sorted); |
313 | mFilter->apply(&el); | 313 | mFilter->apply(&el); |
314 | return el; | 314 | return el; |
315 | } | 315 | } |
316 | 316 | ||
317 | QPtrList<Event> Calendar::events( const QDateTime &qdt ) | 317 | QPtrList<Event> Calendar::events( const QDateTime &qdt ) |
318 | { | 318 | { |
319 | QPtrList<Event> el = rawEventsForDate(qdt); | 319 | QPtrList<Event> el = rawEventsForDate(qdt); |
320 | mFilter->apply(&el); | 320 | mFilter->apply(&el); |
321 | return el; | 321 | return el; |
322 | } | 322 | } |
323 | 323 | ||
324 | QPtrList<Event> Calendar::events( const QDate &start, const QDate &end, | 324 | QPtrList<Event> Calendar::events( const QDate &start, const QDate &end, |
325 | bool inclusive) | 325 | bool inclusive) |
326 | { | 326 | { |
327 | QPtrList<Event> el = rawEvents(start,end,inclusive); | 327 | QPtrList<Event> el = rawEvents(start,end,inclusive); |
328 | mFilter->apply(&el); | 328 | mFilter->apply(&el); |
329 | return el; | 329 | return el; |
330 | } | 330 | } |
331 | 331 | ||
332 | QPtrList<Event> Calendar::events() | 332 | QPtrList<Event> Calendar::events() |
333 | { | 333 | { |
334 | QPtrList<Event> el = rawEvents(); | 334 | QPtrList<Event> el = rawEvents(); |
335 | mFilter->apply(&el); | 335 | mFilter->apply(&el); |
336 | return el; | 336 | return el; |
337 | } | 337 | } |
338 | 338 | void Calendar::addIncidenceBranch(Incidence *i) | |
339 | { | ||
340 | addIncidence( i ); | ||
341 | Incidence * inc; | ||
342 | QPtrList<Incidence> Relations = i->relations(); | ||
343 | for (inc=Relations.first();inc;inc=Relations.next()) { | ||
344 | addIncidenceBranch( inc ); | ||
345 | } | ||
346 | } | ||
339 | 347 | ||
340 | bool Calendar::addIncidence(Incidence *i) | 348 | bool Calendar::addIncidence(Incidence *i) |
341 | { | 349 | { |
342 | Incidence::AddVisitor<Calendar> v(this); | 350 | Incidence::AddVisitor<Calendar> v(this); |
343 | 351 | ||
344 | return i->accept(v); | 352 | return i->accept(v); |
345 | } | 353 | } |
346 | void Calendar::deleteIncidence(Incidence *in) | 354 | void Calendar::deleteIncidence(Incidence *in) |
347 | { | 355 | { |
348 | if ( in->type() == "Event" ) | 356 | if ( in->type() == "Event" ) |
349 | deleteEvent( (Event*) in ); | 357 | deleteEvent( (Event*) in ); |
350 | else if ( in->type() =="Todo" ) | 358 | else if ( in->type() =="Todo" ) |
351 | deleteTodo( (Todo*) in); | 359 | deleteTodo( (Todo*) in); |
352 | else if ( in->type() =="Journal" ) | 360 | else if ( in->type() =="Journal" ) |
353 | deleteJournal( (Journal*) in ); | 361 | deleteJournal( (Journal*) in ); |
354 | } | 362 | } |
355 | 363 | ||
356 | Incidence* Calendar::incidence( const QString& uid ) | 364 | Incidence* Calendar::incidence( const QString& uid ) |
357 | { | 365 | { |
358 | Incidence* i; | 366 | Incidence* i; |
359 | 367 | ||
360 | if( (i = todo( uid )) != 0 ) | 368 | if( (i = todo( uid )) != 0 ) |
361 | return i; | 369 | return i; |
362 | if( (i = event( uid )) != 0 ) | 370 | if( (i = event( uid )) != 0 ) |
363 | return i; | 371 | return i; |
364 | if( (i = journal( uid )) != 0 ) | 372 | if( (i = journal( uid )) != 0 ) |
365 | return i; | 373 | return i; |
366 | 374 | ||
367 | return 0; | 375 | return 0; |
368 | } | 376 | } |
369 | 377 | ||
370 | QPtrList<Todo> Calendar::todos() | 378 | QPtrList<Todo> Calendar::todos() |
371 | { | 379 | { |
372 | QPtrList<Todo> tl = rawTodos(); | 380 | QPtrList<Todo> tl = rawTodos(); |
373 | mFilter->apply( &tl ); | 381 | mFilter->apply( &tl ); |
374 | return tl; | 382 | return tl; |
375 | } | 383 | } |
376 | 384 | ||
377 | // When this is called, the todo have already been added to the calendar. | 385 | // When this is called, the todo have already been added to the calendar. |
378 | // This method is only about linking related todos | 386 | // This method is only about linking related todos |
379 | void Calendar::setupRelations( Incidence *incidence ) | 387 | void Calendar::setupRelations( Incidence *incidence ) |
380 | { | 388 | { |
381 | QString uid = incidence->uid(); | 389 | QString uid = incidence->uid(); |
382 | //qDebug("Calendar::setupRelations "); | 390 | //qDebug("Calendar::setupRelations "); |
383 | // First, go over the list of orphans and see if this is their parent | 391 | // First, go over the list of orphans and see if this is their parent |
384 | while( Incidence* i = mOrphans[ uid ] ) { | 392 | while( Incidence* i = mOrphans[ uid ] ) { |
385 | mOrphans.remove( uid ); | 393 | mOrphans.remove( uid ); |
386 | i->setRelatedTo( incidence ); | 394 | i->setRelatedTo( incidence ); |
387 | incidence->addRelation( i ); | 395 | incidence->addRelation( i ); |
388 | mOrphanUids.remove( i->uid() ); | 396 | mOrphanUids.remove( i->uid() ); |
389 | } | 397 | } |
390 | 398 | ||
391 | // Now see about this incidences parent | 399 | // Now see about this incidences parent |
392 | if( !incidence->relatedTo() && !incidence->relatedToUid().isEmpty() ) { | 400 | if( !incidence->relatedTo() && !incidence->relatedToUid().isEmpty() ) { |
393 | // This incidence has a uid it is related to, but is not registered to it yet | 401 | // This incidence has a uid it is related to, but is not registered to it yet |
394 | // Try to find it | 402 | // Try to find it |
395 | Incidence* parent = this->incidence( incidence->relatedToUid() ); | 403 | Incidence* parent = this->incidence( incidence->relatedToUid() ); |
396 | if( parent ) { | 404 | if( parent ) { |
397 | // Found it | 405 | // Found it |
398 | incidence->setRelatedTo( parent ); | 406 | incidence->setRelatedTo( parent ); |
399 | parent->addRelation( incidence ); | 407 | parent->addRelation( incidence ); |
400 | } else { | 408 | } else { |
401 | // Not found, put this in the mOrphans list | 409 | // Not found, put this in the mOrphans list |
402 | mOrphans.insert( incidence->relatedToUid(), incidence ); | 410 | mOrphans.insert( incidence->relatedToUid(), incidence ); |
403 | mOrphanUids.insert( incidence->uid(), incidence ); | 411 | mOrphanUids.insert( incidence->uid(), incidence ); |
404 | } | 412 | } |
405 | } | 413 | } |
406 | } | 414 | } |
407 | 415 | ||
408 | // If a task with subtasks is deleted, move it's subtasks to the orphans list | 416 | // If a task with subtasks is deleted, move it's subtasks to the orphans list |
409 | void Calendar::removeRelations( Incidence *incidence ) | 417 | void Calendar::removeRelations( Incidence *incidence ) |
410 | { | 418 | { |
411 | // qDebug("Calendar::removeRelations "); | 419 | // qDebug("Calendar::removeRelations "); |
412 | QString uid = incidence->uid(); | 420 | QString uid = incidence->uid(); |
413 | 421 | ||
414 | QPtrList<Incidence> relations = incidence->relations(); | 422 | QPtrList<Incidence> relations = incidence->relations(); |
415 | for( Incidence* i = relations.first(); i; i = relations.next() ) | 423 | for( Incidence* i = relations.first(); i; i = relations.next() ) |
416 | if( !mOrphanUids.find( i->uid() ) ) { | 424 | if( !mOrphanUids.find( i->uid() ) ) { |
417 | mOrphans.insert( uid, i ); | 425 | mOrphans.insert( uid, i ); |
418 | mOrphanUids.insert( i->uid(), i ); | 426 | mOrphanUids.insert( i->uid(), i ); |
419 | i->setRelatedTo( 0 ); | 427 | i->setRelatedTo( 0 ); |
420 | i->setRelatedToUid( uid ); | 428 | i->setRelatedToUid( uid ); |
421 | } | 429 | } |
422 | 430 | ||
423 | // If this incidence is related to something else, tell that about it | 431 | // If this incidence is related to something else, tell that about it |
424 | if( incidence->relatedTo() ) | 432 | if( incidence->relatedTo() ) |
425 | incidence->relatedTo()->removeRelation( incidence ); | 433 | incidence->relatedTo()->removeRelation( incidence ); |
426 | 434 | ||
427 | // Remove this one from the orphans list | 435 | // Remove this one from the orphans list |
428 | if( mOrphanUids.remove( uid ) ) | 436 | if( mOrphanUids.remove( uid ) ) |
429 | // This incidence is located in the orphans list - it should be removed | 437 | // This incidence is located in the orphans list - it should be removed |
430 | if( !( incidence->relatedTo() != 0 && mOrphans.remove( incidence->relatedTo()->uid() ) ) ) { | 438 | if( !( incidence->relatedTo() != 0 && mOrphans.remove( incidence->relatedTo()->uid() ) ) ) { |
431 | // Removing wasn't that easy | 439 | // Removing wasn't that easy |
432 | for( QDictIterator<Incidence> it( mOrphans ); it.current(); ++it ) { | 440 | for( QDictIterator<Incidence> it( mOrphans ); it.current(); ++it ) { |
433 | if( it.current()->uid() == uid ) { | 441 | if( it.current()->uid() == uid ) { |
434 | mOrphans.remove( it.currentKey() ); | 442 | mOrphans.remove( it.currentKey() ); |
435 | break; | 443 | break; |
436 | } | 444 | } |
437 | } | 445 | } |
438 | } | 446 | } |
439 | } | 447 | } |
440 | 448 | ||
441 | void Calendar::registerObserver( Observer *observer ) | 449 | void Calendar::registerObserver( Observer *observer ) |
442 | { | 450 | { |
443 | mObserver = observer; | 451 | mObserver = observer; |
444 | mNewObserver = true; | 452 | mNewObserver = true; |
445 | } | 453 | } |
446 | 454 | ||
447 | void Calendar::setModified( bool modified ) | 455 | void Calendar::setModified( bool modified ) |
448 | { | 456 | { |
449 | if ( mObserver ) mObserver->calendarModified( modified, this ); | 457 | if ( mObserver ) mObserver->calendarModified( modified, this ); |
450 | if ( modified != mModified || mNewObserver ) { | 458 | if ( modified != mModified || mNewObserver ) { |
451 | mNewObserver = false; | 459 | mNewObserver = false; |
452 | // if ( mObserver ) mObserver->calendarModified( modified, this ); | 460 | // if ( mObserver ) mObserver->calendarModified( modified, this ); |
453 | mModified = modified; | 461 | mModified = modified; |
454 | } | 462 | } |
455 | } | 463 | } |
456 | 464 | ||
457 | void Calendar::setLoadedProductId( const QString &id ) | 465 | void Calendar::setLoadedProductId( const QString &id ) |
458 | { | 466 | { |
459 | mLoadedProductId = id; | 467 | mLoadedProductId = id; |
460 | } | 468 | } |
461 | 469 | ||
462 | QString Calendar::loadedProductId() | 470 | QString Calendar::loadedProductId() |
463 | { | 471 | { |
464 | return mLoadedProductId; | 472 | return mLoadedProductId; |
465 | } | 473 | } |
466 | 474 | ||
467 | //#include "calendar.moc" | 475 | //#include "calendar.moc" |
diff --git a/libkcal/calendar.h b/libkcal/calendar.h index 2f2c3aa..ab40970 100644 --- a/libkcal/calendar.h +++ b/libkcal/calendar.h | |||
@@ -1,356 +1,359 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 1998 Preston Brown | 3 | Copyright (c) 1998 Preston Brown |
4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #ifndef CALENDAR_H | 22 | #ifndef CALENDAR_H |
23 | #define CALENDAR_H | 23 | #define CALENDAR_H |
24 | 24 | ||
25 | #include <qobject.h> | 25 | #include <qobject.h> |
26 | #include <qstring.h> | 26 | #include <qstring.h> |
27 | #include <qdatetime.h> | 27 | #include <qdatetime.h> |
28 | #include <qptrlist.h> | 28 | #include <qptrlist.h> |
29 | #include <qdict.h> | 29 | #include <qdict.h> |
30 | 30 | ||
31 | #include "customproperties.h" | 31 | #include "customproperties.h" |
32 | #include "event.h" | 32 | #include "event.h" |
33 | #include "todo.h" | 33 | #include "todo.h" |
34 | #include "journal.h" | 34 | #include "journal.h" |
35 | #include "calfilter.h" | 35 | #include "calfilter.h" |
36 | 36 | ||
37 | //#define _TIME_ZONE "-0500" /* hardcoded, overridden in config file. */ | 37 | //#define _TIME_ZONE "-0500" /* hardcoded, overridden in config file. */ |
38 | 38 | ||
39 | class KConfig; | 39 | class KConfig; |
40 | 40 | ||
41 | namespace KCal { | 41 | namespace KCal { |
42 | 42 | ||
43 | 43 | ||
44 | /** | 44 | /** |
45 | This is the main "calendar" object class for KOrganizer. It holds | 45 | This is the main "calendar" object class for KOrganizer. It holds |
46 | information like all appointments/events, user information, etc. etc. | 46 | information like all appointments/events, user information, etc. etc. |
47 | one calendar is associated with each CalendarView (@see calendarview.h). | 47 | one calendar is associated with each CalendarView (@see calendarview.h). |
48 | This is an abstract base class defining the interface to a calendar. It is | 48 | This is an abstract base class defining the interface to a calendar. It is |
49 | implemented by subclasses like @see CalendarLocal, which use different | 49 | implemented by subclasses like @see CalendarLocal, which use different |
50 | methods to store and access the data. | 50 | methods to store and access the data. |
51 | 51 | ||
52 | Ownership of events etc. is handled by the following policy: As soon as an | 52 | Ownership of events etc. is handled by the following policy: As soon as an |
53 | event (or any other subclass of IncidenceBase) object is added to the | 53 | event (or any other subclass of IncidenceBase) object is added to the |
54 | Calendar by addEvent() it is owned by the Calendar object. The Calendar takes | 54 | Calendar by addEvent() it is owned by the Calendar object. The Calendar takes |
55 | care of deleting it. All Events returned by the query functions are returned | 55 | care of deleting it. All Events returned by the query functions are returned |
56 | as pointers, that means all changes to the returned events are immediately | 56 | as pointers, that means all changes to the returned events are immediately |
57 | visible in the Calendar. You shouldn't delete any Event object you get from | 57 | visible in the Calendar. You shouldn't delete any Event object you get from |
58 | Calendar. | 58 | Calendar. |
59 | */ | 59 | */ |
60 | class Calendar : public QObject, public CustomProperties, | 60 | class Calendar : public QObject, public CustomProperties, |
61 | public IncidenceBase::Observer | 61 | public IncidenceBase::Observer |
62 | { | 62 | { |
63 | Q_OBJECT | 63 | Q_OBJECT |
64 | public: | 64 | public: |
65 | Calendar(); | 65 | Calendar(); |
66 | Calendar(const QString &timeZoneId); | 66 | Calendar(const QString &timeZoneId); |
67 | virtual ~Calendar(); | 67 | virtual ~Calendar(); |
68 | Incidence * undoIncidence() { return mUndoIncidence; }; | 68 | Incidence * undoIncidence() { return mUndoIncidence; }; |
69 | bool undoDeleteIncidence(); | 69 | bool undoDeleteIncidence(); |
70 | void deleteIncidence(Incidence *in); | 70 | void deleteIncidence(Incidence *in); |
71 | void resetTempSyncStat(); | 71 | void resetTempSyncStat(); |
72 | void resetPilotStat(int id); | 72 | void resetPilotStat(int id); |
73 | /** | 73 | /** |
74 | Clears out the current calendar, freeing all used memory etc. | 74 | Clears out the current calendar, freeing all used memory etc. |
75 | */ | 75 | */ |
76 | virtual void close() = 0; | 76 | virtual void close() = 0; |
77 | 77 | ||
78 | /** | 78 | /** |
79 | Sync changes in memory to persistant storage. | 79 | Sync changes in memory to persistant storage. |
80 | */ | 80 | */ |
81 | virtual void save() = 0; | 81 | virtual void save() = 0; |
82 | virtual QPtrList<Event> getExternLastSyncEvents() = 0; | 82 | virtual QPtrList<Event> getExternLastSyncEvents() = 0; |
83 | virtual void removeSyncInfo( QString syncProfile) = 0; | 83 | virtual void removeSyncInfo( QString syncProfile) = 0; |
84 | virtual bool isSaving() { return false; } | 84 | virtual bool isSaving() { return false; } |
85 | 85 | ||
86 | /** | 86 | /** |
87 | Return the owner of the calendar's full name. | 87 | Return the owner of the calendar's full name. |
88 | */ | 88 | */ |
89 | const QString &getOwner() const; | 89 | const QString &getOwner() const; |
90 | /** | 90 | /** |
91 | Set the owner of the calendar. Should be owner's full name. | 91 | Set the owner of the calendar. Should be owner's full name. |
92 | */ | 92 | */ |
93 | void setOwner( const QString &os ); | 93 | void setOwner( const QString &os ); |
94 | /** | 94 | /** |
95 | Return the email address of the calendar owner. | 95 | Return the email address of the calendar owner. |
96 | */ | 96 | */ |
97 | const QString &getEmail(); | 97 | const QString &getEmail(); |
98 | /** | 98 | /** |
99 | Set the email address of the calendar owner. | 99 | Set the email address of the calendar owner. |
100 | */ | 100 | */ |
101 | void setEmail( const QString & ); | 101 | void setEmail( const QString & ); |
102 | 102 | ||
103 | /** | 103 | /** |
104 | Set time zone from a timezone string (e.g. -2:00) | 104 | Set time zone from a timezone string (e.g. -2:00) |
105 | */ | 105 | */ |
106 | void setTimeZone( const QString &tz ); | 106 | void setTimeZone( const QString &tz ); |
107 | /** | 107 | /** |
108 | Set time zone from a minutes value (e.g. -60) | 108 | Set time zone from a minutes value (e.g. -60) |
109 | */ | 109 | */ |
110 | void setTimeZone( int tz ); | 110 | void setTimeZone( int tz ); |
111 | /** | 111 | /** |
112 | Return time zone as offest in minutes. | 112 | Return time zone as offest in minutes. |
113 | */ | 113 | */ |
114 | int getTimeZone() const; | 114 | int getTimeZone() const; |
115 | /** | 115 | /** |
116 | Compute an ISO 8601 format string from the time zone. | 116 | Compute an ISO 8601 format string from the time zone. |
117 | */ | 117 | */ |
118 | QString getTimeZoneStr() const; | 118 | QString getTimeZoneStr() const; |
119 | /** | 119 | /** |
120 | Set time zone id (see /usr/share/zoneinfo/zone.tab for list of legal | 120 | Set time zone id (see /usr/share/zoneinfo/zone.tab for list of legal |
121 | values). | 121 | values). |
122 | */ | 122 | */ |
123 | void setTimeZoneId( const QString & ); | 123 | void setTimeZoneId( const QString & ); |
124 | /** | 124 | /** |
125 | Return time zone id. | 125 | Return time zone id. |
126 | */ | 126 | */ |
127 | QString timeZoneId() const; | 127 | QString timeZoneId() const; |
128 | /** | 128 | /** |
129 | Use local time, not UTC or a time zone. | 129 | Use local time, not UTC or a time zone. |
130 | */ | 130 | */ |
131 | void setLocalTime(); | 131 | void setLocalTime(); |
132 | /** | 132 | /** |
133 | Return whether local time is being used. | 133 | Return whether local time is being used. |
134 | */ | 134 | */ |
135 | bool isLocalTime() const; | 135 | bool isLocalTime() const; |
136 | 136 | ||
137 | /** | 137 | /** |
138 | Add an incidence to calendar. | 138 | Add an incidence to calendar. |
139 | 139 | ||
140 | @return true on success, false on error. | 140 | @return true on success, false on error. |
141 | */ | 141 | */ |
142 | virtual bool addIncidence( Incidence * ); | 142 | virtual bool addIncidence( Incidence * ); |
143 | |||
144 | // Adds an incidence and all relatedto incidences to the cal | ||
145 | void addIncidenceBranch( Incidence * ); | ||
143 | /** | 146 | /** |
144 | Return filtered list of all incidences of this calendar. | 147 | Return filtered list of all incidences of this calendar. |
145 | */ | 148 | */ |
146 | virtual QPtrList<Incidence> incidences(); | 149 | virtual QPtrList<Incidence> incidences(); |
147 | 150 | ||
148 | /** | 151 | /** |
149 | Return unfiltered list of all incidences of this calendar. | 152 | Return unfiltered list of all incidences of this calendar. |
150 | */ | 153 | */ |
151 | virtual QPtrList<Incidence> rawIncidences(); | 154 | virtual QPtrList<Incidence> rawIncidences(); |
152 | 155 | ||
153 | /** | 156 | /** |
154 | Adds a Event to this calendar object. | 157 | Adds a Event to this calendar object. |
155 | @param anEvent a pointer to the event to add | 158 | @param anEvent a pointer to the event to add |
156 | 159 | ||
157 | @return true on success, false on error. | 160 | @return true on success, false on error. |
158 | */ | 161 | */ |
159 | virtual bool addEventNoDup( Event *event ) = 0; | 162 | virtual bool addEventNoDup( Event *event ) = 0; |
160 | virtual bool addAnniversaryNoDup( Event *event ) = 0; | 163 | virtual bool addAnniversaryNoDup( Event *event ) = 0; |
161 | virtual bool addEvent( Event *anEvent ) = 0; | 164 | virtual bool addEvent( Event *anEvent ) = 0; |
162 | /** | 165 | /** |
163 | Delete event from calendar. | 166 | Delete event from calendar. |
164 | */ | 167 | */ |
165 | virtual void deleteEvent( Event * ) = 0; | 168 | virtual void deleteEvent( Event * ) = 0; |
166 | /** | 169 | /** |
167 | Retrieves an event on the basis of the unique string ID. | 170 | Retrieves an event on the basis of the unique string ID. |
168 | */ | 171 | */ |
169 | virtual Event *event( const QString &UniqueStr ) = 0; | 172 | virtual Event *event( const QString &UniqueStr ) = 0; |
170 | virtual Event *event( QString, QString ) = 0; | 173 | virtual Event *event( QString, QString ) = 0; |
171 | /** | 174 | /** |
172 | Builds and then returns a list of all events that match for the | 175 | Builds and then returns a list of all events that match for the |
173 | date specified. useful for dayView, etc. etc. | 176 | date specified. useful for dayView, etc. etc. |
174 | The calendar filter is applied. | 177 | The calendar filter is applied. |
175 | */ | 178 | */ |
176 | QPtrList<Event> events( const QDate &date, bool sorted = false); | 179 | QPtrList<Event> events( const QDate &date, bool sorted = false); |
177 | /** | 180 | /** |
178 | Get events, which occur on the given date. | 181 | Get events, which occur on the given date. |
179 | The calendar filter is applied. | 182 | The calendar filter is applied. |
180 | */ | 183 | */ |
181 | QPtrList<Event> events( const QDateTime &qdt ); | 184 | QPtrList<Event> events( const QDateTime &qdt ); |
182 | /** | 185 | /** |
183 | Get events in a range of dates. If inclusive is set to true, only events | 186 | Get events in a range of dates. If inclusive is set to true, only events |
184 | are returned, which are completely included in the range. | 187 | are returned, which are completely included in the range. |
185 | The calendar filter is applied. | 188 | The calendar filter is applied. |
186 | */ | 189 | */ |
187 | QPtrList<Event> events( const QDate &start, const QDate &end, | 190 | QPtrList<Event> events( const QDate &start, const QDate &end, |
188 | bool inclusive = false); | 191 | bool inclusive = false); |
189 | /** | 192 | /** |
190 | Return filtered list of all events in calendar. | 193 | Return filtered list of all events in calendar. |
191 | */ | 194 | */ |
192 | virtual QPtrList<Event> events(); | 195 | virtual QPtrList<Event> events(); |
193 | /** | 196 | /** |
194 | Return unfiltered list of all events in calendar. | 197 | Return unfiltered list of all events in calendar. |
195 | */ | 198 | */ |
196 | virtual QPtrList<Event> rawEvents() = 0; | 199 | virtual QPtrList<Event> rawEvents() = 0; |
197 | 200 | ||
198 | /** | 201 | /** |
199 | Add a todo to the todolist. | 202 | Add a todo to the todolist. |
200 | 203 | ||
201 | @return true on success, false on error. | 204 | @return true on success, false on error. |
202 | */ | 205 | */ |
203 | virtual bool addTodo( Todo *todo ) = 0; | 206 | virtual bool addTodo( Todo *todo ) = 0; |
204 | virtual bool addTodoNoDup( Todo *todo ) = 0; | 207 | virtual bool addTodoNoDup( Todo *todo ) = 0; |
205 | /** | 208 | /** |
206 | Remove a todo from the todolist. | 209 | Remove a todo from the todolist. |
207 | */ | 210 | */ |
208 | virtual void deleteTodo( Todo * ) = 0; | 211 | virtual void deleteTodo( Todo * ) = 0; |
209 | virtual void deleteJournal( Journal * ) = 0; | 212 | virtual void deleteJournal( Journal * ) = 0; |
210 | /** | 213 | /** |
211 | Return filterd list of todos. | 214 | Return filterd list of todos. |
212 | */ | 215 | */ |
213 | virtual QPtrList<Todo> todos(); | 216 | virtual QPtrList<Todo> todos(); |
214 | /** | 217 | /** |
215 | Searches todolist for an event with this unique string identifier, | 218 | Searches todolist for an event with this unique string identifier, |
216 | returns a pointer or null. | 219 | returns a pointer or null. |
217 | */ | 220 | */ |
218 | virtual Todo *todo( const QString &uid ) = 0; | 221 | virtual Todo *todo( const QString &uid ) = 0; |
219 | virtual Todo *todo( QString, QString ) = 0; | 222 | virtual Todo *todo( QString, QString ) = 0; |
220 | /** | 223 | /** |
221 | Returns list of todos due on the specified date. | 224 | Returns list of todos due on the specified date. |
222 | */ | 225 | */ |
223 | virtual QPtrList<Todo> todos( const QDate &date ) = 0; | 226 | virtual QPtrList<Todo> todos( const QDate &date ) = 0; |
224 | /** | 227 | /** |
225 | Return unfiltered list of todos. | 228 | Return unfiltered list of todos. |
226 | */ | 229 | */ |
227 | virtual QPtrList<Todo> rawTodos() = 0; | 230 | virtual QPtrList<Todo> rawTodos() = 0; |
228 | 231 | ||
229 | /** | 232 | /** |
230 | Add a Journal entry to calendar. | 233 | Add a Journal entry to calendar. |
231 | 234 | ||
232 | @return true on success, false on error. | 235 | @return true on success, false on error. |
233 | */ | 236 | */ |
234 | virtual bool addJournal( Journal * ) = 0; | 237 | virtual bool addJournal( Journal * ) = 0; |
235 | /** | 238 | /** |
236 | Return Journal for given date. | 239 | Return Journal for given date. |
237 | */ | 240 | */ |
238 | virtual Journal *journal( const QDate & ) = 0; | 241 | virtual Journal *journal( const QDate & ) = 0; |
239 | /** | 242 | /** |
240 | Return Journal with given UID. | 243 | Return Journal with given UID. |
241 | */ | 244 | */ |
242 | virtual Journal *journal( const QString &UID ) = 0; | 245 | virtual Journal *journal( const QString &UID ) = 0; |
243 | /** | 246 | /** |
244 | Return list of all Journal entries. | 247 | Return list of all Journal entries. |
245 | */ | 248 | */ |
246 | virtual QPtrList<Journal> journals() = 0; | 249 | virtual QPtrList<Journal> journals() = 0; |
247 | 250 | ||
248 | /** | 251 | /** |
249 | Searches all incidence types for an incidence with this unique | 252 | Searches all incidence types for an incidence with this unique |
250 | string identifier, returns a pointer or null. | 253 | string identifier, returns a pointer or null. |
251 | */ | 254 | */ |
252 | Incidence* incidence( const QString&UID ); | 255 | Incidence* incidence( const QString&UID ); |
253 | 256 | ||
254 | /** | 257 | /** |
255 | Setup relations for an incidence. | 258 | Setup relations for an incidence. |
256 | */ | 259 | */ |
257 | virtual void setupRelations( Incidence * ); | 260 | virtual void setupRelations( Incidence * ); |
258 | /** | 261 | /** |
259 | Remove all relations to an incidence | 262 | Remove all relations to an incidence |
260 | */ | 263 | */ |
261 | virtual void removeRelations( Incidence * ); | 264 | virtual void removeRelations( Incidence * ); |
262 | 265 | ||
263 | /** | 266 | /** |
264 | Set calendar filter, which filters events for the events() functions. | 267 | Set calendar filter, which filters events for the events() functions. |
265 | The Filter object is owned by the caller. | 268 | The Filter object is owned by the caller. |
266 | */ | 269 | */ |
267 | void setFilter( CalFilter * ); | 270 | void setFilter( CalFilter * ); |
268 | /** | 271 | /** |
269 | Return calendar filter. | 272 | Return calendar filter. |
270 | */ | 273 | */ |
271 | CalFilter *filter(); | 274 | CalFilter *filter(); |
272 | virtual QDateTime nextAlarm( int daysTo ) = 0; | 275 | virtual QDateTime nextAlarm( int daysTo ) = 0; |
273 | virtual QString nextSummary( ) const = 0; | 276 | virtual QString nextSummary( ) const = 0; |
274 | virtual void reInitAlarmSettings() = 0; | 277 | virtual void reInitAlarmSettings() = 0; |
275 | virtual QDateTime nextAlarmEventDateTime() const = 0; | 278 | virtual QDateTime nextAlarmEventDateTime() const = 0; |
276 | virtual void checkAlarmForIncidence( Incidence *, bool ) = 0; | 279 | virtual void checkAlarmForIncidence( Incidence *, bool ) = 0; |
277 | /** | 280 | /** |
278 | Return all alarms, which ocur in the given time interval. | 281 | Return all alarms, which ocur in the given time interval. |
279 | */ | 282 | */ |
280 | virtual Alarm::List alarms( const QDateTime &from, | 283 | virtual Alarm::List alarms( const QDateTime &from, |
281 | const QDateTime &to ) = 0; | 284 | const QDateTime &to ) = 0; |
282 | 285 | ||
283 | class Observer { | 286 | class Observer { |
284 | public: | 287 | public: |
285 | virtual void calendarModified( bool, Calendar * ) = 0; | 288 | virtual void calendarModified( bool, Calendar * ) = 0; |
286 | }; | 289 | }; |
287 | 290 | ||
288 | void registerObserver( Observer * ); | 291 | void registerObserver( Observer * ); |
289 | 292 | ||
290 | void setModified( bool ); | 293 | void setModified( bool ); |
291 | 294 | ||
292 | /** | 295 | /** |
293 | Set product id returned by loadedProductId(). This function is only | 296 | Set product id returned by loadedProductId(). This function is only |
294 | useful for the calendar loading code. | 297 | useful for the calendar loading code. |
295 | */ | 298 | */ |
296 | void setLoadedProductId( const QString & ); | 299 | void setLoadedProductId( const QString & ); |
297 | /** | 300 | /** |
298 | Return product id taken from file that has been loaded. Returns | 301 | Return product id taken from file that has been loaded. Returns |
299 | QString::null, if no calendar has been loaded. | 302 | QString::null, if no calendar has been loaded. |
300 | */ | 303 | */ |
301 | QString loadedProductId(); | 304 | QString loadedProductId(); |
302 | 305 | ||
303 | signals: | 306 | signals: |
304 | void calendarChanged(); | 307 | void calendarChanged(); |
305 | void calendarSaved(); | 308 | void calendarSaved(); |
306 | void calendarLoaded(); | 309 | void calendarLoaded(); |
307 | void addAlarm(const QDateTime &qdt, const QString ¬i ); | 310 | void addAlarm(const QDateTime &qdt, const QString ¬i ); |
308 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); | 311 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); |
309 | 312 | ||
310 | protected: | 313 | protected: |
311 | /** | 314 | /** |
312 | Get unfiltered events, which occur on the given date. | 315 | Get unfiltered events, which occur on the given date. |
313 | */ | 316 | */ |
314 | virtual QPtrList<Event> rawEventsForDate( const QDateTime &qdt ) = 0; | 317 | virtual QPtrList<Event> rawEventsForDate( const QDateTime &qdt ) = 0; |
315 | /** | 318 | /** |
316 | Get unfiltered events, which occur on the given date. | 319 | Get unfiltered events, which occur on the given date. |
317 | */ | 320 | */ |
318 | virtual QPtrList<Event> rawEventsForDate( const QDate &date, | 321 | virtual QPtrList<Event> rawEventsForDate( const QDate &date, |
319 | bool sorted = false ) = 0; | 322 | bool sorted = false ) = 0; |
320 | /** | 323 | /** |
321 | Get events in a range of dates. If inclusive is set to true, only events | 324 | Get events in a range of dates. If inclusive is set to true, only events |
322 | are returned, which are completely included in the range. | 325 | are returned, which are completely included in the range. |
323 | */ | 326 | */ |
324 | virtual QPtrList<Event> rawEvents( const QDate &start, const QDate &end, | 327 | virtual QPtrList<Event> rawEvents( const QDate &start, const QDate &end, |
325 | bool inclusive = false ) = 0; | 328 | bool inclusive = false ) = 0; |
326 | Incidence *mNextAlarmIncidence; | 329 | Incidence *mNextAlarmIncidence; |
327 | Incidence *mUndoIncidence; | 330 | Incidence *mUndoIncidence; |
328 | 331 | ||
329 | private: | 332 | private: |
330 | void init(); | 333 | void init(); |
331 | 334 | ||
332 | QString mOwner; // who the calendar belongs to | 335 | QString mOwner; // who the calendar belongs to |
333 | QString mOwnerEmail; // email address of the owner | 336 | QString mOwnerEmail; // email address of the owner |
334 | int mTimeZone; // timezone OFFSET from GMT (MINUTES) | 337 | int mTimeZone; // timezone OFFSET from GMT (MINUTES) |
335 | bool mLocalTime; // use local time, not UTC or a time zone | 338 | bool mLocalTime; // use local time, not UTC or a time zone |
336 | 339 | ||
337 | CalFilter *mFilter; | 340 | CalFilter *mFilter; |
338 | CalFilter *mDefaultFilter; | 341 | CalFilter *mDefaultFilter; |
339 | 342 | ||
340 | QString mTimeZoneId; | 343 | QString mTimeZoneId; |
341 | 344 | ||
342 | Observer *mObserver; | 345 | Observer *mObserver; |
343 | bool mNewObserver; | 346 | bool mNewObserver; |
344 | 347 | ||
345 | bool mModified; | 348 | bool mModified; |
346 | 349 | ||
347 | QString mLoadedProductId; | 350 | QString mLoadedProductId; |
348 | 351 | ||
349 | // This list is used to put together related todos | 352 | // This list is used to put together related todos |
350 | QDict<Incidence> mOrphans; | 353 | QDict<Incidence> mOrphans; |
351 | QDict<Incidence> mOrphanUids; | 354 | QDict<Incidence> mOrphanUids; |
352 | }; | 355 | }; |
353 | 356 | ||
354 | } | 357 | } |
355 | 358 | ||
356 | #endif | 359 | #endif |
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp index 6bca12c..78fa24f 100644 --- a/libkcal/incidence.cpp +++ b/libkcal/incidence.cpp | |||
@@ -1,650 +1,662 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <kglobal.h> | 21 | #include <kglobal.h> |
22 | #include <klocale.h> | 22 | #include <klocale.h> |
23 | #include <kdebug.h> | 23 | #include <kdebug.h> |
24 | 24 | ||
25 | #include "calformat.h" | 25 | #include "calformat.h" |
26 | 26 | ||
27 | #include "incidence.h" | 27 | #include "incidence.h" |
28 | #include "todo.h" | 28 | #include "todo.h" |
29 | 29 | ||
30 | using namespace KCal; | 30 | using namespace KCal; |
31 | 31 | ||
32 | Incidence::Incidence() : | 32 | Incidence::Incidence() : |
33 | IncidenceBase(), | 33 | IncidenceBase(), |
34 | mRelatedTo(0), mSecrecy(SecrecyPublic), mPriority(3) | 34 | mRelatedTo(0), mSecrecy(SecrecyPublic), mPriority(3) |
35 | { | 35 | { |
36 | mRecurrence = new Recurrence(this); | 36 | mRecurrence = new Recurrence(this); |
37 | mCancelled = false; | 37 | mCancelled = false; |
38 | recreate(); | 38 | recreate(); |
39 | mHasStartDate = true; | 39 | mHasStartDate = true; |
40 | mAlarms.setAutoDelete(true); | 40 | mAlarms.setAutoDelete(true); |
41 | mAttachments.setAutoDelete(true); | 41 | mAttachments.setAutoDelete(true); |
42 | mHasRecurrenceID = false; | 42 | mHasRecurrenceID = false; |
43 | mHoliday = false; | 43 | mHoliday = false; |
44 | mBirthday = false; | 44 | mBirthday = false; |
45 | mAnniversary = false; | 45 | mAnniversary = false; |
46 | 46 | ||
47 | } | 47 | } |
48 | 48 | ||
49 | Incidence::Incidence( const Incidence &i ) : IncidenceBase( i ) | 49 | Incidence::Incidence( const Incidence &i ) : IncidenceBase( i ) |
50 | { | 50 | { |
51 | // TODO: reenable attributes currently commented out. | 51 | // TODO: reenable attributes currently commented out. |
52 | mRevision = i.mRevision; | 52 | mRevision = i.mRevision; |
53 | mCreated = i.mCreated; | 53 | mCreated = i.mCreated; |
54 | mDescription = i.mDescription; | 54 | mDescription = i.mDescription; |
55 | mSummary = i.mSummary; | 55 | mSummary = i.mSummary; |
56 | mCategories = i.mCategories; | 56 | mCategories = i.mCategories; |
57 | // Incidence *mRelatedTo; Incidence *mRelatedTo; | 57 | // Incidence *mRelatedTo; Incidence *mRelatedTo; |
58 | mRelatedTo = 0; | 58 | mRelatedTo = 0; |
59 | mRelatedToUid = i.mRelatedToUid; | 59 | mRelatedToUid = i.mRelatedToUid; |
60 | // QPtrList<Incidence> mRelations; QPtrList<Incidence> mRelations; | 60 | // QPtrList<Incidence> mRelations; QPtrList<Incidence> mRelations; |
61 | mExDates = i.mExDates; | 61 | mExDates = i.mExDates; |
62 | mAttachments = i.mAttachments; | 62 | mAttachments = i.mAttachments; |
63 | mResources = i.mResources; | 63 | mResources = i.mResources; |
64 | mSecrecy = i.mSecrecy; | 64 | mSecrecy = i.mSecrecy; |
65 | mPriority = i.mPriority; | 65 | mPriority = i.mPriority; |
66 | mLocation = i.mLocation; | 66 | mLocation = i.mLocation; |
67 | mCancelled = i.mCancelled; | 67 | mCancelled = i.mCancelled; |
68 | mHasStartDate = i.mHasStartDate; | 68 | mHasStartDate = i.mHasStartDate; |
69 | QPtrListIterator<Alarm> it( i.mAlarms ); | 69 | QPtrListIterator<Alarm> it( i.mAlarms ); |
70 | const Alarm *a; | 70 | const Alarm *a; |
71 | while( (a = it.current()) ) { | 71 | while( (a = it.current()) ) { |
72 | Alarm *b = new Alarm( *a ); | 72 | Alarm *b = new Alarm( *a ); |
73 | b->setParent( this ); | 73 | b->setParent( this ); |
74 | mAlarms.append( b ); | 74 | mAlarms.append( b ); |
75 | 75 | ||
76 | ++it; | 76 | ++it; |
77 | } | 77 | } |
78 | mAlarms.setAutoDelete(true); | 78 | mAlarms.setAutoDelete(true); |
79 | mHasRecurrenceID = i.mHasRecurrenceID; | 79 | mHasRecurrenceID = i.mHasRecurrenceID; |
80 | mRecurrenceID = i.mRecurrenceID; | 80 | mRecurrenceID = i.mRecurrenceID; |
81 | mRecurrence = new Recurrence( *(i.mRecurrence), this ); | 81 | mRecurrence = new Recurrence( *(i.mRecurrence), this ); |
82 | mHoliday = i.mHoliday ; | 82 | mHoliday = i.mHoliday ; |
83 | mBirthday = i.mBirthday; | 83 | mBirthday = i.mBirthday; |
84 | mAnniversary = i.mAnniversary; | 84 | mAnniversary = i.mAnniversary; |
85 | } | 85 | } |
86 | 86 | ||
87 | Incidence::~Incidence() | 87 | Incidence::~Incidence() |
88 | { | 88 | { |
89 | 89 | ||
90 | Incidence *ev; | 90 | Incidence *ev; |
91 | QPtrList<Incidence> Relations = relations(); | 91 | QPtrList<Incidence> Relations = relations(); |
92 | for (ev=Relations.first();ev;ev=Relations.next()) { | 92 | for (ev=Relations.first();ev;ev=Relations.next()) { |
93 | if (ev->relatedTo() == this) ev->setRelatedTo(0); | 93 | if (ev->relatedTo() == this) ev->setRelatedTo(0); |
94 | } | 94 | } |
95 | if (relatedTo()) relatedTo()->removeRelation(this); | 95 | if (relatedTo()) relatedTo()->removeRelation(this); |
96 | delete mRecurrence; | 96 | delete mRecurrence; |
97 | 97 | ||
98 | } | 98 | } |
99 | 99 | ||
100 | bool Incidence::isHoliday() const | 100 | bool Incidence::isHoliday() const |
101 | { | 101 | { |
102 | return mHoliday; | 102 | return mHoliday; |
103 | } | 103 | } |
104 | bool Incidence::isBirthday() const | 104 | bool Incidence::isBirthday() const |
105 | { | 105 | { |
106 | 106 | ||
107 | return mBirthday ; | 107 | return mBirthday ; |
108 | } | 108 | } |
109 | bool Incidence::isAnniversary() const | 109 | bool Incidence::isAnniversary() const |
110 | { | 110 | { |
111 | return mAnniversary ; | 111 | return mAnniversary ; |
112 | 112 | ||
113 | } | 113 | } |
114 | 114 | ||
115 | bool Incidence::hasRecurrenceID() const | 115 | bool Incidence::hasRecurrenceID() const |
116 | { | 116 | { |
117 | return mHasRecurrenceID; | 117 | return mHasRecurrenceID; |
118 | } | 118 | } |
119 | 119 | ||
120 | void Incidence::setHasRecurrenceID( bool b ) | 120 | void Incidence::setHasRecurrenceID( bool b ) |
121 | { | 121 | { |
122 | mHasRecurrenceID = b; | 122 | mHasRecurrenceID = b; |
123 | } | 123 | } |
124 | 124 | ||
125 | void Incidence::setRecurrenceID(QDateTime d) | 125 | void Incidence::setRecurrenceID(QDateTime d) |
126 | { | 126 | { |
127 | mRecurrenceID = d; | 127 | mRecurrenceID = d; |
128 | mHasRecurrenceID = true; | 128 | mHasRecurrenceID = true; |
129 | updated(); | 129 | updated(); |
130 | } | 130 | } |
131 | QDateTime Incidence::recurrenceID () const | 131 | QDateTime Incidence::recurrenceID () const |
132 | { | 132 | { |
133 | return mRecurrenceID; | 133 | return mRecurrenceID; |
134 | } | 134 | } |
135 | 135 | ||
136 | bool Incidence::cancelled() const | 136 | bool Incidence::cancelled() const |
137 | { | 137 | { |
138 | return mCancelled; | 138 | return mCancelled; |
139 | } | 139 | } |
140 | void Incidence::setCancelled( bool b ) | 140 | void Incidence::setCancelled( bool b ) |
141 | { | 141 | { |
142 | mCancelled = b; | 142 | mCancelled = b; |
143 | updated(); | 143 | updated(); |
144 | } | 144 | } |
145 | bool Incidence::hasStartDate() const | 145 | bool Incidence::hasStartDate() const |
146 | { | 146 | { |
147 | return mHasStartDate; | 147 | return mHasStartDate; |
148 | } | 148 | } |
149 | 149 | ||
150 | void Incidence::setHasStartDate(bool f) | 150 | void Incidence::setHasStartDate(bool f) |
151 | { | 151 | { |
152 | if (mReadOnly) return; | 152 | if (mReadOnly) return; |
153 | mHasStartDate = f; | 153 | mHasStartDate = f; |
154 | updated(); | 154 | updated(); |
155 | } | 155 | } |
156 | 156 | ||
157 | // A string comparison that considers that null and empty are the same | 157 | // A string comparison that considers that null and empty are the same |
158 | static bool stringCompare( const QString& s1, const QString& s2 ) | 158 | static bool stringCompare( const QString& s1, const QString& s2 ) |
159 | { | 159 | { |
160 | if ( s1.isEmpty() && s2.isEmpty() ) | 160 | if ( s1.isEmpty() && s2.isEmpty() ) |
161 | return true; | 161 | return true; |
162 | return s1 == s2; | 162 | return s1 == s2; |
163 | } | 163 | } |
164 | 164 | ||
165 | bool KCal::operator==( const Incidence& i1, const Incidence& i2 ) | 165 | bool KCal::operator==( const Incidence& i1, const Incidence& i2 ) |
166 | { | 166 | { |
167 | 167 | ||
168 | if( i1.alarms().count() != i2.alarms().count() ) { | 168 | if( i1.alarms().count() != i2.alarms().count() ) { |
169 | return false; // no need to check further | 169 | return false; // no need to check further |
170 | } | 170 | } |
171 | if ( i1.alarms().count() > 0 ) { | 171 | if ( i1.alarms().count() > 0 ) { |
172 | if ( !( *(i1.alarms().first()) == *(i2.alarms().first())) ) | 172 | if ( !( *(i1.alarms().first()) == *(i2.alarms().first())) ) |
173 | { | 173 | { |
174 | qDebug("alarm not equal "); | 174 | qDebug("alarm not equal "); |
175 | return false; | 175 | return false; |
176 | } | 176 | } |
177 | } | 177 | } |
178 | #if 0 | 178 | #if 0 |
179 | QPtrListIterator<Alarm> a1( i1.alarms() ); | 179 | QPtrListIterator<Alarm> a1( i1.alarms() ); |
180 | QPtrListIterator<Alarm> a2( i2.alarms() ); | 180 | QPtrListIterator<Alarm> a2( i2.alarms() ); |
181 | for( ; a1.current() && a2.current(); ++a1, ++a2 ) { | 181 | for( ; a1.current() && a2.current(); ++a1, ++a2 ) { |
182 | if( *a1.current() == *a2.current() ) { | 182 | if( *a1.current() == *a2.current() ) { |
183 | continue; | 183 | continue; |
184 | } | 184 | } |
185 | else { | 185 | else { |
186 | return false; | 186 | return false; |
187 | } | 187 | } |
188 | } | 188 | } |
189 | #endif | 189 | #endif |
190 | 190 | ||
191 | if ( i1.hasRecurrenceID() == i2.hasRecurrenceID() ) { | 191 | if ( i1.hasRecurrenceID() == i2.hasRecurrenceID() ) { |
192 | if ( i1.hasRecurrenceID() ) { | 192 | if ( i1.hasRecurrenceID() ) { |
193 | if ( i1.recurrenceID() != i2.recurrenceID() ) | 193 | if ( i1.recurrenceID() != i2.recurrenceID() ) |
194 | return false; | 194 | return false; |
195 | } | 195 | } |
196 | 196 | ||
197 | } else { | 197 | } else { |
198 | return false; | 198 | return false; |
199 | } | 199 | } |
200 | 200 | ||
201 | if ( ! operator==( (const IncidenceBase&)i1, (const IncidenceBase&)i2 ) ) | 201 | if ( ! operator==( (const IncidenceBase&)i1, (const IncidenceBase&)i2 ) ) |
202 | return false; | 202 | return false; |
203 | if ( i1.hasStartDate() == i2.hasStartDate() ) { | 203 | if ( i1.hasStartDate() == i2.hasStartDate() ) { |
204 | if ( i1.hasStartDate() ) { | 204 | if ( i1.hasStartDate() ) { |
205 | if ( i1.dtStart() != i2.dtStart() ) | 205 | if ( i1.dtStart() != i2.dtStart() ) |
206 | return false; | 206 | return false; |
207 | } | 207 | } |
208 | } else { | 208 | } else { |
209 | return false; | 209 | return false; |
210 | } | 210 | } |
211 | if (!( *i1.recurrence() == *i2.recurrence()) ) { | 211 | if (!( *i1.recurrence() == *i2.recurrence()) ) { |
212 | qDebug("recurrence is NOT equal "); | 212 | qDebug("recurrence is NOT equal "); |
213 | return false; | 213 | return false; |
214 | } | 214 | } |
215 | return | 215 | return |
216 | // i1.created() == i2.created() && | 216 | // i1.created() == i2.created() && |
217 | stringCompare( i1.description(), i2.description() ) && | 217 | stringCompare( i1.description(), i2.description() ) && |
218 | stringCompare( i1.summary(), i2.summary() ) && | 218 | stringCompare( i1.summary(), i2.summary() ) && |
219 | i1.categories() == i2.categories() && | 219 | i1.categories() == i2.categories() && |
220 | // no need to compare mRelatedTo | 220 | // no need to compare mRelatedTo |
221 | stringCompare( i1.relatedToUid(), i2.relatedToUid() ) && | 221 | stringCompare( i1.relatedToUid(), i2.relatedToUid() ) && |
222 | // i1.relations() == i2.relations() && | 222 | // i1.relations() == i2.relations() && |
223 | i1.exDates() == i2.exDates() && | 223 | i1.exDates() == i2.exDates() && |
224 | i1.attachments() == i2.attachments() && | 224 | i1.attachments() == i2.attachments() && |
225 | i1.resources() == i2.resources() && | 225 | i1.resources() == i2.resources() && |
226 | i1.secrecy() == i2.secrecy() && | 226 | i1.secrecy() == i2.secrecy() && |
227 | i1.priority() == i2.priority() && | 227 | i1.priority() == i2.priority() && |
228 | i1.cancelled() == i2.cancelled() && | 228 | i1.cancelled() == i2.cancelled() && |
229 | stringCompare( i1.location(), i2.location() ); | 229 | stringCompare( i1.location(), i2.location() ); |
230 | } | 230 | } |
231 | 231 | ||
232 | Incidence* Incidence::recreateCloneException( QDate d ) | 232 | Incidence* Incidence::recreateCloneException( QDate d ) |
233 | { | 233 | { |
234 | Incidence* newInc = clone(); | 234 | Incidence* newInc = clone(); |
235 | newInc->recreate(); | 235 | newInc->recreate(); |
236 | if ( doesRecur() ) { | 236 | if ( doesRecur() ) { |
237 | addExDate( d ); | 237 | addExDate( d ); |
238 | newInc->recurrence()->unsetRecurs(); | 238 | newInc->recurrence()->unsetRecurs(); |
239 | if ( type() == "Event") { | 239 | if ( type() == "Event") { |
240 | int len = dtStart().secsTo( ((Event*)this)->dtEnd()); | 240 | int len = dtStart().secsTo( ((Event*)this)->dtEnd()); |
241 | QTime tim = dtStart().time(); | 241 | QTime tim = dtStart().time(); |
242 | newInc->setDtStart( QDateTime(d, tim) ); | 242 | newInc->setDtStart( QDateTime(d, tim) ); |
243 | ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); | 243 | ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); |
244 | } else { | 244 | } else { |
245 | int len = dtStart().secsTo( ((Todo*)this)->dtDue()); | 245 | int len = dtStart().secsTo( ((Todo*)this)->dtDue()); |
246 | QTime tim = ((Todo*)this)->dtDue().time(); | 246 | QTime tim = ((Todo*)this)->dtDue().time(); |
247 | ((Todo*)newInc)->setDtDue( QDateTime(d, tim) ); | 247 | ((Todo*)newInc)->setDtDue( QDateTime(d, tim) ); |
248 | ((Todo*)newInc)->setDtStart( ((Todo*)newInc)->dtDue().addSecs( -len ) ); | 248 | ((Todo*)newInc)->setDtStart( ((Todo*)newInc)->dtDue().addSecs( -len ) ); |
249 | ((Todo*)this)->setRecurDates(); | 249 | ((Todo*)this)->setRecurDates(); |
250 | } | 250 | } |
251 | newInc->setExDates( DateList () ); | 251 | newInc->setExDates( DateList () ); |
252 | } | 252 | } |
253 | return newInc; | 253 | return newInc; |
254 | } | 254 | } |
255 | 255 | ||
256 | void Incidence::recreate() | 256 | void Incidence::recreate() |
257 | { | 257 | { |
258 | setCreated(QDateTime::currentDateTime()); | 258 | setCreated(QDateTime::currentDateTime()); |
259 | 259 | ||
260 | setUid(CalFormat::createUniqueId()); | 260 | setUid(CalFormat::createUniqueId()); |
261 | 261 | ||
262 | setRevision(0); | 262 | setRevision(0); |
263 | setIDStr( ":" ); | 263 | setIDStr( ":" ); |
264 | setLastModified(QDateTime::currentDateTime()); | 264 | setLastModified(QDateTime::currentDateTime()); |
265 | } | 265 | } |
266 | 266 | void Incidence::cloneRelations( Incidence * newInc ) | |
267 | { | ||
268 | // newInc is already a clone of this incidence | ||
269 | Incidence * inc; | ||
270 | Incidence * cloneInc; | ||
271 | QPtrList<Incidence> Relations = relations(); | ||
272 | for (inc=Relations.first();inc;inc=Relations.next()) { | ||
273 | cloneInc = inc->clone(); | ||
274 | cloneInc->recreate(); | ||
275 | cloneInc->setRelatedTo( newInc ); | ||
276 | inc->cloneRelations( cloneInc ); | ||
277 | } | ||
278 | } | ||
267 | void Incidence::setReadOnly( bool readOnly ) | 279 | void Incidence::setReadOnly( bool readOnly ) |
268 | { | 280 | { |
269 | IncidenceBase::setReadOnly( readOnly ); | 281 | IncidenceBase::setReadOnly( readOnly ); |
270 | recurrence()->setRecurReadOnly( readOnly); | 282 | recurrence()->setRecurReadOnly( readOnly); |
271 | } | 283 | } |
272 | 284 | ||
273 | void Incidence::setCreated(QDateTime created) | 285 | void Incidence::setCreated(QDateTime created) |
274 | { | 286 | { |
275 | if (mReadOnly) return; | 287 | if (mReadOnly) return; |
276 | mCreated = getEvenTime(created); | 288 | mCreated = getEvenTime(created); |
277 | } | 289 | } |
278 | 290 | ||
279 | QDateTime Incidence::created() const | 291 | QDateTime Incidence::created() const |
280 | { | 292 | { |
281 | return mCreated; | 293 | return mCreated; |
282 | } | 294 | } |
283 | 295 | ||
284 | void Incidence::setRevision(int rev) | 296 | void Incidence::setRevision(int rev) |
285 | { | 297 | { |
286 | if (mReadOnly) return; | 298 | if (mReadOnly) return; |
287 | mRevision = rev; | 299 | mRevision = rev; |
288 | 300 | ||
289 | updated(); | 301 | updated(); |
290 | } | 302 | } |
291 | 303 | ||
292 | int Incidence::revision() const | 304 | int Incidence::revision() const |
293 | { | 305 | { |
294 | return mRevision; | 306 | return mRevision; |
295 | } | 307 | } |
296 | 308 | ||
297 | void Incidence::setDtStart(const QDateTime &dtStart) | 309 | void Incidence::setDtStart(const QDateTime &dtStart) |
298 | { | 310 | { |
299 | 311 | ||
300 | QDateTime dt = getEvenTime(dtStart); | 312 | QDateTime dt = getEvenTime(dtStart); |
301 | recurrence()->setRecurStart( dt); | 313 | recurrence()->setRecurStart( dt); |
302 | IncidenceBase::setDtStart( dt ); | 314 | IncidenceBase::setDtStart( dt ); |
303 | } | 315 | } |
304 | 316 | ||
305 | void Incidence::setDescription(const QString &description) | 317 | void Incidence::setDescription(const QString &description) |
306 | { | 318 | { |
307 | if (mReadOnly) return; | 319 | if (mReadOnly) return; |
308 | mDescription = description; | 320 | mDescription = description; |
309 | updated(); | 321 | updated(); |
310 | } | 322 | } |
311 | 323 | ||
312 | QString Incidence::description() const | 324 | QString Incidence::description() const |
313 | { | 325 | { |
314 | return mDescription; | 326 | return mDescription; |
315 | } | 327 | } |
316 | 328 | ||
317 | 329 | ||
318 | void Incidence::setSummary(const QString &summary) | 330 | void Incidence::setSummary(const QString &summary) |
319 | { | 331 | { |
320 | if (mReadOnly) return; | 332 | if (mReadOnly) return; |
321 | mSummary = summary; | 333 | mSummary = summary; |
322 | updated(); | 334 | updated(); |
323 | } | 335 | } |
324 | 336 | ||
325 | QString Incidence::summary() const | 337 | QString Incidence::summary() const |
326 | { | 338 | { |
327 | return mSummary; | 339 | return mSummary; |
328 | } | 340 | } |
329 | void Incidence::checkCategories() | 341 | void Incidence::checkCategories() |
330 | { | 342 | { |
331 | mHoliday = mCategories.contains("Holiday") || mCategories.contains(i18n("Holiday")); | 343 | mHoliday = mCategories.contains("Holiday") || mCategories.contains(i18n("Holiday")); |
332 | mBirthday = mCategories.contains("Birthday") || mCategories.contains(i18n("Birthday")); | 344 | mBirthday = mCategories.contains("Birthday") || mCategories.contains(i18n("Birthday")); |
333 | mAnniversary = mCategories.contains("Anniversary") || mCategories.contains(i18n("Anniversary")); | 345 | mAnniversary = mCategories.contains("Anniversary") || mCategories.contains(i18n("Anniversary")); |
334 | } | 346 | } |
335 | 347 | ||
336 | void Incidence::setCategories(const QStringList &categories) | 348 | void Incidence::setCategories(const QStringList &categories) |
337 | { | 349 | { |
338 | if (mReadOnly) return; | 350 | if (mReadOnly) return; |
339 | mCategories = categories; | 351 | mCategories = categories; |
340 | checkCategories(); | 352 | checkCategories(); |
341 | updated(); | 353 | updated(); |
342 | } | 354 | } |
343 | 355 | ||
344 | // TODO: remove setCategories(QString) function | 356 | // TODO: remove setCategories(QString) function |
345 | void Incidence::setCategories(const QString &catStr) | 357 | void Incidence::setCategories(const QString &catStr) |
346 | { | 358 | { |
347 | if (mReadOnly) return; | 359 | if (mReadOnly) return; |
348 | mCategories.clear(); | 360 | mCategories.clear(); |
349 | 361 | ||
350 | if (catStr.isEmpty()) return; | 362 | if (catStr.isEmpty()) return; |
351 | 363 | ||
352 | mCategories = QStringList::split(",",catStr); | 364 | mCategories = QStringList::split(",",catStr); |
353 | 365 | ||
354 | QStringList::Iterator it; | 366 | QStringList::Iterator it; |
355 | for(it = mCategories.begin();it != mCategories.end(); ++it) { | 367 | for(it = mCategories.begin();it != mCategories.end(); ++it) { |
356 | *it = (*it).stripWhiteSpace(); | 368 | *it = (*it).stripWhiteSpace(); |
357 | } | 369 | } |
358 | checkCategories(); | 370 | checkCategories(); |
359 | updated(); | 371 | updated(); |
360 | } | 372 | } |
361 | 373 | ||
362 | QStringList Incidence::categories() const | 374 | QStringList Incidence::categories() const |
363 | { | 375 | { |
364 | return mCategories; | 376 | return mCategories; |
365 | } | 377 | } |
366 | 378 | ||
367 | QString Incidence::categoriesStr() | 379 | QString Incidence::categoriesStr() |
368 | { | 380 | { |
369 | return mCategories.join(","); | 381 | return mCategories.join(","); |
370 | } | 382 | } |
371 | 383 | ||
372 | void Incidence::setRelatedToUid(const QString &relatedToUid) | 384 | void Incidence::setRelatedToUid(const QString &relatedToUid) |
373 | { | 385 | { |
374 | if (mReadOnly) return; | 386 | if (mReadOnly) return; |
375 | mRelatedToUid = relatedToUid; | 387 | mRelatedToUid = relatedToUid; |
376 | } | 388 | } |
377 | 389 | ||
378 | QString Incidence::relatedToUid() const | 390 | QString Incidence::relatedToUid() const |
379 | { | 391 | { |
380 | return mRelatedToUid; | 392 | return mRelatedToUid; |
381 | } | 393 | } |
382 | 394 | ||
383 | void Incidence::setRelatedTo(Incidence *relatedTo) | 395 | void Incidence::setRelatedTo(Incidence *relatedTo) |
384 | { | 396 | { |
385 | //qDebug("Incidence::setRelatedTo %d ", relatedTo); | 397 | //qDebug("Incidence::setRelatedTo %d ", relatedTo); |
386 | //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() ); | 398 | //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() ); |
387 | if (mReadOnly || mRelatedTo == relatedTo) return; | 399 | if (mReadOnly || mRelatedTo == relatedTo) return; |
388 | if(mRelatedTo) { | 400 | if(mRelatedTo) { |
389 | // updated(); | 401 | // updated(); |
390 | mRelatedTo->removeRelation(this); | 402 | mRelatedTo->removeRelation(this); |
391 | } | 403 | } |
392 | mRelatedTo = relatedTo; | 404 | mRelatedTo = relatedTo; |
393 | if (mRelatedTo) { | 405 | if (mRelatedTo) { |
394 | mRelatedTo->addRelation(this); | 406 | mRelatedTo->addRelation(this); |
395 | mRelatedToUid = mRelatedTo->uid(); | 407 | mRelatedToUid = mRelatedTo->uid(); |
396 | } else { | 408 | } else { |
397 | mRelatedToUid = ""; | 409 | mRelatedToUid = ""; |
398 | } | 410 | } |
399 | } | 411 | } |
400 | 412 | ||
401 | Incidence *Incidence::relatedTo() const | 413 | Incidence *Incidence::relatedTo() const |
402 | { | 414 | { |
403 | return mRelatedTo; | 415 | return mRelatedTo; |
404 | } | 416 | } |
405 | 417 | ||
406 | QPtrList<Incidence> Incidence::relations() const | 418 | QPtrList<Incidence> Incidence::relations() const |
407 | { | 419 | { |
408 | return mRelations; | 420 | return mRelations; |
409 | } | 421 | } |
410 | 422 | ||
411 | void Incidence::addRelation(Incidence *event) | 423 | void Incidence::addRelation(Incidence *event) |
412 | { | 424 | { |
413 | if( mRelations.findRef( event ) == -1 ) { | 425 | if( mRelations.findRef( event ) == -1 ) { |
414 | mRelations.append(event); | 426 | mRelations.append(event); |
415 | //updated(); | 427 | //updated(); |
416 | } | 428 | } |
417 | } | 429 | } |
418 | 430 | ||
419 | void Incidence::removeRelation(Incidence *event) | 431 | void Incidence::removeRelation(Incidence *event) |
420 | { | 432 | { |
421 | 433 | ||
422 | mRelations.removeRef(event); | 434 | mRelations.removeRef(event); |
423 | 435 | ||
424 | // if (event->getRelatedTo() == this) event->setRelatedTo(0); | 436 | // if (event->getRelatedTo() == this) event->setRelatedTo(0); |
425 | } | 437 | } |
426 | 438 | ||
427 | bool Incidence::recursOn(const QDate &qd) const | 439 | bool Incidence::recursOn(const QDate &qd) const |
428 | { | 440 | { |
429 | if (recurrence()->recursOnPure(qd) && !isException(qd)) return true; | 441 | if (recurrence()->recursOnPure(qd) && !isException(qd)) return true; |
430 | else return false; | 442 | else return false; |
431 | } | 443 | } |
432 | 444 | ||
433 | void Incidence::setExDates(const DateList &exDates) | 445 | void Incidence::setExDates(const DateList &exDates) |
434 | { | 446 | { |
435 | if (mReadOnly) return; | 447 | if (mReadOnly) return; |
436 | mExDates = exDates; | 448 | mExDates = exDates; |
437 | 449 | ||
438 | recurrence()->setRecurExDatesCount(mExDates.count()); | 450 | recurrence()->setRecurExDatesCount(mExDates.count()); |
439 | 451 | ||
440 | updated(); | 452 | updated(); |
441 | } | 453 | } |
442 | 454 | ||
443 | void Incidence::addExDate(const QDate &date) | 455 | void Incidence::addExDate(const QDate &date) |
444 | { | 456 | { |
445 | if (mReadOnly) return; | 457 | if (mReadOnly) return; |
446 | mExDates.append(date); | 458 | mExDates.append(date); |
447 | 459 | ||
448 | recurrence()->setRecurExDatesCount(mExDates.count()); | 460 | recurrence()->setRecurExDatesCount(mExDates.count()); |
449 | 461 | ||
450 | updated(); | 462 | updated(); |
451 | } | 463 | } |
452 | 464 | ||
453 | DateList Incidence::exDates() const | 465 | DateList Incidence::exDates() const |
454 | { | 466 | { |
455 | return mExDates; | 467 | return mExDates; |
456 | } | 468 | } |
457 | 469 | ||
458 | bool Incidence::isException(const QDate &date) const | 470 | bool Incidence::isException(const QDate &date) const |
459 | { | 471 | { |
460 | DateList::ConstIterator it; | 472 | DateList::ConstIterator it; |
461 | for( it = mExDates.begin(); it != mExDates.end(); ++it ) { | 473 | for( it = mExDates.begin(); it != mExDates.end(); ++it ) { |
462 | if ( (*it) == date ) { | 474 | if ( (*it) == date ) { |
463 | return true; | 475 | return true; |
464 | } | 476 | } |
465 | } | 477 | } |
466 | 478 | ||
467 | return false; | 479 | return false; |
468 | } | 480 | } |
469 | 481 | ||
470 | void Incidence::addAttachment(Attachment *attachment) | 482 | void Incidence::addAttachment(Attachment *attachment) |
471 | { | 483 | { |
472 | if (mReadOnly || !attachment) return; | 484 | if (mReadOnly || !attachment) return; |
473 | mAttachments.append(attachment); | 485 | mAttachments.append(attachment); |
474 | updated(); | 486 | updated(); |
475 | } | 487 | } |
476 | 488 | ||
477 | void Incidence::deleteAttachment(Attachment *attachment) | 489 | void Incidence::deleteAttachment(Attachment *attachment) |
478 | { | 490 | { |
479 | mAttachments.removeRef(attachment); | 491 | mAttachments.removeRef(attachment); |
480 | } | 492 | } |
481 | 493 | ||
482 | void Incidence::deleteAttachments(const QString& mime) | 494 | void Incidence::deleteAttachments(const QString& mime) |
483 | { | 495 | { |
484 | Attachment *at = mAttachments.first(); | 496 | Attachment *at = mAttachments.first(); |
485 | while (at) { | 497 | while (at) { |
486 | if (at->mimeType() == mime) | 498 | if (at->mimeType() == mime) |
487 | mAttachments.remove(); | 499 | mAttachments.remove(); |
488 | else | 500 | else |
489 | at = mAttachments.next(); | 501 | at = mAttachments.next(); |
490 | } | 502 | } |
491 | } | 503 | } |
492 | 504 | ||
493 | QPtrList<Attachment> Incidence::attachments() const | 505 | QPtrList<Attachment> Incidence::attachments() const |
494 | { | 506 | { |
495 | return mAttachments; | 507 | return mAttachments; |
496 | } | 508 | } |
497 | 509 | ||
498 | QPtrList<Attachment> Incidence::attachments(const QString& mime) const | 510 | QPtrList<Attachment> Incidence::attachments(const QString& mime) const |
499 | { | 511 | { |
500 | QPtrList<Attachment> attachments; | 512 | QPtrList<Attachment> attachments; |
501 | QPtrListIterator<Attachment> it( mAttachments ); | 513 | QPtrListIterator<Attachment> it( mAttachments ); |
502 | Attachment *at; | 514 | Attachment *at; |
503 | while ( (at = it.current()) ) { | 515 | while ( (at = it.current()) ) { |
504 | if (at->mimeType() == mime) | 516 | if (at->mimeType() == mime) |
505 | attachments.append(at); | 517 | attachments.append(at); |
506 | ++it; | 518 | ++it; |
507 | } | 519 | } |
508 | 520 | ||
509 | return attachments; | 521 | return attachments; |
510 | } | 522 | } |
511 | 523 | ||
512 | void Incidence::setResources(const QStringList &resources) | 524 | void Incidence::setResources(const QStringList &resources) |
513 | { | 525 | { |
514 | if (mReadOnly) return; | 526 | if (mReadOnly) return; |
515 | mResources = resources; | 527 | mResources = resources; |
516 | updated(); | 528 | updated(); |
517 | } | 529 | } |
518 | 530 | ||
519 | QStringList Incidence::resources() const | 531 | QStringList Incidence::resources() const |
520 | { | 532 | { |
521 | return mResources; | 533 | return mResources; |
522 | } | 534 | } |
523 | 535 | ||
524 | 536 | ||
525 | void Incidence::setPriority(int priority) | 537 | void Incidence::setPriority(int priority) |
526 | { | 538 | { |
527 | if (mReadOnly) return; | 539 | if (mReadOnly) return; |
528 | mPriority = priority; | 540 | mPriority = priority; |
529 | updated(); | 541 | updated(); |
530 | } | 542 | } |
531 | 543 | ||
532 | int Incidence::priority() const | 544 | int Incidence::priority() const |
533 | { | 545 | { |
534 | return mPriority; | 546 | return mPriority; |
535 | } | 547 | } |
536 | 548 | ||
537 | void Incidence::setSecrecy(int sec) | 549 | void Incidence::setSecrecy(int sec) |
538 | { | 550 | { |
539 | if (mReadOnly) return; | 551 | if (mReadOnly) return; |
540 | mSecrecy = sec; | 552 | mSecrecy = sec; |
541 | updated(); | 553 | updated(); |
542 | } | 554 | } |
543 | 555 | ||
544 | int Incidence::secrecy() const | 556 | int Incidence::secrecy() const |
545 | { | 557 | { |
546 | return mSecrecy; | 558 | return mSecrecy; |
547 | } | 559 | } |
548 | 560 | ||
549 | QString Incidence::secrecyStr() const | 561 | QString Incidence::secrecyStr() const |
550 | { | 562 | { |
551 | return secrecyName(mSecrecy); | 563 | return secrecyName(mSecrecy); |
552 | } | 564 | } |
553 | 565 | ||
554 | QString Incidence::secrecyName(int secrecy) | 566 | QString Incidence::secrecyName(int secrecy) |
555 | { | 567 | { |
556 | switch (secrecy) { | 568 | switch (secrecy) { |
557 | case SecrecyPublic: | 569 | case SecrecyPublic: |
558 | return i18n("Public"); | 570 | return i18n("Public"); |
559 | break; | 571 | break; |
560 | case SecrecyPrivate: | 572 | case SecrecyPrivate: |
561 | return i18n("Private"); | 573 | return i18n("Private"); |
562 | break; | 574 | break; |
563 | case SecrecyConfidential: | 575 | case SecrecyConfidential: |
564 | return i18n("Confidential"); | 576 | return i18n("Confidential"); |
565 | break; | 577 | break; |
566 | default: | 578 | default: |
567 | return i18n("Undefined"); | 579 | return i18n("Undefined"); |
568 | break; | 580 | break; |
569 | } | 581 | } |
570 | } | 582 | } |
571 | 583 | ||
572 | QStringList Incidence::secrecyList() | 584 | QStringList Incidence::secrecyList() |
573 | { | 585 | { |
574 | QStringList list; | 586 | QStringList list; |
575 | list << secrecyName(SecrecyPublic); | 587 | list << secrecyName(SecrecyPublic); |
576 | list << secrecyName(SecrecyPrivate); | 588 | list << secrecyName(SecrecyPrivate); |
577 | list << secrecyName(SecrecyConfidential); | 589 | list << secrecyName(SecrecyConfidential); |
578 | 590 | ||
579 | return list; | 591 | return list; |
580 | } | 592 | } |
581 | 593 | ||
582 | 594 | ||
583 | QPtrList<Alarm> Incidence::alarms() const | 595 | QPtrList<Alarm> Incidence::alarms() const |
584 | { | 596 | { |
585 | return mAlarms; | 597 | return mAlarms; |
586 | } | 598 | } |
587 | 599 | ||
588 | Alarm* Incidence::newAlarm() | 600 | Alarm* Incidence::newAlarm() |
589 | { | 601 | { |
590 | Alarm* alarm = new Alarm(this); | 602 | Alarm* alarm = new Alarm(this); |
591 | mAlarms.append(alarm); | 603 | mAlarms.append(alarm); |
592 | // updated(); | 604 | // updated(); |
593 | return alarm; | 605 | return alarm; |
594 | } | 606 | } |
595 | 607 | ||
596 | void Incidence::addAlarm(Alarm *alarm) | 608 | void Incidence::addAlarm(Alarm *alarm) |
597 | { | 609 | { |
598 | mAlarms.append(alarm); | 610 | mAlarms.append(alarm); |
599 | updated(); | 611 | updated(); |
600 | } | 612 | } |
601 | 613 | ||
602 | void Incidence::removeAlarm(Alarm *alarm) | 614 | void Incidence::removeAlarm(Alarm *alarm) |
603 | { | 615 | { |
604 | mAlarms.removeRef(alarm); | 616 | mAlarms.removeRef(alarm); |
605 | updated(); | 617 | updated(); |
606 | } | 618 | } |
607 | 619 | ||
608 | void Incidence::clearAlarms() | 620 | void Incidence::clearAlarms() |
609 | { | 621 | { |
610 | mAlarms.clear(); | 622 | mAlarms.clear(); |
611 | updated(); | 623 | updated(); |
612 | } | 624 | } |
613 | 625 | ||
614 | bool Incidence::isAlarmEnabled() const | 626 | bool Incidence::isAlarmEnabled() const |
615 | { | 627 | { |
616 | Alarm* alarm; | 628 | Alarm* alarm; |
617 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { | 629 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { |
618 | if (alarm->enabled()) | 630 | if (alarm->enabled()) |
619 | return true; | 631 | return true; |
620 | } | 632 | } |
621 | return false; | 633 | return false; |
622 | } | 634 | } |
623 | 635 | ||
624 | Recurrence *Incidence::recurrence() const | 636 | Recurrence *Incidence::recurrence() const |
625 | { | 637 | { |
626 | return mRecurrence; | 638 | return mRecurrence; |
627 | } | 639 | } |
628 | void Incidence::setRecurrence( Recurrence * r) | 640 | void Incidence::setRecurrence( Recurrence * r) |
629 | { | 641 | { |
630 | delete mRecurrence; | 642 | delete mRecurrence; |
631 | mRecurrence = r; | 643 | mRecurrence = r; |
632 | } | 644 | } |
633 | 645 | ||
634 | void Incidence::setLocation(const QString &location) | 646 | void Incidence::setLocation(const QString &location) |
635 | { | 647 | { |
636 | if (mReadOnly) return; | 648 | if (mReadOnly) return; |
637 | mLocation = location; | 649 | mLocation = location; |
638 | updated(); | 650 | updated(); |
639 | } | 651 | } |
640 | 652 | ||
641 | QString Incidence::location() const | 653 | QString Incidence::location() const |
642 | { | 654 | { |
643 | return mLocation; | 655 | return mLocation; |
644 | } | 656 | } |
645 | 657 | ||
646 | ushort Incidence::doesRecur() const | 658 | ushort Incidence::doesRecur() const |
647 | { | 659 | { |
648 | if ( mRecurrence ) return mRecurrence->doesRecur(); | 660 | if ( mRecurrence ) return mRecurrence->doesRecur(); |
649 | else return Recurrence::rNone; | 661 | else return Recurrence::rNone; |
650 | } | 662 | } |
diff --git a/libkcal/incidence.h b/libkcal/incidence.h index f8da342..60070a2 100644 --- a/libkcal/incidence.h +++ b/libkcal/incidence.h | |||
@@ -1,314 +1,315 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | #ifndef INCIDENCE_H | 20 | #ifndef INCIDENCE_H |
21 | #define INCIDENCE_H | 21 | #define INCIDENCE_H |
22 | // | 22 | // |
23 | // Incidence - base class of calendaring components | 23 | // Incidence - base class of calendaring components |
24 | // | 24 | // |
25 | 25 | ||
26 | #include <qdatetime.h> | 26 | #include <qdatetime.h> |
27 | #include <qstringlist.h> | 27 | #include <qstringlist.h> |
28 | #include <qvaluelist.h> | 28 | #include <qvaluelist.h> |
29 | 29 | ||
30 | #include "recurrence.h" | 30 | #include "recurrence.h" |
31 | #include "alarm.h" | 31 | #include "alarm.h" |
32 | #include "attachment.h" | 32 | #include "attachment.h" |
33 | #include "listbase.h" | 33 | #include "listbase.h" |
34 | #include "incidencebase.h" | 34 | #include "incidencebase.h" |
35 | 35 | ||
36 | namespace KCal { | 36 | namespace KCal { |
37 | 37 | ||
38 | class Event; | 38 | class Event; |
39 | class Todo; | 39 | class Todo; |
40 | class Journal; | 40 | class Journal; |
41 | 41 | ||
42 | /** | 42 | /** |
43 | This class provides the base class common to all calendar components. | 43 | This class provides the base class common to all calendar components. |
44 | */ | 44 | */ |
45 | class Incidence : public IncidenceBase | 45 | class Incidence : public IncidenceBase |
46 | { | 46 | { |
47 | public: | 47 | public: |
48 | /** | 48 | /** |
49 | This class provides the interface for a visitor of calendar components. It | 49 | This class provides the interface for a visitor of calendar components. It |
50 | serves as base class for concrete visitors, which implement certain actions on | 50 | serves as base class for concrete visitors, which implement certain actions on |
51 | calendar components. It allows to add functions, which operate on the concrete | 51 | calendar components. It allows to add functions, which operate on the concrete |
52 | types of calendar components, without changing the calendar component classes. | 52 | types of calendar components, without changing the calendar component classes. |
53 | */ | 53 | */ |
54 | class Visitor | 54 | class Visitor |
55 | { | 55 | { |
56 | public: | 56 | public: |
57 | /** Destruct Incidence::Visitor */ | 57 | /** Destruct Incidence::Visitor */ |
58 | virtual ~Visitor() {} | 58 | virtual ~Visitor() {} |
59 | 59 | ||
60 | /** | 60 | /** |
61 | Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions | 61 | Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions |
62 | on an Event object. | 62 | on an Event object. |
63 | */ | 63 | */ |
64 | virtual bool visit(Event *) { return false; } | 64 | virtual bool visit(Event *) { return false; } |
65 | /** | 65 | /** |
66 | Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions | 66 | Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions |
67 | on an Todo object. | 67 | on an Todo object. |
68 | */ | 68 | */ |
69 | virtual bool visit(Todo *) { return false; } | 69 | virtual bool visit(Todo *) { return false; } |
70 | /** | 70 | /** |
71 | Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions | 71 | Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions |
72 | on an Journal object. | 72 | on an Journal object. |
73 | */ | 73 | */ |
74 | virtual bool visit(Journal *) { return false; } | 74 | virtual bool visit(Journal *) { return false; } |
75 | 75 | ||
76 | protected: | 76 | protected: |
77 | /** Constructor is protected to prevent direct creation of visitor base class. */ | 77 | /** Constructor is protected to prevent direct creation of visitor base class. */ |
78 | Visitor() {} | 78 | Visitor() {} |
79 | }; | 79 | }; |
80 | 80 | ||
81 | /** | 81 | /** |
82 | This class implements a visitor for adding an Incidence to a resource | 82 | This class implements a visitor for adding an Incidence to a resource |
83 | supporting addEvent(), addTodo() and addJournal() calls. | 83 | supporting addEvent(), addTodo() and addJournal() calls. |
84 | */ | 84 | */ |
85 | template<class T> | 85 | template<class T> |
86 | class AddVisitor : public Visitor | 86 | class AddVisitor : public Visitor |
87 | { | 87 | { |
88 | public: | 88 | public: |
89 | AddVisitor( T *r ) : mResource( r ) {} | 89 | AddVisitor( T *r ) : mResource( r ) {} |
90 | bool visit( Event *e ) { return mResource->addEvent( e ); } | 90 | bool visit( Event *e ) { return mResource->addEvent( e ); } |
91 | bool visit( Todo *t ) { return mResource->addTodo( t ); } | 91 | bool visit( Todo *t ) { return mResource->addTodo( t ); } |
92 | bool visit( Journal *j ) { return mResource->addJournal( j ); } | 92 | bool visit( Journal *j ) { return mResource->addJournal( j ); } |
93 | 93 | ||
94 | private: | 94 | private: |
95 | T *mResource; | 95 | T *mResource; |
96 | }; | 96 | }; |
97 | 97 | ||
98 | /** enumeration for describing an event's secrecy. */ | 98 | /** enumeration for describing an event's secrecy. */ |
99 | enum { SecrecyPublic = 0, SecrecyPrivate = 1, SecrecyConfidential = 2 }; | 99 | enum { SecrecyPublic = 0, SecrecyPrivate = 1, SecrecyConfidential = 2 }; |
100 | typedef ListBase<Incidence> List; | 100 | typedef ListBase<Incidence> List; |
101 | Incidence(); | 101 | Incidence(); |
102 | Incidence(const Incidence &); | 102 | Incidence(const Incidence &); |
103 | ~Incidence(); | 103 | ~Incidence(); |
104 | 104 | ||
105 | /** | 105 | /** |
106 | Accept IncidenceVisitor. A class taking part in the visitor mechanism has to | 106 | Accept IncidenceVisitor. A class taking part in the visitor mechanism has to |
107 | provide this implementation: | 107 | provide this implementation: |
108 | <pre> | 108 | <pre> |
109 | bool accept(Visitor &v) { return v.visit(this); } | 109 | bool accept(Visitor &v) { return v.visit(this); } |
110 | </pre> | 110 | </pre> |
111 | */ | 111 | */ |
112 | virtual bool accept(Visitor &) { return false; } | 112 | virtual bool accept(Visitor &) { return false; } |
113 | 113 | ||
114 | virtual Incidence *clone() = 0; | 114 | virtual Incidence *clone() = 0; |
115 | virtual void cloneRelations( Incidence * ); | ||
115 | 116 | ||
116 | virtual QDateTime getNextAlarmDateTime( bool * ok, int * offset ) const = 0; | 117 | virtual QDateTime getNextAlarmDateTime( bool * ok, int * offset ) const = 0; |
117 | void setReadOnly( bool ); | 118 | void setReadOnly( bool ); |
118 | 119 | ||
119 | /** | 120 | /** |
120 | Recreate event. The event is made a new unique event, but already stored | 121 | Recreate event. The event is made a new unique event, but already stored |
121 | event information is preserved. Sets uniquie id, creation date, last | 122 | event information is preserved. Sets uniquie id, creation date, last |
122 | modification date and revision number. | 123 | modification date and revision number. |
123 | */ | 124 | */ |
124 | void recreate(); | 125 | void recreate(); |
125 | Incidence* recreateCloneException(QDate); | 126 | Incidence* recreateCloneException(QDate); |
126 | 127 | ||
127 | /** set creation date */ | 128 | /** set creation date */ |
128 | void setCreated(QDateTime); | 129 | void setCreated(QDateTime); |
129 | /** return time and date of creation. */ | 130 | /** return time and date of creation. */ |
130 | QDateTime created() const; | 131 | QDateTime created() const; |
131 | 132 | ||
132 | /** set the number of revisions this event has seen */ | 133 | /** set the number of revisions this event has seen */ |
133 | void setRevision(int rev); | 134 | void setRevision(int rev); |
134 | /** return the number of revisions this event has seen */ | 135 | /** return the number of revisions this event has seen */ |
135 | int revision() const; | 136 | int revision() const; |
136 | 137 | ||
137 | /** Set starting date/time. */ | 138 | /** Set starting date/time. */ |
138 | virtual void setDtStart(const QDateTime &dtStart); | 139 | virtual void setDtStart(const QDateTime &dtStart); |
139 | /** Return the incidence's ending date/time as a QDateTime. */ | 140 | /** Return the incidence's ending date/time as a QDateTime. */ |
140 | virtual QDateTime dtEnd() const { return QDateTime(); } | 141 | virtual QDateTime dtEnd() const { return QDateTime(); } |
141 | 142 | ||
142 | /** sets the event's lengthy description. */ | 143 | /** sets the event's lengthy description. */ |
143 | void setDescription(const QString &description); | 144 | void setDescription(const QString &description); |
144 | /** returns a reference to the event's description. */ | 145 | /** returns a reference to the event's description. */ |
145 | QString description() const; | 146 | QString description() const; |
146 | 147 | ||
147 | /** sets the event's short summary. */ | 148 | /** sets the event's short summary. */ |
148 | void setSummary(const QString &summary); | 149 | void setSummary(const QString &summary); |
149 | /** returns a reference to the event's summary. */ | 150 | /** returns a reference to the event's summary. */ |
150 | QString summary() const; | 151 | QString summary() const; |
151 | 152 | ||
152 | /** set event's applicable categories */ | 153 | /** set event's applicable categories */ |
153 | void setCategories(const QStringList &categories); | 154 | void setCategories(const QStringList &categories); |
154 | /** set event's categories based on a comma delimited string */ | 155 | /** set event's categories based on a comma delimited string */ |
155 | void setCategories(const QString &catStr); | 156 | void setCategories(const QString &catStr); |
156 | /** return categories in a list */ | 157 | /** return categories in a list */ |
157 | QStringList categories() const; | 158 | QStringList categories() const; |
158 | /** return categories as a comma separated string */ | 159 | /** return categories as a comma separated string */ |
159 | QString categoriesStr(); | 160 | QString categoriesStr(); |
160 | 161 | ||
161 | /** point at some other event to which the event relates. This function should | 162 | /** point at some other event to which the event relates. This function should |
162 | * only be used when constructing a calendar before the related Event | 163 | * only be used when constructing a calendar before the related Event |
163 | * exists. */ | 164 | * exists. */ |
164 | void setRelatedToUid(const QString &); | 165 | void setRelatedToUid(const QString &); |
165 | /** what event does this one relate to? This function should | 166 | /** what event does this one relate to? This function should |
166 | * only be used when constructing a calendar before the related Event | 167 | * only be used when constructing a calendar before the related Event |
167 | * exists. */ | 168 | * exists. */ |
168 | QString relatedToUid() const; | 169 | QString relatedToUid() const; |
169 | /** point at some other event to which the event relates */ | 170 | /** point at some other event to which the event relates */ |
170 | void setRelatedTo(Incidence *relatedTo); | 171 | void setRelatedTo(Incidence *relatedTo); |
171 | /** what event does this one relate to? */ | 172 | /** what event does this one relate to? */ |
172 | Incidence *relatedTo() const; | 173 | Incidence *relatedTo() const; |
173 | /** All events that are related to this event */ | 174 | /** All events that are related to this event */ |
174 | QPtrList<Incidence> relations() const; | 175 | QPtrList<Incidence> relations() const; |
175 | /** Add an event which is related to this event */ | 176 | /** Add an event which is related to this event */ |
176 | void addRelation(Incidence *); | 177 | void addRelation(Incidence *); |
177 | /** Remove event that is related to this event */ | 178 | /** Remove event that is related to this event */ |
178 | void removeRelation(Incidence *); | 179 | void removeRelation(Incidence *); |
179 | 180 | ||
180 | /** returns the list of dates which are exceptions to the recurrence rule */ | 181 | /** returns the list of dates which are exceptions to the recurrence rule */ |
181 | DateList exDates() const; | 182 | DateList exDates() const; |
182 | /** sets the list of dates which are exceptions to the recurrence rule */ | 183 | /** sets the list of dates which are exceptions to the recurrence rule */ |
183 | void setExDates(const DateList &_exDates); | 184 | void setExDates(const DateList &_exDates); |
184 | void setExDates(const char *dates); | 185 | void setExDates(const char *dates); |
185 | /** Add a date to the list of exceptions of the recurrence rule. */ | 186 | /** Add a date to the list of exceptions of the recurrence rule. */ |
186 | void addExDate(const QDate &date); | 187 | void addExDate(const QDate &date); |
187 | 188 | ||
188 | /** returns true if there is an exception for this date in the recurrence | 189 | /** returns true if there is an exception for this date in the recurrence |
189 | rule set, or false otherwise. */ | 190 | rule set, or false otherwise. */ |
190 | bool isException(const QDate &qd) const; | 191 | bool isException(const QDate &qd) const; |
191 | 192 | ||
192 | /** add attachment to this event */ | 193 | /** add attachment to this event */ |
193 | void addAttachment(Attachment *attachment); | 194 | void addAttachment(Attachment *attachment); |
194 | /** remove and delete a specific attachment */ | 195 | /** remove and delete a specific attachment */ |
195 | void deleteAttachment(Attachment *attachment); | 196 | void deleteAttachment(Attachment *attachment); |
196 | /** remove and delete all attachments with this mime type */ | 197 | /** remove and delete all attachments with this mime type */ |
197 | void deleteAttachments(const QString& mime); | 198 | void deleteAttachments(const QString& mime); |
198 | /** return list of all associated attachments */ | 199 | /** return list of all associated attachments */ |
199 | QPtrList<Attachment> attachments() const; | 200 | QPtrList<Attachment> attachments() const; |
200 | /** find a list of attachments with this mime type */ | 201 | /** find a list of attachments with this mime type */ |
201 | QPtrList<Attachment> attachments(const QString& mime) const; | 202 | QPtrList<Attachment> attachments(const QString& mime) const; |
202 | 203 | ||
203 | /** sets the event's status the value specified. See the enumeration | 204 | /** sets the event's status the value specified. See the enumeration |
204 | * above for possible values. */ | 205 | * above for possible values. */ |
205 | void setSecrecy(int); | 206 | void setSecrecy(int); |
206 | /** return the event's secrecy. */ | 207 | /** return the event's secrecy. */ |
207 | int secrecy() const; | 208 | int secrecy() const; |
208 | /** return the event's secrecy in string format. */ | 209 | /** return the event's secrecy in string format. */ |
209 | QString secrecyStr() const; | 210 | QString secrecyStr() const; |
210 | /** return list of all availbale secrecy classes */ | 211 | /** return list of all availbale secrecy classes */ |
211 | static QStringList secrecyList(); | 212 | static QStringList secrecyList(); |
212 | /** return human-readable name of secrecy class */ | 213 | /** return human-readable name of secrecy class */ |
213 | static QString secrecyName(int); | 214 | static QString secrecyName(int); |
214 | 215 | ||
215 | /** returns TRUE if the date specified is one on which the event will | 216 | /** returns TRUE if the date specified is one on which the event will |
216 | * recur. */ | 217 | * recur. */ |
217 | bool recursOn(const QDate &qd) const; | 218 | bool recursOn(const QDate &qd) const; |
218 | 219 | ||
219 | // VEVENT and VTODO, but not VJOURNAL (move to EventBase class?): | 220 | // VEVENT and VTODO, but not VJOURNAL (move to EventBase class?): |
220 | 221 | ||
221 | /** set resources used, such as Office, Car, etc. */ | 222 | /** set resources used, such as Office, Car, etc. */ |
222 | void setResources(const QStringList &resources); | 223 | void setResources(const QStringList &resources); |
223 | /** return list of current resources */ | 224 | /** return list of current resources */ |
224 | QStringList resources() const; | 225 | QStringList resources() const; |
225 | 226 | ||
226 | /** set the event's priority, 0 is undefined, 1 highest (decreasing order) */ | 227 | /** set the event's priority, 0 is undefined, 1 highest (decreasing order) */ |
227 | void setPriority(int priority); | 228 | void setPriority(int priority); |
228 | /** get the event's priority */ | 229 | /** get the event's priority */ |
229 | int priority() const; | 230 | int priority() const; |
230 | 231 | ||
231 | /** All alarms that are associated with this incidence */ | 232 | /** All alarms that are associated with this incidence */ |
232 | QPtrList<Alarm> alarms() const; | 233 | QPtrList<Alarm> alarms() const; |
233 | /** Create a new alarm which is associated with this incidence */ | 234 | /** Create a new alarm which is associated with this incidence */ |
234 | Alarm* newAlarm(); | 235 | Alarm* newAlarm(); |
235 | /** Add an alarm which is associated with this incidence */ | 236 | /** Add an alarm which is associated with this incidence */ |
236 | void addAlarm(Alarm*); | 237 | void addAlarm(Alarm*); |
237 | /** Remove an alarm that is associated with this incidence */ | 238 | /** Remove an alarm that is associated with this incidence */ |
238 | void removeAlarm(Alarm*); | 239 | void removeAlarm(Alarm*); |
239 | /** Remove all alarms that are associated with this incidence */ | 240 | /** Remove all alarms that are associated with this incidence */ |
240 | void clearAlarms(); | 241 | void clearAlarms(); |
241 | /** return whether any alarm associated with this incidence is enabled */ | 242 | /** return whether any alarm associated with this incidence is enabled */ |
242 | bool isAlarmEnabled() const; | 243 | bool isAlarmEnabled() const; |
243 | 244 | ||
244 | /** | 245 | /** |
245 | Return the recurrence rule associated with this incidence. If there is | 246 | Return the recurrence rule associated with this incidence. If there is |
246 | none, returns an appropriate (non-0) object. | 247 | none, returns an appropriate (non-0) object. |
247 | */ | 248 | */ |
248 | Recurrence *recurrence() const; | 249 | Recurrence *recurrence() const; |
249 | void setRecurrence(Recurrence * r); | 250 | void setRecurrence(Recurrence * r); |
250 | /** | 251 | /** |
251 | Forward to Recurrence::doesRecur(). | 252 | Forward to Recurrence::doesRecur(). |
252 | */ | 253 | */ |
253 | ushort doesRecur() const; | 254 | ushort doesRecur() const; |
254 | 255 | ||
255 | /** set the event's/todo's location. Do _not_ use it with journal */ | 256 | /** set the event's/todo's location. Do _not_ use it with journal */ |
256 | void setLocation(const QString &location); | 257 | void setLocation(const QString &location); |
257 | /** return the event's/todo's location. Do _not_ use it with journal */ | 258 | /** return the event's/todo's location. Do _not_ use it with journal */ |
258 | QString location() const; | 259 | QString location() const; |
259 | /** returns TRUE or FALSE depending on whether the todo has a start date */ | 260 | /** returns TRUE or FALSE depending on whether the todo has a start date */ |
260 | bool hasStartDate() const; | 261 | bool hasStartDate() const; |
261 | /** sets the event's hasStartDate value. */ | 262 | /** sets the event's hasStartDate value. */ |
262 | void setHasStartDate(bool f); | 263 | void setHasStartDate(bool f); |
263 | QDateTime getNextOccurence( const QDateTime& dt, bool* yes ) const; | 264 | QDateTime getNextOccurence( const QDateTime& dt, bool* yes ) const; |
264 | bool cancelled() const; | 265 | bool cancelled() const; |
265 | void setCancelled( bool b ); | 266 | void setCancelled( bool b ); |
266 | 267 | ||
267 | bool hasRecurrenceID() const; | 268 | bool hasRecurrenceID() const; |
268 | void setHasRecurrenceID( bool b ); | 269 | void setHasRecurrenceID( bool b ); |
269 | 270 | ||
270 | void setRecurrenceID(QDateTime); | 271 | void setRecurrenceID(QDateTime); |
271 | QDateTime recurrenceID () const; | 272 | QDateTime recurrenceID () const; |
272 | QDateTime dtStart() const; | 273 | QDateTime dtStart() const; |
273 | bool isHoliday() const; | 274 | bool isHoliday() const; |
274 | bool isBirthday() const; | 275 | bool isBirthday() const; |
275 | bool isAnniversary() const; | 276 | bool isAnniversary() const; |
276 | 277 | ||
277 | 278 | ||
278 | protected: | 279 | protected: |
279 | QPtrList<Alarm> mAlarms; | 280 | QPtrList<Alarm> mAlarms; |
280 | QPtrList<Incidence> mRelations; | 281 | QPtrList<Incidence> mRelations; |
281 | QDateTime mRecurrenceID; | 282 | QDateTime mRecurrenceID; |
282 | bool mHasRecurrenceID; | 283 | bool mHasRecurrenceID; |
283 | private: | 284 | private: |
284 | void checkCategories(); | 285 | void checkCategories(); |
285 | bool mHoliday, mBirthday, mAnniversary; | 286 | bool mHoliday, mBirthday, mAnniversary; |
286 | int mRevision; | 287 | int mRevision; |
287 | bool mCancelled; | 288 | bool mCancelled; |
288 | 289 | ||
289 | // base components of jounal, event and todo | 290 | // base components of jounal, event and todo |
290 | QDateTime mCreated; | 291 | QDateTime mCreated; |
291 | QString mDescription; | 292 | QString mDescription; |
292 | QString mSummary; | 293 | QString mSummary; |
293 | QStringList mCategories; | 294 | QStringList mCategories; |
294 | Incidence *mRelatedTo; | 295 | Incidence *mRelatedTo; |
295 | QString mRelatedToUid; | 296 | QString mRelatedToUid; |
296 | DateList mExDates; | 297 | DateList mExDates; |
297 | QPtrList<Attachment> mAttachments; | 298 | QPtrList<Attachment> mAttachments; |
298 | QStringList mResources; | 299 | QStringList mResources; |
299 | bool mHasStartDate; // if todo has associated start date | 300 | bool mHasStartDate; // if todo has associated start date |
300 | 301 | ||
301 | int mSecrecy; | 302 | int mSecrecy; |
302 | int mPriority; // 1 = highest, 2 = less, etc. | 303 | int mPriority; // 1 = highest, 2 = less, etc. |
303 | 304 | ||
304 | //QPtrList<Alarm> mAlarms; | 305 | //QPtrList<Alarm> mAlarms; |
305 | Recurrence *mRecurrence; | 306 | Recurrence *mRecurrence; |
306 | 307 | ||
307 | QString mLocation; | 308 | QString mLocation; |
308 | }; | 309 | }; |
309 | 310 | ||
310 | bool operator==( const Incidence&, const Incidence& ); | 311 | bool operator==( const Incidence&, const Incidence& ); |
311 | 312 | ||
312 | } | 313 | } |
313 | 314 | ||
314 | #endif | 315 | #endif |