summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/DESIGN6
-rw-r--r--libopie/pim/ocontactaccess.cpp4
-rw-r--r--libopie/pim/ocontactaccess.h49
-rw-r--r--libopie/pim/ocontactaccessbackend_xml.h35
-rw-r--r--libopie/pim/opimaccesstemplate.h12
-rw-r--r--libopie/pim/otodoaccessxml.cpp2
-rw-r--r--libopie/pim/otodoaccessxml.h2
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_xml.h35
-rw-r--r--libopie2/opiepim/backend/otodoaccessxml.cpp2
-rw-r--r--libopie2/opiepim/backend/otodoaccessxml.h2
-rw-r--r--libopie2/opiepim/core/ocontactaccess.cpp4
-rw-r--r--libopie2/opiepim/core/ocontactaccess.h49
-rw-r--r--libopie2/opiepim/core/opimaccesstemplate.h12
13 files changed, 74 insertions, 140 deletions
diff --git a/libopie/pim/DESIGN b/libopie/pim/DESIGN
index 4def7b9..bd92b1b 100644
--- a/libopie/pim/DESIGN
+++ b/libopie/pim/DESIGN
@@ -41,22 +41,16 @@ for( it = list.begin(); it != list.end(); ++it );
41as you can see from here it just behaves like you expect from Qt or STL. 41as you can see from here it just behaves like you expect from Qt or STL.
42 42
43The kewlest thing is that List and List::Iterator is free to use if you 43The kewlest thing is that List and List::Iterator is free to use if you
44want to implement your own OPimAccessTemplate. 44want to implement your own OPimAccessTemplate.
45You just have to sub class it and voila you're done 45You just have to sub class it and voila you're done
46 46
47 47
48Hope you enjoy using OPIE PIM 48Hope you enjoy using OPIE PIM
49 49
50regards Holger 'zecke' Freyther 50regards Holger 'zecke' Freyther
51 51
52 52
53Comment by Stefan Eilers:
54
55The opimaccesstemplate defines "SortOrder":
56I think sortorder is the wrong name for the meaning of it and
57it should be defined by the childs of opimaccesstemplate (every
58implementation may use different values for this..)
59 53
60 54
61 55
62 56
diff --git a/libopie/pim/ocontactaccess.cpp b/libopie/pim/ocontactaccess.cpp
index b5f358b..e8c0a45 100644
--- a/libopie/pim/ocontactaccess.cpp
+++ b/libopie/pim/ocontactaccess.cpp
@@ -12,24 +12,27 @@
12 * Info: This class could just work with a change in the header-file 12 * Info: This class could just work with a change in the header-file
13 * of the Contact class ! Therefore our libopie only compiles 13 * of the Contact class ! Therefore our libopie only compiles
14 * with our version of libqpe 14 * with our version of libqpe
15 * ===================================================================== 15 * =====================================================================
16 * ToDo: XML-Backend: Automatic reload if something was changed... 16 * ToDo: XML-Backend: Automatic reload if something was changed...
17 * 17 *
18 * 18 *
19 * ===================================================================== 19 * =====================================================================
20 * Version: $Id$ 20 * Version: $Id$
21 * ===================================================================== 21 * =====================================================================
22 * History: 22 * History:
23 * $Log$ 23 * $Log$
24 * Revision 1.4 2002/10/14 16:21:54 eilers
25 * Some minor interface updates
26 *
24 * Revision 1.3 2002/10/07 17:34:24 eilers 27 * Revision 1.3 2002/10/07 17:34:24 eilers
25 * added OBackendFactory for advanced backend access 28 * added OBackendFactory for advanced backend access
26 * 29 *
27 * Revision 1.2 2002/10/02 16:18:11 eilers 30 * Revision 1.2 2002/10/02 16:18:11 eilers
28 * debugged and seems to work almost perfectly .. 31 * debugged and seems to work almost perfectly ..
29 * 32 *
30 * Revision 1.1 2002/09/27 17:11:44 eilers 33 * Revision 1.1 2002/09/27 17:11:44 eilers
31 * Added API for accessing the Contact-Database ! It is compiling, but 34 * Added API for accessing the Contact-Database ! It is compiling, but
32 * please do not expect that anything is working ! 35 * please do not expect that anything is working !
33 * I will debug that stuff in the next time .. 36 * I will debug that stuff in the next time ..
34 * Please read README_COMPILE for compiling ! 37 * Please read README_COMPILE for compiling !
35 * 38 *
@@ -57,25 +60,24 @@
57#include "ocontactaccessbackend_xml.h" 60#include "ocontactaccessbackend_xml.h"
58 61
59 62
60OContactAccess::OContactAccess ( const QString appname, const QString , 63OContactAccess::OContactAccess ( const QString appname, const QString ,
61 OContactAccessBackend* end, bool autosync ): 64 OContactAccessBackend* end, bool autosync ):
62 OPimAccessTemplate<OContact>( end ), 65 OPimAccessTemplate<OContact>( end ),
63 m_changed ( false ) 66 m_changed ( false )
64{ 67{
65 /* take care of the backend. If there is no one defined, we 68 /* take care of the backend. If there is no one defined, we
66 * will use the XML-Backend as default (until we have a cute SQL-Backend..). 69 * will use the XML-Backend as default (until we have a cute SQL-Backend..).
67 */ 70 */
68 if( end == 0 ) { 71 if( end == 0 ) {
69 // __asm__("int3");
70 qWarning ("Using BackendFactory !"); 72 qWarning ("Using BackendFactory !");
71 end = OBackendFactory<OContactAccessBackend>::Default( "contact", appname ); 73 end = OBackendFactory<OContactAccessBackend>::Default( "contact", appname );
72 } 74 }
73 // Set backend locally and in template 75 // Set backend locally and in template
74 m_backEnd = end; 76 m_backEnd = end;
75 OPimAccessTemplate<OContact>::setBackEnd (end); 77 OPimAccessTemplate<OContact>::setBackEnd (end);
76 78
77 79
78 /* Connect signal of external db change to function */ 80 /* Connect signal of external db change to function */
79 QCopChannel *dbchannel = new QCopChannel( "QPE/PIM", this ); 81 QCopChannel *dbchannel = new QCopChannel( "QPE/PIM", this );
80 connect( dbchannel, SIGNAL(received(const QCString &, const QByteArray &)), 82 connect( dbchannel, SIGNAL(received(const QCString &, const QByteArray &)),
81 this, SLOT(copMessage( const QCString &, const QByteArray &)) ); 83 this, SLOT(copMessage( const QCString &, const QByteArray &)) );
diff --git a/libopie/pim/ocontactaccess.h b/libopie/pim/ocontactaccess.h
index 54f7f07..adc66cf 100644
--- a/libopie/pim/ocontactaccess.h
+++ b/libopie/pim/ocontactaccess.h
@@ -8,24 +8,27 @@
8 *This program is free software; you can redistribute it and/or 8 *This program is free software; you can redistribute it and/or
9 *modify it under the terms of the GNU Library General Public 9 *modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; 10 * License as published by the Free Software Foundation;
11 * either version 2 of the License, or (at your option) any later 11 * either version 2 of the License, or (at your option) any later
12 * version. 12 * version.
13 * ===================================================================== 13 * =====================================================================
14 * ToDo: Define enum for query settings 14 * ToDo: Define enum for query settings
15 * ===================================================================== 15 * =====================================================================
16 * Version: $Id$ 16 * Version: $Id$
17 * ===================================================================== 17 * =====================================================================
18 * History: 18 * History:
19 * $Log$ 19 * $Log$
20 * Revision 1.2 2002/10/14 16:21:54 eilers
21 * Some minor interface updates
22 *
20 * Revision 1.1 2002/09/27 17:11:44 eilers 23 * Revision 1.1 2002/09/27 17:11:44 eilers
21 * Added API for accessing the Contact-Database ! It is compiling, but 24 * Added API for accessing the Contact-Database ! It is compiling, but
22 * please do not expect that anything is working ! 25 * please do not expect that anything is working !
23 * I will debug that stuff in the next time .. 26 * I will debug that stuff in the next time ..
24 * Please read README_COMPILE for compiling ! 27 * Please read README_COMPILE for compiling !
25 * 28 *
26 * ===================================================================== 29 * =====================================================================
27 */ 30 */
28#ifndef _OCONTACTACCESS_H 31#ifndef _OCONTACTACCESS_H
29#define _OCONTACTACCESS_H 32#define _OCONTACTACCESS_H
30 33
31#include <qobject.h> 34#include <qobject.h>
@@ -38,85 +41,53 @@
38#include "ocontact.h" 41#include "ocontact.h"
39#include "ocontactaccessbackend.h" 42#include "ocontactaccessbackend.h"
40#include "opimaccesstemplate.h" 43#include "opimaccesstemplate.h"
41 44
42/** Class to access the contacts database. 45/** Class to access the contacts database.
43 * This is just a frontend for the real database handling which is 46 * This is just a frontend for the real database handling which is
44 * done by the backend. 47 * done by the backend.
45 */ 48 */
46class OContactAccess: public QObject, public OPimAccessTemplate<OContact> 49class OContactAccess: public QObject, public OPimAccessTemplate<OContact>
47{ 50{
48 Q_OBJECT 51 Q_OBJECT
49 52
50
51 /* class Iterator{
52 friend OContactAccess;
53 public:
54 Iterator();
55 Iterator ( const Iterator& copy );
56
57 bool operator== ( const Iterator& it );
58 bool operator!= ( const Iterator& it );
59 Iterator& operator= ( const Iterator& it );
60 Iterator& operator++ (); // prefix
61 Iterator operator++ ( int ); // postfix
62 Iterator& operator-- (); // prefix
63 Iterator operator-- ( int ); // postfix
64 Contact operator*() const;
65 Contact operator->() const;
66
67 Iterator begin();
68 Iterator end();
69
70 uint count() const;
71
72 private:
73 QValueList<int> m_uids;
74 int m_cur_position;
75 bool m_end_reached;
76 OContactAccess *m_db;
77
78 };
79
80 */
81
82 public: 53 public:
83 /** Create Database with contacts (addressbook). 54 /** Create Database with contacts (addressbook).
84 * @param appname Name of application which wants access to the database 55 * @param appname Name of application which wants access to the database
85 * (i.e. "todolist") 56 * (i.e. "todolist")
86 * @param filename The name of the database file. If not set, the default one 57 * @param filename The name of the database file. If not set, the default one
87 * is used. 58 * is used.
88 * @param backend Pointer to an alternative Backend. If not set, we will use 59 * @param backend Pointer to an alternative Backend. If not set, we will use
89 * the default backend. 60 * the default backend.
90 * @param handlesync If <b>true</b> the database stores the current state 61 * @param handlesync If <b>true</b> the database stores the current state
91 * automatically if it receives the signals <i>flush()</i> and <i>reload()</i> 62 * automatically if it receives the signals <i>flush()</i> and <i>reload()</i>
92 * which are used before and after synchronisation. If the application wants 63 * which are used before and after synchronisation. If the application wants
93 * to react itself, it should be disabled by setting it to <b>false</b> 64 * to react itself, it should be disabled by setting it to <b>false</b>
94 * @see OContactBackend 65 * @see OContactAccessBackend
95 */ 66 */
96 OContactAccess (const QString appname, const QString filename = 0l, 67 OContactAccess (const QString appname, const QString filename = 0l,
97 OContactAccessBackend* backend = 0l, bool handlesync = true); 68 OContactAccessBackend* backend = 0l, bool handlesync = true);
98 ~OContactAccess (); 69 ~OContactAccess ();
99 70
100 /** Constants for query. 71 /** Constants for query.
101 * Use this constants to set the query parameters. 72 * Use this constants to set the query parameters.
102 * Note: <i>query_IgnoreCase</i> just make sense with one of the other attributes ! 73 * Note: <i>query_IgnoreCase</i> just make sense with one of the other attributes !
103 * @see queryByExample() 74 * @see queryByExample()
104 * - why not enum - zecke?
105 * -> Had some implementation problems .. Will use enum soon ! .. (se)
106 */ 75 */
107 static const int query_WildCards = 0x0001; 76 enum QuerySettings {
108 static const int query_IgnoreCase = 0x0002; 77 WildCards = 0x0001,
109 static const int query_RegExp = 0x0004; 78 IgnoreCase = 0x0002,
110 static const int query_ExactMatch = 0x0008; 79 RegExp = 0x0004,
80 ExactMatch = 0x0008,
81 };
111 82
112 /** Return all possible settings. 83 /** Return all possible settings.
113 * @return All settings provided by the current backend 84 * @return All settings provided by the current backend
114 * (i.e.: query_WildCards & query_IgnoreCase) 85 * (i.e.: query_WildCards & query_IgnoreCase)
115 */ 86 */
116 const uint querySettings(); 87 const uint querySettings();
117 88
118 /** Check whether settings are correct. 89 /** Check whether settings are correct.
119 * @return <i>true</i> if the given settings are correct and possible. 90 * @return <i>true</i> if the given settings are correct and possible.
120 */ 91 */
121 bool hasQuerySettings ( int querySettings ) const; 92 bool hasQuerySettings ( int querySettings ) const;
122 93
diff --git a/libopie/pim/ocontactaccessbackend_xml.h b/libopie/pim/ocontactaccessbackend_xml.h
index 97ef40f..50ea329 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.3 2002/10/14 16:21:54 eilers
21 * Some minor interface updates
22 *
20 * Revision 1.2 2002/10/07 17:34:24 eilers 23 * Revision 1.2 2002/10/07 17:34:24 eilers
21 * added OBackendFactory for advanced backend access 24 * added OBackendFactory for advanced backend access
22 * 25 *
23 * Revision 1.1 2002/09/27 17:11:44 eilers 26 * Revision 1.1 2002/09/27 17:11:44 eilers
24 * Added API for accessing the Contact-Database ! It is compiling, but 27 * Added API for accessing the Contact-Database ! It is compiling, but
25 * please do not expect that anything is working ! 28 * please do not expect that anything is working !
26 * I will debug that stuff in the next time .. 29 * I will debug that stuff in the next time ..
27 * Please read README_COMPILE for compiling ! 30 * Please read README_COMPILE for compiling !
28 * 31 *
29 * 32 *
30 */ 33 */
31 34
@@ -190,43 +193,43 @@ class OContactAccessBackend_XML : public OContactAccessBackend {
190 QArray<int> m_currentQuery( m_contactList.count() ); 193 QArray<int> m_currentQuery( m_contactList.count() );
191 QValueListConstIterator<OContact> it; 194 QValueListConstIterator<OContact> it;
192 uint arraycounter = 0; 195 uint arraycounter = 0;
193 196
194 for( it = m_contactList.begin(); it != m_contactList.end(); ++it ){ 197 for( it = m_contactList.begin(); it != m_contactList.end(); ++it ){
195 /* Search all fields and compare them with query object. Store them into list 198 /* Search all fields and compare them with query object. Store them into list
196 * if all fields matches. 199 * if all fields matches.
197 */ 200 */
198 bool allcorrect = true; 201 bool allcorrect = true;
199 for ( int i = 0; i < Qtopia::rid; i++ ) { 202 for ( int i = 0; i < Qtopia::rid; i++ ) {
200 /* Just compare fields which are not empty in the query object */ 203 /* Just compare fields which are not empty in the query object */
201 if ( !query.field(i).isEmpty() ){ 204 if ( !query.field(i).isEmpty() ){
202 switch ( settings & ~OContactAccess::query_IgnoreCase ){ 205 switch ( settings & ~OContactAccess::IgnoreCase ){
203 case OContactAccess::query_RegExp:{ 206 case OContactAccess::RegExp:{
204 QRegExp expr ( query.field(i), 207 QRegExp expr ( query.field(i),
205 !(settings & OContactAccess::query_IgnoreCase), 208 !(settings & OContactAccess::IgnoreCase),
206 false ); 209 false );
207 if ( expr.find ( (*it).field(i), 0 ) == -1 ) 210 if ( expr.find ( (*it).field(i), 0 ) == -1 )
208 allcorrect = false; 211 allcorrect = false;
209 } 212 }
210 break; 213 break;
211 case OContactAccess::query_WildCards:{ 214 case OContactAccess::WildCards:{
212 QRegExp expr ( query.field(i), 215 QRegExp expr ( query.field(i),
213 !(settings & OContactAccess::query_IgnoreCase), 216 !(settings & OContactAccess::IgnoreCase),
214 true ); 217 true );
215 if ( expr.find ( (*it).field(i), 0 ) == -1 ) 218 if ( expr.find ( (*it).field(i), 0 ) == -1 )
216 allcorrect = false; 219 allcorrect = false;
217 } 220 }
218 break; 221 break;
219 case OContactAccess::query_ExactMatch:{ 222 case OContactAccess::ExactMatch:{
220 if (settings & OContactAccess::query_IgnoreCase){ 223 if (settings & OContactAccess::IgnoreCase){
221 if ( query.field(i).upper() != 224 if ( query.field(i).upper() !=
222 (*it).field(i).upper() ) 225 (*it).field(i).upper() )
223 allcorrect = false; 226 allcorrect = false;
224 }else{ 227 }else{
225 if ( query.field(i) != (*it).field(i) ) 228 if ( query.field(i) != (*it).field(i) )
226 allcorrect = false; 229 allcorrect = false;
227 } 230 }
228 } 231 }
229 break; 232 break;
230 } 233 }
231 } 234 }
232 } 235 }
@@ -234,42 +237,42 @@ class OContactAccessBackend_XML : public OContactAccessBackend {
234 m_currentQuery[arraycounter++] = (*it).uid(); 237 m_currentQuery[arraycounter++] = (*it).uid();
235 } 238 }
236 } 239 }
237 240
238 // Shrink to fit.. 241 // Shrink to fit..
239 m_currentQuery.resize(arraycounter); 242 m_currentQuery.resize(arraycounter);
240 243
241 return m_currentQuery; 244 return m_currentQuery;
242 } 245 }
243 246
244 const uint querySettings() 247 const uint querySettings()
245 { 248 {
246 return ( OContactAccess::query_WildCards 249 return ( OContactAccess::WildCards
247 & OContactAccess::query_IgnoreCase 250 & OContactAccess::IgnoreCase
248 & OContactAccess::query_RegExp 251 & OContactAccess::RegExp
249 & OContactAccess::query_ExactMatch ); 252 & OContactAccess::ExactMatch );
250 } 253 }
251 254
252 bool hasQuerySettings (uint querySettings) const 255 bool hasQuerySettings (uint querySettings) const
253 { 256 {
254 /* OContactAccess::query_IgnoreCase may be added with one 257 /* OContactAccess::IgnoreCase may be added with one
255 * of the other settings, but never used alone. 258 * of the other settings, but never used alone.
256 * The other settings are just valid alone... 259 * The other settings are just valid alone...
257 */ 260 */
258 switch ( querySettings & ~OContactAccess::query_IgnoreCase ){ 261 switch ( querySettings & ~OContactAccess::IgnoreCase ){
259 case OContactAccess::query_RegExp: 262 case OContactAccess::RegExp:
260 return ( true ); 263 return ( true );
261 case OContactAccess::query_WildCards: 264 case OContactAccess::WildCards:
262 return ( true ); 265 return ( true );
263 case OContactAccess::query_ExactMatch: 266 case OContactAccess::ExactMatch:
264 return ( true ); 267 return ( true );
265 default: 268 default:
266 return ( false ); 269 return ( false );
267 } 270 }
268 } 271 }
269 272
270 bool add ( const OContact &newcontact ) 273 bool add ( const OContact &newcontact )
271 { 274 {
272 //qWarning("odefaultbackend: ACTION::ADD"); 275 //qWarning("odefaultbackend: ACTION::ADD");
273 updateJournal (newcontact, OContact::ACTION_ADD); 276 updateJournal (newcontact, OContact::ACTION_ADD);
274 addContact_p( newcontact ); 277 addContact_p( newcontact );
275 return true; 278 return true;
diff --git a/libopie/pim/opimaccesstemplate.h b/libopie/pim/opimaccesstemplate.h
index a0d8f63..3e1f393 100644
--- a/libopie/pim/opimaccesstemplate.h
+++ b/libopie/pim/opimaccesstemplate.h
@@ -18,31 +18,24 @@
18 * Just create a OPimRecord and inherit from 18 * Just create a OPimRecord and inherit from
19 * the plugins 19 * the plugins
20 */ 20 */
21 21
22template <class T = OPimRecord > 22template <class T = OPimRecord >
23class OPimAccessTemplate : public OTemplateBase<T> { 23class OPimAccessTemplate : public OTemplateBase<T> {
24public: 24public:
25 typedef ORecordList<T> List; 25 typedef ORecordList<T> List;
26 typedef OPimAccessBackend<T> BackEnd; 26 typedef OPimAccessBackend<T> BackEnd;
27 typedef OPimCache<T> Cache; 27 typedef OPimCache<T> Cache;
28 28
29 /** 29 /**
30 * our sort order
31 * should be safe explaining
32 */
33 enum SortOrder { WildCards = 0, IgnoreCase = 1,
34 RegExp = 2, ExactMatch = 4 };
35
36 /**
37 * c'tor BackEnd 30 * c'tor BackEnd
38 */ 31 */
39 OPimAccessTemplate( BackEnd* end); 32 OPimAccessTemplate( BackEnd* end);
40 virtual ~OPimAccessTemplate(); 33 virtual ~OPimAccessTemplate();
41 34
42 /** 35 /**
43 * load from the backend 36 * load from the backend
44 */ 37 */
45 virtual bool load(); 38 virtual bool load();
46 39
47 /** 40 /**
48 * reload from the backend 41 * reload from the backend
@@ -57,27 +50,28 @@ public:
57 /** 50 /**
58 * if the resource was changed externally 51 * if the resource was changed externally
59 */ 52 */
60 bool wasChangedExternally()const; 53 bool wasChangedExternally()const;
61 54
62 /** 55 /**
63 * return a List of records 56 * return a List of records
64 * you can iterate over them 57 * you can iterate over them
65 */ 58 */
66 virtual List allRecords()const; 59 virtual List allRecords()const;
67 60
68 /** 61 /**
69 * queryByExample 62 * queryByExample)
63 * @see otodoaccess, ocontactaccess
70 */ 64 */
71 virtual List queryByExample( const T& t, int sortOrder ); 65 virtual List queryByExample( const T& t, int querySettings );
72 66
73 /** 67 /**
74 * find the OPimRecord uid 68 * find the OPimRecord uid
75 */ 69 */
76 virtual T find( int uid )const; 70 virtual T find( int uid )const;
77 71
78 /** 72 /**
79 * read ahead cache find method ;) 73 * read ahead cache find method ;)
80 */ 74 */
81 virtual T find( int uid, const QArray<int>&, 75 virtual T find( int uid, const QArray<int>&,
82 uint current, CacheDirection dir = Forward )const; 76 uint current, CacheDirection dir = Forward )const;
83 77
diff --git a/libopie/pim/otodoaccessxml.cpp b/libopie/pim/otodoaccessxml.cpp
index f3b0783..3b4cab2 100644
--- a/libopie/pim/otodoaccessxml.cpp
+++ b/libopie/pim/otodoaccessxml.cpp
@@ -178,25 +178,25 @@ bool OTodoAccessXML::save() {
178} 178}
179QArray<int> OTodoAccessXML::allRecords()const { 179QArray<int> OTodoAccessXML::allRecords()const {
180 QArray<int> ids( m_events.count() ); 180 QArray<int> ids( m_events.count() );
181 QMap<int, OTodo>::ConstIterator it; 181 QMap<int, OTodo>::ConstIterator it;
182 int i = 0; 182 int i = 0;
183 183
184 for ( it = m_events.begin(); it != m_events.end(); ++it ) { 184 for ( it = m_events.begin(); it != m_events.end(); ++it ) {
185 ids[i] = it.key(); 185 ids[i] = it.key();
186 i++; 186 i++;
187 } 187 }
188 return ids; 188 return ids;
189} 189}
190QArray<int> OTodoAccessXML::queryByExample( const OTodo&, int sort ) { 190QArray<int> OTodoAccessXML::queryByExample( const OTodo&, int ) {
191 QArray<int> ids(0); 191 QArray<int> ids(0);
192 return ids; 192 return ids;
193} 193}
194OTodo OTodoAccessXML::find( int uid )const { 194OTodo OTodoAccessXML::find( int uid )const {
195 OTodo todo; 195 OTodo todo;
196 todo.setUid( 0 ); // isEmpty() 196 todo.setUid( 0 ); // isEmpty()
197 QMap<int, OTodo>::ConstIterator it = m_events.find( uid ); 197 QMap<int, OTodo>::ConstIterator it = m_events.find( uid );
198 if ( it != m_events.end() ) 198 if ( it != m_events.end() )
199 todo = it.data(); 199 todo = it.data();
200 200
201 return todo; 201 return todo;
202} 202}
diff --git a/libopie/pim/otodoaccessxml.h b/libopie/pim/otodoaccessxml.h
index 1e7e371..dc41c32 100644
--- a/libopie/pim/otodoaccessxml.h
+++ b/libopie/pim/otodoaccessxml.h
@@ -15,25 +15,25 @@ public:
15 /** 15 /**
16 * fileName if Empty we will use the default path 16 * fileName if Empty we will use the default path
17 */ 17 */
18 OTodoAccessXML( const QString& appName, 18 OTodoAccessXML( const QString& appName,
19 const QString& fileName = QString::null ); 19 const QString& fileName = QString::null );
20 ~OTodoAccessXML(); 20 ~OTodoAccessXML();
21 21
22 bool load(); 22 bool load();
23 bool reload(); 23 bool reload();
24 bool save(); 24 bool save();
25 25
26 QArray<int> allRecords()const; 26 QArray<int> allRecords()const;
27 QArray<int> queryByExample( const OTodo&, int sort ); 27 QArray<int> queryByExample( const OTodo&, int querysettings );
28 OTodo find( int uid )const; 28 OTodo find( int uid )const;
29 void clear(); 29 void clear();
30 bool add( const OTodo& ); 30 bool add( const OTodo& );
31 bool remove( int uid ); 31 bool remove( int uid );
32 bool replace( const OTodo& ); 32 bool replace( const OTodo& );
33 33
34 /* our functions */ 34 /* our functions */
35 QArray<int> effectiveToDos( const QDate& start, 35 QArray<int> effectiveToDos( const QDate& start,
36 const QDate& end, 36 const QDate& end,
37 bool includeNoDates ); 37 bool includeNoDates );
38 QArray<int> overDue(); 38 QArray<int> overDue();
39 QArray<int> sorted( bool asc, int sortOrder, 39 QArray<int> sorted( bool asc, int sortOrder,
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_xml.h b/libopie2/opiepim/backend/ocontactaccessbackend_xml.h
index 97ef40f..50ea329 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.3 2002/10/14 16:21:54 eilers
21 * Some minor interface updates
22 *
20 * Revision 1.2 2002/10/07 17:34:24 eilers 23 * Revision 1.2 2002/10/07 17:34:24 eilers
21 * added OBackendFactory for advanced backend access 24 * added OBackendFactory for advanced backend access
22 * 25 *
23 * Revision 1.1 2002/09/27 17:11:44 eilers 26 * Revision 1.1 2002/09/27 17:11:44 eilers
24 * Added API for accessing the Contact-Database ! It is compiling, but 27 * Added API for accessing the Contact-Database ! It is compiling, but
25 * please do not expect that anything is working ! 28 * please do not expect that anything is working !
26 * I will debug that stuff in the next time .. 29 * I will debug that stuff in the next time ..
27 * Please read README_COMPILE for compiling ! 30 * Please read README_COMPILE for compiling !
28 * 31 *
29 * 32 *
30 */ 33 */
31 34
@@ -190,43 +193,43 @@ class OContactAccessBackend_XML : public OContactAccessBackend {
190 QArray<int> m_currentQuery( m_contactList.count() ); 193 QArray<int> m_currentQuery( m_contactList.count() );
191 QValueListConstIterator<OContact> it; 194 QValueListConstIterator<OContact> it;
192 uint arraycounter = 0; 195 uint arraycounter = 0;
193 196
194 for( it = m_contactList.begin(); it != m_contactList.end(); ++it ){ 197 for( it = m_contactList.begin(); it != m_contactList.end(); ++it ){
195 /* Search all fields and compare them with query object. Store them into list 198 /* Search all fields and compare them with query object. Store them into list
196 * if all fields matches. 199 * if all fields matches.
197 */ 200 */
198 bool allcorrect = true; 201 bool allcorrect = true;
199 for ( int i = 0; i < Qtopia::rid; i++ ) { 202 for ( int i = 0; i < Qtopia::rid; i++ ) {
200 /* Just compare fields which are not empty in the query object */ 203 /* Just compare fields which are not empty in the query object */
201 if ( !query.field(i).isEmpty() ){ 204 if ( !query.field(i).isEmpty() ){
202 switch ( settings & ~OContactAccess::query_IgnoreCase ){ 205 switch ( settings & ~OContactAccess::IgnoreCase ){
203 case OContactAccess::query_RegExp:{ 206 case OContactAccess::RegExp:{
204 QRegExp expr ( query.field(i), 207 QRegExp expr ( query.field(i),
205 !(settings & OContactAccess::query_IgnoreCase), 208 !(settings & OContactAccess::IgnoreCase),
206 false ); 209 false );
207 if ( expr.find ( (*it).field(i), 0 ) == -1 ) 210 if ( expr.find ( (*it).field(i), 0 ) == -1 )
208 allcorrect = false; 211 allcorrect = false;
209 } 212 }
210 break; 213 break;
211 case OContactAccess::query_WildCards:{ 214 case OContactAccess::WildCards:{
212 QRegExp expr ( query.field(i), 215 QRegExp expr ( query.field(i),
213 !(settings & OContactAccess::query_IgnoreCase), 216 !(settings & OContactAccess::IgnoreCase),
214 true ); 217 true );
215 if ( expr.find ( (*it).field(i), 0 ) == -1 ) 218 if ( expr.find ( (*it).field(i), 0 ) == -1 )
216 allcorrect = false; 219 allcorrect = false;
217 } 220 }
218 break; 221 break;
219 case OContactAccess::query_ExactMatch:{ 222 case OContactAccess::ExactMatch:{
220 if (settings & OContactAccess::query_IgnoreCase){ 223 if (settings & OContactAccess::IgnoreCase){
221 if ( query.field(i).upper() != 224 if ( query.field(i).upper() !=
222 (*it).field(i).upper() ) 225 (*it).field(i).upper() )
223 allcorrect = false; 226 allcorrect = false;
224 }else{ 227 }else{
225 if ( query.field(i) != (*it).field(i) ) 228 if ( query.field(i) != (*it).field(i) )
226 allcorrect = false; 229 allcorrect = false;
227 } 230 }
228 } 231 }
229 break; 232 break;
230 } 233 }
231 } 234 }
232 } 235 }
@@ -234,42 +237,42 @@ class OContactAccessBackend_XML : public OContactAccessBackend {
234 m_currentQuery[arraycounter++] = (*it).uid(); 237 m_currentQuery[arraycounter++] = (*it).uid();
235 } 238 }
236 } 239 }
237 240
238 // Shrink to fit.. 241 // Shrink to fit..
239 m_currentQuery.resize(arraycounter); 242 m_currentQuery.resize(arraycounter);
240 243
241 return m_currentQuery; 244 return m_currentQuery;
242 } 245 }
243 246
244 const uint querySettings() 247 const uint querySettings()
245 { 248 {
246 return ( OContactAccess::query_WildCards 249 return ( OContactAccess::WildCards
247 & OContactAccess::query_IgnoreCase 250 & OContactAccess::IgnoreCase
248 & OContactAccess::query_RegExp 251 & OContactAccess::RegExp
249 & OContactAccess::query_ExactMatch ); 252 & OContactAccess::ExactMatch );
250 } 253 }
251 254
252 bool hasQuerySettings (uint querySettings) const 255 bool hasQuerySettings (uint querySettings) const
253 { 256 {
254 /* OContactAccess::query_IgnoreCase may be added with one 257 /* OContactAccess::IgnoreCase may be added with one
255 * of the other settings, but never used alone. 258 * of the other settings, but never used alone.
256 * The other settings are just valid alone... 259 * The other settings are just valid alone...
257 */ 260 */
258 switch ( querySettings & ~OContactAccess::query_IgnoreCase ){ 261 switch ( querySettings & ~OContactAccess::IgnoreCase ){
259 case OContactAccess::query_RegExp: 262 case OContactAccess::RegExp:
260 return ( true ); 263 return ( true );
261 case OContactAccess::query_WildCards: 264 case OContactAccess::WildCards:
262 return ( true ); 265 return ( true );
263 case OContactAccess::query_ExactMatch: 266 case OContactAccess::ExactMatch:
264 return ( true ); 267 return ( true );
265 default: 268 default:
266 return ( false ); 269 return ( false );
267 } 270 }
268 } 271 }
269 272
270 bool add ( const OContact &newcontact ) 273 bool add ( const OContact &newcontact )
271 { 274 {
272 //qWarning("odefaultbackend: ACTION::ADD"); 275 //qWarning("odefaultbackend: ACTION::ADD");
273 updateJournal (newcontact, OContact::ACTION_ADD); 276 updateJournal (newcontact, OContact::ACTION_ADD);
274 addContact_p( newcontact ); 277 addContact_p( newcontact );
275 return true; 278 return true;
diff --git a/libopie2/opiepim/backend/otodoaccessxml.cpp b/libopie2/opiepim/backend/otodoaccessxml.cpp
index f3b0783..3b4cab2 100644
--- a/libopie2/opiepim/backend/otodoaccessxml.cpp
+++ b/libopie2/opiepim/backend/otodoaccessxml.cpp
@@ -178,25 +178,25 @@ bool OTodoAccessXML::save() {
178} 178}
179QArray<int> OTodoAccessXML::allRecords()const { 179QArray<int> OTodoAccessXML::allRecords()const {
180 QArray<int> ids( m_events.count() ); 180 QArray<int> ids( m_events.count() );
181 QMap<int, OTodo>::ConstIterator it; 181 QMap<int, OTodo>::ConstIterator it;
182 int i = 0; 182 int i = 0;
183 183
184 for ( it = m_events.begin(); it != m_events.end(); ++it ) { 184 for ( it = m_events.begin(); it != m_events.end(); ++it ) {
185 ids[i] = it.key(); 185 ids[i] = it.key();
186 i++; 186 i++;
187 } 187 }
188 return ids; 188 return ids;
189} 189}
190QArray<int> OTodoAccessXML::queryByExample( const OTodo&, int sort ) { 190QArray<int> OTodoAccessXML::queryByExample( const OTodo&, int ) {
191 QArray<int> ids(0); 191 QArray<int> ids(0);
192 return ids; 192 return ids;
193} 193}
194OTodo OTodoAccessXML::find( int uid )const { 194OTodo OTodoAccessXML::find( int uid )const {
195 OTodo todo; 195 OTodo todo;
196 todo.setUid( 0 ); // isEmpty() 196 todo.setUid( 0 ); // isEmpty()
197 QMap<int, OTodo>::ConstIterator it = m_events.find( uid ); 197 QMap<int, OTodo>::ConstIterator it = m_events.find( uid );
198 if ( it != m_events.end() ) 198 if ( it != m_events.end() )
199 todo = it.data(); 199 todo = it.data();
200 200
201 return todo; 201 return todo;
202} 202}
diff --git a/libopie2/opiepim/backend/otodoaccessxml.h b/libopie2/opiepim/backend/otodoaccessxml.h
index 1e7e371..dc41c32 100644
--- a/libopie2/opiepim/backend/otodoaccessxml.h
+++ b/libopie2/opiepim/backend/otodoaccessxml.h
@@ -15,25 +15,25 @@ public:
15 /** 15 /**
16 * fileName if Empty we will use the default path 16 * fileName if Empty we will use the default path
17 */ 17 */
18 OTodoAccessXML( const QString& appName, 18 OTodoAccessXML( const QString& appName,
19 const QString& fileName = QString::null ); 19 const QString& fileName = QString::null );
20 ~OTodoAccessXML(); 20 ~OTodoAccessXML();
21 21
22 bool load(); 22 bool load();
23 bool reload(); 23 bool reload();
24 bool save(); 24 bool save();
25 25
26 QArray<int> allRecords()const; 26 QArray<int> allRecords()const;
27 QArray<int> queryByExample( const OTodo&, int sort ); 27 QArray<int> queryByExample( const OTodo&, int querysettings );
28 OTodo find( int uid )const; 28 OTodo find( int uid )const;
29 void clear(); 29 void clear();
30 bool add( const OTodo& ); 30 bool add( const OTodo& );
31 bool remove( int uid ); 31 bool remove( int uid );
32 bool replace( const OTodo& ); 32 bool replace( const OTodo& );
33 33
34 /* our functions */ 34 /* our functions */
35 QArray<int> effectiveToDos( const QDate& start, 35 QArray<int> effectiveToDos( const QDate& start,
36 const QDate& end, 36 const QDate& end,
37 bool includeNoDates ); 37 bool includeNoDates );
38 QArray<int> overDue(); 38 QArray<int> overDue();
39 QArray<int> sorted( bool asc, int sortOrder, 39 QArray<int> sorted( bool asc, int sortOrder,
diff --git a/libopie2/opiepim/core/ocontactaccess.cpp b/libopie2/opiepim/core/ocontactaccess.cpp
index b5f358b..e8c0a45 100644
--- a/libopie2/opiepim/core/ocontactaccess.cpp
+++ b/libopie2/opiepim/core/ocontactaccess.cpp
@@ -12,24 +12,27 @@
12 * Info: This class could just work with a change in the header-file 12 * Info: This class could just work with a change in the header-file
13 * of the Contact class ! Therefore our libopie only compiles 13 * of the Contact class ! Therefore our libopie only compiles
14 * with our version of libqpe 14 * with our version of libqpe
15 * ===================================================================== 15 * =====================================================================
16 * ToDo: XML-Backend: Automatic reload if something was changed... 16 * ToDo: XML-Backend: Automatic reload if something was changed...
17 * 17 *
18 * 18 *
19 * ===================================================================== 19 * =====================================================================
20 * Version: $Id$ 20 * Version: $Id$
21 * ===================================================================== 21 * =====================================================================
22 * History: 22 * History:
23 * $Log$ 23 * $Log$
24 * Revision 1.4 2002/10/14 16:21:54 eilers
25 * Some minor interface updates
26 *
24 * Revision 1.3 2002/10/07 17:34:24 eilers 27 * Revision 1.3 2002/10/07 17:34:24 eilers
25 * added OBackendFactory for advanced backend access 28 * added OBackendFactory for advanced backend access
26 * 29 *
27 * Revision 1.2 2002/10/02 16:18:11 eilers 30 * Revision 1.2 2002/10/02 16:18:11 eilers
28 * debugged and seems to work almost perfectly .. 31 * debugged and seems to work almost perfectly ..
29 * 32 *
30 * Revision 1.1 2002/09/27 17:11:44 eilers 33 * Revision 1.1 2002/09/27 17:11:44 eilers
31 * Added API for accessing the Contact-Database ! It is compiling, but 34 * Added API for accessing the Contact-Database ! It is compiling, but
32 * please do not expect that anything is working ! 35 * please do not expect that anything is working !
33 * I will debug that stuff in the next time .. 36 * I will debug that stuff in the next time ..
34 * Please read README_COMPILE for compiling ! 37 * Please read README_COMPILE for compiling !
35 * 38 *
@@ -57,25 +60,24 @@
57#include "ocontactaccessbackend_xml.h" 60#include "ocontactaccessbackend_xml.h"
58 61
59 62
60OContactAccess::OContactAccess ( const QString appname, const QString , 63OContactAccess::OContactAccess ( const QString appname, const QString ,
61 OContactAccessBackend* end, bool autosync ): 64 OContactAccessBackend* end, bool autosync ):
62 OPimAccessTemplate<OContact>( end ), 65 OPimAccessTemplate<OContact>( end ),
63 m_changed ( false ) 66 m_changed ( false )
64{ 67{
65 /* take care of the backend. If there is no one defined, we 68 /* take care of the backend. If there is no one defined, we
66 * will use the XML-Backend as default (until we have a cute SQL-Backend..). 69 * will use the XML-Backend as default (until we have a cute SQL-Backend..).
67 */ 70 */
68 if( end == 0 ) { 71 if( end == 0 ) {
69 // __asm__("int3");
70 qWarning ("Using BackendFactory !"); 72 qWarning ("Using BackendFactory !");
71 end = OBackendFactory<OContactAccessBackend>::Default( "contact", appname ); 73 end = OBackendFactory<OContactAccessBackend>::Default( "contact", appname );
72 } 74 }
73 // Set backend locally and in template 75 // Set backend locally and in template
74 m_backEnd = end; 76 m_backEnd = end;
75 OPimAccessTemplate<OContact>::setBackEnd (end); 77 OPimAccessTemplate<OContact>::setBackEnd (end);
76 78
77 79
78 /* Connect signal of external db change to function */ 80 /* Connect signal of external db change to function */
79 QCopChannel *dbchannel = new QCopChannel( "QPE/PIM", this ); 81 QCopChannel *dbchannel = new QCopChannel( "QPE/PIM", this );
80 connect( dbchannel, SIGNAL(received(const QCString &, const QByteArray &)), 82 connect( dbchannel, SIGNAL(received(const QCString &, const QByteArray &)),
81 this, SLOT(copMessage( const QCString &, const QByteArray &)) ); 83 this, SLOT(copMessage( const QCString &, const QByteArray &)) );
diff --git a/libopie2/opiepim/core/ocontactaccess.h b/libopie2/opiepim/core/ocontactaccess.h
index 54f7f07..adc66cf 100644
--- a/libopie2/opiepim/core/ocontactaccess.h
+++ b/libopie2/opiepim/core/ocontactaccess.h
@@ -8,24 +8,27 @@
8 *This program is free software; you can redistribute it and/or 8 *This program is free software; you can redistribute it and/or
9 *modify it under the terms of the GNU Library General Public 9 *modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; 10 * License as published by the Free Software Foundation;
11 * either version 2 of the License, or (at your option) any later 11 * either version 2 of the License, or (at your option) any later
12 * version. 12 * version.
13 * ===================================================================== 13 * =====================================================================
14 * ToDo: Define enum for query settings 14 * ToDo: Define enum for query settings
15 * ===================================================================== 15 * =====================================================================
16 * Version: $Id$ 16 * Version: $Id$
17 * ===================================================================== 17 * =====================================================================
18 * History: 18 * History:
19 * $Log$ 19 * $Log$
20 * Revision 1.2 2002/10/14 16:21:54 eilers
21 * Some minor interface updates
22 *
20 * Revision 1.1 2002/09/27 17:11:44 eilers 23 * Revision 1.1 2002/09/27 17:11:44 eilers
21 * Added API for accessing the Contact-Database ! It is compiling, but 24 * Added API for accessing the Contact-Database ! It is compiling, but
22 * please do not expect that anything is working ! 25 * please do not expect that anything is working !
23 * I will debug that stuff in the next time .. 26 * I will debug that stuff in the next time ..
24 * Please read README_COMPILE for compiling ! 27 * Please read README_COMPILE for compiling !
25 * 28 *
26 * ===================================================================== 29 * =====================================================================
27 */ 30 */
28#ifndef _OCONTACTACCESS_H 31#ifndef _OCONTACTACCESS_H
29#define _OCONTACTACCESS_H 32#define _OCONTACTACCESS_H
30 33
31#include <qobject.h> 34#include <qobject.h>
@@ -38,85 +41,53 @@
38#include "ocontact.h" 41#include "ocontact.h"
39#include "ocontactaccessbackend.h" 42#include "ocontactaccessbackend.h"
40#include "opimaccesstemplate.h" 43#include "opimaccesstemplate.h"
41 44
42/** Class to access the contacts database. 45/** Class to access the contacts database.
43 * This is just a frontend for the real database handling which is 46 * This is just a frontend for the real database handling which is
44 * done by the backend. 47 * done by the backend.
45 */ 48 */
46class OContactAccess: public QObject, public OPimAccessTemplate<OContact> 49class OContactAccess: public QObject, public OPimAccessTemplate<OContact>
47{ 50{
48 Q_OBJECT 51 Q_OBJECT
49 52
50
51 /* class Iterator{
52 friend OContactAccess;
53 public:
54 Iterator();
55 Iterator ( const Iterator& copy );
56
57 bool operator== ( const Iterator& it );
58 bool operator!= ( const Iterator& it );
59 Iterator& operator= ( const Iterator& it );
60 Iterator& operator++ (); // prefix
61 Iterator operator++ ( int ); // postfix
62 Iterator& operator-- (); // prefix
63 Iterator operator-- ( int ); // postfix
64 Contact operator*() const;
65 Contact operator->() const;
66
67 Iterator begin();
68 Iterator end();
69
70 uint count() const;
71
72 private:
73 QValueList<int> m_uids;
74 int m_cur_position;
75 bool m_end_reached;
76 OContactAccess *m_db;
77
78 };
79
80 */
81
82 public: 53 public:
83 /** Create Database with contacts (addressbook). 54 /** Create Database with contacts (addressbook).
84 * @param appname Name of application which wants access to the database 55 * @param appname Name of application which wants access to the database
85 * (i.e. "todolist") 56 * (i.e. "todolist")
86 * @param filename The name of the database file. If not set, the default one 57 * @param filename The name of the database file. If not set, the default one
87 * is used. 58 * is used.
88 * @param backend Pointer to an alternative Backend. If not set, we will use 59 * @param backend Pointer to an alternative Backend. If not set, we will use
89 * the default backend. 60 * the default backend.
90 * @param handlesync If <b>true</b> the database stores the current state 61 * @param handlesync If <b>true</b> the database stores the current state
91 * automatically if it receives the signals <i>flush()</i> and <i>reload()</i> 62 * automatically if it receives the signals <i>flush()</i> and <i>reload()</i>
92 * which are used before and after synchronisation. If the application wants 63 * which are used before and after synchronisation. If the application wants
93 * to react itself, it should be disabled by setting it to <b>false</b> 64 * to react itself, it should be disabled by setting it to <b>false</b>
94 * @see OContactBackend 65 * @see OContactAccessBackend
95 */ 66 */
96 OContactAccess (const QString appname, const QString filename = 0l, 67 OContactAccess (const QString appname, const QString filename = 0l,
97 OContactAccessBackend* backend = 0l, bool handlesync = true); 68 OContactAccessBackend* backend = 0l, bool handlesync = true);
98 ~OContactAccess (); 69 ~OContactAccess ();
99 70
100 /** Constants for query. 71 /** Constants for query.
101 * Use this constants to set the query parameters. 72 * Use this constants to set the query parameters.
102 * Note: <i>query_IgnoreCase</i> just make sense with one of the other attributes ! 73 * Note: <i>query_IgnoreCase</i> just make sense with one of the other attributes !
103 * @see queryByExample() 74 * @see queryByExample()
104 * - why not enum - zecke?
105 * -> Had some implementation problems .. Will use enum soon ! .. (se)
106 */ 75 */
107 static const int query_WildCards = 0x0001; 76 enum QuerySettings {
108 static const int query_IgnoreCase = 0x0002; 77 WildCards = 0x0001,
109 static const int query_RegExp = 0x0004; 78 IgnoreCase = 0x0002,
110 static const int query_ExactMatch = 0x0008; 79 RegExp = 0x0004,
80 ExactMatch = 0x0008,
81 };
111 82
112 /** Return all possible settings. 83 /** Return all possible settings.
113 * @return All settings provided by the current backend 84 * @return All settings provided by the current backend
114 * (i.e.: query_WildCards & query_IgnoreCase) 85 * (i.e.: query_WildCards & query_IgnoreCase)
115 */ 86 */
116 const uint querySettings(); 87 const uint querySettings();
117 88
118 /** Check whether settings are correct. 89 /** Check whether settings are correct.
119 * @return <i>true</i> if the given settings are correct and possible. 90 * @return <i>true</i> if the given settings are correct and possible.
120 */ 91 */
121 bool hasQuerySettings ( int querySettings ) const; 92 bool hasQuerySettings ( int querySettings ) const;
122 93
diff --git a/libopie2/opiepim/core/opimaccesstemplate.h b/libopie2/opiepim/core/opimaccesstemplate.h
index a0d8f63..3e1f393 100644
--- a/libopie2/opiepim/core/opimaccesstemplate.h
+++ b/libopie2/opiepim/core/opimaccesstemplate.h
@@ -18,31 +18,24 @@
18 * Just create a OPimRecord and inherit from 18 * Just create a OPimRecord and inherit from
19 * the plugins 19 * the plugins
20 */ 20 */
21 21
22template <class T = OPimRecord > 22template <class T = OPimRecord >
23class OPimAccessTemplate : public OTemplateBase<T> { 23class OPimAccessTemplate : public OTemplateBase<T> {
24public: 24public:
25 typedef ORecordList<T> List; 25 typedef ORecordList<T> List;
26 typedef OPimAccessBackend<T> BackEnd; 26 typedef OPimAccessBackend<T> BackEnd;
27 typedef OPimCache<T> Cache; 27 typedef OPimCache<T> Cache;
28 28
29 /** 29 /**
30 * our sort order
31 * should be safe explaining
32 */
33 enum SortOrder { WildCards = 0, IgnoreCase = 1,
34 RegExp = 2, ExactMatch = 4 };
35
36 /**
37 * c'tor BackEnd 30 * c'tor BackEnd
38 */ 31 */
39 OPimAccessTemplate( BackEnd* end); 32 OPimAccessTemplate( BackEnd* end);
40 virtual ~OPimAccessTemplate(); 33 virtual ~OPimAccessTemplate();
41 34
42 /** 35 /**
43 * load from the backend 36 * load from the backend
44 */ 37 */
45 virtual bool load(); 38 virtual bool load();
46 39
47 /** 40 /**
48 * reload from the backend 41 * reload from the backend
@@ -57,27 +50,28 @@ public:
57 /** 50 /**
58 * if the resource was changed externally 51 * if the resource was changed externally
59 */ 52 */
60 bool wasChangedExternally()const; 53 bool wasChangedExternally()const;
61 54
62 /** 55 /**
63 * return a List of records 56 * return a List of records
64 * you can iterate over them 57 * you can iterate over them
65 */ 58 */
66 virtual List allRecords()const; 59 virtual List allRecords()const;
67 60
68 /** 61 /**
69 * queryByExample 62 * queryByExample)
63 * @see otodoaccess, ocontactaccess
70 */ 64 */
71 virtual List queryByExample( const T& t, int sortOrder ); 65 virtual List queryByExample( const T& t, int querySettings );
72 66
73 /** 67 /**
74 * find the OPimRecord uid 68 * find the OPimRecord uid
75 */ 69 */
76 virtual T find( int uid )const; 70 virtual T find( int uid )const;
77 71
78 /** 72 /**
79 * read ahead cache find method ;) 73 * read ahead cache find method ;)
80 */ 74 */
81 virtual T find( int uid, const QArray<int>&, 75 virtual T find( int uid, const QArray<int>&,
82 uint current, CacheDirection dir = Forward )const; 76 uint current, CacheDirection dir = Forward )const;
83 77