-rw-r--r-- | libkcal/calendarlocal.cpp | 55 |
1 files changed, 37 insertions, 18 deletions
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index 749d9f6..336c3e8 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp | |||
@@ -222,22 +222,26 @@ void CalendarLocal::deleteEvent( Event *event ) | |||
222 | } | 222 | } |
223 | } | 223 | } |
224 | 224 | ||
225 | 225 | ||
226 | Event *CalendarLocal::event( const QString &uid ) | 226 | Event *CalendarLocal::event( const QString &uid ) |
227 | { | 227 | { |
228 | 228 | Event *event; | |
229 | Event *event; | 229 | Event *retVal = 0; |
230 | 230 | for ( event = mEventList.first(); event; event = mEventList.next() ) { | |
231 | for ( event = mEventList.first(); event; event = mEventList.next() ) { | 231 | if ( event->calEnabled() && event->uid() == uid ) { |
232 | if ( event->uid() == uid && event->calEnabled() ) { | 232 | if ( retVal ) { |
233 | return event; | 233 | if ( retVal->calID() > event->calID() ) { |
234 | retVal = event; | ||
235 | } | ||
236 | } else { | ||
237 | retVal = event; | ||
238 | } | ||
239 | } | ||
234 | } | 240 | } |
235 | } | 241 | return retVal; |
236 | |||
237 | return 0; | ||
238 | } | 242 | } |
239 | bool CalendarLocal::addTodoNoDup( Todo *todo ) | 243 | bool CalendarLocal::addTodoNoDup( Todo *todo ) |
240 | { | 244 | { |
241 | Todo * eve; | 245 | Todo * eve; |
242 | for ( eve = mTodoList.first(); eve ; eve = mTodoList.next() ) { | 246 | for ( eve = mTodoList.first(); eve ; eve = mTodoList.next() ) { |
243 | if ( *eve == *todo ) { | 247 | if ( *eve == *todo ) { |
@@ -334,18 +338,26 @@ Event *CalendarLocal::event( QString syncProf, QString id ) | |||
334 | } | 338 | } |
335 | 339 | ||
336 | return 0; | 340 | return 0; |
337 | } | 341 | } |
338 | Todo *CalendarLocal::todo( const QString &uid ) | 342 | Todo *CalendarLocal::todo( const QString &uid ) |
339 | { | 343 | { |
340 | Todo *todo; | 344 | Todo *todo;; |
345 | Todo *retVal = 0; | ||
341 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { | 346 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { |
342 | if ( todo->calEnabled() && todo->uid() == uid ) return todo; | 347 | if ( todo->calEnabled() && todo->uid() == uid ) { |
348 | if ( retVal ) { | ||
349 | if ( retVal->calID() > todo->calID() ) { | ||
350 | retVal = todo; | ||
351 | } | ||
352 | } else { | ||
353 | retVal = todo; | ||
354 | } | ||
355 | } | ||
343 | } | 356 | } |
344 | 357 | return retVal; | |
345 | return 0; | ||
346 | } | 358 | } |
347 | QString CalendarLocal::nextSummary() const | 359 | QString CalendarLocal::nextSummary() const |
348 | { | 360 | { |
349 | return mNextSummary; | 361 | return mNextSummary; |
350 | } | 362 | } |
351 | QDateTime CalendarLocal::nextAlarmEventDateTime() const | 363 | QDateTime CalendarLocal::nextAlarmEventDateTime() const |
@@ -783,17 +795,24 @@ Journal *CalendarLocal::journal( const QDate &date ) | |||
783 | 795 | ||
784 | return 0; | 796 | return 0; |
785 | } | 797 | } |
786 | 798 | ||
787 | Journal *CalendarLocal::journal( const QString &uid ) | 799 | Journal *CalendarLocal::journal( const QString &uid ) |
788 | { | 800 | { |
789 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 801 | Journal * retVal = 0; |
790 | if ( it->calEnabled() && it->uid() == uid ) | 802 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
791 | return it; | 803 | if ( it->calEnabled() && it->uid() == uid ) { |
792 | 804 | if ( retVal ) { | |
793 | return 0; | 805 | if ( retVal->calID() > it->calID() ) { |
806 | retVal = it; | ||
807 | } | ||
808 | } else { | ||
809 | retVal = it; | ||
810 | } | ||
811 | } | ||
812 | return retVal; | ||
794 | } | 813 | } |
795 | 814 | ||
796 | QPtrList<Journal> CalendarLocal::journals() | 815 | QPtrList<Journal> CalendarLocal::journals() |
797 | { | 816 | { |
798 | QPtrList<Journal> el; | 817 | QPtrList<Journal> el; |
799 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 818 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |