summaryrefslogtreecommitdiff
authorzecke <zecke>2004-02-18 23:19:17 (UTC)
committer zecke <zecke>2004-02-18 23:19:17 (UTC)
commit28b63b3270b8162fcea4449b53b75fa325d740ad (patch) (side-by-side diff)
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,
QRegExp r( txt );
r.setCaseSensitive( caseSensitive );
static Event rev, nonrev;
if ( !inSearch ) {
rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) );
nonrev.setStart( rev.start() );
inSearch = true;
}
static QDate searchDate = dt;
+ // if true at the end we will start at the begin again and afterwards
+ // we will emit string not found
static bool wrapAround = true;
bool candidtate;
candidtate = false;
QValueList<Event> repeats = db->getRawRepeats();
// find the candidate for the first repeat that matches...
+ // first check if there can ever be a match and then compute
+ // the next occurence from start. See if this event is closer
+ // to the beginning (start. next < dtEnd) and not smaller then the last
+ // result. If we find a canditate we set the dtEnd to the time
+ // of the ocurrence and rev to this occurence.
+ // set wrap around to true because there might be more events coming
+ // and we're not at the end.
QValueListConstIterator<Event> it;
QDate start = dt;
for ( it = repeats.begin(); it != repeats.end(); ++it ) {
if ( catComp( (*it).categories(), category ) ) {
if ( (*it).match( r ) ) {
if ( nextOccurance( *it, start, next ) ) {
if ( next < dtEnd && !(next <= rev.start() ) ) {
rev = *it;
dtEnd = next;
rev.setStart( next );
candidtate = true;
wrapAround = true;
}
}
}
}
}
// now the for first non repeat...
+ // dtEnd is set by the previous iteration of repeatingEvents
+ // check if we find a closer item. Also set dtEnd to find even
+ // more close occurrence
QValueList<Event> nonRepeats = db->getNonRepeatingEvents( dt, dtEnd.date() );
qHeapSort( nonRepeats.begin(), nonRepeats.end() );
for ( it = nonRepeats.begin(); it != nonRepeats.end(); ++it ) {
if ( catComp( (*it).categories(), category ) ) {
if ( (*it).start() < dtEnd ) {
if ( (*it).match( r ) && !(*it <= nonrev) ) {
nonrev = *it;
dtEnd = nonrev.start();
candidtate = true;
wrapAround = true;
break;
}