summaryrefslogtreecommitdiffabout
path: root/libkcal/calendarlocal.cpp
Unidiff
Diffstat (limited to 'libkcal/calendarlocal.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/calendarlocal.cpp66
1 files changed, 33 insertions, 33 deletions
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index ce3cd09..cb52b7c 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -19,13 +19,13 @@
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. 20 Boston, MA 02111-1307, USA.
21*/ 21*/
22 22
23#include <qdatetime.h> 23#include <qdatetime.h>
24#include <qstring.h> 24#include <qstring.h>
25#include <qptrlist.h> 25#include <q3ptrlist.h>
26 26
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
@@ -189,21 +189,21 @@ bool CalendarLocal::mergeCalendar( Calendar* remote )
189{ 189{
190 // 1 look for raw inc in local 190 // 1 look for raw inc in local
191 // if inc not in remote, delete in local 191 // if inc not in remote, delete in local
192 // 2 look for raw inc in remote 192 // 2 look for raw inc in remote
193 // if inc in local, replace it 193 // if inc in local, replace it
194 // if not in local, add it to default calendar 194 // if not in local, add it to default calendar
195 QPtrList<Incidence> localInc = rawIncidences(); 195 Q3PtrList<Incidence> localInc = rawIncidences();
196 Incidence* inL = localInc.first(); 196 Incidence* inL = localInc.first();
197 while ( inL ) { 197 while ( inL ) {
198 if ( ! inL->isReadOnly () ) 198 if ( ! inL->isReadOnly () )
199 if ( !remote->incidenceForUid( inL->uid(), true )) 199 if ( !remote->incidenceForUid( inL->uid(), true ))
200 deleteIncidence( inL ); 200 deleteIncidence( inL );
201 inL = localInc.next(); 201 inL = localInc.next();
202 } 202 }
203 QPtrList<Incidence> er = remote->rawIncidences(); 203 Q3PtrList<Incidence> er = remote->rawIncidences();
204 Incidence* inR = er.first(); 204 Incidence* inR = er.first();
205 while ( inR ) { 205 while ( inR ) {
206 inL = incidenceForUid( inR->uid(),false ); 206 inL = incidenceForUid( inR->uid(),false );
207 if ( inL ) { 207 if ( inL ) {
208 if ( ! inL->isReadOnly () || inL->uid().left(15) == QString("last-syncEvent-") ) { 208 if ( ! inL->isReadOnly () || inL->uid().left(15) == QString("last-syncEvent-") ) {
209 int calID = inL->calID(); 209 int calID = inL->calID();
@@ -256,15 +256,15 @@ void CalendarLocal::setSyncEventsReadOnly()
256} 256}
257 257
258void CalendarLocal::addCalendar( Calendar* cal ) 258void CalendarLocal::addCalendar( Calendar* cal )
259{ 259{
260 cal->setDontDeleteIncidencesOnClose(); 260 cal->setDontDeleteIncidencesOnClose();
261 setSyncEventsEnabled(); 261 setSyncEventsEnabled();
262 QPtrList<Incidence> incList; 262 Q3PtrList<Incidence> incList;
263 { 263 {
264 QPtrList<Event> EventList = cal->rawEvents(); 264 Q3PtrList<Event> EventList = cal->rawEvents();
265 Event * ev = EventList.first(); 265 Event * ev = EventList.first();
266 while ( ev ) { 266 while ( ev ) {
267 if ( ev->uid().left( 15 ) == QString("last-syncEvent-") ) { 267 if ( ev->uid().left( 15 ) == QString("last-syncEvent-") ) {
268 ev->setCalID_block( 1 ); 268 ev->setCalID_block( 1 );
269 } 269 }
270 Event * se = event( ev->uid() ); 270 Event * se = event( ev->uid() );
@@ -276,13 +276,13 @@ void CalendarLocal::addCalendar( Calendar* cal )
276 ev = EventList.next(); 276 ev = EventList.next();
277 } 277 }
278 278
279 } 279 }
280 { 280 {
281 281
282 QPtrList<Todo> TodoList = cal->rawTodos(); 282 Q3PtrList<Todo> TodoList = cal->rawTodos();
283 Todo * ev = TodoList.first(); 283 Todo * ev = TodoList.first();
284 while ( ev ) { 284 while ( ev ) {
285 ev->resetRelatedTo(); 285 ev->resetRelatedTo();
286 Todo * se = todo( ev->uid() ); 286 Todo * se = todo( ev->uid() );
287 if ( se ) 287 if ( se )
288 deleteTodo( se ); 288 deleteTodo( se );
@@ -296,13 +296,13 @@ void CalendarLocal::addCalendar( Calendar* cal )
296 mTodoList.append( ev ); 296 mTodoList.append( ev );
297 setupRelations( ev ); 297 setupRelations( ev );
298 ev = TodoList.next(); 298 ev = TodoList.next();
299 } 299 }
300 } 300 }
301 { 301 {
302 QPtrList<Journal> JournalList = cal->journals(); 302 Q3PtrList<Journal> JournalList = cal->journals();
303 Journal * ev = JournalList.first(); 303 Journal * ev = JournalList.first();
304 while ( ev ) { 304 while ( ev ) {
305 Journal * se = journal( ev->uid() ); 305 Journal * se = journal( ev->uid() );
306 if ( se ) 306 if ( se )
307 incList.append( se ); 307 incList.append( se );
308 ev->unRegisterObserver( cal ); 308 ev->unRegisterObserver( cal );
@@ -478,15 +478,15 @@ void CalendarLocal::deleteTodo( Todo *todo )
478 } 478 }
479 Todo* dup = todoForUid( uid ); 479 Todo* dup = todoForUid( uid );
480 if ( dup ) 480 if ( dup )
481 setupRelations( dup ); 481 setupRelations( dup );
482} 482}
483 483
484QPtrList<Todo> CalendarLocal::rawTodos() 484Q3PtrList<Todo> CalendarLocal::rawTodos()
485{ 485{
486 QPtrList<Todo> el; 486 Q3PtrList<Todo> el;
487 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) 487 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() )
488 if ( it->calEnabled() ) el.append( it ); 488 if ( it->calEnabled() ) el.append( it );
489 return el; 489 return el;
490} 490}
491Todo *CalendarLocal::todo( QString syncProf, QString id ) 491Todo *CalendarLocal::todo( QString syncProf, QString id )
492{ 492{
@@ -496,19 +496,19 @@ Todo *CalendarLocal::todo( QString syncProf, QString id )
496 } 496 }
497 497
498 return 0; 498 return 0;
499} 499}
500void CalendarLocal::removeSyncInfo( QString syncProfile) 500void CalendarLocal::removeSyncInfo( QString syncProfile)
501{ 501{
502 QPtrList<Incidence> all = rawIncidences() ; 502 Q3PtrList<Incidence> all = rawIncidences() ;
503 Incidence *inc; 503 Incidence *inc;
504 for ( inc = all.first(); inc; inc = all.next() ) { 504 for ( inc = all.first(); inc; inc = all.next() ) {
505 inc->removeID( syncProfile ); 505 inc->removeID( syncProfile );
506 } 506 }
507 if ( syncProfile.isEmpty() ) { 507 if ( syncProfile.isEmpty() ) {
508 QPtrList<Event> el; 508 Q3PtrList<Event> el;
509 Event *todo; 509 Event *todo;
510 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { 510 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) {
511 if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) 511 if ( todo->uid().left( 15 ) == QString("last-syncEvent-") )
512 el.append( todo ); 512 el.append( todo );
513 } 513 }
514 for ( todo = el.first(); todo; todo = el.next() ) { 514 for ( todo = el.first(); todo; todo = el.next() ) {
@@ -517,15 +517,15 @@ void CalendarLocal::removeSyncInfo( QString syncProfile)
517 } else { 517 } else {
518 Event *lse = event( "last-syncEvent-"+ syncProfile); 518 Event *lse = event( "last-syncEvent-"+ syncProfile);
519 if ( lse ) 519 if ( lse )
520 deleteIncidence ( lse ); 520 deleteIncidence ( lse );
521 } 521 }
522} 522}
523QPtrList<Event> CalendarLocal::getExternLastSyncEvents() 523Q3PtrList<Event> CalendarLocal::getExternLastSyncEvents()
524{ 524{
525 QPtrList<Event> el; 525 Q3PtrList<Event> el;
526 Event *todo; 526 Event *todo;
527 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { 527 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) {
528 if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) 528 if ( todo->uid().left( 15 ) == QString("last-syncEvent-") )
529 if ( todo->summary().left(3) == "E: " ) 529 if ( todo->summary().left(3) == "E: " )
530 el.append( todo ); 530 el.append( todo );
531 } 531 }
@@ -682,15 +682,15 @@ void CalendarLocal::deRegisterAlarm()
682 mNextAlarmEventDateTime = QDateTime(); 682 mNextAlarmEventDateTime = QDateTime();
683// #ifndef DESKTOP_VERSION 683// #ifndef DESKTOP_VERSION
684// AlarmServer::deleteAlarm (mNextAlarmDateTime ,"koalarm" ,mLastAlarmNotificationString.latin1() ); 684// AlarmServer::deleteAlarm (mNextAlarmDateTime ,"koalarm" ,mLastAlarmNotificationString.latin1() );
685// #endif 685// #endif
686} 686}
687 687
688QPtrList<Todo> CalendarLocal::todos( const QDate &date ) 688Q3PtrList<Todo> CalendarLocal::todos( const QDate &date )
689{ 689{
690 QPtrList<Todo> todos; 690 Q3PtrList<Todo> todos;
691 691
692 Todo *todo; 692 Todo *todo;
693 for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { 693 for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) {
694 if ( !todo->calEnabled() ) continue; 694 if ( !todo->calEnabled() ) continue;
695 if ( todo->hasDueDate() && todo->dtDue().date() == date ) { 695 if ( todo->hasDueDate() && todo->dtDue().date() == date ) {
696 todos.append( todo ); 696 todos.append( todo );
@@ -783,13 +783,13 @@ Alarm::List CalendarLocal::alarms( const QDateTime &from, const QDateTime &to )
783 return alarms; 783 return alarms;
784} 784}
785 785
786void CalendarLocal::appendAlarms( Alarm::List &alarms, Incidence *incidence, 786void CalendarLocal::appendAlarms( Alarm::List &alarms, Incidence *incidence,
787 const QDateTime &from, const QDateTime &to ) 787 const QDateTime &from, const QDateTime &to )
788{ 788{
789 QPtrList<Alarm> alarmList = incidence->alarms(); 789 Q3PtrList<Alarm> alarmList = incidence->alarms();
790 Alarm *alarm; 790 Alarm *alarm;
791 for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) { 791 for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) {
792// kdDebug(5800) << "CalendarLocal::appendAlarms() '" << alarm->text() 792// kdDebug(5800) << "CalendarLocal::appendAlarms() '" << alarm->text()
793// << "': " << alarm->time().toString() << " - " << alarm->enabled() << endl; 793// << "': " << alarm->time().toString() << " - " << alarm->enabled() << endl;
794 if ( alarm->enabled() ) { 794 if ( alarm->enabled() ) {
795 if ( alarm->time() >= from && alarm->time() <= to ) { 795 if ( alarm->time() >= from && alarm->time() <= to ) {
@@ -802,13 +802,13 @@ void CalendarLocal::appendAlarms( Alarm::List &alarms, Incidence *incidence,
802void CalendarLocal::appendRecurringAlarms( Alarm::List &alarms, 802void CalendarLocal::appendRecurringAlarms( Alarm::List &alarms,
803 Incidence *incidence, 803 Incidence *incidence,
804 const QDateTime &from, 804 const QDateTime &from,
805 const QDateTime &to ) 805 const QDateTime &to )
806{ 806{
807 807
808 QPtrList<Alarm> alarmList = incidence->alarms(); 808 Q3PtrList<Alarm> alarmList = incidence->alarms();
809 Alarm *alarm; 809 Alarm *alarm;
810 QDateTime qdt; 810 QDateTime qdt;
811 for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) { 811 for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) {
812 if (incidence->recursOn(from.date())) { 812 if (incidence->recursOn(from.date())) {
813 qdt.setTime(alarm->time().time()); 813 qdt.setTime(alarm->time().time());
814 qdt.setDate(from.date()); 814 qdt.setDate(from.date());
@@ -841,15 +841,15 @@ void CalendarLocal::update( IncidenceBase *incidence )
841void CalendarLocal::insertEvent( Event *event ) 841void CalendarLocal::insertEvent( Event *event )
842{ 842{
843 if ( mEventList.findRef( event ) < 0 ) mEventList.append( event ); 843 if ( mEventList.findRef( event ) < 0 ) mEventList.append( event );
844} 844}
845 845
846 846
847QPtrList<Event> CalendarLocal::rawEventsForDate( const QDate &qd, bool sorted ) 847Q3PtrList<Event> CalendarLocal::rawEventsForDate( const QDate &qd, bool sorted )
848{ 848{
849 QPtrList<Event> eventList; 849 Q3PtrList<Event> eventList;
850 850
851 Event *event; 851 Event *event;
852 for( event = mEventList.first(); event; event = mEventList.next() ) { 852 for( event = mEventList.first(); event; event = mEventList.next() ) {
853 if ( !event->calEnabled() ) continue; 853 if ( !event->calEnabled() ) continue;
854 if ( event->doesRecur() ) { 854 if ( event->doesRecur() ) {
855 if ( event->isMultiDay() ) { 855 if ( event->isMultiDay() ) {
@@ -875,13 +875,13 @@ QPtrList<Event> CalendarLocal::rawEventsForDate( const QDate &qd, bool sorted )
875 if ( !sorted ) { 875 if ( !sorted ) {
876 return eventList; 876 return eventList;
877 } 877 }
878 878
879 // kdDebug(5800) << "Sorting events for date\n" << endl; 879 // kdDebug(5800) << "Sorting events for date\n" << endl;
880 // now, we have to sort it based on dtStart.time() 880 // now, we have to sort it based on dtStart.time()
881 QPtrList<Event> eventListSorted; 881 Q3PtrList<Event> eventListSorted;
882 Event *sortEvent; 882 Event *sortEvent;
883 for ( event = eventList.first(); event; event = eventList.next() ) { 883 for ( event = eventList.first(); event; event = eventList.next() ) {
884 sortEvent = eventListSorted.first(); 884 sortEvent = eventListSorted.first();
885 int i = 0; 885 int i = 0;
886 while ( sortEvent && event->dtStart().time()>=sortEvent->dtStart().time() ) 886 while ( sortEvent && event->dtStart().time()>=sortEvent->dtStart().time() )
887 { 887 {
@@ -891,18 +891,18 @@ QPtrList<Event> CalendarLocal::rawEventsForDate( const QDate &qd, bool sorted )
891 eventListSorted.insert( i, event ); 891 eventListSorted.insert( i, event );
892 } 892 }
893 return eventListSorted; 893 return eventListSorted;
894} 894}
895 895
896 896
897QPtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end, 897Q3PtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end,
898 bool inclusive ) 898 bool inclusive )
899{ 899{
900 Event *event = 0; 900 Event *event = 0;
901 901
902 QPtrList<Event> eventList; 902 Q3PtrList<Event> eventList;
903 903
904 // Get non-recurring events 904 // Get non-recurring events
905 for( event = mEventList.first(); event; event = mEventList.next() ) { 905 for( event = mEventList.first(); event; event = mEventList.next() ) {
906 if ( !event->calEnabled() ) continue; 906 if ( !event->calEnabled() ) continue;
907 if ( event->doesRecur() ) { 907 if ( event->doesRecur() ) {
908 QDate rStart = event->dtStart().date(); 908 QDate rStart = event->dtStart().date();
@@ -920,13 +920,13 @@ QPtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end,
920 // TODO: Calculate end date from duration. Should be done in Event 920 // TODO: Calculate end date from duration. Should be done in Event
921 // For now exclude all events with a duration. 921 // For now exclude all events with a duration.
922 } 922 }
923 } 923 }
924 } else { 924 } else {
925 bool founOne; 925 bool founOne;
926 QDate next = event->getNextOccurence( start, &founOne ).date(); 926 QDate next = event->getNextOccurence( (QDateTime)start, &founOne ).date();
927 if ( founOne ) { 927 if ( founOne ) {
928 if ( next <= end ) { 928 if ( next <= end ) {
929 found = true; 929 found = true;
930 } 930 }
931 } 931 }
932 932
@@ -969,20 +969,20 @@ QPtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end,
969 } 969 }
970 } 970 }
971 971
972 return eventList; 972 return eventList;
973} 973}
974 974
975QPtrList<Event> CalendarLocal::rawEventsForDate( const QDateTime &qdt ) 975Q3PtrList<Event> CalendarLocal::rawEventsForDate( const QDateTime &qdt )
976{ 976{
977 return rawEventsForDate( qdt.date() ); 977 return rawEventsForDate( qdt.date() );
978} 978}
979 979
980QPtrList<Event> CalendarLocal::rawEvents() 980Q3PtrList<Event> CalendarLocal::rawEvents()
981{ 981{
982 QPtrList<Event> el; 982 Q3PtrList<Event> el;
983 for ( Event *it = mEventList.first(); it; it = mEventList.next() ) 983 for ( Event *it = mEventList.first(); it; it = mEventList.next() )
984 if ( it->calEnabled() ) el.append( it ); 984 if ( it->calEnabled() ) el.append( it );
985 return el; 985 return el;
986} 986}
987 987
988bool CalendarLocal::addJournal(Journal *journal) 988bool CalendarLocal::addJournal(Journal *journal)
@@ -1003,15 +1003,15 @@ void CalendarLocal::deleteJournal( Journal *journal )
1003 clearUndo(journal); 1003 clearUndo(journal);
1004 if ( mJournalList.removeRef(journal) ) { 1004 if ( mJournalList.removeRef(journal) ) {
1005 setModified( true ); 1005 setModified( true );
1006 } 1006 }
1007} 1007}
1008 1008
1009QPtrList<Journal> CalendarLocal::journals4Date( const QDate & date ) 1009Q3PtrList<Journal> CalendarLocal::journals4Date( const QDate & date )
1010{ 1010{
1011 QPtrList<Journal> el; 1011 Q3PtrList<Journal> el;
1012 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) 1012 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
1013 if ( it->calEnabled() && it->dtStart().date() == date) el.append( it ); 1013 if ( it->calEnabled() && it->dtStart().date() == date) el.append( it );
1014 return el; 1014 return el;
1015} 1015}
1016Journal *CalendarLocal::journal( const QDate &date ) 1016Journal *CalendarLocal::journal( const QDate &date )
1017{ 1017{
@@ -1037,43 +1037,43 @@ Journal *CalendarLocal::journal( const QString &uid )
1037 retVal = it; 1037 retVal = it;
1038 } 1038 }
1039 } 1039 }
1040 return retVal; 1040 return retVal;
1041} 1041}
1042 1042
1043QPtrList<Journal> CalendarLocal::journals() 1043Q3PtrList<Journal> CalendarLocal::journals()
1044{ 1044{
1045 QPtrList<Journal> el; 1045 Q3PtrList<Journal> el;
1046 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) 1046 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
1047 if ( it->calEnabled() ) el.append( it ); 1047 if ( it->calEnabled() ) el.append( it );
1048 return el; 1048 return el;
1049} 1049}
1050void CalendarLocal::setCalendarRemove( int id ) 1050void CalendarLocal::setCalendarRemove( int id )
1051{ 1051{
1052 1052
1053 { 1053 {
1054 QPtrList<Event> EventList = mEventList; 1054 Q3PtrList<Event> EventList = mEventList;
1055 Event * ev = EventList.first(); 1055 Event * ev = EventList.first();
1056 while ( ev ) { 1056 while ( ev ) {
1057 if ( ev->calID() == id && ev->uid().left( 15 ) != QString("last-syncEvent-") ) 1057 if ( ev->calID() == id && ev->uid().left( 15 ) != QString("last-syncEvent-") )
1058 deleteEvent( ev ); 1058 deleteEvent( ev );
1059 ev = EventList.next(); 1059 ev = EventList.next();
1060 } 1060 }
1061 } 1061 }
1062 { 1062 {
1063 1063
1064 QPtrList<Todo> TodoList = mTodoList; 1064 Q3PtrList<Todo> TodoList = mTodoList;
1065 Todo * ev = TodoList.first(); 1065 Todo * ev = TodoList.first();
1066 while ( ev ) { 1066 while ( ev ) {
1067 if ( ev->calID() == id ) 1067 if ( ev->calID() == id )
1068 deleteTodo( ev ); 1068 deleteTodo( ev );
1069 ev = TodoList.next(); 1069 ev = TodoList.next();
1070 } 1070 }
1071 } 1071 }
1072 { 1072 {
1073 QPtrList<Journal> JournalList = mJournalList; 1073 Q3PtrList<Journal> JournalList = mJournalList;
1074 Journal * ev = JournalList.first(); 1074 Journal * ev = JournalList.first();
1075 while ( ev ) { 1075 while ( ev ) {
1076 if ( ev->calID() == id ) 1076 if ( ev->calID() == id )
1077 deleteJournal( ev ); 1077 deleteJournal( ev );
1078 ev = JournalList.next(); 1078 ev = JournalList.next();
1079 } 1079 }