-rw-r--r-- | libkcal/calendarlocal.cpp | 47 | ||||
-rw-r--r-- | libkcal/calfilter.cpp | 12 | ||||
-rw-r--r-- | libkcal/incidence.cpp | 5 | ||||
-rw-r--r-- | libkcal/incidence.h | 1 |
4 files changed, 45 insertions, 20 deletions
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index 749d9f6..336c3e8 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp @@ -227,12 +227,16 @@ 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; } @@ -339,8 +343,16 @@ 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; } @@ -788,7 +800,14 @@ 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; } diff --git a/libkcal/calfilter.cpp b/libkcal/calfilter.cpp index 3510c7d..72f70c2 100644 --- a/libkcal/calfilter.cpp +++ b/libkcal/calfilter.cpp @@ -164,5 +164,5 @@ bool CalFilter::filterIncidence(Incidence *incidence) it != mCategoryList.end(); ++it ) { - QStringList incidenceCategories = incidence->categories(); - for (QStringList::Iterator it2 = incidenceCategories.begin(); - it2 != incidenceCategories.end(); ++it2 ) { + //QStringList incidenceCategories = incidence->categories(); + for (QStringList::Iterator it2 = incidence->categoriesP()->begin(); + it2 != incidence->categoriesP()->end(); ++it2 ) { if ((*it) == (*it2)) { @@ -176,5 +176,5 @@ bool CalFilter::filterIncidence(Incidence *incidence) it != mCategoryList.end(); ++it ) { - QStringList incidenceCategories = incidence->categories(); - for (QStringList::Iterator it2 = incidenceCategories.begin(); - it2 != incidenceCategories.end(); ++it2 ) { + //QStringList incidenceCategories = incidence->categories(); + for (QStringList::Iterator it2 = incidence->categoriesP()->begin(); + it2 != incidence->categoriesP()->end(); ++it2 ) { if ((*it) == (*it2)) { diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp index 4382416..11f7ecc 100644 --- a/libkcal/incidence.cpp +++ b/libkcal/incidence.cpp @@ -398,2 +398,7 @@ void Incidence::setCategories(const QString &catStr) } +// using this makes filtering 3 times faster +QStringList* Incidence::categoriesP() +{ + return &mCategories; +} diff --git a/libkcal/incidence.h b/libkcal/incidence.h index fc97ce9..c88ba2f 100644 --- a/libkcal/incidence.h +++ b/libkcal/incidence.h @@ -159,2 +159,3 @@ class Incidence : public IncidenceBase QStringList categories() const; + QStringList* categoriesP(); /** return categories as a comma separated string */ |