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