summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/orecordlist.h
Unidiff
Diffstat (limited to 'libopie2/opiepim/orecordlist.h') (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opiepim/orecordlist.h142
1 files changed, 104 insertions, 38 deletions
diff --git a/libopie2/opiepim/orecordlist.h b/libopie2/opiepim/orecordlist.h
index 8f0011b..1742dcc 100644
--- a/libopie2/opiepim/orecordlist.h
+++ b/libopie2/opiepim/orecordlist.h
@@ -29,7 +29,6 @@
29 29
30#ifndef OPIE_RECORD_LIST_H 30#ifndef ORECORDLIST_H
31#define OPIE_RECORD_LIST_H 31#define ORECORDLIST_H
32
33#include <qarray.h>
34 32
33/* OPIE */
35#include <opie2/otemplatebase.h> 34#include <opie2/otemplatebase.h>
@@ -37,3 +36,7 @@
37 36
38namespace Opie { 37/* QT */
38#include <qarray.h>
39
40namespace Opie
41{
39 42
@@ -49,4 +52,6 @@ template <class T> class ORecordList;
49template <class T = OPimRecord> 52template <class T = OPimRecord>
50class ORecordListIterator { 53class ORecordListIterator
54{
51 friend class ORecordList<T>; 55 friend class ORecordList<T>;
56
52public: 57public:
@@ -107,2 +112,3 @@ private:
107 112
113
108class ORecordListPrivate; 114class ORecordListPrivate;
@@ -113,3 +119,4 @@ class ORecordListPrivate;
113template <class T = OPimRecord > 119template <class T = OPimRecord >
114class ORecordList { 120class ORecordList
121{
115public: 122public:
@@ -121,4 +128,4 @@ public:
121 */ 128 */
122 ORecordList () { 129 ORecordList ()
123 } 130 {}
124ORecordList( const QArray<int>& ids, 131ORecordList( const QArray<int>& ids,
@@ -160,5 +167,7 @@ private:
160 167
168
161/* ok now implement it */ 169/* ok now implement it */
162template <class T> 170template <class T>
163ORecordListIterator<T>::ORecordListIterator() { 171ORecordListIterator<T>::ORecordListIterator()
172{
164 m_current = 0; 173 m_current = 0;
@@ -170,4 +179,7 @@ ORecordListIterator<T>::ORecordListIterator() {
170} 179}
180
181
171template <class T> 182template <class T>
172ORecordListIterator<T>::~ORecordListIterator() { 183ORecordListIterator<T>::~ORecordListIterator()
184{
173/* nothing to delete */ 185/* nothing to delete */
@@ -175,4 +187,6 @@ ORecordListIterator<T>::~ORecordListIterator() {
175 187
188
176template <class T> 189template <class T>
177ORecordListIterator<T>::ORecordListIterator( const ORecordListIterator<T>& it) { 190ORecordListIterator<T>::ORecordListIterator( const ORecordListIterator<T>& it )
191{
178// qWarning("ORecordListIterator copy c'tor"); 192// qWarning("ORecordListIterator copy c'tor");
@@ -186,4 +200,6 @@ ORecordListIterator<T>::ORecordListIterator( const ORecordListIterator<T>& it) {
186 200
201
187template <class T> 202template <class T>
188ORecordListIterator<T> &ORecordListIterator<T>::operator=( const ORecordListIterator<T>& it) { 203ORecordListIterator<T> &ORecordListIterator<T>::operator=( const ORecordListIterator<T>& it )
204{
189 m_uids = it.m_uids; 205 m_uids = it.m_uids;
@@ -197,4 +213,6 @@ ORecordListIterator<T> &ORecordListIterator<T>::operator=( const ORecordListIter
197 213
214
198template <class T> 215template <class T>
199T ORecordListIterator<T>::operator*() { 216T ORecordListIterator<T>::operator*()
217{
200 //qWarning("operator* %d %d", m_current, m_uids[m_current] ); 218 //qWarning("operator* %d %d", m_current, m_uids[m_current] );
@@ -210,9 +228,13 @@ T ORecordListIterator<T>::operator*() {
210 228
229
211template <class T> 230template <class T>
212ORecordListIterator<T> &ORecordListIterator<T>::operator++() { 231ORecordListIterator<T> &ORecordListIterator<T>::operator++()
232{
213 m_direction = true; 233 m_direction = true;
214 if (m_current < m_uids.count() ) { 234 if ( m_current < m_uids.count() )
235 {
215 m_end = false; 236 m_end = false;
216 ++m_current; 237 ++m_current;
217 }else 238 }
239 else
218 m_end = true; 240 m_end = true;
@@ -221,9 +243,14 @@ ORecordListIterator<T> &ORecordListIterator<T>::operator++() {
221} 243}
244
245
222template <class T> 246template <class T>
223ORecordListIterator<T> &ORecordListIterator<T>::operator--() { 247ORecordListIterator<T> &ORecordListIterator<T>::operator--()
248{
224 m_direction = false; 249 m_direction = false;
225 if ( m_current > 0 ) { 250 if ( m_current > 0 )
251 {
226 --m_current; 252 --m_current;
227 m_end = false; 253 m_end = false;
228 } else 254 }
255 else
229 m_end = true; 256 m_end = true;
@@ -233,4 +260,6 @@ ORecordListIterator<T> &ORecordListIterator<T>::operator--() {
233 260
261
234template <class T> 262template <class T>
235bool ORecordListIterator<T>::operator==( const ORecordListIterator<T>& it ) { 263bool ORecordListIterator<T>::operator==( const ORecordListIterator<T>& it )
264{
236 265
@@ -245,6 +274,11 @@ bool ORecordListIterator<T>::operator==( const ORecordListIterator<T>& it ) {
245} 274}
275
276
246template <class T> 277template <class T>
247bool ORecordListIterator<T>::operator!=( const ORecordListIterator<T>& it ) { 278bool ORecordListIterator<T>::operator!=( const ORecordListIterator<T>& it )
279{
248 return !(*this == it ); 280 return !(*this == it );
249} 281}
282
283
250template <class T> 284template <class T>
@@ -259,9 +293,16 @@ ORecordListIterator<T>::ORecordListIterator( const QArray<int> uids,
259} 293}
294
295
260template <class T> 296template <class T>
261uint ORecordListIterator<T>::current()const { 297uint ORecordListIterator<T>::current() const
298{
262 return m_current; 299 return m_current;
263} 300}
301
302
264template <class T> 303template <class T>
265void ORecordListIterator<T>::setCurrent( uint cur ) { 304void ORecordListIterator<T>::setCurrent( uint cur )
266 if( cur < m_uids.count() ) { 305{
306 if ( cur < m_uids.count() )
307 {
267 m_end = false; 308 m_end = false;
@@ -271,5 +312,8 @@ void ORecordListIterator<T>::setCurrent( uint cur ) {
271template <class T> 312template <class T>
272uint ORecordListIterator<T>::count()const { 313uint ORecordListIterator<T>::count() const
314{
273 return m_uids.count(); 315 return m_uids.count();
274} 316}
317
318
275template <class T> 319template <class T>
@@ -278,10 +322,15 @@ ORecordList<T>::ORecordList( const QArray<int>& ids,
278 : m_ids( ids ), m_acc( acc ) 322 : m_ids( ids ), m_acc( acc )
279{ 323{}
280} 324
325
281template <class T> 326template <class T>
282ORecordList<T>::~ORecordList() { 327ORecordList<T>::~ORecordList()
328{
283/* nothing to do here */ 329/* nothing to do here */
284} 330}
331
332
285template <class T> 333template <class T>
286typename ORecordList<T>::Iterator ORecordList<T>::begin() { 334typename ORecordList<T>::Iterator ORecordList<T>::begin()
335{
287 Iterator it( m_ids, m_acc ); 336 Iterator it( m_ids, m_acc );
@@ -289,4 +338,7 @@ typename ORecordList<T>::Iterator ORecordList<T>::begin() {
289} 338}
339
340
290template <class T> 341template <class T>
291typename ORecordList<T>::Iterator ORecordList<T>::end() { 342typename ORecordList<T>::Iterator ORecordList<T>::end()
343{
292 Iterator it( m_ids, m_acc ); 344 Iterator it( m_ids, m_acc );
@@ -297,8 +349,14 @@ typename ORecordList<T>::Iterator ORecordList<T>::end() {
297} 349}
350
351
298template <class T> 352template <class T>
299uint ORecordList<T>::count()const { 353uint ORecordList<T>::count() const
354{
300return m_ids.count(); 355return m_ids.count();
301} 356}
357
358
302template <class T> 359template <class T>
303T ORecordList<T>::operator[]( uint i ) { 360T ORecordList<T>::operator[] ( uint i )
361{
304 if ( i >= m_ids.count() ) 362 if ( i >= m_ids.count() )
@@ -308,4 +366,7 @@ T ORecordList<T>::operator[]( uint i ) {
308} 366}
367
368
309template <class T> 369template <class T>
310int ORecordList<T>::uidAt( uint i ) { 370int ORecordList<T>::uidAt( uint i )
371{
311 return m_ids[i]; 372 return m_ids[i];
@@ -313,4 +374,6 @@ int ORecordList<T>::uidAt( uint i ) {
313 374
375
314template <class T> 376template <class T>
315bool ORecordList<T>::remove( int uid ) { 377bool ORecordList<T>::remove( int uid )
378{
316 QArray<int> copy( m_ids.count() ); 379 QArray<int> copy( m_ids.count() );
@@ -319,7 +382,10 @@ bool ORecordList<T>::remove( int uid ) {
319 382
320 for (uint i = 0; i < m_ids.count(); i++){ 383 for ( uint i = 0; i < m_ids.count(); i++ )
321 if ( m_ids[i] != uid ){ 384 {
385 if ( m_ids[ i ] != uid )
386 {
322 copy[counter++] = m_ids[i]; 387 copy[counter++] = m_ids[i];
323 388
324 }else 389 }
390 else
325 ret_val = true; 391 ret_val = true;