-rw-r--r-- | core/pim/addressbook/addressbook.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp index 30fa85b..c2cce92 100644 --- a/core/pim/addressbook/addressbook.cpp +++ b/core/pim/addressbook/addressbook.cpp | |||
@@ -464,512 +464,513 @@ void AddressbookWindow::slotFindOpen() | |||
464 | void AddressbookWindow::slotFindClose() | 464 | void AddressbookWindow::slotFindClose() |
465 | { | 465 | { |
466 | searchBar->hide(); | 466 | searchBar->hide(); |
467 | m_abView -> offSearch(); | 467 | m_abView -> offSearch(); |
468 | // m_abView->setFocus(); | 468 | // m_abView->setFocus(); |
469 | } | 469 | } |
470 | 470 | ||
471 | 471 | ||
472 | void AddressbookWindow::slotFind() | 472 | void AddressbookWindow::slotFind() |
473 | { | 473 | { |
474 | m_abView->slotDoFind( searchEdit->text(), m_config.beCaseSensitive(), m_config.useRegExp(), false); | 474 | m_abView->slotDoFind( searchEdit->text(), m_config.beCaseSensitive(), m_config.useRegExp(), false); |
475 | 475 | ||
476 | searchEdit->clearFocus(); | 476 | searchEdit->clearFocus(); |
477 | // m_abView->setFocus(); | 477 | // m_abView->setFocus(); |
478 | 478 | ||
479 | } | 479 | } |
480 | 480 | ||
481 | void AddressbookWindow::slotViewBack() | 481 | void AddressbookWindow::slotViewBack() |
482 | { | 482 | { |
483 | // :SX showList(); | 483 | // :SX showList(); |
484 | } | 484 | } |
485 | 485 | ||
486 | void AddressbookWindow::slotViewEdit() | 486 | void AddressbookWindow::slotViewEdit() |
487 | { | 487 | { |
488 | if(!syncing) { | 488 | if(!syncing) { |
489 | if (actionPersonal->isOn()) { | 489 | if (actionPersonal->isOn()) { |
490 | editPersonal(); | 490 | editPersonal(); |
491 | } else { | 491 | } else { |
492 | editEntry( EditEntry ); | 492 | editEntry( EditEntry ); |
493 | } | 493 | } |
494 | } else { | 494 | } else { |
495 | QMessageBox::warning( this, tr("Contacts"), | 495 | QMessageBox::warning( this, tr("Contacts"), |
496 | tr("Can not edit data, currently syncing") ); | 496 | tr("Can not edit data, currently syncing") ); |
497 | } | 497 | } |
498 | } | 498 | } |
499 | 499 | ||
500 | 500 | ||
501 | 501 | ||
502 | void AddressbookWindow::writeMail() | 502 | void AddressbookWindow::writeMail() |
503 | { | 503 | { |
504 | OContact c = m_abView -> currentEntry(); | 504 | OContact c = m_abView -> currentEntry(); |
505 | QString name = c.fileAs(); | 505 | QString name = c.fileAs(); |
506 | QString email = c.defaultEmail(); | 506 | QString email = c.defaultEmail(); |
507 | 507 | ||
508 | // I prefer the OPIE-Environment variable before the | 508 | // I prefer the OPIE-Environment variable before the |
509 | // QPE-one.. | 509 | // QPE-one.. |
510 | QString basepath = QString::fromLatin1( getenv("OPIEDIR") ); | 510 | QString basepath = QString::fromLatin1( getenv("OPIEDIR") ); |
511 | if ( basepath.isEmpty() ) | 511 | if ( basepath.isEmpty() ) |
512 | basepath = QString::fromLatin1( getenv("QPEDIR") ); | 512 | basepath = QString::fromLatin1( getenv("QPEDIR") ); |
513 | 513 | ||
514 | // Try to access the preferred. If not possible, try to | 514 | // Try to access the preferred. If not possible, try to |
515 | // switch to the other one.. | 515 | // switch to the other one.. |
516 | if ( m_config.useQtMail() ){ | 516 | if ( m_config.useQtMail() ){ |
517 | qWarning ("Accessing: %s", (basepath + "/bin/qtmail").latin1()); | 517 | qWarning ("Accessing: %s", (basepath + "/bin/qtmail").latin1()); |
518 | if ( QFile::exists( basepath + "/bin/qtmail" ) ){ | 518 | if ( QFile::exists( basepath + "/bin/qtmail" ) ){ |
519 | qWarning ("QCop"); | 519 | qWarning ("QCop"); |
520 | QCopEnvelope e("QPE/Application/qtmail", "writeMail(QString,QString)"); | 520 | QCopEnvelope e("QPE/Application/qtmail", "writeMail(QString,QString)"); |
521 | e << name << email; | 521 | e << name << email; |
522 | return; | 522 | return; |
523 | } else | 523 | } else |
524 | m_config.setUseOpieMail( true ); | 524 | m_config.setUseOpieMail( true ); |
525 | } | 525 | } |
526 | if ( m_config.useOpieMail() ){ | 526 | if ( m_config.useOpieMail() ){ |
527 | qWarning ("Accessing: %s", (basepath + "/bin/mail").latin1()); | 527 | qWarning ("Accessing: %s", (basepath + "/bin/mail").latin1()); |
528 | if ( QFile::exists( basepath + "/bin/mail" ) ){ | 528 | if ( QFile::exists( basepath + "/bin/mail" ) ){ |
529 | qWarning ("QCop"); | 529 | qWarning ("QCop"); |
530 | QCopEnvelope e("QPE/Application/mail", "writeMail(QString,QString)"); | 530 | QCopEnvelope e("QPE/Application/mail", "writeMail(QString,QString)"); |
531 | e << name << email; | 531 | e << name << email; |
532 | return; | 532 | return; |
533 | } else | 533 | } else |
534 | m_config.setUseQtMail( true ); | 534 | m_config.setUseQtMail( true ); |
535 | } | 535 | } |
536 | 536 | ||
537 | } | 537 | } |
538 | 538 | ||
539 | static const char * beamfile = "/tmp/obex/contact.vcf"; | 539 | static const char * beamfile = "/tmp/obex/contact.vcf"; |
540 | 540 | ||
541 | void AddressbookWindow::slotBeam() | 541 | void AddressbookWindow::slotBeam() |
542 | { | 542 | { |
543 | QString filename; | 543 | QString filename; |
544 | OContact c; | 544 | OContact c; |
545 | if ( actionPersonal->isOn() ) { | 545 | if ( actionPersonal->isOn() ) { |
546 | filename = addressbookPersonalVCardName(); | 546 | filename = addressbookPersonalVCardName(); |
547 | if (!QFile::exists(filename)) | 547 | if (!QFile::exists(filename)) |
548 | return; // can't beam a non-existent file | 548 | return; // can't beam a non-existent file |
549 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, | 549 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, |
550 | filename ); | 550 | filename ); |
551 | OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 551 | OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
552 | OContactAccess::List allList = access->allRecords(); | 552 | OContactAccess::List allList = access->allRecords(); |
553 | OContactAccess::List::Iterator it = allList.begin(); // Just take first | 553 | OContactAccess::List::Iterator it = allList.begin(); // Just take first |
554 | c = *it; | 554 | c = *it; |
555 | 555 | ||
556 | delete access; | 556 | delete access; |
557 | } else { | 557 | } else { |
558 | unlink( beamfile ); // delete if exists | 558 | unlink( beamfile ); // delete if exists |
559 | mkdir("/tmp/obex/", 0755); | 559 | mkdir("/tmp/obex/", 0755); |
560 | c = m_abView -> currentEntry(); | 560 | c = m_abView -> currentEntry(); |
561 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, | 561 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, |
562 | beamfile ); | 562 | beamfile ); |
563 | OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 563 | OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
564 | access->add( c ); | 564 | access->add( c ); |
565 | access->save(); | 565 | access->save(); |
566 | delete access; | 566 | delete access; |
567 | 567 | ||
568 | filename = beamfile; | 568 | filename = beamfile; |
569 | } | 569 | } |
570 | 570 | ||
571 | 571 | ||
572 | Ir *ir = new Ir( this ); | 572 | Ir *ir = new Ir( this ); |
573 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 573 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
574 | QString description = c.fullName(); | 574 | QString description = c.fullName(); |
575 | ir->send( filename, description, "text/x-vCard" ); | 575 | ir->send( filename, description, "text/x-vCard" ); |
576 | } | 576 | } |
577 | 577 | ||
578 | void AddressbookWindow::beamDone( Ir *ir ) | 578 | void AddressbookWindow::beamDone( Ir *ir ) |
579 | { | 579 | { |
580 | delete ir; | 580 | delete ir; |
581 | unlink( beamfile ); | 581 | unlink( beamfile ); |
582 | } | 582 | } |
583 | 583 | ||
584 | 584 | ||
585 | static void parseName( const QString& name, QString *first, QString *middle, | 585 | static void parseName( const QString& name, QString *first, QString *middle, |
586 | QString * last ) | 586 | QString * last ) |
587 | { | 587 | { |
588 | 588 | ||
589 | int comma = name.find ( "," ); | 589 | int comma = name.find ( "," ); |
590 | QString rest; | 590 | QString rest; |
591 | if ( comma > 0 ) { | 591 | if ( comma > 0 ) { |
592 | *last = name.left( comma ); | 592 | *last = name.left( comma ); |
593 | comma++; | 593 | comma++; |
594 | while ( comma < int(name.length()) && name[comma] == ' ' ) | 594 | while ( comma < int(name.length()) && name[comma] == ' ' ) |
595 | comma++; | 595 | comma++; |
596 | rest = name.mid( comma ); | 596 | rest = name.mid( comma ); |
597 | } else { | 597 | } else { |
598 | int space = name.findRev( ' ' ); | 598 | int space = name.findRev( ' ' ); |
599 | *last = name.mid( space+1 ); | 599 | *last = name.mid( space+1 ); |
600 | rest = name.left( space ); | 600 | rest = name.left( space ); |
601 | } | 601 | } |
602 | int space = rest.find( ' ' ); | 602 | int space = rest.find( ' ' ); |
603 | if ( space <= 0 ) { | 603 | if ( space <= 0 ) { |
604 | *first = rest; | 604 | *first = rest; |
605 | } else { | 605 | } else { |
606 | *first = rest.left( space ); | 606 | *first = rest.left( space ); |
607 | *middle = rest.mid( space+1 ); | 607 | *middle = rest.mid( space+1 ); |
608 | } | 608 | } |
609 | 609 | ||
610 | } | 610 | } |
611 | 611 | ||
612 | 612 | ||
613 | void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) | 613 | void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) |
614 | { | 614 | { |
615 | if (msg == "editPersonal()") { | 615 | if (msg == "editPersonal()") { |
616 | editPersonal(); | 616 | editPersonal(); |
617 | } else if (msg == "editPersonalAndClose()") { | 617 | } else if (msg == "editPersonalAndClose()") { |
618 | editPersonal(); | 618 | editPersonal(); |
619 | close(); | 619 | close(); |
620 | } else if ( msg == "addContact(QString,QString)" ) { | 620 | } else if ( msg == "addContact(QString,QString)" ) { |
621 | QDataStream stream(data,IO_ReadOnly); | 621 | QDataStream stream(data,IO_ReadOnly); |
622 | QString name, email; | 622 | QString name, email; |
623 | stream >> name >> email; | 623 | stream >> name >> email; |
624 | 624 | ||
625 | OContact cnt; | 625 | OContact cnt; |
626 | QString fn, mn, ln; | 626 | QString fn, mn, ln; |
627 | parseName( name, &fn, &mn, &ln ); | 627 | parseName( name, &fn, &mn, &ln ); |
628 | // qDebug( " %s - %s - %s", fn.latin1(), mn.latin1(), ln.latin1() ); | 628 | // qDebug( " %s - %s - %s", fn.latin1(), mn.latin1(), ln.latin1() ); |
629 | cnt.setFirstName( fn ); | 629 | cnt.setFirstName( fn ); |
630 | cnt.setMiddleName( mn ); | 630 | cnt.setMiddleName( mn ); |
631 | cnt.setLastName( ln ); | 631 | cnt.setLastName( ln ); |
632 | cnt.insertEmails( email ); | 632 | cnt.insertEmails( email ); |
633 | cnt.setDefaultEmail( email ); | 633 | cnt.setDefaultEmail( email ); |
634 | cnt.setFileAs(); | 634 | cnt.setFileAs(); |
635 | 635 | ||
636 | m_abView -> addEntry( cnt ); | 636 | m_abView -> addEntry( cnt ); |
637 | 637 | ||
638 | // :SXm_abView()->init( cnt ); | 638 | // :SXm_abView()->init( cnt ); |
639 | editEntry( EditEntry ); | 639 | editEntry( EditEntry ); |
640 | 640 | ||
641 | 641 | ||
642 | 642 | ||
643 | } | 643 | } |
644 | #if 0 | 644 | #if 0 |
645 | else if (msg == "pickAddresses(QCString,QCString,QStringList,...)" ) { | 645 | else if (msg == "pickAddresses(QCString,QCString,QStringList,...)" ) { |
646 | QDataStream stream(data,IO_ReadOnly); | 646 | QDataStream stream(data,IO_ReadOnly); |
647 | QCString ch,m; | 647 | QCString ch,m; |
648 | QStringList types; | 648 | QStringList types; |
649 | stream >> ch >> m >> types; | 649 | stream >> ch >> m >> types; |
650 | AddressPicker picker(abList,this,0,TRUE); | 650 | AddressPicker picker(abList,this,0,TRUE); |
651 | picker.showMaximized(); | 651 | picker.showMaximized(); |
652 | picker.setChoiceNames(types); | 652 | picker.setChoiceNames(types); |
653 | int i=0; | 653 | int i=0; |
654 | for (QStringList::ConstIterator it = types.begin(); it!=types.end(); ++it) { | 654 | for (QStringList::ConstIterator it = types.begin(); it!=types.end(); ++it) { |
655 | QStringList sel; | 655 | QStringList sel; |
656 | stream >> sel; | 656 | stream >> sel; |
657 | picker.setSelection(i++,sel); | 657 | picker.setSelection(i++,sel); |
658 | } | 658 | } |
659 | picker.showMaximized(); | 659 | picker.showMaximized(); |
660 | picker.exec(); | 660 | picker.exec(); |
661 | 661 | ||
662 | // ###### note: contacts may have been added - save here! | 662 | // ###### note: contacts may have been added - save here! |
663 | 663 | ||
664 | setCentralWidget(abList); | 664 | setCentralWidget(abList); |
665 | QCopEnvelope e(ch,m); | 665 | QCopEnvelope e(ch,m); |
666 | i=0; | 666 | i=0; |
667 | for (QStringList::ConstIterator it = types.begin(); it!=types.end(); ++it) { | 667 | for (QStringList::ConstIterator it = types.begin(); it!=types.end(); ++it) { |
668 | QStringList sel = picker.selection(i++); | 668 | QStringList sel = picker.selection(i++); |
669 | e << sel; | 669 | e << sel; |
670 | } | 670 | } |
671 | } | 671 | } |
672 | #endif | 672 | #endif |
673 | 673 | ||
674 | } | 674 | } |
675 | 675 | ||
676 | void AddressbookWindow::editEntry( EntryMode entryMode ) | 676 | void AddressbookWindow::editEntry( EntryMode entryMode ) |
677 | { | 677 | { |
678 | OContact entry; | 678 | OContact entry; |
679 | if ( !abEditor ) { | 679 | if ( !abEditor ) { |
680 | abEditor = new ContactEditor( entry, this, "editor" ); | 680 | abEditor = new ContactEditor( entry, this, "editor" ); |
681 | } | 681 | } |
682 | if ( entryMode == EditEntry ) | 682 | if ( entryMode == EditEntry ) |
683 | abEditor->setEntry( m_abView -> currentEntry() ); | 683 | abEditor->setEntry( m_abView -> currentEntry() ); |
684 | else if ( entryMode == NewEntry ) | 684 | else if ( entryMode == NewEntry ) |
685 | abEditor->setEntry( entry ); | 685 | abEditor->setEntry( entry ); |
686 | // other things may change the caption. | 686 | // other things may change the caption. |
687 | abEditor->setCaption( tr("Edit Address") ); | 687 | abEditor->setCaption( tr("Edit Address") ); |
688 | 688 | ||
689 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 689 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
690 | abEditor->showMaximized(); | 690 | abEditor->showMaximized(); |
691 | #endif | 691 | #endif |
692 | // fix the foxus... | 692 | // fix the foxus... |
693 | abEditor->setNameFocus(); | 693 | abEditor->setNameFocus(); |
694 | if ( abEditor->exec() ) { | 694 | if ( abEditor->exec() ) { |
695 | setFocus(); | 695 | setFocus(); |
696 | if ( entryMode == NewEntry ) { | 696 | if ( entryMode == NewEntry ) { |
697 | OContact insertEntry = abEditor->entry(); | 697 | OContact insertEntry = abEditor->entry(); |
698 | insertEntry.assignUid(); | 698 | insertEntry.assignUid(); |
699 | m_abView -> addEntry( insertEntry ); | 699 | m_abView -> addEntry( insertEntry ); |
700 | } else { | 700 | } else { |
701 | OContact replEntry = abEditor->entry(); | 701 | OContact replEntry = abEditor->entry(); |
702 | 702 | ||
703 | if ( !replEntry.isValidUid() ) | 703 | if ( !replEntry.isValidUid() ) |
704 | replEntry.assignUid(); | 704 | replEntry.assignUid(); |
705 | 705 | ||
706 | m_abView -> replaceEntry( replEntry ); | 706 | m_abView -> replaceEntry( replEntry ); |
707 | } | 707 | } |
708 | } | 708 | } |
709 | // populateCategories(); | 709 | // populateCategories(); |
710 | 710 | ||
711 | } | 711 | } |
712 | 712 | ||
713 | void AddressbookWindow::editPersonal() | 713 | void AddressbookWindow::editPersonal() |
714 | { | 714 | { |
715 | OContact entry; | 715 | OContact entry; |
716 | if ( !abEditor ) { | 716 | if ( !abEditor ) { |
717 | abEditor = new ContactEditor( entry, this, "editor" ); | 717 | abEditor = new ContactEditor( entry, this, "editor" ); |
718 | } | 718 | } |
719 | 719 | ||
720 | m_abView->showPersonal( true ); | ||
720 | abEditor->setCaption(tr("Edit My Personal Details")); | 721 | abEditor->setCaption(tr("Edit My Personal Details")); |
721 | abEditor->setPersonalView( true ); | 722 | abEditor->setPersonalView( true ); |
722 | editEntry( EditEntry ); | 723 | editEntry( EditEntry ); |
723 | abEditor->setPersonalView( false ); | 724 | abEditor->setPersonalView( false ); |
724 | 725 | ||
725 | } | 726 | } |
726 | 727 | ||
727 | 728 | ||
728 | void AddressbookWindow::slotPersonalView() | 729 | void AddressbookWindow::slotPersonalView() |
729 | { | 730 | { |
730 | if (!actionPersonal->isOn()) { | 731 | if (!actionPersonal->isOn()) { |
731 | // we just turned it off | 732 | // we just turned it off |
732 | setCaption( tr("Contacts") ); | 733 | setCaption( tr("Contacts") ); |
733 | actionNew->setEnabled(TRUE); | 734 | actionNew->setEnabled(TRUE); |
734 | actionTrash->setEnabled(TRUE); | 735 | actionTrash->setEnabled(TRUE); |
735 | actionFind->setEnabled(TRUE); | 736 | actionFind->setEnabled(TRUE); |
736 | actionMail->setEnabled(TRUE); | 737 | actionMail->setEnabled(TRUE); |
737 | // slotUpdateToolbar(); | 738 | // slotUpdateToolbar(); |
738 | 739 | ||
739 | m_abView->showPersonal( false ); | 740 | m_abView->showPersonal( false ); |
740 | 741 | ||
741 | return; | 742 | return; |
742 | } | 743 | } |
743 | 744 | ||
744 | // XXX need to disable some QActions. | 745 | // XXX need to disable some QActions. |
745 | actionNew->setEnabled(FALSE); | 746 | actionNew->setEnabled(FALSE); |
746 | actionTrash->setEnabled(FALSE); | 747 | actionTrash->setEnabled(FALSE); |
747 | actionFind->setEnabled(FALSE); | 748 | actionFind->setEnabled(FALSE); |
748 | actionMail->setEnabled(FALSE); | 749 | actionMail->setEnabled(FALSE); |
749 | 750 | ||
750 | setCaption( tr("Contacts - My Personal Details") ); | 751 | setCaption( tr("Contacts - My Personal Details") ); |
751 | 752 | ||
752 | m_abView->showPersonal( true ); | 753 | m_abView->showPersonal( true ); |
753 | 754 | ||
754 | } | 755 | } |
755 | 756 | ||
756 | 757 | ||
757 | void AddressbookWindow::listIsEmpty( bool empty ) | 758 | void AddressbookWindow::listIsEmpty( bool empty ) |
758 | { | 759 | { |
759 | if ( !empty ) { | 760 | if ( !empty ) { |
760 | deleteButton->setEnabled( TRUE ); | 761 | deleteButton->setEnabled( TRUE ); |
761 | } | 762 | } |
762 | } | 763 | } |
763 | 764 | ||
764 | void AddressbookWindow::reload() | 765 | void AddressbookWindow::reload() |
765 | { | 766 | { |
766 | syncing = FALSE; | 767 | syncing = FALSE; |
767 | m_abView->clear(); | 768 | m_abView->clear(); |
768 | m_abView->reload(); | 769 | m_abView->reload(); |
769 | } | 770 | } |
770 | 771 | ||
771 | void AddressbookWindow::flush() | 772 | void AddressbookWindow::flush() |
772 | { | 773 | { |
773 | syncing = TRUE; | 774 | syncing = TRUE; |
774 | m_abView->save(); | 775 | m_abView->save(); |
775 | } | 776 | } |
776 | 777 | ||
777 | 778 | ||
778 | void AddressbookWindow::closeEvent( QCloseEvent *e ) | 779 | void AddressbookWindow::closeEvent( QCloseEvent *e ) |
779 | { | 780 | { |
780 | if(active_view == AbView::CardView){ | 781 | if(active_view == AbView::CardView){ |
781 | slotViewSwitched( AbView::TableView ); | 782 | slotViewSwitched( AbView::TableView ); |
782 | e->ignore(); | 783 | e->ignore(); |
783 | return; | 784 | return; |
784 | } | 785 | } |
785 | if(syncing) { | 786 | if(syncing) { |
786 | /* shouldn't we save, I hear you say? well its already been set | 787 | /* shouldn't we save, I hear you say? well its already been set |
787 | so that an edit can not occur during a sync, and we flushed | 788 | so that an edit can not occur during a sync, and we flushed |
788 | at the start of the sync, so there is no need to save | 789 | at the start of the sync, so there is no need to save |
789 | Saving however itself would cause problems. */ | 790 | Saving however itself would cause problems. */ |
790 | e->accept(); | 791 | e->accept(); |
791 | return; | 792 | return; |
792 | } | 793 | } |
793 | //################## shouldn't always save | 794 | //################## shouldn't always save |
794 | // True, but the database handles this automatically ! (se) | 795 | // True, but the database handles this automatically ! (se) |
795 | if ( save() ) | 796 | if ( save() ) |
796 | e->accept(); | 797 | e->accept(); |
797 | else | 798 | else |
798 | e->ignore(); | 799 | e->ignore(); |
799 | } | 800 | } |
800 | 801 | ||
801 | /* | 802 | /* |
802 | Returns TRUE if it is OK to exit | 803 | Returns TRUE if it is OK to exit |
803 | */ | 804 | */ |
804 | 805 | ||
805 | bool AddressbookWindow::save() | 806 | bool AddressbookWindow::save() |
806 | { | 807 | { |
807 | if ( !m_abView->save() ) { | 808 | if ( !m_abView->save() ) { |
808 | if ( QMessageBox::critical( 0, tr( "Out of space" ), | 809 | if ( QMessageBox::critical( 0, tr( "Out of space" ), |
809 | tr("Unable to save information.\n" | 810 | tr("Unable to save information.\n" |
810 | "Free up some space\n" | 811 | "Free up some space\n" |
811 | "and try again.\n" | 812 | "and try again.\n" |
812 | "\nQuit anyway?"), | 813 | "\nQuit anyway?"), |
813 | QMessageBox::Yes|QMessageBox::Escape, | 814 | QMessageBox::Yes|QMessageBox::Escape, |
814 | QMessageBox::No|QMessageBox::Default ) | 815 | QMessageBox::No|QMessageBox::Default ) |
815 | != QMessageBox::No ) | 816 | != QMessageBox::No ) |
816 | return TRUE; | 817 | return TRUE; |
817 | else | 818 | else |
818 | return FALSE; | 819 | return FALSE; |
819 | } | 820 | } |
820 | return TRUE; | 821 | return TRUE; |
821 | } | 822 | } |
822 | 823 | ||
823 | #ifdef __DEBUG_RELEASE | 824 | #ifdef __DEBUG_RELEASE |
824 | void AddressbookWindow::slotSave() | 825 | void AddressbookWindow::slotSave() |
825 | { | 826 | { |
826 | save(); | 827 | save(); |
827 | } | 828 | } |
828 | #endif | 829 | #endif |
829 | 830 | ||
830 | 831 | ||
831 | void AddressbookWindow::slotNotFound() | 832 | void AddressbookWindow::slotNotFound() |
832 | { | 833 | { |
833 | qWarning("Got notfound signal!"); | 834 | qWarning("Got notfound signal!"); |
834 | QMessageBox::information( this, tr( "Not Found" ), | 835 | QMessageBox::information( this, tr( "Not Found" ), |
835 | tr( "Unable to find a contact for this \n search pattern!" ) ); | 836 | tr( "Unable to find a contact for this \n search pattern!" ) ); |
836 | 837 | ||
837 | 838 | ||
838 | } | 839 | } |
839 | void AddressbookWindow::slotWrapAround() | 840 | void AddressbookWindow::slotWrapAround() |
840 | { | 841 | { |
841 | qWarning("Got wrap signal!"); | 842 | qWarning("Got wrap signal!"); |
842 | // if ( doNotifyWrapAround ) | 843 | // if ( doNotifyWrapAround ) |
843 | // QMessageBox::information( this, tr( "End of list" ), | 844 | // QMessageBox::information( this, tr( "End of list" ), |
844 | // tr( "End of list. Wrap around now...!" ) + "\n" ); | 845 | // tr( "End of list. Wrap around now...!" ) + "\n" ); |
845 | 846 | ||
846 | } | 847 | } |
847 | 848 | ||
848 | void AddressbookWindow::slotSetCategory( int c ) | 849 | void AddressbookWindow::slotSetCategory( int c ) |
849 | { | 850 | { |
850 | qWarning( "void AddressbookWindow::slotSetCategory( %d ) from %d", c, catMenu->count() ); | 851 | qWarning( "void AddressbookWindow::slotSetCategory( %d ) from %d", c, catMenu->count() ); |
851 | 852 | ||
852 | QString cat, book; | 853 | QString cat, book; |
853 | AbView::Views view = AbView::TableView; | 854 | AbView::Views view = AbView::TableView; |
854 | 855 | ||
855 | if ( c <= 0 ) | 856 | if ( c <= 0 ) |
856 | return; | 857 | return; |
857 | 858 | ||
858 | // Switch view | 859 | // Switch view |
859 | if ( c < 3 ) | 860 | if ( c < 3 ) |
860 | for ( unsigned int i = 1; i < 3; i++ ){ | 861 | for ( unsigned int i = 1; i < 3; i++ ){ |
861 | if ( catMenu ) | 862 | if ( catMenu ) |
862 | catMenu->setItemChecked( i, c == (int)i ); | 863 | catMenu->setItemChecked( i, c == (int)i ); |
863 | } | 864 | } |
864 | else | 865 | else |
865 | // Checkmark Category Menu Item Selected | 866 | // Checkmark Category Menu Item Selected |
866 | for ( unsigned int i = 3; i < catMenu->count(); i++ ) | 867 | for ( unsigned int i = 3; i < catMenu->count(); i++ ) |
867 | catMenu->setItemChecked( i, c == (int)i ); | 868 | catMenu->setItemChecked( i, c == (int)i ); |
868 | 869 | ||
869 | // Now switch to the selected category | 870 | // Now switch to the selected category |
870 | for ( unsigned int i = 1; i < catMenu->count(); i++ ) { | 871 | for ( unsigned int i = 1; i < catMenu->count(); i++ ) { |
871 | if (catMenu->isItemChecked( i )) { | 872 | if (catMenu->isItemChecked( i )) { |
872 | if ( i == 1 ){ // default List view | 873 | if ( i == 1 ){ // default List view |
873 | book = QString::null; | 874 | book = QString::null; |
874 | view = AbView::TableView; | 875 | view = AbView::TableView; |
875 | }else if ( i == 2 ){ | 876 | }else if ( i == 2 ){ |
876 | book = tr( "Cards" ); | 877 | book = tr( "Cards" ); |
877 | view = AbView::CardView; | 878 | view = AbView::CardView; |
878 | // }else if ( i == 3 ){ | 879 | // }else if ( i == 3 ){ |
879 | // book = tr( "Personal" ); | 880 | // book = tr( "Personal" ); |
880 | // view = AbView:: PersonalView; | 881 | // view = AbView:: PersonalView; |
881 | }else if ( i == 3 ){ // default All Categories | 882 | }else if ( i == 3 ){ // default All Categories |
882 | cat = QString::null; | 883 | cat = QString::null; |
883 | }else if ( i == (unsigned int)catMenu->count() - 1 ){ // last menu option (seperator is counted, too) will be Unfiled | 884 | }else if ( i == (unsigned int)catMenu->count() - 1 ){ // last menu option (seperator is counted, too) will be Unfiled |
884 | cat = "Unfiled"; | 885 | cat = "Unfiled"; |
885 | qWarning ("Unfiled selected!!!"); | 886 | qWarning ("Unfiled selected!!!"); |
886 | }else{ | 887 | }else{ |
887 | cat = m_abView->categories()[i - 4]; | 888 | cat = m_abView->categories()[i - 4]; |
888 | } | 889 | } |
889 | } | 890 | } |
890 | } | 891 | } |
891 | 892 | ||
892 | // Switch to the selected View | 893 | // Switch to the selected View |
893 | slotViewSwitched( view ); | 894 | slotViewSwitched( view ); |
894 | 895 | ||
895 | // Tell the view about the selected category | 896 | // Tell the view about the selected category |
896 | m_abView -> setShowByCategory( cat ); | 897 | m_abView -> setShowByCategory( cat ); |
897 | 898 | ||
898 | if ( book.isEmpty() ) | 899 | if ( book.isEmpty() ) |
899 | book = "List"; | 900 | book = "List"; |
900 | if ( cat.isEmpty() ) | 901 | if ( cat.isEmpty() ) |
901 | cat = "All"; | 902 | cat = "All"; |
902 | 903 | ||
903 | setCaption( tr( "Contacts" ) + " - " + book + " - " + tr( cat ) ); | 904 | setCaption( tr( "Contacts" ) + " - " + book + " - " + tr( cat ) ); |
904 | } | 905 | } |
905 | 906 | ||
906 | void AddressbookWindow::slotViewSwitched( int view ) | 907 | void AddressbookWindow::slotViewSwitched( int view ) |
907 | { | 908 | { |
908 | qWarning( "void AddressbookWindow::slotViewSwitched( %d )", view ); | 909 | qWarning( "void AddressbookWindow::slotViewSwitched( %d )", view ); |
909 | int menu = 0; | 910 | int menu = 0; |
910 | 911 | ||
911 | // Switch to selected view | 912 | // Switch to selected view |
912 | switch ( view ){ | 913 | switch ( view ){ |
913 | case AbView::TableView: | 914 | case AbView::TableView: |
914 | menu = 1; | 915 | menu = 1; |
915 | m_tableViewButton->setOn(true); | 916 | m_tableViewButton->setOn(true); |
916 | m_cardViewButton->setOn(false); | 917 | m_cardViewButton->setOn(false); |
917 | break; | 918 | break; |
918 | case AbView::CardView: | 919 | case AbView::CardView: |
919 | menu = 2; | 920 | menu = 2; |
920 | m_tableViewButton->setOn(false); | 921 | m_tableViewButton->setOn(false); |
921 | m_cardViewButton->setOn(true); | 922 | m_cardViewButton->setOn(true); |
922 | break; | 923 | break; |
923 | } | 924 | } |
924 | for ( unsigned int i = 1; i < 3; i++ ){ | 925 | for ( unsigned int i = 1; i < 3; i++ ){ |
925 | if ( catMenu ) | 926 | if ( catMenu ) |
926 | catMenu->setItemChecked( i, menu == (int)i ); | 927 | catMenu->setItemChecked( i, menu == (int)i ); |
927 | } | 928 | } |
928 | 929 | ||
929 | // Tell the view about the selected view | 930 | // Tell the view about the selected view |
930 | m_abView -> setShowToView ( (AbView::Views) view ); | 931 | m_abView -> setShowToView ( (AbView::Views) view ); |
931 | active_view = view; | 932 | active_view = view; |
932 | } | 933 | } |
933 | 934 | ||
934 | 935 | ||
935 | void AddressbookWindow::slotListView() | 936 | void AddressbookWindow::slotListView() |
936 | { | 937 | { |
937 | slotViewSwitched( AbView::TableView ); | 938 | slotViewSwitched( AbView::TableView ); |
938 | } | 939 | } |
939 | 940 | ||
940 | void AddressbookWindow::slotCardView() | 941 | void AddressbookWindow::slotCardView() |
941 | { | 942 | { |
942 | slotViewSwitched( AbView::CardView ); | 943 | slotViewSwitched( AbView::CardView ); |
943 | } | 944 | } |
944 | 945 | ||
945 | void AddressbookWindow::slotSetLetter( char c ) { | 946 | void AddressbookWindow::slotSetLetter( char c ) { |
946 | 947 | ||
947 | m_abView->setShowByLetter( c ); | 948 | m_abView->setShowByLetter( c ); |
948 | 949 | ||
949 | } | 950 | } |
950 | 951 | ||
951 | 952 | ||
952 | void AddressbookWindow::populateCategories() | 953 | void AddressbookWindow::populateCategories() |
953 | { | 954 | { |
954 | catMenu->clear(); | 955 | catMenu->clear(); |
955 | 956 | ||
956 | int id, rememberId; | 957 | int id, rememberId; |
957 | id = 1; | 958 | id = 1; |
958 | rememberId = 0; | 959 | rememberId = 0; |
959 | 960 | ||
960 | catMenu->insertItem( Resource::loadPixmap( "datebook/weeklst" ), tr( "List" ), id++ ); | 961 | catMenu->insertItem( Resource::loadPixmap( "datebook/weeklst" ), tr( "List" ), id++ ); |
961 | catMenu->insertItem( Resource::loadPixmap( "day" ), tr( "Cards" ), id++ ); | 962 | catMenu->insertItem( Resource::loadPixmap( "day" ), tr( "Cards" ), id++ ); |
962 | // catMenu->insertItem( tr( "Personal" ), id++ ); | 963 | // catMenu->insertItem( tr( "Personal" ), id++ ); |
963 | catMenu->insertSeparator(); | 964 | catMenu->insertSeparator(); |
964 | 965 | ||
965 | catMenu->insertItem( tr( "All" ), id++ ); | 966 | catMenu->insertItem( tr( "All" ), id++ ); |
966 | QStringList categories = m_abView->categories(); | 967 | QStringList categories = m_abView->categories(); |
967 | categories.append( tr( "Unfiled" ) ); | 968 | categories.append( tr( "Unfiled" ) ); |
968 | for ( QStringList::Iterator it = categories.begin(); | 969 | for ( QStringList::Iterator it = categories.begin(); |
969 | it != categories.end(); ++it ) { | 970 | it != categories.end(); ++it ) { |
970 | catMenu->insertItem( *it, id ); | 971 | catMenu->insertItem( *it, id ); |
971 | if ( *it == m_abView -> showCategory() ) | 972 | if ( *it == m_abView -> showCategory() ) |
972 | rememberId = id; | 973 | rememberId = id; |
973 | ++id; | 974 | ++id; |
974 | } | 975 | } |
975 | 976 | ||