-rw-r--r-- | libopie2/opiepim/backend/ocontactaccessbackend.cpp | 5 | ||||
-rw-r--r-- | libopie2/opiepim/backend/ocontactaccessbackend.h | 3 | ||||
-rw-r--r-- | libopie2/opiepim/backend/odatebookaccessbackend.cpp | 58 |
3 files changed, 60 insertions, 6 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,51 +1,52 @@ | |||
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 | */ |
@@ -192,97 +193,97 @@ bool OPimContactAccessBackend::hasQuerySettings (uint querySettings) const | |||
192 | { | 193 | { |
193 | /* OPimContactAccess::IgnoreCase, DateDiff, DateYear, DateMonth, DateDay | 194 | /* OPimContactAccess::IgnoreCase, DateDiff, DateYear, DateMonth, DateDay |
194 | * may be added with any of the other settings. IgnoreCase should never used alone. | 195 | * may be added with any of the other settings. IgnoreCase should never used alone. |
195 | * Wildcards, RegExp, ExactMatch should never used at the same time... | 196 | * Wildcards, RegExp, ExactMatch should never used at the same time... |
196 | */ | 197 | */ |
197 | 198 | ||
198 | // Step 1: Check whether the given settings are supported by this backend | 199 | // Step 1: Check whether the given settings are supported by this backend |
199 | if ( ( querySettings & ( | 200 | if ( ( querySettings & ( |
200 | OPimContactAccess::IgnoreCase | 201 | OPimContactAccess::IgnoreCase |
201 | | OPimContactAccess::WildCards | 202 | | OPimContactAccess::WildCards |
202 | | OPimContactAccess::DateDiff | 203 | | OPimContactAccess::DateDiff |
203 | | OPimContactAccess::DateYear | 204 | | OPimContactAccess::DateYear |
204 | | OPimContactAccess::DateMonth | 205 | | OPimContactAccess::DateMonth |
205 | | OPimContactAccess::DateDay | 206 | | OPimContactAccess::DateDay |
206 | | OPimContactAccess::RegExp | 207 | | OPimContactAccess::RegExp |
207 | | OPimContactAccess::ExactMatch | 208 | | OPimContactAccess::ExactMatch |
208 | ) ) != querySettings ) | 209 | ) ) != querySettings ) |
209 | return false; | 210 | return false; |
210 | 211 | ||
211 | // Step 2: Check whether the given combinations are ok.. | 212 | // Step 2: Check whether the given combinations are ok.. |
212 | 213 | ||
213 | // IngoreCase alone is invalid | 214 | // IngoreCase alone is invalid |
214 | if ( querySettings == OPimContactAccess::IgnoreCase ) | 215 | if ( querySettings == OPimContactAccess::IgnoreCase ) |
215 | return false; | 216 | return false; |
216 | 217 | ||
217 | // WildCards, RegExp and ExactMatch should never used at the same time | 218 | // WildCards, RegExp and ExactMatch should never used at the same time |
218 | switch ( querySettings & ~( OPimContactAccess::IgnoreCase | 219 | switch ( querySettings & ~( OPimContactAccess::IgnoreCase |
219 | | OPimContactAccess::DateDiff | 220 | | OPimContactAccess::DateDiff |
220 | | OPimContactAccess::DateYear | 221 | | OPimContactAccess::DateYear |
221 | | OPimContactAccess::DateMonth | 222 | | OPimContactAccess::DateMonth |
222 | | OPimContactAccess::DateDay | 223 | | OPimContactAccess::DateDay |
223 | ) | 224 | ) |
224 | ){ | 225 | ){ |
225 | case OPimContactAccess::RegExp: | 226 | case OPimContactAccess::RegExp: |
226 | return ( true ); | 227 | return ( true ); |
227 | case OPimContactAccess::WildCards: | 228 | case OPimContactAccess::WildCards: |
228 | return ( true ); | 229 | return ( true ); |
229 | case OPimContactAccess::ExactMatch: | 230 | case OPimContactAccess::ExactMatch: |
230 | return ( true ); | 231 | return ( true ); |
231 | case 0: // one of the upper removed bits were set.. | 232 | case 0: // one of the upper removed bits were set.. |
232 | return ( true ); | 233 | return ( true ); |
233 | default: | 234 | default: |
234 | return ( false ); | 235 | return ( false ); |
235 | } | 236 | } |
236 | } | 237 | } |
237 | 238 | ||
238 | 239 | ||
239 | UIDArray OPimContactAccessBackend::sorted( const UIDArray& ar, bool asc, int sortOrder, | 240 | UIDArray OPimContactAccessBackend::sorted( const UIDArray& ar, bool asc, int sortOrder, |
240 | int filter, const QArray<int>& categories)const { | 241 | int filter, const QArray<int>& categories )const { |
241 | odebug << "Using Unaccelerated OPimContactAccessBackend sorted Implementation" << oendl; | 242 | odebug << "Using Unaccelerated OPimContactAccessBackend sorted Implementation" << oendl; |
242 | 243 | ||
243 | Internal::OPimContactSortVector vector(ar.count(), asc, sortOrder ); | 244 | Internal::OPimContactSortVector vector(ar.count(), asc, sortOrder ); |
244 | 245 | ||
245 | int item = 0; | 246 | int item = 0; |
246 | uint cat_count = categories.count(); | 247 | uint cat_count = categories.count(); |
247 | uint eve_count = ar.count(); | 248 | uint eve_count = ar.count(); |
248 | bool bCat = filter & OPimContactAccess::FilterCategory ? true : false; | 249 | bool bCat = filter & OPimContactAccess::FilterCategory ? true : false; |
249 | bool catPassed = false; | 250 | bool catPassed = false; |
250 | int cat; | 251 | int cat; |
251 | 252 | ||
252 | for ( uint i = 0; i < eve_count; ++i ) { | 253 | for ( uint i = 0; i < eve_count; ++i ) { |
253 | OPimContact contact = find( ar[i], ar, i, Frontend::Forward ); | 254 | OPimContact contact = find( ar[i], ar, i, Frontend::Forward ); |
254 | if ( contact.isEmpty() ) | 255 | if ( contact.isEmpty() ) |
255 | continue; | 256 | continue; |
256 | 257 | ||
257 | /* show category */ | 258 | /* show category */ |
258 | /* -1 == unfiled */ | 259 | /* -1 == unfiled */ |
259 | catPassed = false; | 260 | catPassed = false; |
260 | for ( uint cat_nu = 0; cat_nu < cat_count; ++cat_nu ) { | 261 | for ( uint cat_nu = 0; cat_nu < cat_count; ++cat_nu ) { |
261 | cat = categories[cat_nu]; | 262 | cat = categories[cat_nu]; |
262 | if ( bCat && cat == -1 ) { | 263 | if ( bCat && cat == -1 ) { |
263 | if(!contact.categories().isEmpty() ) | 264 | if(!contact.categories().isEmpty() ) |
264 | continue; | 265 | continue; |
265 | } else if ( bCat && cat != 0) | 266 | } else if ( bCat && cat != 0) |
266 | if (!contact.categories().contains( cat ) ) | 267 | if (!contact.categories().contains( cat ) ) |
267 | continue; | 268 | continue; |
268 | catPassed = true; | 269 | catPassed = true; |
269 | break; | 270 | break; |
270 | } | 271 | } |
271 | 272 | ||
272 | /* | 273 | /* |
273 | * If none of the Categories matched | 274 | * If none of the Categories matched |
274 | * continue | 275 | * continue |
275 | */ | 276 | */ |
276 | if ( !catPassed ) | 277 | if ( !catPassed ) |
277 | continue; | 278 | continue; |
278 | 279 | ||
279 | vector.insert(item++, contact ); | 280 | vector.insert(item++, contact ); |
280 | } | 281 | } |
281 | 282 | ||
282 | vector.resize( item ); | 283 | vector.resize( item ); |
283 | /* sort it now */ | 284 | /* sort it now */ |
284 | vector.sort(); | 285 | vector.sort(); |
285 | /* now get the uids */ | 286 | /* now get the uids */ |
286 | UIDArray array( vector.count() ); | 287 | UIDArray array( vector.count() ); |
287 | for (uint i= 0; i < vector.count(); i++ ) | 288 | for (uint i= 0; i < vector.count(); i++ ) |
288 | array[i] = vector.uidAt( i ); | 289 | array[i] = vector.uidAt( i ); |
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend.h b/libopie2/opiepim/backend/ocontactaccessbackend.h index 27d70ab..d5c463b 100644 --- a/libopie2/opiepim/backend/ocontactaccessbackend.h +++ b/libopie2/opiepim/backend/ocontactaccessbackend.h | |||
@@ -1,51 +1,52 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Main Author <main-author@whereever.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 | * The class responsible for managing a backend. | 31 | * The class responsible for managing a backend. |
31 | * The implementation of this abstract class contains | 32 | * The implementation of this abstract class contains |
32 | * the complete database handling. | 33 | * the complete database handling. |
33 | * | 34 | * |
34 | * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) | 35 | * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) |
35 | * Copyright (c) 2002 by Holger Freyther (zecke@handhelds.org) | 36 | * Copyright (c) 2002 by Holger Freyther (zecke@handhelds.org) |
36 | * | 37 | * |
37 | */ | 38 | */ |
38 | 39 | ||
39 | #ifndef _OCONTACTACCESSBACKEND_H_ | 40 | #ifndef _OCONTACTACCESSBACKEND_H_ |
40 | #define _OCONTACTACCESSBACKEND_H_ | 41 | #define _OCONTACTACCESSBACKEND_H_ |
41 | 42 | ||
42 | #include <opie2/opimcontact.h> | 43 | #include <opie2/opimcontact.h> |
43 | #include <opie2/opimaccessbackend.h> | 44 | #include <opie2/opimaccessbackend.h> |
44 | 45 | ||
45 | #include <qregexp.h> | 46 | #include <qregexp.h> |
46 | 47 | ||
47 | namespace Opie { | 48 | namespace Opie { |
48 | /** | 49 | /** |
49 | * This class represents the interface of all Contact Backends. | 50 | * This class represents the interface of all Contact Backends. |
50 | * Derivates of this class will be used to access the contacts. | 51 | * Derivates of this class will be used to access the contacts. |
51 | * As implementation currently XML and vCard exist. This class needs to be implemented | 52 | * As implementation currently XML and vCard exist. This class needs to be implemented |
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend.cpp b/libopie2/opiepim/backend/odatebookaccessbackend.cpp index e44912a..6da0170 100644 --- a/libopie2/opiepim/backend/odatebookaccessbackend.cpp +++ b/libopie2/opiepim/backend/odatebookaccessbackend.cpp | |||
@@ -1,81 +1,83 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de) | 3 | Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de) |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | #include <qtl.h> | 29 | #include <qtl.h> |
30 | 30 | ||
31 | #include <opie2/odebug.h> | ||
31 | #include <opie2/opimrecurrence.h> | 32 | #include <opie2/opimrecurrence.h> |
32 | 33 | #include <opie2/odatebookaccess.h> | |
33 | #include <opie2/odatebookaccessbackend.h> | 34 | #include <opie2/odatebookaccessbackend.h> |
35 | #include <opie2/private/opimeventsortvector.h> | ||
34 | 36 | ||
35 | using namespace Opie; | 37 | using namespace Opie; |
36 | 38 | ||
37 | namespace { | 39 | namespace { |
38 | /* a small helper to get all NonRepeating events for a range of time */ | 40 | /* a small helper to get all NonRepeating events for a range of time */ |
39 | void events( OPimBackendOccurrence::List& tmpList, | 41 | void events( OPimBackendOccurrence::List& tmpList, |
40 | const OPimEvent::ValueList& events, | 42 | const OPimEvent::ValueList& events, |
41 | const QDate& from, const QDate& to ) { | 43 | const QDate& from, const QDate& to ) { |
42 | QDateTime dtStart, dtEnd; | 44 | QDateTime dtStart, dtEnd; |
43 | 45 | ||
44 | for ( OPimEvent::ValueList::ConstIterator it = events.begin(); it != events.end(); ++it ) { | 46 | for ( OPimEvent::ValueList::ConstIterator it = events.begin(); it != events.end(); ++it ) { |
45 | dtStart = (*it).startDateTime(); | 47 | dtStart = (*it).startDateTime(); |
46 | dtEnd = (*it).endDateTime(); | 48 | dtEnd = (*it).endDateTime(); |
47 | 49 | ||
48 | /* | 50 | /* |
49 | * If in range | 51 | * If in range |
50 | */ | 52 | */ |
51 | if (dtStart.date() >= from && dtEnd.date() <= to ) { | 53 | if (dtStart.date() >= from && dtEnd.date() <= to ) { |
52 | OPimBackendOccurrence eff( dtStart, dtEnd, (*it).uid() );; | 54 | OPimBackendOccurrence eff( dtStart, dtEnd, (*it).uid() );; |
53 | tmpList.append( eff ); | 55 | tmpList.append( eff ); |
54 | } | 56 | } |
55 | } | 57 | } |
56 | } | 58 | } |
57 | 59 | ||
58 | void repeat( OPimBackendOccurrence::List& tmpList, const OPimEvent::ValueList& list, | 60 | void repeat( OPimBackendOccurrence::List& tmpList, const OPimEvent::ValueList& list, |
59 | const QDate& from, const QDate& to ) { | 61 | const QDate& from, const QDate& to ) { |
60 | QDate repeat; | 62 | QDate repeat; |
61 | for ( OPimEvent::ValueList::ConstIterator it = list.begin(); it != list.end(); ++it ) { | 63 | for ( OPimEvent::ValueList::ConstIterator it = list.begin(); it != list.end(); ++it ) { |
62 | int dur = (*it).startDateTime().date().daysTo( (*it).endDateTime().date() ); | 64 | int dur = (*it).startDateTime().date().daysTo( (*it).endDateTime().date() ); |
63 | QDate itDate = from.addDays(-dur ); | 65 | QDate itDate = from.addDays(-dur ); |
64 | OPimRecurrence rec = (*it).recurrence(); | 66 | OPimRecurrence rec = (*it).recurrence(); |
65 | if ( !rec.hasEndDate() || rec.endDate() > to ) { | 67 | if ( !rec.hasEndDate() || rec.endDate() > to ) { |
66 | rec.setEndDate( to ); | 68 | rec.setEndDate( to ); |
67 | rec.setHasEndDate( true ); | 69 | rec.setHasEndDate( true ); |
68 | } | 70 | } |
69 | 71 | ||
70 | QDateTime start, end; | 72 | QDateTime start, end; |
71 | while (rec.nextOcurrence(itDate, repeat ) ) { | 73 | while (rec.nextOcurrence(itDate, repeat ) ) { |
72 | if (repeat > to ) break; | 74 | if (repeat > to ) break; |
73 | 75 | ||
74 | OPimEvent event = *it; | 76 | OPimEvent event = *it; |
75 | start = QDateTime( repeat, event.startDateTime().time() ); | 77 | start = QDateTime( repeat, event.startDateTime().time() ); |
76 | end = QDateTime( repeat.addDays(dur), event.endDateTime().time() ); | 78 | end = QDateTime( repeat.addDays(dur), event.endDateTime().time() ); |
77 | OPimBackendOccurrence eff(start, end, event.uid() ); | 79 | OPimBackendOccurrence eff(start, end, event.uid() ); |
78 | tmpList.append( eff ); | 80 | tmpList.append( eff ); |
79 | } | 81 | } |
80 | } | 82 | } |
81 | } | 83 | } |
@@ -99,83 +101,133 @@ OPimBackendOccurrence::List ODateBookAccessBackend::occurrences( const QDate& fr | |||
99 | repeat( tmpList, directRawRepeats(),from,to ); | 101 | repeat( tmpList, directRawRepeats(),from,to ); |
100 | 102 | ||
101 | return tmpList; | 103 | return tmpList; |
102 | } | 104 | } |
103 | 105 | ||
104 | OPimBackendOccurrence::List ODateBookAccessBackend::occurrences( const QDateTime& dt )const | 106 | OPimBackendOccurrence::List ODateBookAccessBackend::occurrences( const QDateTime& dt )const |
105 | { | 107 | { |
106 | OPimBackendOccurrence::List day = occurrences( dt.date(), dt.date() ); | 108 | OPimBackendOccurrence::List day = occurrences( dt.date(), dt.date() ); |
107 | 109 | ||
108 | return filterOccurrences( day, dt ); | 110 | return filterOccurrences( day, dt ); |
109 | } | 111 | } |
110 | 112 | ||
111 | OPimBackendOccurrence::List ODateBookAccessBackend::effectiveNonRepeatingEvents( const QDate& from, | 113 | OPimBackendOccurrence::List ODateBookAccessBackend::effectiveNonRepeatingEvents( const QDate& from, |
112 | const QDate& to )const | 114 | const QDate& to )const |
113 | { | 115 | { |
114 | OPimBackendOccurrence::List tmpList; | 116 | OPimBackendOccurrence::List tmpList; |
115 | OPimEvent::ValueList list = directNonRepeats(); | 117 | OPimEvent::ValueList list = directNonRepeats(); |
116 | 118 | ||
117 | events( tmpList, list, from, to ); | 119 | events( tmpList, list, from, to ); |
118 | 120 | ||
119 | return tmpList; | 121 | return tmpList; |
120 | } | 122 | } |
121 | 123 | ||
122 | OPimBackendOccurrence::List ODateBookAccessBackend::effectiveNonRepeatingEvents( const QDateTime& dt )const | 124 | OPimBackendOccurrence::List ODateBookAccessBackend::effectiveNonRepeatingEvents( const QDateTime& dt )const |
123 | { | 125 | { |
124 | OPimBackendOccurrence::List day = effectiveNonRepeatingEvents( dt.date(), dt.date() ); | 126 | OPimBackendOccurrence::List day = effectiveNonRepeatingEvents( dt.date(), dt.date() ); |
125 | return filterOccurrences( day,dt ); | 127 | return filterOccurrences( day,dt ); |
126 | } | 128 | } |
127 | 129 | ||
128 | const uint ODateBookAccessBackend::querySettings() const | 130 | const uint ODateBookAccessBackend::querySettings() const |
129 | { | 131 | { |
130 | return 0; | 132 | return 0; |
131 | } | 133 | } |
132 | 134 | ||
133 | bool ODateBookAccessBackend::hasQuerySettings (uint querySettings) const | 135 | bool ODateBookAccessBackend::hasQuerySettings (uint querySettings) const |
134 | { | 136 | { |
135 | return false; | 137 | return false; |
136 | } | 138 | } |
137 | 139 | ||
138 | 140 | ||
139 | 141 | ||
140 | UIDArray ODateBookAccessBackend::queryByExample( const UIDArray& uidlist, const OPimEvent&, int settings, | 142 | UIDArray ODateBookAccessBackend::queryByExample( const UIDArray& uidlist, const OPimEvent&, int settings, |
141 | const QDateTime& d )const | 143 | const QDateTime& d )const |
142 | { | 144 | { |
143 | qDebug( "Accessing ODateBookAccessBackend::queryByExample() which is not implemented!" ); | 145 | qDebug( "Accessing ODateBookAccessBackend::queryByExample() which is not implemented!" ); |
144 | return UIDArray(); | 146 | return UIDArray(); |
145 | } | 147 | } |
146 | 148 | ||
147 | UIDArray ODateBookAccessBackend::sorted( const UIDArray&, bool asc, int, int, const QArray<int>& )const { | 149 | UIDArray ODateBookAccessBackend::sorted( const UIDArray& ar, bool asc, int sortOrder, int filter, const QArray<int>& categories )const { |
148 | return UIDArray(); | 150 | odebug << "Using Unaccelerated ODateBookAccessBackend sorted Implementation" << oendl; |
151 | |||
152 | Internal::OPimEventSortVector vector( ar.count(), asc, sortOrder ); | ||
153 | int item = 0; | ||
154 | |||
155 | for ( uint i = 0; i < ar.count(); ++i ){ | ||
156 | OPimEvent event = find( ar[i], ar, i, Frontend::Forward ); | ||
157 | if ( event.isEmpty() ) | ||
158 | continue; | ||
159 | |||
160 | bool catPassed = true; | ||
161 | if ( filter & ODateBookAccess::FilterCategory ){ | ||
162 | catPassed = false; | ||
163 | // Filter Categories | ||
164 | for ( uint cat_idx = 0; cat_idx < categories.count(); ++cat_idx ){ | ||
165 | int cat = categories[cat_idx]; | ||
166 | if ( cat == -1 || cat == 0 ){ | ||
167 | // Unfiled. Check next category if list is not empty. | ||
168 | // Else: take it as we will not filter unfiled events.. | ||
169 | if ( !event.categories().isEmpty() ) | ||
170 | continue; | ||
171 | else | ||
172 | catPassed = true; | ||
173 | } else { | ||
174 | if ( !event.categories().contains( cat ) ) | ||
175 | continue; | ||
176 | else{ | ||
177 | catPassed = true; | ||
178 | break; | ||
179 | } | ||
180 | } | ||
181 | } | ||
182 | } | ||
183 | |||
184 | // Continue to next event if the category filter removed this item | ||
185 | if ( !catPassed ) | ||
186 | continue; | ||
187 | |||
188 | vector.insert( item++, event ); | ||
189 | } | ||
190 | |||
191 | // Now sort the vector and return the list of UID's | ||
192 | vector.resize( item ); | ||
193 | vector.sort(); | ||
194 | |||
195 | UIDArray array( vector.count() ); | ||
196 | for ( uint i= 0; i < vector.count(); i++ ) | ||
197 | array[i] = vector.uidAt( i ); | ||
198 | |||
199 | return array; | ||
200 | |||
149 | } | 201 | } |
150 | 202 | ||
151 | OPimBackendOccurrence::List ODateBookAccessBackend::filterOccurrences( const OPimBackendOccurrence::List dayList, | 203 | OPimBackendOccurrence::List ODateBookAccessBackend::filterOccurrences( const OPimBackendOccurrence::List dayList, |
152 | const QDateTime& dt ) { | 204 | const QDateTime& dt ) { |
153 | OPimBackendOccurrence::List tmpList; | 205 | OPimBackendOccurrence::List tmpList; |
154 | OPimBackendOccurrence::List::ConstIterator it; | 206 | OPimBackendOccurrence::List::ConstIterator it; |
155 | 207 | ||
156 | for ( it = dayList.begin(); it != dayList.end(); ++it ) { | 208 | for ( it = dayList.begin(); it != dayList.end(); ++it ) { |
157 | OPimBackendOccurrence occ = *it; | 209 | OPimBackendOccurrence occ = *it; |
158 | 210 | ||
159 | /* | 211 | /* |
160 | * Let us find occurrences that are 'now'! | 212 | * Let us find occurrences that are 'now'! |
161 | * If the dt.date() is on the same day as start or end of the Occurrence | 213 | * If the dt.date() is on the same day as start or end of the Occurrence |
162 | * check how near start/end are. | 214 | * check how near start/end are. |
163 | * If it is in the middle of a multiday occurrence list it. | 215 | * If it is in the middle of a multiday occurrence list it. |
164 | * | 216 | * |
165 | * We might want to 'lose' the sixty second offset and list | 217 | * We might want to 'lose' the sixty second offset and list |
166 | * all Events which are active at that time. | 218 | * all Events which are active at that time. |
167 | */ | 219 | */ |
168 | if ( dt.date() == occ.startDateTime().date() ) { | 220 | if ( dt.date() == occ.startDateTime().date() ) { |
169 | if ( QABS( dt.time().secsTo( occ.startDateTime().time() ) ) < 60 ) | 221 | if ( QABS( dt.time().secsTo( occ.startDateTime().time() ) ) < 60 ) |
170 | tmpList.append( occ ); | 222 | tmpList.append( occ ); |
171 | }else if ( dt.date() == occ.endDateTime().date() ) { | 223 | }else if ( dt.date() == occ.endDateTime().date() ) { |
172 | if ( QABS( dt.time().secsTo( occ.endDateTime().time() ) ) < 60 ) | 224 | if ( QABS( dt.time().secsTo( occ.endDateTime().time() ) ) < 60 ) |
173 | tmpList.append( occ ); | 225 | tmpList.append( occ ); |
174 | }else if ( dt.date() >= occ.startDateTime().date() && | 226 | }else if ( dt.date() >= occ.startDateTime().date() && |
175 | dt.date() >= occ.endDateTime().date() ) | 227 | dt.date() >= occ.endDateTime().date() ) |
176 | tmpList.append( occ ); | 228 | tmpList.append( occ ); |
177 | } | 229 | } |
178 | 230 | ||
179 | return tmpList; | 231 | return tmpList; |
180 | } | 232 | } |
181 | } | 233 | } |