summaryrefslogtreecommitdiffabout
path: root/libkcal/calendarlocal.cpp
authorzautrix <zautrix>2005-07-30 14:43:57 (UTC)
committer zautrix <zautrix>2005-07-30 14:43:57 (UTC)
commit9ca2cd947f22d33543e065f54c6487e86d80befa (patch) (unidiff)
tree549192e9e27e8972e2b48cf40e1599118df12da5 /libkcal/calendarlocal.cpp
parent055928e26613f4ab249bd82be86890ed278372f6 (diff)
downloadkdepimpi-9ca2cd947f22d33543e065f54c6487e86d80befa.zip
kdepimpi-9ca2cd947f22d33543e065f54c6487e86d80befa.tar.gz
kdepimpi-9ca2cd947f22d33543e065f54c6487e86d80befa.tar.bz2
fixxx
Diffstat (limited to 'libkcal/calendarlocal.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/calendarlocal.cpp26
1 files changed, 5 insertions, 21 deletions
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index e8c969f..1a1c6be 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -259,38 +259,25 @@ void CalendarLocal::close()
259 mJournalList.setAutoDelete( true ); 259 mJournalList.setAutoDelete( true );
260 260
261 mEventList.clear(); 261 mEventList.clear();
262 mTodoList.clear(); 262 mTodoList.clear();
263 mJournalList.clear(); 263 mJournalList.clear();
264 264
265 mEventList.setAutoDelete( false ); 265 mEventList.setAutoDelete( false );
266 mTodoList.setAutoDelete( false ); 266 mTodoList.setAutoDelete( false );
267 mJournalList.setAutoDelete( false ); 267 mJournalList.setAutoDelete( false );
268 268
269 setModified( false ); 269 setModified( false );
270} 270}
271 void CalendarLocal::clearUndo() 271
272{
273 if ( mUndoIncidence ) {
274 if ( mUndoIncidence->typeID() == eventID )
275 delete ((Event*) mUndoIncidence) ;
276 else if ( mUndoIncidence->typeID() == todoID )
277 delete ( (Todo*) mUndoIncidence );
278 else if ( mUndoIncidence->typeID() == journalID )
279 delete ( (Journal*) mUndoIncidence );
280 else
281 delete mUndoIncidence;
282 }
283 mUndoIncidence = 0;
284}
285bool CalendarLocal::addAnniversaryNoDup( Event *event ) 272bool CalendarLocal::addAnniversaryNoDup( Event *event )
286{ 273{
287 QString cat; 274 QString cat;
288 bool isBirthday = true; 275 bool isBirthday = true;
289 if( event->categoriesStr() == i18n( "Anniversary" ) ) { 276 if( event->categoriesStr() == i18n( "Anniversary" ) ) {
290 isBirthday = false; 277 isBirthday = false;
291 cat = i18n( "Anniversary" ); 278 cat = i18n( "Anniversary" );
292 } else if( event->categoriesStr() == i18n( "Birthday" ) ) { 279 } else if( event->categoriesStr() == i18n( "Birthday" ) ) {
293 isBirthday = true; 280 isBirthday = true;
294 cat = i18n( "Birthday" ); 281 cat = i18n( "Birthday" );
295 } else { 282 } else {
296 qDebug("addAnniversaryNoDup called without fitting category! "); 283 qDebug("addAnniversaryNoDup called without fitting category! ");
@@ -331,26 +318,25 @@ bool CalendarLocal::addEvent( Event *event )
331 event->registerObserver( this ); 318 event->registerObserver( this );
332 319
333 setModified( true ); 320 setModified( true );
334 if ( event->calID() == 0 ) 321 if ( event->calID() == 0 )
335 event->setCalID( mDefaultCalendar ); 322 event->setCalID( mDefaultCalendar );
336 event->setCalEnabled( true ); 323 event->setCalEnabled( true );
337 324
338 return true; 325 return true;
339} 326}
340 327
341void CalendarLocal::deleteEvent( Event *event ) 328void CalendarLocal::deleteEvent( Event *event )
342{ 329{
343 clearUndo(); 330 clearUndo(event);
344 mUndoIncidence = event;
345 if ( mEventList.removeRef( event ) ) { 331 if ( mEventList.removeRef( event ) ) {
346 setModified( true ); 332 setModified( true );
347 } 333 }
348} 334}
349 335
350 336
351Event *CalendarLocal::event( const QString &uid ) 337Event *CalendarLocal::event( const QString &uid )
352{ 338{
353 Event *event; 339 Event *event;
354 Event *retVal = 0; 340 Event *retVal = 0;
355 for ( event = mEventList.first(); event; event = mEventList.next() ) { 341 for ( event = mEventList.first(); event; event = mEventList.next() ) {
356 if ( event->calEnabled() && event->uid() == uid ) { 342 if ( event->calEnabled() && event->uid() == uid ) {
@@ -386,27 +372,26 @@ bool CalendarLocal::addTodo( Todo *todo )
386 setupRelations( todo ); 372 setupRelations( todo );
387 373
388 setModified( true ); 374 setModified( true );
389 if ( todo->calID() == 0 ) 375 if ( todo->calID() == 0 )
390 todo->setCalID( mDefaultCalendar ); 376 todo->setCalID( mDefaultCalendar );
391 todo->setCalEnabled( true ); 377 todo->setCalEnabled( true );
392 return true; 378 return true;
393} 379}
394 380
395void CalendarLocal::deleteTodo( Todo *todo ) 381void CalendarLocal::deleteTodo( Todo *todo )
396{ 382{
397 // Handle orphaned children 383 // Handle orphaned children
398 clearUndo();
399 removeRelations( todo ); 384 removeRelations( todo );
400 mUndoIncidence = todo; 385 clearUndo(todo);
401 386
402 if ( mTodoList.removeRef( todo ) ) { 387 if ( mTodoList.removeRef( todo ) ) {
403 setModified( true ); 388 setModified( true );
404 } 389 }
405} 390}
406 391
407QPtrList<Todo> CalendarLocal::rawTodos() 392QPtrList<Todo> CalendarLocal::rawTodos()
408{ 393{
409 QPtrList<Todo> el; 394 QPtrList<Todo> el;
410 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) 395 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() )
411 if ( it->calEnabled() ) el.append( it ); 396 if ( it->calEnabled() ) el.append( it );
412 return el; 397 return el;
@@ -890,26 +875,25 @@ bool CalendarLocal::addJournal(Journal *journal)
890 875
891 journal->registerObserver( this ); 876 journal->registerObserver( this );
892 877
893 setModified( true ); 878 setModified( true );
894 if ( journal->calID() == 0 ) 879 if ( journal->calID() == 0 )
895 journal->setCalID( mDefaultCalendar ); 880 journal->setCalID( mDefaultCalendar );
896 journal->setCalEnabled( true ); 881 journal->setCalEnabled( true );
897 return true; 882 return true;
898} 883}
899 884
900void CalendarLocal::deleteJournal( Journal *journal ) 885void CalendarLocal::deleteJournal( Journal *journal )
901{ 886{
902 clearUndo(); 887 clearUndo(journal);
903 mUndoIncidence = journal;
904 if ( mJournalList.removeRef(journal) ) { 888 if ( mJournalList.removeRef(journal) ) {
905 setModified( true ); 889 setModified( true );
906 } 890 }
907} 891}
908 892
909QPtrList<Journal> CalendarLocal::journals4Date( const QDate & date ) 893QPtrList<Journal> CalendarLocal::journals4Date( const QDate & date )
910{ 894{
911 QPtrList<Journal> el; 895 QPtrList<Journal> el;
912 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) 896 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
913 if ( it->calEnabled() && it->dtStart().date() == date) el.append( it ); 897 if ( it->calEnabled() && it->dtStart().date() == date) el.append( it );
914 return el; 898 return el;
915} 899}
@@ -970,25 +954,25 @@ void CalendarLocal::setCalendarRemove( int id )
970 } 954 }
971 } 955 }
972 { 956 {
973 QPtrList<Journal> JournalList = mJournalList; 957 QPtrList<Journal> JournalList = mJournalList;
974 Journal * ev = JournalList.first(); 958 Journal * ev = JournalList.first();
975 while ( ev ) { 959 while ( ev ) {
976 if ( ev->calID() == id ) 960 if ( ev->calID() == id )
977 deleteJournal( ev ); 961 deleteJournal( ev );
978 ev = JournalList.next(); 962 ev = JournalList.next();
979 } 963 }
980 } 964 }
981 965
982 clearUndo(); 966 clearUndo(0);
983 967
984} 968}
985 969
986void CalendarLocal::setCalendarEnabled( int id, bool enable ) 970void CalendarLocal::setCalendarEnabled( int id, bool enable )
987{ 971{
988 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) 972 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
989 if ( it->calID() == id ) it->setCalEnabled( enable ); 973 if ( it->calID() == id ) it->setCalEnabled( enable );
990 974
991 for ( Event *it = mEventList.first(); it; it = mEventList.next() ) 975 for ( Event *it = mEventList.first(); it; it = mEventList.next() )
992 if ( it->calID() == id ) it->setCalEnabled( enable ); 976 if ( it->calID() == id ) it->setCalEnabled( enable );
993 977
994 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) 978 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() )