Diffstat (limited to 'libopie2/opiepim/core/opimrecordlist.h') (more/less context) (show whitespace changes)
-rw-r--r-- | libopie2/opiepim/core/opimrecordlist.h | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/libopie2/opiepim/core/opimrecordlist.h b/libopie2/opiepim/core/opimrecordlist.h index 1d5027f..0459f41 100644 --- a/libopie2/opiepim/core/opimrecordlist.h +++ b/libopie2/opiepim/core/opimrecordlist.h @@ -32,24 +32,25 @@ /* OPIE */ #include <opie2/opimtemplatebase.h> #include <opie2/opimrecord.h> //#include <opie2/odebug.h> /* QT */ #include <qarray.h> namespace Opie { +template<class T> class OPimAccessTemplate; class OPimRecordListIteratorPrivate; /** * Our List Iterator * it behaves like STL or Qt * * for(it = list.begin(); it != list.end(); ++it ) * doSomeCoolStuff( (*it) ); */ template <class T> class OPimRecordList; template <class T = OPimRecord> class OPimRecordListIterator { @@ -111,33 +112,33 @@ class OPimRecordListIterator OPimRecordListIteratorPrivate *d; }; class OPimRecordListPrivate; /** * The recordlist used as a return type * from OPimAccessTemplate */ template <class T = OPimRecord > class OPimRecordList { + template<class> friend class OPimAccessTemplate; public: typedef OTemplateBase<T> Base; typedef OPimRecordListIterator<T> Iterator; /** * c'tor */ - OPimRecordList () - {} + OPimRecordList (){} OPimRecordList( const QArray<int>& ids, const Base* ); ~OPimRecordList(); /** * the first iterator */ Iterator begin(); /** * the end */ @@ -151,24 +152,27 @@ class OPimRecordList T operator[] ( uint i ); int uidAt( uint i ); /** * Remove the contact with given uid */ bool remove( int uid ); /* ConstIterator begin()const; ConstIterator end()const; */ + protected: + UIDArray uids()const; + private: QArray<int> m_ids; const Base* m_acc; OPimRecordListPrivate *d; }; /* ok now implement it */ template <class T> OPimRecordListIterator<T>::OPimRecordListIterator() { m_current = 0; @@ -181,25 +185,24 @@ OPimRecordListIterator<T>::OPimRecordListIterator() template <class T> OPimRecordListIterator<T>::~OPimRecordListIterator() { /* nothing to delete */ } template <class T> OPimRecordListIterator<T>::OPimRecordListIterator( const OPimRecordListIterator<T>& it ) { - //owarn << "OPimRecordListIterator copy c'tor" << oendl; m_uids = it.m_uids; m_current = it.m_current; m_temp = it.m_temp; m_end = it.m_end; m_record = it.m_record; m_direction = it.m_direction; } template <class T> OPimRecordListIterator<T> &OPimRecordListIterator<T>::operator=( const OPimRecordListIterator<T>& it ) { @@ -207,25 +210,24 @@ OPimRecordListIterator<T> &OPimRecordListIterator<T>::operator=( const OPimRecor m_current = it.m_current; m_temp = it.m_temp; m_end = it.m_end; m_record = it.m_record; return *this; } template <class T> T OPimRecordListIterator<T>::operator*() { - //owarn << "operator* " << m_current << " " << m_uids[m_current] << oendl; if ( !m_end ) m_record = m_temp->find( m_uids[ m_current ], m_uids, m_current, m_direction ? Base::Forward : Base::Reverse ); else m_record = T(); return m_record; } template <class T> @@ -390,14 +392,19 @@ bool OPimRecordList<T>::remove( int uid ) } else ret_val = true; } copy.resize( counter ); m_ids = copy; return ret_val; } +template<class T> +UIDArray OPimRecordList<T>::uids()const { + return m_ids; +} + } #endif |