Diffstat (limited to 'libopie2/opiepim/core/opimaccesstemplate.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiepim/core/opimaccesstemplate.h | 351 |
1 files changed, 250 insertions, 101 deletions
diff --git a/libopie2/opiepim/core/opimaccesstemplate.h b/libopie2/opiepim/core/opimaccesstemplate.h index f936d4e..2deb92a 100644 --- a/libopie2/opiepim/core/opimaccesstemplate.h +++ b/libopie2/opiepim/core/opimaccesstemplate.h | |||
@@ -1,10 +1,10 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) Holger Freyther <zecke@handhelds.org> | 3 | Copyright (C) Holger Freyther <zecke@handhelds.org> |
4 | Copyright (C) Stefan Eilers <eilers.stefan@epost.de> | 4 | Copyright (C) Stefan Eilers <eilers.stefan@epost.de> |
5 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 5 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
6 | .=l. | 6 | .=l. |
7 | .>+-= | 7 | .>+-= |
8 | _;:, .> :=|. This program is free software; you can | 8 | _;:, .> :=|. This program is free software; you can |
9 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, > . <= redistribute it and/or modify it under |
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
@@ -37,12 +37,13 @@ | |||
37 | 37 | ||
38 | #include <opie2/opimtemplatebase.h> | 38 | #include <opie2/opimtemplatebase.h> |
39 | #include <opie2/odebug.h> | 39 | #include <opie2/odebug.h> |
40 | 40 | ||
41 | /* QT */ | 41 | /* QT */ |
42 | #include <qarray.h> | 42 | #include <qarray.h> |
43 | #include <qdatetime.h> | ||
43 | 44 | ||
44 | namespace Opie { | 45 | namespace Opie { |
45 | 46 | ||
46 | class OPimAccessTemplatePrivate; | 47 | class OPimAccessTemplatePrivate; |
47 | /** | 48 | /** |
48 | * Thats the frontend to our OPIE PIM | 49 | * Thats the frontend to our OPIE PIM |
@@ -53,138 +54,89 @@ class OPimAccessTemplatePrivate; | |||
53 | * the templates | 54 | * the templates |
54 | */ | 55 | */ |
55 | 56 | ||
56 | template <class T = OPimRecord > | 57 | template <class T = OPimRecord > |
57 | class OPimAccessTemplate : public OTemplateBase<T> { | 58 | class OPimAccessTemplate : public OTemplateBase<T> { |
58 | public: | 59 | public: |
60 | /** | ||
61 | * | ||
62 | */ | ||
59 | enum Access { | 63 | enum Access { |
60 | Random = 0, | 64 | Random = 0, |
61 | SortedAccess | 65 | SortedAccess |
62 | }; | 66 | }; |
63 | typedef OPimRecordList<T> List; | 67 | typedef OPimRecordList<T> List; |
64 | typedef OPimAccessBackend<T> BackEnd; | 68 | typedef OPimAccessBackend<T> BackEnd; |
65 | typedef OPimCache<T> Cache; | 69 | typedef OPimCache<T> Cache; |
66 | 70 | ||
67 | /** | 71 | //@{ |
68 | * c'tor BackEnd | ||
69 | * enum Access a small hint on how to handle the backend | ||
70 | */ | ||
71 | OPimAccessTemplate( BackEnd* end); | 72 | OPimAccessTemplate( BackEnd* end); |
72 | |||
73 | virtual ~OPimAccessTemplate(); | 73 | virtual ~OPimAccessTemplate(); |
74 | //@} | ||
74 | 75 | ||
75 | /** | 76 | //@{ |
76 | * load from the backend | ||
77 | */ | ||
78 | bool load(); | 77 | bool load(); |
79 | |||
80 | /** Reload database. | ||
81 | * You should execute this function if the external database | ||
82 | * was changed. | ||
83 | * This function will load the external database and afterwards | ||
84 | * rejoin the local changes. Therefore the local database will be set consistent. | ||
85 | */ | ||
86 | virtual bool reload(); | 78 | virtual bool reload(); |
87 | |||
88 | /** Save contacts database. | ||
89 | * Save is more a "commit". After calling this function, all changes are public available. | ||
90 | * @return true if successful | ||
91 | */ | ||
92 | bool save(); | 79 | bool save(); |
80 | void clear() ; | ||
81 | //@} | ||
82 | |||
93 | 83 | ||
94 | /** | ||
95 | * if the resource was changed externally | ||
96 | * You should use the signal handling instead of polling possible changes ! | ||
97 | * zecke: Do you implement a signal for otodoaccess ? | ||
98 | */ | ||
99 | bool wasChangedExternally()const; | 84 | bool wasChangedExternally()const; |
100 | 85 | ||
101 | /** | 86 | //@{ |
102 | * return a List of records | ||
103 | * you can iterate over them | ||
104 | */ | ||
105 | virtual List allRecords()const; | 87 | virtual List allRecords()const; |
106 | |||
107 | /** | ||
108 | * return a List of records | ||
109 | * that match the regex | ||
110 | */ | ||
111 | virtual List matchRegexp( const QRegExp &r ) const; | 88 | virtual List matchRegexp( const QRegExp &r ) const; |
112 | |||
113 | /** | ||
114 | * queryByExample. | ||
115 | * @see otodoaccess, ocontactaccess | ||
116 | */ | ||
117 | virtual List queryByExample( const T& t, int querySettings, const QDateTime& d = QDateTime() ); | 89 | virtual List queryByExample( const T& t, int querySettings, const QDateTime& d = QDateTime() ); |
90 | virtual T find( UID uid )const; | ||
91 | virtual T find( UID uid, const QArray<int>&, | ||
92 | uint current, typename OTemplateBase<T>::CacheDirection dir = OTemplateBase<T>::Forward )const; | ||
93 | virtual List sorted( const List&, bool ascending, int sortOrder, | ||
94 | int sortFilter, int cat )const; | ||
95 | virtual List sorted( const List&, bool ascending, int sortOrder, | ||
96 | int sortFilter, const QArray<UID>& cats )const; | ||
97 | virtual List sorted( bool ascending, int sortOrder, int sortFilter, int cat )const; | ||
98 | virtual List sorted( bool ascending, int sortOrder, int sortOrder, | ||
99 | const QArray<UID>& cats )const; | ||
100 | //@} | ||
118 | 101 | ||
119 | /** | 102 | /** |
120 | * find the OPimRecord uid | 103 | * (Re)Implementation |
121 | */ | ||
122 | T find( int uid )const; | ||
123 | |||
124 | /** | ||
125 | * read ahead cache find method ;) | ||
126 | */ | ||
127 | T find( int uid, const QArray<int>&, | ||
128 | uint current, typename OTemplateBase<T>::CacheDirection dir = OTemplateBase<T>::Forward )const; | ||
129 | |||
130 | |||
131 | /* invalidate cache here */ | ||
132 | /** | ||
133 | * clears the backend and invalidates the backend | ||
134 | */ | 104 | */ |
135 | void clear() ; | 105 | //@{ |
136 | 106 | UIDArray matchRegexpSimple( const QRegExp& r )const; | |
137 | /** | 107 | UIDArray queryByExampleSimple( const OPimRecord*, int, const QDateTime& )const; |
138 | * add T to the backend | 108 | UIDArray sortedSimple( const UIDArray&, bool asc, int sortOrder, |
139 | * @param t The item to add. | 109 | int sortFilter, int cat )const; |
140 | * @return <i>true</i> if added successfully. | 110 | UIDArray sortedSimple( const UIDArray&, bool asc, int sortOrder, |
141 | */ | 111 | int sortFilter, const QArray<int>& )const; |
142 | virtual bool add( const T& t ) ; | 112 | UIDArray sortedSimple( bool ascending, int sortOrder, int sortFilter, |
143 | 113 | int cat )const; | |
114 | UIDArray sortedSimple( bool ascending, int sortOrder, int sortFilter, | ||
115 | const QArray<int>& )const; | ||
116 | OPimOccurrence::List occurrences( const QDate& start, const QDate& end )const; | ||
117 | OPimOccurrence::List occurrences( const QDateTime& dt )const; | ||
118 | //@} | ||
119 | |||
120 | //@{ | ||
121 | virtual bool add( const T& t ) ; | ||
144 | bool add( const OPimRecord& ); | 122 | bool add( const OPimRecord& ); |
145 | /** | ||
146 | * Add an Opie PimRecord. | ||
147 | * Info: Take this if you are working with OPimRecords and you need to add it into any database. | ||
148 | * But take care that the accessing database is compatible to the real type of OPimRecord !! | ||
149 | * Otherwise this access will be rejected ! | ||
150 | */ | ||
151 | bool add( const OPimRecord* ); | 123 | bool add( const OPimRecord* ); |
152 | |||
153 | |||
154 | /* only the uid matters */ | ||
155 | /** | ||
156 | * remove T from the backend | ||
157 | * @param t The item to remove | ||
158 | * @return <i>true</i> if successful. | ||
159 | */ | ||
160 | virtual bool remove( const T& t ); | 124 | virtual bool remove( const T& t ); |
161 | 125 | bool remove( UID uid ); | |
162 | /** | ||
163 | * remove the OPimRecord with uid | ||
164 | * @param uid The ID of the item to remove | ||
165 | * @return <i>true</i> if successful. | ||
166 | */ | ||
167 | bool remove( int uid ); | ||
168 | bool remove( const OPimRecord& ); | 126 | bool remove( const OPimRecord& ); |
169 | |||
170 | /** | ||
171 | * replace T from backend | ||
172 | * @param t The item to replace | ||
173 | * @return <i>true</i> if successful. | ||
174 | */ | ||
175 | virtual bool replace( const T& t) ; | 127 | virtual bool replace( const T& t) ; |
176 | 128 | ||
129 | //@} | ||
130 | |||
177 | void setReadAhead( uint count ); | 131 | void setReadAhead( uint count ); |
178 | /** | 132 | virtual T cacheFind( int uid )const; |
179 | * @internal | ||
180 | */ | ||
181 | void cache( const T& )const; | 133 | void cache( const T& )const; |
182 | void setSaneCacheSize( int ); | 134 | void setSaneCacheSize( int ); |
183 | 135 | ||
184 | QArray<int> records()const; | 136 | QArray<UID> records()const; |
185 | protected: | 137 | protected: |
186 | /** | 138 | /** |
187 | * invalidate the cache | 139 | * invalidate the cache |
188 | */ | 140 | */ |
189 | void invalidateCache(); | 141 | void invalidateCache(); |
190 | 142 | ||
@@ -199,96 +151,157 @@ protected: | |||
199 | 151 | ||
200 | private: | 152 | private: |
201 | OPimAccessTemplatePrivate *d; | 153 | OPimAccessTemplatePrivate *d; |
202 | 154 | ||
203 | }; | 155 | }; |
204 | 156 | ||
157 | /** | ||
158 | * c'tor BackEnd | ||
159 | * enum Access a small hint on how to handle the backend | ||
160 | */ | ||
205 | template <class T> | 161 | template <class T> |
206 | OPimAccessTemplate<T>::OPimAccessTemplate( BackEnd* end ) | 162 | OPimAccessTemplate<T>::OPimAccessTemplate( BackEnd* end ) |
207 | : OTemplateBase<T>(), m_backEnd( end ) | 163 | : OTemplateBase<T>(), m_backEnd( end ) |
208 | { | 164 | { |
209 | if (end ) | 165 | if (end ) |
210 | end->setFrontend( this ); | 166 | end->setFrontend( this ); |
211 | } | 167 | } |
212 | template <class T> | 168 | template <class T> |
213 | OPimAccessTemplate<T>::~OPimAccessTemplate() { | 169 | OPimAccessTemplate<T>::~OPimAccessTemplate() { |
214 | owarn << "~OPimAccessTemplate<T>" << oendl; | ||
215 | delete m_backEnd; | 170 | delete m_backEnd; |
216 | } | 171 | } |
172 | |||
173 | /** | ||
174 | * load from the backend | ||
175 | */ | ||
217 | template <class T> | 176 | template <class T> |
218 | bool OPimAccessTemplate<T>::load() { | 177 | bool OPimAccessTemplate<T>::load() { |
219 | invalidateCache(); | 178 | invalidateCache(); |
220 | return m_backEnd->load(); | 179 | return m_backEnd->load(); |
221 | } | 180 | } |
181 | |||
182 | /** Reload database. | ||
183 | * You should execute this function if the external database | ||
184 | * was changed. | ||
185 | * This function will load the external database and afterwards | ||
186 | * rejoin the local changes. Therefore the local database will be set consistent. | ||
187 | */ | ||
222 | template <class T> | 188 | template <class T> |
223 | bool OPimAccessTemplate<T>::reload() { | 189 | bool OPimAccessTemplate<T>::reload() { |
224 | invalidateCache(); | 190 | invalidateCache(); |
225 | return m_backEnd->reload(); | 191 | return m_backEnd->reload(); |
226 | } | 192 | } |
193 | |||
194 | /** | ||
195 | * Save contacts database. | ||
196 | * Save is more a "commit". After calling this function, all changes are public available. | ||
197 | * @return true if successful | ||
198 | */ | ||
227 | template <class T> | 199 | template <class T> |
228 | bool OPimAccessTemplate<T>::save() { | 200 | bool OPimAccessTemplate<T>::save() { |
229 | return m_backEnd->save(); | 201 | return m_backEnd->save(); |
230 | } | 202 | } |
203 | |||
204 | |||
205 | /** | ||
206 | * return a List of records | ||
207 | * you can iterate over them | ||
208 | */ | ||
231 | template <class T> | 209 | template <class T> |
232 | typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::allRecords()const { | 210 | typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::allRecords()const { |
233 | QArray<int> ints = m_backEnd->allRecords(); | 211 | QArray<int> ints = m_backEnd->allRecords(); |
234 | List lis(ints, this ); | 212 | List lis(ints, this ); |
235 | return lis; | 213 | return lis; |
236 | } | 214 | } |
215 | |||
216 | /** | ||
217 | * return a List of records | ||
218 | * that match the regex | ||
219 | */ | ||
237 | template <class T> | 220 | template <class T> |
238 | typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::matchRegexp( const QRegExp &r )const { | 221 | typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::matchRegexp( const QRegExp &r )const { |
239 | QArray<int> ints = m_backEnd->matchRegexp( r ); | 222 | QArray<int> ints = m_backEnd->matchRegexp( r ); |
240 | List lis(ints, this ); | 223 | List lis(ints, this ); |
241 | return lis; | 224 | return lis; |
242 | } | 225 | } |
226 | |||
227 | /** | ||
228 | * find the OPimRecord uid | ||
229 | */ | ||
243 | template <class T> | 230 | template <class T> |
244 | QArray<int> OPimAccessTemplate<T>::records()const { | 231 | QArray<int> OPimAccessTemplate<T>::records()const { |
245 | return m_backEnd->allRecords(); | 232 | return m_backEnd->allRecords(); |
246 | } | 233 | } |
234 | |||
235 | |||
236 | /** | ||
237 | * queryByExample. | ||
238 | * @see otodoaccess, ocontactaccess | ||
239 | */ | ||
247 | template <class T> | 240 | template <class T> |
248 | typename OPimAccessTemplate<T>::List | 241 | typename OPimAccessTemplate<T>::List |
249 | OPimAccessTemplate<T>::queryByExample( const T& t, int settings, const QDateTime& d ) { | 242 | OPimAccessTemplate<T>::queryByExample( const T& t, int settings, const QDateTime& d ) { |
250 | QArray<int> ints = m_backEnd->queryByExample( t, settings, d ); | 243 | QArray<int> ints = m_backEnd->queryByExample( t, settings, d ); |
251 | 244 | ||
252 | List lis(ints, this ); | 245 | List lis(ints, this ); |
253 | return lis; | 246 | return lis; |
254 | } | 247 | } |
248 | |||
255 | template <class T> | 249 | template <class T> |
256 | T OPimAccessTemplate<T>::find( int uid ) const{ | 250 | T OPimAccessTemplate<T>::find( UID uid ) const{ |
257 | // First search in cache.. | 251 | // First search in cache.. |
258 | if ( m_cache.contains( uid ) ) | 252 | if ( m_cache.contains( uid ) ) |
259 | return m_cache.find( uid ); | 253 | return m_cache.find( uid ); |
260 | 254 | ||
261 | T t = m_backEnd->find( uid ); | 255 | T t = m_backEnd->find( uid ); |
262 | cache( t ); | 256 | cache( t ); |
263 | 257 | ||
264 | return t; | 258 | return t; |
265 | } | 259 | } |
266 | 260 | ||
267 | template <class T> | 261 | template <class T> |
268 | T OPimAccessTemplate<T>::find( int uid, const QArray<int>& ar, | 262 | T OPimAccessTemplate<T>::cacheFind( int uid ) const |
263 | { | ||
264 | return m_cache.find( uid ); | ||
265 | } | ||
266 | |||
267 | /** | ||
268 | * read ahead cache find method ;) | ||
269 | */ | ||
270 | template <class T> | ||
271 | T OPimAccessTemplate<T>::find( UID uid, const QArray<int>& ar, | ||
269 | uint current, typename OTemplateBase<T>::CacheDirection dir )const { | 272 | uint current, typename OTemplateBase<T>::CacheDirection dir )const { |
270 | /* | 273 | /* |
271 | * better do T.isEmpty() | 274 | * better do T.isEmpty() |
272 | * after a find this way we would | 275 | * after a find this way we would |
273 | * avoid two finds in QCache... | 276 | * avoid two finds in QCache... |
274 | */ | 277 | */ |
275 | // owarn << "find it now " << uid << oendl; | 278 | if (m_cache.contains( uid ) ) |
276 | if ( m_cache.contains( uid ) ) { | ||
277 | return m_cache.find( uid ); | 279 | return m_cache.find( uid ); |
278 | } | 280 | |
279 | 281 | ||
280 | T t = m_backEnd->find( uid, ar, current, dir ); | 282 | T t = m_backEnd->find( uid, ar, current, dir ); |
281 | cache( t ); | 283 | cache( t ); |
282 | return t; | 284 | return t; |
283 | } | 285 | } |
286 | |||
287 | /** | ||
288 | * clears the backend and invalidates the backend | ||
289 | */ | ||
284 | template <class T> | 290 | template <class T> |
285 | void OPimAccessTemplate<T>::clear() { | 291 | void OPimAccessTemplate<T>::clear() { |
286 | invalidateCache(); | 292 | invalidateCache(); |
287 | m_backEnd->clear(); | 293 | m_backEnd->clear(); |
288 | } | 294 | } |
295 | |||
296 | |||
297 | /** | ||
298 | * add T to the backend | ||
299 | * @param t The item to add. | ||
300 | * @return <i>true</i> if added successfully. | ||
301 | */ | ||
289 | template <class T> | 302 | template <class T> |
290 | bool OPimAccessTemplate<T>::add( const T& t ) { | 303 | bool OPimAccessTemplate<T>::add( const T& t ) { |
291 | cache( t ); | 304 | cache( t ); |
292 | return m_backEnd->add( t ); | 305 | return m_backEnd->add( t ); |
293 | } | 306 | } |
294 | 307 | ||
@@ -302,12 +315,18 @@ bool OPimAccessTemplate<T>::add( const OPimRecord& rec ) { | |||
302 | } else { | 315 | } else { |
303 | owarn << "Adding not possible: Objecttype mismatch" << oendl; | 316 | owarn << "Adding not possible: Objecttype mismatch" << oendl; |
304 | } | 317 | } |
305 | return false; | 318 | return false; |
306 | } | 319 | } |
307 | 320 | ||
321 | /** | ||
322 | * Add an Opie PimRecord. | ||
323 | * Info: Take this if you are working with OPimRecords and you need to add it into any database. | ||
324 | * But take care that the accessing database is compatible to the real type of OPimRecord !! | ||
325 | * Otherwise this access will be rejected ! | ||
326 | */ | ||
308 | template <class T> | 327 | template <class T> |
309 | bool OPimAccessTemplate<T>::add( const OPimRecord* rec) { | 328 | bool OPimAccessTemplate<T>::add( const OPimRecord* rec) { |
310 | /* same type, but pointer */ | 329 | /* same type, but pointer */ |
311 | T tempInstance; | 330 | T tempInstance; |
312 | if ( rec -> rtti() == tempInstance.rtti() ) { | 331 | if ( rec -> rtti() == tempInstance.rtti() ) { |
313 | const T* t = static_cast<const T*>(rec); | 332 | const T* t = static_cast<const T*>(rec); |
@@ -315,38 +334,65 @@ bool OPimAccessTemplate<T>::add( const OPimRecord* rec) { | |||
315 | } else { | 334 | } else { |
316 | owarn << "Adding not possible: Objecttype mismatch" << oendl; | 335 | owarn << "Adding not possible: Objecttype mismatch" << oendl; |
317 | } | 336 | } |
318 | return false; | 337 | return false; |
319 | } | 338 | } |
320 | 339 | ||
340 | /** | ||
341 | * remove T from the backend | ||
342 | * @param t The item to remove | ||
343 | * @return <i>true</i> if successful. | ||
344 | */ | ||
321 | template <class T> | 345 | template <class T> |
322 | bool OPimAccessTemplate<T>::remove( const T& t ) { | 346 | bool OPimAccessTemplate<T>::remove( const T& t ) { |
323 | return remove( t.uid() ); | 347 | return remove( t.uid() ); |
324 | } | 348 | } |
349 | |||
350 | /** | ||
351 | * remove the OPimRecord with uid | ||
352 | * @param uid The ID of the item to remove | ||
353 | * @return <i>true</i> if successful. | ||
354 | */ | ||
325 | template <class T> | 355 | template <class T> |
326 | bool OPimAccessTemplate<T>::remove( int uid ) { | 356 | bool OPimAccessTemplate<T>::remove( UID uid ) { |
327 | m_cache.remove( uid ); | 357 | m_cache.remove( uid ); |
328 | return m_backEnd->remove( uid ); | 358 | return m_backEnd->remove( uid ); |
329 | } | 359 | } |
330 | template <class T> | 360 | template <class T> |
331 | bool OPimAccessTemplate<T>::remove( const OPimRecord& rec) { | 361 | bool OPimAccessTemplate<T>::remove( const OPimRecord& rec) { |
332 | return remove( rec.uid() ); | 362 | return remove( rec.uid() ); |
333 | } | 363 | } |
364 | |||
365 | /** | ||
366 | * replace T from backend | ||
367 | * @param t The item to replace | ||
368 | * @return <i>true</i> if successful. | ||
369 | */ | ||
334 | template <class T> | 370 | template <class T> |
335 | bool OPimAccessTemplate<T>::replace( const T& t ) { | 371 | bool OPimAccessTemplate<T>::replace( const T& t ) { |
336 | m_cache.replace( t ); | 372 | m_cache.replace( t ); |
337 | return m_backEnd->replace( t ); | 373 | return m_backEnd->replace( t ); |
338 | } | 374 | } |
375 | |||
376 | /** | ||
377 | * @internal | ||
378 | */ | ||
339 | template <class T> | 379 | template <class T> |
340 | void OPimAccessTemplate<T>::invalidateCache() { | 380 | void OPimAccessTemplate<T>::invalidateCache() { |
341 | m_cache.invalidate(); | 381 | m_cache.invalidate(); |
342 | } | 382 | } |
343 | template <class T> | 383 | template <class T> |
344 | typename OPimAccessTemplate<T>::BackEnd* OPimAccessTemplate<T>::backEnd() { | 384 | typename OPimAccessTemplate<T>::BackEnd* OPimAccessTemplate<T>::backEnd() { |
345 | return m_backEnd; | 385 | return m_backEnd; |
346 | } | 386 | } |
387 | |||
388 | /** | ||
389 | * if the resource was changed externally | ||
390 | * You should use the signal handling instead of polling possible changes ! | ||
391 | * zecke: Do you implement a signal for otodoaccess ? | ||
392 | */ | ||
347 | template <class T> | 393 | template <class T> |
348 | bool OPimAccessTemplate<T>::wasChangedExternally()const { | 394 | bool OPimAccessTemplate<T>::wasChangedExternally()const { |
349 | return false; | 395 | return false; |
350 | } | 396 | } |
351 | template <class T> | 397 | template <class T> |
352 | void OPimAccessTemplate<T>::setBackEnd( BackEnd* end ) { | 398 | void OPimAccessTemplate<T>::setBackEnd( BackEnd* end ) { |
@@ -365,9 +411,112 @@ void OPimAccessTemplate<T>::setSaneCacheSize( int size ) { | |||
365 | } | 411 | } |
366 | template <class T> | 412 | template <class T> |
367 | void OPimAccessTemplate<T>::setReadAhead( uint count ) { | 413 | void OPimAccessTemplate<T>::setReadAhead( uint count ) { |
368 | m_backEnd->setReadAhead( count ); | 414 | m_backEnd->setReadAhead( count ); |
369 | } | 415 | } |
370 | 416 | ||
417 | |||
418 | template <class T> | ||
419 | typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::sorted( const OPimAccessTemplate::List& lst, | ||
420 | bool ascending, int sortOrder, | ||
421 | int sortFilter, int cat )const { | ||
422 | QArray<int> cats( 1 ); | ||
423 | cats[0] = cat; | ||
424 | UIDArray ints = m_backEnd->sorted( lst.uids(), ascending, sortOrder, | ||
425 | sortFilter, cats ); | ||
426 | return List(ints, this); | ||
427 | } | ||
428 | |||
429 | template<class T> | ||
430 | typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::sorted( const OPimAccessTemplate::List& lst, | ||
431 | bool ascending, int sortOrder, | ||
432 | int sortFilter, const QArray<UID>& cats )const { | ||
433 | UIDArray ints = m_backEnd->sorted( lst.uids(), ascending, sortOrder, | ||
434 | sortFilter, cats ); | ||
435 | return List(ints, this); | ||
436 | } | ||
437 | |||
438 | template<class T> | ||
439 | typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::sorted( bool ascending, int sortOrder, | ||
440 | int sortFilter, int cat )const { | ||
441 | QArray<int> cats( 1 ); | ||
442 | cats[0] = cat; | ||
443 | UIDArray ints = m_backEnd->sorted( ascending, sortOrder, | ||
444 | sortFilter, cats ); | ||
445 | return List(ints, this); | ||
446 | } | ||
447 | |||
448 | template<class T> | ||
449 | typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::sorted( bool ascending, int sortOrder, | ||
450 | int sortFilter, const QArray<UID>& cats )const { | ||
451 | UIDArray ints = m_backEnd->sorted( ascending, sortOrder, | ||
452 | sortFilter, cats ); | ||
453 | return List(ints, this); | ||
454 | } | ||
455 | |||
456 | template <class T> | ||
457 | OPimOccurrence::List OPimAccessTemplate<T>::occurrences( const QDate& start, | ||
458 | const QDate& end ) const { | ||
459 | /* | ||
460 | * Some magic involved to go from single OPimBackendOccurrence | ||
461 | * to multiple OPimOccurrence's | ||
462 | */ | ||
463 | return OPimBase::convertOccurrenceFromBackend( m_backEnd->occurrences( start, end ) ); | ||
464 | } | ||
465 | |||
466 | template<class T> | ||
467 | OPimOccurrence::List OPimAccessTemplate<T>::occurrences( const QDateTime& dt )const { | ||
468 | return OPimBase::convertOccurrenceFromBackend( m_backEnd->occurrences( dt ) ); | ||
469 | } | ||
470 | |||
471 | /* | ||
472 | *Implementations!! | ||
473 | */ | ||
474 | template <class T> | ||
475 | UIDArray OPimAccessTemplate<T>::matchRegexpSimple( const QRegExp &r )const { | ||
476 | return m_backEnd->matchRegexp( r ); | ||
477 | } | ||
478 | |||
479 | template <class T> | ||
480 | UIDArray OPimAccessTemplate<T>::queryByExampleSimple( const OPimRecord* rec, | ||
481 | int settings, | ||
482 | const QDateTime& d )const { | ||
483 | return m_backEnd->queryByExample( rec, settings, d ); | ||
484 | } | ||
485 | |||
486 | template <class T> | ||
487 | UIDArray OPimAccessTemplate<T>::sortedSimple( const UIDArray& lst, | ||
488 | bool ascending, | ||
489 | int sortOrder, int sortFilter, | ||
490 | int cat ) const{ | ||
491 | QArray<int> cats( 1 ); | ||
492 | cats[0] = cat; | ||
493 | return m_backEnd->sorted( lst, ascending, sortOrder, sortFilter, cats ); | ||
494 | } | ||
495 | |||
496 | template <class T> | ||
497 | UIDArray OPimAccessTemplate<T>::sortedSimple( const UIDArray& lst, | ||
498 | bool ascending, | ||
499 | int sortOrder, int sortFilter, | ||
500 | const QArray<int>& cats ) const{ | ||
501 | return m_backEnd->sorted( lst, ascending, sortOrder, sortFilter, cats ); | ||
502 | } | ||
503 | |||
504 | template <class T> | ||
505 | UIDArray OPimAccessTemplate<T>::sortedSimple( bool ascending, | ||
506 | int sortOrder, int sortFilter, | ||
507 | int cat ) const{ | ||
508 | QArray<int> cats( 1 ); | ||
509 | cats[0] = cat; | ||
510 | |||
511 | return m_backEnd->sorted( ascending, sortOrder, sortFilter, cats ); | ||
512 | } | ||
513 | |||
514 | template <class T> | ||
515 | UIDArray OPimAccessTemplate<T>::sortedSimple( bool ascending, | ||
516 | int sortOrder, int sortFilter, | ||
517 | const QArray<int>& cats ) const{ | ||
518 | return m_backEnd->sorted( ascending, sortOrder, sortFilter, cats ); | ||
519 | } | ||
371 | } | 520 | } |
372 | 521 | ||
373 | #endif | 522 | #endif |