summaryrefslogtreecommitdiff
authorsimon <simon>2003-01-01 12:40:02 (UTC)
committer simon <simon>2003-01-01 12:40:02 (UTC)
commit25d85fe77aac5763ccc50bd532c2e661f4a64d1b (patch) (unidiff)
tree28a4a01f3bf232599db4f6c0d14162d6ac61bbd3
parent31cbc7a5e6cc0a52b58d4de34cc8581a18bc4527 (diff)
downloadopie-25d85fe77aac5763ccc50bd532c2e661f4a64d1b.zip
opie-25d85fe77aac5763ccc50bd532c2e661f4a64d1b.tar.gz
opie-25d85fe77aac5763ccc50bd532c2e661f4a64d1b.tar.bz2
T ORecordList<T>::operator[]( uint i ) {
- if ( i < 0 || (i+1) > m_ids.count() ) + if ( i >= m_ids.count() ) -> fix warning and simplify :)
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/orecordlist.h2
-rw-r--r--libopie2/opiepim/orecordlist.h2
2 files changed, 2 insertions, 2 deletions
diff --git a/libopie/pim/orecordlist.h b/libopie/pim/orecordlist.h
index b77a4ab..edcd729 100644
--- a/libopie/pim/orecordlist.h
+++ b/libopie/pim/orecordlist.h
@@ -172,129 +172,129 @@ T ORecordListIterator<T>::operator*() {
172 else 172 else
173 m_record = T(); 173 m_record = T();
174 174
175 return m_record; 175 return m_record;
176} 176}
177 177
178template <class T> 178template <class T>
179ORecordListIterator<T> &ORecordListIterator<T>::operator++() { 179ORecordListIterator<T> &ORecordListIterator<T>::operator++() {
180 m_direction = true; 180 m_direction = true;
181 if (m_current < m_uids.count() ) { 181 if (m_current < m_uids.count() ) {
182 m_end = false; 182 m_end = false;
183 ++m_current; 183 ++m_current;
184 }else 184 }else
185 m_end = true; 185 m_end = true;
186 186
187 return *this; 187 return *this;
188} 188}
189template <class T> 189template <class T>
190ORecordListIterator<T> &ORecordListIterator<T>::operator--() { 190ORecordListIterator<T> &ORecordListIterator<T>::operator--() {
191 m_direction = false; 191 m_direction = false;
192 if ( m_current > 0 ) { 192 if ( m_current > 0 ) {
193 --m_current; 193 --m_current;
194 m_end = false; 194 m_end = false;
195 } else 195 } else
196 m_end = true; 196 m_end = true;
197 197
198 return *this; 198 return *this;
199} 199}
200 200
201template <class T> 201template <class T>
202bool ORecordListIterator<T>::operator==( const ORecordListIterator<T>& it ) { 202bool ORecordListIterator<T>::operator==( const ORecordListIterator<T>& it ) {
203 203
204 /* if both are at we're the same.... */ 204 /* if both are at we're the same.... */
205 if ( m_end == it.m_end ) return true; 205 if ( m_end == it.m_end ) return true;
206 206
207 if ( m_uids != it.m_uids ) return false; 207 if ( m_uids != it.m_uids ) return false;
208 if ( m_current != it.m_current ) return false; 208 if ( m_current != it.m_current ) return false;
209 if ( m_temp != it.m_temp ) return false; 209 if ( m_temp != it.m_temp ) return false;
210 210
211 return true; 211 return true;
212} 212}
213template <class T> 213template <class T>
214bool ORecordListIterator<T>::operator!=( const ORecordListIterator<T>& it ) { 214bool ORecordListIterator<T>::operator!=( const ORecordListIterator<T>& it ) {
215 return !(*this == it ); 215 return !(*this == it );
216} 216}
217template <class T> 217template <class T>
218ORecordListIterator<T>::ORecordListIterator( const QArray<int> uids, 218ORecordListIterator<T>::ORecordListIterator( const QArray<int> uids,
219 const Base* t ) 219 const Base* t )
220 : m_uids( uids ), m_current( 0 ), m_temp( t ), m_end( false ), 220 : m_uids( uids ), m_current( 0 ), m_temp( t ), m_end( false ),
221 m_direction( false ) 221 m_direction( false )
222{ 222{
223} 223}
224template <class T> 224template <class T>
225uint ORecordListIterator<T>::current()const { 225uint ORecordListIterator<T>::current()const {
226 return m_current; 226 return m_current;
227} 227}
228template <class T> 228template <class T>
229void ORecordListIterator<T>::setCurrent( uint cur ) { 229void ORecordListIterator<T>::setCurrent( uint cur ) {
230 if( cur < m_uids.count() ) { 230 if( cur < m_uids.count() ) {
231 m_end = false; 231 m_end = false;
232 m_current= cur; 232 m_current= cur;
233 } 233 }
234} 234}
235template <class T> 235template <class T>
236uint ORecordListIterator<T>::count()const { 236uint ORecordListIterator<T>::count()const {
237 return m_uids.count(); 237 return m_uids.count();
238} 238}
239template <class T> 239template <class T>
240ORecordList<T>::ORecordList( const QArray<int>& ids, 240ORecordList<T>::ORecordList( const QArray<int>& ids,
241 const Base* acc ) 241 const Base* acc )
242 : m_ids( ids ), m_acc( acc ) 242 : m_ids( ids ), m_acc( acc )
243{ 243{
244} 244}
245template <class T> 245template <class T>
246ORecordList<T>::~ORecordList() { 246ORecordList<T>::~ORecordList() {
247/* nothing to do here */ 247/* nothing to do here */
248} 248}
249template <class T> 249template <class T>
250typename ORecordList<T>::Iterator ORecordList<T>::begin() { 250typename ORecordList<T>::Iterator ORecordList<T>::begin() {
251 Iterator it( m_ids, m_acc ); 251 Iterator it( m_ids, m_acc );
252 return it; 252 return it;
253} 253}
254template <class T> 254template <class T>
255typename ORecordList<T>::Iterator ORecordList<T>::end() { 255typename ORecordList<T>::Iterator ORecordList<T>::end() {
256 Iterator it( m_ids, m_acc ); 256 Iterator it( m_ids, m_acc );
257 it.m_end = true; 257 it.m_end = true;
258 it.m_current = m_ids.count(); 258 it.m_current = m_ids.count();
259 259
260 return it; 260 return it;
261} 261}
262template <class T> 262template <class T>
263uint ORecordList<T>::count()const { 263uint ORecordList<T>::count()const {
264return m_ids.count(); 264return m_ids.count();
265} 265}
266template <class T> 266template <class T>
267T ORecordList<T>::operator[]( uint i ) { 267T ORecordList<T>::operator[]( uint i ) {
268 if ( i < 0 || (i+1) > m_ids.count() ) 268 if ( i >= m_ids.count() )
269 return T(); 269 return T();
270 /* forward */ 270 /* forward */
271 return m_acc->find( m_ids[i], m_ids, i ); 271 return m_acc->find( m_ids[i], m_ids, i );
272} 272}
273template <class T> 273template <class T>
274int ORecordList<T>::uidAt( uint i ) { 274int ORecordList<T>::uidAt( uint i ) {
275 return m_ids[i]; 275 return m_ids[i];
276} 276}
277 277
278template <class T> 278template <class T>
279bool ORecordList<T>::remove( int uid ) { 279bool ORecordList<T>::remove( int uid ) {
280 QArray<int> copy( m_ids.count() ); 280 QArray<int> copy( m_ids.count() );
281 int counter = 0; 281 int counter = 0;
282 bool ret_val = false; 282 bool ret_val = false;
283 283
284 for (uint i = 0; i < m_ids.count(); i++){ 284 for (uint i = 0; i < m_ids.count(); i++){
285 if ( m_ids[i] != uid ){ 285 if ( m_ids[i] != uid ){
286 copy[counter++] = m_ids[i]; 286 copy[counter++] = m_ids[i];
287 287
288 }else 288 }else
289 ret_val = true; 289 ret_val = true;
290 } 290 }
291 291
292 copy.resize( counter ); 292 copy.resize( counter );
293 m_ids = copy; 293 m_ids = copy;
294 294
295 295
296 return ret_val; 296 return ret_val;
297} 297}
298 298
299 299
300#endif 300#endif
diff --git a/libopie2/opiepim/orecordlist.h b/libopie2/opiepim/orecordlist.h
index b77a4ab..edcd729 100644
--- a/libopie2/opiepim/orecordlist.h
+++ b/libopie2/opiepim/orecordlist.h
@@ -172,129 +172,129 @@ T ORecordListIterator<T>::operator*() {
172 else 172 else
173 m_record = T(); 173 m_record = T();
174 174
175 return m_record; 175 return m_record;
176} 176}
177 177
178template <class T> 178template <class T>
179ORecordListIterator<T> &ORecordListIterator<T>::operator++() { 179ORecordListIterator<T> &ORecordListIterator<T>::operator++() {
180 m_direction = true; 180 m_direction = true;
181 if (m_current < m_uids.count() ) { 181 if (m_current < m_uids.count() ) {
182 m_end = false; 182 m_end = false;
183 ++m_current; 183 ++m_current;
184 }else 184 }else
185 m_end = true; 185 m_end = true;
186 186
187 return *this; 187 return *this;
188} 188}
189template <class T> 189template <class T>
190ORecordListIterator<T> &ORecordListIterator<T>::operator--() { 190ORecordListIterator<T> &ORecordListIterator<T>::operator--() {
191 m_direction = false; 191 m_direction = false;
192 if ( m_current > 0 ) { 192 if ( m_current > 0 ) {
193 --m_current; 193 --m_current;
194 m_end = false; 194 m_end = false;
195 } else 195 } else
196 m_end = true; 196 m_end = true;
197 197
198 return *this; 198 return *this;
199} 199}
200 200
201template <class T> 201template <class T>
202bool ORecordListIterator<T>::operator==( const ORecordListIterator<T>& it ) { 202bool ORecordListIterator<T>::operator==( const ORecordListIterator<T>& it ) {
203 203
204 /* if both are at we're the same.... */ 204 /* if both are at we're the same.... */
205 if ( m_end == it.m_end ) return true; 205 if ( m_end == it.m_end ) return true;
206 206
207 if ( m_uids != it.m_uids ) return false; 207 if ( m_uids != it.m_uids ) return false;
208 if ( m_current != it.m_current ) return false; 208 if ( m_current != it.m_current ) return false;
209 if ( m_temp != it.m_temp ) return false; 209 if ( m_temp != it.m_temp ) return false;
210 210
211 return true; 211 return true;
212} 212}
213template <class T> 213template <class T>
214bool ORecordListIterator<T>::operator!=( const ORecordListIterator<T>& it ) { 214bool ORecordListIterator<T>::operator!=( const ORecordListIterator<T>& it ) {
215 return !(*this == it ); 215 return !(*this == it );
216} 216}
217template <class T> 217template <class T>
218ORecordListIterator<T>::ORecordListIterator( const QArray<int> uids, 218ORecordListIterator<T>::ORecordListIterator( const QArray<int> uids,
219 const Base* t ) 219 const Base* t )
220 : m_uids( uids ), m_current( 0 ), m_temp( t ), m_end( false ), 220 : m_uids( uids ), m_current( 0 ), m_temp( t ), m_end( false ),
221 m_direction( false ) 221 m_direction( false )
222{ 222{
223} 223}
224template <class T> 224template <class T>
225uint ORecordListIterator<T>::current()const { 225uint ORecordListIterator<T>::current()const {
226 return m_current; 226 return m_current;
227} 227}
228template <class T> 228template <class T>
229void ORecordListIterator<T>::setCurrent( uint cur ) { 229void ORecordListIterator<T>::setCurrent( uint cur ) {
230 if( cur < m_uids.count() ) { 230 if( cur < m_uids.count() ) {
231 m_end = false; 231 m_end = false;
232 m_current= cur; 232 m_current= cur;
233 } 233 }
234} 234}
235template <class T> 235template <class T>
236uint ORecordListIterator<T>::count()const { 236uint ORecordListIterator<T>::count()const {
237 return m_uids.count(); 237 return m_uids.count();
238} 238}
239template <class T> 239template <class T>
240ORecordList<T>::ORecordList( const QArray<int>& ids, 240ORecordList<T>::ORecordList( const QArray<int>& ids,
241 const Base* acc ) 241 const Base* acc )
242 : m_ids( ids ), m_acc( acc ) 242 : m_ids( ids ), m_acc( acc )
243{ 243{
244} 244}
245template <class T> 245template <class T>
246ORecordList<T>::~ORecordList() { 246ORecordList<T>::~ORecordList() {
247/* nothing to do here */ 247/* nothing to do here */
248} 248}
249template <class T> 249template <class T>
250typename ORecordList<T>::Iterator ORecordList<T>::begin() { 250typename ORecordList<T>::Iterator ORecordList<T>::begin() {
251 Iterator it( m_ids, m_acc ); 251 Iterator it( m_ids, m_acc );
252 return it; 252 return it;
253} 253}
254template <class T> 254template <class T>
255typename ORecordList<T>::Iterator ORecordList<T>::end() { 255typename ORecordList<T>::Iterator ORecordList<T>::end() {
256 Iterator it( m_ids, m_acc ); 256 Iterator it( m_ids, m_acc );
257 it.m_end = true; 257 it.m_end = true;
258 it.m_current = m_ids.count(); 258 it.m_current = m_ids.count();
259 259
260 return it; 260 return it;
261} 261}
262template <class T> 262template <class T>
263uint ORecordList<T>::count()const { 263uint ORecordList<T>::count()const {
264return m_ids.count(); 264return m_ids.count();
265} 265}
266template <class T> 266template <class T>
267T ORecordList<T>::operator[]( uint i ) { 267T ORecordList<T>::operator[]( uint i ) {
268 if ( i < 0 || (i+1) > m_ids.count() ) 268 if ( i >= m_ids.count() )
269 return T(); 269 return T();
270 /* forward */ 270 /* forward */
271 return m_acc->find( m_ids[i], m_ids, i ); 271 return m_acc->find( m_ids[i], m_ids, i );
272} 272}
273template <class T> 273template <class T>
274int ORecordList<T>::uidAt( uint i ) { 274int ORecordList<T>::uidAt( uint i ) {
275 return m_ids[i]; 275 return m_ids[i];
276} 276}
277 277
278template <class T> 278template <class T>
279bool ORecordList<T>::remove( int uid ) { 279bool ORecordList<T>::remove( int uid ) {
280 QArray<int> copy( m_ids.count() ); 280 QArray<int> copy( m_ids.count() );
281 int counter = 0; 281 int counter = 0;
282 bool ret_val = false; 282 bool ret_val = false;
283 283
284 for (uint i = 0; i < m_ids.count(); i++){ 284 for (uint i = 0; i < m_ids.count(); i++){
285 if ( m_ids[i] != uid ){ 285 if ( m_ids[i] != uid ){
286 copy[counter++] = m_ids[i]; 286 copy[counter++] = m_ids[i];
287 287
288 }else 288 }else
289 ret_val = true; 289 ret_val = true;
290 } 290 }
291 291
292 copy.resize( counter ); 292 copy.resize( counter );
293 m_ids = copy; 293 m_ids = copy;
294 294
295 295
296 return ret_val; 296 return ret_val;
297} 297}
298 298
299 299
300#endif 300#endif