-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 @@ -226,14 +226,18 @@ void CalendarLocal::deleteEvent( Event *event ) Event *CalendarLocal::event( const QString &uid ) { - - Event *event; - - for ( event = mEventList.first(); event; event = mEventList.next() ) { - if ( event->uid() == uid && event->calEnabled() ) { - return event; + Event *event; + Event *retVal = 0; + for ( event = mEventList.first(); event; event = mEventList.next() ) { + if ( event->calEnabled() && event->uid() == uid ) { + if ( retVal ) { + if ( retVal->calID() > event->calID() ) { + retVal = event; + } + } else { + retVal = event; + } + } } - } - - return 0; + return retVal; } bool CalendarLocal::addTodoNoDup( Todo *todo ) @@ -338,10 +342,18 @@ Event *CalendarLocal::event( QString syncProf, QString id ) Todo *CalendarLocal::todo( const QString &uid ) { - Todo *todo; + Todo *todo;; + Todo *retVal = 0; for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { - if ( todo->calEnabled() && todo->uid() == uid ) return todo; + if ( todo->calEnabled() && todo->uid() == uid ) { + if ( retVal ) { + if ( retVal->calID() > todo->calID() ) { + retVal = todo; + } + } else { + retVal = todo; + } + } } - - return 0; + return retVal; } QString CalendarLocal::nextSummary() const @@ -787,9 +799,16 @@ Journal *CalendarLocal::journal( const QDate &date ) Journal *CalendarLocal::journal( const QString &uid ) { - for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) - if ( it->calEnabled() && it->uid() == uid ) - return it; - - return 0; + Journal * retVal = 0; + for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) + if ( it->calEnabled() && it->uid() == uid ) { + if ( retVal ) { + if ( retVal->calID() > it->calID() ) { + retVal = it; + } + } else { + retVal = it; + } + } + return retVal; } |