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