summaryrefslogtreecommitdiff
authorzecke <zecke>2004-02-18 23:19:17 (UTC)
committer zecke <zecke>2004-02-18 23:19:17 (UTC)
commit28b63b3270b8162fcea4449b53b75fa325d740ad (patch) (unidiff)
treeeed2c5064cd05c080ac6e9da38996857cd9008b7
parentf8caabcef314cad5007fec940af48d8cd4612c49 (diff)
downloadopie-28b63b3270b8162fcea4449b53b75fa325d740ad.zip
opie-28b63b3270b8162fcea4449b53b75fa325d740ad.tar.gz
opie-28b63b3270b8162fcea4449b53b75fa325d740ad.tar.bz2
Add Documentation on how we search and why we do stuff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebook.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp
index 832b2f8..24affd0 100644
--- a/core/pim/datebook/datebook.cpp
+++ b/core/pim/datebook/datebook.cpp
@@ -988,50 +988,62 @@ void DateBook::slotDoFind( const QString& txt, const QDate &dt,
988 988
989 QRegExp r( txt ); 989 QRegExp r( txt );
990 r.setCaseSensitive( caseSensitive ); 990 r.setCaseSensitive( caseSensitive );
991 991
992 992
993 static Event rev, nonrev; 993 static Event rev, nonrev;
994 if ( !inSearch ) { 994 if ( !inSearch ) {
995 rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) ); 995 rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) );
996 nonrev.setStart( rev.start() ); 996 nonrev.setStart( rev.start() );
997 inSearch = true; 997 inSearch = true;
998 } 998 }
999 static QDate searchDate = dt; 999 static QDate searchDate = dt;
1000 // if true at the end we will start at the begin again and afterwards
1001 // we will emit string not found
1000 static bool wrapAround = true; 1002 static bool wrapAround = true;
1001 bool candidtate; 1003 bool candidtate;
1002 candidtate = false; 1004 candidtate = false;
1003 1005
1004 QValueList<Event> repeats = db->getRawRepeats(); 1006 QValueList<Event> repeats = db->getRawRepeats();
1005 1007
1006 // find the candidate for the first repeat that matches... 1008 // find the candidate for the first repeat that matches...
1009 // first check if there can ever be a match and then compute
1010 // the next occurence from start. See if this event is closer
1011 // to the beginning (start. next < dtEnd) and not smaller then the last
1012 // result. If we find a canditate we set the dtEnd to the time
1013 // of the ocurrence and rev to this occurence.
1014 // set wrap around to true because there might be more events coming
1015 // and we're not at the end.
1007 QValueListConstIterator<Event> it; 1016 QValueListConstIterator<Event> it;
1008 QDate start = dt; 1017 QDate start = dt;
1009 for ( it = repeats.begin(); it != repeats.end(); ++it ) { 1018 for ( it = repeats.begin(); it != repeats.end(); ++it ) {
1010 if ( catComp( (*it).categories(), category ) ) { 1019 if ( catComp( (*it).categories(), category ) ) {
1011 if ( (*it).match( r ) ) { 1020 if ( (*it).match( r ) ) {
1012 if ( nextOccurance( *it, start, next ) ) { 1021 if ( nextOccurance( *it, start, next ) ) {
1013 if ( next < dtEnd && !(next <= rev.start() ) ) { 1022 if ( next < dtEnd && !(next <= rev.start() ) ) {
1014 rev = *it; 1023 rev = *it;
1015 dtEnd = next; 1024 dtEnd = next;
1016 rev.setStart( next ); 1025 rev.setStart( next );
1017 candidtate = true; 1026 candidtate = true;
1018 wrapAround = true; 1027 wrapAround = true;
1019 } 1028 }
1020 } 1029 }
1021 } 1030 }
1022 } 1031 }
1023 } 1032 }
1024 1033
1025 // now the for first non repeat... 1034 // now the for first non repeat...
1035 // dtEnd is set by the previous iteration of repeatingEvents
1036 // check if we find a closer item. Also set dtEnd to find even
1037 // more close occurrence
1026 QValueList<Event> nonRepeats = db->getNonRepeatingEvents( dt, dtEnd.date() ); 1038 QValueList<Event> nonRepeats = db->getNonRepeatingEvents( dt, dtEnd.date() );
1027 qHeapSort( nonRepeats.begin(), nonRepeats.end() ); 1039 qHeapSort( nonRepeats.begin(), nonRepeats.end() );
1028 for ( it = nonRepeats.begin(); it != nonRepeats.end(); ++it ) { 1040 for ( it = nonRepeats.begin(); it != nonRepeats.end(); ++it ) {
1029 if ( catComp( (*it).categories(), category ) ) { 1041 if ( catComp( (*it).categories(), category ) ) {
1030 if ( (*it).start() < dtEnd ) { 1042 if ( (*it).start() < dtEnd ) {
1031 if ( (*it).match( r ) && !(*it <= nonrev) ) { 1043 if ( (*it).match( r ) && !(*it <= nonrev) ) {
1032 nonrev = *it; 1044 nonrev = *it;
1033 dtEnd = nonrev.start(); 1045 dtEnd = nonrev.start();
1034 candidtate = true; 1046 candidtate = true;
1035 wrapAround = true; 1047 wrapAround = true;
1036 break; 1048 break;
1037 } 1049 }