Diffstat (limited to 'core/pim/addressbook/abtable.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/addressbook/abtable.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/core/pim/addressbook/abtable.cpp b/core/pim/addressbook/abtable.cpp index 9297d6a..97f4a8f 100644 --- a/core/pim/addressbook/abtable.cpp +++ b/core/pim/addressbook/abtable.cpp | |||
@@ -125,13 +125,13 @@ AbTable::AbTable( const QValueList<int> *order, QWidget *parent, const char *nam | |||
125 | // #else | 125 | // #else |
126 | : QTable( parent, name ), | 126 | : QTable( parent, name ), |
127 | // #endif | 127 | // #endif |
128 | lastSortCol( -1 ), | 128 | lastSortCol( -1 ), |
129 | asc( TRUE ), | 129 | asc( TRUE ), |
130 | intFields( order ), | 130 | intFields( order ), |
131 | currFindRow( -2 ), | 131 | currFindRow( -1 ), |
132 | mCat( 0 ), | 132 | mCat( 0 ), |
133 | m_contactdb ("addressbook", 0l, 0l, false) // Handle syncing myself.. ! | 133 | m_contactdb ("addressbook", 0l, 0l, false) // Handle syncing myself.. ! |
134 | { | 134 | { |
135 | mCat.load( categoryFileName() ); | 135 | mCat.load( categoryFileName() ); |
136 | setSelectionMode( NoSelection ); | 136 | setSelectionMode( NoSelection ); |
137 | init(); | 137 | init(); |
@@ -635,41 +635,43 @@ void QTable::paintEmptyArea( QPainter *p, int cx, int cy, int cw, int ch ) | |||
635 | // } | 635 | // } |
636 | 636 | ||
637 | void AbTable::slotDoFind( const QString &findString, bool caseSensitive, | 637 | void AbTable::slotDoFind( const QString &findString, bool caseSensitive, |
638 | bool backwards, QString cat /* int category */ ) | 638 | bool backwards, QString cat /* int category */ ) |
639 | { | 639 | { |
640 | int category = 0; | 640 | int category = 0; |
641 | |||
642 | // Use the current Category if nothing else selected | ||
641 | if ( cat.isEmpty() ) | 643 | if ( cat.isEmpty() ) |
642 | category = -2; // mCat.id("Contacts", "All"); | 644 | category = mCat.id( "Contacts", showCat ); |
643 | else | 645 | else{ |
644 | category = mCat.id("Contacts", cat ); | 646 | category = mCat.id("Contacts", cat ); |
647 | } | ||
645 | 648 | ||
646 | qWarning ("Found in Category %d", category); | 649 | qWarning ("Found in Category %d", category); |
647 | 650 | ||
648 | if ( currFindRow < -1 ) | 651 | if ( currFindRow < -1 ) |
649 | currFindRow = currentRow() - 1; | 652 | currFindRow = - 1; |
653 | |||
650 | clearSelection( TRUE ); | 654 | clearSelection( TRUE ); |
651 | int rows, row; | 655 | int rows, row; |
652 | AbTableItem *ati; | 656 | AbTableItem *ati; |
653 | QRegExp r( findString ); | 657 | QRegExp r( findString ); |
654 | r.setCaseSensitive( caseSensitive ); | 658 | r.setCaseSensitive( caseSensitive ); |
655 | rows = numRows(); | 659 | rows = numRows(); |
656 | static bool wrapAround = true; | 660 | static bool wrapAround = true; |
657 | 661 | ||
658 | if ( !backwards ) { | 662 | if ( !backwards ) { |
659 | for ( row = currFindRow + 1; row < rows; row++ ) { | 663 | for ( row = currFindRow + 1; row < rows; row++ ) { |
660 | ati = static_cast<AbTableItem*>( item(row, 0) ); | 664 | ati = static_cast<AbTableItem*>( item(row, 0) ); |
661 | if ( contactCompare( contactList[ati], r, category ) ) | 665 | if ( contactCompare( contactList[ati], r, category ) ) |
662 | //if ( contactCompare( contactList[row], r, category ) ) | ||
663 | break; | 666 | break; |
664 | } | 667 | } |
665 | } else { | 668 | } else { |
666 | for ( row = currFindRow - 1; row > -1; row-- ) { | 669 | for ( row = currFindRow - 1; row > -1; row-- ) { |
667 | ati = static_cast<AbTableItem*>( item(row, 0) ); | 670 | ati = static_cast<AbTableItem*>( item(row, 0) ); |
668 | if ( contactCompare( contactList[ati], r, category ) ) | 671 | if ( contactCompare( contactList[ati], r, category ) ) |
669 | //if ( contactCompare( contactList[row], r, category ) ) | ||
670 | break; | 672 | break; |
671 | } | 673 | } |
672 | } | 674 | } |
673 | if ( row >= rows || row < 0 ) { | 675 | if ( row >= rows || row < 0 ) { |
674 | if ( row < 0 ) | 676 | if ( row < 0 ) |
675 | currFindRow = rows; | 677 | currFindRow = rows; |
@@ -685,25 +687,25 @@ void AbTable::slotDoFind( const QString &findString, bool caseSensitive, | |||
685 | } else { | 687 | } else { |
686 | currFindRow = row; | 688 | currFindRow = row; |
687 | QTableSelection foundSelection; | 689 | QTableSelection foundSelection; |
688 | foundSelection.init( currFindRow, 0 ); | 690 | foundSelection.init( currFindRow, 0 ); |
689 | foundSelection.expandTo( currFindRow, numCols() - 1 ); | 691 | foundSelection.expandTo( currFindRow, numCols() - 1 ); |
690 | addSelection( foundSelection ); | 692 | addSelection( foundSelection ); |
691 | setCurrentCell( currFindRow, numCols() - 1 ); | 693 | setCurrentCell( currFindRow, 0 /* numCols() - 1 */ ); |
692 | wrapAround = true; | 694 | wrapAround = true; |
693 | } | 695 | } |
694 | } | 696 | } |
695 | 697 | ||
696 | static bool contactCompare( const OContact &cnt, const QRegExp &r, int category ) | 698 | static bool contactCompare( const OContact &cnt, const QRegExp &r, int category ) |
697 | { | 699 | { |
698 | bool returnMe; | 700 | bool returnMe; |
699 | QArray<int> cats; | 701 | QArray<int> cats; |
700 | cats = cnt.categories(); | 702 | cats = cnt.categories(); |
701 | 703 | ||
702 | returnMe = false; | 704 | returnMe = false; |
703 | if ( (category == -1 && cats.count() == 0) || category == -2 ) | 705 | if ( (cats.count() == 0) || (category == 0) ) |
704 | returnMe = cnt.match( r ); | 706 | returnMe = cnt.match( r ); |
705 | else { | 707 | else { |
706 | int i; | 708 | int i; |
707 | for ( i = 0; i < int(cats.count()); i++ ) { | 709 | for ( i = 0; i < int(cats.count()); i++ ) { |
708 | if ( cats[i] == category ) { | 710 | if ( cats[i] == category ) { |
709 | returnMe = cnt.match( r ); | 711 | returnMe = cnt.match( r ); |