author | zautrix <zautrix> | 2005-06-14 08:23:19 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-06-14 08:23:19 (UTC) |
commit | 1dccb9dd9ea32989ecec33c72a3ebd873dce048e (patch) (unidiff) | |
tree | 6b7dd7e4696c91a3afaba89225dd4f31f376a30b | |
parent | b3743f5abe0a95c9ffeadf6701c9943f604febd6 (diff) | |
download | kdepimpi-1dccb9dd9ea32989ecec33c72a3ebd873dce048e.zip kdepimpi-1dccb9dd9ea32989ecec33c72a3ebd873dce048e.tar.gz kdepimpi-1dccb9dd9ea32989ecec33c72a3ebd873dce048e.tar.bz2 |
faster filter
-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 | |||
@@ -225,16 +225,20 @@ void CalendarLocal::deleteEvent( Event *event ) | |||
225 | 225 | ||
226 | Event *CalendarLocal::event( const QString &uid ) | 226 | Event *CalendarLocal::event( const QString &uid ) |
227 | { | 227 | { |
228 | |||
229 | Event *event; | 228 | Event *event; |
230 | 229 | Event *retVal = 0; | |
231 | for ( event = mEventList.first(); event; event = mEventList.next() ) { | 230 | for ( event = mEventList.first(); event; event = mEventList.next() ) { |
232 | if ( event->uid() == uid && event->calEnabled() ) { | 231 | if ( event->calEnabled() && event->uid() == uid ) { |
233 | return event; | 232 | if ( retVal ) { |
233 | if ( retVal->calID() > event->calID() ) { | ||
234 | retVal = event; | ||
235 | } | ||
236 | } else { | ||
237 | retVal = event; | ||
234 | } | 238 | } |
235 | } | 239 | } |
236 | 240 | } | |
237 | return 0; | 241 | return retVal; |
238 | } | 242 | } |
239 | bool CalendarLocal::addTodoNoDup( Todo *todo ) | 243 | bool CalendarLocal::addTodoNoDup( Todo *todo ) |
240 | { | 244 | { |
@@ -337,12 +341,20 @@ Event *CalendarLocal::event( QString syncProf, QString id ) | |||
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; | ||
343 | } | 351 | } |
344 | 352 | } else { | |
345 | return 0; | 353 | retVal = todo; |
354 | } | ||
355 | } | ||
356 | } | ||
357 | return retVal; | ||
346 | } | 358 | } |
347 | QString CalendarLocal::nextSummary() const | 359 | QString CalendarLocal::nextSummary() const |
348 | { | 360 | { |
@@ -786,11 +798,18 @@ Journal *CalendarLocal::journal( const QDate &date ) | |||
786 | 798 | ||
787 | Journal *CalendarLocal::journal( const QString &uid ) | 799 | Journal *CalendarLocal::journal( const QString &uid ) |
788 | { | 800 | { |
801 | Journal * retVal = 0; | ||
789 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 802 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
790 | if ( it->calEnabled() && it->uid() == uid ) | 803 | if ( it->calEnabled() && it->uid() == uid ) { |
791 | return it; | 804 | if ( retVal ) { |
792 | 805 | if ( retVal->calID() > it->calID() ) { | |
793 | return 0; | 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() |
diff --git a/libkcal/calfilter.cpp b/libkcal/calfilter.cpp index 3510c7d..72f70c2 100644 --- a/libkcal/calfilter.cpp +++ b/libkcal/calfilter.cpp | |||
@@ -162,9 +162,9 @@ bool CalFilter::filterIncidence(Incidence *incidence) | |||
162 | if (mCriteria & ShowCategories) { | 162 | if (mCriteria & ShowCategories) { |
163 | for (QStringList::Iterator it = mCategoryList.begin(); | 163 | for (QStringList::Iterator it = mCategoryList.begin(); |
164 | it != mCategoryList.end(); ++it ) { | 164 | it != mCategoryList.end(); ++it ) { |
165 | QStringList incidenceCategories = incidence->categories(); | 165 | //QStringList incidenceCategories = incidence->categories(); |
166 | for (QStringList::Iterator it2 = incidenceCategories.begin(); | 166 | for (QStringList::Iterator it2 = incidence->categoriesP()->begin(); |
167 | it2 != incidenceCategories.end(); ++it2 ) { | 167 | it2 != incidence->categoriesP()->end(); ++it2 ) { |
168 | if ((*it) == (*it2)) { | 168 | if ((*it) == (*it2)) { |
169 | return true; | 169 | return true; |
170 | } | 170 | } |
@@ -174,9 +174,9 @@ bool CalFilter::filterIncidence(Incidence *incidence) | |||
174 | } else { | 174 | } else { |
175 | for (QStringList::Iterator it = mCategoryList.begin(); | 175 | for (QStringList::Iterator it = mCategoryList.begin(); |
176 | it != mCategoryList.end(); ++it ) { | 176 | it != mCategoryList.end(); ++it ) { |
177 | QStringList incidenceCategories = incidence->categories(); | 177 | //QStringList incidenceCategories = incidence->categories(); |
178 | for (QStringList::Iterator it2 = incidenceCategories.begin(); | 178 | for (QStringList::Iterator it2 = incidence->categoriesP()->begin(); |
179 | it2 != incidenceCategories.end(); ++it2 ) { | 179 | it2 != incidence->categoriesP()->end(); ++it2 ) { |
180 | if ((*it) == (*it2)) { | 180 | if ((*it) == (*it2)) { |
181 | return false; | 181 | return false; |
182 | } | 182 | } |
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp index 4382416..11f7ecc 100644 --- a/libkcal/incidence.cpp +++ b/libkcal/incidence.cpp | |||
@@ -396,6 +396,11 @@ void Incidence::setCategories(const QString &catStr) | |||
396 | checkCategories(); | 396 | checkCategories(); |
397 | updated(); | 397 | updated(); |
398 | } | 398 | } |
399 | // using this makes filtering 3 times faster | ||
400 | QStringList* Incidence::categoriesP() | ||
401 | { | ||
402 | return &mCategories; | ||
403 | } | ||
399 | 404 | ||
400 | QStringList Incidence::categories() const | 405 | QStringList Incidence::categories() const |
401 | { | 406 | { |
diff --git a/libkcal/incidence.h b/libkcal/incidence.h index fc97ce9..c88ba2f 100644 --- a/libkcal/incidence.h +++ b/libkcal/incidence.h | |||
@@ -157,6 +157,7 @@ class Incidence : public IncidenceBase | |||
157 | void setCategories(const QString &catStr); | 157 | void setCategories(const QString &catStr); |
158 | /** return categories in a list */ | 158 | /** return categories in a list */ |
159 | QStringList categories() const; | 159 | QStringList categories() const; |
160 | QStringList* categoriesP(); | ||
160 | /** return categories as a comma separated string */ | 161 | /** return categories as a comma separated string */ |
161 | QString categoriesStr(); | 162 | QString categoriesStr(); |
162 | QString categoriesStrWithSpace(); | 163 | QString categoriesStrWithSpace(); |