summaryrefslogtreecommitdiffabout
path: root/libkcal/calendarlocal.cpp
Unidiff
Diffstat (limited to 'libkcal/calendarlocal.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/calendarlocal.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index 3f46d53..12294c0 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -27,306 +27,308 @@
27#include <kdebug.h> 27#include <kdebug.h>
28#include <kconfig.h> 28#include <kconfig.h>
29#include <kglobal.h> 29#include <kglobal.h>
30#include <klocale.h> 30#include <klocale.h>
31 31
32#include "vcaldrag.h" 32#include "vcaldrag.h"
33#include "vcalformat.h" 33#include "vcalformat.h"
34#include "icalformat.h" 34#include "icalformat.h"
35#include "exceptions.h" 35#include "exceptions.h"
36#include "incidence.h" 36#include "incidence.h"
37#include "journal.h" 37#include "journal.h"
38#include "filestorage.h" 38#include "filestorage.h"
39#include "calfilter.h" 39#include "calfilter.h"
40 40
41#include "calendarlocal.h" 41#include "calendarlocal.h"
42 42
43// #ifndef DESKTOP_VERSION 43// #ifndef DESKTOP_VERSION
44// #include <qtopia/alarmserver.h> 44// #include <qtopia/alarmserver.h>
45// #endif 45// #endif
46using namespace KCal; 46using namespace KCal;
47 47
48CalendarLocal::CalendarLocal() 48CalendarLocal::CalendarLocal()
49 : Calendar() 49 : Calendar()
50{ 50{
51 init(); 51 init();
52} 52}
53 53
54CalendarLocal::CalendarLocal(const QString &timeZoneId) 54CalendarLocal::CalendarLocal(const QString &timeZoneId)
55 : Calendar(timeZoneId) 55 : Calendar(timeZoneId)
56{ 56{
57 init(); 57 init();
58} 58}
59 59
60void CalendarLocal::init() 60void CalendarLocal::init()
61{ 61{
62 mNextAlarmIncidence = 0; 62 mNextAlarmIncidence = 0;
63} 63}
64 64
65 65
66CalendarLocal::~CalendarLocal() 66CalendarLocal::~CalendarLocal()
67{ 67{
68 close(); 68 close();
69} 69}
70 70
71bool CalendarLocal::load( const QString &fileName ) 71bool CalendarLocal::load( const QString &fileName )
72{ 72{
73 FileStorage storage( this, fileName ); 73 FileStorage storage( this, fileName );
74 return storage.load(); 74 return storage.load();
75} 75}
76 76
77bool CalendarLocal::save( const QString &fileName, CalFormat *format ) 77bool CalendarLocal::save( const QString &fileName, CalFormat *format )
78{ 78{
79 FileStorage storage( this, fileName, format ); 79 FileStorage storage( this, fileName, format );
80 return storage.save(); 80 return storage.save();
81} 81}
82 82
83void CalendarLocal::close() 83void CalendarLocal::close()
84{ 84{
85 mEventList.setAutoDelete( true ); 85 mEventList.setAutoDelete( true );
86 mTodoList.setAutoDelete( true ); 86 mTodoList.setAutoDelete( true );
87 mJournalList.setAutoDelete( false ); 87 mJournalList.setAutoDelete( false );
88 88
89 mEventList.clear(); 89 mEventList.clear();
90 mTodoList.clear(); 90 mTodoList.clear();
91 mJournalList.clear(); 91 mJournalList.clear();
92 92
93 mEventList.setAutoDelete( false ); 93 mEventList.setAutoDelete( false );
94 mTodoList.setAutoDelete( false ); 94 mTodoList.setAutoDelete( false );
95 mJournalList.setAutoDelete( false ); 95 mJournalList.setAutoDelete( false );
96 96
97 setModified( false ); 97 setModified( false );
98} 98}
99 99
100bool CalendarLocal::addAnniversaryNoDup( Event *event ) 100bool CalendarLocal::addAnniversaryNoDup( Event *event )
101{ 101{
102 QString cat; 102 QString cat;
103 bool isBirthday = true; 103 bool isBirthday = true;
104 if( event->categoriesStr() == i18n( "Anniversary" ) ) { 104 if( event->categoriesStr() == i18n( "Anniversary" ) ) {
105 isBirthday = false; 105 isBirthday = false;
106 cat = i18n( "Anniversary" ); 106 cat = i18n( "Anniversary" );
107 } else if( event->categoriesStr() == i18n( "Birthday" ) ) { 107 } else if( event->categoriesStr() == i18n( "Birthday" ) ) {
108 isBirthday = true; 108 isBirthday = true;
109 cat = i18n( "Birthday" ); 109 cat = i18n( "Birthday" );
110 } else { 110 } else {
111 qDebug("addAnniversaryNoDup called without fitting category! "); 111 qDebug("addAnniversaryNoDup called without fitting category! ");
112 return false; 112 return false;
113 } 113 }
114 Event * eve; 114 Event * eve;
115 for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) { 115 for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) {
116 if ( !(eve->categories().contains( cat ) )) 116 if ( !(eve->categories().contains( cat ) ))
117 continue; 117 continue;
118 // now we have an event with fitting category 118 // now we have an event with fitting category
119 if ( eve->dtStart().date() != event->dtStart().date() ) 119 if ( eve->dtStart().date() != event->dtStart().date() )
120 continue; 120 continue;
121 // now we have an event with fitting category+date 121 // now we have an event with fitting category+date
122 if ( eve->summary() != event->summary() ) 122 if ( eve->summary() != event->summary() )
123 continue; 123 continue;
124 // now we have an event with fitting category+date+summary 124 // now we have an event with fitting category+date+summary
125 return false; 125 return false;
126 } 126 }
127 return addEvent( event ); 127 return addEvent( event );
128 128
129} 129}
130bool CalendarLocal::addEventNoDup( Event *event ) 130bool CalendarLocal::addEventNoDup( Event *event )
131{ 131{
132 Event * eve; 132 Event * eve;
133 for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) { 133 for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) {
134 if ( *eve == *event ) { 134 if ( *eve == *event ) {
135 //qDebug("CalendarLocal::Duplicate event found! Not inserted! "); 135 //qDebug("CalendarLocal::Duplicate event found! Not inserted! ");
136 return false; 136 return false;
137 } 137 }
138 } 138 }
139 return addEvent( event ); 139 return addEvent( event );
140} 140}
141 141
142bool CalendarLocal::addEvent( Event *event ) 142bool CalendarLocal::addEvent( Event *event )
143{ 143{
144 insertEvent( event ); 144 insertEvent( event );
145 145
146 event->registerObserver( this ); 146 event->registerObserver( this );
147 147
148 setModified( true ); 148 setModified( true );
149 149
150 return true; 150 return true;
151} 151}
152 152
153void CalendarLocal::deleteEvent( Event *event ) 153void CalendarLocal::deleteEvent( Event *event )
154{ 154{
155 155 if ( mUndoIncidence ) delete mUndoIncidence;
156 156 mUndoIncidence = event->clone();
157 if ( mEventList.removeRef( event ) ) { 157 if ( mEventList.removeRef( event ) ) {
158 setModified( true ); 158 setModified( true );
159 } 159 }
160} 160}
161 161
162 162
163Event *CalendarLocal::event( const QString &uid ) 163Event *CalendarLocal::event( const QString &uid )
164{ 164{
165 165
166 Event *event; 166 Event *event;
167 167
168 for ( event = mEventList.first(); event; event = mEventList.next() ) { 168 for ( event = mEventList.first(); event; event = mEventList.next() ) {
169 if ( event->uid() == uid ) { 169 if ( event->uid() == uid ) {
170 return event; 170 return event;
171 } 171 }
172 } 172 }
173 173
174 return 0; 174 return 0;
175} 175}
176bool CalendarLocal::addTodoNoDup( Todo *todo ) 176bool CalendarLocal::addTodoNoDup( Todo *todo )
177{ 177{
178 Todo * eve; 178 Todo * eve;
179 for ( eve = mTodoList.first(); eve ; eve = mTodoList.next() ) { 179 for ( eve = mTodoList.first(); eve ; eve = mTodoList.next() ) {
180 if ( *eve == *todo ) { 180 if ( *eve == *todo ) {
181 //qDebug("duplicate todo found! not inserted! "); 181 //qDebug("duplicate todo found! not inserted! ");
182 return false; 182 return false;
183 } 183 }
184 } 184 }
185 return addTodo( todo ); 185 return addTodo( todo );
186} 186}
187bool CalendarLocal::addTodo( Todo *todo ) 187bool CalendarLocal::addTodo( Todo *todo )
188{ 188{
189 mTodoList.append( todo ); 189 mTodoList.append( todo );
190 190
191 todo->registerObserver( this ); 191 todo->registerObserver( this );
192 192
193 // Set up subtask relations 193 // Set up subtask relations
194 setupRelations( todo ); 194 setupRelations( todo );
195 195
196 setModified( true ); 196 setModified( true );
197 197
198 return true; 198 return true;
199} 199}
200 200
201void CalendarLocal::deleteTodo( Todo *todo ) 201void CalendarLocal::deleteTodo( Todo *todo )
202{ 202{
203 // Handle orphaned children 203 // Handle orphaned children
204 removeRelations( todo ); 204 if ( mUndoIncidence ) delete mUndoIncidence;
205 mUndoIncidence = todo->clone();
206 removeRelations( todo );
205 207
206 if ( mTodoList.removeRef( todo ) ) { 208 if ( mTodoList.removeRef( todo ) ) {
207 setModified( true ); 209 setModified( true );
208 } 210 }
209} 211}
210 212
211QPtrList<Todo> CalendarLocal::rawTodos() 213QPtrList<Todo> CalendarLocal::rawTodos()
212{ 214{
213 return mTodoList; 215 return mTodoList;
214} 216}
215Todo *CalendarLocal::todo( QString syncProf, QString id ) 217Todo *CalendarLocal::todo( QString syncProf, QString id )
216{ 218{
217 Todo *todo; 219 Todo *todo;
218 for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { 220 for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) {
219 if ( todo->getID( syncProf ) == id ) return todo; 221 if ( todo->getID( syncProf ) == id ) return todo;
220 } 222 }
221 223
222 return 0; 224 return 0;
223} 225}
224void CalendarLocal::removeSyncInfo( QString syncProfile) 226void CalendarLocal::removeSyncInfo( QString syncProfile)
225{ 227{
226 QPtrList<Incidence> all = rawIncidences() ; 228 QPtrList<Incidence> all = rawIncidences() ;
227 Incidence *inc; 229 Incidence *inc;
228 for ( inc = all.first(); inc; inc = all.next() ) { 230 for ( inc = all.first(); inc; inc = all.next() ) {
229 inc->removeID( syncProfile ); 231 inc->removeID( syncProfile );
230 } 232 }
231 if ( syncProfile.isEmpty() ) { 233 if ( syncProfile.isEmpty() ) {
232 QPtrList<Event> el; 234 QPtrList<Event> el;
233 Event *todo; 235 Event *todo;
234 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { 236 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) {
235 if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) 237 if ( todo->uid().left( 15 ) == QString("last-syncEvent-") )
236 el.append( todo ); 238 el.append( todo );
237 } 239 }
238 for ( todo = el.first(); todo; todo = el.next() ) { 240 for ( todo = el.first(); todo; todo = el.next() ) {
239 deleteIncidence ( todo ); 241 deleteIncidence ( todo );
240 } 242 }
241 } else { 243 } else {
242 Event *lse = event( "last-syncEvent-"+ syncProfile); 244 Event *lse = event( "last-syncEvent-"+ syncProfile);
243 deleteIncidence ( lse ); 245 deleteIncidence ( lse );
244 } 246 }
245} 247}
246QPtrList<Event> CalendarLocal::getExternLastSyncEvents() 248QPtrList<Event> CalendarLocal::getExternLastSyncEvents()
247{ 249{
248 QPtrList<Event> el; 250 QPtrList<Event> el;
249 Event *todo; 251 Event *todo;
250 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { 252 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) {
251 if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) 253 if ( todo->uid().left( 15 ) == QString("last-syncEvent-") )
252 if ( todo->summary().left(3) == "E: " ) 254 if ( todo->summary().left(3) == "E: " )
253 el.append( todo ); 255 el.append( todo );
254 } 256 }
255 257
256 return el; 258 return el;
257 259
258} 260}
259Event *CalendarLocal::event( QString syncProf, QString id ) 261Event *CalendarLocal::event( QString syncProf, QString id )
260{ 262{
261 Event *todo; 263 Event *todo;
262 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { 264 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) {
263 if ( todo->getID( syncProf ) == id ) return todo; 265 if ( todo->getID( syncProf ) == id ) return todo;
264 } 266 }
265 267
266 return 0; 268 return 0;
267} 269}
268Todo *CalendarLocal::todo( const QString &uid ) 270Todo *CalendarLocal::todo( const QString &uid )
269{ 271{
270 Todo *todo; 272 Todo *todo;
271 for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { 273 for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) {
272 if ( todo->uid() == uid ) return todo; 274 if ( todo->uid() == uid ) return todo;
273 } 275 }
274 276
275 return 0; 277 return 0;
276} 278}
277QString CalendarLocal::nextSummary() const 279QString CalendarLocal::nextSummary() const
278{ 280{
279 return mNextSummary; 281 return mNextSummary;
280} 282}
281QDateTime CalendarLocal::nextAlarmEventDateTime() const 283QDateTime CalendarLocal::nextAlarmEventDateTime() const
282{ 284{
283 return mNextAlarmEventDateTime; 285 return mNextAlarmEventDateTime;
284} 286}
285void CalendarLocal::checkAlarmForIncidence( Incidence * incidence, bool deleted) 287void CalendarLocal::checkAlarmForIncidence( Incidence * incidence, bool deleted)
286{ 288{
287 //mNextAlarmIncidence 289 //mNextAlarmIncidence
288 //mNextAlarmDateTime 290 //mNextAlarmDateTime
289 //return mNextSummary; 291 //return mNextSummary;
290 //return mNextAlarmEventDateTime; 292 //return mNextAlarmEventDateTime;
291 bool newNextAlarm = false; 293 bool newNextAlarm = false;
292 bool computeNextAlarm = false; 294 bool computeNextAlarm = false;
293 bool ok; 295 bool ok;
294 int offset; 296 int offset;
295 QDateTime nextA; 297 QDateTime nextA;
296 // QString nextSum; 298 // QString nextSum;
297 //QDateTime nextEvent; 299 //QDateTime nextEvent;
298 if ( mNextAlarmIncidence == 0 || incidence == 0 ) { 300 if ( mNextAlarmIncidence == 0 || incidence == 0 ) {
299 computeNextAlarm = true; 301 computeNextAlarm = true;
300 } else { 302 } else {
301 if ( ! deleted ) { 303 if ( ! deleted ) {
302 nextA = incidence->getNextAlarmDateTime(& ok, &offset ) ; 304 nextA = incidence->getNextAlarmDateTime(& ok, &offset ) ;
303 if ( ok ) { 305 if ( ok ) {
304 if ( nextA < mNextAlarmDateTime ) { 306 if ( nextA < mNextAlarmDateTime ) {
305 deRegisterAlarm(); 307 deRegisterAlarm();
306 mNextAlarmDateTime = nextA; 308 mNextAlarmDateTime = nextA;
307 mNextSummary = incidence->summary(); 309 mNextSummary = incidence->summary();
308 mNextAlarmEventDateTime = nextA.addSecs(offset ) ; 310 mNextAlarmEventDateTime = nextA.addSecs(offset ) ;
309 mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime); 311 mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime);
310 newNextAlarm = true; 312 newNextAlarm = true;
311 mNextAlarmIncidence = incidence; 313 mNextAlarmIncidence = incidence;
312 } else { 314 } else {
313 if ( incidence == mNextAlarmIncidence ) { 315 if ( incidence == mNextAlarmIncidence ) {
314 computeNextAlarm = true; 316 computeNextAlarm = true;
315 } 317 }
316 } 318 }
317 } else { 319 } else {
318 if ( mNextAlarmIncidence == incidence ) { 320 if ( mNextAlarmIncidence == incidence ) {
319 computeNextAlarm = true; 321 computeNextAlarm = true;
320 } 322 }
321 } 323 }
322 } else { // deleted 324 } else { // deleted
323 if ( incidence == mNextAlarmIncidence ) { 325 if ( incidence == mNextAlarmIncidence ) {
324 computeNextAlarm = true; 326 computeNextAlarm = true;
325 } 327 }
326 } 328 }
327 } 329 }
328 if ( computeNextAlarm ) { 330 if ( computeNextAlarm ) {
329 deRegisterAlarm(); 331 deRegisterAlarm();
330 nextA = nextAlarm( 1000 ); 332 nextA = nextAlarm( 1000 );
331 if (! mNextAlarmIncidence ) { 333 if (! mNextAlarmIncidence ) {
332 return; 334 return;
@@ -562,158 +564,161 @@ QPtrList<Event> CalendarLocal::rawEventsForDate( const QDate &qd, bool sorted )
562 564
563 if ( !sorted ) { 565 if ( !sorted ) {
564 return eventList; 566 return eventList;
565 } 567 }
566 568
567 // kdDebug(5800) << "Sorting events for date\n" << endl; 569 // kdDebug(5800) << "Sorting events for date\n" << endl;
568 // now, we have to sort it based on dtStart.time() 570 // now, we have to sort it based on dtStart.time()
569 QPtrList<Event> eventListSorted; 571 QPtrList<Event> eventListSorted;
570 Event *sortEvent; 572 Event *sortEvent;
571 for ( event = eventList.first(); event; event = eventList.next() ) { 573 for ( event = eventList.first(); event; event = eventList.next() ) {
572 sortEvent = eventListSorted.first(); 574 sortEvent = eventListSorted.first();
573 int i = 0; 575 int i = 0;
574 while ( sortEvent && event->dtStart().time()>=sortEvent->dtStart().time() ) 576 while ( sortEvent && event->dtStart().time()>=sortEvent->dtStart().time() )
575 { 577 {
576 i++; 578 i++;
577 sortEvent = eventListSorted.next(); 579 sortEvent = eventListSorted.next();
578 } 580 }
579 eventListSorted.insert( i, event ); 581 eventListSorted.insert( i, event );
580 } 582 }
581 return eventListSorted; 583 return eventListSorted;
582} 584}
583 585
584 586
585QPtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end, 587QPtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end,
586 bool inclusive ) 588 bool inclusive )
587{ 589{
588 Event *event = 0; 590 Event *event = 0;
589 591
590 QPtrList<Event> eventList; 592 QPtrList<Event> eventList;
591 593
592 // Get non-recurring events 594 // Get non-recurring events
593 for( event = mEventList.first(); event; event = mEventList.next() ) { 595 for( event = mEventList.first(); event; event = mEventList.next() ) {
594 if ( event->doesRecur() ) { 596 if ( event->doesRecur() ) {
595 QDate rStart = event->dtStart().date(); 597 QDate rStart = event->dtStart().date();
596 bool found = false; 598 bool found = false;
597 if ( inclusive ) { 599 if ( inclusive ) {
598 if ( rStart >= start && rStart <= end ) { 600 if ( rStart >= start && rStart <= end ) {
599 // Start date of event is in range. Now check for end date. 601 // Start date of event is in range. Now check for end date.
600 // if duration is negative, event recurs forever, so do not include it. 602 // if duration is negative, event recurs forever, so do not include it.
601 if ( event->recurrence()->duration() == 0 ) { // End date set 603 if ( event->recurrence()->duration() == 0 ) { // End date set
602 QDate rEnd = event->recurrence()->endDate(); 604 QDate rEnd = event->recurrence()->endDate();
603 if ( rEnd >= start && rEnd <= end ) { // End date within range 605 if ( rEnd >= start && rEnd <= end ) { // End date within range
604 found = true; 606 found = true;
605 } 607 }
606 } else if ( event->recurrence()->duration() > 0 ) { // Duration set 608 } else if ( event->recurrence()->duration() > 0 ) { // Duration set
607 // TODO: Calculate end date from duration. Should be done in Event 609 // TODO: Calculate end date from duration. Should be done in Event
608 // For now exclude all events with a duration. 610 // For now exclude all events with a duration.
609 } 611 }
610 } 612 }
611 } else { 613 } else {
612 bool founOne; 614 bool founOne;
613 QDate next = event->getNextOccurence( start, &founOne ).date(); 615 QDate next = event->getNextOccurence( start, &founOne ).date();
614 if ( founOne ) { 616 if ( founOne ) {
615 if ( next <= end ) { 617 if ( next <= end ) {
616 found = true; 618 found = true;
617 } 619 }
618 } 620 }
619 621
620 /* 622 /*
621 // crap !!! 623 // crap !!!
622 if ( rStart <= end ) { // Start date not after range 624 if ( rStart <= end ) { // Start date not after range
623 if ( rStart >= start ) { // Start date within range 625 if ( rStart >= start ) { // Start date within range
624 found = true; 626 found = true;
625 } else if ( event->recurrence()->duration() == -1 ) { // Recurs forever 627 } else if ( event->recurrence()->duration() == -1 ) { // Recurs forever
626 found = true; 628 found = true;
627 } else if ( event->recurrence()->duration() == 0 ) { // End date set 629 } else if ( event->recurrence()->duration() == 0 ) { // End date set
628 QDate rEnd = event->recurrence()->endDate(); 630 QDate rEnd = event->recurrence()->endDate();
629 if ( rEnd >= start && rEnd <= end ) { // End date within range 631 if ( rEnd >= start && rEnd <= end ) { // End date within range
630 found = true; 632 found = true;
631 } 633 }
632 } else { // Duration set 634 } else { // Duration set
633 // TODO: Calculate end date from duration. Should be done in Event 635 // TODO: Calculate end date from duration. Should be done in Event
634 // For now include all events with a duration. 636 // For now include all events with a duration.
635 found = true; 637 found = true;
636 } 638 }
637 } 639 }
638 */ 640 */
639 641
640 } 642 }
641 643
642 if ( found ) eventList.append( event ); 644 if ( found ) eventList.append( event );
643 } else { 645 } else {
644 QDate s = event->dtStart().date(); 646 QDate s = event->dtStart().date();
645 QDate e = event->dtEnd().date(); 647 QDate e = event->dtEnd().date();
646 648
647 if ( inclusive ) { 649 if ( inclusive ) {
648 if ( s >= start && e <= end ) { 650 if ( s >= start && e <= end ) {
649 eventList.append( event ); 651 eventList.append( event );
650 } 652 }
651 } else { 653 } else {
652 if ( ( s >= start && s <= end ) || ( e >= start && e <= end ) ) { 654 if ( ( s >= start && s <= end ) || ( e >= start && e <= end ) ) {
653 eventList.append( event ); 655 eventList.append( event );
654 } 656 }
655 } 657 }
656 } 658 }
657 } 659 }
658 660
659 return eventList; 661 return eventList;
660} 662}
661 663
662QPtrList<Event> CalendarLocal::rawEventsForDate( const QDateTime &qdt ) 664QPtrList<Event> CalendarLocal::rawEventsForDate( const QDateTime &qdt )
663{ 665{
664 return rawEventsForDate( qdt.date() ); 666 return rawEventsForDate( qdt.date() );
665} 667}
666 668
667QPtrList<Event> CalendarLocal::rawEvents() 669QPtrList<Event> CalendarLocal::rawEvents()
668{ 670{
669 return mEventList; 671 return mEventList;
670} 672}
671 673
672bool CalendarLocal::addJournal(Journal *journal) 674bool CalendarLocal::addJournal(Journal *journal)
673{ 675{
674 if ( journal->dtStart().isValid()) 676 if ( journal->dtStart().isValid())
675 kdDebug(5800) << "Adding Journal on " << journal->dtStart().toString() << endl; 677 kdDebug(5800) << "Adding Journal on " << journal->dtStart().toString() << endl;
676 else 678 else
677 kdDebug(5800) << "Adding Journal without a DTSTART" << endl; 679 kdDebug(5800) << "Adding Journal without a DTSTART" << endl;
678 680
679 mJournalList.append(journal); 681 mJournalList.append(journal);
680 682
681 journal->registerObserver( this ); 683 journal->registerObserver( this );
682 684
683 setModified( true ); 685 setModified( true );
684 686
685 return true; 687 return true;
686} 688}
687 689
688void CalendarLocal::deleteJournal( Journal *journal ) 690void CalendarLocal::deleteJournal( Journal *journal )
689{ 691{
692 if ( mUndoIncidence ) delete mUndoIncidence;
693 mUndoIncidence = journal->clone();
694 mUndoIncidence->setSummary( mUndoIncidence->description().left(25));
690 if ( mJournalList.removeRef(journal) ) { 695 if ( mJournalList.removeRef(journal) ) {
691 setModified( true ); 696 setModified( true );
692 } 697 }
693} 698}
694 699
695Journal *CalendarLocal::journal( const QDate &date ) 700Journal *CalendarLocal::journal( const QDate &date )
696{ 701{
697// kdDebug(5800) << "CalendarLocal::journal() " << date.toString() << endl; 702// kdDebug(5800) << "CalendarLocal::journal() " << date.toString() << endl;
698 703
699 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) 704 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
700 if ( it->dtStart().date() == date ) 705 if ( it->dtStart().date() == date )
701 return it; 706 return it;
702 707
703 return 0; 708 return 0;
704} 709}
705 710
706Journal *CalendarLocal::journal( const QString &uid ) 711Journal *CalendarLocal::journal( const QString &uid )
707{ 712{
708 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) 713 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
709 if ( it->uid() == uid ) 714 if ( it->uid() == uid )
710 return it; 715 return it;
711 716
712 return 0; 717 return 0;
713} 718}
714 719
715QPtrList<Journal> CalendarLocal::journals() 720QPtrList<Journal> CalendarLocal::journals()
716{ 721{
717 return mJournalList; 722 return mJournalList;
718} 723}
719 724