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 | |||
@@ -107,49 +107,49 @@ QWidget *AbPickItem::createEditor() const | |||
107 | 107 | ||
108 | void AbPickItem::setContentFromEditor( QWidget *w ) | 108 | void AbPickItem::setContentFromEditor( QWidget *w ) |
109 | { | 109 | { |
110 | if ( w->inherits("QComboBox") ) | 110 | if ( w->inherits("QComboBox") ) |
111 | setText( ( (QComboBox*)w )->currentText() ); | 111 | setText( ( (QComboBox*)w )->currentText() ); |
112 | else | 112 | else |
113 | QTableItem::setContentFromEditor( w ); | 113 | QTableItem::setContentFromEditor( w ); |
114 | } | 114 | } |
115 | 115 | ||
116 | /*! | 116 | /*! |
117 | \class AbTable abtable.h | 117 | \class AbTable abtable.h |
118 | 118 | ||
119 | \brief QTable based class for showing a list of entries | 119 | \brief QTable based class for showing a list of entries |
120 | */ | 120 | */ |
121 | 121 | ||
122 | AbTable::AbTable( const QValueList<int> *order, QWidget *parent, const char *name ) | 122 | AbTable::AbTable( const QValueList<int> *order, QWidget *parent, const char *name ) |
123 | // #ifdef QT_QTABLE_NOHEADER_CONSTRUCTOR | 123 | // #ifdef QT_QTABLE_NOHEADER_CONSTRUCTOR |
124 | // : QTable( 0, 0, parent, name, TRUE ), | 124 | // : QTable( 0, 0, parent, name, TRUE ), |
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(); |
138 | setSorting( TRUE ); | 138 | setSorting( TRUE ); |
139 | connect( this, SIGNAL(clicked(int,int,int,const QPoint &)), | 139 | connect( this, SIGNAL(clicked(int,int,int,const QPoint &)), |
140 | this, SLOT(itemClicked(int,int)) ); | 140 | this, SLOT(itemClicked(int,int)) ); |
141 | } | 141 | } |
142 | 142 | ||
143 | AbTable::~AbTable() | 143 | AbTable::~AbTable() |
144 | { | 144 | { |
145 | } | 145 | } |
146 | 146 | ||
147 | void AbTable::init() | 147 | void AbTable::init() |
148 | { | 148 | { |
149 | showChar = '\0'; | 149 | showChar = '\0'; |
150 | setNumRows( 0 ); | 150 | setNumRows( 0 ); |
151 | setNumCols( 2 ); | 151 | setNumCols( 2 ); |
152 | 152 | ||
153 | horizontalHeader()->setLabel( 0, tr( "Full Name" )); | 153 | horizontalHeader()->setLabel( 0, tr( "Full Name" )); |
154 | horizontalHeader()->setLabel( 1, tr( "Contact" )); | 154 | horizontalHeader()->setLabel( 1, tr( "Contact" )); |
155 | setLeftMargin( 0 ); | 155 | setLeftMargin( 0 ); |
@@ -617,111 +617,113 @@ void QTable::paintEmptyArea( QPainter *p, int cx, int cy, int cw, int ch ) | |||
617 | } | 617 | } |
618 | #endif | 618 | #endif |
619 | #endif | 619 | #endif |
620 | 620 | ||
621 | 621 | ||
622 | // int AbTable::rowHeight( int ) const | 622 | // int AbTable::rowHeight( int ) const |
623 | // { | 623 | // { |
624 | // return 18; | 624 | // return 18; |
625 | // } | 625 | // } |
626 | 626 | ||
627 | // int AbTable::rowPos( int row ) const | 627 | // int AbTable::rowPos( int row ) const |
628 | // { | 628 | // { |
629 | // return 18*row; | 629 | // return 18*row; |
630 | // } | 630 | // } |
631 | 631 | ||
632 | // int AbTable::rowAt( int pos ) const | 632 | // int AbTable::rowAt( int pos ) const |
633 | // { | 633 | // { |
634 | // return QMIN( pos/18, numRows()-1 ); | 634 | // return QMIN( pos/18, numRows()-1 ); |
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; |
676 | else | 678 | else |
677 | currFindRow = -1; | 679 | currFindRow = -1; |
678 | 680 | ||
679 | if ( wrapAround ) | 681 | if ( wrapAround ) |
680 | emit signalWrapAround(); | 682 | emit signalWrapAround(); |
681 | else | 683 | else |
682 | emit signalNotFound(); | 684 | emit signalNotFound(); |
683 | 685 | ||
684 | wrapAround = !wrapAround; | 686 | wrapAround = !wrapAround; |
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 ); |
710 | break; | 712 | break; |
711 | } | 713 | } |
712 | } | 714 | } |
713 | } | 715 | } |
714 | 716 | ||
715 | return returnMe; | 717 | return returnMe; |
716 | } | 718 | } |
717 | 719 | ||
718 | void AbTable::fitColumns() | 720 | void AbTable::fitColumns() |
719 | { | 721 | { |
720 | int contentsWidth = visibleWidth() / 2; | 722 | int contentsWidth = visibleWidth() / 2; |
721 | 723 | ||
722 | if ( showBk == "Cards" ) { | 724 | if ( showBk == "Cards" ) { |
723 | showColumn(1); | 725 | showColumn(1); |
724 | //adjustColumn(1); | 726 | //adjustColumn(1); |
725 | setColumnWidth( 1, visibleWidth() ); | 727 | setColumnWidth( 1, visibleWidth() ); |
726 | columnVisible = false; | 728 | columnVisible = false; |
727 | } else { | 729 | } else { |