-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 | |||
@@ -91,3 +91,3 @@ public: | |||
91 | } | 91 | } |
92 | ORecordList( const QArray<int>& ids, | 92 | ORecordList( const QArray<int>& ids, |
93 | const Base* ); | 93 | const Base* ); |
@@ -112,3 +112,8 @@ public: | |||
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 | /* |
@@ -161,3 +166,3 @@ 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 ) |
@@ -271,2 +276,25 @@ int ORecordList<T>::uidAt( uint 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 |