summaryrefslogtreecommitdiff
path: root/libopie/pim/orecordlist.h
Unidiff
Diffstat (limited to 'libopie/pim/orecordlist.h') (more/less context) (show whitespace changes)
-rw-r--r--libopie/pim/orecordlist.h20
1 files changed, 13 insertions, 7 deletions
diff --git a/libopie/pim/orecordlist.h b/libopie/pim/orecordlist.h
index b6fa7fa..08f5c85 100644
--- a/libopie/pim/orecordlist.h
+++ b/libopie/pim/orecordlist.h
@@ -59,24 +59,25 @@ public:
59 59
60 /** 60 /**
61 * sets the current item 61 * sets the current item
62 */ 62 */
63 void setCurrent( uint cur ); 63 void setCurrent( uint cur );
64 64
65private: 65private:
66 QArray<int> m_uids; 66 QArray<int> m_uids;
67 uint m_current; 67 uint m_current;
68 const Base* m_temp; 68 const Base* m_temp;
69 bool m_end : 1; 69 bool m_end : 1;
70 T m_record; 70 T m_record;
71 bool m_direction :1;
71 72
72 /* d pointer for future versions */ 73 /* d pointer for future versions */
73 class IteratorPrivate; 74 class IteratorPrivate;
74 IteratorPrivate *d; 75 IteratorPrivate *d;
75}; 76};
76/** 77/**
77 * The recordlist used as a return type 78 * The recordlist used as a return type
78 * from OPimAccessTemplate 79 * from OPimAccessTemplate
79 */ 80 */
80template <class T = OPimRecord > 81template <class T = OPimRecord >
81class ORecordList { 82class ORecordList {
82public: 83public:
@@ -116,78 +117,81 @@ public:
116private: 117private:
117 QArray<int> m_ids; 118 QArray<int> m_ids;
118 const Base* m_acc; 119 const Base* m_acc;
119}; 120};
120 121
121/* ok now implement it */ 122/* ok now implement it */
122template <class T> 123template <class T>
123ORecordListIterator<T>::ORecordListIterator() { 124ORecordListIterator<T>::ORecordListIterator() {
124 m_current = 0; 125 m_current = 0;
125 m_temp = 0l; 126 m_temp = 0l;
126 m_end = true; 127 m_end = true;
127 m_record = T(); 128 m_record = T();
129 /* forward */
130 m_direction = TRUE;
128} 131}
129template <class T> 132template <class T>
130ORecordListIterator<T>::~ORecordListIterator() { 133ORecordListIterator<T>::~ORecordListIterator() {
131/* nothing to delete */ 134/* nothing to delete */
132} 135}
133 136
134template <class T> 137template <class T>
135ORecordListIterator<T>::ORecordListIterator( const ORecordListIterator<T>& it) { 138ORecordListIterator<T>::ORecordListIterator( const ORecordListIterator<T>& it) {
136// qWarning("ORecordListIterator copy c'tor"); 139// qWarning("ORecordListIterator copy c'tor");
137 m_uids = it.m_uids; 140 m_uids = it.m_uids;
138 m_current = it.m_current; 141 m_current = it.m_current;
139 m_temp = it.m_temp; 142 m_temp = it.m_temp;
140 m_end = it.m_end; 143 m_end = it.m_end;
141 m_record = it.m_record; 144 m_record = it.m_record;
145 m_direction = it.m_direction;
142} 146}
143 147
144template <class T> 148template <class T>
145ORecordListIterator<T> &ORecordListIterator<T>::operator=( const ORecordListIterator<T>& it) { 149ORecordListIterator<T> &ORecordListIterator<T>::operator=( const ORecordListIterator<T>& it) {
146 m_uids = it.m_uids; 150 m_uids = it.m_uids;
147 m_current = it.m_current; 151 m_current = it.m_current;
148 m_temp = it.m_temp; 152 m_temp = it.m_temp;
149 m_end = it.m_end; 153 m_end = it.m_end;
150 m_record = it.m_record; 154 m_record = it.m_record;
151 155
152 return *this; 156 return *this;
153} 157}
154 158
155template <class T> 159template <class T>
156T ORecordListIterator<T>::operator*() { 160T ORecordListIterator<T>::operator*() {
157 qWarning("operator* %d %d", m_current, m_uids[m_current] ); 161 qWarning("operator* %d %d", m_current, m_uids[m_current] );
158 if (!m_end ) 162 if (!m_end )
159 /* FIXME 163 m_record = m_temp->find( m_uids[m_current], m_uids, m_current,
160 * until the cache is in place 164 m_direction ? Base::Forward :
161 * we do the uid match uid check 165 Base::Reverse );
162 */
163 m_record = m_temp->find( m_uids[m_current] );
164 else 166 else
165 m_record = T(); 167 m_record = T();
166 168
167 return m_record; 169 return m_record;
168} 170}
169 171
170template <class T> 172template <class T>
171ORecordListIterator<T> &ORecordListIterator<T>::operator++() { 173ORecordListIterator<T> &ORecordListIterator<T>::operator++() {
174 m_direction = true;
172 if (m_current < m_uids.count() ) { 175 if (m_current < m_uids.count() ) {
173 m_end = false; 176 m_end = false;
174 ++m_current; 177 ++m_current;
175 }else 178 }else
176 m_end = true; 179 m_end = true;
177 180
178 return *this; 181 return *this;
179} 182}
180template <class T> 183template <class T>
181ORecordListIterator<T> &ORecordListIterator<T>::operator--() { 184ORecordListIterator<T> &ORecordListIterator<T>::operator--() {
185 m_direction = false;
182 if ( m_current > 0 ) { 186 if ( m_current > 0 ) {
183 --m_current; 187 --m_current;
184 m_end = false; 188 m_end = false;
185 } else 189 } else
186 m_end = true; 190 m_end = true;
187 191
188 return *this; 192 return *this;
189} 193}
190 194
191template <class T> 195template <class T>
192bool ORecordListIterator<T>::operator==( const ORecordListIterator<T>& it ) { 196bool ORecordListIterator<T>::operator==( const ORecordListIterator<T>& it ) {
193 197
@@ -198,25 +202,26 @@ bool ORecordListIterator<T>::operator==( const ORecordListIterator<T>& it ) {
198 if ( m_current != it.m_current ) return false; 202 if ( m_current != it.m_current ) return false;
199 if ( m_temp != it.m_temp ) return false; 203 if ( m_temp != it.m_temp ) return false;
200 204
201 return true; 205 return true;
202} 206}
203template <class T> 207template <class T>
204bool ORecordListIterator<T>::operator!=( const ORecordListIterator<T>& it ) { 208bool ORecordListIterator<T>::operator!=( const ORecordListIterator<T>& it ) {
205 return !(*this == it ); 209 return !(*this == it );
206} 210}
207template <class T> 211template <class T>
208ORecordListIterator<T>::ORecordListIterator( const QArray<int> uids, 212ORecordListIterator<T>::ORecordListIterator( const QArray<int> uids,
209 const Base* t ) 213 const Base* t )
210 : m_uids( uids ), m_current( 0 ), m_temp( t ), m_end( false ) 214 : m_uids( uids ), m_current( 0 ), m_temp( t ), m_end( false ),
215 m_direction( false )
211{ 216{
212} 217}
213template <class T> 218template <class T>
214uint ORecordListIterator<T>::current()const { 219uint ORecordListIterator<T>::current()const {
215 return m_current; 220 return m_current;
216} 221}
217template <class T> 222template <class T>
218void ORecordListIterator<T>::setCurrent( uint cur ) { 223void ORecordListIterator<T>::setCurrent( uint cur ) {
219 if( cur < m_uids.count() ) { 224 if( cur < m_uids.count() ) {
220 m_end = false; 225 m_end = false;
221 m_current= cur; 226 m_current= cur;
222 } 227 }
@@ -245,15 +250,16 @@ ORecordList<T>::Iterator ORecordList<T>::end() {
245 Iterator it( m_ids, m_acc ); 250 Iterator it( m_ids, m_acc );
246 it.m_end = true; 251 it.m_end = true;
247 it.m_current = m_ids.count(); 252 it.m_current = m_ids.count();
248 253
249 return it; 254 return it;
250} 255}
251template <class T> 256template <class T>
252uint ORecordList<T>::count()const { 257uint ORecordList<T>::count()const {
253return m_ids.count(); 258return m_ids.count();
254} 259}
255template <class T> 260template <class T>
256T ORecordList<T>::operator[]( uint i ) { 261T ORecordList<T>::operator[]( uint i ) {
257 return m_acc->find( m_ids[i] ); 262 /* forward */
263 return m_acc->find( m_ids[i], m_ids, i );
258} 264}
259#endif 265#endif