summaryrefslogtreecommitdiffabout
path: root/libkcal/calendarlocal.cpp
authorzautrix <zautrix>2005-07-04 08:17:48 (UTC)
committer zautrix <zautrix>2005-07-04 08:17:48 (UTC)
commite19b410f43c4fcf35d3d62fc312d1b5251068691 (patch) (unidiff)
treec3aecb6089dbb2e068ad072226e227c14cd8c2cf /libkcal/calendarlocal.cpp
parent068a89b64d8ef4cb49702ed53ab4e415a0b90a80 (diff)
downloadkdepimpi-e19b410f43c4fcf35d3d62fc312d1b5251068691.zip
kdepimpi-e19b410f43c4fcf35d3d62fc312d1b5251068691.tar.gz
kdepimpi-e19b410f43c4fcf35d3d62fc312d1b5251068691.tar.bz2
fixes
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
@@ -202,49 +202,50 @@ bool CalendarLocal::addAnniversaryNoDup( Event *event )
202 return false; 202 return false;
203 } 203 }
204 return addEvent( event ); 204 return addEvent( event );
205 205
206} 206}
207bool CalendarLocal::addEventNoDup( Event *event ) 207bool CalendarLocal::addEventNoDup( Event *event )
208{ 208{
209 Event * eve; 209 Event * eve;
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 )
243{ 244{
244 Event *event; 245 Event *event;
245 Event *retVal = 0; 246 Event *retVal = 0;
246 for ( event = mEventList.first(); event; event = mEventList.next() ) { 247 for ( event = mEventList.first(); event; event = mEventList.next() ) {
247 if ( event->calEnabled() && event->uid() == uid ) { 248 if ( event->calEnabled() && event->uid() == uid ) {
248 if ( retVal ) { 249 if ( retVal ) {
249 if ( retVal->calID() > event->calID() ) { 250 if ( retVal->calID() > event->calID() ) {
250 retVal = event; 251 retVal = event;
@@ -256,48 +257,49 @@ Event *CalendarLocal::event( const QString &uid )
256 } 257 }
257 return retVal; 258 return retVal;
258} 259}
259bool CalendarLocal::addTodoNoDup( Todo *todo ) 260bool CalendarLocal::addTodoNoDup( Todo *todo )
260{ 261{
261 Todo * eve; 262 Todo * eve;
262 for ( eve = mTodoList.first(); eve ; eve = mTodoList.next() ) { 263 for ( eve = mTodoList.first(); eve ; eve = mTodoList.next() ) {
263 if ( *eve == *todo ) { 264 if ( *eve == *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}
296 298
297QPtrList<Todo> CalendarLocal::rawTodos() 299QPtrList<Todo> CalendarLocal::rawTodos()
298{ 300{
299 QPtrList<Todo> el; 301 QPtrList<Todo> el;
300 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) 302 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() )
301 if ( it->calEnabled() ) el.append( it ); 303 if ( it->calEnabled() ) el.append( it );
302 return el; 304 return el;
303} 305}
@@ -760,49 +762,50 @@ QPtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end,
760 762
761 return eventList; 763 return eventList;
762} 764}
763 765
764QPtrList<Event> CalendarLocal::rawEventsForDate( const QDateTime &qdt ) 766QPtrList<Event> CalendarLocal::rawEventsForDate( const QDateTime &qdt )
765{ 767{
766 return rawEventsForDate( qdt.date() ); 768 return rawEventsForDate( qdt.date() );
767} 769}
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{
801 QPtrList<Journal> el; 804 QPtrList<Journal> el;
802 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) 805 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
803 if ( it->calEnabled() && it->dtStart().date() == date) el.append( it ); 806 if ( it->calEnabled() && it->dtStart().date() == date) el.append( it );
804 return el; 807 return el;
805} 808}
806Journal *CalendarLocal::journal( const QDate &date ) 809Journal *CalendarLocal::journal( const QDate &date )
807{ 810{
808// kdDebug(5800) << "CalendarLocal::journal() " << date.toString() << endl; 811// kdDebug(5800) << "CalendarLocal::journal() " << date.toString() << endl;