Diffstat (limited to 'libopie2/opiepim/orecordlist.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiepim/orecordlist.h | 12 |
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> | |||
19 | class ORecordListIterator { | 19 | class ORecordListIterator { |
20 | friend class ORecordList<T>; | 20 | friend class ORecordList<T>; |
21 | public: | 21 | public: |
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 | ||
50 | private: | 50 | private: |
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 | */ |
65 | template <class T = OPimRecord > | 65 | template <class T = OPimRecord > |
66 | class ORecordList { | 66 | class ORecordList { |
67 | public: | 67 | public: |
@@ -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 | */ |
91 | private: | 91 | private: |
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 */ |
97 | template <class T> | 97 | template <class T> |
98 | ORecordListIterator<T>::ORecordListIterator() { | 98 | ORecordListIterator<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 | } |
103 | template <class T> | 104 | template <class T> |
104 | ORecordListIterator<T>::~ORecordListIterator() { | 105 | ORecordListIterator<T>::~ORecordListIterator() { |
105 | /* nothing to delete */ | 106 | /* nothing to delete */ |
106 | } | 107 | } |
107 | 108 | ||
108 | template <class T> | 109 | template <class T> |
109 | ORecordListIterator<T>::ORecordListIterator( const ORecordListIterator<T>& it) { | 110 | ORecordListIterator<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 | ||
118 | template <class T> | 119 | template <class T> |
119 | ORecordListIterator<T> &ORecordListIterator<T>::operator=( const ORecordListIterator<T>& it) { | 120 | ORecordListIterator<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 | ||
129 | template <class T> | 130 | template <class T> |
130 | T &ORecordListIterator<T>::operator*() { | 131 | T 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 | ||
140 | template <class T> | 141 | template <class T> |
141 | ORecordListIterator<T> &ORecordListIterator<T>::operator++() { | 142 | ORecordListIterator<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 | } |
150 | template <class T> | 151 | template <class T> |
151 | ORecordListIterator<T> &ORecordListIterator<T>::operator--() { | 152 | ORecordListIterator<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 | } |
173 | template <class T> | 174 | template <class T> |
174 | bool ORecordListIterator<T>::operator!=( const ORecordListIterator<T>& it ) { | 175 | bool ORecordListIterator<T>::operator!=( const ORecordListIterator<T>& it ) { |
175 | return !(*this == it ); | 176 | return !(*this == it ); |
176 | } | 177 | } |
177 | template <class T> | 178 | template <class T> |
178 | ORecordListIterator<T>::ORecordListIterator( const QArray<int> uids, | 179 | ORecordListIterator<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 | ||
184 | template <class T> | 185 | template <class T> |
185 | ORecordList<T>::ORecordList( const QArray<int>& ids, | 186 | ORecordList<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 | } |
190 | template <class T> | 191 | template <class T> |
191 | ORecordList<T>::~ORecordList() { | 192 | ORecordList<T>::~ORecordList() { |
192 | /* nothing to do here */ | 193 | /* nothing to do here */ |
193 | } | 194 | } |
194 | template <class T> | 195 | template <class T> |
195 | ORecordList<T>::Iterator ORecordList<T>::begin() { | 196 | ORecordList<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 | } |
200 | template <class T> | 200 | template <class T> |
201 | ORecordList<T>::Iterator ORecordList<T>::end() { | 201 | ORecordList<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 |