summaryrefslogtreecommitdiffabout
path: root/libkcal/calendar.cpp
Unidiff
Diffstat (limited to 'libkcal/calendar.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/calendar.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp
index ed39ddb..7e8e2c5 100644
--- a/libkcal/calendar.cpp
+++ b/libkcal/calendar.cpp
@@ -164,312 +164,312 @@ 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
178void Calendar::setTimeZone(int tz) 178void 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
186int Calendar::getTimeZone() const 186int Calendar::getTimeZone() const
187{ 187{
188 return mTimeZone; 188 return mTimeZone;
189} 189}
190 190
191void Calendar::setTimeZoneId(const QString &id) 191void 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
202QString Calendar::timeZoneId() const 202QString Calendar::timeZoneId() const
203{ 203{
204 return mTimeZoneId; 204 return mTimeZoneId;
205} 205}
206 206
207void Calendar::setLocalTime() 207void 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
217bool Calendar::isLocalTime() const 217bool Calendar::isLocalTime() const
218{ 218{
219 return mLocalTime; 219 return mLocalTime;
220} 220}
221 221
222const QString &Calendar::getEmail() 222const QString &Calendar::getEmail()
223{ 223{
224 return mOwnerEmail; 224 return mOwnerEmail;
225} 225}
226 226
227void Calendar::setEmail(const QString &e) 227void 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
234void Calendar::setFilter(CalFilter *filter) 234void Calendar::setFilter(CalFilter *filter)
235{ 235{
236 mFilter = filter; 236 mFilter = filter;
237} 237}
238 238
239CalFilter *Calendar::filter() 239CalFilter *Calendar::filter()
240{ 240{
241 return mFilter; 241 return mFilter;
242} 242}
243 243
244QPtrList<Incidence> Calendar::incidences() 244QPtrList<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
262void Calendar::resetPilotStat(int id ) 262void 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}
277void Calendar::resetTempSyncStat() 277void 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}
292QPtrList<Incidence> Calendar::rawIncidences() 292QPtrList<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
310QPtrList<Event> Calendar::events( const QDate &date, bool sorted ) 310QPtrList<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
317QPtrList<Event> Calendar::events( const QDateTime &qdt ) 317QPtrList<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
324QPtrList<Event> Calendar::events( const QDate &start, const QDate &end, 324QPtrList<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
332QPtrList<Event> Calendar::events() 332QPtrList<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}
338void Calendar::addIncidenceBranch(Incidence *i) 338void Calendar::addIncidenceBranch(Incidence *i)
339{ 339{
340 addIncidence( i ); 340 addIncidence( i );
341 Incidence * inc; 341 Incidence * inc;
342 QPtrList<Incidence> Relations = i->relations(); 342 QPtrList<Incidence> Relations = i->relations();
343 for (inc=Relations.first();inc;inc=Relations.next()) { 343 for (inc=Relations.first();inc;inc=Relations.next()) {
344 addIncidenceBranch( inc ); 344 addIncidenceBranch( inc );
345 } 345 }
346} 346}
347 347
348bool Calendar::addIncidence(Incidence *i) 348bool Calendar::addIncidence(Incidence *i)
349{ 349{
350 Incidence::AddVisitor<Calendar> v(this); 350 Incidence::AddVisitor<Calendar> v(this);
351 351
352 return i->accept(v); 352 return i->accept(v);
353} 353}
354void Calendar::deleteIncidence(Incidence *in) 354void Calendar::deleteIncidence(Incidence *in)
355{ 355{
356 if ( in->type() == "Event" ) 356 if ( in->typeID() == eventID )
357 deleteEvent( (Event*) in ); 357 deleteEvent( (Event*) in );
358 else if ( in->type() =="Todo" ) 358 else if ( in->typeID() == todoID )
359 deleteTodo( (Todo*) in); 359 deleteTodo( (Todo*) in);
360 else if ( in->type() =="Journal" ) 360 else if ( in->typeID() == journalID )
361 deleteJournal( (Journal*) in ); 361 deleteJournal( (Journal*) in );
362} 362}
363 363
364Incidence* Calendar::incidence( const QString& uid ) 364Incidence* Calendar::incidence( const QString& uid )
365{ 365{
366 Incidence* i; 366 Incidence* i;
367 367
368 if( (i = todo( uid )) != 0 ) 368 if( (i = todo( uid )) != 0 )
369 return i; 369 return i;
370 if( (i = event( uid )) != 0 ) 370 if( (i = event( uid )) != 0 )
371 return i; 371 return i;
372 if( (i = journal( uid )) != 0 ) 372 if( (i = journal( uid )) != 0 )
373 return i; 373 return i;
374 374
375 return 0; 375 return 0;
376} 376}
377 377
378QPtrList<Todo> Calendar::todos() 378QPtrList<Todo> Calendar::todos()
379{ 379{
380 QPtrList<Todo> tl = rawTodos(); 380 QPtrList<Todo> tl = rawTodos();
381 mFilter->apply( &tl ); 381 mFilter->apply( &tl );
382 return tl; 382 return tl;
383} 383}
384 384
385// 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.
386// This method is only about linking related todos 386// This method is only about linking related todos
387void Calendar::setupRelations( Incidence *incidence ) 387void Calendar::setupRelations( Incidence *incidence )
388{ 388{
389 QString uid = incidence->uid(); 389 QString uid = incidence->uid();
390 //qDebug("Calendar::setupRelations "); 390 //qDebug("Calendar::setupRelations ");
391 // 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
392 while( Incidence* i = mOrphans[ uid ] ) { 392 while( Incidence* i = mOrphans[ uid ] ) {
393 mOrphans.remove( uid ); 393 mOrphans.remove( uid );
394 i->setRelatedTo( incidence ); 394 i->setRelatedTo( incidence );
395 incidence->addRelation( i ); 395 incidence->addRelation( i );
396 mOrphanUids.remove( i->uid() ); 396 mOrphanUids.remove( i->uid() );
397 } 397 }
398 398
399 // Now see about this incidences parent 399 // Now see about this incidences parent
400 if( !incidence->relatedTo() && !incidence->relatedToUid().isEmpty() ) { 400 if( !incidence->relatedTo() && !incidence->relatedToUid().isEmpty() ) {
401 // 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
402 // Try to find it 402 // Try to find it
403 Incidence* parent = this->incidence( incidence->relatedToUid() ); 403 Incidence* parent = this->incidence( incidence->relatedToUid() );
404 if( parent ) { 404 if( parent ) {
405 // Found it 405 // Found it
406 incidence->setRelatedTo( parent ); 406 incidence->setRelatedTo( parent );
407 parent->addRelation( incidence ); 407 parent->addRelation( incidence );
408 } else { 408 } else {
409 // Not found, put this in the mOrphans list 409 // Not found, put this in the mOrphans list
410 mOrphans.insert( incidence->relatedToUid(), incidence ); 410 mOrphans.insert( incidence->relatedToUid(), incidence );
411 mOrphanUids.insert( incidence->uid(), incidence ); 411 mOrphanUids.insert( incidence->uid(), incidence );
412 } 412 }
413 } 413 }
414} 414}
415 415
416// 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
417void Calendar::removeRelations( Incidence *incidence ) 417void Calendar::removeRelations( Incidence *incidence )
418{ 418{
419 // qDebug("Calendar::removeRelations "); 419 // qDebug("Calendar::removeRelations ");
420 QString uid = incidence->uid(); 420 QString uid = incidence->uid();
421 421
422 QPtrList<Incidence> relations = incidence->relations(); 422 QPtrList<Incidence> relations = incidence->relations();
423 for( Incidence* i = relations.first(); i; i = relations.next() ) 423 for( Incidence* i = relations.first(); i; i = relations.next() )
424 if( !mOrphanUids.find( i->uid() ) ) { 424 if( !mOrphanUids.find( i->uid() ) ) {
425 mOrphans.insert( uid, i ); 425 mOrphans.insert( uid, i );
426 mOrphanUids.insert( i->uid(), i ); 426 mOrphanUids.insert( i->uid(), i );
427 i->setRelatedTo( 0 ); 427 i->setRelatedTo( 0 );
428 i->setRelatedToUid( uid ); 428 i->setRelatedToUid( uid );
429 } 429 }
430 430
431 // 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
432 if( incidence->relatedTo() ) 432 if( incidence->relatedTo() )
433 incidence->relatedTo()->removeRelation( incidence ); 433 incidence->relatedTo()->removeRelation( incidence );
434 434
435 // Remove this one from the orphans list 435 // Remove this one from the orphans list
436 if( mOrphanUids.remove( uid ) ) 436 if( mOrphanUids.remove( uid ) )
437 // 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
438 if( !( incidence->relatedTo() != 0 && mOrphans.remove( incidence->relatedTo()->uid() ) ) ) { 438 if( !( incidence->relatedTo() != 0 && mOrphans.remove( incidence->relatedTo()->uid() ) ) ) {
439 // Removing wasn't that easy 439 // Removing wasn't that easy
440 for( QDictIterator<Incidence> it( mOrphans ); it.current(); ++it ) { 440 for( QDictIterator<Incidence> it( mOrphans ); it.current(); ++it ) {
441 if( it.current()->uid() == uid ) { 441 if( it.current()->uid() == uid ) {
442 mOrphans.remove( it.currentKey() ); 442 mOrphans.remove( it.currentKey() );
443 break; 443 break;
444 } 444 }
445 } 445 }
446 } 446 }
447} 447}
448 448
449void Calendar::registerObserver( Observer *observer ) 449void Calendar::registerObserver( Observer *observer )
450{ 450{
451 mObserver = observer; 451 mObserver = observer;
452 mNewObserver = true; 452 mNewObserver = true;
453} 453}
454 454
455void Calendar::setModified( bool modified ) 455void Calendar::setModified( bool modified )
456{ 456{
457 if ( mObserver ) mObserver->calendarModified( modified, this ); 457 if ( mObserver ) mObserver->calendarModified( modified, this );
458 if ( modified != mModified || mNewObserver ) { 458 if ( modified != mModified || mNewObserver ) {
459 mNewObserver = false; 459 mNewObserver = false;
460 // if ( mObserver ) mObserver->calendarModified( modified, this ); 460 // if ( mObserver ) mObserver->calendarModified( modified, this );
461 mModified = modified; 461 mModified = modified;
462 } 462 }
463} 463}
464 464
465void Calendar::setLoadedProductId( const QString &id ) 465void Calendar::setLoadedProductId( const QString &id )
466{ 466{
467 mLoadedProductId = id; 467 mLoadedProductId = id;
468} 468}
469 469
470QString Calendar::loadedProductId() 470QString Calendar::loadedProductId()
471{ 471{
472 return mLoadedProductId; 472 return mLoadedProductId;
473} 473}
474 474
475//#include "calendar.moc" 475//#include "calendar.moc"