author | eilers <eilers> | 2002-11-01 15:10:42 (UTC) |
---|---|---|
committer | eilers <eilers> | 2002-11-01 15:10:42 (UTC) |
commit | 28b70b2b7f8fa03ba0991fb73dccf7b46e5c3d1f (patch) (unidiff) | |
tree | d5ead4aa63aed345ce406c7857ba1ec7813272db /libopie2/opiepim/backend | |
parent | a098735b8749ead08c658792cc31f95e73045107 (diff) | |
download | opie-28b70b2b7f8fa03ba0991fb73dccf7b46e5c3d1f.zip opie-28b70b2b7f8fa03ba0991fb73dccf7b46e5c3d1f.tar.gz opie-28b70b2b7f8fa03ba0991fb73dccf7b46e5c3d1f.tar.bz2 |
Added regExp-search in database for all fields in a contact.
-rw-r--r-- | libopie2/opiepim/backend/ocontactaccessbackend.h | 7 | ||||
-rw-r--r-- | libopie2/opiepim/backend/ocontactaccessbackend_xml.h | 20 |
2 files changed, 27 insertions, 0 deletions
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend.h b/libopie2/opiepim/backend/ocontactaccessbackend.h index a651477..c898f61 100644 --- a/libopie2/opiepim/backend/ocontactaccessbackend.h +++ b/libopie2/opiepim/backend/ocontactaccessbackend.h | |||
@@ -10,63 +10,70 @@ | |||
10 | *This program is free software; you can redistribute it and/or | 10 | *This program is free software; you can redistribute it and/or |
11 | *modify it under the terms of the GNU Library General Public | 11 | *modify it under the terms of the GNU Library General Public |
12 | * License as published by the Free Software Foundation; | 12 | * License as published by the Free Software Foundation; |
13 | * either version 2 of the License, or (at your option) any later | 13 | * either version 2 of the License, or (at your option) any later |
14 | * version. | 14 | * version. |
15 | * ===================================================================== | 15 | * ===================================================================== |
16 | * ToDo: Define enum for query settings | 16 | * ToDo: Define enum for query settings |
17 | * ===================================================================== | 17 | * ===================================================================== |
18 | * Version: $Id$ | 18 | * Version: $Id$ |
19 | * ===================================================================== | 19 | * ===================================================================== |
20 | * History: | 20 | * History: |
21 | * $Log$ | 21 | * $Log$ |
22 | * Revision 1.3 2002/11/01 15:10:42 eilers | ||
23 | * Added regExp-search in database for all fields in a contact. | ||
24 | * | ||
22 | * Revision 1.2 2002/10/07 17:34:24 eilers | 25 | * Revision 1.2 2002/10/07 17:34:24 eilers |
23 | * added OBackendFactory for advanced backend access | 26 | * added OBackendFactory for advanced backend access |
24 | * | 27 | * |
25 | * Revision 1.1 2002/09/27 17:11:44 eilers | 28 | * Revision 1.1 2002/09/27 17:11:44 eilers |
26 | * Added API for accessing the Contact-Database ! It is compiling, but | 29 | * Added API for accessing the Contact-Database ! It is compiling, but |
27 | * please do not expect that anything is working ! | 30 | * please do not expect that anything is working ! |
28 | * I will debug that stuff in the next time .. | 31 | * I will debug that stuff in the next time .. |
29 | * Please read README_COMPILE for compiling ! | 32 | * Please read README_COMPILE for compiling ! |
30 | * | 33 | * |
31 | * ===================================================================== | 34 | * ===================================================================== |
32 | * | 35 | * |
33 | */ | 36 | */ |
34 | 37 | ||
35 | #ifndef _OCONTACTACCESSBACKEND_H_ | 38 | #ifndef _OCONTACTACCESSBACKEND_H_ |
36 | #define _OCONTACTACCESSBACKEND_H_ | 39 | #define _OCONTACTACCESSBACKEND_H_ |
37 | 40 | ||
38 | #include "ocontact.h" | 41 | #include "ocontact.h" |
39 | #include "opimaccessbackend.h" | 42 | #include "opimaccessbackend.h" |
40 | 43 | ||
44 | #include "qregexp.h" | ||
45 | |||
41 | class OContactAccessBackend: public OPimAccessBackend<OContact> { | 46 | class OContactAccessBackend: public OPimAccessBackend<OContact> { |
42 | public: | 47 | public: |
43 | OContactAccessBackend() {} | 48 | OContactAccessBackend() {} |
44 | virtual ~OContactAccessBackend() {} | 49 | virtual ~OContactAccessBackend() {} |
45 | 50 | ||
46 | 51 | ||
47 | /** Return if database was changed externally. | 52 | /** Return if database was changed externally. |
48 | * This may just make sense on file based databases like a XML-File. | 53 | * This may just make sense on file based databases like a XML-File. |
49 | * It is used to prevent to overwrite the current database content | 54 | * It is used to prevent to overwrite the current database content |
50 | * if the file was already changed by something else ! | 55 | * if the file was already changed by something else ! |
51 | * If this happens, we have to reload before save our data. | 56 | * If this happens, we have to reload before save our data. |
52 | * If we use real databases, this should be handled by the database | 57 | * If we use real databases, this should be handled by the database |
53 | * management system themselve, therefore this function should always return false in | 58 | * management system themselve, therefore this function should always return false in |
54 | * this case. It is not our problem to handle this conflict ... | 59 | * this case. It is not our problem to handle this conflict ... |
55 | * @return <i>true</i> if the database was changed and if save without reload will | 60 | * @return <i>true</i> if the database was changed and if save without reload will |
56 | * be dangerous. <i>false</i> if the database was not changed or it is save to write | 61 | * be dangerous. <i>false</i> if the database was not changed or it is save to write |
57 | * in this situation. | 62 | * in this situation. |
58 | */ | 63 | */ |
59 | virtual bool wasChangedExternally() = 0; | 64 | virtual bool wasChangedExternally() = 0; |
60 | 65 | ||
66 | virtual QArray<int> matchRegexp( const QRegExp &r ) const = 0; | ||
67 | |||
61 | /** Return all possible settings. | 68 | /** Return all possible settings. |
62 | * @return All settings provided by the current backend | 69 | * @return All settings provided by the current backend |
63 | * (i.e.: query_WildCards & query_IgnoreCase) | 70 | * (i.e.: query_WildCards & query_IgnoreCase) |
64 | */ | 71 | */ |
65 | virtual const uint querySettings() = 0; | 72 | virtual const uint querySettings() = 0; |
66 | 73 | ||
67 | /** Check whether settings are correct. | 74 | /** Check whether settings are correct. |
68 | * @return <i>true</i> if the given settings are correct and possible. | 75 | * @return <i>true</i> if the given settings are correct and possible. |
69 | */ | 76 | */ |
70 | virtual bool hasQuerySettings (uint querySettings) const = 0; | 77 | virtual bool hasQuerySettings (uint querySettings) const = 0; |
71 | 78 | ||
72 | 79 | ||
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_xml.h b/libopie2/opiepim/backend/ocontactaccessbackend_xml.h index 12a75ba..f7e8207 100644 --- a/libopie2/opiepim/backend/ocontactaccessbackend_xml.h +++ b/libopie2/opiepim/backend/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.5 2002/11/01 15:10:42 eilers | ||
21 | * Added regExp-search in database for all fields in a contact. | ||
22 | * | ||
20 | * Revision 1.4 2002/10/16 10:52:40 eilers | 23 | * Revision 1.4 2002/10/16 10:52:40 eilers |
21 | * Added some docu to the interface and now using the cache infrastucture by zecke.. :) | 24 | * Added some docu to the interface and now using the cache infrastucture by zecke.. :) |
22 | * | 25 | * |
23 | * Revision 1.3 2002/10/14 16:21:54 eilers | 26 | * Revision 1.3 2002/10/14 16:21:54 eilers |
24 | * Some minor interface updates | 27 | * Some minor interface updates |
25 | * | 28 | * |
26 | * Revision 1.2 2002/10/07 17:34:24 eilers | 29 | * Revision 1.2 2002/10/07 17:34:24 eilers |
27 | * added OBackendFactory for advanced backend access | 30 | * added OBackendFactory for advanced backend access |
28 | * | 31 | * |
29 | * Revision 1.1 2002/09/27 17:11:44 eilers | 32 | * Revision 1.1 2002/09/27 17:11:44 eilers |
30 | * Added API for accessing the Contact-Database ! It is compiling, but | 33 | * Added API for accessing the Contact-Database ! It is compiling, but |
31 | * please do not expect that anything is working ! | 34 | * please do not expect that anything is working ! |
@@ -245,24 +248,41 @@ class OContactAccessBackend_XML : public OContactAccessBackend { | |||
245 | } | 248 | } |
246 | } | 249 | } |
247 | if ( allcorrect ){ | 250 | if ( allcorrect ){ |
248 | m_currentQuery[arraycounter++] = (*it).uid(); | 251 | m_currentQuery[arraycounter++] = (*it).uid(); |
249 | } | 252 | } |
250 | } | 253 | } |
251 | 254 | ||
252 | // Shrink to fit.. | 255 | // Shrink to fit.. |
253 | m_currentQuery.resize(arraycounter); | 256 | m_currentQuery.resize(arraycounter); |
254 | 257 | ||
255 | return m_currentQuery; | 258 | return m_currentQuery; |
256 | } | 259 | } |
260 | |||
261 | QArray<int> matchRegexp( const QRegExp &r ) const{ | ||
262 | QArray<int> m_currentQuery( m_contactList.count() ); | ||
263 | QValueListConstIterator<OContact> it; | ||
264 | uint arraycounter = 0; | ||
265 | |||
266 | for( it = m_contactList.begin(); it != m_contactList.end(); ++it ){ | ||
267 | if ( (*it).match( r ) ){ | ||
268 | m_currentQuery[arraycounter++] = (*it).uid(); | ||
269 | } | ||
270 | |||
271 | } | ||
272 | // Shrink to fit.. | ||
273 | m_currentQuery.resize(arraycounter); | ||
274 | |||
275 | return m_currentQuery; | ||
276 | } | ||
257 | 277 | ||
258 | const uint querySettings() | 278 | const uint querySettings() |
259 | { | 279 | { |
260 | return ( OContactAccess::WildCards | 280 | return ( OContactAccess::WildCards |
261 | & OContactAccess::IgnoreCase | 281 | & OContactAccess::IgnoreCase |
262 | & OContactAccess::RegExp | 282 | & OContactAccess::RegExp |
263 | & OContactAccess::ExactMatch ); | 283 | & OContactAccess::ExactMatch ); |
264 | } | 284 | } |
265 | 285 | ||
266 | bool hasQuerySettings (uint querySettings) const | 286 | bool hasQuerySettings (uint querySettings) const |
267 | { | 287 | { |
268 | /* OContactAccess::IgnoreCase may be added with one | 288 | /* OContactAccess::IgnoreCase may be added with one |