From a098735b8749ead08c658792cc31f95e73045107 Mon Sep 17 00:00:00 2001 From: eilers Date: Fri, 01 Nov 2002 15:09:04 +0000 Subject: Added remove --- (limited to 'libopie2') diff --git a/libopie2/opiepim/orecordlist.h b/libopie2/opiepim/orecordlist.h index e377447..2f4a5d3 100644 --- a/libopie2/opiepim/orecordlist.h +++ b/libopie2/opiepim/orecordlist.h @@ -89,7 +89,7 @@ public: */ ORecordList () { } - ORecordList( const QArray& ids, +ORecordList( const QArray& ids, const Base* ); ~ORecordList(); @@ -110,7 +110,12 @@ public: T operator[]( uint i ); int uidAt(uint i ); - // FIXME implemenent remove + + /** + * Remove the contact with given uid + */ + bool remove( int uid ); + /* ConstIterator begin()const; ConstIterator end()const; @@ -159,7 +164,7 @@ ORecordListIterator &ORecordListIterator::operator=( const ORecordListIter template T ORecordListIterator::operator*() { - qWarning("operator* %d %d", m_current, m_uids[m_current] ); + //qWarning("operator* %d %d", m_current, m_uids[m_current] ); if (!m_end ) m_record = m_temp->find( m_uids[m_current], m_uids, m_current, m_direction ? Base::Forward : @@ -269,4 +274,27 @@ template int ORecordList::uidAt( uint i ) { return m_ids[i]; } + +template +bool ORecordList::remove( int uid ) { + QArray copy( m_ids.count() ); + int counter = 0; + bool ret_val = false; + + for (uint i = 0; i < m_ids.count(); i++){ + if ( m_ids[i] != uid ){ + copy[counter++] = m_ids[i]; + + }else + ret_val = true; + } + + copy.resize( counter ); + m_ids = copy; + + + return ret_val; +} + + #endif -- cgit v0.9.0.2