-rw-r--r-- | libkcal/calendar.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp index a3977d7..eeb5f48 100644 --- a/libkcal/calendar.cpp +++ b/libkcal/calendar.cpp | |||
@@ -155,192 +155,208 @@ QString Calendar::getTimeZoneStr() const | |||
155 | if (mLocalTime) | 155 | if (mLocalTime) |
156 | return ""; | 156 | return ""; |
157 | QString tmpStr; | 157 | QString tmpStr; |
158 | int hours = abs(mTimeZone / 60); | 158 | int hours = abs(mTimeZone / 60); |
159 | int minutes = abs(mTimeZone % 60); | 159 | int minutes = abs(mTimeZone % 60); |
160 | bool neg = mTimeZone < 0; | 160 | bool neg = mTimeZone < 0; |
161 | 161 | ||
162 | tmpStr.sprintf("%c%.2d%.2d", | 162 | tmpStr.sprintf("%c%.2d%.2d", |
163 | (neg ? '-' : '+'), | 163 | (neg ? '-' : '+'), |
164 | hours, minutes); | 164 | hours, minutes); |
165 | return tmpStr; | 165 | return tmpStr; |
166 | } | 166 | } |
167 | 167 | ||
168 | void Calendar::setTimeZone(int tz) | 168 | void Calendar::setTimeZone(int tz) |
169 | { | 169 | { |
170 | mTimeZone = tz; | 170 | mTimeZone = tz; |
171 | mLocalTime = false; | 171 | mLocalTime = false; |
172 | 172 | ||
173 | setModified( true ); | 173 | setModified( true ); |
174 | } | 174 | } |
175 | 175 | ||
176 | int Calendar::getTimeZone() const | 176 | int Calendar::getTimeZone() const |
177 | { | 177 | { |
178 | return mTimeZone; | 178 | return mTimeZone; |
179 | } | 179 | } |
180 | 180 | ||
181 | void Calendar::setTimeZoneId(const QString &id) | 181 | void Calendar::setTimeZoneId(const QString &id) |
182 | { | 182 | { |
183 | mTimeZoneId = id; | 183 | mTimeZoneId = id; |
184 | mLocalTime = false; | 184 | mLocalTime = false; |
185 | mTimeZone = KGlobal::locale()->timezoneOffset(mTimeZoneId); | 185 | mTimeZone = KGlobal::locale()->timezoneOffset(mTimeZoneId); |
186 | if ( mTimeZone > 1000) | 186 | if ( mTimeZone > 1000) |
187 | setLocalTime(); | 187 | setLocalTime(); |
188 | //qDebug("Calendar::setTimeZoneOffset %s %d ",mTimeZoneId.latin1(), mTimeZone); | 188 | //qDebug("Calendar::setTimeZoneOffset %s %d ",mTimeZoneId.latin1(), mTimeZone); |
189 | setModified( true ); | 189 | setModified( true ); |
190 | } | 190 | } |
191 | 191 | ||
192 | QString Calendar::timeZoneId() const | 192 | QString Calendar::timeZoneId() const |
193 | { | 193 | { |
194 | return mTimeZoneId; | 194 | return mTimeZoneId; |
195 | } | 195 | } |
196 | 196 | ||
197 | void Calendar::setLocalTime() | 197 | void Calendar::setLocalTime() |
198 | { | 198 | { |
199 | //qDebug("Calendar::setLocalTime() "); | 199 | //qDebug("Calendar::setLocalTime() "); |
200 | mLocalTime = true; | 200 | mLocalTime = true; |
201 | mTimeZone = 0; | 201 | mTimeZone = 0; |
202 | mTimeZoneId = ""; | 202 | mTimeZoneId = ""; |
203 | 203 | ||
204 | setModified( true ); | 204 | setModified( true ); |
205 | } | 205 | } |
206 | 206 | ||
207 | bool Calendar::isLocalTime() const | 207 | bool Calendar::isLocalTime() const |
208 | { | 208 | { |
209 | return mLocalTime; | 209 | return mLocalTime; |
210 | } | 210 | } |
211 | 211 | ||
212 | const QString &Calendar::getEmail() | 212 | const QString &Calendar::getEmail() |
213 | { | 213 | { |
214 | return mOwnerEmail; | 214 | return mOwnerEmail; |
215 | } | 215 | } |
216 | 216 | ||
217 | void Calendar::setEmail(const QString &e) | 217 | void Calendar::setEmail(const QString &e) |
218 | { | 218 | { |
219 | mOwnerEmail = e; | 219 | mOwnerEmail = e; |
220 | 220 | ||
221 | setModified( true ); | 221 | setModified( true ); |
222 | } | 222 | } |
223 | 223 | ||
224 | void Calendar::setFilter(CalFilter *filter) | 224 | void Calendar::setFilter(CalFilter *filter) |
225 | { | 225 | { |
226 | mFilter = filter; | 226 | mFilter = filter; |
227 | } | 227 | } |
228 | 228 | ||
229 | CalFilter *Calendar::filter() | 229 | CalFilter *Calendar::filter() |
230 | { | 230 | { |
231 | return mFilter; | 231 | return mFilter; |
232 | } | 232 | } |
233 | 233 | ||
234 | QPtrList<Incidence> Calendar::incidences() | 234 | QPtrList<Incidence> Calendar::incidences() |
235 | { | 235 | { |
236 | QPtrList<Incidence> incidences; | 236 | QPtrList<Incidence> incidences; |
237 | 237 | ||
238 | Incidence *i; | 238 | Incidence *i; |
239 | 239 | ||
240 | QPtrList<Event> e = events(); | 240 | QPtrList<Event> e = events(); |
241 | for( i = e.first(); i; i = e.next() ) incidences.append( i ); | 241 | for( i = e.first(); i; i = e.next() ) incidences.append( i ); |
242 | 242 | ||
243 | QPtrList<Todo> t = todos(); | 243 | QPtrList<Todo> t = todos(); |
244 | for( i = t.first(); i; i = t.next() ) incidences.append( i ); | 244 | for( i = t.first(); i; i = t.next() ) incidences.append( i ); |
245 | 245 | ||
246 | QPtrList<Journal> j = journals(); | 246 | QPtrList<Journal> j = journals(); |
247 | for( i = j.first(); i; i = j.next() ) incidences.append( i ); | 247 | for( i = j.first(); i; i = j.next() ) incidences.append( i ); |
248 | 248 | ||
249 | return incidences; | 249 | return incidences; |
250 | } | 250 | } |
251 | |||
252 | void Calendar::resetPilotStat() | ||
253 | { | ||
254 | QPtrList<Incidence> incidences; | ||
255 | |||
256 | Incidence *i; | ||
257 | |||
258 | QPtrList<Event> e = rawEvents(); | ||
259 | for( i = e.first(); i; i = e.next() ) i->setPilotId( 0 ); | ||
260 | |||
261 | QPtrList<Todo> t = rawTodos(); | ||
262 | for( i = t.first(); i; i = t.next() ) i->setPilotId( 0 ); | ||
263 | |||
264 | QPtrList<Journal> j = journals(); | ||
265 | for( i = j.first(); i; i = j.next() ) i->setPilotId( 0 ); | ||
266 | } | ||
251 | void Calendar::resetTempSyncStat() | 267 | void Calendar::resetTempSyncStat() |
252 | { | 268 | { |
253 | QPtrList<Incidence> incidences; | 269 | QPtrList<Incidence> incidences; |
254 | 270 | ||
255 | Incidence *i; | 271 | Incidence *i; |
256 | 272 | ||
257 | QPtrList<Event> e = rawEvents(); | 273 | QPtrList<Event> e = rawEvents(); |
258 | for( i = e.first(); i; i = e.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 274 | for( i = e.first(); i; i = e.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
259 | 275 | ||
260 | QPtrList<Todo> t = rawTodos(); | 276 | QPtrList<Todo> t = rawTodos(); |
261 | for( i = t.first(); i; i = t.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 277 | for( i = t.first(); i; i = t.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
262 | 278 | ||
263 | QPtrList<Journal> j = journals(); | 279 | QPtrList<Journal> j = journals(); |
264 | for( i = j.first(); i; i = j.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 280 | for( i = j.first(); i; i = j.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
265 | } | 281 | } |
266 | QPtrList<Incidence> Calendar::rawIncidences() | 282 | QPtrList<Incidence> Calendar::rawIncidences() |
267 | { | 283 | { |
268 | QPtrList<Incidence> incidences; | 284 | QPtrList<Incidence> incidences; |
269 | 285 | ||
270 | Incidence *i; | 286 | Incidence *i; |
271 | 287 | ||
272 | QPtrList<Event> e = rawEvents(); | 288 | QPtrList<Event> e = rawEvents(); |
273 | for( i = e.first(); i; i = e.next() ) incidences.append( i ); | 289 | for( i = e.first(); i; i = e.next() ) incidences.append( i ); |
274 | 290 | ||
275 | QPtrList<Todo> t = rawTodos(); | 291 | QPtrList<Todo> t = rawTodos(); |
276 | for( i = t.first(); i; i = t.next() ) incidences.append( i ); | 292 | for( i = t.first(); i; i = t.next() ) incidences.append( i ); |
277 | 293 | ||
278 | QPtrList<Journal> j = journals(); | 294 | QPtrList<Journal> j = journals(); |
279 | for( i = j.first(); i; i = j.next() ) incidences.append( i ); | 295 | for( i = j.first(); i; i = j.next() ) incidences.append( i ); |
280 | 296 | ||
281 | return incidences; | 297 | return incidences; |
282 | } | 298 | } |
283 | 299 | ||
284 | QPtrList<Event> Calendar::events( const QDate &date, bool sorted ) | 300 | QPtrList<Event> Calendar::events( const QDate &date, bool sorted ) |
285 | { | 301 | { |
286 | QPtrList<Event> el = rawEventsForDate(date,sorted); | 302 | QPtrList<Event> el = rawEventsForDate(date,sorted); |
287 | mFilter->apply(&el); | 303 | mFilter->apply(&el); |
288 | return el; | 304 | return el; |
289 | } | 305 | } |
290 | 306 | ||
291 | QPtrList<Event> Calendar::events( const QDateTime &qdt ) | 307 | QPtrList<Event> Calendar::events( const QDateTime &qdt ) |
292 | { | 308 | { |
293 | QPtrList<Event> el = rawEventsForDate(qdt); | 309 | QPtrList<Event> el = rawEventsForDate(qdt); |
294 | mFilter->apply(&el); | 310 | mFilter->apply(&el); |
295 | return el; | 311 | return el; |
296 | } | 312 | } |
297 | 313 | ||
298 | QPtrList<Event> Calendar::events( const QDate &start, const QDate &end, | 314 | QPtrList<Event> Calendar::events( const QDate &start, const QDate &end, |
299 | bool inclusive) | 315 | bool inclusive) |
300 | { | 316 | { |
301 | QPtrList<Event> el = rawEvents(start,end,inclusive); | 317 | QPtrList<Event> el = rawEvents(start,end,inclusive); |
302 | mFilter->apply(&el); | 318 | mFilter->apply(&el); |
303 | return el; | 319 | return el; |
304 | } | 320 | } |
305 | 321 | ||
306 | QPtrList<Event> Calendar::events() | 322 | QPtrList<Event> Calendar::events() |
307 | { | 323 | { |
308 | QPtrList<Event> el = rawEvents(); | 324 | QPtrList<Event> el = rawEvents(); |
309 | mFilter->apply(&el); | 325 | mFilter->apply(&el); |
310 | return el; | 326 | return el; |
311 | } | 327 | } |
312 | 328 | ||
313 | 329 | ||
314 | bool Calendar::addIncidence(Incidence *i) | 330 | bool Calendar::addIncidence(Incidence *i) |
315 | { | 331 | { |
316 | Incidence::AddVisitor<Calendar> v(this); | 332 | Incidence::AddVisitor<Calendar> v(this); |
317 | 333 | ||
318 | return i->accept(v); | 334 | return i->accept(v); |
319 | } | 335 | } |
320 | void Calendar::deleteIncidence(Incidence *in) | 336 | void Calendar::deleteIncidence(Incidence *in) |
321 | { | 337 | { |
322 | if ( in->type() == "Event" ) | 338 | if ( in->type() == "Event" ) |
323 | deleteEvent( (Event*) in ); | 339 | deleteEvent( (Event*) in ); |
324 | else if ( in->type() =="Todo" ) | 340 | else if ( in->type() =="Todo" ) |
325 | deleteTodo( (Todo*) in); | 341 | deleteTodo( (Todo*) in); |
326 | else if ( in->type() =="Journal" ) | 342 | else if ( in->type() =="Journal" ) |
327 | deleteJournal( (Journal*) in ); | 343 | deleteJournal( (Journal*) in ); |
328 | } | 344 | } |
329 | 345 | ||
330 | Incidence* Calendar::incidence( const QString& uid ) | 346 | Incidence* Calendar::incidence( const QString& uid ) |
331 | { | 347 | { |
332 | Incidence* i; | 348 | Incidence* i; |
333 | 349 | ||
334 | if( (i = todo( uid )) != 0 ) | 350 | if( (i = todo( uid )) != 0 ) |
335 | return i; | 351 | return i; |
336 | if( (i = event( uid )) != 0 ) | 352 | if( (i = event( uid )) != 0 ) |
337 | return i; | 353 | return i; |
338 | if( (i = journal( uid )) != 0 ) | 354 | if( (i = journal( uid )) != 0 ) |
339 | return i; | 355 | return i; |
340 | 356 | ||
341 | return 0; | 357 | return 0; |
342 | } | 358 | } |
343 | 359 | ||
344 | QPtrList<Todo> Calendar::todos() | 360 | QPtrList<Todo> Calendar::todos() |
345 | { | 361 | { |
346 | QPtrList<Todo> tl = rawTodos(); | 362 | QPtrList<Todo> tl = rawTodos(); |