Diffstat (limited to 'libopie2/opiepim/orecordlist.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiepim/orecordlist.h | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/libopie2/opiepim/orecordlist.h b/libopie2/opiepim/orecordlist.h index 5211f57..8f0011b 100644 --- a/libopie2/opiepim/orecordlist.h +++ b/libopie2/opiepim/orecordlist.h | |||
@@ -1,32 +1,62 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | Copyright (C) The Main Author <main-author@whereever.org> | ||
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | ||
5 | .=l. | ||
6 | .>+-= | ||
7 | _;:, .> :=|. This program is free software; you can | ||
8 | .> <`_, > . <= redistribute it and/or modify it under | ||
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
10 | .="- .-=="i, .._ License as published by the Free Software | ||
11 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
12 | ._= =} : or (at your option) any later version. | ||
13 | .%`+i> _;_. | ||
14 | .i_,=:_. -<s. This program is distributed in the hope that | ||
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
16 | : .. .:, . . . without even the implied warranty of | ||
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
19 | ..}^=.= = ; Library General Public License for more | ||
20 | ++= -. .` .: details. | ||
21 | : = ...= . :.=- | ||
22 | -. .:....=;==+<; You should have received a copy of the GNU | ||
23 | -_. . . )=. = Library General Public License along with | ||
24 | -- :-=` this library; see the file COPYING.LIB. | ||
25 | If not, write to the Free Software Foundation, | ||
26 | Inc., 59 Temple Place - Suite 330, | ||
27 | Boston, MA 02111-1307, USA. | ||
28 | */ | ||
1 | 29 | ||
2 | #ifndef OPIE_RECORD_LIST_H | 30 | #ifndef OPIE_RECORD_LIST_H |
3 | #define OPIE_RECORD_LIST_H | 31 | #define OPIE_RECORD_LIST_H |
4 | 32 | ||
5 | #include <qarray.h> | 33 | #include <qarray.h> |
6 | 34 | ||
7 | #include "otemplatebase.h" | 35 | #include <opie2/otemplatebase.h> |
8 | #include "opimrecord.h" | 36 | #include <opie2/opimrecord.h> |
37 | |||
38 | namespace Opie { | ||
9 | 39 | ||
10 | class ORecordListIteratorPrivate; | 40 | class ORecordListIteratorPrivate; |
11 | /** | 41 | /** |
12 | * Our List Iterator | 42 | * Our List Iterator |
13 | * it behaves like STL or Qt | 43 | * it behaves like STL or Qt |
14 | * | 44 | * |
15 | * for(it = list.begin(); it != list.end(); ++it ) | 45 | * for(it = list.begin(); it != list.end(); ++it ) |
16 | * doSomeCoolStuff( (*it) ); | 46 | * doSomeCoolStuff( (*it) ); |
17 | */ | 47 | */ |
18 | template <class T> class ORecordList; | 48 | template <class T> class ORecordList; |
19 | template <class T = OPimRecord> | 49 | template <class T = OPimRecord> |
20 | class ORecordListIterator { | 50 | class ORecordListIterator { |
21 | friend class ORecordList<T>; | 51 | friend class ORecordList<T>; |
22 | public: | 52 | public: |
23 | typedef OTemplateBase<T> Base; | 53 | typedef OTemplateBase<T> Base; |
24 | 54 | ||
25 | /** | 55 | /** |
26 | * The c'tor used internally from | 56 | * The c'tor used internally from |
27 | * ORecordList | 57 | * ORecordList |
28 | */ | 58 | */ |
29 | ORecordListIterator( const QArray<int>, const Base* ); | 59 | ORecordListIterator( const QArray<int>, const Base* ); |
30 | 60 | ||
31 | /** | 61 | /** |
32 | * The standard c'tor | 62 | * The standard c'tor |
@@ -281,26 +311,26 @@ int ORecordList<T>::uidAt( uint i ) { | |||
281 | return m_ids[i]; | 311 | return m_ids[i]; |
282 | } | 312 | } |
283 | 313 | ||
284 | template <class T> | 314 | template <class T> |
285 | bool ORecordList<T>::remove( int uid ) { | 315 | bool ORecordList<T>::remove( int uid ) { |
286 | QArray<int> copy( m_ids.count() ); | 316 | QArray<int> copy( m_ids.count() ); |
287 | int counter = 0; | 317 | int counter = 0; |
288 | bool ret_val = false; | 318 | bool ret_val = false; |
289 | 319 | ||
290 | for (uint i = 0; i < m_ids.count(); i++){ | 320 | for (uint i = 0; i < m_ids.count(); i++){ |
291 | if ( m_ids[i] != uid ){ | 321 | if ( m_ids[i] != uid ){ |
292 | copy[counter++] = m_ids[i]; | 322 | copy[counter++] = m_ids[i]; |
293 | 323 | ||
294 | }else | 324 | }else |
295 | ret_val = true; | 325 | ret_val = true; |
296 | } | 326 | } |
297 | 327 | ||
298 | copy.resize( counter ); | 328 | copy.resize( counter ); |
299 | m_ids = copy; | 329 | m_ids = copy; |
300 | 330 | ||
301 | 331 | ||
302 | return ret_val; | 332 | return ret_val; |
303 | } | 333 | } |
304 | 334 | ||
305 | 335 | } | |
306 | #endif | 336 | #endif |