summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/calendarlocal.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index 0eba6a9..52c298b 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -149,193 +149,194 @@ bool CalendarLocal::addEvent( Event *event )
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 if ( mUndoIncidence ) delete mUndoIncidence; 155 if ( mUndoIncidence ) delete mUndoIncidence;
156 mUndoIncidence = event->clone(); 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 if ( mUndoIncidence ) delete mUndoIncidence; 204 if ( mUndoIncidence ) delete mUndoIncidence;
205 removeRelations( todo ); 205 removeRelations( todo );
206 mUndoIncidence = todo->clone(); 206 mUndoIncidence = todo->clone();
207 207
208 if ( mTodoList.removeRef( todo ) ) { 208 if ( mTodoList.removeRef( todo ) ) {
209 setModified( true ); 209 setModified( true );
210 } 210 }
211} 211}
212 212
213QPtrList<Todo> CalendarLocal::rawTodos() 213QPtrList<Todo> CalendarLocal::rawTodos()
214{ 214{
215 return mTodoList; 215 return mTodoList;
216} 216}
217Todo *CalendarLocal::todo( QString syncProf, QString id ) 217Todo *CalendarLocal::todo( QString syncProf, QString id )
218{ 218{
219 Todo *todo; 219 Todo *todo;
220 for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { 220 for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) {
221 if ( todo->getID( syncProf ) == id ) return todo; 221 if ( todo->getID( syncProf ) == id ) return todo;
222 } 222 }
223 223
224 return 0; 224 return 0;
225} 225}
226void CalendarLocal::removeSyncInfo( QString syncProfile) 226void CalendarLocal::removeSyncInfo( QString syncProfile)
227{ 227{
228 QPtrList<Incidence> all = rawIncidences() ; 228 QPtrList<Incidence> all = rawIncidences() ;
229 Incidence *inc; 229 Incidence *inc;
230 for ( inc = all.first(); inc; inc = all.next() ) { 230 for ( inc = all.first(); inc; inc = all.next() ) {
231 inc->removeID( syncProfile ); 231 inc->removeID( syncProfile );
232 } 232 }
233 if ( syncProfile.isEmpty() ) { 233 if ( syncProfile.isEmpty() ) {
234 QPtrList<Event> el; 234 QPtrList<Event> el;
235 Event *todo; 235 Event *todo;
236 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { 236 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) {
237 if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) 237 if ( todo->uid().left( 15 ) == QString("last-syncEvent-") )
238 el.append( todo ); 238 el.append( todo );
239 } 239 }
240 for ( todo = el.first(); todo; todo = el.next() ) { 240 for ( todo = el.first(); todo; todo = el.next() ) {
241 deleteIncidence ( todo ); 241 deleteIncidence ( todo );
242 } 242 }
243 } else { 243 } else {
244 Event *lse = event( "last-syncEvent-"+ syncProfile); 244 Event *lse = event( "last-syncEvent-"+ syncProfile);
245 deleteIncidence ( lse ); 245 if ( lse )
246 deleteIncidence ( lse );
246 } 247 }
247} 248}
248QPtrList<Event> CalendarLocal::getExternLastSyncEvents() 249QPtrList<Event> CalendarLocal::getExternLastSyncEvents()
249{ 250{
250 QPtrList<Event> el; 251 QPtrList<Event> el;
251 Event *todo; 252 Event *todo;
252 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { 253 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) {
253 if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) 254 if ( todo->uid().left( 15 ) == QString("last-syncEvent-") )
254 if ( todo->summary().left(3) == "E: " ) 255 if ( todo->summary().left(3) == "E: " )
255 el.append( todo ); 256 el.append( todo );
256 } 257 }
257 258
258 return el; 259 return el;
259 260
260} 261}
261Event *CalendarLocal::event( QString syncProf, QString id ) 262Event *CalendarLocal::event( QString syncProf, QString id )
262{ 263{
263 Event *todo; 264 Event *todo;
264 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { 265 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) {
265 if ( todo->getID( syncProf ) == id ) return todo; 266 if ( todo->getID( syncProf ) == id ) return todo;
266 } 267 }
267 268
268 return 0; 269 return 0;
269} 270}
270Todo *CalendarLocal::todo( const QString &uid ) 271Todo *CalendarLocal::todo( const QString &uid )
271{ 272{
272 Todo *todo; 273 Todo *todo;
273 for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { 274 for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) {
274 if ( todo->uid() == uid ) return todo; 275 if ( todo->uid() == uid ) return todo;
275 } 276 }
276 277
277 return 0; 278 return 0;
278} 279}
279QString CalendarLocal::nextSummary() const 280QString CalendarLocal::nextSummary() const
280{ 281{
281 return mNextSummary; 282 return mNextSummary;
282} 283}
283QDateTime CalendarLocal::nextAlarmEventDateTime() const 284QDateTime CalendarLocal::nextAlarmEventDateTime() const
284{ 285{
285 return mNextAlarmEventDateTime; 286 return mNextAlarmEventDateTime;
286} 287}
287void CalendarLocal::checkAlarmForIncidence( Incidence * incidence, bool deleted) 288void CalendarLocal::checkAlarmForIncidence( Incidence * incidence, bool deleted)
288{ 289{
289 //mNextAlarmIncidence 290 //mNextAlarmIncidence
290 //mNextAlarmDateTime 291 //mNextAlarmDateTime
291 //return mNextSummary; 292 //return mNextSummary;
292 //return mNextAlarmEventDateTime; 293 //return mNextAlarmEventDateTime;
293 bool newNextAlarm = false; 294 bool newNextAlarm = false;
294 bool computeNextAlarm = false; 295 bool computeNextAlarm = false;
295 bool ok; 296 bool ok;
296 int offset; 297 int offset;
297 QDateTime nextA; 298 QDateTime nextA;
298 // QString nextSum; 299 // QString nextSum;
299 //QDateTime nextEvent; 300 //QDateTime nextEvent;
300 if ( mNextAlarmIncidence == 0 || incidence == 0 ) { 301 if ( mNextAlarmIncidence == 0 || incidence == 0 ) {
301 computeNextAlarm = true; 302 computeNextAlarm = true;
302 } else { 303 } else {
303 if ( ! deleted ) { 304 if ( ! deleted ) {
304 nextA = incidence->getNextAlarmDateTime(& ok, &offset ) ; 305 nextA = incidence->getNextAlarmDateTime(& ok, &offset ) ;
305 if ( ok ) { 306 if ( ok ) {
306 if ( nextA < mNextAlarmDateTime ) { 307 if ( nextA < mNextAlarmDateTime ) {
307 deRegisterAlarm(); 308 deRegisterAlarm();
308 mNextAlarmDateTime = nextA; 309 mNextAlarmDateTime = nextA;
309 mNextSummary = incidence->summary(); 310 mNextSummary = incidence->summary();
310 mNextAlarmEventDateTime = nextA.addSecs(offset ) ; 311 mNextAlarmEventDateTime = nextA.addSecs(offset ) ;
311 mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime); 312 mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime);
312 newNextAlarm = true; 313 newNextAlarm = true;
313 mNextAlarmIncidence = incidence; 314 mNextAlarmIncidence = incidence;
314 } else { 315 } else {
315 if ( incidence == mNextAlarmIncidence ) { 316 if ( incidence == mNextAlarmIncidence ) {
316 computeNextAlarm = true; 317 computeNextAlarm = true;
317 } 318 }
318 } 319 }
319 } else { 320 } else {
320 if ( mNextAlarmIncidence == incidence ) { 321 if ( mNextAlarmIncidence == incidence ) {
321 computeNextAlarm = true; 322 computeNextAlarm = true;
322 } 323 }
323 } 324 }
324 } else { // deleted 325 } else { // deleted
325 if ( incidence == mNextAlarmIncidence ) { 326 if ( incidence == mNextAlarmIncidence ) {
326 computeNextAlarm = true; 327 computeNextAlarm = true;
327 } 328 }
328 } 329 }
329 } 330 }
330 if ( computeNextAlarm ) { 331 if ( computeNextAlarm ) {
331 deRegisterAlarm(); 332 deRegisterAlarm();
332 nextA = nextAlarm( 1000 ); 333 nextA = nextAlarm( 1000 );
333 if (! mNextAlarmIncidence ) { 334 if (! mNextAlarmIncidence ) {
334 return; 335 return;
335 } 336 }
336 newNextAlarm = true; 337 newNextAlarm = true;
337 } 338 }
338 if ( newNextAlarm ) 339 if ( newNextAlarm )
339 registerAlarm(); 340 registerAlarm();
340} 341}
341QString CalendarLocal:: getAlarmNotification() 342QString CalendarLocal:: getAlarmNotification()