Diffstat (limited to 'libopie/pim/ocontactaccessbackend_xml.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie/pim/ocontactaccessbackend_xml.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/libopie/pim/ocontactaccessbackend_xml.h b/libopie/pim/ocontactaccessbackend_xml.h index f7e8207..8b95102 100644 --- a/libopie/pim/ocontactaccessbackend_xml.h +++ b/libopie/pim/ocontactaccessbackend_xml.h | |||
@@ -8,24 +8,27 @@ | |||
8 | *modify it under the terms of the GNU Library General Public | 8 | *modify it under the terms of the GNU Library General Public |
9 | * License as published by the Free Software Foundation; either | 9 | * License as published by the Free Software Foundation; either |
10 | * version 2 of the License, or (at your option) any later version. | 10 | * version 2 of the License, or (at your option) any later version. |
11 | * ===================================================================== | 11 | * ===================================================================== |
12 | * ToDo: XML-Backend: Automatic reload if something was changed... | 12 | * ToDo: XML-Backend: Automatic reload if something was changed... |
13 | * | 13 | * |
14 | * | 14 | * |
15 | * ===================================================================== | 15 | * ===================================================================== |
16 | * Version: $Id$ | 16 | * Version: $Id$ |
17 | * ===================================================================== | 17 | * ===================================================================== |
18 | * History: | 18 | * History: |
19 | * $Log$ | 19 | * $Log$ |
20 | * Revision 1.6 2002/11/13 14:14:51 eilers | ||
21 | * Added sorted for Contacts.. | ||
22 | * | ||
20 | * Revision 1.5 2002/11/01 15:10:42 eilers | 23 | * Revision 1.5 2002/11/01 15:10:42 eilers |
21 | * Added regExp-search in database for all fields in a contact. | 24 | * Added regExp-search in database for all fields in a contact. |
22 | * | 25 | * |
23 | * Revision 1.4 2002/10/16 10:52:40 eilers | 26 | * Revision 1.4 2002/10/16 10:52:40 eilers |
24 | * Added some docu to the interface and now using the cache infrastucture by zecke.. :) | 27 | * Added some docu to the interface and now using the cache infrastucture by zecke.. :) |
25 | * | 28 | * |
26 | * Revision 1.3 2002/10/14 16:21:54 eilers | 29 | * Revision 1.3 2002/10/14 16:21:54 eilers |
27 | * Some minor interface updates | 30 | * Some minor interface updates |
28 | * | 31 | * |
29 | * Revision 1.2 2002/10/07 17:34:24 eilers | 32 | * Revision 1.2 2002/10/07 17:34:24 eilers |
30 | * added OBackendFactory for advanced backend access | 33 | * added OBackendFactory for advanced backend access |
31 | * | 34 | * |
@@ -38,24 +41,25 @@ | |||
38 | * | 41 | * |
39 | */ | 42 | */ |
40 | 43 | ||
41 | #ifndef _OContactAccessBackend_XML_ | 44 | #ifndef _OContactAccessBackend_XML_ |
42 | #define _OContactAccessBackend_XML_ | 45 | #define _OContactAccessBackend_XML_ |
43 | 46 | ||
44 | #include <qasciidict.h> | 47 | #include <qasciidict.h> |
45 | #include <qdatetime.h> | 48 | #include <qdatetime.h> |
46 | #include <qfile.h> | 49 | #include <qfile.h> |
47 | #include <qfileinfo.h> | 50 | #include <qfileinfo.h> |
48 | #include <qregexp.h> | 51 | #include <qregexp.h> |
49 | #include <qarray.h> | 52 | #include <qarray.h> |
53 | #include <qmap.h> | ||
50 | 54 | ||
51 | #include <qpe/global.h> | 55 | #include <qpe/global.h> |
52 | 56 | ||
53 | #include <opie/xmltree.h> | 57 | #include <opie/xmltree.h> |
54 | #include "ocontactaccessbackend.h" | 58 | #include "ocontactaccessbackend.h" |
55 | #include "ocontactaccess.h" | 59 | #include "ocontactaccess.h" |
56 | 60 | ||
57 | #include <stdlib.h> | 61 | #include <stdlib.h> |
58 | #include <errno.h> | 62 | #include <errno.h> |
59 | 63 | ||
60 | using namespace Opie; | 64 | using namespace Opie; |
61 | 65 | ||
@@ -292,24 +296,52 @@ class OContactAccessBackend_XML : public OContactAccessBackend { | |||
292 | switch ( querySettings & ~OContactAccess::IgnoreCase ){ | 296 | switch ( querySettings & ~OContactAccess::IgnoreCase ){ |
293 | case OContactAccess::RegExp: | 297 | case OContactAccess::RegExp: |
294 | return ( true ); | 298 | return ( true ); |
295 | case OContactAccess::WildCards: | 299 | case OContactAccess::WildCards: |
296 | return ( true ); | 300 | return ( true ); |
297 | case OContactAccess::ExactMatch: | 301 | case OContactAccess::ExactMatch: |
298 | return ( true ); | 302 | return ( true ); |
299 | default: | 303 | default: |
300 | return ( false ); | 304 | return ( false ); |
301 | } | 305 | } |
302 | } | 306 | } |
303 | 307 | ||
308 | // Currently only asc implemented.. | ||
309 | QArray<int> sorted( bool asc, int , int , int ) | ||
310 | { | ||
311 | QMap<QString, int> nameToUid; | ||
312 | QStringList names; | ||
313 | QArray<int> m_currentQuery( m_contactList.count() ); | ||
314 | |||
315 | // First fill map and StringList with all Names ( better LastNames ? ) | ||
316 | // Afterwards sort namelist and use map to fill array to return.. | ||
317 | QValueListConstIterator<OContact> it; | ||
318 | for( it = m_contactList.begin(); it != m_contactList.end(); ++it ){ | ||
319 | names.append( (*it).lastName() ); | ||
320 | nameToUid.insert( (*it).lastName(), (*it).uid() ); | ||
321 | } | ||
322 | names.sort(); | ||
323 | |||
324 | int i = 0; | ||
325 | if ( asc ){ | ||
326 | for ( QStringList::Iterator it = names.begin(); it != names.end(); ++it ) | ||
327 | m_currentQuery[i++] = nameToUid[ (*it) ]; | ||
328 | }else{ | ||
329 | for ( QStringList::Iterator it = names.end(); it != names.begin(); --it ) | ||
330 | m_currentQuery[i++] = nameToUid[ (*it) ]; | ||
331 | } | ||
332 | |||
333 | return m_currentQuery; | ||
334 | |||
335 | } | ||
304 | bool add ( const OContact &newcontact ) | 336 | bool add ( const OContact &newcontact ) |
305 | { | 337 | { |
306 | //qWarning("odefaultbackend: ACTION::ADD"); | 338 | //qWarning("odefaultbackend: ACTION::ADD"); |
307 | updateJournal (newcontact, OContact::ACTION_ADD); | 339 | updateJournal (newcontact, OContact::ACTION_ADD); |
308 | addContact_p( newcontact ); | 340 | addContact_p( newcontact ); |
309 | 341 | ||
310 | m_changed = true; | 342 | m_changed = true; |
311 | 343 | ||
312 | return true; | 344 | return true; |
313 | } | 345 | } |
314 | 346 | ||
315 | bool replace ( const OContact &contact ) | 347 | bool replace ( const OContact &contact ) |