-rw-r--r-- | libopie/pim/orecordlist.h | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/libopie/pim/orecordlist.h b/libopie/pim/orecordlist.h index 3b30a73..75bb33c 100644 --- a/libopie/pim/orecordlist.h +++ b/libopie/pim/orecordlist.h | |||
@@ -14,28 +14,30 @@ | |||
14 | * for(it = list.begin(); it != list.end(); ++it ) | 14 | * for(it = list.begin(); it != list.end(); ++it ) |
15 | * doSomeCoolStuff( (*it) ); | 15 | * doSomeCoolStuff( (*it) ); |
16 | */ | 16 | */ |
17 | template <class T> class ORecordList; | ||
17 | template <class T = OPimRecord> | 18 | template <class T = OPimRecord> |
18 | class ORecordListIterator { | 19 | class ORecordListIterator { |
20 | friend class ORecordList<T>; | ||
19 | public: | 21 | public: |
20 | typedef OTemplateBase<T> Base; | 22 | typedef OTemplateBase<T> Base; |
21 | 23 | ||
22 | /** | 24 | /** |
23 | * The c'tor used internally from | 25 | * The c'tor used internally from |
24 | * ORecordList | 26 | * ORecordList |
25 | */ | 27 | */ |
26 | ORecordListIterator( const QArray<int>, const Base* ); | 28 | ORecordListIterator( const QArray<int>, const Base* ); |
27 | 29 | ||
28 | /** | 30 | /** |
29 | * The standard c'tor | 31 | * The standard c'tor |
30 | */ | 32 | */ |
31 | ORecordListIterator(); | 33 | ORecordListIterator(); |
32 | ~ORecordListIterator(); | 34 | ~ORecordListIterator(); |
33 | 35 | ||
34 | ORecordListIterator( const ORecordListIterator& ); | 36 | ORecordListIterator( const ORecordListIterator& ); |
35 | ORecordListIterator &operator=(const ORecordListIterator& ); | 37 | ORecordListIterator &operator=(const ORecordListIterator& ); |
36 | 38 | ||
37 | /** | 39 | /** |
38 | * a * operator ;) | 40 | * a * operator ;) |
39 | * use it like this T = (*it); | 41 | * use it like this T = (*it); |
40 | */ | 42 | */ |
41 | T &operator*(); | 43 | T &operator*(); |
@@ -59,25 +61,25 @@ private: | |||
59 | /** | 61 | /** |
60 | * The recordlist used as a return type | 62 | * The recordlist used as a return type |
61 | * from OPimAccessTemplate | 63 | * from OPimAccessTemplate |
62 | */ | 64 | */ |
63 | template <class T = OPimRecord > | 65 | template <class T = OPimRecord > |
64 | class ORecordList { | 66 | class ORecordList { |
65 | public: | 67 | public: |
66 | typedef OTemplateBase<T> Base; | 68 | typedef OTemplateBase<T> Base; |
67 | typedef ORecordListIterator<T> Iterator; | 69 | typedef ORecordListIterator<T> Iterator; |
68 | 70 | ||
69 | /** | 71 | /** |
70 | * c'tor | 72 | * c'tor |
71 | */ | 73 | */ |
72 | ORecordList( const QArray<int>& ids, | 74 | ORecordList( const QArray<int>& ids, |
73 | const Base* ); | 75 | const Base* ); |
74 | ~ORecordList(); | 76 | ~ORecordList(); |
75 | 77 | ||
76 | /** | 78 | /** |
77 | * the first iterator | 79 | * the first iterator |
78 | */ | 80 | */ |
79 | Iterator begin(); | 81 | Iterator begin(); |
80 | 82 | ||
81 | /** | 83 | /** |
82 | * the end | 84 | * the end |
83 | */ | 85 | */ |
@@ -105,6 +107,7 @@ ORecordListIterator<T>::~ORecordListIterator() { | |||
105 | 107 | ||
106 | template <class T> | 108 | template <class T> |
107 | ORecordListIterator<T>::ORecordListIterator( const ORecordListIterator<T>& it) { | 109 | ORecordListIterator<T>::ORecordListIterator( const ORecordListIterator<T>& it) { |
110 | qWarning("ORecordListIterator"); | ||
108 | m_uids = it.m_uids; | 111 | m_uids = it.m_uids; |
109 | m_current = it.m_current; | 112 | m_current = it.m_current; |
110 | m_temp = it.m_temp; | 113 | m_temp = it.m_temp; |
@@ -125,6 +128,7 @@ ORecordListIterator<T> &ORecordListIterator<T>::operator=( const ORecordListIter | |||
125 | 128 | ||
126 | template <class T> | 129 | template <class T> |
127 | T &ORecordListIterator<T>::operator*() { | 130 | T &ORecordListIterator<T>::operator*() { |
131 | qWarning("operator* %d %d", m_current, m_uids[m_current] ); | ||
128 | if (!m_end ) | 132 | if (!m_end ) |
129 | m_record = m_temp->find( m_uids[m_current] ); | 133 | m_record = m_temp->find( m_uids[m_current] ); |
130 | else | 134 | else |
@@ -135,7 +139,7 @@ T &ORecordListIterator<T>::operator*() { | |||
135 | 139 | ||
136 | template <class T> | 140 | template <class T> |
137 | ORecordListIterator<T> &ORecordListIterator<T>::operator++() { | 141 | ORecordListIterator<T> &ORecordListIterator<T>::operator++() { |
138 | if (m_current < m_uids.count() ) { | 142 | if (m_current < (int)m_uids.count() ) { |
139 | m_end = false; | 143 | m_end = false; |
140 | ++m_current; | 144 | ++m_current; |
141 | }else | 145 | }else |
@@ -189,6 +193,7 @@ ORecordList<T>::~ORecordList() { | |||
189 | } | 193 | } |
190 | template <class T> | 194 | template <class T> |
191 | ORecordList<T>::Iterator ORecordList<T>::begin() { | 195 | ORecordList<T>::Iterator ORecordList<T>::begin() { |
196 | qWarning("ORecordList::begin"); | ||
192 | Iterator it( m_ids, m_acc ); | 197 | Iterator it( m_ids, m_acc ); |
193 | return it; | 198 | return it; |
194 | } | 199 | } |
@@ -197,5 +202,7 @@ ORecordList<T>::Iterator ORecordList<T>::end() { | |||
197 | Iterator it( m_ids, m_acc ); | 202 | Iterator it( m_ids, m_acc ); |
198 | it.m_end = true; | 203 | it.m_end = true; |
199 | it.m_current = m_ids.count(); | 204 | it.m_current = m_ids.count(); |
205 | |||
206 | return it; | ||
200 | } | 207 | } |
201 | #endif | 208 | #endif |