-rw-r--r-- | libopie/pim/orecordlist.h | 53 | ||||
-rw-r--r-- | libopie2/opiepim/orecordlist.h | 53 |
2 files changed, 98 insertions, 8 deletions
diff --git a/libopie/pim/orecordlist.h b/libopie/pim/orecordlist.h index 1795938..c63d813 100644 --- a/libopie/pim/orecordlist.h +++ b/libopie/pim/orecordlist.h | |||
@@ -45,12 +45,27 @@ public: | |||
45 | ORecordListIterator &operator--(); | 45 | ORecordListIterator &operator--(); |
46 | 46 | ||
47 | bool operator==( const ORecordListIterator& it ); | 47 | bool operator==( const ORecordListIterator& it ); |
48 | bool operator!=( const ORecordListIterator& it ); | 48 | bool operator!=( const ORecordListIterator& it ); |
49 | |||
50 | /** | ||
51 | * the current item | ||
52 | */ | ||
53 | uint current()const; | ||
54 | |||
55 | /** | ||
56 | * the number of items | ||
57 | */ | ||
58 | uint count()const; | ||
59 | |||
60 | /** | ||
61 | * sets the current item | ||
62 | */ | ||
63 | void setCurrent( uint cur ); | ||
49 | 64 | ||
50 | private: | 65 | private: |
51 | QArray<int> m_uids; | 66 | QArray<int> m_uids; |
52 | int m_current; | 67 | uint m_current; |
53 | const Base* m_temp; | 68 | const Base* m_temp; |
54 | bool m_end : 1; | 69 | bool m_end : 1; |
55 | T m_record; | 70 | T m_record; |
56 | 71 | ||
@@ -85,8 +100,15 @@ public: | |||
85 | /** | 100 | /** |
86 | * the end | 101 | * the end |
87 | */ | 102 | */ |
88 | Iterator end(); | 103 | Iterator end(); |
104 | |||
105 | /** | ||
106 | * the number of items in the list | ||
107 | */ | ||
108 | uint count()const; | ||
109 | |||
110 | // FIXME implemenent remove | ||
89 | /* | 111 | /* |
90 | ConstIterator begin()const; | 112 | ConstIterator begin()const; |
91 | ConstIterator end()const; | 113 | ConstIterator end()const; |
92 | */ | 114 | */ |
@@ -132,18 +154,23 @@ ORecordListIterator<T> &ORecordListIterator<T>::operator=( const ORecordListIter | |||
132 | template <class T> | 154 | template <class T> |
133 | T ORecordListIterator<T>::operator*() { | 155 | T ORecordListIterator<T>::operator*() { |
134 | // qWarning("operator* %d %d", m_current, m_uids[m_current] ); | 156 | // qWarning("operator* %d %d", m_current, m_uids[m_current] ); |
135 | if (!m_end ) | 157 | if (!m_end ) |
136 | m_record = m_temp->find( m_uids[m_current] ); | 158 | /* FIXME |
159 | * until the cache is in place | ||
160 | * we do the uid match uid check | ||
161 | */ | ||
162 | if(m_record.uid() != m_uids[m_current] ) | ||
163 | m_record = m_temp->find( m_uids[m_current] ); | ||
137 | else | 164 | else |
138 | m_record = T(); | 165 | m_record = T(); |
139 | 166 | ||
140 | return m_record; | 167 | return m_record; |
141 | } | 168 | } |
142 | 169 | ||
143 | template <class T> | 170 | template <class T> |
144 | ORecordListIterator<T> &ORecordListIterator<T>::operator++() { | 171 | ORecordListIterator<T> &ORecordListIterator<T>::operator++() { |
145 | if (m_current < (int)m_uids.count() ) { | 172 | if (m_current < m_uids.count() ) { |
146 | m_end = false; | 173 | m_end = false; |
147 | ++m_current; | 174 | ++m_current; |
148 | }else | 175 | }else |
149 | m_end = true; | 176 | m_end = true; |
@@ -182,9 +209,23 @@ ORecordListIterator<T>::ORecordListIterator( const QArray<int> uids, | |||
182 | const Base* t ) | 209 | const Base* t ) |
183 | : m_uids( uids ), m_current( 0 ), m_temp( t ), m_end( false ) | 210 | : m_uids( uids ), m_current( 0 ), m_temp( t ), m_end( false ) |
184 | { | 211 | { |
185 | } | 212 | } |
186 | 213 | template <class T> | |
214 | uint ORecordListIterator<T>::current()const { | ||
215 | return m_current; | ||
216 | } | ||
217 | template <class T> | ||
218 | void ORecordListIterator<T>::setCurrent( uint cur ) { | ||
219 | if( cur < m_uids.count() ) { | ||
220 | m_end = false; | ||
221 | m_current= cur; | ||
222 | } | ||
223 | } | ||
224 | template <class T> | ||
225 | uint ORecordListIterator<T>::count()const { | ||
226 | return m_uids.count(); | ||
227 | } | ||
187 | template <class T> | 228 | template <class T> |
188 | ORecordList<T>::ORecordList( const QArray<int>& ids, | 229 | ORecordList<T>::ORecordList( const QArray<int>& ids, |
189 | const Base* acc ) | 230 | const Base* acc ) |
190 | : m_ids( ids ), m_acc( acc ) | 231 | : m_ids( ids ), m_acc( acc ) |
@@ -206,5 +247,9 @@ ORecordList<T>::Iterator ORecordList<T>::end() { | |||
206 | it.m_current = m_ids.count(); | 247 | it.m_current = m_ids.count(); |
207 | 248 | ||
208 | return it; | 249 | return it; |
209 | } | 250 | } |
251 | template <class T> | ||
252 | uint ORecordList<T>::count()const { | ||
253 | return m_ids.count(); | ||
254 | } | ||
210 | #endif | 255 | #endif |
diff --git a/libopie2/opiepim/orecordlist.h b/libopie2/opiepim/orecordlist.h index 1795938..c63d813 100644 --- a/libopie2/opiepim/orecordlist.h +++ b/libopie2/opiepim/orecordlist.h | |||
@@ -45,12 +45,27 @@ public: | |||
45 | ORecordListIterator &operator--(); | 45 | ORecordListIterator &operator--(); |
46 | 46 | ||
47 | bool operator==( const ORecordListIterator& it ); | 47 | bool operator==( const ORecordListIterator& it ); |
48 | bool operator!=( const ORecordListIterator& it ); | 48 | bool operator!=( const ORecordListIterator& it ); |
49 | |||
50 | /** | ||
51 | * the current item | ||
52 | */ | ||
53 | uint current()const; | ||
54 | |||
55 | /** | ||
56 | * the number of items | ||
57 | */ | ||
58 | uint count()const; | ||
59 | |||
60 | /** | ||
61 | * sets the current item | ||
62 | */ | ||
63 | void setCurrent( uint cur ); | ||
49 | 64 | ||
50 | private: | 65 | private: |
51 | QArray<int> m_uids; | 66 | QArray<int> m_uids; |
52 | int m_current; | 67 | uint m_current; |
53 | const Base* m_temp; | 68 | const Base* m_temp; |
54 | bool m_end : 1; | 69 | bool m_end : 1; |
55 | T m_record; | 70 | T m_record; |
56 | 71 | ||
@@ -85,8 +100,15 @@ public: | |||
85 | /** | 100 | /** |
86 | * the end | 101 | * the end |
87 | */ | 102 | */ |
88 | Iterator end(); | 103 | Iterator end(); |
104 | |||
105 | /** | ||
106 | * the number of items in the list | ||
107 | */ | ||
108 | uint count()const; | ||
109 | |||
110 | // FIXME implemenent remove | ||
89 | /* | 111 | /* |
90 | ConstIterator begin()const; | 112 | ConstIterator begin()const; |
91 | ConstIterator end()const; | 113 | ConstIterator end()const; |
92 | */ | 114 | */ |
@@ -132,18 +154,23 @@ ORecordListIterator<T> &ORecordListIterator<T>::operator=( const ORecordListIter | |||
132 | template <class T> | 154 | template <class T> |
133 | T ORecordListIterator<T>::operator*() { | 155 | T ORecordListIterator<T>::operator*() { |
134 | // qWarning("operator* %d %d", m_current, m_uids[m_current] ); | 156 | // qWarning("operator* %d %d", m_current, m_uids[m_current] ); |
135 | if (!m_end ) | 157 | if (!m_end ) |
136 | m_record = m_temp->find( m_uids[m_current] ); | 158 | /* FIXME |
159 | * until the cache is in place | ||
160 | * we do the uid match uid check | ||
161 | */ | ||
162 | if(m_record.uid() != m_uids[m_current] ) | ||
163 | m_record = m_temp->find( m_uids[m_current] ); | ||
137 | else | 164 | else |
138 | m_record = T(); | 165 | m_record = T(); |
139 | 166 | ||
140 | return m_record; | 167 | return m_record; |
141 | } | 168 | } |
142 | 169 | ||
143 | template <class T> | 170 | template <class T> |
144 | ORecordListIterator<T> &ORecordListIterator<T>::operator++() { | 171 | ORecordListIterator<T> &ORecordListIterator<T>::operator++() { |
145 | if (m_current < (int)m_uids.count() ) { | 172 | if (m_current < m_uids.count() ) { |
146 | m_end = false; | 173 | m_end = false; |
147 | ++m_current; | 174 | ++m_current; |
148 | }else | 175 | }else |
149 | m_end = true; | 176 | m_end = true; |
@@ -182,9 +209,23 @@ ORecordListIterator<T>::ORecordListIterator( const QArray<int> uids, | |||
182 | const Base* t ) | 209 | const Base* t ) |
183 | : m_uids( uids ), m_current( 0 ), m_temp( t ), m_end( false ) | 210 | : m_uids( uids ), m_current( 0 ), m_temp( t ), m_end( false ) |
184 | { | 211 | { |
185 | } | 212 | } |
186 | 213 | template <class T> | |
214 | uint ORecordListIterator<T>::current()const { | ||
215 | return m_current; | ||
216 | } | ||
217 | template <class T> | ||
218 | void ORecordListIterator<T>::setCurrent( uint cur ) { | ||
219 | if( cur < m_uids.count() ) { | ||
220 | m_end = false; | ||
221 | m_current= cur; | ||
222 | } | ||
223 | } | ||
224 | template <class T> | ||
225 | uint ORecordListIterator<T>::count()const { | ||
226 | return m_uids.count(); | ||
227 | } | ||
187 | template <class T> | 228 | template <class T> |
188 | ORecordList<T>::ORecordList( const QArray<int>& ids, | 229 | ORecordList<T>::ORecordList( const QArray<int>& ids, |
189 | const Base* acc ) | 230 | const Base* acc ) |
190 | : m_ids( ids ), m_acc( acc ) | 231 | : m_ids( ids ), m_acc( acc ) |
@@ -206,5 +247,9 @@ ORecordList<T>::Iterator ORecordList<T>::end() { | |||
206 | it.m_current = m_ids.count(); | 247 | it.m_current = m_ids.count(); |
207 | 248 | ||
208 | return it; | 249 | return it; |
209 | } | 250 | } |
251 | template <class T> | ||
252 | uint ORecordList<T>::count()const { | ||
253 | return m_ids.count(); | ||
254 | } | ||
210 | #endif | 255 | #endif |