-rw-r--r-- | core/pim/addressbook/TODO | 1 | ||||
-rw-r--r-- | core/pim/addressbook/abtable.cpp | 10 | ||||
-rw-r--r-- | core/pim/addressbook/abtable.h | 2 | ||||
-rw-r--r-- | core/pim/addressbook/addressbook.cpp | 69 | ||||
-rw-r--r-- | core/pim/addressbook/addressbook.h | 17 | ||||
-rw-r--r-- | core/pim/addressbook/addressbook.pro | 3 | ||||
-rw-r--r-- | core/pim/addressbook/ofloatbar.h | 20 |
7 files changed, 97 insertions, 25 deletions
diff --git a/core/pim/addressbook/TODO b/core/pim/addressbook/TODO index 7bc906d..d8720b3 100644 --- a/core/pim/addressbook/TODO +++ b/core/pim/addressbook/TODO | |||
@@ -1,28 +1,29 @@ | |||
1 | Stuff todo: | 1 | Stuff todo: |
2 | 2 | ||
3 | Urgent: | 3 | Urgent: |
4 | 4 | ||
5 | - Font menu is invisible using german translation | 5 | - Font menu is invisible using german translation |
6 | 6 | ||
7 | Important: | 7 | Important: |
8 | 8 | ||
9 | - Finishing of new View functions (List, Phonebook...) | 9 | - Finishing of new View functions (List, Phonebook...) |
10 | - Reload if contacts were changed externally | 10 | - Reload if contacts were changed externally |
11 | - "What's this" should be added | 11 | - "What's this" should be added |
12 | - The names of the countries are sorted by there english names, only.. | 12 | - The names of the countries are sorted by there english names, only.. |
13 | Even if they are translated.. :S | 13 | Even if they are translated.. :S |
14 | - Store last settings of combo-boxes | 14 | - Store last settings of combo-boxes |
15 | - Mail-Icon is missing | ||
15 | 16 | ||
16 | Less important: | 17 | Less important: |
17 | 18 | ||
18 | - Find widget should be replaced by something like | 19 | - Find widget should be replaced by something like |
19 | qpdf has. | 20 | qpdf has. |
20 | - The picker (alphabetical sort widget) should be | 21 | - The picker (alphabetical sort widget) should be |
21 | placed verticaly or horizontally (configurable) | 22 | placed verticaly or horizontally (configurable) |
22 | 23 | ||
23 | 24 | ||
24 | Should be Fixed (not absolute sure, need validation): | 25 | Should be Fixed (not absolute sure, need validation): |
25 | - "Nonenglish" translation bug has to be fixed. | 26 | - "Nonenglish" translation bug has to be fixed. |
26 | 27 | ||
27 | Fixed: | 28 | Fixed: |
28 | - Syncing: abtable not reloaded after sync. | 29 | - Syncing: abtable not reloaded after sync. |
diff --git a/core/pim/addressbook/abtable.cpp b/core/pim/addressbook/abtable.cpp index 91a7171..9297d6a 100644 --- a/core/pim/addressbook/abtable.cpp +++ b/core/pim/addressbook/abtable.cpp | |||
@@ -446,386 +446,394 @@ QString AbTable::findContactContact( const OContact &entry, int /* row */ ) | |||
446 | 446 | ||
447 | void AbTable::addEntry( const OContact &newCnt ) | 447 | void AbTable::addEntry( const OContact &newCnt ) |
448 | { | 448 | { |
449 | int row = numRows(); | 449 | int row = numRows(); |
450 | 450 | ||
451 | setNumRows( row + 1 ); | 451 | setNumRows( row + 1 ); |
452 | insertIntoTable( newCnt, row ); | 452 | insertIntoTable( newCnt, row ); |
453 | 453 | ||
454 | qWarning("abtable:AddContact"); | 454 | qWarning("abtable:AddContact"); |
455 | m_contactdb.add ( newCnt ); | 455 | m_contactdb.add ( newCnt ); |
456 | 456 | ||
457 | setCurrentCell( row, 0 ); | 457 | setCurrentCell( row, 0 ); |
458 | // updateVisible(); | 458 | // updateVisible(); |
459 | } | 459 | } |
460 | 460 | ||
461 | void AbTable::resizeRows() { | 461 | void AbTable::resizeRows() { |
462 | /* | 462 | /* |
463 | if (numRows()) { | 463 | if (numRows()) { |
464 | for (int i = 0; i < numRows(); i++) { | 464 | for (int i = 0; i < numRows(); i++) { |
465 | setRowHeight( i, size ); | 465 | setRowHeight( i, size ); |
466 | } | 466 | } |
467 | } | 467 | } |
468 | updateVisible(); | 468 | updateVisible(); |
469 | */ | 469 | */ |
470 | } | 470 | } |
471 | 471 | ||
472 | 472 | ||
473 | bool AbTable::save() | 473 | bool AbTable::save() |
474 | { | 474 | { |
475 | // QTime t; | 475 | // QTime t; |
476 | // t.start(); | 476 | // t.start(); |
477 | qWarning("abtable:Save data"); | 477 | qWarning("abtable:Save data"); |
478 | 478 | ||
479 | return m_contactdb.save(); | 479 | return m_contactdb.save(); |
480 | } | 480 | } |
481 | 481 | ||
482 | void AbTable::load() | 482 | void AbTable::load() |
483 | { | 483 | { |
484 | setSorting( false ); | 484 | setSorting( false ); |
485 | setUpdatesEnabled( FALSE ); | 485 | setUpdatesEnabled( FALSE ); |
486 | 486 | ||
487 | qWarning("abtable:Load data"); | 487 | qWarning("abtable:Load data"); |
488 | 488 | ||
489 | OContactAccess::List list = m_contactdb.allRecords(); | 489 | OContactAccess::List list = m_contactdb.allRecords(); |
490 | OContactAccess::List::Iterator it; | 490 | OContactAccess::List::Iterator it; |
491 | setNumRows( list.count() ); | 491 | setNumRows( list.count() ); |
492 | int row = 0; | 492 | int row = 0; |
493 | for ( it = list.begin(); it != list.end(); ++it ) | 493 | for ( it = list.begin(); it != list.end(); ++it ) |
494 | insertIntoTable( *it, row++ ); | 494 | insertIntoTable( *it, row++ ); |
495 | 495 | ||
496 | setUpdatesEnabled( TRUE ); | 496 | setUpdatesEnabled( TRUE ); |
497 | 497 | ||
498 | setSorting( true ); | 498 | setSorting( true ); |
499 | resort(); | 499 | resort(); |
500 | } | 500 | } |
501 | 501 | ||
502 | 502 | ||
503 | void AbTable::reload() | 503 | void AbTable::reload() |
504 | { | 504 | { |
505 | m_contactdb.reload(); | 505 | m_contactdb.reload(); |
506 | load(); | 506 | load(); |
507 | } | 507 | } |
508 | 508 | ||
509 | void AbTable::realignTable( int row ) | 509 | void AbTable::realignTable( int row ) |
510 | { | 510 | { |
511 | QTableItem *ti1, | 511 | QTableItem *ti1, |
512 | *ti2; | 512 | *ti2; |
513 | int totalRows = numRows(); | 513 | int totalRows = numRows(); |
514 | for ( int curr = row; curr < totalRows - 1; curr++ ) { | 514 | for ( int curr = row; curr < totalRows - 1; curr++ ) { |
515 | // the same info from the todo list still applies, but I | 515 | // the same info from the todo list still applies, but I |
516 | // don't think it is _too_ bad. | 516 | // don't think it is _too_ bad. |
517 | ti1 = item( curr + 1, 0 ); | 517 | ti1 = item( curr + 1, 0 ); |
518 | ti2 = item( curr + 1, 1 ); | 518 | ti2 = item( curr + 1, 1 ); |
519 | takeItem( ti1 ); | 519 | takeItem( ti1 ); |
520 | takeItem( ti2 ); | 520 | takeItem( ti2 ); |
521 | setItem( curr, 0, ti1 ); | 521 | setItem( curr, 0, ti1 ); |
522 | setItem( curr, 1, ti2 ); | 522 | setItem( curr, 1, ti2 ); |
523 | } | 523 | } |
524 | setNumRows( totalRows - 1 ); | 524 | setNumRows( totalRows - 1 ); |
525 | resort(); | 525 | resort(); |
526 | } | 526 | } |
527 | 527 | ||
528 | // Add contact into table. | 528 | // Add contact into table. |
529 | void AbTable::insertIntoTable( const OContact &cnt, int row ) | 529 | void AbTable::insertIntoTable( const OContact &cnt, int row ) |
530 | { | 530 | { |
531 | QString strName, | 531 | QString strName, |
532 | strContact; | 532 | strContact; |
533 | 533 | ||
534 | strName = findContactName( cnt ); | 534 | strName = findContactName( cnt ); |
535 | strContact = findContactContact( cnt, row ); | 535 | strContact = findContactContact( cnt, row ); |
536 | 536 | ||
537 | AbTableItem *ati; | 537 | AbTableItem *ati; |
538 | ati = new AbTableItem( this, QTableItem::Never, strName, strContact); | 538 | ati = new AbTableItem( this, QTableItem::Never, strName, strContact); |
539 | contactList.insert( ati, cnt ); | 539 | contactList.insert( ati, cnt ); |
540 | setItem( row, 0, ati ); | 540 | setItem( row, 0, ati ); |
541 | ati = new AbTableItem( this, QTableItem::Never, strContact, strName); | 541 | ati = new AbTableItem( this, QTableItem::Never, strContact, strName); |
542 | setItem( row, 1, ati ); | 542 | setItem( row, 1, ati ); |
543 | 543 | ||
544 | //### cannot do this; table only has two columns at this point | 544 | //### cannot do this; table only has two columns at this point |
545 | // setItem( row, 2, new AbPickItem( this ) ); | 545 | // setItem( row, 2, new AbPickItem( this ) ); |
546 | 546 | ||
547 | // resort at some point? | 547 | // resort at some point? |
548 | } | 548 | } |
549 | 549 | ||
550 | 550 | ||
551 | // Replace or add an entry | 551 | // Replace or add an entry |
552 | void AbTable::journalFreeReplace( const OContact &cnt, int row ) | 552 | void AbTable::journalFreeReplace( const OContact &cnt, int row ) |
553 | { | 553 | { |
554 | QString strName, | 554 | QString strName, |
555 | strContact; | 555 | strContact; |
556 | AbTableItem *ati = 0l; | 556 | AbTableItem *ati = 0l; |
557 | 557 | ||
558 | strName = findContactName( cnt ); | 558 | strName = findContactName( cnt ); |
559 | strContact = findContactContact( cnt, row ); | 559 | strContact = findContactContact( cnt, row ); |
560 | ati = static_cast<AbTableItem*>(item(row, 0)); | 560 | ati = static_cast<AbTableItem*>(item(row, 0)); |
561 | 561 | ||
562 | // Replace element if found in row "row" | 562 | // Replace element if found in row "row" |
563 | // or add this element if not. | 563 | // or add this element if not. |
564 | if ( ati != 0 ) { // replace | 564 | if ( ati != 0 ) { // replace |
565 | // :SX db access -> replace | 565 | // :SX db access -> replace |
566 | qWarning ("Replace Contact in DB ! UID: %d", contactList[ati].uid() ); | 566 | qWarning ("Replace Contact in DB ! UID: %d", contactList[ati].uid() ); |
567 | m_contactdb.replace ( cnt ); | 567 | m_contactdb.replace ( cnt ); |
568 | 568 | ||
569 | contactList.remove( ati ); | 569 | contactList.remove( ati ); |
570 | ati->setItem( strName, strContact ); | 570 | ati->setItem( strName, strContact ); |
571 | contactList.insert( ati, cnt ); | 571 | contactList.insert( ati, cnt ); |
572 | 572 | ||
573 | ati = static_cast<AbTableItem*>(item(row, 1)); | 573 | ati = static_cast<AbTableItem*>(item(row, 1)); |
574 | ati->setItem( strContact, strName ); | 574 | ati->setItem( strContact, strName ); |
575 | 575 | ||
576 | }else{ // add | 576 | }else{ // add |
577 | int myrows = numRows(); | 577 | int myrows = numRows(); |
578 | setNumRows( myrows + 1 ); | 578 | setNumRows( myrows + 1 ); |
579 | insertIntoTable( cnt, myrows ); | 579 | insertIntoTable( cnt, myrows ); |
580 | // gets deleted when returning -- Why ? (se) | 580 | // gets deleted when returning -- Why ? (se) |
581 | // :SX db access -> add | 581 | // :SX db access -> add |
582 | qWarning ("Are you sure to add to database ? -> Currently disabled !!"); | 582 | qWarning ("Are you sure to add to database ? -> Currently disabled !!"); |
583 | // m_contactdb.add( cnt ); | 583 | // m_contactdb.add( cnt ); |
584 | } | 584 | } |
585 | } | 585 | } |
586 | 586 | ||
587 | // Remove entry | 587 | // Remove entry |
588 | void AbTable::journalFreeRemove( int row ) | 588 | void AbTable::journalFreeRemove( int row ) |
589 | { | 589 | { |
590 | AbTableItem *ati; | 590 | AbTableItem *ati; |
591 | ati = static_cast<AbTableItem*>(item(row, 0)); | 591 | ati = static_cast<AbTableItem*>(item(row, 0)); |
592 | if ( !ati ) | 592 | if ( !ati ) |
593 | return; | 593 | return; |
594 | 594 | ||
595 | // :SX db access -> remove | 595 | // :SX db access -> remove |
596 | qWarning ("Remove Contact from DB ! UID: %d",contactList[ati].uid() ); | 596 | qWarning ("Remove Contact from DB ! UID: %d",contactList[ati].uid() ); |
597 | m_contactdb.remove( contactList[ati].uid() ); | 597 | m_contactdb.remove( contactList[ati].uid() ); |
598 | 598 | ||
599 | contactList.remove( ati ); | 599 | contactList.remove( ati ); |
600 | 600 | ||
601 | realignTable( row ); | 601 | realignTable( row ); |
602 | 602 | ||
603 | } | 603 | } |
604 | 604 | ||
605 | #if QT_VERSION <= 230 | 605 | #if QT_VERSION <= 230 |
606 | #ifndef SINGLE_APP | 606 | #ifndef SINGLE_APP |
607 | void QTable::paintEmptyArea( QPainter *p, int cx, int cy, int cw, int ch ) | 607 | void QTable::paintEmptyArea( QPainter *p, int cx, int cy, int cw, int ch ) |
608 | { | 608 | { |
609 | // Region of the rect we should draw | 609 | // Region of the rect we should draw |
610 | QRegion reg( QRect( cx, cy, cw, ch ) ); | 610 | QRegion reg( QRect( cx, cy, cw, ch ) ); |
611 | // Subtract the table from it | 611 | // Subtract the table from it |
612 | reg = reg.subtract( QRect( QPoint( 0, 0 ), tableSize() ) ); | 612 | reg = reg.subtract( QRect( QPoint( 0, 0 ), tableSize() ) ); |
613 | // And draw the rectangles (transformed as needed) | 613 | // And draw the rectangles (transformed as needed) |
614 | QArray<QRect> r = reg.rects(); | 614 | QArray<QRect> r = reg.rects(); |
615 | for (unsigned int i=0; i<r.count(); i++) | 615 | for (unsigned int i=0; i<r.count(); i++) |
616 | p->fillRect( r[i], colorGroup().brush( QColorGroup::Base ) ); | 616 | p->fillRect( r[i], colorGroup().brush( QColorGroup::Base ) ); |
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, int category ) | 638 | bool backwards, QString cat /* int category */ ) |
639 | { | 639 | { |
640 | int category = 0; | ||
641 | if ( cat.isEmpty() ) | ||
642 | category = -2; // mCat.id("Contacts", "All"); | ||
643 | else | ||
644 | category = mCat.id("Contacts", cat ); | ||
645 | |||
646 | qWarning ("Found in Category %d", category); | ||
647 | |||
640 | if ( currFindRow < -1 ) | 648 | if ( currFindRow < -1 ) |
641 | currFindRow = currentRow() - 1; | 649 | currFindRow = currentRow() - 1; |
642 | clearSelection( TRUE ); | 650 | clearSelection( TRUE ); |
643 | int rows, row; | 651 | int rows, row; |
644 | AbTableItem *ati; | 652 | AbTableItem *ati; |
645 | QRegExp r( findString ); | 653 | QRegExp r( findString ); |
646 | r.setCaseSensitive( caseSensitive ); | 654 | r.setCaseSensitive( caseSensitive ); |
647 | rows = numRows(); | 655 | rows = numRows(); |
648 | static bool wrapAround = true; | 656 | static bool wrapAround = true; |
649 | 657 | ||
650 | if ( !backwards ) { | 658 | if ( !backwards ) { |
651 | for ( row = currFindRow + 1; row < rows; row++ ) { | 659 | for ( row = currFindRow + 1; row < rows; row++ ) { |
652 | ati = static_cast<AbTableItem*>( item(row, 0) ); | 660 | ati = static_cast<AbTableItem*>( item(row, 0) ); |
653 | if ( contactCompare( contactList[ati], r, category ) ) | 661 | if ( contactCompare( contactList[ati], r, category ) ) |
654 | //if ( contactCompare( contactList[row], r, category ) ) | 662 | //if ( contactCompare( contactList[row], r, category ) ) |
655 | break; | 663 | break; |
656 | } | 664 | } |
657 | } else { | 665 | } else { |
658 | for ( row = currFindRow - 1; row > -1; row-- ) { | 666 | for ( row = currFindRow - 1; row > -1; row-- ) { |
659 | ati = static_cast<AbTableItem*>( item(row, 0) ); | 667 | ati = static_cast<AbTableItem*>( item(row, 0) ); |
660 | if ( contactCompare( contactList[ati], r, category ) ) | 668 | if ( contactCompare( contactList[ati], r, category ) ) |
661 | //if ( contactCompare( contactList[row], r, category ) ) | 669 | //if ( contactCompare( contactList[row], r, category ) ) |
662 | break; | 670 | break; |
663 | } | 671 | } |
664 | } | 672 | } |
665 | if ( row >= rows || row < 0 ) { | 673 | if ( row >= rows || row < 0 ) { |
666 | if ( row < 0 ) | 674 | if ( row < 0 ) |
667 | currFindRow = rows; | 675 | currFindRow = rows; |
668 | else | 676 | else |
669 | currFindRow = -1; | 677 | currFindRow = -1; |
670 | 678 | ||
671 | if ( wrapAround ) | 679 | if ( wrapAround ) |
672 | emit signalWrapAround(); | 680 | emit signalWrapAround(); |
673 | else | 681 | else |
674 | emit signalNotFound(); | 682 | emit signalNotFound(); |
675 | 683 | ||
676 | wrapAround = !wrapAround; | 684 | wrapAround = !wrapAround; |
677 | } else { | 685 | } else { |
678 | currFindRow = row; | 686 | currFindRow = row; |
679 | QTableSelection foundSelection; | 687 | QTableSelection foundSelection; |
680 | foundSelection.init( currFindRow, 0 ); | 688 | foundSelection.init( currFindRow, 0 ); |
681 | foundSelection.expandTo( currFindRow, numCols() - 1 ); | 689 | foundSelection.expandTo( currFindRow, numCols() - 1 ); |
682 | addSelection( foundSelection ); | 690 | addSelection( foundSelection ); |
683 | setCurrentCell( currFindRow, numCols() - 1 ); | 691 | setCurrentCell( currFindRow, numCols() - 1 ); |
684 | wrapAround = true; | 692 | wrapAround = true; |
685 | } | 693 | } |
686 | } | 694 | } |
687 | 695 | ||
688 | static bool contactCompare( const OContact &cnt, const QRegExp &r, int category ) | 696 | static bool contactCompare( const OContact &cnt, const QRegExp &r, int category ) |
689 | { | 697 | { |
690 | bool returnMe; | 698 | bool returnMe; |
691 | QArray<int> cats; | 699 | QArray<int> cats; |
692 | cats = cnt.categories(); | 700 | cats = cnt.categories(); |
693 | 701 | ||
694 | returnMe = false; | 702 | returnMe = false; |
695 | if ( (category == -1 && cats.count() == 0) || category == -2 ) | 703 | if ( (category == -1 && cats.count() == 0) || category == -2 ) |
696 | returnMe = cnt.match( r ); | 704 | returnMe = cnt.match( r ); |
697 | else { | 705 | else { |
698 | int i; | 706 | int i; |
699 | for ( i = 0; i < int(cats.count()); i++ ) { | 707 | for ( i = 0; i < int(cats.count()); i++ ) { |
700 | if ( cats[i] == category ) { | 708 | if ( cats[i] == category ) { |
701 | returnMe = cnt.match( r ); | 709 | returnMe = cnt.match( r ); |
702 | break; | 710 | break; |
703 | } | 711 | } |
704 | } | 712 | } |
705 | } | 713 | } |
706 | 714 | ||
707 | return returnMe; | 715 | return returnMe; |
708 | } | 716 | } |
709 | 717 | ||
710 | void AbTable::fitColumns() | 718 | void AbTable::fitColumns() |
711 | { | 719 | { |
712 | int contentsWidth = visibleWidth() / 2; | 720 | int contentsWidth = visibleWidth() / 2; |
713 | 721 | ||
714 | if ( showBk == "Cards" ) { | 722 | if ( showBk == "Cards" ) { |
715 | showColumn(1); | 723 | showColumn(1); |
716 | //adjustColumn(1); | 724 | //adjustColumn(1); |
717 | setColumnWidth( 1, visibleWidth() ); | 725 | setColumnWidth( 1, visibleWidth() ); |
718 | columnVisible = false; | 726 | columnVisible = false; |
719 | } else { | 727 | } else { |
720 | if ( columnVisible == false ){ | 728 | if ( columnVisible == false ){ |
721 | showColumn(0); | 729 | showColumn(0); |
722 | columnVisible = true; | 730 | columnVisible = true; |
723 | } | 731 | } |
724 | setColumnWidth( 0, contentsWidth ); | 732 | setColumnWidth( 0, contentsWidth ); |
725 | adjustColumn(1); | 733 | adjustColumn(1); |
726 | if ( columnWidth(1) < contentsWidth ) | 734 | if ( columnWidth(1) < contentsWidth ) |
727 | setColumnWidth( 1, contentsWidth ); | 735 | setColumnWidth( 1, contentsWidth ); |
728 | } | 736 | } |
729 | } | 737 | } |
730 | 738 | ||
731 | void AbTable::show() | 739 | void AbTable::show() |
732 | { | 740 | { |
733 | fitColumns(); | 741 | fitColumns(); |
734 | QTable::show(); | 742 | QTable::show(); |
735 | } | 743 | } |
736 | 744 | ||
737 | void AbTable::setChoiceNames( const QStringList& list) | 745 | void AbTable::setChoiceNames( const QStringList& list) |
738 | { | 746 | { |
739 | choicenames = list; | 747 | choicenames = list; |
740 | if ( choicenames.isEmpty() ) { | 748 | if ( choicenames.isEmpty() ) { |
741 | // hide pick column | 749 | // hide pick column |
742 | setNumCols( 2 ); | 750 | setNumCols( 2 ); |
743 | } else { | 751 | } else { |
744 | // show pick column | 752 | // show pick column |
745 | setNumCols( 3 ); | 753 | setNumCols( 3 ); |
746 | setColumnWidth( 2, fontMetrics().width(tr( "Pick" ))+8 ); | 754 | setColumnWidth( 2, fontMetrics().width(tr( "Pick" ))+8 ); |
747 | horizontalHeader()->setLabel( 2, tr( "Pick" )); | 755 | horizontalHeader()->setLabel( 2, tr( "Pick" )); |
748 | } | 756 | } |
749 | fitColumns(); | 757 | fitColumns(); |
750 | } | 758 | } |
751 | 759 | ||
752 | void AbTable::itemClicked(int,int col) | 760 | void AbTable::itemClicked(int,int col) |
753 | { | 761 | { |
754 | if ( col == 2 ) { | 762 | if ( col == 2 ) { |
755 | return; | 763 | return; |
756 | } else { | 764 | } else { |
757 | emit details(); | 765 | emit details(); |
758 | } | 766 | } |
759 | } | 767 | } |
760 | 768 | ||
761 | QStringList AbTable::choiceNames() const | 769 | QStringList AbTable::choiceNames() const |
762 | { | 770 | { |
763 | return choicenames; | 771 | return choicenames; |
764 | } | 772 | } |
765 | 773 | ||
766 | void AbTable::setChoiceSelection(int /*index*/, const QStringList& /*list*/) | 774 | void AbTable::setChoiceSelection(int /*index*/, const QStringList& /*list*/) |
767 | { | 775 | { |
768 | /* ###### | 776 | /* ###### |
769 | 777 | ||
770 | QString selname = choicenames.at(index); | 778 | QString selname = choicenames.at(index); |
771 | for (each row) { | 779 | for (each row) { |
772 | OContact *c = contactForRow(row); | 780 | OContact *c = contactForRow(row); |
773 | if ( list.contains(c->email) ) { | 781 | if ( list.contains(c->email) ) { |
774 | list.remove(c->email); | 782 | list.remove(c->email); |
775 | setText(row, 2, selname); | 783 | setText(row, 2, selname); |
776 | } | 784 | } |
777 | } | 785 | } |
778 | for (remaining list items) { | 786 | for (remaining list items) { |
779 | OContact *c = new contact(item); | 787 | OContact *c = new contact(item); |
780 | setText(newrow, 2, selname); | 788 | setText(newrow, 2, selname); |
781 | } | 789 | } |
782 | 790 | ||
783 | */ | 791 | */ |
784 | } | 792 | } |
785 | 793 | ||
786 | QStringList AbTable::choiceSelection(int /*index*/) const | 794 | QStringList AbTable::choiceSelection(int /*index*/) const |
787 | { | 795 | { |
788 | QStringList r; | 796 | QStringList r; |
789 | /* ###### | 797 | /* ###### |
790 | 798 | ||
791 | QString selname = choicenames.at(index); | 799 | QString selname = choicenames.at(index); |
792 | for (each row) { | 800 | for (each row) { |
793 | OContact *c = contactForRow(row); | 801 | OContact *c = contactForRow(row); |
794 | if ( text(row,2) == selname ) { | 802 | if ( text(row,2) == selname ) { |
795 | r.append(c->email); | 803 | r.append(c->email); |
796 | } | 804 | } |
797 | } | 805 | } |
798 | 806 | ||
799 | */ | 807 | */ |
800 | return r; | 808 | return r; |
801 | } | 809 | } |
802 | 810 | ||
803 | void AbTable::setShowCategory( const QString &b, const QString &c ) | 811 | void AbTable::setShowCategory( const QString &b, const QString &c ) |
804 | { | 812 | { |
805 | showBk = b; | 813 | showBk = b; |
806 | showCat = c; | 814 | showCat = c; |
807 | //QMessageBox::information( this, "setShowCategory", "setShowCategory" ); | 815 | //QMessageBox::information( this, "setShowCategory", "setShowCategory" ); |
808 | //updateVisible(); | 816 | //updateVisible(); |
809 | refresh(); | 817 | refresh(); |
810 | ensureCellVisible( currentRow(), 0 ); | 818 | ensureCellVisible( currentRow(), 0 ); |
811 | updateVisible(); // :SX | 819 | updateVisible(); // :SX |
812 | } | 820 | } |
813 | 821 | ||
814 | void AbTable::setShowByLetter( char c ) | 822 | void AbTable::setShowByLetter( char c ) |
815 | { | 823 | { |
816 | showChar = tolower(c); | 824 | showChar = tolower(c); |
817 | updateVisible(); | 825 | updateVisible(); |
818 | } | 826 | } |
819 | 827 | ||
820 | QString AbTable::showCategory() const | 828 | QString AbTable::showCategory() const |
821 | { | 829 | { |
822 | return showCat; | 830 | return showCat; |
823 | } | 831 | } |
824 | 832 | ||
825 | QString AbTable::showBook() const | 833 | QString AbTable::showBook() const |
826 | { | 834 | { |
827 | return showBk; | 835 | return showBk; |
828 | } | 836 | } |
829 | 837 | ||
830 | QStringList AbTable::categories() | 838 | QStringList AbTable::categories() |
831 | { | 839 | { |
diff --git a/core/pim/addressbook/abtable.h b/core/pim/addressbook/abtable.h index 80c3ca0..a603e17 100644 --- a/core/pim/addressbook/abtable.h +++ b/core/pim/addressbook/abtable.h | |||
@@ -1,154 +1,154 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #ifndef ABTABLE_H | 21 | #ifndef ABTABLE_H |
22 | #define ABTABLE_H | 22 | #define ABTABLE_H |
23 | 23 | ||
24 | #include <qpe/categories.h> | 24 | #include <qpe/categories.h> |
25 | #include <opie/ocontact.h> | 25 | #include <opie/ocontact.h> |
26 | 26 | ||
27 | #include <qmap.h> | 27 | #include <qmap.h> |
28 | #include <qtable.h> | 28 | #include <qtable.h> |
29 | #include <qstringlist.h> | 29 | #include <qstringlist.h> |
30 | #include <qcombobox.h> | 30 | #include <qcombobox.h> |
31 | 31 | ||
32 | #include <opie/ocontactaccess.h> | 32 | #include <opie/ocontactaccess.h> |
33 | 33 | ||
34 | class AbTableItem : public QTableItem | 34 | class AbTableItem : public QTableItem |
35 | { | 35 | { |
36 | public: | 36 | public: |
37 | AbTableItem( QTable *t, EditType et, const QString &s, | 37 | AbTableItem( QTable *t, EditType et, const QString &s, |
38 | const QString &secondSortKey); | 38 | const QString &secondSortKey); |
39 | QString entryKey() const; | 39 | QString entryKey() const; |
40 | void setEntryKey( const QString & k ); | 40 | void setEntryKey( const QString & k ); |
41 | virtual int alignment() const; | 41 | virtual int alignment() const; |
42 | virtual QString key() const; | 42 | virtual QString key() const; |
43 | void setItem( const QString &txt, const QString &secondKey ); | 43 | void setItem( const QString &txt, const QString &secondKey ); |
44 | 44 | ||
45 | private: | 45 | private: |
46 | QString sortKey; | 46 | QString sortKey; |
47 | }; | 47 | }; |
48 | 48 | ||
49 | class AbPickItem : public QTableItem | 49 | class AbPickItem : public QTableItem |
50 | { | 50 | { |
51 | public: | 51 | public: |
52 | AbPickItem( QTable *t ); | 52 | AbPickItem( QTable *t ); |
53 | 53 | ||
54 | QWidget *createEditor() const; | 54 | QWidget *createEditor() const; |
55 | void setContentFromEditor( QWidget *w ); | 55 | void setContentFromEditor( QWidget *w ); |
56 | 56 | ||
57 | private: | 57 | private: |
58 | QGuardedPtr<QComboBox> cb; | 58 | QGuardedPtr<QComboBox> cb; |
59 | }; | 59 | }; |
60 | 60 | ||
61 | class AbTable : public QTable | 61 | class AbTable : public QTable |
62 | { | 62 | { |
63 | Q_OBJECT | 63 | Q_OBJECT |
64 | 64 | ||
65 | public: | 65 | public: |
66 | AbTable( const QValueList<int> *ordered, QWidget *parent, const char *name=0 ); | 66 | AbTable( const QValueList<int> *ordered, QWidget *parent, const char *name=0 ); |
67 | ~AbTable(); | 67 | ~AbTable(); |
68 | // NEW | 68 | // NEW |
69 | void addEntry( const OContact &newContact ); | 69 | void addEntry( const OContact &newContact ); |
70 | OContact currentEntry(); | 70 | OContact currentEntry(); |
71 | void replaceCurrentEntry( const OContact &newContact ); | 71 | void replaceCurrentEntry( const OContact &newContact ); |
72 | 72 | ||
73 | void init(); | 73 | void init(); |
74 | 74 | ||
75 | void deleteCurrentEntry(); | 75 | void deleteCurrentEntry(); |
76 | void clear(); | 76 | void clear(); |
77 | void clearFindRow() { currFindRow = -2; } | 77 | void clearFindRow() { currFindRow = -2; } |
78 | void loadFields(); | 78 | void loadFields(); |
79 | void refresh(); | 79 | void refresh(); |
80 | bool save(); | 80 | bool save(); |
81 | void load(); | 81 | void load(); |
82 | void reload(); | 82 | void reload(); |
83 | 83 | ||
84 | // addresspicker mode | 84 | // addresspicker mode |
85 | void setChoiceNames( const QStringList& list); | 85 | void setChoiceNames( const QStringList& list); |
86 | QStringList choiceNames() const; | 86 | QStringList choiceNames() const; |
87 | void setChoiceSelection(int index, const QStringList& list); | 87 | void setChoiceSelection(int index, const QStringList& list); |
88 | QStringList choiceSelection(int index) const; | 88 | QStringList choiceSelection(int index) const; |
89 | void setShowCategory( const QString &b, const QString &c ); | 89 | void setShowCategory( const QString &b, const QString &c ); |
90 | void setShowByLetter( char c ); | 90 | void setShowByLetter( char c ); |
91 | QString showCategory() const; | 91 | QString showCategory() const; |
92 | QStringList categories(); | 92 | QStringList categories(); |
93 | 93 | ||
94 | void resizeRows(); | 94 | void resizeRows(); |
95 | 95 | ||
96 | void show(); | 96 | void show(); |
97 | void setPaintingEnabled( bool e ); | 97 | void setPaintingEnabled( bool e ); |
98 | 98 | ||
99 | QString showBook() const; | 99 | QString showBook() const; |
100 | 100 | ||
101 | public slots: | 101 | public slots: |
102 | void slotDoFind( const QString &str, bool caseSensitive, bool backwards, | 102 | void slotDoFind( const QString &str, bool caseSensitive, bool backwards, |
103 | int category ); | 103 | QString category = QString::null ); |
104 | signals: | 104 | signals: |
105 | void empty( bool ); | 105 | void empty( bool ); |
106 | void details(); | 106 | void details(); |
107 | void signalNotFound(); | 107 | void signalNotFound(); |
108 | void signalWrapAround(); | 108 | void signalWrapAround(); |
109 | 109 | ||
110 | protected: | 110 | protected: |
111 | virtual void keyPressEvent( QKeyEvent *e ); | 111 | virtual void keyPressEvent( QKeyEvent *e ); |
112 | 112 | ||
113 | // int rowHeight( int ) const; | 113 | // int rowHeight( int ) const; |
114 | // int rowPos( int row ) const; | 114 | // int rowPos( int row ) const; |
115 | // virtual int rowAt( int pos ) const; | 115 | // virtual int rowAt( int pos ) const; |
116 | 116 | ||
117 | 117 | ||
118 | protected slots: | 118 | protected slots: |
119 | void moveTo( char ); | 119 | void moveTo( char ); |
120 | virtual void columnClicked( int col ); | 120 | virtual void columnClicked( int col ); |
121 | void itemClicked(int,int col); | 121 | void itemClicked(int,int col); |
122 | void rowHeightChanged( int row ); | 122 | void rowHeightChanged( int row ); |
123 | 123 | ||
124 | private: | 124 | private: |
125 | void loadFile( const QString &strFile, bool journalFile ); | 125 | void loadFile( const QString &strFile, bool journalFile ); |
126 | void fitColumns(); | 126 | void fitColumns(); |
127 | void resort(); | 127 | void resort(); |
128 | void updateJournal( const OContact &contact, OContact::journal_action action, | 128 | void updateJournal( const OContact &contact, OContact::journal_action action, |
129 | int row = -1 ); | 129 | int row = -1 ); |
130 | void insertIntoTable( const OContact &contact, int row ); | 130 | void insertIntoTable( const OContact &contact, int row ); |
131 | QString findContactName( const OContact &entry ); | 131 | QString findContactName( const OContact &entry ); |
132 | QString findContactContact( const OContact &entry, int row ); | 132 | QString findContactContact( const OContact &entry, int row ); |
133 | void journalFreeReplace( const OContact &cnt, int row ); | 133 | void journalFreeReplace( const OContact &cnt, int row ); |
134 | void journalFreeRemove( int row ); | 134 | void journalFreeRemove( int row ); |
135 | void realignTable( int ); | 135 | void realignTable( int ); |
136 | void updateVisible(); | 136 | void updateVisible(); |
137 | int lastSortCol; | 137 | int lastSortCol; |
138 | bool asc; | 138 | bool asc; |
139 | char showChar; | 139 | char showChar; |
140 | QMap<AbTableItem*, OContact> contactList; | 140 | QMap<AbTableItem*, OContact> contactList; |
141 | const QValueList<int> *intFields; | 141 | const QValueList<int> *intFields; |
142 | int currFindRow; | 142 | int currFindRow; |
143 | QString showCat; | 143 | QString showCat; |
144 | QStringList choicenames; | 144 | QStringList choicenames; |
145 | bool enablePainting; | 145 | bool enablePainting; |
146 | Categories mCat; | 146 | Categories mCat; |
147 | 147 | ||
148 | QString showBk; | 148 | QString showBk; |
149 | bool columnVisible; | 149 | bool columnVisible; |
150 | 150 | ||
151 | OContactAccess m_contactdb; | 151 | OContactAccess m_contactdb; |
152 | 152 | ||
153 | }; | 153 | }; |
154 | #endif // ABTABLE_H | 154 | #endif // ABTABLE_H |
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp index 82a1b57..8335d8b 100644 --- a/core/pim/addressbook/addressbook.cpp +++ b/core/pim/addressbook/addressbook.cpp | |||
@@ -1,393 +1,400 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** OContact info@trolltech.com if any conditions of this licensing are | 16 | ** OContact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #define QTOPIA_INTERNAL_FD | 21 | #define QTOPIA_INTERNAL_FD |
22 | 22 | ||
23 | #include "contacteditor.h" | 23 | #include "contacteditor.h" |
24 | #include "ablabel.h" | 24 | #include "ablabel.h" |
25 | #include "abtable.h" | 25 | #include "abtable.h" |
26 | #include "addresssettings.h" | 26 | #include "addresssettings.h" |
27 | #include "addressbook.h" | 27 | #include "addressbook.h" |
28 | 28 | ||
29 | 29 | ||
30 | #include <opie/ofileselector.h> | 30 | #include <opie/ofileselector.h> |
31 | #include <opie/ofiledialog.h> | 31 | #include <opie/ofiledialog.h> |
32 | #include <qpe/qpeapplication.h> | 32 | #include <qpe/qpeapplication.h> |
33 | #include <qpe/config.h> | 33 | #include <qpe/config.h> |
34 | #include <opie/ocontact.h> | 34 | #include <opie/ocontact.h> |
35 | 35 | ||
36 | #ifndef MAKE_FOR_SHARP_ROM | 36 | #ifndef MAKE_FOR_SHARP_ROM |
37 | #include <qpe/finddialog.h> | 37 | #include <qpe/finddialog.h> |
38 | #endif | 38 | #endif |
39 | 39 | ||
40 | #include <qpe/global.h> | 40 | #include <qpe/global.h> |
41 | #include <qpe/resource.h> | 41 | #include <qpe/resource.h> |
42 | #include <qpe/ir.h> | 42 | #include <qpe/ir.h> |
43 | #include <qpe/qpemessagebox.h> | 43 | #include <qpe/qpemessagebox.h> |
44 | #include <qpe/qcopenvelope_qws.h> | 44 | #include <qpe/qcopenvelope_qws.h> |
45 | 45 | ||
46 | #include <qaction.h> | 46 | #include <qaction.h> |
47 | #include <qdialog.h> | 47 | #include <qdialog.h> |
48 | #include <qdir.h> | 48 | #include <qdir.h> |
49 | #include <qfile.h> | 49 | #include <qfile.h> |
50 | #include <qimage.h> | 50 | #include <qimage.h> |
51 | #include <qlayout.h> | 51 | #include <qlayout.h> |
52 | #include <qpe/qpemenubar.h> | 52 | #include <qpe/qpemenubar.h> |
53 | #include <qmessagebox.h> | 53 | #include <qmessagebox.h> |
54 | #include <qpixmap.h> | 54 | #include <qpixmap.h> |
55 | #include <qpopupmenu.h> | 55 | #include <qpopupmenu.h> |
56 | #include <qpe/qpetoolbar.h> | 56 | #include <qpe/qpetoolbar.h> |
57 | #include <qstringlist.h> | 57 | #include <qstringlist.h> |
58 | #include <qtoolbutton.h> | 58 | #include <qtoolbutton.h> |
59 | #include <qwhatsthis.h> | 59 | #include <qwhatsthis.h> |
60 | 60 | ||
61 | #include <stdlib.h> | 61 | #include <stdlib.h> |
62 | #include <sys/stat.h> | 62 | #include <sys/stat.h> |
63 | #include <sys/types.h> | 63 | #include <sys/types.h> |
64 | #include <fcntl.h> | 64 | #include <fcntl.h> |
65 | #include <unistd.h> | 65 | #include <unistd.h> |
66 | 66 | ||
67 | #include <qdatetime.h> | 67 | #include <qdatetime.h> |
68 | 68 | ||
69 | #include "picker.h" | 69 | #include "picker.h" |
70 | 70 | ||
71 | // Remove this for OPIE releae 1.0 ! | ||
72 | #define __DEBUG_RELEASE | ||
73 | |||
74 | |||
75 | static QString addressbookPersonalVCardName() | 71 | static QString addressbookPersonalVCardName() |
76 | { | 72 | { |
77 | QString filename = Global::applicationFileName("addressbook", | 73 | QString filename = Global::applicationFileName("addressbook", |
78 | "businesscard.vcf"); | 74 | "businesscard.vcf"); |
79 | return filename; | 75 | return filename; |
80 | } | 76 | } |
81 | 77 | ||
82 | 78 | ||
83 | AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, | 79 | AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, |
84 | WFlags f ) | 80 | WFlags f ) |
85 | : QMainWindow( parent, name, f ), | 81 | : QMainWindow( parent, name, f ), |
86 | abEditor(0), | 82 | abEditor(0), |
87 | bAbEditFirstTime(TRUE), | 83 | bAbEditFirstTime(TRUE), |
88 | syncing(FALSE) | 84 | syncing(FALSE) |
89 | { | 85 | { |
90 | isLoading = true; | 86 | isLoading = true; |
91 | 87 | ||
92 | initFields(); | 88 | initFields(); |
93 | 89 | ||
94 | setCaption( tr("Contacts") ); | 90 | setCaption( tr("Contacts") ); |
95 | setIcon( Resource::loadPixmap( "AddressBook" ) ); | 91 | setIcon( Resource::loadPixmap( "AddressBook" ) ); |
96 | 92 | ||
97 | setToolBarsMovable( FALSE ); | 93 | setToolBarsMovable( FALSE ); |
98 | 94 | ||
99 | // Create Toolbars | 95 | // Create Toolbars |
100 | 96 | ||
101 | QPEToolBar *bar = new QPEToolBar( this ); | 97 | QPEToolBar *bar = new QPEToolBar( this ); |
102 | bar->setHorizontalStretchable( TRUE ); | 98 | bar->setHorizontalStretchable( TRUE ); |
103 | 99 | ||
104 | QPEMenuBar *mbList = new QPEMenuBar( bar ); | 100 | QPEMenuBar *mbList = new QPEMenuBar( bar ); |
105 | mbList->setMargin( 0 ); | 101 | mbList->setMargin( 0 ); |
106 | 102 | ||
107 | QPopupMenu *edit = new QPopupMenu( this ); | 103 | QPopupMenu *edit = new QPopupMenu( this ); |
108 | mbList->insertItem( tr( "Contact" ), edit ); | 104 | mbList->insertItem( tr( "Contact" ), edit ); |
109 | 105 | ||
110 | listTools = new QPEToolBar( this, "list operations" ); | 106 | listTools = new QPEToolBar( this, "list operations" ); |
111 | 107 | ||
112 | 108 | ||
113 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, | 109 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, |
114 | 0, this, 0 ); | 110 | 0, this, 0 ); |
115 | actionNew = a; | 111 | actionNew = a; |
116 | connect( a, SIGNAL( activated() ), this, SLOT( slotListNew() ) ); | 112 | connect( a, SIGNAL( activated() ), this, SLOT( slotListNew() ) ); |
117 | a->addTo( edit ); | 113 | a->addTo( edit ); |
118 | a->addTo( listTools ); | 114 | a->addTo( listTools ); |
119 | 115 | ||
120 | a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null, | 116 | a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null, |
121 | 0, this, 0 ); | 117 | 0, this, 0 ); |
122 | actionEdit = a; | 118 | actionEdit = a; |
123 | connect( a, SIGNAL( activated() ), this, SLOT( slotViewEdit() ) ); | 119 | connect( a, SIGNAL( activated() ), this, SLOT( slotViewEdit() ) ); |
124 | a->addTo( edit ); | 120 | a->addTo( edit ); |
125 | a->addTo( listTools ); | 121 | a->addTo( listTools ); |
126 | 122 | ||
127 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, | 123 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, |
128 | 0, this, 0 ); | 124 | 0, this, 0 ); |
129 | actionTrash = a; | 125 | actionTrash = a; |
130 | connect( a, SIGNAL( activated() ), this, SLOT( slotListDelete() ) ); | 126 | connect( a, SIGNAL( activated() ), this, SLOT( slotListDelete() ) ); |
131 | a->addTo( edit ); | 127 | a->addTo( edit ); |
132 | a->addTo( listTools ); | 128 | a->addTo( listTools ); |
133 | 129 | ||
134 | 130 | ||
135 | // make it possible to go directly to businesscard via qcop call | 131 | // make it possible to go directly to businesscard via qcop call |
136 | #if defined(Q_WS_QWS) | 132 | #if defined(Q_WS_QWS) |
137 | #if !defined(QT_NO_COP) | 133 | #if !defined(QT_NO_COP) |
138 | QCopChannel *addressChannel = new QCopChannel("QPE/Addressbook" , this ); | 134 | QCopChannel *addressChannel = new QCopChannel("QPE/Addressbook" , this ); |
139 | connect (addressChannel, SIGNAL( received(const QCString &, const QByteArray &)), | 135 | connect (addressChannel, SIGNAL( received(const QCString &, const QByteArray &)), |
140 | this, SLOT ( appMessage(const QCString &, const QByteArray &) ) ); | 136 | this, SLOT ( appMessage(const QCString &, const QByteArray &) ) ); |
141 | #endif | 137 | #endif |
142 | #endif | 138 | #endif |
143 | |||
144 | |||
145 | |||
146 | |||
147 | |||
148 | #ifndef MAKE_FOR_SHARP_ROM | ||
149 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), | 139 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), |
150 | QString::null, 0, this, 0 ); | 140 | QString::null, 0, this, 0 ); |
151 | actionFind = a; | 141 | actionFind = a; |
152 | connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); | 142 | connect( a, SIGNAL(activated()), this, SLOT( slotFindOpen()) ); |
153 | a->addTo( edit ); | 143 | a->addTo( edit ); |
154 | a->addTo( listTools ); | 144 | a->addTo( listTools ); |
155 | #endif | 145 | |
156 | 146 | // Much better search widget, taken from QTReader.. (se) | |
147 | searchBar = new OFloatBar( "Search", this, QMainWindow::Top, TRUE ); | ||
148 | searchBar->setHorizontalStretchable( TRUE ); | ||
149 | searchBar->hide(); | ||
150 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); | ||
151 | // QFont f("unifont", 16 /*, QFont::Bold*/); | ||
152 | // searchEdit->setFont( f ); | ||
153 | searchBar->setStretchableWidget( searchEdit ); | ||
154 | connect( searchEdit, SIGNAL( returnPressed( ) ), | ||
155 | this, SLOT( slotFind( ) ) ); | ||
156 | |||
157 | a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 ); | ||
158 | connect( a, SIGNAL( activated() ), this, SLOT( slotFindNext() ) ); | ||
159 | a->addTo( searchBar ); | ||
160 | |||
161 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | ||
162 | connect( a, SIGNAL( activated() ), this, SLOT( slotFindClose() ) ); | ||
163 | a->addTo( searchBar ); | ||
157 | 164 | ||
158 | a = new QAction( tr( "Write Mail To" ), Resource::loadPixmap( "qtmail/reply" ), | 165 | a = new QAction( tr( "Write Mail To" ), Resource::loadPixmap( "qtmail/reply" ), |
159 | QString::null, 0, this, 0 ); | 166 | QString::null, 0, this, 0 ); |
160 | //a->setEnabled( FALSE ); we got support for it now :) zecke | 167 | //a->setEnabled( FALSE ); we got support for it now :) zecke |
161 | actionMail = a; | 168 | actionMail = a; |
162 | connect( a, SIGNAL( activated() ), this, SLOT( writeMail() ) ); | 169 | connect( a, SIGNAL( activated() ), this, SLOT( writeMail() ) ); |
163 | a->addTo( edit ); | 170 | a->addTo( edit ); |
164 | a->addTo( listTools ); | 171 | a->addTo( listTools ); |
165 | 172 | ||
166 | 173 | ||
167 | 174 | ||
168 | if ( Ir::supported() ) { | 175 | if ( Ir::supported() ) { |
169 | a = new QAction( tr ("Beam Entry" ), Resource::loadPixmap( "beam" ), QString::null, | 176 | a = new QAction( tr ("Beam Entry" ), Resource::loadPixmap( "beam" ), QString::null, |
170 | 0, this, 0 ); | 177 | 0, this, 0 ); |
171 | actionBeam = a; | 178 | actionBeam = a; |
172 | connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) ); | 179 | connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) ); |
173 | a->addTo( edit ); | 180 | a->addTo( edit ); |
174 | a->addTo( listTools ); | 181 | a->addTo( listTools ); |
175 | } | 182 | } |
176 | 183 | ||
177 | edit->insertSeparator(); | 184 | edit->insertSeparator(); |
178 | 185 | ||
179 | a = new QAction( tr("Import vCard"), QString::null, 0, 0, 0, TRUE ); | 186 | a = new QAction( tr("Import vCard"), QString::null, 0, 0, 0, TRUE ); |
180 | actionPersonal = a; | 187 | actionPersonal = a; |
181 | connect( a, SIGNAL( activated() ), this, SLOT( importvCard() ) ); | 188 | connect( a, SIGNAL( activated() ), this, SLOT( importvCard() ) ); |
182 | a->addTo( edit ); | 189 | a->addTo( edit ); |
183 | 190 | ||
184 | edit->insertSeparator(); | 191 | edit->insertSeparator(); |
185 | 192 | ||
186 | a = new QAction( tr("My Personal Details"), QString::null, 0, 0, 0, TRUE ); | 193 | a = new QAction( tr("My Personal Details"), QString::null, 0, 0, 0, TRUE ); |
187 | actionPersonal = a; | 194 | actionPersonal = a; |
188 | connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) ); | 195 | connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) ); |
189 | a->addTo( edit ); | 196 | a->addTo( edit ); |
190 | 197 | ||
191 | // Do we need this function ? (se) | 198 | // Do we need this function ? (se) |
192 | // a = new QAction( tr( "Arrange Edit Fields"), QString::null, 0, 0 ); | 199 | // a = new QAction( tr( "Arrange Edit Fields"), QString::null, 0, 0 ); |
193 | // connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); | 200 | // connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); |
194 | // a->addTo( edit ); | 201 | // a->addTo( edit ); |
195 | 202 | ||
196 | 203 | ||
197 | #ifdef __DEBUG_RELEASE | 204 | #ifdef __DEBUG_RELEASE |
198 | // Remove this function for public Release ! This is only | 205 | // Remove this function for public Release ! This is only |
199 | // for debug purposes .. | 206 | // for debug purposes .. |
200 | a = new QAction( tr( "Save all Data"), QString::null, 0, 0 ); | 207 | a = new QAction( tr( "Save all Data"), QString::null, 0, 0 ); |
201 | connect( a, SIGNAL( activated() ), this, SLOT( save() ) ); | 208 | connect( a, SIGNAL( activated() ), this , SLOT( slotSave() ) ); |
202 | a->addTo( edit ); | 209 | a->addTo( edit ); |
203 | #endif | 210 | #endif |
204 | 211 | ||
205 | // Create Views | 212 | // Create Views |
206 | listContainer = new QWidget( this ); | 213 | listContainer = new QWidget( this ); |
207 | 214 | ||
208 | QVBoxLayout *vb = new QVBoxLayout( listContainer ); | 215 | QVBoxLayout *vb = new QVBoxLayout( listContainer ); |
209 | 216 | ||
210 | abList = new AbTable( &orderedFields, listContainer, "table" ); | 217 | abList = new AbTable( &orderedFields, listContainer, "table" ); |
211 | vb->addWidget(abList); | 218 | vb->addWidget(abList); |
212 | // abList->setHScrollBarMode( QScrollView::AlwaysOff ); | 219 | // abList->setHScrollBarMode( QScrollView::AlwaysOff ); |
213 | connect( abList, SIGNAL( empty( bool ) ), this, SLOT( listIsEmpty( bool ) ) ); | 220 | connect( abList, SIGNAL( empty( bool ) ), this, SLOT( listIsEmpty( bool ) ) ); |
214 | connect( abList, SIGNAL( details() ), this, SLOT( slotListView() ) ); | 221 | connect( abList, SIGNAL( details() ), this, SLOT( slotListView() ) ); |
215 | connect( abList, SIGNAL(currentChanged(int,int)), this, SLOT(slotUpdateToolbar()) ); | 222 | connect( abList, SIGNAL(currentChanged(int,int)), this, SLOT(slotUpdateToolbar()) ); |
216 | 223 | ||
217 | mView = 0; | 224 | mView = 0; |
218 | 225 | ||
219 | abList->load(); | 226 | abList->load(); |
220 | 227 | ||
221 | pLabel = new LetterPicker( listContainer ); | 228 | pLabel = new LetterPicker( listContainer ); |
222 | connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char))); | 229 | connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char))); |
223 | vb->addWidget(pLabel); | 230 | vb->addWidget(pLabel); |
224 | catMenu = new QPopupMenu( this ); | 231 | catMenu = new QPopupMenu( this ); |
225 | catMenu->setCheckable( TRUE ); | 232 | catMenu->setCheckable( TRUE ); |
226 | connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) ); | 233 | connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) ); |
227 | populateCategories(); | 234 | populateCategories(); |
228 | 235 | ||
229 | mbList->insertItem( tr("View"), catMenu ); | 236 | mbList->insertItem( tr("View"), catMenu ); |
230 | // setCentralWidget( listContainer ); | 237 | // setCentralWidget( listContainer ); |
231 | 238 | ||
232 | fontMenu = new QPopupMenu(this); | 239 | fontMenu = new QPopupMenu(this); |
233 | fontMenu->setCheckable( true ); | 240 | fontMenu->setCheckable( true ); |
234 | connect( fontMenu, SIGNAL(activated(int)), this, SLOT(slotSetFont(int))); | 241 | connect( fontMenu, SIGNAL(activated(int)), this, SLOT(slotSetFont(int))); |
235 | 242 | ||
236 | fontMenu->insertItem(tr( "Small" ), 0); | 243 | fontMenu->insertItem(tr( "Small" ), 0); |
237 | fontMenu->insertItem(tr( "Normal" ), 1); | 244 | fontMenu->insertItem(tr( "Normal" ), 1); |
238 | fontMenu->insertItem(tr( "Large" ), 2); | 245 | fontMenu->insertItem(tr( "Large" ), 2); |
239 | 246 | ||
240 | defaultFont = new QFont( abList->font() ); | 247 | defaultFont = new QFont( abList->font() ); |
241 | 248 | ||
242 | slotSetFont(startFontSize); | 249 | slotSetFont(startFontSize); |
243 | 250 | ||
244 | mbList->insertItem( tr("Font"), fontMenu); | 251 | mbList->insertItem( tr("Font"), fontMenu); |
245 | setCentralWidget(listContainer); | 252 | setCentralWidget(listContainer); |
246 | 253 | ||
247 | // qDebug("adressbook contrsuction: t=%d", t.elapsed() ); | 254 | // qDebug("adressbook contrsuction: t=%d", t.elapsed() ); |
248 | 255 | ||
249 | abList->setCurrentCell( 0, 0 ); | 256 | abList->setCurrentCell( 0, 0 ); |
250 | 257 | ||
251 | isLoading = false; | 258 | isLoading = false; |
252 | } | 259 | } |
253 | 260 | ||
254 | 261 | ||
255 | void AddressbookWindow::slotSetFont( int size ) { | 262 | void AddressbookWindow::slotSetFont( int size ) { |
256 | 263 | ||
257 | if (size > 2 || size < 0) | 264 | if (size > 2 || size < 0) |
258 | size = 1; | 265 | size = 1; |
259 | 266 | ||
260 | startFontSize = size; | 267 | startFontSize = size; |
261 | 268 | ||
262 | QFont *currentFont; | 269 | QFont *currentFont; |
263 | 270 | ||
264 | switch (size) { | 271 | switch (size) { |
265 | case 0: | 272 | case 0: |
266 | fontMenu->setItemChecked(0, true); | 273 | fontMenu->setItemChecked(0, true); |
267 | fontMenu->setItemChecked(1, false); | 274 | fontMenu->setItemChecked(1, false); |
268 | fontMenu->setItemChecked(2, false); | 275 | fontMenu->setItemChecked(2, false); |
269 | abList->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) ); | 276 | abList->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) ); |
270 | currentFont = new QFont (abList->font()); | 277 | currentFont = new QFont (abList->font()); |
271 | // abList->resizeRows(currentFont->pixelSize() + 7); | 278 | // abList->resizeRows(currentFont->pixelSize() + 7); |
272 | abList->resizeRows(); | 279 | abList->resizeRows(); |
273 | break; | 280 | break; |
274 | case 1: | 281 | case 1: |
275 | fontMenu->setItemChecked(0, false); | 282 | fontMenu->setItemChecked(0, false); |
276 | fontMenu->setItemChecked(1, true); | 283 | fontMenu->setItemChecked(1, true); |
277 | fontMenu->setItemChecked(2, false); | 284 | fontMenu->setItemChecked(2, false); |
278 | abList->setFont( *defaultFont ); | 285 | abList->setFont( *defaultFont ); |
279 | currentFont = new QFont (abList->font()); | 286 | currentFont = new QFont (abList->font()); |
280 | // abList->resizeRows(currentFont->pixelSize() + 7); | 287 | // abList->resizeRows(currentFont->pixelSize() + 7); |
281 | abList->resizeRows(); | 288 | abList->resizeRows(); |
282 | break; | 289 | break; |
283 | case 2: | 290 | case 2: |
284 | fontMenu->setItemChecked(0, false); | 291 | fontMenu->setItemChecked(0, false); |
285 | fontMenu->setItemChecked(1, false); | 292 | fontMenu->setItemChecked(1, false); |
286 | fontMenu->setItemChecked(2, true); | 293 | fontMenu->setItemChecked(2, true); |
287 | abList->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) ); | 294 | abList->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) ); |
288 | currentFont = new QFont (abList->font()); | 295 | currentFont = new QFont (abList->font()); |
289 | //abList->resizeRows(currentFont->pixelSize() + 7); | 296 | //abList->resizeRows(currentFont->pixelSize() + 7); |
290 | abList->resizeRows(); | 297 | abList->resizeRows(); |
291 | break; | 298 | break; |
292 | } | 299 | } |
293 | } | 300 | } |
294 | 301 | ||
295 | 302 | ||
296 | 303 | ||
297 | void AddressbookWindow::importvCard() { | 304 | void AddressbookWindow::importvCard() { |
298 | QString str = OFileDialog::getOpenFileName( 1,"/");//,"", "*", this ); | 305 | QString str = OFileDialog::getOpenFileName( 1,"/");//,"", "*", this ); |
299 | if(!str.isEmpty() ) | 306 | if(!str.isEmpty() ) |
300 | setDocument((const QString&) str ); | 307 | setDocument((const QString&) str ); |
301 | 308 | ||
302 | } | 309 | } |
303 | 310 | ||
304 | void AddressbookWindow::setDocument( const QString &filename ) | 311 | void AddressbookWindow::setDocument( const QString &filename ) |
305 | { | 312 | { |
306 | if ( filename.find(".vcf") != int(filename.length()) - 4 ) | 313 | if ( filename.find(".vcf") != int(filename.length()) - 4 ) |
307 | return; | 314 | return; |
308 | 315 | ||
309 | QValueList<OContact> cl = OContact::readVCard( filename ); | 316 | QValueList<OContact> cl = OContact::readVCard( filename ); |
310 | for( QValueList<OContact>::Iterator it = cl.begin(); it != cl.end(); ++it ) { | 317 | for( QValueList<OContact>::Iterator it = cl.begin(); it != cl.end(); ++it ) { |
311 | // QString msg = tr("You received a vCard for\n%1.\nDo You want to add it to your\naddressbook?") | 318 | // QString msg = tr("You received a vCard for\n%1.\nDo You want to add it to your\naddressbook?") |
312 | // .arg( (*it).fullName() ); | 319 | // .arg( (*it).fullName() ); |
313 | // if ( QMessageBox::information( this, tr("received contact"), msg, QMessageBox::Ok, QMessageBox::Cancel ) == | 320 | // if ( QMessageBox::information( this, tr("received contact"), msg, QMessageBox::Ok, QMessageBox::Cancel ) == |
314 | // QMessageBox::Ok ) { | 321 | // QMessageBox::Ok ) { |
315 | abList->addEntry( *it ); | 322 | abList->addEntry( *it ); |
316 | // } | 323 | // } |
317 | } | 324 | } |
318 | 325 | ||
319 | } | 326 | } |
320 | 327 | ||
321 | void AddressbookWindow::resizeEvent( QResizeEvent *e ) | 328 | void AddressbookWindow::resizeEvent( QResizeEvent *e ) |
322 | { | 329 | { |
323 | QMainWindow::resizeEvent( e ); | 330 | QMainWindow::resizeEvent( e ); |
324 | 331 | ||
325 | if ( centralWidget() == listContainer ) | 332 | if ( centralWidget() == listContainer ) |
326 | showList(); | 333 | showList(); |
327 | else if ( centralWidget() == mView ) | 334 | else if ( centralWidget() == mView ) |
328 | showView(); | 335 | showView(); |
329 | } | 336 | } |
330 | 337 | ||
331 | AddressbookWindow::~AddressbookWindow() | 338 | AddressbookWindow::~AddressbookWindow() |
332 | { | 339 | { |
333 | Config cfg("AddressBook"); | 340 | Config cfg("AddressBook"); |
334 | cfg.setGroup("Font"); | 341 | cfg.setGroup("Font"); |
335 | cfg.writeEntry("fontSize", startFontSize); | 342 | cfg.writeEntry("fontSize", startFontSize); |
336 | } | 343 | } |
337 | 344 | ||
338 | void AddressbookWindow::slotUpdateToolbar() | 345 | void AddressbookWindow::slotUpdateToolbar() |
339 | { | 346 | { |
340 | OContact ce = abList->currentEntry(); | 347 | OContact ce = abList->currentEntry(); |
341 | actionMail->setEnabled( !ce.defaultEmail().isEmpty() ); | 348 | actionMail->setEnabled( !ce.defaultEmail().isEmpty() ); |
342 | } | 349 | } |
343 | 350 | ||
344 | void AddressbookWindow::showList() | 351 | void AddressbookWindow::showList() |
345 | { | 352 | { |
346 | bool visiblemView; | 353 | bool visiblemView; |
347 | 354 | ||
348 | visiblemView = false; | 355 | visiblemView = false; |
349 | if ( mView ) { | 356 | if ( mView ) { |
350 | mView->hide(); | 357 | mView->hide(); |
351 | visiblemView = true; | 358 | visiblemView = true; |
352 | } | 359 | } |
353 | setCentralWidget( listContainer ); | 360 | setCentralWidget( listContainer ); |
354 | listContainer->show(); | 361 | listContainer->show(); |
355 | // update our focues... (or use a stack widget!); | 362 | // update our focues... (or use a stack widget!); |
356 | abList->setFocus(); | 363 | abList->setFocus(); |
357 | 364 | ||
358 | // This makes sure we are scrolled all the way to the left | 365 | // This makes sure we are scrolled all the way to the left |
359 | abList->setContentsPos( 0, abList->contentsY() ); | 366 | abList->setContentsPos( 0, abList->contentsY() ); |
360 | 367 | ||
361 | //if ( visiblemView && abList->showBook() == "Cards" ) | 368 | //if ( visiblemView && abList->showBook() == "Cards" ) |
362 | //abList->setShowCategory( abList->showBook(), abList->showCategory() ); | 369 | //abList->setShowCategory( abList->showBook(), abList->showCategory() ); |
363 | 370 | ||
364 | } | 371 | } |
365 | 372 | ||
366 | void AddressbookWindow::showView() | 373 | void AddressbookWindow::showView() |
367 | { | 374 | { |
368 | if ( abList->numRows() > 0 ) { | 375 | if ( abList->numRows() > 0 ) { |
369 | listContainer->hide(); | 376 | listContainer->hide(); |
370 | setCentralWidget( abView() ); | 377 | setCentralWidget( abView() ); |
371 | mView->show(); | 378 | mView->show(); |
372 | mView->setFocus(); | 379 | mView->setFocus(); |
373 | } | 380 | } |
374 | } | 381 | } |
375 | 382 | ||
376 | void AddressbookWindow::slotListNew() | 383 | void AddressbookWindow::slotListNew() |
377 | { | 384 | { |
378 | OContact cnt; | 385 | OContact cnt; |
379 | if( !syncing ) { | 386 | if( !syncing ) { |
380 | if ( abEditor ) | 387 | if ( abEditor ) |
381 | abEditor->setEntry( cnt ); | 388 | abEditor->setEntry( cnt ); |
382 | abView()->init( cnt ); | 389 | abView()->init( cnt ); |
383 | editEntry( NewEntry ); | 390 | editEntry( NewEntry ); |
384 | } else { | 391 | } else { |
385 | QMessageBox::warning(this, tr("OContacts"), | 392 | QMessageBox::warning(this, tr("OContacts"), |
386 | tr("Can not edit data, currently syncing")); | 393 | tr("Can not edit data, currently syncing")); |
387 | } | 394 | } |
388 | } | 395 | } |
389 | 396 | ||
390 | void AddressbookWindow::slotListView() | 397 | void AddressbookWindow::slotListView() |
391 | { | 398 | { |
392 | abView()->init( abList->currentEntry() ); | 399 | abView()->init( abList->currentEntry() ); |
393 | mView->sync(); | 400 | mView->sync(); |
@@ -564,437 +571,457 @@ void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) | |||
564 | picker.showMaximized(); | 571 | picker.showMaximized(); |
565 | picker.exec(); | 572 | picker.exec(); |
566 | 573 | ||
567 | // ###### note: contacts may have been added - save here! | 574 | // ###### note: contacts may have been added - save here! |
568 | 575 | ||
569 | setCentralWidget(abList); | 576 | setCentralWidget(abList); |
570 | QCopEnvelope e(ch,m); | 577 | QCopEnvelope e(ch,m); |
571 | i=0; | 578 | i=0; |
572 | for (QStringList::ConstIterator it = types.begin(); it!=types.end(); ++it) { | 579 | for (QStringList::ConstIterator it = types.begin(); it!=types.end(); ++it) { |
573 | QStringList sel = picker.selection(i++); | 580 | QStringList sel = picker.selection(i++); |
574 | e << sel; | 581 | e << sel; |
575 | } | 582 | } |
576 | } | 583 | } |
577 | #endif | 584 | #endif |
578 | 585 | ||
579 | } | 586 | } |
580 | 587 | ||
581 | void AddressbookWindow::editPersonal() | 588 | void AddressbookWindow::editPersonal() |
582 | { | 589 | { |
583 | QString filename = addressbookPersonalVCardName(); | 590 | QString filename = addressbookPersonalVCardName(); |
584 | OContact me; | 591 | OContact me; |
585 | if (QFile::exists(filename)) | 592 | if (QFile::exists(filename)) |
586 | me = OContact::readVCard( filename )[0]; | 593 | me = OContact::readVCard( filename )[0]; |
587 | if (bAbEditFirstTime) { | 594 | if (bAbEditFirstTime) { |
588 | abEditor = new ContactEditor( me, &orderedFields, &slOrderedFields, | 595 | abEditor = new ContactEditor( me, &orderedFields, &slOrderedFields, |
589 | this, "editor" ); | 596 | this, "editor" ); |
590 | // don't create a new editor every time | 597 | // don't create a new editor every time |
591 | bAbEditFirstTime = FALSE; | 598 | bAbEditFirstTime = FALSE; |
592 | } else | 599 | } else |
593 | abEditor->setEntry( me ); | 600 | abEditor->setEntry( me ); |
594 | 601 | ||
595 | abEditor->setCaption(tr("Edit My Personal Details")); | 602 | abEditor->setCaption(tr("Edit My Personal Details")); |
596 | abEditor->showMaximized(); | 603 | abEditor->showMaximized(); |
597 | 604 | ||
598 | // fix the foxus... | 605 | // fix the foxus... |
599 | abEditor->setNameFocus(); | 606 | abEditor->setNameFocus(); |
600 | if ( abEditor->exec() ) { | 607 | if ( abEditor->exec() ) { |
601 | setFocus(); | 608 | setFocus(); |
602 | OContact new_personal = abEditor->entry(); | 609 | OContact new_personal = abEditor->entry(); |
603 | QString fname = addressbookPersonalVCardName(); | 610 | QString fname = addressbookPersonalVCardName(); |
604 | OContact::writeVCard( fname, new_personal ); | 611 | OContact::writeVCard( fname, new_personal ); |
605 | abView()->init(new_personal); | 612 | abView()->init(new_personal); |
606 | abView()->sync(); | 613 | abView()->sync(); |
607 | } | 614 | } |
608 | abEditor->setCaption( tr("Edit Address") ); | 615 | abEditor->setCaption( tr("Edit Address") ); |
609 | } | 616 | } |
610 | 617 | ||
611 | void AddressbookWindow::slotPersonalView() | 618 | void AddressbookWindow::slotPersonalView() |
612 | { | 619 | { |
613 | if (!actionPersonal->isOn()) { | 620 | if (!actionPersonal->isOn()) { |
614 | // we just turned it off | 621 | // we just turned it off |
615 | setCaption( tr("Contacts") ); | 622 | setCaption( tr("Contacts") ); |
616 | actionNew->setEnabled(TRUE); | 623 | actionNew->setEnabled(TRUE); |
617 | actionTrash->setEnabled(TRUE); | 624 | actionTrash->setEnabled(TRUE); |
618 | #ifndef MAKE_FOR_SHARP_ROM | 625 | #ifndef MAKE_FOR_SHARP_ROM |
619 | actionFind->setEnabled(TRUE); | 626 | actionFind->setEnabled(TRUE); |
620 | #endif | 627 | #endif |
621 | slotUpdateToolbar(); // maybe some of the above could be moved there | 628 | slotUpdateToolbar(); // maybe some of the above could be moved there |
622 | showList(); | 629 | showList(); |
623 | return; | 630 | return; |
624 | } | 631 | } |
625 | 632 | ||
626 | // XXX need to disable some QActions. | 633 | // XXX need to disable some QActions. |
627 | actionNew->setEnabled(FALSE); | 634 | actionNew->setEnabled(FALSE); |
628 | actionTrash->setEnabled(FALSE); | 635 | actionTrash->setEnabled(FALSE); |
629 | #ifndef MAKE_FOR_SHARP_ROM | 636 | #ifndef MAKE_FOR_SHARP_ROM |
630 | actionFind->setEnabled(FALSE); | 637 | actionFind->setEnabled(FALSE); |
631 | #endif | 638 | #endif |
632 | actionMail->setEnabled(FALSE); | 639 | actionMail->setEnabled(FALSE); |
633 | 640 | ||
634 | setCaption( tr("Contacts - My Personal Details") ); | 641 | setCaption( tr("Contacts - My Personal Details") ); |
635 | QString filename = addressbookPersonalVCardName(); | 642 | QString filename = addressbookPersonalVCardName(); |
636 | OContact me; | 643 | OContact me; |
637 | if (QFile::exists(filename)) | 644 | if (QFile::exists(filename)) |
638 | me = OContact::readVCard( filename )[0]; | 645 | me = OContact::readVCard( filename )[0]; |
639 | 646 | ||
640 | abView()->init( me ); | 647 | abView()->init( me ); |
641 | abView()->sync(); | 648 | abView()->sync(); |
642 | listContainer->hide(); | 649 | listContainer->hide(); |
643 | setCentralWidget( abView() ); | 650 | setCentralWidget( abView() ); |
644 | mView->show(); | 651 | mView->show(); |
645 | mView->setFocus(); | 652 | mView->setFocus(); |
646 | } | 653 | } |
647 | 654 | ||
648 | void AddressbookWindow::editEntry( EntryMode entryMode ) | 655 | void AddressbookWindow::editEntry( EntryMode entryMode ) |
649 | { | 656 | { |
650 | OContact entry; | 657 | OContact entry; |
651 | if ( bAbEditFirstTime ) { | 658 | if ( bAbEditFirstTime ) { |
652 | abEditor = new ContactEditor( entry, &orderedFields, &slOrderedFields, | 659 | abEditor = new ContactEditor( entry, &orderedFields, &slOrderedFields, |
653 | this, "editor" ); | 660 | this, "editor" ); |
654 | bAbEditFirstTime = FALSE; | 661 | bAbEditFirstTime = FALSE; |
655 | if ( entryMode == EditEntry ) | 662 | if ( entryMode == EditEntry ) |
656 | abEditor->setEntry( abList->currentEntry() ); | 663 | abEditor->setEntry( abList->currentEntry() ); |
657 | } | 664 | } |
658 | // other things may chane the caption. | 665 | // other things may chane the caption. |
659 | abEditor->setCaption( tr("Edit Address") ); | 666 | abEditor->setCaption( tr("Edit Address") ); |
660 | 667 | ||
661 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 668 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
662 | abEditor->showMaximized(); | 669 | abEditor->showMaximized(); |
663 | #endif | 670 | #endif |
664 | // fix the foxus... | 671 | // fix the foxus... |
665 | abEditor->setNameFocus(); | 672 | abEditor->setNameFocus(); |
666 | if ( abEditor->exec() ) { | 673 | if ( abEditor->exec() ) { |
667 | setFocus(); | 674 | setFocus(); |
668 | if ( entryMode == NewEntry ) { | 675 | if ( entryMode == NewEntry ) { |
669 | OContact insertEntry = abEditor->entry(); | 676 | OContact insertEntry = abEditor->entry(); |
670 | insertEntry.assignUid(); | 677 | insertEntry.assignUid(); |
671 | abList->addEntry( insertEntry ); | 678 | abList->addEntry( insertEntry ); |
672 | } else { | 679 | } else { |
673 | OContact replaceEntry = abEditor->entry(); | 680 | OContact replaceEntry = abEditor->entry(); |
674 | if ( !replaceEntry.isValidUid() ) | 681 | if ( !replaceEntry.isValidUid() ) |
675 | replaceEntry.assignUid(); | 682 | replaceEntry.assignUid(); |
676 | abList->replaceCurrentEntry( replaceEntry ); | 683 | abList->replaceCurrentEntry( replaceEntry ); |
677 | } | 684 | } |
678 | } | 685 | } |
679 | populateCategories(); | 686 | populateCategories(); |
680 | showList(); | 687 | showList(); |
681 | } | 688 | } |
682 | 689 | ||
683 | void AddressbookWindow::listIsEmpty( bool empty ) | 690 | void AddressbookWindow::listIsEmpty( bool empty ) |
684 | { | 691 | { |
685 | if ( !empty ) { | 692 | if ( !empty ) { |
686 | deleteButton->setEnabled( TRUE ); | 693 | deleteButton->setEnabled( TRUE ); |
687 | } | 694 | } |
688 | } | 695 | } |
689 | 696 | ||
690 | void AddressbookWindow::reload() | 697 | void AddressbookWindow::reload() |
691 | { | 698 | { |
692 | syncing = FALSE; | 699 | syncing = FALSE; |
693 | abList->clear(); | 700 | abList->clear(); |
694 | abList->reload(); | 701 | abList->reload(); |
695 | } | 702 | } |
696 | 703 | ||
697 | void AddressbookWindow::flush() | 704 | void AddressbookWindow::flush() |
698 | { | 705 | { |
699 | syncing = TRUE; | 706 | syncing = TRUE; |
700 | abList->save(); | 707 | abList->save(); |
701 | } | 708 | } |
702 | 709 | ||
703 | 710 | ||
704 | void AddressbookWindow::closeEvent( QCloseEvent *e ) | 711 | void AddressbookWindow::closeEvent( QCloseEvent *e ) |
705 | { | 712 | { |
706 | if ( centralWidget() == mView ) { | 713 | if ( centralWidget() == mView ) { |
707 | if (actionPersonal->isOn()) { | 714 | if (actionPersonal->isOn()) { |
708 | // pretend we clicked it off | 715 | // pretend we clicked it off |
709 | actionPersonal->setOn(FALSE); | 716 | actionPersonal->setOn(FALSE); |
710 | slotPersonalView(); | 717 | slotPersonalView(); |
711 | } else { | 718 | } else { |
712 | showList(); | 719 | showList(); |
713 | } | 720 | } |
714 | e->ignore(); | 721 | e->ignore(); |
715 | return; | 722 | return; |
716 | } | 723 | } |
717 | 724 | ||
718 | if(syncing) { | 725 | if(syncing) { |
719 | /* shouldn't we save, I hear you say? well its already been set | 726 | /* shouldn't we save, I hear you say? well its already been set |
720 | so that an edit can not occur during a sync, and we flushed | 727 | so that an edit can not occur during a sync, and we flushed |
721 | at the start of the sync, so there is no need to save | 728 | at the start of the sync, so there is no need to save |
722 | Saving however itself would cause problems. */ | 729 | Saving however itself would cause problems. */ |
723 | e->accept(); | 730 | e->accept(); |
724 | return; | 731 | return; |
725 | } | 732 | } |
726 | //################## shouldn't always save | 733 | //################## shouldn't always save |
727 | // True, but the database handles this automatically ! (se) | 734 | // True, but the database handles this automatically ! (se) |
728 | if ( save() ) | 735 | if ( save() ) |
729 | e->accept(); | 736 | e->accept(); |
730 | else | 737 | else |
731 | e->ignore(); | 738 | e->ignore(); |
732 | } | 739 | } |
733 | 740 | ||
734 | /* | 741 | /* |
735 | Returns TRUE if it is OK to exit | 742 | Returns TRUE if it is OK to exit |
736 | */ | 743 | */ |
737 | 744 | ||
738 | bool AddressbookWindow::save() | 745 | bool AddressbookWindow::save() |
739 | { | 746 | { |
740 | if ( !abList->save() ) { | 747 | if ( !abList->save() ) { |
741 | if ( QMessageBox::critical( 0, tr( "Out of space" ), | 748 | if ( QMessageBox::critical( 0, tr( "Out of space" ), |
742 | tr("Unable to save information.\n" | 749 | tr("Unable to save information.\n" |
743 | "Free up some space\n" | 750 | "Free up some space\n" |
744 | "and try again.\n" | 751 | "and try again.\n" |
745 | "\nQuit anyway?"), | 752 | "\nQuit anyway?"), |
746 | QMessageBox::Yes|QMessageBox::Escape, | 753 | QMessageBox::Yes|QMessageBox::Escape, |
747 | QMessageBox::No|QMessageBox::Default ) | 754 | QMessageBox::No|QMessageBox::Default ) |
748 | != QMessageBox::No ) | 755 | != QMessageBox::No ) |
749 | return TRUE; | 756 | return TRUE; |
750 | else | 757 | else |
751 | return FALSE; | 758 | return FALSE; |
752 | } | 759 | } |
753 | return TRUE; | 760 | return TRUE; |
754 | } | 761 | } |
755 | 762 | ||
763 | #ifdef __DEBUG_RELEASE | ||
764 | void AddressbookWindow::slotSave() | ||
765 | { | ||
766 | save(); | ||
767 | } | ||
768 | #endif | ||
769 | |||
756 | void AddressbookWindow::slotSettings() | 770 | void AddressbookWindow::slotSettings() |
757 | { | 771 | { |
758 | AddressSettings frmSettings( this ); | 772 | AddressSettings frmSettings( this ); |
759 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 773 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
760 | frmSettings.showMaximized(); | 774 | frmSettings.showMaximized(); |
761 | #endif | 775 | #endif |
762 | 776 | ||
763 | if ( frmSettings.exec() ) { | 777 | if ( frmSettings.exec() ) { |
764 | allFields.clear(); | 778 | allFields.clear(); |
765 | orderedFields.clear(); | 779 | orderedFields.clear(); |
766 | slOrderedFields.clear(); | 780 | slOrderedFields.clear(); |
767 | initFields(); | 781 | initFields(); |
768 | if ( abEditor ) | 782 | if ( abEditor ) |
769 | abEditor->loadFields(); | 783 | abEditor->loadFields(); |
770 | abList->refresh(); | 784 | abList->refresh(); |
771 | } | 785 | } |
772 | } | 786 | } |
773 | 787 | ||
774 | 788 | ||
775 | void AddressbookWindow::initFields() | 789 | void AddressbookWindow::initFields() |
776 | { | 790 | { |
777 | // we really don't need the things from the configuration, anymore | 791 | // we really don't need the things from the configuration, anymore |
778 | // only thing that is important are the important categories. So, | 792 | // only thing that is important are the important categories. So, |
779 | // Call the contact functions that correspond to these old functions... | 793 | // Call the contact functions that correspond to these old functions... |
780 | 794 | ||
781 | QStringList xmlFields = OContact::fields(); | 795 | QStringList xmlFields = OContact::fields(); |
782 | QStringList visibleFields = OContact::untrfields(); | 796 | QStringList visibleFields = OContact::untrfields(); |
783 | // QStringList trFields = OContact::trfields(); | 797 | // QStringList trFields = OContact::trfields(); |
784 | 798 | ||
785 | xmlFields.remove( "Title" ); | 799 | xmlFields.remove( "Title" ); |
786 | visibleFields.remove( "Name Title" ); | 800 | visibleFields.remove( "Name Title" ); |
787 | visibleFields.remove( "Notes" ); | 801 | visibleFields.remove( "Notes" ); |
788 | 802 | ||
789 | int i, version; | 803 | int i, version; |
790 | Config cfg( "AddressBook" ); | 804 | Config cfg( "AddressBook" ); |
791 | QString zn; | 805 | QString zn; |
792 | 806 | ||
793 | // ### Write a function to keep this from happening again... | 807 | // ### Write a function to keep this from happening again... |
794 | QStringList::ConstIterator it; | 808 | QStringList::ConstIterator it; |
795 | for ( i = 0, it = xmlFields.begin(); it != xmlFields.end(); ++it, i++ ) { | 809 | for ( i = 0, it = xmlFields.begin(); it != xmlFields.end(); ++it, i++ ) { |
796 | allFields.append( i + 3 ); | 810 | allFields.append( i + 3 ); |
797 | } | 811 | } |
798 | 812 | ||
799 | cfg.setGroup( "Version" ); | 813 | cfg.setGroup( "Version" ); |
800 | version = cfg.readNumEntry( "version" ); | 814 | version = cfg.readNumEntry( "version" ); |
801 | i = 0; | 815 | i = 0; |
802 | startFontSize = 1; | 816 | startFontSize = 1; |
803 | 817 | ||
804 | if ( version >= ADDRESSVERSION ) { | 818 | if ( version >= ADDRESSVERSION ) { |
805 | 819 | ||
806 | cfg.setGroup( "ImportantCategory" ); | 820 | cfg.setGroup( "ImportantCategory" ); |
807 | 821 | ||
808 | zn = cfg.readEntry( "Category" + QString::number(i), QString::null ); | 822 | zn = cfg.readEntry( "Category" + QString::number(i), QString::null ); |
809 | while ( !zn.isNull() ) { | 823 | while ( !zn.isNull() ) { |
810 | if ( zn.contains( "Work" ) || zn.contains( "Mb" ) ) { | 824 | if ( zn.contains( "Work" ) || zn.contains( "Mb" ) ) { |
811 | slOrderedFields.clear(); | 825 | slOrderedFields.clear(); |
812 | break; | 826 | break; |
813 | } | 827 | } |
814 | slOrderedFields.append( zn ); | 828 | slOrderedFields.append( zn ); |
815 | zn = cfg.readEntry( "Category" + QString::number(++i), QString::null ); | 829 | zn = cfg.readEntry( "Category" + QString::number(++i), QString::null ); |
816 | } | 830 | } |
817 | cfg.setGroup( "Font" ); | 831 | cfg.setGroup( "Font" ); |
818 | startFontSize = cfg.readNumEntry( "fontSize", 1 ); | 832 | startFontSize = cfg.readNumEntry( "fontSize", 1 ); |
819 | 833 | ||
820 | 834 | ||
821 | } else { | 835 | } else { |
822 | QString str; | 836 | QString str; |
823 | str = getenv("HOME"); | 837 | str = getenv("HOME"); |
824 | str += "/Settings/AddressBook.conf"; | 838 | str += "/Settings/AddressBook.conf"; |
825 | QFile::remove( str ); | 839 | QFile::remove( str ); |
826 | } | 840 | } |
827 | 841 | ||
828 | if ( slOrderedFields.count() > 0 ) { | 842 | if ( slOrderedFields.count() > 0 ) { |
829 | for( QStringList::ConstIterator it = slOrderedFields.begin(); | 843 | for( QStringList::ConstIterator it = slOrderedFields.begin(); |
830 | it != slOrderedFields.end(); ++it ) { | 844 | it != slOrderedFields.end(); ++it ) { |
831 | QValueList<int>::ConstIterator itVl; | 845 | QValueList<int>::ConstIterator itVl; |
832 | QStringList::ConstIterator itVis; | 846 | QStringList::ConstIterator itVis; |
833 | itVl = allFields.begin(); | 847 | itVl = allFields.begin(); |
834 | for ( itVis = visibleFields.begin(); | 848 | for ( itVis = visibleFields.begin(); |
835 | itVis != visibleFields.end() && itVl != allFields.end(); | 849 | itVis != visibleFields.end() && itVl != allFields.end(); |
836 | ++itVis, ++itVl ) { | 850 | ++itVis, ++itVl ) { |
837 | if ( *it == *itVis && itVl != allFields.end() ) { | 851 | if ( *it == *itVis && itVl != allFields.end() ) { |
838 | orderedFields.append( *itVl ); | 852 | orderedFields.append( *itVl ); |
839 | } | 853 | } |
840 | } | 854 | } |
841 | } | 855 | } |
842 | } else { | 856 | } else { |
843 | QValueList<int>::ConstIterator it; | 857 | QValueList<int>::ConstIterator it; |
844 | for ( it = allFields.begin(); it != allFields.end(); ++it ) | 858 | for ( it = allFields.begin(); it != allFields.end(); ++it ) |
845 | orderedFields.append( *it ); | 859 | orderedFields.append( *it ); |
846 | 860 | ||
847 | slOrderedFields = visibleFields; | 861 | slOrderedFields = visibleFields; |
848 | orderedFields.remove( Qtopia::AddressUid ); | 862 | orderedFields.remove( Qtopia::AddressUid ); |
849 | orderedFields.remove( Qtopia::Title ); | 863 | orderedFields.remove( Qtopia::Title ); |
850 | orderedFields.remove( Qtopia::Groups ); | 864 | orderedFields.remove( Qtopia::Groups ); |
851 | orderedFields.remove( Qtopia::AddressCategory ); | 865 | orderedFields.remove( Qtopia::AddressCategory ); |
852 | orderedFields.remove( Qtopia::FirstName ); | 866 | orderedFields.remove( Qtopia::FirstName ); |
853 | orderedFields.remove( Qtopia::LastName ); | 867 | orderedFields.remove( Qtopia::LastName ); |
854 | orderedFields.remove( Qtopia::DefaultEmail ); | 868 | orderedFields.remove( Qtopia::DefaultEmail ); |
855 | orderedFields.remove( Qtopia::FileAs ); | 869 | orderedFields.remove( Qtopia::FileAs ); |
856 | orderedFields.remove( Qtopia::Notes ); | 870 | orderedFields.remove( Qtopia::Notes ); |
857 | orderedFields.remove( Qtopia::Gender ); | 871 | orderedFields.remove( Qtopia::Gender ); |
858 | slOrderedFields.remove( "Name Title" ); | 872 | slOrderedFields.remove( "Name Title" ); |
859 | slOrderedFields.remove( "First Name" ); | 873 | slOrderedFields.remove( "First Name" ); |
860 | slOrderedFields.remove( "Last Name" ); | 874 | slOrderedFields.remove( "Last Name" ); |
861 | slOrderedFields.remove( "File As" ); | 875 | slOrderedFields.remove( "File As" ); |
862 | slOrderedFields.remove( "Default Email" ); | 876 | slOrderedFields.remove( "Default Email" ); |
863 | slOrderedFields.remove( "Notes" ); | 877 | slOrderedFields.remove( "Notes" ); |
864 | slOrderedFields.remove( "Gender" ); | 878 | slOrderedFields.remove( "Gender" ); |
865 | 879 | ||
866 | } | 880 | } |
867 | } | 881 | } |
868 | 882 | ||
869 | 883 | ||
870 | AbLabel *AddressbookWindow::abView() | 884 | AbLabel *AddressbookWindow::abView() |
871 | { | 885 | { |
872 | if ( !mView ) { | 886 | if ( !mView ) { |
873 | mView = new AbLabel( this, "viewer" ); | 887 | mView = new AbLabel( this, "viewer" ); |
874 | mView->init( OContact() ); | 888 | mView->init( OContact() ); |
875 | connect( mView, SIGNAL( okPressed() ), this, SLOT( slotListView() ) ); | 889 | connect( mView, SIGNAL( okPressed() ), this, SLOT( slotListView() ) ); |
876 | } | 890 | } |
877 | return mView; | 891 | return mView; |
878 | } | 892 | } |
879 | 893 | ||
894 | void AddressbookWindow::slotFindOpen() | ||
895 | { | ||
896 | searchBar->show(); | ||
897 | } | ||
898 | void AddressbookWindow::slotFindClose() | ||
899 | { | ||
900 | searchBar->hide(); | ||
901 | } | ||
902 | void AddressbookWindow::slotFindNext() | ||
903 | { | ||
904 | } | ||
905 | |||
880 | void AddressbookWindow::slotFind() | 906 | void AddressbookWindow::slotFind() |
881 | { | 907 | { |
882 | #ifndef MAKE_FOR_SHARP_ROM | ||
883 | if ( centralWidget() == abView() ) | 908 | if ( centralWidget() == abView() ) |
884 | showList(); | 909 | showList(); |
885 | 910 | ||
886 | FindDialog frmFind( "Contacts", this ); | 911 | // FindDialog frmFind( "Contacts", this ); |
887 | QObject::connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), abList, SLOT(slotDoFind( const QString&,bool,bool,int))); | 912 | // QObject::connect( abList, SIGNAL(signalNotFound()), &frmFind, SLOT(slotNotFound()) ); |
888 | QObject::connect( abList, SIGNAL(signalNotFound()), &frmFind, SLOT(slotNotFound()) ); | 913 | // QObject::connect( abList, SIGNAL(signalWrapAround()), &frmFind, SLOT(slotWrapAround()) ); |
889 | QObject::connect( abList, SIGNAL(signalWrapAround()), &frmFind, SLOT(slotWrapAround()) ); | 914 | // frmFind.exec(); |
915 | |||
916 | // QStringList categories = abList->categories(); | ||
917 | // abList->setShowCategory( book, cat ); | ||
918 | abList->slotDoFind( searchEdit->text(), false, false); | ||
890 | 919 | ||
891 | frmFind.exec(); | ||
892 | 920 | ||
893 | if ( abList->numSelections() ) | 921 | if ( abList->numSelections() ) |
894 | abList->clearSelection(); | 922 | abList->clearSelection(); |
895 | 923 | ||
896 | abList->clearFindRow(); | 924 | abList->clearFindRow(); |
897 | #endif | ||
898 | } | 925 | } |
899 | 926 | ||
900 | void AddressbookWindow::slotSetCategory( int c ) | 927 | void AddressbookWindow::slotSetCategory( int c ) |
901 | { | 928 | { |
902 | 929 | ||
903 | QString cat, book; | 930 | QString cat, book; |
904 | 931 | ||
905 | if ( c <= 0 ) | 932 | if ( c <= 0 ) |
906 | return; | 933 | return; |
907 | 934 | ||
908 | // Checkmark Book Menu Item Selected | 935 | // Checkmark Book Menu Item Selected |
909 | if ( c < 6 ) | 936 | if ( c < 6 ) |
910 | for ( unsigned int i = 1; i < 6; i++ ) | 937 | for ( unsigned int i = 1; i < 6; i++ ) |
911 | catMenu->setItemChecked( i, c == (int)i ); | 938 | catMenu->setItemChecked( i, c == (int)i ); |
912 | 939 | ||
913 | // Checkmark Category Menu Item Selected | 940 | // Checkmark Category Menu Item Selected |
914 | else | 941 | else |
915 | for ( unsigned int i = 6; i < catMenu->count(); i++ ) | 942 | for ( unsigned int i = 6; i < catMenu->count(); i++ ) |
916 | catMenu->setItemChecked( i, c == (int)i ); | 943 | catMenu->setItemChecked( i, c == (int)i ); |
917 | 944 | ||
918 | for ( unsigned int i = 1; i < catMenu->count(); i++ ) { | 945 | for ( unsigned int i = 1; i < catMenu->count(); i++ ) { |
919 | if (catMenu->isItemChecked( i )) { | 946 | if (catMenu->isItemChecked( i )) { |
920 | if ( i == 1 ) // default List view | 947 | if ( i == 1 ) // default List view |
921 | book = QString::null; | 948 | book = QString::null; |
922 | else if ( i == 2 ) | 949 | else if ( i == 2 ) |
923 | book = "Phone"; | 950 | book = "Phone"; |
924 | else if ( i == 3 ) | 951 | else if ( i == 3 ) |
925 | book = "Company"; | 952 | book = "Company"; |
926 | else if ( i == 4 ) | 953 | else if ( i == 4 ) |
927 | book = "Email"; | 954 | book = "Email"; |
928 | else if ( i == 5 ) | 955 | else if ( i == 5 ) |
929 | book = "Cards"; | 956 | book = "Cards"; |
930 | else if ( i == 6 ) // default All Categories | 957 | else if ( i == 6 ) // default All Categories |
931 | cat = QString::null; | 958 | cat = QString::null; |
932 | else if ( i == (unsigned int)catMenu->count() ) // last menu option will be Unfiled | 959 | else if ( i == (unsigned int)catMenu->count() ) // last menu option will be Unfiled |
933 | cat = "Unfiled"; | 960 | cat = "Unfiled"; |
934 | else | 961 | else |
935 | cat = abList->categories()[i - 7]; | 962 | cat = abList->categories()[i - 7]; |
936 | } | 963 | } |
937 | } | 964 | } |
938 | 965 | ||
939 | abList->setShowCategory( book, cat ); | 966 | abList->setShowCategory( book, cat ); |
940 | 967 | ||
941 | if ( book.isEmpty() ) | 968 | if ( book.isEmpty() ) |
942 | book = "List"; | 969 | book = "List"; |
943 | if ( cat.isEmpty() ) | 970 | if ( cat.isEmpty() ) |
944 | cat = "All"; | 971 | cat = "All"; |
945 | 972 | ||
946 | setCaption( tr( "Contacts" ) + " - " + tr( book ) + " - " + tr( cat ) ); | 973 | setCaption( tr( "Contacts" ) + " - " + tr( book ) + " - " + tr( cat ) ); |
947 | } | 974 | } |
948 | 975 | ||
949 | void AddressbookWindow::slotSetLetter( char c ) { | 976 | void AddressbookWindow::slotSetLetter( char c ) { |
950 | 977 | ||
951 | abList->setShowByLetter( c ); | 978 | abList->setShowByLetter( c ); |
952 | 979 | ||
953 | } | 980 | } |
954 | 981 | ||
955 | void AddressbookWindow::populateCategories() | 982 | void AddressbookWindow::populateCategories() |
956 | { | 983 | { |
957 | catMenu->clear(); | 984 | catMenu->clear(); |
958 | 985 | ||
959 | int id, rememberId; | 986 | int id, rememberId; |
960 | id = 1; | 987 | id = 1; |
961 | rememberId = 0; | 988 | rememberId = 0; |
962 | 989 | ||
963 | catMenu->insertItem( tr( "List" ), id++ ); | 990 | catMenu->insertItem( tr( "List" ), id++ ); |
964 | catMenu->insertItem( tr( "Phone Book" ), id++ ); | 991 | catMenu->insertItem( tr( "Phone Book" ), id++ ); |
965 | catMenu->insertItem( tr( "Company Book" ), id++ ); | 992 | catMenu->insertItem( tr( "Company Book" ), id++ ); |
966 | catMenu->insertItem( tr( "Email Book" ), id++ ); | 993 | catMenu->insertItem( tr( "Email Book" ), id++ ); |
967 | catMenu->insertItem( tr( "Cards" ), id++ ); | 994 | catMenu->insertItem( tr( "Cards" ), id++ ); |
968 | catMenu->insertSeparator(); | 995 | catMenu->insertSeparator(); |
969 | 996 | ||
970 | catMenu->insertItem( tr( "All" ), id++ ); | 997 | catMenu->insertItem( tr( "All" ), id++ ); |
971 | QStringList categories = abList->categories(); | 998 | QStringList categories = abList->categories(); |
972 | categories.append( tr( "Unfiled" ) ); | 999 | categories.append( tr( "Unfiled" ) ); |
973 | for ( QStringList::Iterator it = categories.begin(); | 1000 | for ( QStringList::Iterator it = categories.begin(); |
974 | it != categories.end(); ++it ) { | 1001 | it != categories.end(); ++it ) { |
975 | catMenu->insertItem( *it, id ); | 1002 | catMenu->insertItem( *it, id ); |
976 | if ( *it == abList->showCategory() ) | 1003 | if ( *it == abList->showCategory() ) |
977 | rememberId = id; | 1004 | rememberId = id; |
978 | ++id; | 1005 | ++id; |
979 | } | 1006 | } |
980 | 1007 | ||
981 | if ( abList->showBook().isEmpty() ) { | 1008 | if ( abList->showBook().isEmpty() ) { |
982 | catMenu->setItemChecked( 1, true ); | 1009 | catMenu->setItemChecked( 1, true ); |
983 | } else if ( abList->showBook() == "Phone" ) { | 1010 | } else if ( abList->showBook() == "Phone" ) { |
984 | catMenu->setItemChecked( 2, true ); | 1011 | catMenu->setItemChecked( 2, true ); |
985 | } else if ( abList->showBook() == "Company" ) { | 1012 | } else if ( abList->showBook() == "Company" ) { |
986 | catMenu->setItemChecked( 3, true ); | 1013 | catMenu->setItemChecked( 3, true ); |
987 | } else if ( abList->showBook() == "Email" ) { | 1014 | } else if ( abList->showBook() == "Email" ) { |
988 | catMenu->setItemChecked( 4, true ); | 1015 | catMenu->setItemChecked( 4, true ); |
989 | } else if ( abList->showBook() == "Cards" ) { | 1016 | } else if ( abList->showBook() == "Cards" ) { |
990 | catMenu->setItemChecked( 5, true ); | 1017 | catMenu->setItemChecked( 5, true ); |
991 | } | 1018 | } |
992 | 1019 | ||
993 | if ( abList->showCategory().isEmpty() ) { | 1020 | if ( abList->showCategory().isEmpty() ) { |
994 | slotSetCategory( 6 ); | 1021 | slotSetCategory( 6 ); |
995 | } | 1022 | } |
996 | else { | 1023 | else { |
997 | slotSetCategory( rememberId ); | 1024 | slotSetCategory( rememberId ); |
998 | } | 1025 | } |
999 | } | 1026 | } |
1000 | 1027 | ||
diff --git a/core/pim/addressbook/addressbook.h b/core/pim/addressbook/addressbook.h index bf36407..b7cf355 100644 --- a/core/pim/addressbook/addressbook.h +++ b/core/pim/addressbook/addressbook.h | |||
@@ -1,109 +1,124 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef Addressbook_H | 20 | #ifndef Addressbook_H |
21 | #define Addressbook_H | 21 | #define Addressbook_H |
22 | 22 | ||
23 | // Remove this for OPIE releae 1.0 ! | ||
24 | #define __DEBUG_RELEASE | ||
25 | |||
23 | #include <qmainwindow.h> | 26 | #include <qmainwindow.h> |
24 | #include <qvaluelist.h> | 27 | #include <qvaluelist.h> |
25 | #include <qstringlist.h> | 28 | #include <qstringlist.h> |
29 | #include <qlineedit.h> | ||
30 | #include "ofloatbar.h" | ||
26 | 31 | ||
27 | class ContactEditor; | 32 | class ContactEditor; |
28 | class AbLabel; | 33 | class AbLabel; |
29 | class AbTable; | 34 | class AbTable; |
30 | class QPEToolBar; | 35 | class QPEToolBar; |
31 | class QPopupMenu; | 36 | class QPopupMenu; |
32 | class QToolButton; | 37 | class QToolButton; |
33 | class QDialog; | 38 | class QDialog; |
34 | class Ir; | 39 | class Ir; |
35 | class QAction; | 40 | class QAction; |
36 | class LetterPicker; | 41 | class LetterPicker; |
37 | 42 | ||
38 | class AddressbookWindow: public QMainWindow | 43 | class AddressbookWindow: public QMainWindow |
39 | { | 44 | { |
40 | Q_OBJECT | 45 | Q_OBJECT |
41 | public: | 46 | public: |
42 | AddressbookWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); | 47 | AddressbookWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); |
43 | ~AddressbookWindow(); | 48 | ~AddressbookWindow(); |
44 | 49 | ||
45 | protected: | 50 | protected: |
46 | void resizeEvent( QResizeEvent * e ); | 51 | void resizeEvent( QResizeEvent * e ); |
47 | void showList(); | 52 | void showList(); |
48 | void showView(); | 53 | void showView(); |
49 | enum EntryMode { NewEntry=0, EditEntry }; | 54 | enum EntryMode { NewEntry=0, EditEntry }; |
50 | void editPersonal(); | 55 | void editPersonal(); |
51 | void editEntry( EntryMode ); | 56 | void editEntry( EntryMode ); |
52 | void closeEvent( QCloseEvent *e ); | 57 | void closeEvent( QCloseEvent *e ); |
53 | bool save(); | 58 | bool save(); |
54 | 59 | ||
55 | public slots: | 60 | public slots: |
56 | void flush(); | 61 | void flush(); |
57 | void reload(); | 62 | void reload(); |
58 | void appMessage(const QCString &, const QByteArray &); | 63 | void appMessage(const QCString &, const QByteArray &); |
59 | void setDocument( const QString & ); | 64 | void setDocument( const QString & ); |
65 | #ifdef __DEBUG_RELEASE | ||
66 | void slotSave(); | ||
67 | #endif | ||
60 | 68 | ||
61 | private slots: | 69 | private slots: |
62 | void importvCard(); | 70 | void importvCard(); |
63 | void slotListNew(); | 71 | void slotListNew(); |
64 | void slotListView(); | 72 | void slotListView(); |
65 | void slotListDelete(); | 73 | void slotListDelete(); |
66 | void slotViewBack(); | 74 | void slotViewBack(); |
67 | void slotViewEdit(); | 75 | void slotViewEdit(); |
68 | void slotPersonalView(); | 76 | void slotPersonalView(); |
69 | void listIsEmpty( bool ); | 77 | void listIsEmpty( bool ); |
70 | void slotSettings(); | 78 | void slotSettings(); |
71 | void writeMail(); | 79 | void writeMail(); |
72 | void slotBeam(); | 80 | void slotBeam(); |
73 | void beamDone( Ir * ); | 81 | void beamDone( Ir * ); |
74 | void slotFind(); | ||
75 | void slotSetCategory( int ); | 82 | void slotSetCategory( int ); |
76 | void slotSetLetter( char ); | 83 | void slotSetLetter( char ); |
77 | void slotUpdateToolbar(); | 84 | void slotUpdateToolbar(); |
78 | void slotSetFont(int); | 85 | void slotSetFont(int); |
79 | 86 | ||
87 | void slotFindOpen(); | ||
88 | void slotFindClose(); | ||
89 | void slotFind(); | ||
90 | void slotFindNext(); | ||
91 | |||
80 | private: | 92 | private: |
81 | void initFields(); // inititialize our fields... | 93 | void initFields(); // inititialize our fields... |
82 | AbLabel *abView(); | 94 | AbLabel *abView(); |
83 | void populateCategories(); | 95 | void populateCategories(); |
84 | 96 | ||
85 | QPopupMenu *catMenu, *fontMenu; | 97 | QPopupMenu *catMenu, *fontMenu; |
86 | QPEToolBar *listTools; | 98 | QPEToolBar *listTools; |
87 | QToolButton *deleteButton; | 99 | QToolButton *deleteButton; |
88 | QValueList<int> allFields, orderedFields; | 100 | QValueList<int> allFields, orderedFields; |
89 | QStringList slOrderedFields; | 101 | QStringList slOrderedFields; |
90 | enum Panes { paneList=0, paneView, paneEdit }; | 102 | enum Panes { paneList=0, paneView, paneEdit }; |
91 | ContactEditor *abEditor; | 103 | ContactEditor *abEditor; |
92 | AbLabel *mView; | 104 | AbLabel *mView; |
93 | LetterPicker *pLabel; | 105 | LetterPicker *pLabel; |
94 | AbTable *abList; | 106 | AbTable *abList; |
95 | QWidget *listContainer; | 107 | QWidget *listContainer; |
96 | 108 | ||
109 | OFloatBar* searchBar; | ||
110 | QLineEdit* searchEdit; | ||
111 | |||
97 | QAction *actionNew, *actionEdit, *actionTrash, *actionFind, *actionBeam, *actionPersonal, *actionMail; | 112 | QAction *actionNew, *actionEdit, *actionTrash, *actionFind, *actionBeam, *actionPersonal, *actionMail; |
98 | 113 | ||
99 | bool bAbEditFirstTime; | 114 | bool bAbEditFirstTime; |
100 | int viewMargin; | 115 | int viewMargin; |
101 | 116 | ||
102 | bool syncing; | 117 | bool syncing; |
103 | QFont *defaultFont; | 118 | QFont *defaultFont; |
104 | int startFontSize; | 119 | int startFontSize; |
105 | 120 | ||
106 | bool isLoading; | 121 | bool isLoading; |
107 | }; | 122 | }; |
108 | 123 | ||
109 | #endif | 124 | #endif |
diff --git a/core/pim/addressbook/addressbook.pro b/core/pim/addressbook/addressbook.pro index 24bdd8c..05aa5ec 100644 --- a/core/pim/addressbook/addressbook.pro +++ b/core/pim/addressbook/addressbook.pro | |||
@@ -1,37 +1,38 @@ | |||
1 | TEMPLATE= app | 1 | TEMPLATE= app |
2 | CONFIG = qt warn_on release | 2 | CONFIG = qt warn_on release |
3 | DESTDIR = $(OPIEDIR)/bin | 3 | DESTDIR = $(OPIEDIR)/bin |
4 | HEADERS= addressbook.h \ | 4 | HEADERS= addressbook.h \ |
5 | contacteditor.h \ | 5 | contacteditor.h \ |
6 | ablabel.h \ | 6 | ablabel.h \ |
7 | abtable.h \ | 7 | abtable.h \ |
8 | addresssettings.h \ | 8 | addresssettings.h \ |
9 | picker.h | 9 | picker.h \ |
10 | ofloatbar.h | ||
10 | SOURCES= main.cpp \ | 11 | SOURCES= main.cpp \ |
11 | addressbook.cpp \ | 12 | addressbook.cpp \ |
12 | contacteditor.cpp \ | 13 | contacteditor.cpp \ |
13 | ablabel.cpp \ | 14 | ablabel.cpp \ |
14 | abtable.cpp \ | 15 | abtable.cpp \ |
15 | addresssettings.cpp \ | 16 | addresssettings.cpp \ |
16 | picker.cpp | 17 | picker.cpp |
17 | INTERFACES= addresssettingsbase.ui | 18 | INTERFACES= addresssettingsbase.ui |
18 | TARGET = addressbook | 19 | TARGET = addressbook |
19 | INCLUDEPATH += $(OPIEDIR)/include | 20 | INCLUDEPATH += $(OPIEDIR)/include |
20 | DEPENDPATH+= $(OPIEDIR)/include | 21 | DEPENDPATH+= $(OPIEDIR)/include |
21 | LIBS += -lqpe -lopie | 22 | LIBS += -lqpe -lopie |
22 | 23 | ||
23 | TRANSLATIONS = ../../../i18n/de/addressbook.ts \ | 24 | TRANSLATIONS = ../../../i18n/de/addressbook.ts \ |
24 | ../../../i18n/en/addressbook.ts \ | 25 | ../../../i18n/en/addressbook.ts \ |
25 | ../../../i18n/es/addressbook.ts \ | 26 | ../../../i18n/es/addressbook.ts \ |
26 | ../../../i18n/fr/addressbook.ts \ | 27 | ../../../i18n/fr/addressbook.ts \ |
27 | ../../../i18n/hu/addressbook.ts \ | 28 | ../../../i18n/hu/addressbook.ts \ |
28 | ../../../i18n/ja/addressbook.ts \ | 29 | ../../../i18n/ja/addressbook.ts \ |
29 | ../../../i18n/ko/addressbook.ts \ | 30 | ../../../i18n/ko/addressbook.ts \ |
30 | ../../../i18n/no/addressbook.ts \ | 31 | ../../../i18n/no/addressbook.ts \ |
31 | ../../../i18n/pl/addressbook.ts \ | 32 | ../../../i18n/pl/addressbook.ts \ |
32 | ../../../i18n/pt/addressbook.ts \ | 33 | ../../../i18n/pt/addressbook.ts \ |
33 | ../../../i18n/pt_BR/addressbook.ts \ | 34 | ../../../i18n/pt_BR/addressbook.ts \ |
34 | ../../../i18n/sl/addressbook.ts \ | 35 | ../../../i18n/sl/addressbook.ts \ |
35 | ../../../i18n/zh_CN/addressbook.ts \ | 36 | ../../../i18n/zh_CN/addressbook.ts \ |
36 | ../../../i18n/it/addressbook.ts \ | 37 | ../../../i18n/it/addressbook.ts \ |
37 | ../../../i18n/zh_TW/addressbook.ts | 38 | ../../../i18n/zh_TW/addressbook.ts |
diff --git a/core/pim/addressbook/ofloatbar.h b/core/pim/addressbook/ofloatbar.h new file mode 100644 index 0000000..85a0c4f --- a/dev/null +++ b/core/pim/addressbook/ofloatbar.h | |||
@@ -0,0 +1,20 @@ | |||
1 | #ifndef __OFLOATBAR_H | ||
2 | #define __OFLOATBAR_H | ||
3 | |||
4 | #include <qtoolbar.h> | ||
5 | #include <qevent.h> | ||
6 | |||
7 | class OFloatBar : public QToolBar | ||
8 | { | ||
9 | Q_OBJECT | ||
10 | virtual void hideEvent(QHideEvent* e) | ||
11 | { | ||
12 | /*if (e->spontaneous())*/ emit OnHide(); | ||
13 | } | ||
14 | public: | ||
15 | OFloatBar(char* t, QMainWindow* mw, QMainWindow::ToolBarDock td, bool f) : QToolBar(t, mw, td, f) {} | ||
16 | signals: | ||
17 | void OnHide(); | ||
18 | }; | ||
19 | |||
20 | #endif | ||