summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/addressbook.cpp26
1 files changed, 17 insertions, 9 deletions
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp
index 0276231..8937227 100644
--- a/core/pim/addressbook/addressbook.cpp
+++ b/core/pim/addressbook/addressbook.cpp
@@ -353,484 +353,492 @@ void AddressbookWindow::setDocument( const QString &filename )
353 filename ); 353 filename );
354 OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); 354 OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true );
355 OContactAccess::List allList = access->allRecords(); 355 OContactAccess::List allList = access->allRecords();
356 qWarning( "Found number of contacts in File: %d", allList.count() ); 356 qWarning( "Found number of contacts in File: %d", allList.count() );
357 357
358 if ( !allList.count() ) { 358 if ( !allList.count() ) {
359 QMessageBox::information( this, "Import VCard", 359 QMessageBox::information( this, "Import VCard",
360 "It was impossible to import\nthe VCard.\n" 360 "It was impossible to import\nthe VCard.\n"
361 "The VCard may be corrupted!" ); 361 "The VCard may be corrupted!" );
362 } 362 }
363 363
364 bool doAsk = true; 364 bool doAsk = true;
365 OContactAccess::List::Iterator it; 365 OContactAccess::List::Iterator it;
366 for ( it = allList.begin(); it != allList.end(); ++it ){ 366 for ( it = allList.begin(); it != allList.end(); ++it ){
367 qWarning("Adding Contact from: %s", (*it).fullName().latin1() ); 367 qWarning("Adding Contact from: %s", (*it).fullName().latin1() );
368 if ( doAsk ){ 368 if ( doAsk ){
369 switch( QMessageBox::information( this, tr ( "Add Contact?" ), 369 switch( QMessageBox::information( this, tr ( "Add Contact?" ),
370 tr( "Do you really want add contact for \n%1?" ) 370 tr( "Do you really want add contact for \n%1?" )
371 .arg( (*it).fullName().latin1() ), 371 .arg( (*it).fullName().latin1() ),
372 tr( "&Yes" ), tr( "&No" ), tr( "&All Yes"), 372 tr( "&Yes" ), tr( "&No" ), tr( "&All Yes"),
373 0, // Enter == button 0 373 0, // Enter == button 0
374 2 ) ) { // Escape == button 2 374 2 ) ) { // Escape == button 2
375 case 0: 375 case 0:
376 qWarning("YES clicked"); 376 qWarning("YES clicked");
377 m_abView->addEntry( *it ); 377 m_abView->addEntry( *it );
378 break; 378 break;
379 case 1: 379 case 1:
380 qWarning("NO clicked"); 380 qWarning("NO clicked");
381 break; 381 break;
382 case 2: 382 case 2:
383 qWarning("YesAll clicked"); 383 qWarning("YesAll clicked");
384 doAsk = false; 384 doAsk = false;
385 break; 385 break;
386 } 386 }
387 }else 387 }else
388 m_abView->addEntry( *it ); 388 m_abView->addEntry( *it );
389 389
390 } 390 }
391 391
392 delete access; 392 delete access;
393} 393}
394 394
395void AddressbookWindow::resizeEvent( QResizeEvent *e ) 395void AddressbookWindow::resizeEvent( QResizeEvent *e )
396{ 396{
397 QMainWindow::resizeEvent( e ); 397 QMainWindow::resizeEvent( e );
398 398
399 399
400} 400}
401 401
402AddressbookWindow::~AddressbookWindow() 402AddressbookWindow::~AddressbookWindow()
403{ 403{
404 ToolBarDock dock; 404 ToolBarDock dock;
405 int dummy; 405 int dummy;
406 bool bDummy; 406 bool bDummy;
407 getLocation ( listTools, dock, dummy, bDummy, dummy ); 407 getLocation ( listTools, dock, dummy, bDummy, dummy );
408 m_config.setToolBarDock( dock ); 408 m_config.setToolBarDock( dock );
409 m_config.save(); 409 m_config.save();
410} 410}
411 411
412void AddressbookWindow::slotUpdateToolbar() 412void AddressbookWindow::slotUpdateToolbar()
413{ 413{
414 OContact ce = m_abView->currentEntry(); 414 OContact ce = m_abView->currentEntry();
415 actionMail->setEnabled( !ce.defaultEmail().isEmpty() ); 415 actionMail->setEnabled( !ce.defaultEmail().isEmpty() );
416} 416}
417 417
418void AddressbookWindow::slotListNew() 418void AddressbookWindow::slotListNew()
419{ 419{
420 OContact cnt; 420 OContact cnt;
421 if( !syncing ) { 421 if( !syncing ) {
422 editEntry( NewEntry ); 422 editEntry( NewEntry );
423 } else { 423 } else {
424 QMessageBox::warning(this, tr("Contacts"), 424 QMessageBox::warning(this, tr("Contacts"),
425 tr("Can not edit data, currently syncing")); 425 tr("Can not edit data, currently syncing"));
426 } 426 }
427} 427}
428 428
429// void AddressbookWindow::slotListView() 429// void AddressbookWindow::slotListView()
430// { 430// {
431 // m_abView -> init( abList->currentEntry() ); 431 // m_abView -> init( abList->currentEntry() );
432 // // :SX mView->sync(); 432 // // :SX mView->sync();
433 // //:SXshowView(); 433 // //:SXshowView();
434// } 434// }
435 435
436void AddressbookWindow::slotListDelete() 436void AddressbookWindow::slotListDelete()
437{ 437{
438 if(!syncing) { 438 if(!syncing) {
439 OContact tmpEntry = m_abView ->currentEntry(); 439 OContact tmpEntry = m_abView ->currentEntry();
440 440
441 // get a name, do the best we can... 441 // get a name, do the best we can...
442 QString strName = tmpEntry.fullName(); 442 QString strName = tmpEntry.fullName();
443 if ( strName.isEmpty() ) { 443 if ( strName.isEmpty() ) {
444 strName = tmpEntry.company(); 444 strName = tmpEntry.company();
445 if ( strName.isEmpty() ) 445 if ( strName.isEmpty() )
446 strName = "No Name"; 446 strName = "No Name";
447 } 447 }
448 448
449 449
450 if ( QPEMessageBox::confirmDelete( this, tr( "Contacts" ), 450 if ( QPEMessageBox::confirmDelete( this, tr( "Contacts" ),
451 strName ) ) { 451 strName ) ) {
452 m_abView->removeEntry( tmpEntry.uid() ); 452 m_abView->removeEntry( tmpEntry.uid() );
453 } 453 }
454 } else { 454 } else {
455 QMessageBox::warning( this, tr("Contacts"), 455 QMessageBox::warning( this, tr("Contacts"),
456 tr("Can not edit data, currently syncing") ); 456 tr("Can not edit data, currently syncing") );
457 } 457 }
458} 458}
459 459
460void AddressbookWindow::slotFindOpen() 460void AddressbookWindow::slotFindOpen()
461{ 461{
462 searchBar->show(); 462 searchBar->show();
463 m_abView -> inSearch(); 463 m_abView -> inSearch();
464 searchEdit->setFocus(); 464 searchEdit->setFocus();
465} 465}
466void AddressbookWindow::slotFindClose() 466void AddressbookWindow::slotFindClose()
467{ 467{
468 searchBar->hide(); 468 searchBar->hide();
469 m_abView -> offSearch(); 469 m_abView -> offSearch();
470 // m_abView->setFocus(); 470 // m_abView->setFocus();
471} 471}
472 472
473 473
474void AddressbookWindow::slotFind() 474void AddressbookWindow::slotFind()
475{ 475{
476 m_abView->slotDoFind( searchEdit->text(), m_config.beCaseSensitive(), m_config.useRegExp(), false); 476 m_abView->slotDoFind( searchEdit->text(), m_config.beCaseSensitive(), m_config.useRegExp(), false);
477 477
478 searchEdit->clearFocus(); 478 searchEdit->clearFocus();
479 // m_abView->setFocus(); 479 // m_abView->setFocus();
480 480
481} 481}
482 482
483void AddressbookWindow::slotViewBack() 483void AddressbookWindow::slotViewBack()
484{ 484{
485 // :SX showList(); 485 // :SX showList();
486} 486}
487 487
488void AddressbookWindow::slotViewEdit() 488void AddressbookWindow::slotViewEdit()
489{ 489{
490 if(!syncing) { 490 if(!syncing) {
491 if (actionPersonal->isOn()) { 491 if (actionPersonal->isOn()) {
492 editPersonal(); 492 editPersonal();
493 } else { 493 } else {
494 editEntry( EditEntry ); 494 editEntry( EditEntry );
495 } 495 }
496 } else { 496 } else {
497 QMessageBox::warning( this, tr("Contacts"), 497 QMessageBox::warning( this, tr("Contacts"),
498 tr("Can not edit data, currently syncing") ); 498 tr("Can not edit data, currently syncing") );
499 } 499 }
500} 500}
501 501
502 502
503 503
504void AddressbookWindow::writeMail() 504void AddressbookWindow::writeMail()
505{ 505{
506 OContact c = m_abView -> currentEntry(); 506 OContact c = m_abView -> currentEntry();
507 QString name = c.fileAs(); 507 QString name = c.fileAs();
508 QString email = c.defaultEmail(); 508 QString email = c.defaultEmail();
509 509
510 // I prefer the OPIE-Environment variable before the 510 // I prefer the OPIE-Environment variable before the
511 // QPE-one.. 511 // QPE-one..
512 QString basepath = QString::fromLatin1( getenv("OPIEDIR") ); 512 QString basepath = QString::fromLatin1( getenv("OPIEDIR") );
513 if ( basepath.isEmpty() ) 513 if ( basepath.isEmpty() )
514 basepath = QString::fromLatin1( getenv("QPEDIR") ); 514 basepath = QString::fromLatin1( getenv("QPEDIR") );
515 515
516 // Try to access the preferred. If not possible, try to 516 // Try to access the preferred. If not possible, try to
517 // switch to the other one.. 517 // switch to the other one..
518 if ( m_config.useQtMail() ){ 518 if ( m_config.useQtMail() ){
519 qWarning ("Accessing: %s", (basepath + "/bin/qtmail").latin1()); 519 qWarning ("Accessing: %s", (basepath + "/bin/qtmail").latin1());
520 if ( QFile::exists( basepath + "/bin/qtmail" ) ){ 520 if ( QFile::exists( basepath + "/bin/qtmail" ) ){
521 qWarning ("QCop"); 521 qWarning ("QCop");
522 QCopEnvelope e("QPE/Application/qtmail", "writeMail(QString,QString)"); 522 QCopEnvelope e("QPE/Application/qtmail", "writeMail(QString,QString)");
523 e << name << email; 523 e << name << email;
524 return; 524 return;
525 } else 525 } else
526 m_config.setUseOpieMail( true ); 526 m_config.setUseOpieMail( true );
527 } 527 }
528 if ( m_config.useOpieMail() ){ 528 if ( m_config.useOpieMail() ){
529 qWarning ("Accessing: %s", (basepath + "/bin/mail").latin1()); 529 qWarning ("Accessing: %s", (basepath + "/bin/mail").latin1());
530 if ( QFile::exists( basepath + "/bin/mail" ) ){ 530 if ( QFile::exists( basepath + "/bin/mail" ) ){
531 qWarning ("QCop"); 531 qWarning ("QCop");
532 QCopEnvelope e("QPE/Application/mail", "writeMail(QString,QString)"); 532 QCopEnvelope e("QPE/Application/mail", "writeMail(QString,QString)");
533 e << name << email; 533 e << name << email;
534 return; 534 return;
535 } else 535 } else
536 m_config.setUseQtMail( true ); 536 m_config.setUseQtMail( true );
537 } 537 }
538 538
539} 539}
540 540
541static const char * beamfile = "/tmp/obex/contact.vcf"; 541static const char * beamfile = "/tmp/obex/contact.vcf";
542 542
543void AddressbookWindow::slotBeam() 543void AddressbookWindow::slotBeam()
544{ 544{
545 QString filename; 545 QString beamFilename;
546 OContact c; 546 OContact c;
547 if ( actionPersonal->isOn() ) { 547 if ( actionPersonal->isOn() ) {
548 filename = addressbookPersonalVCardName(); 548 beamFilename = addressbookPersonalVCardName();
549 if (!QFile::exists(filename)) 549 if ( !QFile::exists( beamFilename ) )
550 return; // can't beam a non-existent file 550 return; // can't beam a non-existent file
551 OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, 551 OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null,
552 filename ); 552 beamFilename );
553 OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); 553 OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true );
554 OContactAccess::List allList = access->allRecords(); 554 OContactAccess::List allList = access->allRecords();
555 OContactAccess::List::Iterator it = allList.begin(); // Just take first 555 OContactAccess::List::Iterator it = allList.begin(); // Just take first
556 c = *it; 556 c = *it;
557 557
558 delete access; 558 delete access;
559 } else { 559 } else {
560 unlink( beamfile ); // delete if exists 560 unlink( beamfile ); // delete if exists
561 mkdir("/tmp/obex/", 0755); 561 mkdir("/tmp/obex/", 0755);
562 c = m_abView -> currentEntry(); 562 c = m_abView -> currentEntry();
563 OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, 563 OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null,
564 beamfile ); 564 beamfile );
565 OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); 565 OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true );
566 access->add( c ); 566 access->add( c );
567 access->save(); 567 access->save();
568 delete access; 568 delete access;
569 569
570 filename = beamfile; 570 beamFilename = beamfile;
571 } 571 }
572 572
573 qWarning("Beaming: %s", beamFilename.latin1() );
573 574
574 Ir *ir = new Ir( this ); 575 Ir *ir = new Ir( this );
575 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 576 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
576 QString description = c.fullName(); 577 QString description = c.fullName();
577 ir->send( filename, description, "text/x-vCard" ); 578 ir->send( beamFilename, description, "text/x-vCard" );
578} 579}
579 580
580void AddressbookWindow::beamDone( Ir *ir ) 581void AddressbookWindow::beamDone( Ir *ir )
581{ 582{
583
582 delete ir; 584 delete ir;
583 unlink( beamfile ); 585 unlink( beamfile );
584} 586}
585 587
586 588
587static void parseName( const QString& name, QString *first, QString *middle, 589static void parseName( const QString& name, QString *first, QString *middle,
588 QString * last ) 590 QString * last )
589{ 591{
590 592
591 int comma = name.find ( "," ); 593 int comma = name.find ( "," );
592 QString rest; 594 QString rest;
593 if ( comma > 0 ) { 595 if ( comma > 0 ) {
594 *last = name.left( comma ); 596 *last = name.left( comma );
595 comma++; 597 comma++;
596 while ( comma < int(name.length()) && name[comma] == ' ' ) 598 while ( comma < int(name.length()) && name[comma] == ' ' )
597 comma++; 599 comma++;
598 rest = name.mid( comma ); 600 rest = name.mid( comma );
599 } else { 601 } else {
600 int space = name.findRev( ' ' ); 602 int space = name.findRev( ' ' );
601 *last = name.mid( space+1 ); 603 *last = name.mid( space+1 );
602 rest = name.left( space ); 604 rest = name.left( space );
603 } 605 }
604 int space = rest.find( ' ' ); 606 int space = rest.find( ' ' );
605 if ( space <= 0 ) { 607 if ( space <= 0 ) {
606 *first = rest; 608 *first = rest;
607 } else { 609 } else {
608 *first = rest.left( space ); 610 *first = rest.left( space );
609 *middle = rest.mid( space+1 ); 611 *middle = rest.mid( space+1 );
610 } 612 }
611 613
612} 614}
613 615
614 616
615void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) 617void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data)
616{ 618{
617 if (msg == "editPersonal()") { 619 if (msg == "editPersonal()") {
618 editPersonal(); 620 editPersonal();
619 } else if (msg == "editPersonalAndClose()") { 621 } else if (msg == "editPersonalAndClose()") {
620 editPersonal(); 622 editPersonal();
621 close(); 623 close();
622 } else if ( msg == "addContact(QString,QString)" ) { 624 } else if ( msg == "addContact(QString,QString)" ) {
623 QDataStream stream(data,IO_ReadOnly); 625 QDataStream stream(data,IO_ReadOnly);
624 QString name, email; 626 QString name, email;
625 stream >> name >> email; 627 stream >> name >> email;
626 628
627 OContact cnt; 629 OContact cnt;
628 QString fn, mn, ln; 630 QString fn, mn, ln;
629 parseName( name, &fn, &mn, &ln ); 631 parseName( name, &fn, &mn, &ln );
630 // qDebug( " %s - %s - %s", fn.latin1(), mn.latin1(), ln.latin1() ); 632 // qDebug( " %s - %s - %s", fn.latin1(), mn.latin1(), ln.latin1() );
631 cnt.setFirstName( fn ); 633 cnt.setFirstName( fn );
632 cnt.setMiddleName( mn ); 634 cnt.setMiddleName( mn );
633 cnt.setLastName( ln ); 635 cnt.setLastName( ln );
634 cnt.insertEmails( email ); 636 cnt.insertEmails( email );
635 cnt.setDefaultEmail( email ); 637 cnt.setDefaultEmail( email );
636 cnt.setFileAs(); 638 cnt.setFileAs();
637 639
638 m_abView -> addEntry( cnt ); 640 m_abView -> addEntry( cnt );
639 641
640 // :SXm_abView()->init( cnt ); 642 // :SXm_abView()->init( cnt );
641 editEntry( EditEntry ); 643 editEntry( EditEntry );
642 644 } else if ( msg == "beamBusinessCard()" ) {
643 645 QString beamFilename = addressbookPersonalVCardName();
644 646 if ( !QFile::exists( beamFilename ) )
647 return; // can't beam a non-existent file
648
649 Ir *ir = new Ir( this );
650 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
651 QString description = "mycard.vcf";
652 ir->send( beamFilename, description, "text/x-vCard" );
645 } 653 }
646#if 0 654#if 0
647 else if (msg == "pickAddresses(QCString,QCString,QStringList,...)" ) { 655 else if (msg == "pickAddresses(QCString,QCString,QStringList,...)" ) {
648 QDataStream stream(data,IO_ReadOnly); 656 QDataStream stream(data,IO_ReadOnly);
649 QCString ch,m; 657 QCString ch,m;
650 QStringList types; 658 QStringList types;
651 stream >> ch >> m >> types; 659 stream >> ch >> m >> types;
652 AddressPicker picker(abList,this,0,TRUE); 660 AddressPicker picker(abList,this,0,TRUE);
653 picker.showMaximized(); 661 picker.showMaximized();
654 picker.setChoiceNames(types); 662 picker.setChoiceNames(types);
655 int i=0; 663 int i=0;
656 for (QStringList::ConstIterator it = types.begin(); it!=types.end(); ++it) { 664 for (QStringList::ConstIterator it = types.begin(); it!=types.end(); ++it) {
657 QStringList sel; 665 QStringList sel;
658 stream >> sel; 666 stream >> sel;
659 picker.setSelection(i++,sel); 667 picker.setSelection(i++,sel);
660 } 668 }
661 picker.showMaximized(); 669 picker.showMaximized();
662 picker.exec(); 670 picker.exec();
663 671
664 // ###### note: contacts may have been added - save here! 672 // ###### note: contacts may have been added - save here!
665 673
666 setCentralWidget(abList); 674 setCentralWidget(abList);
667 QCopEnvelope e(ch,m); 675 QCopEnvelope e(ch,m);
668 i=0; 676 i=0;
669 for (QStringList::ConstIterator it = types.begin(); it!=types.end(); ++it) { 677 for (QStringList::ConstIterator it = types.begin(); it!=types.end(); ++it) {
670 QStringList sel = picker.selection(i++); 678 QStringList sel = picker.selection(i++);
671 e << sel; 679 e << sel;
672 } 680 }
673 } 681 }
674#endif 682#endif
675 683
676} 684}
677 685
678void AddressbookWindow::editEntry( EntryMode entryMode ) 686void AddressbookWindow::editEntry( EntryMode entryMode )
679{ 687{
680 OContact entry; 688 OContact entry;
681 if ( !abEditor ) { 689 if ( !abEditor ) {
682 abEditor = new ContactEditor( entry, this, "editor" ); 690 abEditor = new ContactEditor( entry, this, "editor" );
683 } 691 }
684 if ( entryMode == EditEntry ) 692 if ( entryMode == EditEntry )
685 abEditor->setEntry( m_abView -> currentEntry() ); 693 abEditor->setEntry( m_abView -> currentEntry() );
686 else if ( entryMode == NewEntry ) 694 else if ( entryMode == NewEntry )
687 abEditor->setEntry( entry ); 695 abEditor->setEntry( entry );
688 // other things may change the caption. 696 // other things may change the caption.
689 abEditor->setCaption( tr("Edit Address") ); 697 abEditor->setCaption( tr("Edit Address") );
690 698
691#if defined(Q_WS_QWS) || defined(_WS_QWS_) 699#if defined(Q_WS_QWS) || defined(_WS_QWS_)
692 abEditor->showMaximized(); 700 abEditor->showMaximized();
693#endif 701#endif
694 // fix the foxus... 702 // fix the foxus...
695 abEditor->setNameFocus(); 703 abEditor->setNameFocus();
696 if ( abEditor->exec() ) { 704 if ( abEditor->exec() ) {
697 setFocus(); 705 setFocus();
698 if ( entryMode == NewEntry ) { 706 if ( entryMode == NewEntry ) {
699 OContact insertEntry = abEditor->entry(); 707 OContact insertEntry = abEditor->entry();
700 insertEntry.assignUid(); 708 insertEntry.assignUid();
701 m_abView -> addEntry( insertEntry ); 709 m_abView -> addEntry( insertEntry );
702 } else { 710 } else {
703 OContact replEntry = abEditor->entry(); 711 OContact replEntry = abEditor->entry();
704 712
705 if ( !replEntry.isValidUid() ) 713 if ( !replEntry.isValidUid() )
706 replEntry.assignUid(); 714 replEntry.assignUid();
707 715
708 m_abView -> replaceEntry( replEntry ); 716 m_abView -> replaceEntry( replEntry );
709 } 717 }
710 } 718 }
711 // populateCategories(); 719 // populateCategories();
712 720
713} 721}
714 722
715void AddressbookWindow::editPersonal() 723void AddressbookWindow::editPersonal()
716{ 724{
717 OContact entry; 725 OContact entry;
718 726
719 // Switch to personal view if not selected 727 // Switch to personal view if not selected
720 // but take care of the menu, too 728 // but take care of the menu, too
721 if ( ! actionPersonal->isOn() ){ 729 if ( ! actionPersonal->isOn() ){
722 qWarning("*** ++++"); 730 qWarning("*** ++++");
723 actionPersonal->setOn( true ); 731 actionPersonal->setOn( true );
724 slotPersonalView(); 732 slotPersonalView();
725 } 733 }
726 734
727 if ( !abEditor ) { 735 if ( !abEditor ) {
728 abEditor = new ContactEditor( entry, this, "editor" ); 736 abEditor = new ContactEditor( entry, this, "editor" );
729 } 737 }
730 738
731 abEditor->setCaption(tr("Edit My Personal Details")); 739 abEditor->setCaption(tr("Edit My Personal Details"));
732 abEditor->setPersonalView( true ); 740 abEditor->setPersonalView( true );
733 editEntry( EditEntry ); 741 editEntry( EditEntry );
734 abEditor->setPersonalView( false ); 742 abEditor->setPersonalView( false );
735 743
736} 744}
737 745
738 746
739void AddressbookWindow::slotPersonalView() 747void AddressbookWindow::slotPersonalView()
740{ 748{
741 qWarning("slotPersonalView()"); 749 qWarning("slotPersonalView()");
742 if (!actionPersonal->isOn()) { 750 if (!actionPersonal->isOn()) {
743 // we just turned it off 751 // we just turned it off
744 qWarning("slotPersonalView()-> OFF"); 752 qWarning("slotPersonalView()-> OFF");
745 setCaption( tr("Contacts") ); 753 setCaption( tr("Contacts") );
746 actionNew->setEnabled(TRUE); 754 actionNew->setEnabled(TRUE);
747 actionTrash->setEnabled(TRUE); 755 actionTrash->setEnabled(TRUE);
748 actionFind->setEnabled(TRUE); 756 actionFind->setEnabled(TRUE);
749 actionMail->setEnabled(TRUE); 757 actionMail->setEnabled(TRUE);
750 // slotUpdateToolbar(); 758 // slotUpdateToolbar();
751 759
752 m_abView->showPersonal( false ); 760 m_abView->showPersonal( false );
753 761
754 return; 762 return;
755 } 763 }
756 764
757 qWarning("slotPersonalView()-> ON"); 765 qWarning("slotPersonalView()-> ON");
758 // XXX need to disable some QActions. 766 // XXX need to disable some QActions.
759 actionNew->setEnabled(FALSE); 767 actionNew->setEnabled(FALSE);
760 actionTrash->setEnabled(FALSE); 768 actionTrash->setEnabled(FALSE);
761 actionFind->setEnabled(FALSE); 769 actionFind->setEnabled(FALSE);
762 actionMail->setEnabled(FALSE); 770 actionMail->setEnabled(FALSE);
763 771
764 setCaption( tr("Contacts - My Personal Details") ); 772 setCaption( tr("Contacts - My Personal Details") );
765 773
766 m_abView->showPersonal( true ); 774 m_abView->showPersonal( true );
767 775
768} 776}
769 777
770 778
771void AddressbookWindow::listIsEmpty( bool empty ) 779void AddressbookWindow::listIsEmpty( bool empty )
772{ 780{
773 if ( !empty ) { 781 if ( !empty ) {
774 deleteButton->setEnabled( TRUE ); 782 deleteButton->setEnabled( TRUE );
775 } 783 }
776} 784}
777 785
778void AddressbookWindow::reload() 786void AddressbookWindow::reload()
779{ 787{
780 syncing = FALSE; 788 syncing = FALSE;
781 m_abView->clear(); 789 m_abView->clear();
782 m_abView->reload(); 790 m_abView->reload();
783} 791}
784 792
785void AddressbookWindow::flush() 793void AddressbookWindow::flush()
786{ 794{
787 syncing = TRUE; 795 syncing = TRUE;
788 m_abView->save(); 796 m_abView->save();
789} 797}
790 798
791 799
792void AddressbookWindow::closeEvent( QCloseEvent *e ) 800void AddressbookWindow::closeEvent( QCloseEvent *e )
793{ 801{
794 if(active_view == AbView::CardView){ 802 if(active_view == AbView::CardView){
795 slotViewSwitched( AbView::TableView ); 803 slotViewSwitched( AbView::TableView );
796 e->ignore(); 804 e->ignore();
797 return; 805 return;
798 } 806 }
799 if(syncing) { 807 if(syncing) {
800 /* shouldn't we save, I hear you say? well its already been set 808 /* shouldn't we save, I hear you say? well its already been set
801 so that an edit can not occur during a sync, and we flushed 809 so that an edit can not occur during a sync, and we flushed
802 at the start of the sync, so there is no need to save 810 at the start of the sync, so there is no need to save
803 Saving however itself would cause problems. */ 811 Saving however itself would cause problems. */
804 e->accept(); 812 e->accept();
805 return; 813 return;
806 } 814 }
807 //################## shouldn't always save 815 //################## shouldn't always save
808 // True, but the database handles this automatically ! (se) 816 // True, but the database handles this automatically ! (se)
809 if ( save() ) 817 if ( save() )
810 e->accept(); 818 e->accept();
811 else 819 else
812 e->ignore(); 820 e->ignore();
813} 821}
814 822
815/* 823/*
816 Returns TRUE if it is OK to exit 824 Returns TRUE if it is OK to exit
817*/ 825*/
818 826
819bool AddressbookWindow::save() 827bool AddressbookWindow::save()
820{ 828{
821 if ( !m_abView->save() ) { 829 if ( !m_abView->save() ) {
822 if ( QMessageBox::critical( 0, tr( "Out of space" ), 830 if ( QMessageBox::critical( 0, tr( "Out of space" ),
823 tr("Unable to save information.\n" 831 tr("Unable to save information.\n"
824 "Free up some space\n" 832 "Free up some space\n"
825 "and try again.\n" 833 "and try again.\n"
826 "\nQuit anyway?"), 834 "\nQuit anyway?"),
827 QMessageBox::Yes|QMessageBox::Escape, 835 QMessageBox::Yes|QMessageBox::Escape,
828 QMessageBox::No|QMessageBox::Default ) 836 QMessageBox::No|QMessageBox::Default )
829 != QMessageBox::No ) 837 != QMessageBox::No )
830 return TRUE; 838 return TRUE;
831 else 839 else
832 return FALSE; 840 return FALSE;
833 } 841 }
834 return TRUE; 842 return TRUE;
835} 843}
836 844