author | eilers <eilers> | 2002-11-01 15:09:04 (UTC) |
---|---|---|
committer | eilers <eilers> | 2002-11-01 15:09:04 (UTC) |
commit | a098735b8749ead08c658792cc31f95e73045107 (patch) (unidiff) | |
tree | 28bd5ee97878ff3dfc7aa0e6b0c0dcd511acd3f7 /libopie/pim/orecordlist.h | |
parent | 3fbba334274ca53bd26cd79ccd4662e529c61f40 (diff) | |
download | opie-a098735b8749ead08c658792cc31f95e73045107.zip opie-a098735b8749ead08c658792cc31f95e73045107.tar.gz opie-a098735b8749ead08c658792cc31f95e73045107.tar.bz2 |
Added remove
-rw-r--r-- | libopie/pim/orecordlist.h | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/libopie/pim/orecordlist.h b/libopie/pim/orecordlist.h index e377447..2f4a5d3 100644 --- a/libopie/pim/orecordlist.h +++ b/libopie/pim/orecordlist.h | |||
@@ -86,13 +86,13 @@ public: | |||
86 | 86 | ||
87 | /** | 87 | /** |
88 | * c'tor | 88 | * c'tor |
89 | */ | 89 | */ |
90 | ORecordList () { | 90 | ORecordList () { |
91 | } | 91 | } |
92 | ORecordList( const QArray<int>& ids, | 92 | ORecordList( const QArray<int>& ids, |
93 | const Base* ); | 93 | const Base* ); |
94 | ~ORecordList(); | 94 | ~ORecordList(); |
95 | 95 | ||
96 | /** | 96 | /** |
97 | * the first iterator | 97 | * the first iterator |
98 | */ | 98 | */ |
@@ -107,13 +107,18 @@ public: | |||
107 | * the number of items in the list | 107 | * the number of items in the list |
108 | */ | 108 | */ |
109 | uint count()const; | 109 | uint count()const; |
110 | 110 | ||
111 | T operator[]( uint i ); | 111 | T operator[]( uint i ); |
112 | int uidAt(uint i ); | 112 | int uidAt(uint i ); |
113 | // FIXME implemenent remove | 113 | |
114 | /** | ||
115 | * Remove the contact with given uid | ||
116 | */ | ||
117 | bool remove( int uid ); | ||
118 | |||
114 | /* | 119 | /* |
115 | ConstIterator begin()const; | 120 | ConstIterator begin()const; |
116 | ConstIterator end()const; | 121 | ConstIterator end()const; |
117 | */ | 122 | */ |
118 | private: | 123 | private: |
119 | QArray<int> m_ids; | 124 | QArray<int> m_ids; |
@@ -156,13 +161,13 @@ ORecordListIterator<T> &ORecordListIterator<T>::operator=( const ORecordListIter | |||
156 | 161 | ||
157 | return *this; | 162 | return *this; |
158 | } | 163 | } |
159 | 164 | ||
160 | template <class T> | 165 | template <class T> |
161 | T ORecordListIterator<T>::operator*() { | 166 | T ORecordListIterator<T>::operator*() { |
162 | qWarning("operator* %d %d", m_current, m_uids[m_current] ); | 167 | //qWarning("operator* %d %d", m_current, m_uids[m_current] ); |
163 | if (!m_end ) | 168 | if (!m_end ) |
164 | m_record = m_temp->find( m_uids[m_current], m_uids, m_current, | 169 | m_record = m_temp->find( m_uids[m_current], m_uids, m_current, |
165 | m_direction ? Base::Forward : | 170 | m_direction ? Base::Forward : |
166 | Base::Reverse ); | 171 | Base::Reverse ); |
167 | else | 172 | else |
168 | m_record = T(); | 173 | m_record = T(); |
@@ -266,7 +271,30 @@ T ORecordList<T>::operator[]( uint i ) { | |||
266 | return m_acc->find( m_ids[i], m_ids, i ); | 271 | return m_acc->find( m_ids[i], m_ids, i ); |
267 | } | 272 | } |
268 | template <class T> | 273 | template <class T> |
269 | int ORecordList<T>::uidAt( uint i ) { | 274 | int ORecordList<T>::uidAt( uint i ) { |
270 | return m_ids[i]; | 275 | return m_ids[i]; |
271 | } | 276 | } |
277 | |||
278 | template <class T> | ||
279 | bool ORecordList<T>::remove( int uid ) { | ||
280 | QArray<int> copy( m_ids.count() ); | ||
281 | int counter = 0; | ||
282 | bool ret_val = false; | ||
283 | |||
284 | for (uint i = 0; i < m_ids.count(); i++){ | ||
285 | if ( m_ids[i] != uid ){ | ||
286 | copy[counter++] = m_ids[i]; | ||
287 | |||
288 | }else | ||
289 | ret_val = true; | ||
290 | } | ||
291 | |||
292 | copy.resize( counter ); | ||
293 | m_ids = copy; | ||
294 | |||
295 | |||
296 | return ret_val; | ||
297 | } | ||
298 | |||
299 | |||
272 | #endif | 300 | #endif |