author | zautrix <zautrix> | 2005-06-14 08:23:19 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-06-14 08:23:19 (UTC) |
commit | 1dccb9dd9ea32989ecec33c72a3ebd873dce048e (patch) (side-by-side diff) | |
tree | 6b7dd7e4696c91a3afaba89225dd4f31f376a30b /libkcal/calendarlocal.cpp | |
parent | b3743f5abe0a95c9ffeadf6701c9943f604febd6 (diff) | |
download | kdepimpi-1dccb9dd9ea32989ecec33c72a3ebd873dce048e.zip kdepimpi-1dccb9dd9ea32989ecec33c72a3ebd873dce048e.tar.gz kdepimpi-1dccb9dd9ea32989ecec33c72a3ebd873dce048e.tar.bz2 |
faster filter
-rw-r--r-- | libkcal/calendarlocal.cpp | 47 |
1 files changed, 33 insertions, 14 deletions
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index 749d9f6..336c3e8 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp @@ -224,18 +224,22 @@ void CalendarLocal::deleteEvent( Event *event ) Event *CalendarLocal::event( const QString &uid ) { - Event *event; - + Event *retVal = 0; for ( event = mEventList.first(); event; event = mEventList.next() ) { - if ( event->uid() == uid && event->calEnabled() ) { - return event; + 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 ) { Todo * eve; @@ -336,14 +340,22 @@ Event *CalendarLocal::event( QString syncProf, QString id ) return 0; } 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; } - - return 0; + } else { + retVal = todo; + } + } + } + return retVal; } QString CalendarLocal::nextSummary() const { return mNextSummary; @@ -785,13 +797,20 @@ Journal *CalendarLocal::journal( const QDate &date ) } Journal *CalendarLocal::journal( const QString &uid ) { + Journal * retVal = 0; for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) - if ( it->calEnabled() && it->uid() == uid ) - return it; - - return 0; + if ( it->calEnabled() && it->uid() == uid ) { + if ( retVal ) { + if ( retVal->calID() > it->calID() ) { + retVal = it; + } + } else { + retVal = it; + } + } + return retVal; } QPtrList<Journal> CalendarLocal::journals() { |