-rw-r--r-- | kaddressbook/kabcore.cpp | 49 |
1 files changed, 35 insertions, 14 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index d891b07..25891a0 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -445,21 +445,21 @@ void KABCore::setContactSelected( const QString &uid ) | |||
445 | mActionPaste->setEnabled( selected ); | 445 | mActionPaste->setEnabled( selected ); |
446 | } | 446 | } |
447 | 447 | ||
448 | mActionCopy->setEnabled( selected ); | 448 | mActionCopy->setEnabled( selected ); |
449 | mActionDelete->setEnabled( selected ); | 449 | mActionDelete->setEnabled( selected ); |
450 | mActionEditAddressee->setEnabled( selected ); | 450 | mActionEditAddressee->setEnabled( selected ); |
451 | mActionMail->setEnabled( selected ); | 451 | mActionMail->setEnabled( selected ); |
452 | mActionMailVCard->setEnabled( selected ); | 452 | mActionMailVCard->setEnabled( selected ); |
453 | if (mActionBeam) | 453 | //if (mActionBeam) |
454 | mActionBeam->setEnabled( selected ); | 454 | //mActionBeam->setEnabled( selected ); |
455 | 455 | ||
456 | if (mActionBeam) | 456 | if (mActionBeamVCard) |
457 | mActionBeamVCard->setEnabled( selected ); | 457 | mActionBeamVCard->setEnabled( selected ); |
458 | 458 | ||
459 | mActionWhoAmI->setEnabled( selected ); | 459 | mActionWhoAmI->setEnabled( selected ); |
460 | mActionCategories->setEnabled( selected ); | 460 | mActionCategories->setEnabled( selected ); |
461 | } | 461 | } |
462 | 462 | ||
463 | void KABCore::sendMail() | 463 | void KABCore::sendMail() |
464 | { | 464 | { |
465 | sendMail( mViewManager->selectedEmails().join( ", " ) ); | 465 | sendMail( mViewManager->selectedEmails().join( ", " ) ); |
@@ -580,16 +580,20 @@ void KABCore::beamMySelf() | |||
580 | { | 580 | { |
581 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); | 581 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); |
582 | if (!a.isEmpty()) | 582 | if (!a.isEmpty()) |
583 | { | 583 | { |
584 | QStringList uids; | 584 | QStringList uids; |
585 | uids << a.uid(); | 585 | uids << a.uid(); |
586 | 586 | ||
587 | beamVCard(uids); | 587 | beamVCard(uids); |
588 | } else { | ||
589 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); | ||
590 | |||
591 | |||
588 | } | 592 | } |
589 | } | 593 | } |
590 | 594 | ||
591 | void KABCore::beamVCard() | 595 | void KABCore::beamVCard() |
592 | { | 596 | { |
593 | QStringList uids = mViewManager->selectedUids(); | 597 | QStringList uids = mViewManager->selectedUids(); |
594 | if ( !uids.isEmpty() ) | 598 | if ( !uids.isEmpty() ) |
595 | beamVCard( uids ); | 599 | beamVCard( uids ); |
@@ -624,26 +628,32 @@ void KABCore::beamVCard(const QStringList& uids) | |||
624 | access->save(); | 628 | access->save(); |
625 | delete access; | 629 | delete access; |
626 | 630 | ||
627 | beamFilename = beamfile; | 631 | beamFilename = beamfile; |
628 | } | 632 | } |
629 | 633 | ||
630 | owarn << "Beaming: " << beamFilename << oendl; | 634 | owarn << "Beaming: " << beamFilename << oendl; |
631 | */ | 635 | */ |
636 | |||
637 | #if 0 | ||
632 | QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | 638 | QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); |
633 | 639 | ||
634 | QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); | 640 | QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); |
635 | 641 | ||
636 | QString name = "contact.vcf"; | 642 | QString name = "contact.vcf"; |
637 | 643 | ||
638 | QString fileName = dirName + "/" + name; | 644 | QString fileName = dirName + "/" + name; |
645 | #endif | ||
646 | // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory | ||
647 | // | ||
648 | QString fileName = "/tmp/kdepimbeamfile"; | ||
639 | 649 | ||
640 | 650 | ||
641 | QDir().mkdir( dirName, true ); | 651 | //QDir().mkdir( dirName, true ); |
642 | 652 | ||
643 | QFile outFile(fileName); | 653 | QFile outFile(fileName); |
644 | KABC::VCardConverter converter; | 654 | KABC::VCardConverter converter; |
645 | QString description; | 655 | QString description; |
646 | 656 | ||
647 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully | 657 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully |
648 | 658 | ||
649 | QTextStream t( &outFile ); // use a text stream | 659 | QTextStream t( &outFile ); // use a text stream |
@@ -658,29 +668,36 @@ void KABCore::beamVCard(const QStringList& uids) | |||
658 | if (description.isEmpty()) | 668 | if (description.isEmpty()) |
659 | description = a.formattedName(); | 669 | description = a.formattedName(); |
660 | 670 | ||
661 | QString vcard; | 671 | QString vcard; |
662 | converter.addresseeToVCard( a, vcard ); | 672 | converter.addresseeToVCard( a, vcard ); |
663 | t << vcard; | 673 | t << vcard; |
664 | 674 | ||
665 | } | 675 | } |
676 | } else { | ||
677 | qDebug("Error open temp beam file "); | ||
678 | return; | ||
666 | } | 679 | } |
667 | 680 | ||
668 | outFile.close(); | 681 | outFile.close(); |
669 | 682 | ||
683 | #ifndef DESKTOP_VERSION | ||
670 | Ir *ir = new Ir( this ); | 684 | Ir *ir = new Ir( this ); |
671 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); | 685 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); |
672 | ir->send( fileName, description, "text/x-vCard" ); | 686 | ir->send( fileName, description, "text/x-vCard" ); |
687 | #endif | ||
673 | 688 | ||
674 | } | 689 | } |
675 | 690 | ||
676 | void KABCore::beamDone( Ir *ir ) | 691 | void KABCore::beamDone( Ir *ir ) |
677 | { | 692 | { |
693 | #ifndef DESKTOP_VERSION | ||
678 | delete ir; | 694 | delete ir; |
695 | #endif | ||
679 | } | 696 | } |
680 | 697 | ||
681 | 698 | ||
682 | void KABCore::browse( const QString& url ) | 699 | void KABCore::browse( const QString& url ) |
683 | { | 700 | { |
684 | #ifndef KAB_EMBEDDED | 701 | #ifndef KAB_EMBEDDED |
685 | kapp->invokeBrowser( url ); | 702 | kapp->invokeBrowser( url ); |
686 | #else //KAB_EMBEDDED | 703 | #else //KAB_EMBEDDED |
@@ -1485,22 +1502,29 @@ void KABCore::initActions() | |||
1485 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, | 1502 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, |
1486 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); | 1503 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); |
1487 | 1504 | ||
1488 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, | 1505 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, |
1489 | this, SLOT( mailVCard() ), | 1506 | this, SLOT( mailVCard() ), |
1490 | actionCollection(), "file_mail_vcard"); | 1507 | actionCollection(), "file_mail_vcard"); |
1491 | 1508 | ||
1492 | mActionBeamVCard = 0; | 1509 | mActionBeamVCard = 0; |
1510 | mActionBeam = 0; | ||
1511 | |||
1512 | #ifndef DESKTOP_VERSION | ||
1493 | if ( Ir::supported() ) { | 1513 | if ( Ir::supported() ) { |
1494 | mActionBeamVCard = new KAction( i18n( "Beam v&Card" ), "beam", 0, this, | 1514 | mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, |
1495 | SLOT( beamVCard() ), actionCollection(), | 1515 | SLOT( beamVCard() ), actionCollection(), |
1496 | "kaddressbook_beam_vcard" ); | 1516 | "kaddressbook_beam_vcard" ); |
1517 | |||
1518 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, | ||
1519 | SLOT( beamMySelf() ), actionCollection(), | ||
1520 | "kaddressbook_beam_myself" ); | ||
1497 | } | 1521 | } |
1498 | 1522 | #endif | |
1499 | 1523 | ||
1500 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, | 1524 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, |
1501 | this, SLOT( editContact2() ), | 1525 | this, SLOT( editContact2() ), |
1502 | actionCollection(), "file_properties" ); | 1526 | actionCollection(), "file_properties" ); |
1503 | 1527 | ||
1504 | #ifdef KAB_EMBEDDED | 1528 | #ifdef KAB_EMBEDDED |
1505 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); | 1529 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); |
1506 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, | 1530 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, |
@@ -1592,22 +1616,17 @@ void KABCore::initActions() | |||
1592 | //qDebug("KABCore::initActions() LDAP has to be implemented"); | 1616 | //qDebug("KABCore::initActions() LDAP has to be implemented"); |
1593 | #endif //KAB_EMBEDDED | 1617 | #endif //KAB_EMBEDDED |
1594 | 1618 | ||
1595 | 1619 | ||
1596 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, | 1620 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, |
1597 | SLOT( setWhoAmI() ), actionCollection(), | 1621 | SLOT( setWhoAmI() ), actionCollection(), |
1598 | "set_personal" ); | 1622 | "set_personal" ); |
1599 | 1623 | ||
1600 | mActionBeam = 0; | 1624 | |
1601 | if ( Ir::supported() ) { | ||
1602 | mActionBeam = new KAction( i18n( "&Beam Who Am I" ), "beam", 0, this, | ||
1603 | SLOT( beamMySelf() ), actionCollection(), | ||
1604 | "kaddressbook_beam_myself" ); | ||
1605 | } | ||
1606 | 1625 | ||
1607 | 1626 | ||
1608 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, | 1627 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, |
1609 | SLOT( setCategories() ), actionCollection(), | 1628 | SLOT( setCategories() ), actionCollection(), |
1610 | "edit_set_categories" ); | 1629 | "edit_set_categories" ); |
1611 | 1630 | ||
1612 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, | 1631 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, |
1613 | SLOT( removeVoice() ), actionCollection(), | 1632 | SLOT( removeVoice() ), actionCollection(), |
@@ -1688,17 +1707,20 @@ void KABCore::addActionsManually() | |||
1688 | 1707 | ||
1689 | mActionEditAddressee->plug( fileMenu ); | 1708 | mActionEditAddressee->plug( fileMenu ); |
1690 | fileMenu->insertSeparator(); | 1709 | fileMenu->insertSeparator(); |
1691 | mActionSave->plug( fileMenu ); | 1710 | mActionSave->plug( fileMenu ); |
1692 | fileMenu->insertItem( "&Import", ImportMenu ); | 1711 | fileMenu->insertItem( "&Import", ImportMenu ); |
1693 | fileMenu->insertItem( "&Emport", ExportMenu ); | 1712 | fileMenu->insertItem( "&Emport", ExportMenu ); |
1694 | fileMenu->insertSeparator(); | 1713 | fileMenu->insertSeparator(); |
1695 | mActionMailVCard->plug( fileMenu ); | 1714 | mActionMailVCard->plug( fileMenu ); |
1715 | #ifndef DESKTOP_VERSION | ||
1696 | if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); | 1716 | if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); |
1717 | if ( Ir::supported() ) mActionBeam->plug(fileMenu ); | ||
1718 | #endif | ||
1697 | fileMenu->insertSeparator(); | 1719 | fileMenu->insertSeparator(); |
1698 | mActionQuit->plug( fileMenu ); | 1720 | mActionQuit->plug( fileMenu ); |
1699 | #ifdef _WIN32_ | 1721 | #ifdef _WIN32_ |
1700 | mActionImportOL->plug( ImportMenu ); | 1722 | mActionImportOL->plug( ImportMenu ); |
1701 | #endif | 1723 | #endif |
1702 | // edit menu | 1724 | // edit menu |
1703 | mActionUndo->plug( editMenu ); | 1725 | mActionUndo->plug( editMenu ); |
1704 | mActionRedo->plug( editMenu ); | 1726 | mActionRedo->plug( editMenu ); |
@@ -1729,17 +1751,16 @@ void KABCore::addActionsManually() | |||
1729 | 1751 | ||
1730 | settingsMenu->insertSeparator(); | 1752 | settingsMenu->insertSeparator(); |
1731 | 1753 | ||
1732 | mActionJumpBar->plug( settingsMenu ); | 1754 | mActionJumpBar->plug( settingsMenu ); |
1733 | mActionDetails->plug( settingsMenu ); | 1755 | mActionDetails->plug( settingsMenu ); |
1734 | settingsMenu->insertSeparator(); | 1756 | settingsMenu->insertSeparator(); |
1735 | 1757 | ||
1736 | mActionWhoAmI->plug( settingsMenu ); | 1758 | mActionWhoAmI->plug( settingsMenu ); |
1737 | if ( Ir::supported() ) mActionBeam->plug( settingsMenu ); | ||
1738 | mActionCategories->plug( settingsMenu ); | 1759 | mActionCategories->plug( settingsMenu ); |
1739 | 1760 | ||
1740 | mActionAboutKAddressbook->plug( helpMenu ); | 1761 | mActionAboutKAddressbook->plug( helpMenu ); |
1741 | 1762 | ||
1742 | 1763 | ||
1743 | if (QApplication::desktop()->width() > 320 ) { | 1764 | if (QApplication::desktop()->width() > 320 ) { |
1744 | 1765 | ||
1745 | mActionEditAddressee->plug( tb ); | 1766 | mActionEditAddressee->plug( tb ); |