Diffstat (limited to 'libopie2/opiepim/backend/ocontactaccessbackend.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | libopie2/opiepim/backend/ocontactaccessbackend.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend.cpp b/libopie2/opiepim/backend/ocontactaccessbackend.cpp index b4fdd46..c09427c 100644 --- a/libopie2/opiepim/backend/ocontactaccessbackend.cpp +++ b/libopie2/opiepim/backend/ocontactaccessbackend.cpp | |||
@@ -1,99 +1,100 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) 2004 Holger Freyther <freyther@handhelds.org> | 3 | Copyright (C) Holger Freyther <freyther@handhelds.org> |
4 | Copyright (C) Stefan Eilers <stefan@eilers-online.net> | ||
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 5 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 6 | .=l. |
6 | .>+-= | 7 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 8 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 13 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 14 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 17 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 21 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 22 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 24 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 25 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
28 | */ | 29 | */ |
29 | 30 | ||
30 | #include "ocontactaccessbackend.h" | 31 | #include "ocontactaccessbackend.h" |
31 | #include <opie2/private/opimcontactsortvector.h> | 32 | #include <opie2/private/opimcontactsortvector.h> |
32 | #include <opie2/ocontactaccess.h> | 33 | #include <opie2/ocontactaccess.h> |
33 | 34 | ||
34 | #include <opie2/odebug.h> | 35 | #include <opie2/odebug.h> |
35 | 36 | ||
36 | #include <qdatetime.h> | 37 | #include <qdatetime.h> |
37 | 38 | ||
38 | namespace Opie { | 39 | namespace Opie { |
39 | OPimContactAccessBackend::OPimContactAccessBackend() {} | 40 | OPimContactAccessBackend::OPimContactAccessBackend() {} |
40 | 41 | ||
41 | UIDArray OPimContactAccessBackend::queryByExample( const UIDArray& uid_array, const OPimContact& query, int settings, | 42 | UIDArray OPimContactAccessBackend::queryByExample( const UIDArray& uid_array, const OPimContact& query, int settings, |
42 | const QDateTime& d )const { | 43 | const QDateTime& d )const { |
43 | odebug << "Using Unaccelerated OPimContactAccessBackend implementation of queryByExample!" << oendl; | 44 | odebug << "Using Unaccelerated OPimContactAccessBackend implementation of queryByExample!" << oendl; |
44 | 45 | ||
45 | UIDArray m_currentQuery( uid_array.count() ); | 46 | UIDArray m_currentQuery( uid_array.count() ); |
46 | uint arraycounter = 0; | 47 | uint arraycounter = 0; |
47 | 48 | ||
48 | for( uint it = 0; it < uid_array.count(); ++it ){ | 49 | for( uint it = 0; it < uid_array.count(); ++it ){ |
49 | /* Search all fields and compare them with query object. Store them into list | 50 | /* Search all fields and compare them with query object. Store them into list |
50 | * if all fields matches. | 51 | * if all fields matches. |
51 | */ | 52 | */ |
52 | QDate* queryDate = 0l; | 53 | QDate* queryDate = 0l; |
53 | QDate* checkDate = 0l; | 54 | QDate* checkDate = 0l; |
54 | bool allcorrect = true; | 55 | bool allcorrect = true; |
55 | for ( int i = 0; i < Qtopia::Groups; i++ ) { | 56 | for ( int i = 0; i < Qtopia::Groups; i++ ) { |
56 | // Birthday and anniversary are special nonstring fields and should | 57 | // Birthday and anniversary are special nonstring fields and should |
57 | // be handled specially | 58 | // be handled specially |
58 | switch ( i ){ | 59 | switch ( i ){ |
59 | case Qtopia::Birthday: | 60 | case Qtopia::Birthday: |
60 | queryDate = new QDate( query.birthday() ); | 61 | queryDate = new QDate( query.birthday() ); |
61 | checkDate = new QDate( find( uid_array[it] ).birthday() ); | 62 | checkDate = new QDate( find( uid_array[it] ).birthday() ); |
62 | // fall through | 63 | // fall through |
63 | case Qtopia::Anniversary: | 64 | case Qtopia::Anniversary: |
64 | if ( queryDate == 0l ){ | 65 | if ( queryDate == 0l ){ |
65 | queryDate = new QDate( query.anniversary() ); | 66 | queryDate = new QDate( query.anniversary() ); |
66 | checkDate = new QDate( find( uid_array[it] ).anniversary() ); | 67 | checkDate = new QDate( find( uid_array[it] ).anniversary() ); |
67 | } | 68 | } |
68 | 69 | ||
69 | if ( queryDate->isValid() ){ | 70 | if ( queryDate->isValid() ){ |
70 | if( checkDate->isValid() ){ | 71 | if( checkDate->isValid() ){ |
71 | if ( settings & OPimContactAccess::DateYear ){ | 72 | if ( settings & OPimContactAccess::DateYear ){ |
72 | if ( queryDate->year() != checkDate->year() ) | 73 | if ( queryDate->year() != checkDate->year() ) |
73 | allcorrect = false; | 74 | allcorrect = false; |
74 | } | 75 | } |
75 | if ( settings & OPimContactAccess::DateMonth ){ | 76 | if ( settings & OPimContactAccess::DateMonth ){ |
76 | if ( queryDate->month() != checkDate->month() ) | 77 | if ( queryDate->month() != checkDate->month() ) |
77 | allcorrect = false; | 78 | allcorrect = false; |
78 | } | 79 | } |
79 | if ( settings & OPimContactAccess::DateDay ){ | 80 | if ( settings & OPimContactAccess::DateDay ){ |
80 | if ( queryDate->day() != checkDate->day() ) | 81 | if ( queryDate->day() != checkDate->day() ) |
81 | allcorrect = false; | 82 | allcorrect = false; |
82 | } | 83 | } |
83 | if ( settings & OPimContactAccess::DateDiff ) { | 84 | if ( settings & OPimContactAccess::DateDiff ) { |
84 | QDate current; | 85 | QDate current; |
85 | // If we get an additional date, we | 86 | // If we get an additional date, we |
86 | // will take this date instead of | 87 | // will take this date instead of |
87 | // the current one.. | 88 | // the current one.. |
88 | if ( !d.date().isValid() ) | 89 | if ( !d.date().isValid() ) |
89 | current = QDate::currentDate(); | 90 | current = QDate::currentDate(); |
90 | else | 91 | else |
91 | current = d.date(); | 92 | current = d.date(); |
92 | 93 | ||
93 | // We have to equalize the year, otherwise | 94 | // We have to equalize the year, otherwise |
94 | // the search will fail.. | 95 | // the search will fail.. |
95 | checkDate->setYMD( current.year(), | 96 | checkDate->setYMD( current.year(), |
96 | checkDate->month(), | 97 | checkDate->month(), |
97 | checkDate->day() ); | 98 | checkDate->day() ); |
98 | if ( *checkDate < current ) | 99 | if ( *checkDate < current ) |
99 | checkDate->setYMD( current.year()+1, | 100 | checkDate->setYMD( current.year()+1, |