-rw-r--r-- | libopie/pim/orecordlist.h | 53 |
1 files changed, 49 insertions, 4 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: ORecordListIterator &operator--(); 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<int> m_uids; - int m_current; + uint m_current; const Base* m_temp; bool m_end : 1; T m_record; @@ -85,8 +100,15 @@ public: /** * the end */ Iterator end(); + + /** + * the number of items in the list + */ + uint count()const; + + // FIXME implemenent remove /* ConstIterator begin()const; ConstIterator end()const; */ @@ -132,18 +154,23 @@ ORecordListIterator<T> &ORecordListIterator<T>::operator=( const ORecordListIter template <class T> T ORecordListIterator<T>::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(); return m_record; } template <class T> ORecordListIterator<T> &ORecordListIterator<T>::operator++() { - if (m_current < (int)m_uids.count() ) { + if (m_current < m_uids.count() ) { m_end = false; ++m_current; }else m_end = true; @@ -182,9 +209,23 @@ ORecordListIterator<T>::ORecordListIterator( const QArray<int> uids, const Base* t ) : m_uids( uids ), m_current( 0 ), m_temp( t ), m_end( false ) { } - +template <class T> +uint ORecordListIterator<T>::current()const { + return m_current; +} +template <class T> +void ORecordListIterator<T>::setCurrent( uint cur ) { + if( cur < m_uids.count() ) { + m_end = false; + m_current= cur; + } +} +template <class T> +uint ORecordListIterator<T>::count()const { + return m_uids.count(); +} template <class T> ORecordList<T>::ORecordList( const QArray<int>& ids, const Base* acc ) : m_ids( ids ), m_acc( acc ) @@ -206,5 +247,9 @@ ORecordList<T>::Iterator ORecordList<T>::end() { it.m_current = m_ids.count(); return it; } +template <class T> +uint ORecordList<T>::count()const { +return m_ids.count(); +} #endif |