author | zecke <zecke> | 2002-09-21 15:02:50 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-09-21 15:02:50 (UTC) |
commit | e6c53c4d7317e766235449535b22d0d2fe709214 (patch) (side-by-side diff) | |
tree | c210c639611acd5aa3c1863451fb4e31ac3af29a /libopie2/opiepim/orecordlist.h | |
parent | fe0806def8ec79815832193fe402c75361108622 (diff) | |
download | opie-e6c53c4d7317e766235449535b22d0d2fe709214.zip opie-e6c53c4d7317e766235449535b22d0d2fe709214.tar.gz opie-e6c53c4d7317e766235449535b22d0d2fe709214.tar.bz2 |
Some more implementation
in OPimRecord::setUid
ORecordList implemented never compiled it though
OTodo a new c'tor and some more changes
Diffstat (limited to 'libopie2/opiepim/orecordlist.h') (more/less context) (show whitespace changes)
-rw-r--r-- | libopie2/opiepim/orecordlist.h | 139 |
1 files changed, 127 insertions, 12 deletions
diff --git a/libopie2/opiepim/orecordlist.h b/libopie2/opiepim/orecordlist.h index c17186f..65c2169 100644 --- a/libopie2/opiepim/orecordlist.h +++ b/libopie2/opiepim/orecordlist.h @@ -12,23 +12,32 @@ public: friend class ORecordList; public: - Iterator() {} - ~Iterator() {} - Iterator(const Iterator& ) {} + Iterator(); + ~Iterator(); + Iterator(const Iterator& ); Iterator &operator=(const Iterator& ); - T &operator*() {} + T &operator*(); Iterator &operator++(); + Iterator &operator--(); bool operator==( const Iterator& it ); bool operator!=( const Iterator& it ); - } - ORecordList( const QArray<int>& ids, - OPimAccessTemplate<T>* acc ) - : m_ids(ids ), m_acc( acc ) { + private: + Iterator( const QArray<int>, + OPimAccessTemplate<T>* ); - } - ~ORecordList() { + QArray<int> m_uids; + int m_current; + OPimAccessTemplate* m_temp; + bool m_end : 1; + T m_record; - } + /* d pointer for future versions */ + class IteratorPrivate; + IteratorPrivate *d; + }; + ORecordList( const QArray<int>& ids, + OPimAccessTemplate<T>* acc ); + ~ORecordList(); Iterator begin(); Iterator end(); @@ -38,7 +47,113 @@ public: */ private: - QArray<int> ids; + QArray<int> m_ids; OPimAccessTemplate<T>* m_acc; }; +/* ok now implement it */ +template <class T= OPimRecord> +ORecordList<T>::Iterator::Iterator() { + m_current = 0; + m_temp = 0l; + m_end = true; +} +template <class T= OPimRecord> +ORecordList<T>::Iterator::~Iterator() { +/* nothing to delete */ +} + +template <class T = OPimRecord> +ORecordList<T>::Iterator::Iterator( const ORecordList<T>::Iterator& it) { + 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; +} + +template <class T = OPimRecord> +ORecordList<T>::Iterator &ORecordList::Iterator::operator=( const ORecordList<T>::Iterator& it) { + 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; + + return *this; +} + +template <class T = OPimRecord> +T &ORecordList<T>::Iterator::operator*() { + if (!m_end ) + m_record = m_temp->find( m_uids[m_current] ); + else + m_record = T; + + return m_record; +} + +template <class T = OPimRecord> +ORecordList<T>::Iterator &ORecordList<T>::Iterator::operator++() { + if (m_current < m_uids.count() ) { + m_end = false; + ++m_current; + }else + m_end = true; + + return *this; +} +template <class T = OPimRecord> +ORecordList<T>::Iterator &ORecordList<T>::Iterator::operator--() { + if ( m_current > 0 ) { + --m_current; + m_end = false; + } else + m_end = true; + + return *this; +} + +template <class T = OPimRecord> +bool ORecordList<T>::Iterator::operator==( const ORecordList<T>::Iterator& it ) { + + /* if both are at we're the same.... */ + if ( m_end == it.m_end ) return true; + + if ( m_uids != it.m_uids ) return false; + if ( m_current != it.m_current ) return false; + if ( m_temp != it.m_temp ) return false; + + return true; +} +template <class T = ORecordList> +bool ORecordList<T>::Iterator::operator!=( const ORecordList<T>::Iterator it ) { + return !(*this == it ); +} +template <class T = ORecordList> +ORecordList<T>::Iterator::Iterator( const QArray<int> uids, + OPimAccessTemplate<T>* t ) + : m_uids( uids ), m_current( 0 ), m_temp( t ), m_end( false ) +{ +} +template <class T = ORecordList> +ORecordList<T>::ORecordList( const QArray<int>& ids, + OPimAccessTemplate<T>* acc ) + : m_ids( ids ), m_acc( acc ) +{ +} +template <class T = ORecordList> +ORecordList<T>::~ORecordList() { +/* nothing to do here */ +} +template <class T = ORecordList> +ORecordList<T>::Iterator ORecordList<T>::begin() { + Iterator it( m_ids, m_acc ); + return it; +} +template <class T = ORecordList> +ORecordList<T>::Iterator ORecordList<T>::end() { + Iterator it( m_ids, m_acc ); + it.m_end = true; + it.m_current = m_ids.count(); +} #endif |