author | eilers <eilers> | 2003-01-03 12:31:28 (UTC) |
---|---|---|
committer | eilers <eilers> | 2003-01-03 12:31:28 (UTC) |
commit | 54ebecbfd86a9ce6782dc55dad7ae15c73adef21 (patch) (side-by-side diff) | |
tree | a3934153aafb2d5e05186a5965e45f6d4dc267ec /libopie | |
parent | f1a3efd2d335b59aaa63bbf542abba524774b2d3 (diff) | |
download | opie-54ebecbfd86a9ce6782dc55dad7ae15c73adef21.zip opie-54ebecbfd86a9ce6782dc55dad7ae15c73adef21.tar.gz opie-54ebecbfd86a9ce6782dc55dad7ae15c73adef21.tar.bz2 |
Bugfix for calculating data diffs..
-rw-r--r-- | libopie/pim/ocontactaccessbackend_xml.h | 57 |
1 files changed, 39 insertions, 18 deletions
diff --git a/libopie/pim/ocontactaccessbackend_xml.h b/libopie/pim/ocontactaccessbackend_xml.h index c6e6cbc..6a1c91d 100644 --- a/libopie/pim/ocontactaccessbackend_xml.h +++ b/libopie/pim/ocontactaccessbackend_xml.h @@ -8,24 +8,27 @@ * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * ===================================================================== * ToDo: XML-Backend: Automatic reload if something was changed... * * * ===================================================================== * Version: $Id$ * ===================================================================== * History: * $Log$ + * Revision 1.11 2003/01/03 12:31:28 eilers + * Bugfix for calculating data diffs.. + * * Revision 1.10 2003/01/02 14:27:12 eilers * Improved query by example: Search by date is possible.. First step * for a today plugin for birthdays.. * * Revision 1.9 2002/12/08 12:48:57 eilers * Moved journal-enum from ocontact into i the xml-backend.. * * Revision 1.8 2002/11/14 17:04:24 eilers * Sorting will now work if fullname is identical on some entries * * Revision 1.7 2002/11/13 15:02:46 eilers * Small Bug in sorted fixed @@ -226,55 +229,73 @@ class OContactAccessBackend_XML : public OContactAccessBackend { QValueListConstIterator<OContact> it; uint arraycounter = 0; for( it = m_contactList.begin(); it != m_contactList.end(); ++it ){ /* Search all fields and compare them with query object. Store them into list * if all fields matches. */ QDate* queryDate = 0l; QDate* checkDate = 0l; bool allcorrect = true; for ( int i = 0; i < Qtopia::Groups; i++ ) { // Birthday and anniversary are special nonstring fields and should - // be handled especially + // be handled specially switch ( i ){ case Qtopia::Birthday: queryDate = new QDate( query.birthday() ); checkDate = new QDate( (*it).birthday() ); case Qtopia::Anniversary: if ( queryDate == 0l ){ queryDate = new QDate( query.anniversary() ); checkDate = new QDate( (*it).anniversary() ); } if ( queryDate->isValid() ){ - if ( settings & OContactAccess::DateYear ){ - if ( queryDate->year() != checkDate->year() ) - allcorrect = false; - } - if ( settings & OContactAccess::DateMonth ){ - if ( queryDate->month() != checkDate->month() ) - allcorrect = false; - } - if ( settings & OContactAccess::DateDay ){ - if ( queryDate->day() != checkDate->day() ) - allcorrect = false; - } - if ( settings & OContactAccess::DateDiff ) { - QDate current = QDate::currentDate(); - if ( current.daysTo( *queryDate ) > 0 ){ - if ( !( ( *checkDate >= current ) && - ( *checkDate <= *queryDate ) ) ) + if( checkDate->isValid() ){ + if ( settings & OContactAccess::DateYear ){ + if ( queryDate->year() != checkDate->year() ) + allcorrect = false; + } + if ( settings & OContactAccess::DateMonth ){ + if ( queryDate->month() != checkDate->month() ) + allcorrect = false; + } + if ( settings & OContactAccess::DateDay ){ + if ( queryDate->day() != checkDate->day() ) allcorrect = false; + } + if ( settings & OContactAccess::DateDiff ) { + QDate current = QDate::currentDate(); + // We have to equalize the year, otherwise + // the search will fail.. + checkDate->setYMD( current.year(), checkDate->month(), checkDate->day() ); + if ( *checkDate < current ) + checkDate->setYMD( current.year()+1, + checkDate->month(), + checkDate->day() ); + // qWarning("Checking if %s is between %s and %s ! ", + // checkDate->toString().latin1(), + // current.toString().latin1(), + // queryDate->toString().latin1() ); + if ( current.daysTo( *queryDate ) > 0 ){ + if ( !( ( *checkDate >= current ) && + ( *checkDate <= *queryDate ) ) ){ + allcorrect = false; + //qWarning (" Nope!.."); + } + } } + } else{ + // checkDate is invalid. Therfore this entry is always rejected + allcorrect = false; } } delete queryDate; queryDate = 0l; delete checkDate; checkDate = 0l; break; default: /* Just compare fields which are not empty in the query object */ if ( !query.field(i).isEmpty() ){ switch ( settings & ~( OContactAccess::IgnoreCase |