summaryrefslogtreecommitdiff
path: root/libopie/pim/orecordlist.h
Unidiff
Diffstat (limited to 'libopie/pim/orecordlist.h') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/orecordlist.h29
1 files changed, 18 insertions, 11 deletions
diff --git a/libopie/pim/orecordlist.h b/libopie/pim/orecordlist.h
index 3b30a73..75bb33c 100644
--- a/libopie/pim/orecordlist.h
+++ b/libopie/pim/orecordlist.h
@@ -11,34 +11,36 @@
11 * Our List Iterator 11 * Our List Iterator
12 * it behaves like STL or Qt 12 * it behaves like STL or Qt
13 * 13 *
14 * for(it = list.begin(); it != list.end(); ++it ) 14 * for(it = list.begin(); it != list.end(); ++it )
15 * doSomeCoolStuff( (*it) ); 15 * doSomeCoolStuff( (*it) );
16 */ 16 */
17template <class T> class ORecordList;
17template <class T = OPimRecord> 18template <class T = OPimRecord>
18class ORecordListIterator { 19class ORecordListIterator {
20 friend class ORecordList<T>;
19public: 21public:
20 typedef OTemplateBase<T> Base; 22 typedef OTemplateBase<T> Base;
21 23
22 /** 24 /**
23 * The c'tor used internally from 25 * The c'tor used internally from
24 * ORecordList 26 * ORecordList
25 */ 27 */
26 ORecordListIterator( const QArray<int>, const Base* ); 28 ORecordListIterator( const QArray<int>, const Base* );
27 29
28 /** 30 /**
29 * The standard c'tor 31 * The standard c'tor
30 */ 32 */
31 ORecordListIterator(); 33 ORecordListIterator();
32 ~ORecordListIterator(); 34 ~ORecordListIterator();
33 35
34 ORecordListIterator( const ORecordListIterator& ); 36 ORecordListIterator( const ORecordListIterator& );
35 ORecordListIterator &operator=(const ORecordListIterator& ); 37 ORecordListIterator &operator=(const ORecordListIterator& );
36 38
37 /** 39 /**
38 * a * operator ;) 40 * a * operator ;)
39 * use it like this T = (*it); 41 * use it like this T = (*it);
40 */ 42 */
41 T &operator*(); 43 T &operator*();
42 ORecordListIterator &operator++(); 44 ORecordListIterator &operator++();
43 ORecordListIterator &operator--(); 45 ORecordListIterator &operator--();
44 46
@@ -56,31 +58,31 @@ private:
56 class IteratorPrivate; 58 class IteratorPrivate;
57 IteratorPrivate *d; 59 IteratorPrivate *d;
58}; 60};
59/** 61/**
60 * The recordlist used as a return type 62 * The recordlist used as a return type
61 * from OPimAccessTemplate 63 * from OPimAccessTemplate
62 */ 64 */
63template <class T = OPimRecord > 65template <class T = OPimRecord >
64class ORecordList { 66class ORecordList {
65public: 67public:
66 typedef OTemplateBase<T> Base; 68 typedef OTemplateBase<T> Base;
67 typedef ORecordListIterator<T> Iterator; 69 typedef ORecordListIterator<T> Iterator;
68 70
69 /** 71 /**
70 * c'tor 72 * c'tor
71 */ 73 */
72 ORecordList( const QArray<int>& ids, 74 ORecordList( const QArray<int>& ids,
73 const Base* ); 75 const Base* );
74 ~ORecordList(); 76 ~ORecordList();
75 77
76 /** 78 /**
77 * the first iterator 79 * the first iterator
78 */ 80 */
79 Iterator begin(); 81 Iterator begin();
80 82
81 /** 83 /**
82 * the end 84 * the end
83 */ 85 */
84 Iterator end(); 86 Iterator end();
85 /* 87 /*
86 ConstIterator begin()const; 88 ConstIterator begin()const;
@@ -102,12 +104,13 @@ template <class T>
102ORecordListIterator<T>::~ORecordListIterator() { 104ORecordListIterator<T>::~ORecordListIterator() {
103/* nothing to delete */ 105/* nothing to delete */
104} 106}
105 107
106template <class T> 108template <class T>
107ORecordListIterator<T>::ORecordListIterator( const ORecordListIterator<T>& it) { 109ORecordListIterator<T>::ORecordListIterator( const ORecordListIterator<T>& it) {
110 qWarning("ORecordListIterator");
108 m_uids = it.m_uids; 111 m_uids = it.m_uids;
109 m_current = it.m_current; 112 m_current = it.m_current;
110 m_temp = it.m_temp; 113 m_temp = it.m_temp;
111 m_end = it.m_end; 114 m_end = it.m_end;
112 m_record = it.m_record; 115 m_record = it.m_record;
113} 116}
@@ -122,23 +125,24 @@ ORecordListIterator<T> &ORecordListIterator<T>::operator=( const ORecordListIter
122 125
123 return *this; 126 return *this;
124} 127}
125 128
126template <class T> 129template <class T>
127T &ORecordListIterator<T>::operator*() { 130T &ORecordListIterator<T>::operator*() {
131 qWarning("operator* %d %d", m_current, m_uids[m_current] );
128 if (!m_end ) 132 if (!m_end )
129 m_record = m_temp->find( m_uids[m_current] ); 133 m_record = m_temp->find( m_uids[m_current] );
130 else 134 else
131 m_record = T(); 135 m_record = T();
132 136
133 return m_record; 137 return m_record;
134} 138}
135 139
136template <class T> 140template <class T>
137ORecordListIterator<T> &ORecordListIterator<T>::operator++() { 141ORecordListIterator<T> &ORecordListIterator<T>::operator++() {
138 if (m_current < m_uids.count() ) { 142 if (m_current < (int)m_uids.count() ) {
139 m_end = false; 143 m_end = false;
140 ++m_current; 144 ++m_current;
141 }else 145 }else
142 m_end = true; 146 m_end = true;
143 147
144 return *this; 148 return *this;
@@ -186,16 +190,19 @@ ORecordList<T>::ORecordList( const QArray<int>& ids,
186template <class T> 190template <class T>
187ORecordList<T>::~ORecordList() { 191ORecordList<T>::~ORecordList() {
188/* nothing to do here */ 192/* nothing to do here */
189} 193}
190template <class T> 194template <class T>
191ORecordList<T>::Iterator ORecordList<T>::begin() { 195ORecordList<T>::Iterator ORecordList<T>::begin() {
196 qWarning("ORecordList::begin");
192 Iterator it( m_ids, m_acc ); 197 Iterator it( m_ids, m_acc );
193 return it; 198 return it;
194} 199}
195template <class T> 200template <class T>
196ORecordList<T>::Iterator ORecordList<T>::end() { 201ORecordList<T>::Iterator ORecordList<T>::end() {
197 Iterator it( m_ids, m_acc ); 202 Iterator it( m_ids, m_acc );
198 it.m_end = true; 203 it.m_end = true;
199 it.m_current = m_ids.count(); 204 it.m_current = m_ids.count();
205
206 return it;
200} 207}
201#endif 208#endif