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