Diffstat (limited to 'libopie2/opiepim/orecordlist.h') (more/less context) (show whitespace changes)
-rw-r--r-- | libopie2/opiepim/orecordlist.h | 142 |
1 files changed, 104 insertions, 38 deletions
diff --git a/libopie2/opiepim/orecordlist.h b/libopie2/opiepim/orecordlist.h index 8f0011b..1742dcc 100644 --- a/libopie2/opiepim/orecordlist.h +++ b/libopie2/opiepim/orecordlist.h @@ -28,13 +28,16 @@ */ -#ifndef OPIE_RECORD_LIST_H -#define OPIE_RECORD_LIST_H - -#include <qarray.h> +#ifndef ORECORDLIST_H +#define ORECORDLIST_H +/* OPIE */ #include <opie2/otemplatebase.h> #include <opie2/opimrecord.h> -namespace Opie { +/* QT */ +#include <qarray.h> + +namespace Opie +{ class ORecordListIteratorPrivate; @@ -48,6 +51,8 @@ class ORecordListIteratorPrivate; template <class T> class ORecordList; template <class T = OPimRecord> -class ORecordListIterator { +class ORecordListIterator +{ friend class ORecordList<T>; + public: typedef OTemplateBase<T> Base; @@ -106,4 +111,5 @@ private: }; + class ORecordListPrivate; /** @@ -112,5 +118,6 @@ class ORecordListPrivate; */ template <class T = OPimRecord > -class ORecordList { +class ORecordList +{ public: typedef OTemplateBase<T> Base; @@ -120,6 +127,6 @@ public: * c'tor */ - ORecordList () { - } + ORecordList () + {} ORecordList( const QArray<int>& ids, const Base* ); @@ -159,7 +166,9 @@ private: }; + /* ok now implement it */ template <class T> -ORecordListIterator<T>::ORecordListIterator() { +ORecordListIterator<T>::ORecordListIterator() +{ m_current = 0; m_temp = 0l; @@ -169,11 +178,16 @@ ORecordListIterator<T>::ORecordListIterator() { m_direction = TRUE; } + + template <class T> -ORecordListIterator<T>::~ORecordListIterator() { +ORecordListIterator<T>::~ORecordListIterator() +{ /* nothing to delete */ } + template <class T> -ORecordListIterator<T>::ORecordListIterator( const ORecordListIterator<T>& it) { +ORecordListIterator<T>::ORecordListIterator( const ORecordListIterator<T>& it ) +{ // qWarning("ORecordListIterator copy c'tor"); m_uids = it.m_uids; @@ -185,6 +199,8 @@ ORecordListIterator<T>::ORecordListIterator( const ORecordListIterator<T>& it) { } + template <class T> -ORecordListIterator<T> &ORecordListIterator<T>::operator=( const ORecordListIterator<T>& it) { +ORecordListIterator<T> &ORecordListIterator<T>::operator=( const ORecordListIterator<T>& it ) +{ m_uids = it.m_uids; m_current = it.m_current; @@ -196,6 +212,8 @@ ORecordListIterator<T> &ORecordListIterator<T>::operator=( const ORecordListIter } + template <class T> -T ORecordListIterator<T>::operator*() { +T ORecordListIterator<T>::operator*() +{ //qWarning("operator* %d %d", m_current, m_uids[m_current] ); if (!m_end ) @@ -209,22 +227,31 @@ T ORecordListIterator<T>::operator*() { } + template <class T> -ORecordListIterator<T> &ORecordListIterator<T>::operator++() { +ORecordListIterator<T> &ORecordListIterator<T>::operator++() +{ m_direction = true; - if (m_current < m_uids.count() ) { + if ( m_current < m_uids.count() ) + { m_end = false; ++m_current; - }else + } + else m_end = true; return *this; } + + template <class T> -ORecordListIterator<T> &ORecordListIterator<T>::operator--() { +ORecordListIterator<T> &ORecordListIterator<T>::operator--() +{ m_direction = false; - if ( m_current > 0 ) { + if ( m_current > 0 ) + { --m_current; m_end = false; - } else + } + else m_end = true; @@ -232,6 +259,8 @@ ORecordListIterator<T> &ORecordListIterator<T>::operator--() { } + template <class T> -bool ORecordListIterator<T>::operator==( const ORecordListIterator<T>& it ) { +bool ORecordListIterator<T>::operator==( const ORecordListIterator<T>& it ) +{ /* if both are at we're the same.... */ @@ -244,8 +273,13 @@ bool ORecordListIterator<T>::operator==( const ORecordListIterator<T>& it ) { return true; } + + template <class T> -bool ORecordListIterator<T>::operator!=( const ORecordListIterator<T>& it ) { +bool ORecordListIterator<T>::operator!=( const ORecordListIterator<T>& it ) +{ return !(*this == it ); } + + template <class T> ORecordListIterator<T>::ORecordListIterator( const QArray<int> uids, @@ -258,11 +292,18 @@ ORecordListIterator<T>::ORecordListIterator( const QArray<int> uids, m_end = true; } + + template <class T> -uint ORecordListIterator<T>::current()const { +uint ORecordListIterator<T>::current() const +{ return m_current; } + + template <class T> -void ORecordListIterator<T>::setCurrent( uint cur ) { - if( cur < m_uids.count() ) { +void ORecordListIterator<T>::setCurrent( uint cur ) +{ + if ( cur < m_uids.count() ) + { m_end = false; m_current= cur; @@ -270,24 +311,35 @@ void ORecordListIterator<T>::setCurrent( uint cur ) { } template <class T> -uint ORecordListIterator<T>::count()const { +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 ) -{ -} +{} + + template <class T> -ORecordList<T>::~ORecordList() { +ORecordList<T>::~ORecordList() +{ /* nothing to do here */ } + + template <class T> -typename ORecordList<T>::Iterator ORecordList<T>::begin() { +typename ORecordList<T>::Iterator ORecordList<T>::begin() +{ Iterator it( m_ids, m_acc ); return it; } + + template <class T> -typename ORecordList<T>::Iterator ORecordList<T>::end() { +typename ORecordList<T>::Iterator ORecordList<T>::end() +{ Iterator it( m_ids, m_acc ); it.m_end = true; @@ -296,10 +348,16 @@ typename ORecordList<T>::Iterator ORecordList<T>::end() { return it; } + + template <class T> -uint ORecordList<T>::count()const { +uint ORecordList<T>::count() const +{ return m_ids.count(); } + + template <class T> -T ORecordList<T>::operator[]( uint i ) { +T ORecordList<T>::operator[] ( uint i ) +{ if ( i >= m_ids.count() ) return T(); @@ -307,20 +365,28 @@ T ORecordList<T>::operator[]( uint i ) { return m_acc->find( m_ids[i], m_ids, i ); } + + template <class T> -int ORecordList<T>::uidAt( uint i ) { +int ORecordList<T>::uidAt( uint i ) +{ return m_ids[i]; } + template <class T> -bool ORecordList<T>::remove( int uid ) { +bool ORecordList<T>::remove( int uid ) +{ QArray<int> 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 ){ + for ( uint i = 0; i < m_ids.count(); i++ ) + { + if ( m_ids[ i ] != uid ) + { copy[counter++] = m_ids[i]; - }else + } + else ret_val = true; } |