author | zautrix <zautrix> | 2005-07-09 08:48:32 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-07-09 08:48:32 (UTC) |
commit | f731dd9fc5b3f14c44d4de26eb5370a79c63887c (patch) (unidiff) | |
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 | |||
@@ -67,8 +67,83 @@ CalendarLocal::~CalendarLocal() | |||
67 | { | 67 | { |
68 | if ( mDeleteIncidencesOnClose ) | 68 | if ( mDeleteIncidencesOnClose ) |
69 | close(); | 69 | close(); |
70 | } | 70 | } |
71 | bool CalendarLocal::mergeCalendarFile( QString name ) | ||
72 | { | ||
73 | CalendarLocal calendar( timeZoneId() ); | ||
74 | calendar.setDefaultCalendar( 1 ); | ||
75 | if ( calendar.load( name ) ) { | ||
76 | mergeCalendar( &calendar ); | ||
77 | return true; | ||
78 | } | ||
79 | return false; | ||
80 | } | ||
81 | |||
82 | Incidence* CalendarLocal::incidenceForUid( const QString& uid ) | ||
83 | { | ||
84 | Todo *todo;; | ||
85 | Incidence *retVal = 0; | ||
86 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { | ||
87 | if ( todo->uid() == uid ) { | ||
88 | if ( retVal ) { | ||
89 | if ( retVal->calID() > todo->calID() ) { | ||
90 | retVal = todo; | ||
91 | } | ||
92 | } else { | ||
93 | retVal = todo; | ||
94 | } | ||
95 | } | ||
96 | } | ||
97 | if ( retVal ) return retVal; | ||
98 | Event *event; | ||
99 | for ( event = mEventList.first(); event; event = mEventList.next() ) { | ||
100 | if ( event->uid() == uid ) { | ||
101 | if ( retVal ) { | ||
102 | if ( retVal->calID() > event->calID() ) { | ||
103 | retVal = event; | ||
104 | } | ||
105 | } else { | ||
106 | retVal = event; | ||
107 | } | ||
108 | } | ||
109 | } | ||
110 | if ( retVal ) return retVal; | ||
111 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | ||
112 | if ( it->uid() == uid ) { | ||
113 | if ( retVal ) { | ||
114 | if ( retVal->calID() > it->calID() ) { | ||
115 | retVal = it; | ||
116 | } | ||
117 | } else { | ||
118 | retVal = it; | ||
119 | } | ||
120 | } | ||
121 | return retVal; | ||
122 | } | ||
123 | |||
124 | bool CalendarLocal::mergeCalendar( Calendar* remote ) | ||
125 | { | ||
126 | QPtrList<Incidence> er = remote->rawIncidences(); | ||
127 | Incidence* inR = er.first(); | ||
128 | Incidence* inL; | ||
129 | while ( inR ) { | ||
130 | inL = incidenceForUid( inR->uid() ); | ||
131 | if ( inL ) { | ||
132 | int calID = inL->calID(); | ||
133 | deleteIncidence( inL ); | ||
134 | inL = inR->clone(); | ||
135 | inL->setCalID( calID ); | ||
136 | addIncidence( inL ); | ||
137 | } else { | ||
138 | inL = inR->clone(); | ||
139 | inL->setCalID( 0 );// add to default cal | ||
140 | addIncidence( inL ); | ||
141 | } | ||
142 | inR = er.next(); | ||
143 | } | ||
144 | return true; | ||
145 | } | ||
71 | bool CalendarLocal::addCalendarFile( QString name, int id ) | 146 | bool CalendarLocal::addCalendarFile( QString name, int id ) |
72 | { | 147 | { |
73 | CalendarLocal calendar( timeZoneId() ); | 148 | CalendarLocal calendar( timeZoneId() ); |
74 | calendar.setDefaultCalendar( id ); | 149 | calendar.setDefaultCalendar( id ); |