summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/abtable.cpp36
-rw-r--r--core/pim/addressbook/abtable.h1
2 files changed, 35 insertions, 2 deletions
diff --git a/core/pim/addressbook/abtable.cpp b/core/pim/addressbook/abtable.cpp
index 55b1ba1..a829dc2 100644
--- a/core/pim/addressbook/abtable.cpp
+++ b/core/pim/addressbook/abtable.cpp
@@ -541,129 +541,161 @@ QStringList AbTable::choiceSelection(int /*index*/) const
541 QString selname = choicenames.at(index); 541 QString selname = choicenames.at(index);
542 for (each row) { 542 for (each row) {
543 OContact *c = contactForRow(row); 543 OContact *c = contactForRow(row);
544 if ( text(row,2) == selname ) { 544 if ( text(row,2) == selname ) {
545 r.append(c->email); 545 r.append(c->email);
546 } 546 }
547 } 547 }
548 548
549 */ 549 */
550 return r; 550 return r;
551} 551}
552 552
553 553
554 554
555 555
556void AbTable::updateVisible() 556void AbTable::updateVisible()
557{ 557{
558 //qWarning("void AbTable::updateVisible()"); 558 //qWarning("void AbTable::updateVisible()");
559 559
560 int visible, 560 int visible,
561 totalRows, 561 totalRows,
562 row, 562 row,
563 selectedRow = 0; 563 selectedRow = 0;
564 564
565 visible = 0; 565 visible = 0;
566 566
567 setPaintingEnabled( FALSE ); 567 setPaintingEnabled( FALSE );
568 568
569 realignTable(); 569 realignTable();
570 570
571 totalRows = numRows(); 571 totalRows = numRows();
572 for ( row = 0; row < totalRows; row++ ) { 572 for ( row = 0; row < totalRows; row++ ) {
573 if ( rowHeight(row) == 0 ) { 573 if ( rowHeight(row) == 0 ) {
574 showRow( row ); 574 showRow( row );
575 adjustRow( row ); 575 adjustRow( row );
576 if ( isSelected( row,0 ) || isSelected( row,1 ) ) 576 if ( isSelected( row,0 ) || isSelected( row,1 ) )
577 selectedRow = row; 577 selectedRow = row;
578 } 578 }
579 visible++; 579 visible++;
580 } 580 }
581 581
582 if ( selectedRow ) 582 if ( selectedRow )
583 setCurrentCell( selectedRow, 0 ); 583 setCurrentCell( selectedRow, 0 );
584 584
585 if ( !visible ) 585 if ( !visible )
586 setCurrentCell( -1, 0 ); 586 setCurrentCell( -1, 0 );
587 587
588 setPaintingEnabled( TRUE ); 588 setPaintingEnabled( TRUE );
589
590
591} 589}
592 590
593 591
594void AbTable::setPaintingEnabled( bool e ) 592void AbTable::setPaintingEnabled( bool e )
595{ 593{
596 //qWarning("IN void AbTable::setPaintingEnabled( %d )->Nested: %d", e, countNested ); 594 //qWarning("IN void AbTable::setPaintingEnabled( %d )->Nested: %d", e, countNested );
597 595
598 if ( e ) { 596 if ( e ) {
599 if ( countNested > 0 ) 597 if ( countNested > 0 )
600 --countNested; 598 --countNested;
601 if ( ! countNested ){ 599 if ( ! countNested ){
602 setUpdatesEnabled( true ); 600 setUpdatesEnabled( true );
603 enablePainting = true; 601 enablePainting = true;
604 rowHeightChanged( 0 ); 602 rowHeightChanged( 0 );
605 viewport()->update(); 603 viewport()->update();
606 } 604 }
607 } else { 605 } else {
608 ++countNested; 606 ++countNested;
609 enablePainting = false; 607 enablePainting = false;
610 setUpdatesEnabled( false ); 608 setUpdatesEnabled( false );
611 } 609 }
612 //qWarning("OUT void AbTable::setPaintingEnabled( %d )->Nested: %d", e, countNested ); 610 //qWarning("OUT void AbTable::setPaintingEnabled( %d )->Nested: %d", e, countNested );
613} 611}
614 612
615void AbTable::viewportPaintEvent( QPaintEvent* e ) { 613void AbTable::viewportPaintEvent( QPaintEvent* e ) {
616 //qWarning(" void AbTable::viewportPaintEvent( QPaintEvent* e ) -> %d", enablePainting); 614 //qWarning(" void AbTable::viewportPaintEvent( QPaintEvent* e ) -> %d", enablePainting);
617 if ( enablePainting ) 615 if ( enablePainting )
618 QTable::viewportPaintEvent( e ); 616 QTable::viewportPaintEvent( e );
619} 617}
620 618
619void AbTable::paintCell(QPainter* p, int row, int col, const QRect& cr, bool ) {
620 const QColorGroup &cg = colorGroup();
621
622 p->save();
623
624 // Paint alternating background bars
625 if ( (row % 2 ) == 0 ) {
626 p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) );
627 p->setPen( QPen( cg.text() ) );
628 }
629 else {
630 p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Background ) );
631 p->setPen( QPen( cg.buttonText() ) );
632 }
621 633
634 QFont f = p->font();
635 QFontMetrics fm(f);
636
637 int marg = 2;
638 int x = 0;
639 int y = ( cr.height() - 14 ) / 2;
640
641 QPixmap pic = pixmap( row, col );
642 if ( !pic.isNull() )
643 {
644 p->drawPixmap( x + marg, y, pixmap( row, col ) );
645 p->drawText( x + marg + pixmap( row, col ).width() + 4,2 + fm.ascent(), text( row, col ) );
646 }
647 else
648 {
649 p->drawText( x + marg,2 + fm.ascent(), text( row, col ) );
650 }
651
652 p->restore();
653}
622 654
623void AbTable::rowHeightChanged( int row ) 655void AbTable::rowHeightChanged( int row )
624{ 656{
625 if ( enablePainting ) 657 if ( enablePainting )
626 QTable::rowHeightChanged( row ); 658 QTable::rowHeightChanged( row );
627} 659}
628ContactItem AbTable::findContactContact( const OContact &entry, int /* row */ ) 660ContactItem AbTable::findContactContact( const OContact &entry, int /* row */ )
629{ 661{
630 662
631 ContactItem item; 663 ContactItem item;
632 664
633 item.value = ""; 665 item.value = "";
634 666
635 for ( QValueList<int>::ConstIterator it = intFields.begin(); 667 for ( QValueList<int>::ConstIterator it = intFields.begin();
636 it != intFields.end(); ++it ) { 668 it != intFields.end(); ++it ) {
637 switch ( *it ) { 669 switch ( *it ) {
638 default: 670 default:
639 break; 671 break;
640 case Qtopia::Title: 672 case Qtopia::Title:
641 item.value = entry.title(); 673 item.value = entry.title();
642 break; 674 break;
643 case Qtopia::Suffix: 675 case Qtopia::Suffix:
644 item.value = entry.suffix(); 676 item.value = entry.suffix();
645 break; 677 break;
646 case Qtopia::FileAs: 678 case Qtopia::FileAs:
647 item.value = entry.fileAs(); 679 item.value = entry.fileAs();
648 break; 680 break;
649 case Qtopia::DefaultEmail: 681 case Qtopia::DefaultEmail:
650 item.value = entry.defaultEmail(); 682 item.value = entry.defaultEmail();
651 if ( !item.value.isEmpty() ) 683 if ( !item.value.isEmpty() )
652 item.icon = Resource::loadPixmap( "addressbook/email" ); 684 item.icon = Resource::loadPixmap( "addressbook/email" );
653 break; 685 break;
654 case Qtopia::Emails: 686 case Qtopia::Emails:
655 item.value = entry.emails(); 687 item.value = entry.emails();
656 if ( !item.value.isEmpty() ) 688 if ( !item.value.isEmpty() )
657 item.icon = Resource::loadPixmap( "addressbook/email" ); 689 item.icon = Resource::loadPixmap( "addressbook/email" );
658 break; 690 break;
659 case Qtopia::HomeStreet: 691 case Qtopia::HomeStreet:
660 item.value = entry.homeStreet(); 692 item.value = entry.homeStreet();
661 break; 693 break;
662 case Qtopia::HomeCity: 694 case Qtopia::HomeCity:
663 item.value = entry.homeCity(); 695 item.value = entry.homeCity();
664 break; 696 break;
665 case Qtopia::HomeState: 697 case Qtopia::HomeState:
666 item.value = entry.homeState(); 698 item.value = entry.homeState();
667 break; 699 break;
668 case Qtopia::HomeZip: 700 case Qtopia::HomeZip:
669 item.value = entry.homeZip(); 701 item.value = entry.homeZip();
diff --git a/core/pim/addressbook/abtable.h b/core/pim/addressbook/abtable.h
index 092e86f..4e6b294 100644
--- a/core/pim/addressbook/abtable.h
+++ b/core/pim/addressbook/abtable.h
@@ -51,96 +51,97 @@ private:
51// information 51// information
52class ContactItem 52class ContactItem
53{ 53{
54 public: 54 public:
55 QPixmap icon; 55 QPixmap icon;
56 QString value; 56 QString value;
57}; 57};
58 58
59class AbPickItem : public QTableItem 59class AbPickItem : public QTableItem
60{ 60{
61public: 61public:
62 AbPickItem( QTable *t ); 62 AbPickItem( QTable *t );
63 63
64 QWidget *createEditor() const; 64 QWidget *createEditor() const;
65 void setContentFromEditor( QWidget *w ); 65 void setContentFromEditor( QWidget *w );
66 66
67private: 67private:
68 QGuardedPtr<QComboBox> cb; 68 QGuardedPtr<QComboBox> cb;
69}; 69};
70 70
71class AbTable : public QTable 71class AbTable : public QTable
72{ 72{
73 Q_OBJECT 73 Q_OBJECT
74 74
75public: 75public:
76 AbTable( const QValueList<int> ordered, QWidget *parent, const char *name=0 ); 76 AbTable( const QValueList<int> ordered, QWidget *parent, const char *name=0 );
77 ~AbTable(); 77 ~AbTable();
78 78
79 // Set the contacts shown in the table 79 // Set the contacts shown in the table
80 void setContacts( const OContactAccess::List& viewList ); 80 void setContacts( const OContactAccess::List& viewList );
81 // Selects a contact of a specific UID 81 // Selects a contact of a specific UID
82 bool selectContact( int UID ); 82 bool selectContact( int UID );
83 83
84 // Get the current selected entry 84 // Get the current selected entry
85 OContact currentEntry(); 85 OContact currentEntry();
86 86
87 // Get the UID of the current selected Entry 87 // Get the UID of the current selected Entry
88 int currentEntry_UID(); 88 int currentEntry_UID();
89 89
90 QString findContactName( const OContact &entry ); 90 QString findContactName( const OContact &entry );
91 91
92 void init(); 92 void init();
93 void clear(); 93 void clear();
94 void refresh(); 94 void refresh();
95 95
96 void show(); 96 void show();
97 void setPaintingEnabled( bool e ); 97 void setPaintingEnabled( bool e );
98 void viewportPaintEvent( QPaintEvent* e); 98 void viewportPaintEvent( QPaintEvent* e);
99 void paintCell(QPainter* p, int row, int col, const QRect&, bool );
99 100
100 // addresspicker mode (What's that ? se) 101 // addresspicker mode (What's that ? se)
101 void setChoiceNames( const QStringList& list); 102 void setChoiceNames( const QStringList& list);
102 QStringList choiceNames() const; 103 QStringList choiceNames() const;
103 void setChoiceSelection( const QValueList<int>& list ); 104 void setChoiceSelection( const QValueList<int>& list );
104 QStringList choiceSelection(int index) const; 105 QStringList choiceSelection(int index) const;
105 106
106signals: 107signals:
107 void signalSwitch(); 108 void signalSwitch();
108 void signalEditor(); 109 void signalEditor();
109 void signalKeyDown(); 110 void signalKeyDown();
110 void signalKeyUp(); 111 void signalKeyUp();
111 112
112protected: 113protected:
113 virtual void keyPressEvent( QKeyEvent *e ); 114 virtual void keyPressEvent( QKeyEvent *e );
114 115
115// int rowHeight( int ) const; 116// int rowHeight( int ) const;
116// int rowPos( int row ) const; 117// int rowPos( int row ) const;
117// virtual int rowAt( int pos ) const; 118// virtual int rowAt( int pos ) const;
118 119
119 120
120protected slots: 121protected slots:
121 void moveTo( char ); 122 void moveTo( char );
122 virtual void columnClicked( int col ); 123 virtual void columnClicked( int col );
123 void itemClicked(int,int col); 124 void itemClicked(int,int col);
124 void rowHeightChanged( int row ); 125 void rowHeightChanged( int row );
125 126
126private: 127private:
127 void insertIntoTable( const OContact &cnt, int row ); 128 void insertIntoTable( const OContact &cnt, int row );
128 ContactItem findContactContact( const OContact &entry, int row ); 129 ContactItem findContactContact( const OContact &entry, int row );
129 void fitColumns(); 130 void fitColumns();
130 void resizeRows(); 131 void resizeRows();
131 void realignTable(); 132 void realignTable();
132 void resort(); 133 void resort();
133 void updateVisible(); 134 void updateVisible();
134 135
135 int lastSortCol; 136 int lastSortCol;
136 bool asc; 137 bool asc;
137 QMap<AbTableItem*, OContact> contactList; 138 QMap<AbTableItem*, OContact> contactList;
138 QValueList<int> intFields; 139 QValueList<int> intFields;
139 QStringList choicenames; 140 QStringList choicenames;
140 bool enablePainting; 141 bool enablePainting;
141 bool columnVisible; 142 bool columnVisible;
142 int countNested; 143 int countNested;
143 144
144 OContactAccess::List m_viewList; 145 OContactAccess::List m_viewList;
145 146
146}; 147};