-rw-r--r-- | core/pim/addressbook/abtable.cpp | 36 | ||||
-rw-r--r-- | core/pim/addressbook/abtable.h | 1 |
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 | |||
@@ -397,384 +397,416 @@ QString AbTable::findContactName( const OContact &entry ) | |||
397 | str = entry.company(); | 397 | str = entry.company(); |
398 | if ( str.isEmpty() ) { | 398 | if ( str.isEmpty() ) { |
399 | str = entry.defaultEmail(); | 399 | str = entry.defaultEmail(); |
400 | } | 400 | } |
401 | } | 401 | } |
402 | return str; | 402 | return str; |
403 | } | 403 | } |
404 | 404 | ||
405 | 405 | ||
406 | 406 | ||
407 | void AbTable::resizeRows() { | 407 | void AbTable::resizeRows() { |
408 | /* | 408 | /* |
409 | if (numRows()) { | 409 | if (numRows()) { |
410 | for (int i = 0; i < numRows(); i++) { | 410 | for (int i = 0; i < numRows(); i++) { |
411 | setRowHeight( i, size ); | 411 | setRowHeight( i, size ); |
412 | } | 412 | } |
413 | } | 413 | } |
414 | updateVisible(); | 414 | updateVisible(); |
415 | */ | 415 | */ |
416 | } | 416 | } |
417 | 417 | ||
418 | 418 | ||
419 | void AbTable::realignTable() | 419 | void AbTable::realignTable() |
420 | { | 420 | { |
421 | //qWarning( "void AbTable::realignTable()" ); | 421 | //qWarning( "void AbTable::realignTable()" ); |
422 | 422 | ||
423 | setPaintingEnabled( FALSE ); | 423 | setPaintingEnabled( FALSE ); |
424 | 424 | ||
425 | resizeRows(); | 425 | resizeRows(); |
426 | fitColumns(); | 426 | fitColumns(); |
427 | 427 | ||
428 | setPaintingEnabled( TRUE ); | 428 | setPaintingEnabled( TRUE ); |
429 | 429 | ||
430 | } | 430 | } |
431 | 431 | ||
432 | 432 | ||
433 | 433 | ||
434 | 434 | ||
435 | #if QT_VERSION <= 230 | 435 | #if QT_VERSION <= 230 |
436 | #ifndef SINGLE_APP | 436 | #ifndef SINGLE_APP |
437 | void QTable::paintEmptyArea( QPainter *p, int cx, int cy, int cw, int ch ) | 437 | void QTable::paintEmptyArea( QPainter *p, int cx, int cy, int cw, int ch ) |
438 | { | 438 | { |
439 | // Region of the rect we should draw | 439 | // Region of the rect we should draw |
440 | QRegion reg( QRect( cx, cy, cw, ch ) ); | 440 | QRegion reg( QRect( cx, cy, cw, ch ) ); |
441 | // Subtract the table from it | 441 | // Subtract the table from it |
442 | reg = reg.subtract( QRect( QPoint( 0, 0 ), tableSize() ) ); | 442 | reg = reg.subtract( QRect( QPoint( 0, 0 ), tableSize() ) ); |
443 | // And draw the rectangles (transformed as needed) | 443 | // And draw the rectangles (transformed as needed) |
444 | QArray<QRect> r = reg.rects(); | 444 | QArray<QRect> r = reg.rects(); |
445 | for (unsigned int i=0; i<r.count(); i++) | 445 | for (unsigned int i=0; i<r.count(); i++) |
446 | p->fillRect( r[i], colorGroup().brush( QColorGroup::Base ) ); | 446 | p->fillRect( r[i], colorGroup().brush( QColorGroup::Base ) ); |
447 | } | 447 | } |
448 | #endif | 448 | #endif |
449 | #endif | 449 | #endif |
450 | 450 | ||
451 | 451 | ||
452 | // int AbTable::rowHeight( int ) const | 452 | // int AbTable::rowHeight( int ) const |
453 | // { | 453 | // { |
454 | // return 18; | 454 | // return 18; |
455 | // } | 455 | // } |
456 | 456 | ||
457 | // int AbTable::rowPos( int row ) const | 457 | // int AbTable::rowPos( int row ) const |
458 | // { | 458 | // { |
459 | // return 18*row; | 459 | // return 18*row; |
460 | // } | 460 | // } |
461 | 461 | ||
462 | // int AbTable::rowAt( int pos ) const | 462 | // int AbTable::rowAt( int pos ) const |
463 | // { | 463 | // { |
464 | // return QMIN( pos/18, numRows()-1 ); | 464 | // return QMIN( pos/18, numRows()-1 ); |
465 | // } | 465 | // } |
466 | 466 | ||
467 | 467 | ||
468 | 468 | ||
469 | void AbTable::fitColumns() | 469 | void AbTable::fitColumns() |
470 | { | 470 | { |
471 | //qWarning( "void AbTable::fitColumns()" ); | 471 | //qWarning( "void AbTable::fitColumns()" ); |
472 | int contentsWidth = visibleWidth() / 2; // :SX Why too low | 472 | int contentsWidth = visibleWidth() / 2; // :SX Why too low |
473 | // Fix to better value | 473 | // Fix to better value |
474 | // contentsWidth = 130; | 474 | // contentsWidth = 130; |
475 | 475 | ||
476 | setPaintingEnabled( FALSE ); | 476 | setPaintingEnabled( FALSE ); |
477 | 477 | ||
478 | if ( columnVisible == false ){ | 478 | if ( columnVisible == false ){ |
479 | showColumn(0); | 479 | showColumn(0); |
480 | columnVisible = true; | 480 | columnVisible = true; |
481 | } | 481 | } |
482 | 482 | ||
483 | //qWarning("Width: %d", contentsWidth); | 483 | //qWarning("Width: %d", contentsWidth); |
484 | 484 | ||
485 | setColumnWidth( 0, contentsWidth ); | 485 | setColumnWidth( 0, contentsWidth ); |
486 | adjustColumn(1); | 486 | adjustColumn(1); |
487 | if ( columnWidth(1) < contentsWidth ) | 487 | if ( columnWidth(1) < contentsWidth ) |
488 | setColumnWidth( 1, contentsWidth ); | 488 | setColumnWidth( 1, contentsWidth ); |
489 | 489 | ||
490 | setPaintingEnabled( TRUE ); | 490 | setPaintingEnabled( TRUE ); |
491 | } | 491 | } |
492 | 492 | ||
493 | void AbTable::show() | 493 | void AbTable::show() |
494 | { | 494 | { |
495 | //qWarning( "void AbTable::show()" ); | 495 | //qWarning( "void AbTable::show()" ); |
496 | realignTable(); | 496 | realignTable(); |
497 | QTable::show(); | 497 | QTable::show(); |
498 | } | 498 | } |
499 | 499 | ||
500 | void AbTable::setChoiceNames( const QStringList& list) | 500 | void AbTable::setChoiceNames( const QStringList& list) |
501 | { | 501 | { |
502 | choicenames = list; | 502 | choicenames = list; |
503 | if ( choicenames.isEmpty() ) { | 503 | if ( choicenames.isEmpty() ) { |
504 | // hide pick column | 504 | // hide pick column |
505 | setNumCols( 2 ); | 505 | setNumCols( 2 ); |
506 | } else { | 506 | } else { |
507 | // show pick column | 507 | // show pick column |
508 | setNumCols( 3 ); | 508 | setNumCols( 3 ); |
509 | setColumnWidth( 2, fontMetrics().width(tr( "Pick" ))+8 ); | 509 | setColumnWidth( 2, fontMetrics().width(tr( "Pick" ))+8 ); |
510 | horizontalHeader()->setLabel( 2, tr( "Pick" )); | 510 | horizontalHeader()->setLabel( 2, tr( "Pick" )); |
511 | } | 511 | } |
512 | fitColumns(); | 512 | fitColumns(); |
513 | } | 513 | } |
514 | 514 | ||
515 | void AbTable::itemClicked(int,int col) | 515 | void AbTable::itemClicked(int,int col) |
516 | { | 516 | { |
517 | //qWarning( "AbTable::itemClicked(int, col:%d)", col); | 517 | //qWarning( "AbTable::itemClicked(int, col:%d)", col); |
518 | if ( col == 2 ) { | 518 | if ( col == 2 ) { |
519 | return; | 519 | return; |
520 | } else { | 520 | } else { |
521 | // qWarning ("Emitting signalSwitch()"); | 521 | // qWarning ("Emitting signalSwitch()"); |
522 | emit signalSwitch(); | 522 | emit signalSwitch(); |
523 | } | 523 | } |
524 | } | 524 | } |
525 | 525 | ||
526 | QStringList AbTable::choiceNames() const | 526 | QStringList AbTable::choiceNames() const |
527 | { | 527 | { |
528 | return choicenames; | 528 | return choicenames; |
529 | } | 529 | } |
530 | 530 | ||
531 | void AbTable::setChoiceSelection( const QValueList<int>& list ) | 531 | void AbTable::setChoiceSelection( const QValueList<int>& list ) |
532 | { | 532 | { |
533 | intFields = list; | 533 | intFields = list; |
534 | } | 534 | } |
535 | 535 | ||
536 | QStringList AbTable::choiceSelection(int /*index*/) const | 536 | QStringList AbTable::choiceSelection(int /*index*/) const |
537 | { | 537 | { |
538 | QStringList r; | 538 | QStringList r; |
539 | /* ###### | 539 | /* ###### |
540 | 540 | ||
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 | ||
556 | void AbTable::updateVisible() | 556 | void 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 | ||
594 | void AbTable::setPaintingEnabled( bool e ) | 592 | void 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 | ||
615 | void AbTable::viewportPaintEvent( QPaintEvent* e ) { | 613 | void 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 | ||
619 | void 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 | ||
623 | void AbTable::rowHeightChanged( int row ) | 655 | void AbTable::rowHeightChanged( int row ) |
624 | { | 656 | { |
625 | if ( enablePainting ) | 657 | if ( enablePainting ) |
626 | QTable::rowHeightChanged( row ); | 658 | QTable::rowHeightChanged( row ); |
627 | } | 659 | } |
628 | ContactItem AbTable::findContactContact( const OContact &entry, int /* row */ ) | 660 | ContactItem 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(); |
670 | break; | 702 | break; |
671 | case Qtopia::HomeCountry: | 703 | case Qtopia::HomeCountry: |
672 | item.value = entry.homeCountry(); | 704 | item.value = entry.homeCountry(); |
673 | break; | 705 | break; |
674 | case Qtopia::HomePhone: | 706 | case Qtopia::HomePhone: |
675 | item.value = entry.homePhone(); | 707 | item.value = entry.homePhone(); |
676 | if ( !item.value.isEmpty() ) | 708 | if ( !item.value.isEmpty() ) |
677 | item.icon = Resource::loadPixmap( "addressbook/phonehome" ); | 709 | item.icon = Resource::loadPixmap( "addressbook/phonehome" ); |
678 | break; | 710 | break; |
679 | case Qtopia::HomeFax: | 711 | case Qtopia::HomeFax: |
680 | item.value = entry.homeFax(); | 712 | item.value = entry.homeFax(); |
681 | if ( !item.value.isEmpty() ) | 713 | if ( !item.value.isEmpty() ) |
682 | item.icon = Resource::loadPixmap( "addressbook/faxhome" ); | 714 | item.icon = Resource::loadPixmap( "addressbook/faxhome" ); |
683 | break; | 715 | break; |
684 | case Qtopia::HomeMobile: | 716 | case Qtopia::HomeMobile: |
685 | item.value = entry.homeMobile(); | 717 | item.value = entry.homeMobile(); |
686 | if ( !item.value.isEmpty() ) | 718 | if ( !item.value.isEmpty() ) |
687 | item.icon = Resource::loadPixmap( "addressbook/mobilehome" ); | 719 | item.icon = Resource::loadPixmap( "addressbook/mobilehome" ); |
688 | break; | 720 | break; |
689 | case Qtopia::HomeWebPage: | 721 | case Qtopia::HomeWebPage: |
690 | item.value = entry.homeWebpage(); | 722 | item.value = entry.homeWebpage(); |
691 | if ( !item.value.isEmpty() ) | 723 | if ( !item.value.isEmpty() ) |
692 | item.icon = Resource::loadPixmap( "addressbook/webpagehome" ); | 724 | item.icon = Resource::loadPixmap( "addressbook/webpagehome" ); |
693 | break; | 725 | break; |
694 | case Qtopia::Company: | 726 | case Qtopia::Company: |
695 | item.value = entry.company(); | 727 | item.value = entry.company(); |
696 | break; | 728 | break; |
697 | case Qtopia::BusinessCity: | 729 | case Qtopia::BusinessCity: |
698 | item.value = entry.businessCity(); | 730 | item.value = entry.businessCity(); |
699 | break; | 731 | break; |
700 | case Qtopia::BusinessStreet: | 732 | case Qtopia::BusinessStreet: |
701 | item.value = entry.businessStreet(); | 733 | item.value = entry.businessStreet(); |
702 | break; | 734 | break; |
703 | case Qtopia::BusinessZip: | 735 | case Qtopia::BusinessZip: |
704 | item.value = entry.businessZip(); | 736 | item.value = entry.businessZip(); |
705 | break; | 737 | break; |
706 | case Qtopia::BusinessCountry: | 738 | case Qtopia::BusinessCountry: |
707 | item.value = entry.businessCountry(); | 739 | item.value = entry.businessCountry(); |
708 | break; | 740 | break; |
709 | case Qtopia::BusinessWebPage: | 741 | case Qtopia::BusinessWebPage: |
710 | item.value = entry.businessWebpage(); | 742 | item.value = entry.businessWebpage(); |
711 | if ( !item.value.isEmpty() ) | 743 | if ( !item.value.isEmpty() ) |
712 | item.icon = Resource::loadPixmap( "addressbook/webpagework" ); | 744 | item.icon = Resource::loadPixmap( "addressbook/webpagework" ); |
713 | break; | 745 | break; |
714 | case Qtopia::JobTitle: | 746 | case Qtopia::JobTitle: |
715 | item.value = entry.jobTitle(); | 747 | item.value = entry.jobTitle(); |
716 | break; | 748 | break; |
717 | case Qtopia::Department: | 749 | case Qtopia::Department: |
718 | item.value = entry.department(); | 750 | item.value = entry.department(); |
719 | break; | 751 | break; |
720 | case Qtopia::Office: | 752 | case Qtopia::Office: |
721 | item.value = entry.office(); | 753 | item.value = entry.office(); |
722 | break; | 754 | break; |
723 | case Qtopia::BusinessPhone: | 755 | case Qtopia::BusinessPhone: |
724 | item.value = entry.businessPhone(); | 756 | item.value = entry.businessPhone(); |
725 | if ( !item.value.isEmpty() ) | 757 | if ( !item.value.isEmpty() ) |
726 | item.icon = Resource::loadPixmap( "addressbook/phonework" ); | 758 | item.icon = Resource::loadPixmap( "addressbook/phonework" ); |
727 | break; | 759 | break; |
728 | case Qtopia::BusinessFax: | 760 | case Qtopia::BusinessFax: |
729 | item.value = entry.businessFax(); | 761 | item.value = entry.businessFax(); |
730 | if ( !item.value.isEmpty() ) | 762 | if ( !item.value.isEmpty() ) |
731 | item.icon = Resource::loadPixmap( "addressbook/faxwork" ); | 763 | item.icon = Resource::loadPixmap( "addressbook/faxwork" ); |
732 | break; | 764 | break; |
733 | case Qtopia::BusinessMobile: | 765 | case Qtopia::BusinessMobile: |
734 | item.value = entry.businessMobile(); | 766 | item.value = entry.businessMobile(); |
735 | if ( !item.value.isEmpty() ) | 767 | if ( !item.value.isEmpty() ) |
736 | item.icon = Resource::loadPixmap( "addressbook/mobilework" ); | 768 | item.icon = Resource::loadPixmap( "addressbook/mobilework" ); |
737 | break; | 769 | break; |
738 | case Qtopia::BusinessPager: | 770 | case Qtopia::BusinessPager: |
739 | item.value = entry.businessPager(); | 771 | item.value = entry.businessPager(); |
740 | break; | 772 | break; |
741 | case Qtopia::Profession: | 773 | case Qtopia::Profession: |
742 | item.value = entry.profession(); | 774 | item.value = entry.profession(); |
743 | break; | 775 | break; |
744 | case Qtopia::Assistant: | 776 | case Qtopia::Assistant: |
745 | item.value = entry.assistant(); | 777 | item.value = entry.assistant(); |
746 | break; | 778 | break; |
747 | case Qtopia::Manager: | 779 | case Qtopia::Manager: |
748 | item.value = entry.manager(); | 780 | item.value = entry.manager(); |
749 | break; | 781 | break; |
750 | case Qtopia::Spouse: | 782 | case Qtopia::Spouse: |
751 | item.value = entry.spouse(); | 783 | item.value = entry.spouse(); |
752 | break; | 784 | break; |
753 | case Qtopia::Gender: | 785 | case Qtopia::Gender: |
754 | item.value = entry.gender(); | 786 | item.value = entry.gender(); |
755 | break; | 787 | break; |
756 | case Qtopia::Birthday: | 788 | case Qtopia::Birthday: |
757 | if ( ! entry.birthday().isNull() ){ | 789 | if ( ! entry.birthday().isNull() ){ |
758 | item.value = TimeString::numberDateString( entry.birthday() ); | 790 | item.value = TimeString::numberDateString( entry.birthday() ); |
759 | } | 791 | } |
760 | break; | 792 | break; |
761 | case Qtopia::Anniversary: | 793 | case Qtopia::Anniversary: |
762 | if ( ! entry.anniversary().isNull() ){ | 794 | if ( ! entry.anniversary().isNull() ){ |
763 | item.value = TimeString::numberDateString( entry.anniversary() ); | 795 | item.value = TimeString::numberDateString( entry.anniversary() ); |
764 | } | 796 | } |
765 | break; | 797 | break; |
766 | case Qtopia::Nickname: | 798 | case Qtopia::Nickname: |
767 | item.value = entry.nickname(); | 799 | item.value = entry.nickname(); |
768 | break; | 800 | break; |
769 | case Qtopia::Children: | 801 | case Qtopia::Children: |
770 | item.value = entry.children(); | 802 | item.value = entry.children(); |
771 | break; | 803 | break; |
772 | case Qtopia::Notes: | 804 | case Qtopia::Notes: |
773 | item.value = entry.notes(); | 805 | item.value = entry.notes(); |
774 | break; | 806 | break; |
775 | } | 807 | } |
776 | if ( !item.value.isEmpty() ) | 808 | if ( !item.value.isEmpty() ) |
777 | break; | 809 | break; |
778 | } | 810 | } |
779 | return item; | 811 | return item; |
780 | } | 812 | } |
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 | |||
@@ -1,147 +1,148 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** Copyright (c) 2002 Stefan Eilers (eilers.stefan@epost.de) | 3 | ** Copyright (c) 2002 Stefan Eilers (eilers.stefan@epost.de) |
4 | ** | 4 | ** |
5 | ** This file is part of Qt Palmtop Environment. | 5 | ** This file is part of Qt Palmtop Environment. |
6 | ** | 6 | ** |
7 | ** This file may be distributed and/or modified under the terms of the | 7 | ** This file may be distributed and/or modified under the terms of the |
8 | ** GNU General Public License version 2 as published by the Free Software | 8 | ** GNU General Public License version 2 as published by the Free Software |
9 | ** Foundation and appearing in the file LICENSE.GPL included in the | 9 | ** Foundation and appearing in the file LICENSE.GPL included in the |
10 | ** packaging of this file. | 10 | ** packaging of this file. |
11 | ** | 11 | ** |
12 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 12 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
13 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 13 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
14 | ** | 14 | ** |
15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
16 | ** | 16 | ** |
17 | ** Contact info@trolltech.com if any conditions of this licensing are | 17 | ** Contact info@trolltech.com if any conditions of this licensing are |
18 | ** not clear to you. | 18 | ** not clear to you. |
19 | ** | 19 | ** |
20 | **********************************************************************/ | 20 | **********************************************************************/ |
21 | 21 | ||
22 | #ifndef ABTABLE_H | 22 | #ifndef ABTABLE_H |
23 | #define ABTABLE_H | 23 | #define ABTABLE_H |
24 | 24 | ||
25 | #include <qpe/categories.h> | 25 | #include <qpe/categories.h> |
26 | #include <opie/ocontact.h> | 26 | #include <opie/ocontact.h> |
27 | #include <opie/ocontactaccess.h> | 27 | #include <opie/ocontactaccess.h> |
28 | 28 | ||
29 | #include <qmap.h> | 29 | #include <qmap.h> |
30 | #include <qtable.h> | 30 | #include <qtable.h> |
31 | #include <qstringlist.h> | 31 | #include <qstringlist.h> |
32 | #include <qcombobox.h> | 32 | #include <qcombobox.h> |
33 | #include <qpixmap.h> | 33 | #include <qpixmap.h> |
34 | 34 | ||
35 | class AbTableItem : public QTableItem | 35 | class AbTableItem : public QTableItem |
36 | { | 36 | { |
37 | public: | 37 | public: |
38 | AbTableItem( QTable *t, EditType et, const QString &s, | 38 | AbTableItem( QTable *t, EditType et, const QString &s, |
39 | const QString &secondSortKey); | 39 | const QString &secondSortKey); |
40 | QString entryKey() const; | 40 | QString entryKey() const; |
41 | void setEntryKey( const QString & k ); | 41 | void setEntryKey( const QString & k ); |
42 | virtual int alignment() const; | 42 | virtual int alignment() const; |
43 | virtual QString key() const; | 43 | virtual QString key() const; |
44 | void setItem( const QString &txt, const QString &secondKey ); | 44 | void setItem( const QString &txt, const QString &secondKey ); |
45 | 45 | ||
46 | private: | 46 | private: |
47 | QString sortKey; | 47 | QString sortKey; |
48 | }; | 48 | }; |
49 | 49 | ||
50 | // This is a simple container, storing all contact | 50 | // This is a simple container, storing all contact |
51 | // information | 51 | // information |
52 | class ContactItem | 52 | class ContactItem |
53 | { | 53 | { |
54 | public: | 54 | public: |
55 | QPixmap icon; | 55 | QPixmap icon; |
56 | QString value; | 56 | QString value; |
57 | }; | 57 | }; |
58 | 58 | ||
59 | class AbPickItem : public QTableItem | 59 | class AbPickItem : public QTableItem |
60 | { | 60 | { |
61 | public: | 61 | public: |
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 | ||
67 | private: | 67 | private: |
68 | QGuardedPtr<QComboBox> cb; | 68 | QGuardedPtr<QComboBox> cb; |
69 | }; | 69 | }; |
70 | 70 | ||
71 | class AbTable : public QTable | 71 | class AbTable : public QTable |
72 | { | 72 | { |
73 | Q_OBJECT | 73 | Q_OBJECT |
74 | 74 | ||
75 | public: | 75 | public: |
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 | ||
106 | signals: | 107 | signals: |
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 | ||
112 | protected: | 113 | protected: |
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 | ||
120 | protected slots: | 121 | protected 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 | ||
126 | private: | 127 | private: |
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 | }; |
147 | #endif // ABTABLE_H | 148 | #endif // ABTABLE_H |