summaryrefslogtreecommitdiff
path: root/core/pim/addressbook/abtable.cpp
Unidiff
Diffstat (limited to 'core/pim/addressbook/abtable.cpp') (more/less context) (show whitespace changes)
-rw-r--r--core/pim/addressbook/abtable.cpp20
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
@@ -686,30 +686,40 @@ void AbTable::slotDoFind( const QString &findString, bool caseSensitive, bool us
686 r.setWildcard( !useRegExp ); 686 r.setWildcard( !useRegExp );
687 rows = numRows(); 687 rows = numRows();
688 static bool wrapAround = true; 688 static bool wrapAround = true;
689 bool try_again = false;
689 690
691 // We will loop until we found an entry or found nothing.
692 do {
690 if ( !backwards ) { 693 if ( !backwards ) {
691 for ( row = currFindRow + 1; row < rows; row++ ) { 694 for ( row = currFindRow + 1; row < rows; row++ ) {
692 ati = static_cast<AbTableItem*>( item(row, 0) ); 695 ati = static_cast<AbTableItem*>( item(row, 0) );
693 if ( contactCompare( contactList[ati], r, category ) ) 696 if ( contactCompare( contactList[ati], r, category ) ){
697 try_again = false;
694 break; 698 break;
695 } 699 }
700 }
696 } else { 701 } else {
697 for ( row = currFindRow - 1; row > -1; row-- ) { 702 for ( row = currFindRow - 1; row > -1; row-- ) {
698 ati = static_cast<AbTableItem*>( item(row, 0) ); 703 ati = static_cast<AbTableItem*>( item(row, 0) );
699 if ( contactCompare( contactList[ati], r, category ) ) 704 if ( contactCompare( contactList[ati], r, category ) ){
705 try_again = false;
700 break; 706 break;
701 } 707 }
702 } 708 }
709 }
703 if ( row >= rows || row < 0 ) { 710 if ( row >= rows || row < 0 ) {
704 if ( row < 0 ) 711 if ( row < 0 )
705 currFindRow = rows; 712 currFindRow = rows;
706 else 713 else
707 currFindRow = -1; 714 currFindRow = -1;
708 715
709 if ( wrapAround ) 716 if ( wrapAround ){
710 emit signalWrapAround(); 717 emit signalWrapAround();
711 else 718 try_again = true;
719 }else{
712 emit signalNotFound(); 720 emit signalNotFound();
721 try_again = false;
722 }
713 723
714 wrapAround = !wrapAround; 724 wrapAround = !wrapAround;
715 } else { 725 } else {
@@ -720,7 +730,9 @@ void AbTable::slotDoFind( const QString &findString, bool caseSensitive, bool us
720 addSelection( foundSelection ); 730 addSelection( foundSelection );
721 setCurrentCell( currFindRow, 0 /* numCols() - 1 */ ); 731 setCurrentCell( currFindRow, 0 /* numCols() - 1 */ );
722 wrapAround = true; 732 wrapAround = true;
733 try_again = false;
723 } 734 }
735 } while ( try_again );
724} 736}
725 737
726static bool contactCompare( const OContact &cnt, const QRegExp &r, int category ) 738static bool contactCompare( const OContact &cnt, const QRegExp &r, int category )