author | zautrix <zautrix> | 2005-07-09 08:48:32 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-07-09 08:48:32 (UTC) |
commit | f731dd9fc5b3f14c44d4de26eb5370a79c63887c (patch) (side-by-side diff) | |
tree | e3d7b3929cc8819a5451bd04c9698bc0767e49b1 /libkcal/calendarlocal.cpp | |
parent | e27ad31c6016152449bbdaf4f9f387fa61183c37 (diff) | |
download | kdepimpi-f731dd9fc5b3f14c44d4de26eb5370a79c63887c.zip kdepimpi-f731dd9fc5b3f14c44d4de26eb5370a79c63887c.tar.gz kdepimpi-f731dd9fc5b3f14c44d4de26eb5370a79c63887c.tar.bz2 |
fixi
-rw-r--r-- | libkcal/calendarlocal.cpp | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index cce798f..3e42ec0 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp @@ -63,16 +63,91 @@ void CalendarLocal::init() } CalendarLocal::~CalendarLocal() { if ( mDeleteIncidencesOnClose ) close(); } +bool CalendarLocal::mergeCalendarFile( QString name ) +{ + CalendarLocal calendar( timeZoneId() ); + calendar.setDefaultCalendar( 1 ); + if ( calendar.load( name ) ) { + mergeCalendar( &calendar ); + return true; + } + return false; +} + +Incidence* CalendarLocal::incidenceForUid( const QString& uid ) +{ + Todo *todo;; + Incidence *retVal = 0; + for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { + if ( todo->uid() == uid ) { + if ( retVal ) { + if ( retVal->calID() > todo->calID() ) { + retVal = todo; + } + } else { + retVal = todo; + } + } + } + if ( retVal ) return retVal; + Event *event; + for ( event = mEventList.first(); event; event = mEventList.next() ) { + if ( event->uid() == uid ) { + if ( retVal ) { + if ( retVal->calID() > event->calID() ) { + retVal = event; + } + } else { + retVal = event; + } + } + } + if ( retVal ) return retVal; + for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) + if ( it->uid() == uid ) { + if ( retVal ) { + if ( retVal->calID() > it->calID() ) { + retVal = it; + } + } else { + retVal = it; + } + } + return retVal; +} + +bool CalendarLocal::mergeCalendar( Calendar* remote ) +{ + QPtrList<Incidence> er = remote->rawIncidences(); + Incidence* inR = er.first(); + Incidence* inL; + while ( inR ) { + inL = incidenceForUid( inR->uid() ); + if ( inL ) { + int calID = inL->calID(); + deleteIncidence( inL ); + inL = inR->clone(); + inL->setCalID( calID ); + addIncidence( inL ); + } else { + inL = inR->clone(); + inL->setCalID( 0 );// add to default cal + addIncidence( inL ); + } + inR = er.next(); + } + return true; +} bool CalendarLocal::addCalendarFile( QString name, int id ) { CalendarLocal calendar( timeZoneId() ); calendar.setDefaultCalendar( id ); if ( calendar.load( name ) ) { addCalendar( &calendar ); return true; } |