summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/orecordlist.h
Unidiff
Diffstat (limited to 'libopie2/opiepim/orecordlist.h') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/orecordlist.h12
1 files changed, 6 insertions, 6 deletions
diff --git a/libopie2/opiepim/orecordlist.h b/libopie2/opiepim/orecordlist.h
index 75bb33c..36728b8 100644
--- a/libopie2/opiepim/orecordlist.h
+++ b/libopie2/opiepim/orecordlist.h
@@ -19,49 +19,49 @@ template <class T = OPimRecord>
19class ORecordListIterator { 19class ORecordListIterator {
20 friend class ORecordList<T>; 20 friend class ORecordList<T>;
21public: 21public:
22 typedef OTemplateBase<T> Base; 22 typedef OTemplateBase<T> Base;
23 23
24 /** 24 /**
25 * The c'tor used internally from 25 * The c'tor used internally from
26 * ORecordList 26 * ORecordList
27 */ 27 */
28 ORecordListIterator( const QArray<int>, const Base* ); 28 ORecordListIterator( const QArray<int>, const Base* );
29 29
30 /** 30 /**
31 * The standard c'tor 31 * The standard c'tor
32 */ 32 */
33 ORecordListIterator(); 33 ORecordListIterator();
34 ~ORecordListIterator(); 34 ~ORecordListIterator();
35 35
36 ORecordListIterator( const ORecordListIterator& ); 36 ORecordListIterator( const ORecordListIterator& );
37 ORecordListIterator &operator=(const ORecordListIterator& ); 37 ORecordListIterator &operator=(const ORecordListIterator& );
38 38
39 /** 39 /**
40 * a * operator ;) 40 * a * operator ;)
41 * use it like this T = (*it); 41 * use it like this T = (*it);
42 */ 42 */
43 T &operator*(); 43 T operator*();
44 ORecordListIterator &operator++(); 44 ORecordListIterator &operator++();
45 ORecordListIterator &operator--(); 45 ORecordListIterator &operator--();
46 46
47 bool operator==( const ORecordListIterator& it ); 47 bool operator==( const ORecordListIterator& it );
48 bool operator!=( const ORecordListIterator& it ); 48 bool operator!=( const ORecordListIterator& it );
49 49
50private: 50private:
51 QArray<int> m_uids; 51 QArray<int> m_uids;
52 int m_current; 52 int m_current;
53 const Base* m_temp; 53 const Base* m_temp;
54 bool m_end : 1; 54 bool m_end : 1;
55 T m_record; 55 T m_record;
56 56
57 /* d pointer for future versions */ 57 /* d pointer for future versions */
58 class IteratorPrivate; 58 class IteratorPrivate;
59 IteratorPrivate *d; 59 IteratorPrivate *d;
60}; 60};
61/** 61/**
62 * The recordlist used as a return type 62 * The recordlist used as a return type
63 * from OPimAccessTemplate 63 * from OPimAccessTemplate
64 */ 64 */
65template <class T = OPimRecord > 65template <class T = OPimRecord >
66class ORecordList { 66class ORecordList {
67public: 67public:
@@ -78,78 +78,79 @@ public:
78 /** 78 /**
79 * the first iterator 79 * the first iterator
80 */ 80 */
81 Iterator begin(); 81 Iterator begin();
82 82
83 /** 83 /**
84 * the end 84 * the end
85 */ 85 */
86 Iterator end(); 86 Iterator end();
87 /* 87 /*
88 ConstIterator begin()const; 88 ConstIterator begin()const;
89 ConstIterator end()const; 89 ConstIterator end()const;
90 */ 90 */
91private: 91private:
92 QArray<int> m_ids; 92 QArray<int> m_ids;
93 const Base* m_acc; 93 const Base* m_acc;
94}; 94};
95 95
96/* ok now implement it */ 96/* ok now implement it */
97template <class T> 97template <class T>
98ORecordListIterator<T>::ORecordListIterator() { 98ORecordListIterator<T>::ORecordListIterator() {
99 m_current = 0; 99 m_current = 0;
100 m_temp = 0l; 100 m_temp = 0l;
101 m_end = true; 101 m_end = true;
102 m_record = T();
102} 103}
103template <class T> 104template <class T>
104ORecordListIterator<T>::~ORecordListIterator() { 105ORecordListIterator<T>::~ORecordListIterator() {
105/* nothing to delete */ 106/* nothing to delete */
106} 107}
107 108
108template <class T> 109template <class T>
109ORecordListIterator<T>::ORecordListIterator( const ORecordListIterator<T>& it) { 110ORecordListIterator<T>::ORecordListIterator( const ORecordListIterator<T>& it) {
110 qWarning("ORecordListIterator"); 111// qWarning("ORecordListIterator copy c'tor");
111 m_uids = it.m_uids; 112 m_uids = it.m_uids;
112 m_current = it.m_current; 113 m_current = it.m_current;
113 m_temp = it.m_temp; 114 m_temp = it.m_temp;
114 m_end = it.m_end; 115 m_end = it.m_end;
115 m_record = it.m_record; 116 m_record = it.m_record;
116} 117}
117 118
118template <class T> 119template <class T>
119ORecordListIterator<T> &ORecordListIterator<T>::operator=( const ORecordListIterator<T>& it) { 120ORecordListIterator<T> &ORecordListIterator<T>::operator=( const ORecordListIterator<T>& it) {
120 m_uids = it.m_uids; 121 m_uids = it.m_uids;
121 m_current = it.m_current; 122 m_current = it.m_current;
122 m_temp = it.m_temp; 123 m_temp = it.m_temp;
123 m_end = it.m_end; 124 m_end = it.m_end;
124 m_record = it.m_record; 125// m_record = it.m_record;
125 126
126 return *this; 127 return *this;
127} 128}
128 129
129template <class T> 130template <class T>
130T &ORecordListIterator<T>::operator*() { 131T ORecordListIterator<T>::operator*() {
131 qWarning("operator* %d %d", m_current, m_uids[m_current] ); 132// qWarning("operator* %d %d", m_current, m_uids[m_current] );
132 if (!m_end ) 133 if (!m_end )
133 m_record = m_temp->find( m_uids[m_current] ); 134 m_record = m_temp->find( m_uids[m_current] );
134 else 135 else
135 m_record = T(); 136 m_record = T();
136 137
137 return m_record; 138 return m_record;
138} 139}
139 140
140template <class T> 141template <class T>
141ORecordListIterator<T> &ORecordListIterator<T>::operator++() { 142ORecordListIterator<T> &ORecordListIterator<T>::operator++() {
142 if (m_current < (int)m_uids.count() ) { 143 if (m_current < (int)m_uids.count() ) {
143 m_end = false; 144 m_end = false;
144 ++m_current; 145 ++m_current;
145 }else 146 }else
146 m_end = true; 147 m_end = true;
147 148
148 return *this; 149 return *this;
149} 150}
150template <class T> 151template <class T>
151ORecordListIterator<T> &ORecordListIterator<T>::operator--() { 152ORecordListIterator<T> &ORecordListIterator<T>::operator--() {
152 if ( m_current > 0 ) { 153 if ( m_current > 0 ) {
153 --m_current; 154 --m_current;
154 m_end = false; 155 m_end = false;
155 } else 156 } else
@@ -172,37 +173,36 @@ bool ORecordListIterator<T>::operator==( const ORecordListIterator<T>& it ) {
172} 173}
173template <class T> 174template <class T>
174bool ORecordListIterator<T>::operator!=( const ORecordListIterator<T>& it ) { 175bool ORecordListIterator<T>::operator!=( const ORecordListIterator<T>& it ) {
175 return !(*this == it ); 176 return !(*this == it );
176} 177}
177template <class T> 178template <class T>
178ORecordListIterator<T>::ORecordListIterator( const QArray<int> uids, 179ORecordListIterator<T>::ORecordListIterator( const QArray<int> uids,
179 const Base* t ) 180 const Base* t )
180 : m_uids( uids ), m_current( 0 ), m_temp( t ), m_end( false ) 181 : m_uids( uids ), m_current( 0 ), m_temp( t ), m_end( false )
181{ 182{
182} 183}
183 184
184template <class T> 185template <class T>
185ORecordList<T>::ORecordList( const QArray<int>& ids, 186ORecordList<T>::ORecordList( const QArray<int>& ids,
186 const Base* acc ) 187 const Base* acc )
187 : m_ids( ids ), m_acc( acc ) 188 : m_ids( ids ), m_acc( acc )
188{ 189{
189} 190}
190template <class T> 191template <class T>
191ORecordList<T>::~ORecordList() { 192ORecordList<T>::~ORecordList() {
192/* nothing to do here */ 193/* nothing to do here */
193} 194}
194template <class T> 195template <class T>
195ORecordList<T>::Iterator ORecordList<T>::begin() { 196ORecordList<T>::Iterator ORecordList<T>::begin() {
196 qWarning("ORecordList::begin");
197 Iterator it( m_ids, m_acc ); 197 Iterator it( m_ids, m_acc );
198 return it; 198 return it;
199} 199}
200template <class T> 200template <class T>
201ORecordList<T>::Iterator ORecordList<T>::end() { 201ORecordList<T>::Iterator ORecordList<T>::end() {
202 Iterator it( m_ids, m_acc ); 202 Iterator it( m_ids, m_acc );
203 it.m_end = true; 203 it.m_end = true;
204 it.m_current = m_ids.count(); 204 it.m_current = m_ids.count();
205 205
206 return it; 206 return it;
207} 207}
208#endif 208#endif