Diffstat (limited to 'core/pim/addressbook/abtable.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/pim/addressbook/abtable.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/core/pim/addressbook/abtable.cpp b/core/pim/addressbook/abtable.cpp index 97b26db..4feadeb 100644 --- a/core/pim/addressbook/abtable.cpp +++ b/core/pim/addressbook/abtable.cpp @@ -677,59 +677,71 @@ void AbTable::slotDoFind( const QString &findString, bool caseSensitive, bool us if ( currFindRow < -1 ) currFindRow = - 1; clearSelection( TRUE ); int rows, row; AbTableItem *ati; QRegExp r( findString ); r.setCaseSensitive( caseSensitive ); r.setWildcard( !useRegExp ); rows = numRows(); static bool wrapAround = true; + bool try_again = false; + // We will loop until we found an entry or found nothing. + do { if ( !backwards ) { for ( row = currFindRow + 1; row < rows; row++ ) { ati = static_cast<AbTableItem*>( item(row, 0) ); - if ( contactCompare( contactList[ati], r, category ) ) + if ( contactCompare( contactList[ati], r, category ) ){ + try_again = false; break; } + } } else { for ( row = currFindRow - 1; row > -1; row-- ) { ati = static_cast<AbTableItem*>( item(row, 0) ); - if ( contactCompare( contactList[ati], r, category ) ) + if ( contactCompare( contactList[ati], r, category ) ){ + try_again = false; break; } } + } if ( row >= rows || row < 0 ) { if ( row < 0 ) currFindRow = rows; else currFindRow = -1; - if ( wrapAround ) + if ( wrapAround ){ emit signalWrapAround(); - else + try_again = true; + }else{ emit signalNotFound(); + try_again = false; + } wrapAround = !wrapAround; } else { currFindRow = row; QTableSelection foundSelection; foundSelection.init( currFindRow, 0 ); foundSelection.expandTo( currFindRow, numCols() - 1 ); addSelection( foundSelection ); setCurrentCell( currFindRow, 0 /* numCols() - 1 */ ); wrapAround = true; + try_again = false; } + } while ( try_again ); } static bool contactCompare( const OContact &cnt, const QRegExp &r, int category ) { bool returnMe; QArray<int> cats; cats = cnt.categories(); returnMe = false; if ( (cats.count() == 0) || (category == 0) ) returnMe = cnt.match( r ); else { |