From 7b065f0388604e0485fa64a14abdf939dceab954 Mon Sep 17 00:00:00 2001 From: zecke Date: Tue, 24 Sep 2002 14:58:51 +0000 Subject: Add some hooks to ORecordList and Iterator current() for Iterator setCurrent() for Iterator count() for both --- 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 @@ -46,10 +46,25 @@ public: bool operator==( const ORecordListIterator& it ); bool operator!=( const ORecordListIterator& it ); + + /** + * the current item + */ + uint current()const; + + /** + * the number of items + */ + uint count()const; + + /** + * sets the current item + */ + void setCurrent( uint cur ); private: QArray m_uids; - int m_current; + uint m_current; const Base* m_temp; bool m_end : 1; T m_record; @@ -86,6 +101,13 @@ public: * the end */ Iterator end(); + + /** + * the number of items in the list + */ + uint count()const; + + // FIXME implemenent remove /* ConstIterator begin()const; ConstIterator end()const; @@ -133,7 +155,12 @@ template T ORecordListIterator::operator*() { // qWarning("operator* %d %d", m_current, m_uids[m_current] ); if (!m_end ) - m_record = m_temp->find( m_uids[m_current] ); + /* FIXME + * until the cache is in place + * we do the uid match uid check + */ + if(m_record.uid() != m_uids[m_current] ) + m_record = m_temp->find( m_uids[m_current] ); else m_record = T(); @@ -142,7 +169,7 @@ T ORecordListIterator::operator*() { template ORecordListIterator &ORecordListIterator::operator++() { - if (m_current < (int)m_uids.count() ) { + if (m_current < m_uids.count() ) { m_end = false; ++m_current; }else @@ -183,7 +210,21 @@ ORecordListIterator::ORecordListIterator( const QArray uids, : m_uids( uids ), m_current( 0 ), m_temp( t ), m_end( false ) { } - +template +uint ORecordListIterator::current()const { + return m_current; +} +template +void ORecordListIterator::setCurrent( uint cur ) { + if( cur < m_uids.count() ) { + m_end = false; + m_current= cur; + } +} +template +uint ORecordListIterator::count()const { + return m_uids.count(); +} template ORecordList::ORecordList( const QArray& ids, const Base* acc ) @@ -207,4 +248,8 @@ ORecordList::Iterator ORecordList::end() { return it; } +template +uint ORecordList::count()const { +return m_ids.count(); +} #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 @@ -46,10 +46,25 @@ public: bool operator==( const ORecordListIterator& it ); bool operator!=( const ORecordListIterator& it ); + + /** + * the current item + */ + uint current()const; + + /** + * the number of items + */ + uint count()const; + + /** + * sets the current item + */ + void setCurrent( uint cur ); private: QArray m_uids; - int m_current; + uint m_current; const Base* m_temp; bool m_end : 1; T m_record; @@ -86,6 +101,13 @@ public: * the end */ Iterator end(); + + /** + * the number of items in the list + */ + uint count()const; + + // FIXME implemenent remove /* ConstIterator begin()const; ConstIterator end()const; @@ -133,7 +155,12 @@ template T ORecordListIterator::operator*() { // qWarning("operator* %d %d", m_current, m_uids[m_current] ); if (!m_end ) - m_record = m_temp->find( m_uids[m_current] ); + /* FIXME + * until the cache is in place + * we do the uid match uid check + */ + if(m_record.uid() != m_uids[m_current] ) + m_record = m_temp->find( m_uids[m_current] ); else m_record = T(); @@ -142,7 +169,7 @@ T ORecordListIterator::operator*() { template ORecordListIterator &ORecordListIterator::operator++() { - if (m_current < (int)m_uids.count() ) { + if (m_current < m_uids.count() ) { m_end = false; ++m_current; }else @@ -183,7 +210,21 @@ ORecordListIterator::ORecordListIterator( const QArray uids, : m_uids( uids ), m_current( 0 ), m_temp( t ), m_end( false ) { } - +template +uint ORecordListIterator::current()const { + return m_current; +} +template +void ORecordListIterator::setCurrent( uint cur ) { + if( cur < m_uids.count() ) { + m_end = false; + m_current= cur; + } +} +template +uint ORecordListIterator::count()const { + return m_uids.count(); +} template ORecordList::ORecordList( const QArray& ids, const Base* acc ) @@ -207,4 +248,8 @@ ORecordList::Iterator ORecordList::end() { return it; } +template +uint ORecordList::count()const { +return m_ids.count(); +} #endif -- cgit v0.9.0.2