summaryrefslogtreecommitdiffabout
path: root/libkcal/calendarlocal.cpp
Unidiff
Diffstat (limited to 'libkcal/calendarlocal.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/calendarlocal.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index ca64e66..cce798f 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -210,33 +210,34 @@ bool CalendarLocal::addEventNoDup( Event *event )
210 for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) { 210 for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) {
211 if ( *eve == *event ) { 211 if ( *eve == *event ) {
212 //qDebug("CalendarLocal::Duplicate event found! Not inserted! "); 212 //qDebug("CalendarLocal::Duplicate event found! Not inserted! ");
213 return false; 213 return false;
214 } 214 }
215 } 215 }
216 return addEvent( event ); 216 return addEvent( event );
217} 217}
218 218
219bool CalendarLocal::addEvent( Event *event ) 219bool CalendarLocal::addEvent( Event *event )
220{ 220{
221 insertEvent( event ); 221 insertEvent( event );
222 222
223 event->registerObserver( this ); 223 event->registerObserver( this );
224 224
225 setModified( true ); 225 setModified( true );
226 event->setCalID( mDefaultCalendar ); 226 if ( event->calID() == 0 )
227 event->setCalID( mDefaultCalendar );
227 event->setCalEnabled( true ); 228 event->setCalEnabled( true );
228 229
229 return true; 230 return true;
230} 231}
231 232
232void CalendarLocal::deleteEvent( Event *event ) 233void CalendarLocal::deleteEvent( Event *event )
233{ 234{
234 if ( mUndoIncidence ) delete mUndoIncidence; 235 if ( mUndoIncidence ) delete mUndoIncidence;
235 mUndoIncidence = event->clone(); 236 mUndoIncidence = event->clone();
236 if ( mEventList.removeRef( event ) ) { 237 if ( mEventList.removeRef( event ) ) {
237 setModified( true ); 238 setModified( true );
238 } 239 }
239} 240}
240 241
241 242
242Event *CalendarLocal::event( const QString &uid ) 243Event *CalendarLocal::event( const QString &uid )
@@ -264,32 +265,33 @@ bool CalendarLocal::addTodoNoDup( Todo *todo )
264 //qDebug("duplicate todo found! not inserted! "); 265 //qDebug("duplicate todo found! not inserted! ");
265 return false; 266 return false;
266 } 267 }
267 } 268 }
268 return addTodo( todo ); 269 return addTodo( todo );
269} 270}
270bool CalendarLocal::addTodo( Todo *todo ) 271bool CalendarLocal::addTodo( Todo *todo )
271{ 272{
272 mTodoList.append( todo ); 273 mTodoList.append( todo );
273 274
274 todo->registerObserver( this ); 275 todo->registerObserver( this );
275 276
276 // Set up subtask relations 277 // Set up subtask relations
277 setupRelations( todo ); 278 setupRelations( todo );
278 279
279 setModified( true ); 280 setModified( true );
281 if ( todo->calID() == 0 )
280 todo->setCalID( mDefaultCalendar ); 282 todo->setCalID( mDefaultCalendar );
281 todo->setCalEnabled( true ); 283 todo->setCalEnabled( true );
282 return true; 284 return true;
283} 285}
284 286
285void CalendarLocal::deleteTodo( Todo *todo ) 287void CalendarLocal::deleteTodo( Todo *todo )
286{ 288{
287 // Handle orphaned children 289 // Handle orphaned children
288 if ( mUndoIncidence ) delete mUndoIncidence; 290 if ( mUndoIncidence ) delete mUndoIncidence;
289 removeRelations( todo ); 291 removeRelations( todo );
290 mUndoIncidence = todo->clone(); 292 mUndoIncidence = todo->clone();
291 293
292 if ( mTodoList.removeRef( todo ) ) { 294 if ( mTodoList.removeRef( todo ) ) {
293 setModified( true ); 295 setModified( true );
294 } 296 }
295} 297}
@@ -768,33 +770,34 @@ QPtrList<Event> CalendarLocal::rawEventsForDate( const QDateTime &qdt )
768 770
769QPtrList<Event> CalendarLocal::rawEvents() 771QPtrList<Event> CalendarLocal::rawEvents()
770{ 772{
771 QPtrList<Event> el; 773 QPtrList<Event> el;
772 for ( Event *it = mEventList.first(); it; it = mEventList.next() ) 774 for ( Event *it = mEventList.first(); it; it = mEventList.next() )
773 if ( it->calEnabled() ) el.append( it ); 775 if ( it->calEnabled() ) el.append( it );
774 return el; 776 return el;
775} 777}
776 778
777bool CalendarLocal::addJournal(Journal *journal) 779bool CalendarLocal::addJournal(Journal *journal)
778{ 780{
779 mJournalList.append(journal); 781 mJournalList.append(journal);
780 782
781 journal->registerObserver( this ); 783 journal->registerObserver( this );
782 784
783 setModified( true ); 785 setModified( true );
784 journal->setCalID( mDefaultCalendar ); 786 if ( journal->calID() == 0 )
787 journal->setCalID( mDefaultCalendar );
785 journal->setCalEnabled( true ); 788 journal->setCalEnabled( true );
786 return true; 789 return true;
787} 790}
788 791
789void CalendarLocal::deleteJournal( Journal *journal ) 792void CalendarLocal::deleteJournal( Journal *journal )
790{ 793{
791 if ( mUndoIncidence ) delete mUndoIncidence; 794 if ( mUndoIncidence ) delete mUndoIncidence;
792 mUndoIncidence = journal->clone(); 795 mUndoIncidence = journal->clone();
793 mUndoIncidence->setSummary( mUndoIncidence->description().left(25)); 796 mUndoIncidence->setSummary( mUndoIncidence->description().left(25));
794 if ( mJournalList.removeRef(journal) ) { 797 if ( mJournalList.removeRef(journal) ) {
795 setModified( true ); 798 setModified( true );
796 } 799 }
797} 800}
798 801
799QPtrList<Journal> CalendarLocal::journals4Date( const QDate & date ) 802QPtrList<Journal> CalendarLocal::journals4Date( const QDate & date )
800{ 803{