summaryrefslogtreecommitdiffabout
path: root/kaddressbook
Unidiff
Diffstat (limited to 'kaddressbook') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp32
1 files changed, 21 insertions, 11 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 42e147f..d970ff1 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1332,1974 +1332,1984 @@ void KABCore::editContact( const QString &uid )
1332 1332
1333 // First, locate the contact entry 1333 // First, locate the contact entry
1334 QString localUID = uid; 1334 QString localUID = uid;
1335 if ( localUID.isNull() ) { 1335 if ( localUID.isNull() ) {
1336 QStringList uidList = mViewManager->selectedUids(); 1336 QStringList uidList = mViewManager->selectedUids();
1337 if ( uidList.count() > 0 ) 1337 if ( uidList.count() > 0 )
1338 localUID = *( uidList.at( 0 ) ); 1338 localUID = *( uidList.at( 0 ) );
1339 } 1339 }
1340 1340
1341 KABC::Addressee addr = mAddressBook->findByUid( localUID ); 1341 KABC::Addressee addr = mAddressBook->findByUid( localUID );
1342 if ( !addr.isEmpty() ) { 1342 if ( !addr.isEmpty() ) {
1343 mEditorDialog->setAddressee( addr ); 1343 mEditorDialog->setAddressee( addr );
1344 KApplication::execDialog ( mEditorDialog ); 1344 KApplication::execDialog ( mEditorDialog );
1345 } 1345 }
1346} 1346}
1347 1347
1348/** 1348/**
1349 Shows or edits the detail view for the given uid. If the uid is QString::null, 1349 Shows or edits the detail view for the given uid. If the uid is QString::null,
1350 the method will try to find a selected addressee in the view. 1350 the method will try to find a selected addressee in the view.
1351 */ 1351 */
1352void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) 1352void KABCore::executeContact( const QString &uid /*US = QString::null*/ )
1353{ 1353{
1354 if ( mMultipleViewsAtOnce ) 1354 if ( mMultipleViewsAtOnce )
1355 { 1355 {
1356 editContact( uid ); 1356 editContact( uid );
1357 } 1357 }
1358 else 1358 else
1359 { 1359 {
1360 setDetailsVisible( true ); 1360 setDetailsVisible( true );
1361 mActionDetails->setChecked(true); 1361 mActionDetails->setChecked(true);
1362 } 1362 }
1363 1363
1364} 1364}
1365 1365
1366void KABCore::save() 1366void KABCore::save()
1367{ 1367{
1368 if (syncManager->blockSave()) 1368 if (syncManager->blockSave())
1369 return; 1369 return;
1370 if ( !mModified ) 1370 if ( !mModified )
1371 return; 1371 return;
1372 1372
1373 syncManager->setBlockSave(true); 1373 syncManager->setBlockSave(true);
1374 QString text = i18n( "There was an error while attempting to save\n the " 1374 QString text = i18n( "There was an error while attempting to save\n the "
1375 "address book. Please check that some \nother application is " 1375 "address book. Please check that some \nother application is "
1376 "not using it. " ); 1376 "not using it. " );
1377 message(i18n("Saving ... please wait! "), false); 1377 message(i18n("Saving ... please wait! "), false);
1378 //qApp->processEvents(); 1378 //qApp->processEvents();
1379#ifndef KAB_EMBEDDED 1379#ifndef KAB_EMBEDDED
1380 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); 1380 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook );
1381 if ( !b || !b->save() ) { 1381 if ( !b || !b->save() ) {
1382 KMessageBox::error( this, text, i18n( "Unable to Save" ) ); 1382 KMessageBox::error( this, text, i18n( "Unable to Save" ) );
1383 } 1383 }
1384#else //KAB_EMBEDDED 1384#else //KAB_EMBEDDED
1385 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); 1385 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook );
1386 if ( !b || !b->save() ) { 1386 if ( !b || !b->save() ) {
1387 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); 1387 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok"));
1388 } 1388 }
1389#endif //KAB_EMBEDDED 1389#endif //KAB_EMBEDDED
1390 1390
1391 message(i18n("Addressbook saved!")); 1391 message(i18n("Addressbook saved!"));
1392 setModified( false ); 1392 setModified( false );
1393 syncManager->setBlockSave(false); 1393 syncManager->setBlockSave(false);
1394} 1394}
1395 1395
1396 1396
1397void KABCore::undo() 1397void KABCore::undo()
1398{ 1398{
1399 UndoStack::instance()->undo(); 1399 UndoStack::instance()->undo();
1400 1400
1401 // Refresh the view 1401 // Refresh the view
1402 mViewManager->refreshView(); 1402 mViewManager->refreshView();
1403} 1403}
1404 1404
1405void KABCore::redo() 1405void KABCore::redo()
1406{ 1406{
1407 RedoStack::instance()->redo(); 1407 RedoStack::instance()->redo();
1408 1408
1409 // Refresh the view 1409 // Refresh the view
1410 mViewManager->refreshView(); 1410 mViewManager->refreshView();
1411} 1411}
1412 1412
1413void KABCore::setJumpButtonBarVisible( bool visible ) 1413void KABCore::setJumpButtonBarVisible( bool visible )
1414{ 1414{
1415 if (mMultipleViewsAtOnce) 1415 if (mMultipleViewsAtOnce)
1416 { 1416 {
1417 if ( visible ) 1417 if ( visible )
1418 mJumpButtonBar->show(); 1418 mJumpButtonBar->show();
1419 else 1419 else
1420 mJumpButtonBar->hide(); 1420 mJumpButtonBar->hide();
1421 } 1421 }
1422 else 1422 else
1423 { 1423 {
1424 // show the jumpbar only if "the details are hidden" == "viewmanager are shown" 1424 // show the jumpbar only if "the details are hidden" == "viewmanager are shown"
1425 if (mViewManager->isVisible()) 1425 if (mViewManager->isVisible())
1426 { 1426 {
1427 if ( visible ) 1427 if ( visible )
1428 mJumpButtonBar->show(); 1428 mJumpButtonBar->show();
1429 else 1429 else
1430 mJumpButtonBar->hide(); 1430 mJumpButtonBar->hide();
1431 } 1431 }
1432 else 1432 else
1433 { 1433 {
1434 mJumpButtonBar->hide(); 1434 mJumpButtonBar->hide();
1435 } 1435 }
1436 } 1436 }
1437} 1437}
1438 1438
1439 1439
1440void KABCore::setDetailsToState() 1440void KABCore::setDetailsToState()
1441{ 1441{
1442 setDetailsVisible( mActionDetails->isChecked() ); 1442 setDetailsVisible( mActionDetails->isChecked() );
1443} 1443}
1444void KABCore::setDetailsToggle() 1444void KABCore::setDetailsToggle()
1445{ 1445{
1446 mActionDetails->setChecked( !mActionDetails->isChecked() ); 1446 mActionDetails->setChecked( !mActionDetails->isChecked() );
1447 setDetailsToState(); 1447 setDetailsToState();
1448} 1448}
1449 1449
1450 1450
1451 1451
1452void KABCore::setDetailsVisible( bool visible ) 1452void KABCore::setDetailsVisible( bool visible )
1453{ 1453{
1454 if (visible && mDetails->isHidden()) 1454 if (visible && mDetails->isHidden())
1455 { 1455 {
1456 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1456 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1457 if ( addrList.count() > 0 ) 1457 if ( addrList.count() > 0 )
1458 mDetails->setAddressee( addrList[ 0 ] ); 1458 mDetails->setAddressee( addrList[ 0 ] );
1459 } 1459 }
1460 1460
1461 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between 1461 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between
1462 // the listview and the detailview. We do that by changing the splitbar size. 1462 // the listview and the detailview. We do that by changing the splitbar size.
1463 if (mMultipleViewsAtOnce) 1463 if (mMultipleViewsAtOnce)
1464 { 1464 {
1465 if ( visible ) 1465 if ( visible )
1466 mDetails->show(); 1466 mDetails->show();
1467 else 1467 else
1468 mDetails->hide(); 1468 mDetails->hide();
1469 } 1469 }
1470 else 1470 else
1471 { 1471 {
1472 if ( visible ) { 1472 if ( visible ) {
1473 mViewManager->hide(); 1473 mViewManager->hide();
1474 mDetails->show(); 1474 mDetails->show();
1475 mIncSearchWidget->setFocus(); 1475 mIncSearchWidget->setFocus();
1476 } 1476 }
1477 else { 1477 else {
1478 mViewManager->show(); 1478 mViewManager->show();
1479 mDetails->hide(); 1479 mDetails->hide();
1480 mViewManager->setFocusAV(); 1480 mViewManager->setFocusAV();
1481 } 1481 }
1482 setJumpButtonBarVisible( !visible ); 1482 setJumpButtonBarVisible( !visible );
1483 } 1483 }
1484 1484
1485} 1485}
1486 1486
1487void KABCore::extensionChanged( int id ) 1487void KABCore::extensionChanged( int id )
1488{ 1488{
1489 //change the details view only for non desktop systems 1489 //change the details view only for non desktop systems
1490#ifndef DESKTOP_VERSION 1490#ifndef DESKTOP_VERSION
1491 1491
1492 if (id == 0) 1492 if (id == 0)
1493 { 1493 {
1494 //the user disabled the extension. 1494 //the user disabled the extension.
1495 1495
1496 if (mMultipleViewsAtOnce) 1496 if (mMultipleViewsAtOnce)
1497 { // enable detailsview again 1497 { // enable detailsview again
1498 setDetailsVisible( true ); 1498 setDetailsVisible( true );
1499 mActionDetails->setChecked( true ); 1499 mActionDetails->setChecked( true );
1500 } 1500 }
1501 else 1501 else
1502 { //go back to the listview 1502 { //go back to the listview
1503 setDetailsVisible( false ); 1503 setDetailsVisible( false );
1504 mActionDetails->setChecked( false ); 1504 mActionDetails->setChecked( false );
1505 mActionDetails->setEnabled(true); 1505 mActionDetails->setEnabled(true);
1506 } 1506 }
1507 1507
1508 } 1508 }
1509 else 1509 else
1510 { 1510 {
1511 //the user enabled the extension. 1511 //the user enabled the extension.
1512 setDetailsVisible( false ); 1512 setDetailsVisible( false );
1513 mActionDetails->setChecked( false ); 1513 mActionDetails->setChecked( false );
1514 1514
1515 if (!mMultipleViewsAtOnce) 1515 if (!mMultipleViewsAtOnce)
1516 { 1516 {
1517 mActionDetails->setEnabled(false); 1517 mActionDetails->setEnabled(false);
1518 } 1518 }
1519 1519
1520 mExtensionManager->setSelectionChanged(); 1520 mExtensionManager->setSelectionChanged();
1521 1521
1522 } 1522 }
1523 1523
1524#endif// DESKTOP_VERSION 1524#endif// DESKTOP_VERSION
1525 1525
1526} 1526}
1527 1527
1528 1528
1529void KABCore::extensionModified( const KABC::Addressee::List &list ) 1529void KABCore::extensionModified( const KABC::Addressee::List &list )
1530{ 1530{
1531 1531
1532 if ( list.count() != 0 ) { 1532 if ( list.count() != 0 ) {
1533 KABC::Addressee::List::ConstIterator it; 1533 KABC::Addressee::List::ConstIterator it;
1534 for ( it = list.begin(); it != list.end(); ++it ) 1534 for ( it = list.begin(); it != list.end(); ++it )
1535 mAddressBook->insertAddressee( *it ); 1535 mAddressBook->insertAddressee( *it );
1536 if ( list.count() > 1 ) 1536 if ( list.count() > 1 )
1537 setModified(); 1537 setModified();
1538 else 1538 else
1539 setModifiedWOrefresh(); 1539 setModifiedWOrefresh();
1540 } 1540 }
1541 if ( list.count() == 0 ) 1541 if ( list.count() == 0 )
1542 mViewManager->refreshView(); 1542 mViewManager->refreshView();
1543 else 1543 else
1544 mViewManager->refreshView( list[ 0 ].uid() ); 1544 mViewManager->refreshView( list[ 0 ].uid() );
1545 1545
1546 1546
1547 1547
1548} 1548}
1549 1549
1550QString KABCore::getNameByPhone( const QString &phone ) 1550QString KABCore::getNameByPhone( const QString &phone )
1551{ 1551{
1552#ifndef KAB_EMBEDDED 1552#ifndef KAB_EMBEDDED
1553 QRegExp r( "[/*/-/ ]" ); 1553 QRegExp r( "[/*/-/ ]" );
1554 QString localPhone( phone ); 1554 QString localPhone( phone );
1555 1555
1556 bool found = false; 1556 bool found = false;
1557 QString ownerName = ""; 1557 QString ownerName = "";
1558 KABC::AddressBook::Iterator iter; 1558 KABC::AddressBook::Iterator iter;
1559 KABC::PhoneNumber::List::Iterator phoneIter; 1559 KABC::PhoneNumber::List::Iterator phoneIter;
1560 KABC::PhoneNumber::List phoneList; 1560 KABC::PhoneNumber::List phoneList;
1561 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { 1561 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) {
1562 phoneList = (*iter).phoneNumbers(); 1562 phoneList = (*iter).phoneNumbers();
1563 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); 1563 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() );
1564 ++phoneIter) { 1564 ++phoneIter) {
1565 // Get rid of separator chars so just the numbers are compared. 1565 // Get rid of separator chars so just the numbers are compared.
1566 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { 1566 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) {
1567 ownerName = (*iter).formattedName(); 1567 ownerName = (*iter).formattedName();
1568 found = true; 1568 found = true;
1569 } 1569 }
1570 } 1570 }
1571 } 1571 }
1572 1572
1573 return ownerName; 1573 return ownerName;
1574#else //KAB_EMBEDDED 1574#else //KAB_EMBEDDED
1575 qDebug("KABCore::getNameByPhone finsih method"); 1575 qDebug("KABCore::getNameByPhone finsih method");
1576 return ""; 1576 return "";
1577#endif //KAB_EMBEDDED 1577#endif //KAB_EMBEDDED
1578 1578
1579} 1579}
1580 1580
1581void KABCore::openConfigDialog() 1581void KABCore::openConfigDialog()
1582{ 1582{
1583 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); 1583 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true );
1584 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); 1584 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" );
1585 ConfigureDialog->addModule(kabcfg ); 1585 ConfigureDialog->addModule(kabcfg );
1586 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); 1586 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" );
1587 ConfigureDialog->addModule(kdelibcfg ); 1587 ConfigureDialog->addModule(kdelibcfg );
1588 1588
1589 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1589 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1590 this, SLOT( configurationChanged() ) ); 1590 this, SLOT( configurationChanged() ) );
1591 connect( ConfigureDialog, SIGNAL( okClicked() ), 1591 connect( ConfigureDialog, SIGNAL( okClicked() ),
1592 this, SLOT( configurationChanged() ) ); 1592 this, SLOT( configurationChanged() ) );
1593 saveSettings(); 1593 saveSettings();
1594#ifndef DESKTOP_VERSION 1594#ifndef DESKTOP_VERSION
1595 ConfigureDialog->showMaximized(); 1595 ConfigureDialog->showMaximized();
1596#endif 1596#endif
1597 if ( ConfigureDialog->exec() ) 1597 if ( ConfigureDialog->exec() )
1598 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); 1598 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") );
1599 delete ConfigureDialog; 1599 delete ConfigureDialog;
1600} 1600}
1601 1601
1602void KABCore::openLDAPDialog() 1602void KABCore::openLDAPDialog()
1603{ 1603{
1604#ifndef KAB_EMBEDDED 1604#ifndef KAB_EMBEDDED
1605 if ( !mLdapSearchDialog ) { 1605 if ( !mLdapSearchDialog ) {
1606 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); 1606 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this );
1607 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, 1607 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager,
1608 SLOT( refreshView() ) ); 1608 SLOT( refreshView() ) );
1609 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, 1609 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this,
1610 SLOT( setModified() ) ); 1610 SLOT( setModified() ) );
1611 } else 1611 } else
1612 mLdapSearchDialog->restoreSettings(); 1612 mLdapSearchDialog->restoreSettings();
1613 1613
1614 if ( mLdapSearchDialog->isOK() ) 1614 if ( mLdapSearchDialog->isOK() )
1615 mLdapSearchDialog->exec(); 1615 mLdapSearchDialog->exec();
1616#else //KAB_EMBEDDED 1616#else //KAB_EMBEDDED
1617 qDebug("KABCore::openLDAPDialog() finsih method"); 1617 qDebug("KABCore::openLDAPDialog() finsih method");
1618#endif //KAB_EMBEDDED 1618#endif //KAB_EMBEDDED
1619} 1619}
1620 1620
1621void KABCore::print() 1621void KABCore::print()
1622{ 1622{
1623#ifndef KAB_EMBEDDED 1623#ifndef KAB_EMBEDDED
1624 KPrinter printer; 1624 KPrinter printer;
1625 if ( !printer.setup( this ) ) 1625 if ( !printer.setup( this ) )
1626 return; 1626 return;
1627 1627
1628 KABPrinting::PrintingWizard wizard( &printer, mAddressBook, 1628 KABPrinting::PrintingWizard wizard( &printer, mAddressBook,
1629 mViewManager->selectedUids(), this ); 1629 mViewManager->selectedUids(), this );
1630 1630
1631 wizard.exec(); 1631 wizard.exec();
1632#else //KAB_EMBEDDED 1632#else //KAB_EMBEDDED
1633 qDebug("KABCore::print() finsih method"); 1633 qDebug("KABCore::print() finsih method");
1634#endif //KAB_EMBEDDED 1634#endif //KAB_EMBEDDED
1635 1635
1636} 1636}
1637 1637
1638 1638
1639void KABCore::addGUIClient( KXMLGUIClient *client ) 1639void KABCore::addGUIClient( KXMLGUIClient *client )
1640{ 1640{
1641 if ( mGUIClient ) 1641 if ( mGUIClient )
1642 mGUIClient->insertChildClient( client ); 1642 mGUIClient->insertChildClient( client );
1643 else 1643 else
1644 KMessageBox::error( this, "no KXMLGUICLient"); 1644 KMessageBox::error( this, "no KXMLGUICLient");
1645} 1645}
1646 1646
1647 1647
1648void KABCore::configurationChanged() 1648void KABCore::configurationChanged()
1649{ 1649{
1650 mExtensionManager->reconfigure(); 1650 mExtensionManager->reconfigure();
1651} 1651}
1652 1652
1653void KABCore::addressBookChanged() 1653void KABCore::addressBookChanged()
1654{ 1654{
1655/*US 1655/*US
1656 QDictIterator<AddresseeEditorDialog> it( mEditorDict ); 1656 QDictIterator<AddresseeEditorDialog> it( mEditorDict );
1657 while ( it.current() ) { 1657 while ( it.current() ) {
1658 if ( it.current()->dirty() ) { 1658 if ( it.current()->dirty() ) {
1659 QString text = i18n( "Data has been changed externally. Unsaved " 1659 QString text = i18n( "Data has been changed externally. Unsaved "
1660 "changes will be lost." ); 1660 "changes will be lost." );
1661 KMessageBox::information( this, text ); 1661 KMessageBox::information( this, text );
1662 } 1662 }
1663 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); 1663 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) );
1664 ++it; 1664 ++it;
1665 } 1665 }
1666*/ 1666*/
1667 if (mEditorDialog) 1667 if (mEditorDialog)
1668 { 1668 {
1669 if (mEditorDialog->dirty()) 1669 if (mEditorDialog->dirty())
1670 { 1670 {
1671 QString text = i18n( "Data has been changed externally. Unsaved " 1671 QString text = i18n( "Data has been changed externally. Unsaved "
1672 "changes will be lost." ); 1672 "changes will be lost." );
1673 KMessageBox::information( this, text ); 1673 KMessageBox::information( this, text );
1674 } 1674 }
1675 QString currentuid = mEditorDialog->addressee().uid(); 1675 QString currentuid = mEditorDialog->addressee().uid();
1676 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); 1676 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) );
1677 } 1677 }
1678 mViewManager->refreshView(); 1678 mViewManager->refreshView();
1679 1679
1680 1680
1681} 1681}
1682 1682
1683AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, 1683AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent,
1684 const char *name ) 1684 const char *name )
1685{ 1685{
1686 1686
1687 if ( mEditorDialog == 0 ) { 1687 if ( mEditorDialog == 0 ) {
1688 mEditorDialog = new AddresseeEditorDialog( this, parent, 1688 mEditorDialog = new AddresseeEditorDialog( this, parent,
1689 name ? name : "editorDialog" ); 1689 name ? name : "editorDialog" );
1690 1690
1691 1691
1692 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), 1692 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ),
1693 SLOT( contactModified( const KABC::Addressee& ) ) ); 1693 SLOT( contactModified( const KABC::Addressee& ) ) );
1694 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), 1694 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ),
1695 // SLOT( slotEditorDestroyed( const QString& ) ) ; 1695 // SLOT( slotEditorDestroyed( const QString& ) ) ;
1696 } 1696 }
1697 1697
1698 return mEditorDialog; 1698 return mEditorDialog;
1699} 1699}
1700 1700
1701void KABCore::slotEditorDestroyed( const QString &uid ) 1701void KABCore::slotEditorDestroyed( const QString &uid )
1702{ 1702{
1703 //mEditorDict.remove( uid ); 1703 //mEditorDict.remove( uid );
1704} 1704}
1705 1705
1706void KABCore::initGUI() 1706void KABCore::initGUI()
1707{ 1707{
1708#ifndef KAB_EMBEDDED 1708#ifndef KAB_EMBEDDED
1709 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1709 QHBoxLayout *topLayout = new QHBoxLayout( this );
1710 topLayout->setSpacing( KDialogBase::spacingHint() ); 1710 topLayout->setSpacing( KDialogBase::spacingHint() );
1711 1711
1712 mExtensionBarSplitter = new QSplitter( this ); 1712 mExtensionBarSplitter = new QSplitter( this );
1713 mExtensionBarSplitter->setOrientation( Qt::Vertical ); 1713 mExtensionBarSplitter->setOrientation( Qt::Vertical );
1714 1714
1715 mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); 1715 mDetailsSplitter = new QSplitter( mExtensionBarSplitter );
1716 1716
1717 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1717 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1718 mIncSearchWidget = new IncSearchWidget( viewSpace ); 1718 mIncSearchWidget = new IncSearchWidget( viewSpace );
1719 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1719 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1720 SLOT( incrementalSearch( const QString& ) ) ); 1720 SLOT( incrementalSearch( const QString& ) ) );
1721 1721
1722 mViewManager = new ViewManager( this, viewSpace ); 1722 mViewManager = new ViewManager( this, viewSpace );
1723 viewSpace->setStretchFactor( mViewManager, 1 ); 1723 viewSpace->setStretchFactor( mViewManager, 1 );
1724 1724
1725 mDetails = new ViewContainer( mDetailsSplitter ); 1725 mDetails = new ViewContainer( mDetailsSplitter );
1726 1726
1727 mJumpButtonBar = new JumpButtonBar( this, this ); 1727 mJumpButtonBar = new JumpButtonBar( this, this );
1728 1728
1729 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1729 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1730 1730
1731 topLayout->addWidget( mExtensionBarSplitter ); 1731 topLayout->addWidget( mExtensionBarSplitter );
1732 topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); 1732 topLayout->setStretchFactor( mExtensionBarSplitter, 100 );
1733 topLayout->addWidget( mJumpButtonBar ); 1733 topLayout->addWidget( mJumpButtonBar );
1734 topLayout->setStretchFactor( mJumpButtonBar, 1 ); 1734 topLayout->setStretchFactor( mJumpButtonBar, 1 );
1735 1735
1736 mXXPortManager = new XXPortManager( this, this ); 1736 mXXPortManager = new XXPortManager( this, this );
1737 1737
1738#else //KAB_EMBEDDED 1738#else //KAB_EMBEDDED
1739 //US initialize viewMenu before settingup viewmanager. 1739 //US initialize viewMenu before settingup viewmanager.
1740 // Viewmanager needs this menu to plugin submenues. 1740 // Viewmanager needs this menu to plugin submenues.
1741 viewMenu = new QPopupMenu( this ); 1741 viewMenu = new QPopupMenu( this );
1742 settingsMenu = new QPopupMenu( this ); 1742 settingsMenu = new QPopupMenu( this );
1743 //filterMenu = new QPopupMenu( this ); 1743 //filterMenu = new QPopupMenu( this );
1744 ImportMenu = new QPopupMenu( this ); 1744 ImportMenu = new QPopupMenu( this );
1745 ExportMenu = new QPopupMenu( this ); 1745 ExportMenu = new QPopupMenu( this );
1746 syncMenu = new QPopupMenu( this ); 1746 syncMenu = new QPopupMenu( this );
1747 changeMenu= new QPopupMenu( this ); 1747 changeMenu= new QPopupMenu( this );
1748 beamMenu= new QPopupMenu( this ); 1748 beamMenu= new QPopupMenu( this );
1749 1749
1750//US since we have no splitter for the embedded system, setup 1750//US since we have no splitter for the embedded system, setup
1751// a layout with two frames. One left and one right. 1751// a layout with two frames. One left and one right.
1752 1752
1753 QBoxLayout *topLayout; 1753 QBoxLayout *topLayout;
1754 1754
1755 // = new QHBoxLayout( this ); 1755 // = new QHBoxLayout( this );
1756// QBoxLayout *topLayout = (QBoxLayout*)layout(); 1756// QBoxLayout *topLayout = (QBoxLayout*)layout();
1757 1757
1758// QWidget *mainBox = new QWidget( this ); 1758// QWidget *mainBox = new QWidget( this );
1759// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); 1759// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox);
1760 1760
1761#ifdef DESKTOP_VERSION 1761#ifdef DESKTOP_VERSION
1762 topLayout = new QHBoxLayout( this ); 1762 topLayout = new QHBoxLayout( this );
1763 1763
1764 1764
1765 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1765 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1766 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1766 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1767 1767
1768 topLayout->addWidget(mMiniSplitter ); 1768 topLayout->addWidget(mMiniSplitter );
1769 1769
1770 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); 1770 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter );
1771 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1771 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1772 mViewManager = new ViewManager( this, mExtensionBarSplitter ); 1772 mViewManager = new ViewManager( this, mExtensionBarSplitter );
1773 mDetails = new ViewContainer( mMiniSplitter ); 1773 mDetails = new ViewContainer( mMiniSplitter );
1774 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1774 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1775#else 1775#else
1776 if ( QApplication::desktop()->width() > 480 ) { 1776 if ( QApplication::desktop()->width() > 480 ) {
1777 topLayout = new QHBoxLayout( this ); 1777 topLayout = new QHBoxLayout( this );
1778 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1778 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1779 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1779 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1780 } else { 1780 } else {
1781 1781
1782 topLayout = new QHBoxLayout( this ); 1782 topLayout = new QHBoxLayout( this );
1783 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); 1783 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this);
1784 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1784 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1785 } 1785 }
1786 1786
1787 topLayout->addWidget(mMiniSplitter ); 1787 topLayout->addWidget(mMiniSplitter );
1788 mViewManager = new ViewManager( this, mMiniSplitter ); 1788 mViewManager = new ViewManager( this, mMiniSplitter );
1789 mDetails = new ViewContainer( mMiniSplitter ); 1789 mDetails = new ViewContainer( mMiniSplitter );
1790 1790
1791 1791
1792 mExtensionManager = new ExtensionManager( this, mMiniSplitter ); 1792 mExtensionManager = new ExtensionManager( this, mMiniSplitter );
1793#endif 1793#endif
1794 //eh->hide(); 1794 //eh->hide();
1795 // topLayout->addWidget(mExtensionManager ); 1795 // topLayout->addWidget(mExtensionManager );
1796 1796
1797 1797
1798/*US 1798/*US
1799#ifndef KAB_NOSPLITTER 1799#ifndef KAB_NOSPLITTER
1800 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1800 QHBoxLayout *topLayout = new QHBoxLayout( this );
1801//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1801//US topLayout->setSpacing( KDialogBase::spacingHint() );
1802 topLayout->setSpacing( 10 ); 1802 topLayout->setSpacing( 10 );
1803 1803
1804 mDetailsSplitter = new QSplitter( this ); 1804 mDetailsSplitter = new QSplitter( this );
1805 1805
1806 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1806 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1807 1807
1808 mViewManager = new ViewManager( this, viewSpace ); 1808 mViewManager = new ViewManager( this, viewSpace );
1809 viewSpace->setStretchFactor( mViewManager, 1 ); 1809 viewSpace->setStretchFactor( mViewManager, 1 );
1810 1810
1811 mDetails = new ViewContainer( mDetailsSplitter ); 1811 mDetails = new ViewContainer( mDetailsSplitter );
1812 1812
1813 topLayout->addWidget( mDetailsSplitter ); 1813 topLayout->addWidget( mDetailsSplitter );
1814 topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1814 topLayout->setStretchFactor( mDetailsSplitter, 100 );
1815#else //KAB_NOSPLITTER 1815#else //KAB_NOSPLITTER
1816 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1816 QHBoxLayout *topLayout = new QHBoxLayout( this );
1817//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1817//US topLayout->setSpacing( KDialogBase::spacingHint() );
1818 topLayout->setSpacing( 10 ); 1818 topLayout->setSpacing( 10 );
1819 1819
1820// mDetailsSplitter = new QSplitter( this ); 1820// mDetailsSplitter = new QSplitter( this );
1821 1821
1822 QVBox *viewSpace = new QVBox( this ); 1822 QVBox *viewSpace = new QVBox( this );
1823 1823
1824 mViewManager = new ViewManager( this, viewSpace ); 1824 mViewManager = new ViewManager( this, viewSpace );
1825 viewSpace->setStretchFactor( mViewManager, 1 ); 1825 viewSpace->setStretchFactor( mViewManager, 1 );
1826 1826
1827 mDetails = new ViewContainer( this ); 1827 mDetails = new ViewContainer( this );
1828 1828
1829 topLayout->addWidget( viewSpace ); 1829 topLayout->addWidget( viewSpace );
1830// topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1830// topLayout->setStretchFactor( mDetailsSplitter, 100 );
1831 topLayout->addWidget( mDetails ); 1831 topLayout->addWidget( mDetails );
1832#endif //KAB_NOSPLITTER 1832#endif //KAB_NOSPLITTER
1833*/ 1833*/
1834 1834
1835 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 1835 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
1836 syncManager->setBlockSave(false); 1836 syncManager->setBlockSave(false);
1837 1837
1838 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 1838 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
1839 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 1839 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
1840 QString sync_file = sentSyncFile(); 1840 QString sync_file = sentSyncFile();
1841 qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1()); 1841 qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1());
1842 syncManager->setDefaultFileName( sync_file ); 1842 syncManager->setDefaultFileName( sync_file );
1843 //connect(syncManager , SIGNAL( ), this, SLOT( ) ); 1843 //connect(syncManager , SIGNAL( ), this, SLOT( ) );
1844 1844
1845#endif //KAB_EMBEDDED 1845#endif //KAB_EMBEDDED
1846 initActions(); 1846 initActions();
1847 1847
1848#ifdef KAB_EMBEDDED 1848#ifdef KAB_EMBEDDED
1849 addActionsManually(); 1849 addActionsManually();
1850 //US make sure the export and import menues are initialized before creating the xxPortManager. 1850 //US make sure the export and import menues are initialized before creating the xxPortManager.
1851 mXXPortManager = new XXPortManager( this, this ); 1851 mXXPortManager = new XXPortManager( this, this );
1852 1852
1853 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); 1853 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() );
1854 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); 1854 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget);
1855 // mActionQuit->plug ( mMainWindow->toolBar()); 1855 // mActionQuit->plug ( mMainWindow->toolBar());
1856 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); 1856 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() );
1857 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); 1857 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget);
1858 // mIncSearchWidget->hide(); 1858 // mIncSearchWidget->hide();
1859 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1859 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1860 SLOT( incrementalSearch( const QString& ) ) ); 1860 SLOT( incrementalSearch( const QString& ) ) );
1861 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); 1861 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) );
1862 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); 1862 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) );
1863 1863
1864 mJumpButtonBar = new JumpButtonBar( this, this ); 1864 mJumpButtonBar = new JumpButtonBar( this, this );
1865 1865
1866 topLayout->addWidget( mJumpButtonBar ); 1866 topLayout->addWidget( mJumpButtonBar );
1867//US topLayout->setStretchFactor( mJumpButtonBar, 10 ); 1867//US topLayout->setStretchFactor( mJumpButtonBar, 10 );
1868 1868
1869// mMainWindow->getIconToolBar()->raise(); 1869// mMainWindow->getIconToolBar()->raise();
1870 1870
1871#endif //KAB_EMBEDDED 1871#endif //KAB_EMBEDDED
1872 1872
1873} 1873}
1874void KABCore::initActions() 1874void KABCore::initActions()
1875{ 1875{
1876//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1876//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1877 1877
1878#ifndef KAB_EMBEDDED 1878#ifndef KAB_EMBEDDED
1879 connect( QApplication::clipboard(), SIGNAL( dataChanged() ), 1879 connect( QApplication::clipboard(), SIGNAL( dataChanged() ),
1880 SLOT( clipboardDataChanged() ) ); 1880 SLOT( clipboardDataChanged() ) );
1881#endif //KAB_EMBEDDED 1881#endif //KAB_EMBEDDED
1882 1882
1883 // file menu 1883 // file menu
1884 1884
1885 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); 1885 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() );
1886 //mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); 1886 //mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() );
1887 mActionPrint = new KAction( i18n( "&Print View" ), "fileprint", CTRL + Key_P, mViewManager, 1887 mActionPrint = new KAction( i18n( "&Print View" ), "fileprint", CTRL + Key_P, mViewManager,
1888 SLOT( printView() ), actionCollection(), "kaddressbook_print" ); 1888 SLOT( printView() ), actionCollection(), "kaddressbook_print" );
1889 1889
1890 1890
1891 mActionPrintDetails = new KAction( i18n( "&Print Details" ), "fileprint", 0, mDetails, 1891 mActionPrintDetails = new KAction( i18n( "&Print Details" ), "fileprint", 0, mDetails,
1892 SLOT( printView() ), actionCollection(), "kaddressbook_print2" ); 1892 SLOT( printView() ), actionCollection(), "kaddressbook_print2" );
1893 1893
1894 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, 1894 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this,
1895 SLOT( save() ), actionCollection(), "file_sync" ); 1895 SLOT( save() ), actionCollection(), "file_sync" );
1896 1896
1897 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, 1897 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this,
1898 SLOT( newContact() ), actionCollection(), "file_new_contact" ); 1898 SLOT( newContact() ), actionCollection(), "file_new_contact" );
1899 1899
1900 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, 1900 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0,
1901 this, SLOT( mailVCard() ), 1901 this, SLOT( mailVCard() ),
1902 actionCollection(), "file_mail_vcard"); 1902 actionCollection(), "file_mail_vcard");
1903 1903
1904 mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this, 1904 mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this,
1905 SLOT( export2phone() ), actionCollection(), 1905 SLOT( export2phone() ), actionCollection(),
1906 "kaddressbook_ex2phone" ); 1906 "kaddressbook_ex2phone" );
1907 1907
1908 mActionBeamVCard = 0; 1908 mActionBeamVCard = 0;
1909 mActionBeam = 0; 1909 mActionBeam = 0;
1910 1910
1911#ifndef DESKTOP_VERSION 1911#ifndef DESKTOP_VERSION
1912 if ( Ir::supported() ) { 1912 if ( Ir::supported() ) {
1913 mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this, 1913 mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this,
1914 SLOT( beamVCard() ), actionCollection(), 1914 SLOT( beamVCard() ), actionCollection(),
1915 "kaddressbook_beam_vcard" ); 1915 "kaddressbook_beam_vcard" );
1916 1916
1917 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, 1917 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this,
1918 SLOT( beamMySelf() ), actionCollection(), 1918 SLOT( beamMySelf() ), actionCollection(),
1919 "kaddressbook_beam_myself" ); 1919 "kaddressbook_beam_myself" );
1920 } 1920 }
1921#endif 1921#endif
1922 1922
1923 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, 1923 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0,
1924 this, SLOT( editContact2() ), 1924 this, SLOT( editContact2() ),
1925 actionCollection(), "file_properties" ); 1925 actionCollection(), "file_properties" );
1926 1926
1927#ifdef KAB_EMBEDDED 1927#ifdef KAB_EMBEDDED
1928 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); 1928 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() );
1929 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, 1929 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0,
1930 mMainWindow, SLOT( exit() ), 1930 mMainWindow, SLOT( exit() ),
1931 actionCollection(), "quit" ); 1931 actionCollection(), "quit" );
1932#endif //KAB_EMBEDDED 1932#endif //KAB_EMBEDDED
1933 1933
1934 // edit menu 1934 // edit menu
1935 if ( mIsPart ) { 1935 if ( mIsPart ) {
1936 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, 1936 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this,
1937 SLOT( copyContacts() ), actionCollection(), 1937 SLOT( copyContacts() ), actionCollection(),
1938 "kaddressbook_copy" ); 1938 "kaddressbook_copy" );
1939 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, 1939 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this,
1940 SLOT( cutContacts() ), actionCollection(), 1940 SLOT( cutContacts() ), actionCollection(),
1941 "kaddressbook_cut" ); 1941 "kaddressbook_cut" );
1942 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, 1942 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this,
1943 SLOT( pasteContacts() ), actionCollection(), 1943 SLOT( pasteContacts() ), actionCollection(),
1944 "kaddressbook_paste" ); 1944 "kaddressbook_paste" );
1945 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, 1945 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this,
1946 SLOT( selectAllContacts() ), actionCollection(), 1946 SLOT( selectAllContacts() ), actionCollection(),
1947 "kaddressbook_select_all" ); 1947 "kaddressbook_select_all" );
1948 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, 1948 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this,
1949 SLOT( undo() ), actionCollection(), 1949 SLOT( undo() ), actionCollection(),
1950 "kaddressbook_undo" ); 1950 "kaddressbook_undo" );
1951 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, 1951 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z,
1952 this, SLOT( redo() ), actionCollection(), 1952 this, SLOT( redo() ), actionCollection(),
1953 "kaddressbook_redo" ); 1953 "kaddressbook_redo" );
1954 } else { 1954 } else {
1955 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); 1955 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() );
1956 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); 1956 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() );
1957 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); 1957 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() );
1958 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); 1958 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() );
1959 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); 1959 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() );
1960 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); 1960 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() );
1961 } 1961 }
1962 1962
1963 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", 1963 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete",
1964 Key_Delete, this, SLOT( deleteContacts() ), 1964 Key_Delete, this, SLOT( deleteContacts() ),
1965 actionCollection(), "edit_delete" ); 1965 actionCollection(), "edit_delete" );
1966 1966
1967 mActionUndo->setEnabled( false ); 1967 mActionUndo->setEnabled( false );
1968 mActionRedo->setEnabled( false ); 1968 mActionRedo->setEnabled( false );
1969 1969
1970 // settings menu 1970 // settings menu
1971#ifdef KAB_EMBEDDED 1971#ifdef KAB_EMBEDDED
1972//US special menuentry to configure the addressbook resources. On KDE 1972//US special menuentry to configure the addressbook resources. On KDE
1973// you do that through the control center !!! 1973// you do that through the control center !!!
1974 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, 1974 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this,
1975 SLOT( configureResources() ), actionCollection(), 1975 SLOT( configureResources() ), actionCollection(),
1976 "kaddressbook_configure_resources" ); 1976 "kaddressbook_configure_resources" );
1977#endif //KAB_EMBEDDED 1977#endif //KAB_EMBEDDED
1978 1978
1979 if ( mIsPart ) { 1979 if ( mIsPart ) {
1980 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, 1980 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this,
1981 SLOT( openConfigDialog() ), actionCollection(), 1981 SLOT( openConfigDialog() ), actionCollection(),
1982 "kaddressbook_configure" ); 1982 "kaddressbook_configure" );
1983 1983
1984 //US not implemented yet 1984 //US not implemented yet
1985 //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, 1985 //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0,
1986 // this, SLOT( configureKeyBindings() ), actionCollection(), 1986 // this, SLOT( configureKeyBindings() ), actionCollection(),
1987 // "kaddressbook_configure_shortcuts" ); 1987 // "kaddressbook_configure_shortcuts" );
1988#ifdef KAB_EMBEDDED 1988#ifdef KAB_EMBEDDED
1989 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); 1989 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() );
1990 mActionConfigureToolbars->setEnabled( false ); 1990 mActionConfigureToolbars->setEnabled( false );
1991#endif //KAB_EMBEDDED 1991#endif //KAB_EMBEDDED
1992 1992
1993 } else { 1993 } else {
1994 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); 1994 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() );
1995 1995
1996 //US not implemented yet 1996 //US not implemented yet
1997 //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); 1997 //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() );
1998 } 1998 }
1999 1999
2000 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, 2000 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0,
2001 actionCollection(), "options_show_jump_bar" ); 2001 actionCollection(), "options_show_jump_bar" );
2002 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); 2002 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) );
2003 2003
2004 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, 2004 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0,
2005 actionCollection(), "options_show_details" ); 2005 actionCollection(), "options_show_details" );
2006 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); 2006 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) );
2007 2007
2008 2008
2009 mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, 2009 mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this,
2010 SLOT( toggleBeamReceive() ), actionCollection(), 2010 SLOT( toggleBeamReceive() ), actionCollection(),
2011 "kaddressbook_beam_rec" ); 2011 "kaddressbook_beam_rec" );
2012 2012
2013 2013
2014 // misc 2014 // misc
2015 // only enable LDAP lookup if we can handle the protocol 2015 // only enable LDAP lookup if we can handle the protocol
2016#ifndef KAB_EMBEDDED 2016#ifndef KAB_EMBEDDED
2017 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { 2017 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) {
2018 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, 2018 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0,
2019 this, SLOT( openLDAPDialog() ), actionCollection(), 2019 this, SLOT( openLDAPDialog() ), actionCollection(),
2020 "ldap_lookup" ); 2020 "ldap_lookup" );
2021 } 2021 }
2022#else //KAB_EMBEDDED 2022#else //KAB_EMBEDDED
2023 //qDebug("KABCore::initActions() LDAP has to be implemented"); 2023 //qDebug("KABCore::initActions() LDAP has to be implemented");
2024#endif //KAB_EMBEDDED 2024#endif //KAB_EMBEDDED
2025 2025
2026 2026
2027 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, 2027 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this,
2028 SLOT( setWhoAmI() ), actionCollection(), 2028 SLOT( setWhoAmI() ), actionCollection(),
2029 "set_personal" ); 2029 "set_personal" );
2030 2030
2031 2031
2032 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, 2032 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this,
2033 SLOT( setCategories() ), actionCollection(), 2033 SLOT( setCategories() ), actionCollection(),
2034 "edit_set_categories" ); 2034 "edit_set_categories" );
2035 mActionEditCategories = new KAction( i18n( "Edit Categories" ), 0, this, 2035 mActionEditCategories = new KAction( i18n( "Edit Categories" ), 0, this,
2036 SLOT( editCategories() ), actionCollection(), 2036 SLOT( editCategories() ), actionCollection(),
2037 "edit__categories" ); 2037 "edit__categories" );
2038 2038
2039 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, 2039 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this,
2040 SLOT( removeVoice() ), actionCollection(), 2040 SLOT( removeVoice() ), actionCollection(),
2041 "remove_voice" ); 2041 "remove_voice" );
2042 mActionSetFormattedName = new KAction( i18n( "Set formatted name..." ), 0, this, 2042 mActionSetFormattedName = new KAction( i18n( "Set formatted name..." ), 0, this,
2043 SLOT( setFormattedName() ), actionCollection(), 2043 SLOT( setFormattedName() ), actionCollection(),
2044 "set_formatted" ); 2044 "set_formatted" );
2045 2045
2046 mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this, 2046 mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this,
2047 SLOT( manageCategories() ), actionCollection(), 2047 SLOT( manageCategories() ), actionCollection(),
2048 "remove_voice" ); 2048 "remove_voice" );
2049 2049
2050 2050
2051 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, 2051 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this,
2052 SLOT( importFromOL() ), actionCollection(), 2052 SLOT( importFromOL() ), actionCollection(),
2053 "import_OL" ); 2053 "import_OL" );
2054#ifdef KAB_EMBEDDED 2054#ifdef KAB_EMBEDDED
2055 mActionLicence = new KAction( i18n( "Licence" ), 0, 2055 mActionLicence = new KAction( i18n( "Licence" ), 0,
2056 this, SLOT( showLicence() ), actionCollection(), 2056 this, SLOT( showLicence() ), actionCollection(),
2057 "licence_about_data" ); 2057 "licence_about_data" );
2058 mActionFaq = new KAction( i18n( "Faq" ), 0, 2058 mActionFaq = new KAction( i18n( "Faq" ), 0,
2059 this, SLOT( faq() ), actionCollection(), 2059 this, SLOT( faq() ), actionCollection(),
2060 "faq_about_data" ); 2060 "faq_about_data" );
2061 mActionWN = new KAction( i18n( "What's New?" ), 0, 2061 mActionWN = new KAction( i18n( "What's New?" ), 0,
2062 this, SLOT( whatsnew() ), actionCollection(), 2062 this, SLOT( whatsnew() ), actionCollection(),
2063 "wn" ); 2063 "wn" );
2064 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, 2064 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0,
2065 this, SLOT( synchowto() ), actionCollection(), 2065 this, SLOT( synchowto() ), actionCollection(),
2066 "sync" ); 2066 "sync" );
2067 mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, 2067 mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0,
2068 this, SLOT( kdesynchowto() ), actionCollection(), 2068 this, SLOT( kdesynchowto() ), actionCollection(),
2069 "kdesync" ); 2069 "kdesync" );
2070 mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, 2070 mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0,
2071 this, SLOT( multisynchowto() ), actionCollection(), 2071 this, SLOT( multisynchowto() ), actionCollection(),
2072 "multisync" ); 2072 "multisync" );
2073 2073
2074 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, 2074 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0,
2075 this, SLOT( createAboutData() ), actionCollection(), 2075 this, SLOT( createAboutData() ), actionCollection(),
2076 "kaddressbook_about_data" ); 2076 "kaddressbook_about_data" );
2077#endif //KAB_EMBEDDED 2077#endif //KAB_EMBEDDED
2078 2078
2079 clipboardDataChanged(); 2079 clipboardDataChanged();
2080 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 2080 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
2081 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 2081 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
2082} 2082}
2083 2083
2084//US we need this function, to plug all actions into the correct menues. 2084//US we need this function, to plug all actions into the correct menues.
2085// KDE uses a XML format to plug the actions, but we work her without this overhead. 2085// KDE uses a XML format to plug the actions, but we work her without this overhead.
2086void KABCore::addActionsManually() 2086void KABCore::addActionsManually()
2087{ 2087{
2088//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 2088//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
2089 2089
2090#ifdef KAB_EMBEDDED 2090#ifdef KAB_EMBEDDED
2091 QPopupMenu *fileMenu = new QPopupMenu( this ); 2091 QPopupMenu *fileMenu = new QPopupMenu( this );
2092 QPopupMenu *editMenu = new QPopupMenu( this ); 2092 QPopupMenu *editMenu = new QPopupMenu( this );
2093 QPopupMenu *helpMenu = new QPopupMenu( this ); 2093 QPopupMenu *helpMenu = new QPopupMenu( this );
2094 2094
2095 KToolBar* tb = mMainWindow->toolBar(); 2095 KToolBar* tb = mMainWindow->toolBar();
2096 2096
2097#ifndef DESKTOP_VERSION 2097#ifndef DESKTOP_VERSION
2098 if ( KABPrefs::instance()->mFullMenuBarVisible ) { 2098 if ( KABPrefs::instance()->mFullMenuBarVisible ) {
2099#endif 2099#endif
2100 QMenuBar* mb = mMainWindow->menuBar(); 2100 QMenuBar* mb = mMainWindow->menuBar();
2101 2101
2102 //US setup menubar. 2102 //US setup menubar.
2103 //Disable the following block if you do not want to have a menubar. 2103 //Disable the following block if you do not want to have a menubar.
2104 mb->insertItem( i18n("&File"), fileMenu ); 2104 mb->insertItem( i18n("&File"), fileMenu );
2105 mb->insertItem( i18n("&Edit"), editMenu ); 2105 mb->insertItem( i18n("&Edit"), editMenu );
2106 mb->insertItem( i18n("&View"), viewMenu ); 2106 mb->insertItem( i18n("&View"), viewMenu );
2107 mb->insertItem( i18n("&Settings"), settingsMenu ); 2107 mb->insertItem( i18n("&Settings"), settingsMenu );
2108 mb->insertItem( i18n("Synchronize"), syncMenu ); 2108 mb->insertItem( i18n("Synchronize"), syncMenu );
2109 //mb->insertItem( i18n("&Change"), changeMenu ); 2109 //mb->insertItem( i18n("&Change"), changeMenu );
2110 mb->insertItem( i18n("&Help"), helpMenu ); 2110 mb->insertItem( i18n("&Help"), helpMenu );
2111 mIncSearchWidget = new IncSearchWidget( tb ); 2111 mIncSearchWidget = new IncSearchWidget( tb );
2112 // tb->insertWidget(-1, 0, mIncSearchWidget); 2112 // tb->insertWidget(-1, 0, mIncSearchWidget);
2113#ifndef DESKTOP_VERSION 2113#ifndef DESKTOP_VERSION
2114 } else { 2114 } else {
2115 //US setup toolbar 2115 //US setup toolbar
2116 QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); 2116 QPEMenuBar *menuBarTB = new QPEMenuBar( tb );
2117 QPopupMenu *popupBarTB = new QPopupMenu( this ); 2117 QPopupMenu *popupBarTB = new QPopupMenu( this );
2118 menuBarTB->insertItem( "ME", popupBarTB); 2118 menuBarTB->insertItem( "ME", popupBarTB);
2119 tb->insertWidget(-1, 0, menuBarTB); 2119 tb->insertWidget(-1, 0, menuBarTB);
2120 mIncSearchWidget = new IncSearchWidget( tb ); 2120 mIncSearchWidget = new IncSearchWidget( tb );
2121 2121
2122 tb->enableMoving(false); 2122 tb->enableMoving(false);
2123 popupBarTB->insertItem( i18n("&File"), fileMenu ); 2123 popupBarTB->insertItem( i18n("&File"), fileMenu );
2124 popupBarTB->insertItem( i18n("&Edit"), editMenu ); 2124 popupBarTB->insertItem( i18n("&Edit"), editMenu );
2125 popupBarTB->insertItem( i18n("&View"), viewMenu ); 2125 popupBarTB->insertItem( i18n("&View"), viewMenu );
2126 popupBarTB->insertItem( i18n("&Settings"), settingsMenu ); 2126 popupBarTB->insertItem( i18n("&Settings"), settingsMenu );
2127 popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); 2127 popupBarTB->insertItem( i18n("Synchronize"), syncMenu );
2128 mViewManager->getFilterAction()->plug ( popupBarTB); 2128 mViewManager->getFilterAction()->plug ( popupBarTB);
2129 //popupBarTB->insertItem( i18n("&Change selected"), changeMenu ); 2129 //popupBarTB->insertItem( i18n("&Change selected"), changeMenu );
2130 popupBarTB->insertItem( i18n("&Help"), helpMenu ); 2130 popupBarTB->insertItem( i18n("&Help"), helpMenu );
2131 if (QApplication::desktop()->width() > 320 ) { 2131 if (QApplication::desktop()->width() > 320 ) {
2132 // mViewManager->getFilterAction()->plug ( tb); 2132 // mViewManager->getFilterAction()->plug ( tb);
2133 } 2133 }
2134 } 2134 }
2135#endif 2135#endif
2136 // mActionQuit->plug ( mMainWindow->toolBar()); 2136 // mActionQuit->plug ( mMainWindow->toolBar());
2137 2137
2138 2138
2139 2139
2140 //US Now connect the actions with the menue entries. 2140 //US Now connect the actions with the menue entries.
2141#ifdef DESKTOP_VERSION 2141#ifdef DESKTOP_VERSION
2142 mActionPrint->plug( fileMenu ); 2142 mActionPrint->plug( fileMenu );
2143 mActionPrintDetails->plug( fileMenu ); 2143 mActionPrintDetails->plug( fileMenu );
2144 fileMenu->insertSeparator(); 2144 fileMenu->insertSeparator();
2145#endif 2145#endif
2146 mActionMail->plug( fileMenu ); 2146 mActionMail->plug( fileMenu );
2147 fileMenu->insertSeparator(); 2147 fileMenu->insertSeparator();
2148 2148
2149 mActionNewContact->plug( fileMenu ); 2149 mActionNewContact->plug( fileMenu );
2150 mActionNewContact->plug( tb ); 2150 mActionNewContact->plug( tb );
2151 2151
2152 mActionEditAddressee->plug( fileMenu ); 2152 mActionEditAddressee->plug( fileMenu );
2153 // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || 2153 // if ((KGlobal::getDesktopSize() > KGlobal::Small ) ||
2154 // (!KABPrefs::instance()->mMultipleViewsAtOnce )) 2154 // (!KABPrefs::instance()->mMultipleViewsAtOnce ))
2155 mActionEditAddressee->plug( tb ); 2155 mActionEditAddressee->plug( tb );
2156 2156
2157 fileMenu->insertSeparator(); 2157 fileMenu->insertSeparator();
2158 mActionSave->plug( fileMenu ); 2158 mActionSave->plug( fileMenu );
2159 fileMenu->insertItem( "&Import", ImportMenu ); 2159 fileMenu->insertItem( "&Import", ImportMenu );
2160 fileMenu->insertItem( "&Export", ExportMenu ); 2160 fileMenu->insertItem( "&Export", ExportMenu );
2161 fileMenu->insertItem( i18n("&Change"), changeMenu ); 2161 fileMenu->insertItem( i18n("&Change"), changeMenu );
2162#ifndef DESKTOP_VERSION 2162#ifndef DESKTOP_VERSION
2163 if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu ); 2163 if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu );
2164#endif 2164#endif
2165#if 0 2165#if 0
2166 // PENDING fix MailVCard 2166 // PENDING fix MailVCard
2167 fileMenu->insertSeparator(); 2167 fileMenu->insertSeparator();
2168 mActionMailVCard->plug( fileMenu ); 2168 mActionMailVCard->plug( fileMenu );
2169#endif 2169#endif
2170#ifndef DESKTOP_VERSION 2170#ifndef DESKTOP_VERSION
2171 if ( Ir::supported() ) mActionBR->plug( beamMenu ); 2171 if ( Ir::supported() ) mActionBR->plug( beamMenu );
2172 if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu ); 2172 if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu );
2173 if ( Ir::supported() ) mActionBeam->plug( beamMenu ); 2173 if ( Ir::supported() ) mActionBeam->plug( beamMenu );
2174#endif 2174#endif
2175 fileMenu->insertSeparator(); 2175 fileMenu->insertSeparator();
2176 mActionQuit->plug( fileMenu ); 2176 mActionQuit->plug( fileMenu );
2177#ifdef _WIN32_ 2177#ifdef _WIN32_
2178 mActionImportOL->plug( ImportMenu ); 2178 mActionImportOL->plug( ImportMenu );
2179#endif 2179#endif
2180 // edit menu 2180 // edit menu
2181 mActionUndo->plug( editMenu ); 2181 mActionUndo->plug( editMenu );
2182 mActionRedo->plug( editMenu ); 2182 mActionRedo->plug( editMenu );
2183 editMenu->insertSeparator(); 2183 editMenu->insertSeparator();
2184 mActionCut->plug( editMenu ); 2184 mActionCut->plug( editMenu );
2185 mActionCopy->plug( editMenu ); 2185 mActionCopy->plug( editMenu );
2186 mActionPaste->plug( editMenu ); 2186 mActionPaste->plug( editMenu );
2187 mActionDelete->plug( editMenu ); 2187 mActionDelete->plug( editMenu );
2188 editMenu->insertSeparator(); 2188 editMenu->insertSeparator();
2189 mActionSelectAll->plug( editMenu ); 2189 mActionSelectAll->plug( editMenu );
2190 2190
2191 mActionSetFormattedName->plug( changeMenu ); 2191 mActionSetFormattedName->plug( changeMenu );
2192 mActionRemoveVoice->plug( changeMenu ); 2192 mActionRemoveVoice->plug( changeMenu );
2193 // settings menu 2193 // settings menu
2194//US special menuentry to configure the addressbook resources. On KDE 2194//US special menuentry to configure the addressbook resources. On KDE
2195// you do that through the control center !!! 2195// you do that through the control center !!!
2196 mActionConfigResources->plug( settingsMenu ); 2196 mActionConfigResources->plug( settingsMenu );
2197 settingsMenu->insertSeparator(); 2197 settingsMenu->insertSeparator();
2198 2198
2199 mActionConfigKAddressbook->plug( settingsMenu ); 2199 mActionConfigKAddressbook->plug( settingsMenu );
2200 2200
2201 if ( mIsPart ) { 2201 if ( mIsPart ) {
2202 //US not implemented yet 2202 //US not implemented yet
2203 //mActionConfigShortcuts->plug( settingsMenu ); 2203 //mActionConfigShortcuts->plug( settingsMenu );
2204 //mActionConfigureToolbars->plug( settingsMenu ); 2204 //mActionConfigureToolbars->plug( settingsMenu );
2205 2205
2206 } else { 2206 } else {
2207 //US not implemented yet 2207 //US not implemented yet
2208 //mActionKeyBindings->plug( settingsMenu ); 2208 //mActionKeyBindings->plug( settingsMenu );
2209 } 2209 }
2210 2210
2211 settingsMenu->insertSeparator(); 2211 settingsMenu->insertSeparator();
2212 2212
2213 mActionJumpBar->plug( settingsMenu ); 2213 mActionJumpBar->plug( settingsMenu );
2214 mActionDetails->plug( settingsMenu ); 2214 mActionDetails->plug( settingsMenu );
2215 //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) 2215 //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop )
2216 mActionDetails->plug( tb ); 2216 mActionDetails->plug( tb );
2217 settingsMenu->insertSeparator(); 2217 settingsMenu->insertSeparator();
2218#ifndef DESKTOP_VERSION 2218#ifndef DESKTOP_VERSION
2219 if ( Ir::supported() ) mActionBR->plug(settingsMenu ); 2219 if ( Ir::supported() ) mActionBR->plug(settingsMenu );
2220#endif 2220#endif
2221 settingsMenu->insertSeparator(); 2221 settingsMenu->insertSeparator();
2222 2222
2223 mActionWhoAmI->plug( settingsMenu ); 2223 mActionWhoAmI->plug( settingsMenu );
2224 mActionEditCategories->plug( settingsMenu ); 2224 mActionEditCategories->plug( settingsMenu );
2225 mActionEditCategories->plug( changeMenu ); 2225 mActionEditCategories->plug( changeMenu );
2226 mActionCategories->plug( changeMenu ); 2226 mActionCategories->plug( changeMenu );
2227 mActionManageCategories->plug( changeMenu ); 2227 mActionManageCategories->plug( changeMenu );
2228 2228
2229 mActionCategories->plug( settingsMenu ); 2229 mActionCategories->plug( settingsMenu );
2230 mActionManageCategories->plug( settingsMenu ); 2230 mActionManageCategories->plug( settingsMenu );
2231 2231
2232 2232
2233 mActionWN->plug( helpMenu ); 2233 mActionWN->plug( helpMenu );
2234 mActionSyncHowto->plug( helpMenu ); 2234 mActionSyncHowto->plug( helpMenu );
2235 mActionKdeSyncHowto->plug( helpMenu ); 2235 mActionKdeSyncHowto->plug( helpMenu );
2236 mActionMultiSyncHowto->plug( helpMenu ); 2236 mActionMultiSyncHowto->plug( helpMenu );
2237 mActionFaq->plug( helpMenu ); 2237 mActionFaq->plug( helpMenu );
2238 mActionLicence->plug( helpMenu ); 2238 mActionLicence->plug( helpMenu );
2239 mActionAboutKAddressbook->plug( helpMenu ); 2239 mActionAboutKAddressbook->plug( helpMenu );
2240 2240
2241 if (KGlobal::getDesktopSize() > KGlobal::Small ) { 2241 if (KGlobal::getDesktopSize() > KGlobal::Small ) {
2242 2242
2243 mActionSave->plug( tb ); 2243 mActionSave->plug( tb );
2244 mViewManager->getFilterAction()->plug ( tb); 2244 mViewManager->getFilterAction()->plug ( tb);
2245 //LR hide filteraction on started in 480x640 2245 //LR hide filteraction on started in 480x640
2246 if (QApplication::desktop()->width() == 480 ) { 2246 if (QApplication::desktop()->width() == 480 ) {
2247 mViewManager->getFilterAction()->setComboWidth( 0 ); 2247 mViewManager->getFilterAction()->setComboWidth( 0 );
2248 } 2248 }
2249 mActionUndo->plug( tb ); 2249 mActionUndo->plug( tb );
2250 mActionDelete->plug( tb ); 2250 mActionDelete->plug( tb );
2251 mActionRedo->plug( tb ); 2251 mActionRedo->plug( tb );
2252 } else { 2252 } else {
2253 mActionSave->plug( tb ); 2253 mActionSave->plug( tb );
2254 tb->enableMoving(false); 2254 tb->enableMoving(false);
2255 } 2255 }
2256 //mActionQuit->plug ( tb ); 2256 //mActionQuit->plug ( tb );
2257 // tb->insertWidget(-1, 0, mIncSearchWidget, 6); 2257 // tb->insertWidget(-1, 0, mIncSearchWidget, 6);
2258 2258
2259 //US link the searchwidget first to this. 2259 //US link the searchwidget first to this.
2260 // The real linkage to the toolbar happens later. 2260 // The real linkage to the toolbar happens later.
2261//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); 2261//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE);
2262//US tb->insertItem( mIncSearchWidget ); 2262//US tb->insertItem( mIncSearchWidget );
2263/*US 2263/*US
2264 mIncSearchWidget = new IncSearchWidget( tb ); 2264 mIncSearchWidget = new IncSearchWidget( tb );
2265 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 2265 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
2266 SLOT( incrementalSearch( const QString& ) ) ); 2266 SLOT( incrementalSearch( const QString& ) ) );
2267 2267
2268 mJumpButtonBar = new JumpButtonBar( this, this ); 2268 mJumpButtonBar = new JumpButtonBar( this, this );
2269 2269
2270//US topLayout->addWidget( mJumpButtonBar ); 2270//US topLayout->addWidget( mJumpButtonBar );
2271 this->layout()->add( mJumpButtonBar ); 2271 this->layout()->add( mJumpButtonBar );
2272*/ 2272*/
2273 2273
2274#endif //KAB_EMBEDDED 2274#endif //KAB_EMBEDDED
2275 2275
2276 mActionExport2phone->plug( ExportMenu ); 2276 mActionExport2phone->plug( ExportMenu );
2277 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); 2277 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) );
2278 syncManager->fillSyncMenu(); 2278 syncManager->fillSyncMenu();
2279 2279
2280} 2280}
2281void KABCore::showLicence() 2281void KABCore::showLicence()
2282{ 2282{
2283 KApplication::showLicence(); 2283 KApplication::showLicence();
2284} 2284}
2285 2285
2286void KABCore::manageCategories( ) 2286void KABCore::manageCategories( )
2287{ 2287{
2288 KABCatPrefs* cp = new KABCatPrefs(); 2288 KABCatPrefs* cp = new KABCatPrefs();
2289 cp->show(); 2289 cp->show();
2290 int w =cp->sizeHint().width() ; 2290 int w =cp->sizeHint().width() ;
2291 int h = cp->sizeHint().height() ; 2291 int h = cp->sizeHint().height() ;
2292 int dw = QApplication::desktop()->width(); 2292 int dw = QApplication::desktop()->width();
2293 int dh = QApplication::desktop()->height(); 2293 int dh = QApplication::desktop()->height();
2294 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2294 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2295 if ( !cp->exec() ) { 2295 if ( !cp->exec() ) {
2296 delete cp; 2296 delete cp;
2297 return; 2297 return;
2298 } 2298 }
2299 int count = 0; 2299 int count = 0;
2300 int cc = 0; 2300 int cc = 0;
2301 message( i18n("Please wait, processing categories...")); 2301 message( i18n("Please wait, processing categories..."));
2302 if ( cp->addCat() ) { 2302 if ( cp->addCat() ) {
2303 KABC::AddressBook::Iterator it; 2303 KABC::AddressBook::Iterator it;
2304 QStringList catList = KABPrefs::instance()->mCustomCategories; 2304 QStringList catList = KABPrefs::instance()->mCustomCategories;
2305 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2305 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2306 ++cc; 2306 ++cc;
2307 if ( cc %10 == 0) 2307 if ( cc %10 == 0)
2308 message(i18n("Processing contact #%1").arg(cc)); 2308 message(i18n("Processing contact #%1").arg(cc));
2309 QStringList catIncList = (*it).categories(); 2309 QStringList catIncList = (*it).categories();
2310 int i; 2310 int i;
2311 for( i = 0; i< catIncList.count(); ++i ) { 2311 for( i = 0; i< catIncList.count(); ++i ) {
2312 if ( !catList.contains (catIncList[i])) { 2312 if ( !catList.contains (catIncList[i])) {
2313 catList.append( catIncList[i] ); 2313 catList.append( catIncList[i] );
2314 //qDebug("add cat %s ", catIncList[i].latin1()); 2314 //qDebug("add cat %s ", catIncList[i].latin1());
2315 ++count; 2315 ++count;
2316 } 2316 }
2317 } 2317 }
2318 } 2318 }
2319 catList.sort(); 2319 catList.sort();
2320 KABPrefs::instance()->mCustomCategories = catList; 2320 KABPrefs::instance()->mCustomCategories = catList;
2321 KABPrefs::instance()->writeConfig(); 2321 KABPrefs::instance()->writeConfig();
2322 message(QString::number( count )+ i18n(" categories added to list! ")); 2322 message(QString::number( count )+ i18n(" categories added to list! "));
2323 } else { 2323 } else {
2324 QStringList catList = KABPrefs::instance()->mCustomCategories; 2324 QStringList catList = KABPrefs::instance()->mCustomCategories;
2325 QStringList catIncList; 2325 QStringList catIncList;
2326 QStringList newCatList; 2326 QStringList newCatList;
2327 KABC::AddressBook::Iterator it; 2327 KABC::AddressBook::Iterator it;
2328 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2328 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2329 ++cc; 2329 ++cc;
2330 if ( cc %10 == 0) 2330 if ( cc %10 == 0)
2331 message(i18n("Processing contact #%1").arg(cc)); 2331 message(i18n("Processing contact #%1").arg(cc));
2332 QStringList catIncList = (*it).categories(); 2332 QStringList catIncList = (*it).categories();
2333 int i; 2333 int i;
2334 if ( catIncList.count() ) { 2334 if ( catIncList.count() ) {
2335 newCatList.clear(); 2335 newCatList.clear();
2336 for( i = 0; i< catIncList.count(); ++i ) { 2336 for( i = 0; i< catIncList.count(); ++i ) {
2337 if ( catList.contains (catIncList[i])) { 2337 if ( catList.contains (catIncList[i])) {
2338 newCatList.append( catIncList[i] ); 2338 newCatList.append( catIncList[i] );
2339 } 2339 }
2340 } 2340 }
2341 newCatList.sort(); 2341 newCatList.sort();
2342 (*it).setCategories( newCatList ); 2342 (*it).setCategories( newCatList );
2343 mAddressBook->insertAddressee( (*it) ); 2343 mAddressBook->insertAddressee( (*it) );
2344 } 2344 }
2345 } 2345 }
2346 setModified( true ); 2346 setModified( true );
2347 mViewManager->refreshView(); 2347 mViewManager->refreshView();
2348 message( i18n("Removing categories done!")); 2348 message( i18n("Removing categories done!"));
2349 } 2349 }
2350 delete cp; 2350 delete cp;
2351} 2351}
2352void KABCore::removeVoice() 2352void KABCore::removeVoice()
2353{ 2353{
2354 if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) 2354 if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No )
2355 return; 2355 return;
2356 KABC::Addressee::List list;
2357 XXPortSelectDialog dlg( this, false, this ); 2356 XXPortSelectDialog dlg( this, false, this );
2358 if ( dlg.exec() ) 2357 if ( !dlg.exec() )
2359 list = dlg.contacts();
2360 else
2361 return; 2358 return;
2362 KABC::Addressee::List::Iterator it; 2359 mAddressBook->setUntagged();
2363 for ( it = list.begin(); it != list.end(); ++it ) { 2360 dlg.tagSelected();
2364 if ( (*it).removeVoice() ) 2361 message(i18n("Removing voice..."), false );
2365 addrModified((*it), false ); 2362 KABC::AddressBook::Iterator it;
2363 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2364 if ( (*it).tagged() ) {
2365 (*it).removeVoice();
2366 }
2366 } 2367 }
2368 message(i18n("Refreshing view...") );
2369 qApp->processEvents();
2370 mViewManager->refreshView( "" );
2371 Addressee add;
2372 mDetails->setAddressee( add );
2373 message(i18n("Remove voice completed!") );
2374
2375
2376
2367} 2377}
2368 2378
2369void KABCore::setFormattedName() 2379void KABCore::setFormattedName()
2370{ 2380{
2371 KABFormatPrefs setpref; 2381 KABFormatPrefs setpref;
2372 if ( !setpref.exec() ) { 2382 if ( !setpref.exec() ) {
2373 return; 2383 return;
2374 } 2384 }
2375 XXPortSelectDialog dlg( this, false, this ); 2385 XXPortSelectDialog dlg( this, false, this );
2376 if ( !dlg.exec() ) 2386 if ( !dlg.exec() )
2377 return; 2387 return;
2378 mAddressBook->setUntagged(); 2388 mAddressBook->setUntagged();
2379 dlg.tagSelected(); 2389 dlg.tagSelected();
2380 int count = 0; 2390 int count = 0;
2381 KABC::AddressBook::Iterator it; 2391 KABC::AddressBook::Iterator it;
2382 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2392 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2383 if ( (*it).tagged() ) { 2393 if ( (*it).tagged() ) {
2384 ++count; 2394 ++count;
2385 if ( count %10 == 0 ) 2395 if ( count %10 == 0 )
2386 message(i18n("Changing contact #%1").arg( count ) ); 2396 message(i18n("Changing contact #%1").arg( count ) );
2387 qApp->processEvents(); 2397 qApp->processEvents();
2388 QString fName; 2398 QString fName;
2389 if ( setpref.simple->isChecked() ) 2399 if ( setpref.simple->isChecked() )
2390 fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName ); 2400 fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName );
2391 else if ( setpref.full->isChecked() ) 2401 else if ( setpref.full->isChecked() )
2392 fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName ); 2402 fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName );
2393 else if ( setpref.reverse->isChecked() ) 2403 else if ( setpref.reverse->isChecked() )
2394 fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName ); 2404 fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName );
2395 else 2405 else
2396 fName = (*it).organization(); 2406 fName = (*it).organization();
2397 if ( setpref.setCompany->isChecked() ) 2407 if ( setpref.setCompany->isChecked() )
2398 if ( fName.isEmpty() || fName =="," ) 2408 if ( fName.isEmpty() || fName =="," )
2399 fName = (*it).organization(); 2409 fName = (*it).organization();
2400 (*it).setFormattedName( fName ); 2410 (*it).setFormattedName( fName );
2401 } 2411 }
2402 } 2412 }
2403 message(i18n("Refreshing view...") ); 2413 message(i18n("Refreshing view...") );
2404 qApp->processEvents(); 2414 qApp->processEvents();
2405 mViewManager->refreshView( "" ); 2415 mViewManager->refreshView( "" );
2406 Addressee add; 2416 Addressee add;
2407 mDetails->setAddressee( add ); 2417 mDetails->setAddressee( add );
2408 message(i18n("Setting formatted name completed!") ); 2418 message(i18n("Setting formatted name completed!") );
2409} 2419}
2410 2420
2411void KABCore::clipboardDataChanged() 2421void KABCore::clipboardDataChanged()
2412{ 2422{
2413 2423
2414 if ( mReadWrite ) 2424 if ( mReadWrite )
2415 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); 2425 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() );
2416 2426
2417} 2427}
2418 2428
2419void KABCore::updateActionMenu() 2429void KABCore::updateActionMenu()
2420{ 2430{
2421 UndoStack *undo = UndoStack::instance(); 2431 UndoStack *undo = UndoStack::instance();
2422 RedoStack *redo = RedoStack::instance(); 2432 RedoStack *redo = RedoStack::instance();
2423 2433
2424 if ( undo->isEmpty() ) 2434 if ( undo->isEmpty() )
2425 mActionUndo->setText( i18n( "Undo" ) ); 2435 mActionUndo->setText( i18n( "Undo" ) );
2426 else 2436 else
2427 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); 2437 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) );
2428 2438
2429 mActionUndo->setEnabled( !undo->isEmpty() ); 2439 mActionUndo->setEnabled( !undo->isEmpty() );
2430 2440
2431 if ( !redo->top() ) 2441 if ( !redo->top() )
2432 mActionRedo->setText( i18n( "Redo" ) ); 2442 mActionRedo->setText( i18n( "Redo" ) );
2433 else 2443 else
2434 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); 2444 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) );
2435 2445
2436 mActionRedo->setEnabled( !redo->isEmpty() ); 2446 mActionRedo->setEnabled( !redo->isEmpty() );
2437} 2447}
2438 2448
2439void KABCore::configureKeyBindings() 2449void KABCore::configureKeyBindings()
2440{ 2450{
2441#ifndef KAB_EMBEDDED 2451#ifndef KAB_EMBEDDED
2442 KKeyDialog::configure( actionCollection(), true ); 2452 KKeyDialog::configure( actionCollection(), true );
2443#else //KAB_EMBEDDED 2453#else //KAB_EMBEDDED
2444 qDebug("KABCore::configureKeyBindings() not implemented"); 2454 qDebug("KABCore::configureKeyBindings() not implemented");
2445#endif //KAB_EMBEDDED 2455#endif //KAB_EMBEDDED
2446} 2456}
2447 2457
2448#ifdef KAB_EMBEDDED 2458#ifdef KAB_EMBEDDED
2449void KABCore::configureResources() 2459void KABCore::configureResources()
2450{ 2460{
2451 KRES::KCMKResources dlg( this, "" , 0 ); 2461 KRES::KCMKResources dlg( this, "" , 0 );
2452 2462
2453 if ( !dlg.exec() ) 2463 if ( !dlg.exec() )
2454 return; 2464 return;
2455 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); 2465 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") );
2456} 2466}
2457#endif //KAB_EMBEDDED 2467#endif //KAB_EMBEDDED
2458 2468
2459 2469
2460/* this method will be called through the QCop interface from Ko/Pi to select addresses 2470/* this method will be called through the QCop interface from Ko/Pi to select addresses
2461 * for the attendees list of an event. 2471 * for the attendees list of an event.
2462 */ 2472 */
2463void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) 2473void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid)
2464{ 2474{
2465 QStringList nameList; 2475 QStringList nameList;
2466 QStringList emailList; 2476 QStringList emailList;
2467 QStringList uidList; 2477 QStringList uidList;
2468 2478
2469 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); 2479 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this);
2470 uint i=0; 2480 uint i=0;
2471 for (i=0; i < list.count(); i++) 2481 for (i=0; i < list.count(); i++)
2472 { 2482 {
2473 nameList.append(list[i].realName()); 2483 nameList.append(list[i].realName());
2474 emailList.append(list[i].preferredEmail()); 2484 emailList.append(list[i].preferredEmail());
2475 uidList.append(list[i].uid()); 2485 uidList.append(list[i].uid());
2476 } 2486 }
2477 2487
2478 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); 2488 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList);
2479 2489
2480} 2490}
2481 2491
2482/* this method will be called through the QCop interface from Ko/Pi to select birthdays 2492/* this method will be called through the QCop interface from Ko/Pi to select birthdays
2483 * to put them into the calendar. 2493 * to put them into the calendar.
2484 */ 2494 */
2485void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) 2495void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid)
2486{ 2496{
2487 // qDebug("KABCore::requestForBirthdayList"); 2497 // qDebug("KABCore::requestForBirthdayList");
2488 QStringList birthdayList; 2498 QStringList birthdayList;
2489 QStringList anniversaryList; 2499 QStringList anniversaryList;
2490 QStringList realNameList; 2500 QStringList realNameList;
2491 QStringList preferredEmailList; 2501 QStringList preferredEmailList;
2492 QStringList assembledNameList; 2502 QStringList assembledNameList;
2493 QStringList uidList; 2503 QStringList uidList;
2494 2504
2495 KABC::AddressBook::Iterator it; 2505 KABC::AddressBook::Iterator it;
2496 2506
2497 int count = 0; 2507 int count = 0;
2498 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2508 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2499 ++count; 2509 ++count;
2500 } 2510 }
2501 QProgressBar bar(count,0 ); 2511 QProgressBar bar(count,0 );
2502 int w = 300; 2512 int w = 300;
2503 if ( QApplication::desktop()->width() < 320 ) 2513 if ( QApplication::desktop()->width() < 320 )
2504 w = 220; 2514 w = 220;
2505 int h = bar.sizeHint().height() ; 2515 int h = bar.sizeHint().height() ;
2506 int dw = QApplication::desktop()->width(); 2516 int dw = QApplication::desktop()->width();
2507 int dh = QApplication::desktop()->height(); 2517 int dh = QApplication::desktop()->height();
2508 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2518 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2509 bar.show(); 2519 bar.show();
2510 bar.setCaption (i18n("Collecting birthdays - close to abort!") ); 2520 bar.setCaption (i18n("Collecting birthdays - close to abort!") );
2511 qApp->processEvents(); 2521 qApp->processEvents();
2512 2522
2513 QDate bday; 2523 QDate bday;
2514 QString anni; 2524 QString anni;
2515 QString formattedbday; 2525 QString formattedbday;
2516 2526
2517 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) 2527 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it )
2518 { 2528 {
2519 if ( ! bar.isVisible() ) 2529 if ( ! bar.isVisible() )
2520 return; 2530 return;
2521 bar.setProgress( count++ ); 2531 bar.setProgress( count++ );
2522 qApp->processEvents(); 2532 qApp->processEvents();
2523 bday = (*it).birthday().date(); 2533 bday = (*it).birthday().date();
2524 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); 2534 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" );
2525 2535
2526 if ( bday.isValid() || !anni.isEmpty()) 2536 if ( bday.isValid() || !anni.isEmpty())
2527 { 2537 {
2528 if (bday.isValid()) 2538 if (bday.isValid())
2529 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); 2539 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate);
2530 else 2540 else
2531 formattedbday = "NOTVALID"; 2541 formattedbday = "NOTVALID";
2532 if (anni.isEmpty()) 2542 if (anni.isEmpty())
2533 anni = "INVALID"; 2543 anni = "INVALID";
2534 2544
2535 birthdayList.append(formattedbday); 2545 birthdayList.append(formattedbday);
2536 anniversaryList.append(anni); //should be ISODate 2546 anniversaryList.append(anni); //should be ISODate
2537 realNameList.append((*it).realName()); 2547 realNameList.append((*it).realName());
2538 preferredEmailList.append((*it).preferredEmail()); 2548 preferredEmailList.append((*it).preferredEmail());
2539 assembledNameList.append((*it).assembledName()); 2549 assembledNameList.append((*it).assembledName());
2540 uidList.append((*it).uid()); 2550 uidList.append((*it).uid());
2541 2551
2542 //qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); 2552 //qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() );
2543 } 2553 }
2544 } 2554 }
2545 2555
2546 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); 2556 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList);
2547 2557
2548} 2558}
2549 2559
2550/* this method will be called through the QCop interface from other apps to show details of a contact. 2560/* this method will be called through the QCop interface from other apps to show details of a contact.
2551 */ 2561 */
2552void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) 2562void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid)
2553{ 2563{
2554 //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); 2564 //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1());
2555 2565
2556 QString foundUid = QString::null; 2566 QString foundUid = QString::null;
2557 if ( ! uid.isEmpty() ) { 2567 if ( ! uid.isEmpty() ) {
2558 Addressee adrr = mAddressBook->findByUid( uid ); 2568 Addressee adrr = mAddressBook->findByUid( uid );
2559 if ( !adrr.isEmpty() ) { 2569 if ( !adrr.isEmpty() ) {
2560 foundUid = uid; 2570 foundUid = uid;
2561 } 2571 }
2562 if ( email == "sendbacklist" ) { 2572 if ( email == "sendbacklist" ) {
2563 //qDebug("ssssssssssssssssssssssend "); 2573 //qDebug("ssssssssssssssssssssssend ");
2564 QStringList nameList; 2574 QStringList nameList;
2565 QStringList emailList; 2575 QStringList emailList;
2566 QStringList uidList; 2576 QStringList uidList;
2567 nameList.append(adrr.realName()); 2577 nameList.append(adrr.realName());
2568 emailList = adrr.emails(); 2578 emailList = adrr.emails();
2569 uidList.append( adrr.preferredEmail()); 2579 uidList.append( adrr.preferredEmail());
2570 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); 2580 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList);
2571 return; 2581 return;
2572 } 2582 }
2573 2583
2574 } 2584 }
2575 2585
2576 if ( email == "sendbacklist" ) 2586 if ( email == "sendbacklist" )
2577 return; 2587 return;
2578 if (foundUid.isEmpty()) 2588 if (foundUid.isEmpty())
2579 { 2589 {
2580 //find the uid of the person first 2590 //find the uid of the person first
2581 Addressee::List namelist; 2591 Addressee::List namelist;
2582 Addressee::List emaillist; 2592 Addressee::List emaillist;
2583 2593
2584 if (!name.isEmpty()) 2594 if (!name.isEmpty())
2585 namelist = mAddressBook->findByName( name ); 2595 namelist = mAddressBook->findByName( name );
2586 2596
2587 if (!email.isEmpty()) 2597 if (!email.isEmpty())
2588 emaillist = mAddressBook->findByEmail( email ); 2598 emaillist = mAddressBook->findByEmail( email );
2589 //qDebug("count %d %d ", namelist.count(),emaillist.count() ); 2599 //qDebug("count %d %d ", namelist.count(),emaillist.count() );
2590 //check if we have a match in Namelist and Emaillist 2600 //check if we have a match in Namelist and Emaillist
2591 if ((namelist.count() == 0) && (emaillist.count() > 0)) { 2601 if ((namelist.count() == 0) && (emaillist.count() > 0)) {
2592 foundUid = emaillist[0].uid(); 2602 foundUid = emaillist[0].uid();
2593 } 2603 }
2594 else if ((namelist.count() > 0) && (emaillist.count() == 0)) 2604 else if ((namelist.count() > 0) && (emaillist.count() == 0))
2595 foundUid = namelist[0].uid(); 2605 foundUid = namelist[0].uid();
2596 else 2606 else
2597 { 2607 {
2598 for (int i = 0; i < namelist.count(); i++) 2608 for (int i = 0; i < namelist.count(); i++)
2599 { 2609 {
2600 for (int j = 0; j < emaillist.count(); j++) 2610 for (int j = 0; j < emaillist.count(); j++)
2601 { 2611 {
2602 if (namelist[i] == emaillist[j]) 2612 if (namelist[i] == emaillist[j])
2603 { 2613 {
2604 foundUid = namelist[i].uid(); 2614 foundUid = namelist[i].uid();
2605 } 2615 }
2606 } 2616 }
2607 } 2617 }
2608 } 2618 }
2609 } 2619 }
2610 else 2620 else
2611 { 2621 {
2612 foundUid = uid; 2622 foundUid = uid;
2613 } 2623 }
2614 2624
2615 if (!foundUid.isEmpty()) 2625 if (!foundUid.isEmpty())
2616 { 2626 {
2617 2627
2618 // raise Ka/Pi if it is in the background 2628 // raise Ka/Pi if it is in the background
2619#ifndef DESKTOP_VERSION 2629#ifndef DESKTOP_VERSION
2620#ifndef KORG_NODCOP 2630#ifndef KORG_NODCOP
2621 //QCopEnvelope e("QPE/Application/kapi", "raise()"); 2631 //QCopEnvelope e("QPE/Application/kapi", "raise()");
2622#endif 2632#endif
2623#endif 2633#endif
2624 2634
2625 mMainWindow->showMaximized(); 2635 mMainWindow->showMaximized();
2626 mMainWindow-> raise(); 2636 mMainWindow-> raise();
2627 2637
2628 mViewManager->setSelected( "", false); 2638 mViewManager->setSelected( "", false);
2629 mViewManager->refreshView( "" ); 2639 mViewManager->refreshView( "" );
2630 mViewManager->setSelected( foundUid, true ); 2640 mViewManager->setSelected( foundUid, true );
2631 mViewManager->refreshView( foundUid ); 2641 mViewManager->refreshView( foundUid );
2632 2642
2633 if ( !mMultipleViewsAtOnce ) 2643 if ( !mMultipleViewsAtOnce )
2634 { 2644 {
2635 setDetailsVisible( true ); 2645 setDetailsVisible( true );
2636 mActionDetails->setChecked(true); 2646 mActionDetails->setChecked(true);
2637 } 2647 }
2638 } 2648 }
2639} 2649}
2640 2650
2641void KABCore::whatsnew() 2651void KABCore::whatsnew()
2642{ 2652{
2643 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 2653 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
2644} 2654}
2645void KABCore::synchowto() 2655void KABCore::synchowto()
2646{ 2656{
2647 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 2657 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
2648} 2658}
2649void KABCore::kdesynchowto() 2659void KABCore::kdesynchowto()
2650{ 2660{
2651 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); 2661 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" );
2652} 2662}
2653void KABCore::multisynchowto() 2663void KABCore::multisynchowto()
2654{ 2664{
2655 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); 2665 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" );
2656} 2666}
2657void KABCore::faq() 2667void KABCore::faq()
2658{ 2668{
2659 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); 2669 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" );
2660} 2670}
2661 2671
2662#include <libkcal/syncdefines.h> 2672#include <libkcal/syncdefines.h>
2663 2673
2664KABC::Addressee KABCore::getLastSyncAddressee() 2674KABC::Addressee KABCore::getLastSyncAddressee()
2665{ 2675{
2666 Addressee lse; 2676 Addressee lse;
2667 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2677 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2668 2678
2669 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 2679 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
2670 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2680 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2671 if (lse.isEmpty()) { 2681 if (lse.isEmpty()) {
2672 qDebug("Creating new last-syncAddressee "); 2682 qDebug("Creating new last-syncAddressee ");
2673 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2683 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice );
2674 QString sum = ""; 2684 QString sum = "";
2675 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 2685 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
2676 sum = "E: "; 2686 sum = "E: ";
2677 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); 2687 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event"));
2678 lse.setRevision( mLastAddressbookSync ); 2688 lse.setRevision( mLastAddressbookSync );
2679 lse.setCategories( i18n("SyncEvent") ); 2689 lse.setCategories( i18n("SyncEvent") );
2680 mAddressBook->insertAddressee( lse ); 2690 mAddressBook->insertAddressee( lse );
2681 } 2691 }
2682 return lse; 2692 return lse;
2683} 2693}
2684int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) 2694int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full )
2685{ 2695{
2686 2696
2687 //void setZaurusId(int id); 2697 //void setZaurusId(int id);
2688 // int zaurusId() const; 2698 // int zaurusId() const;
2689 // void setZaurusUid(int id); 2699 // void setZaurusUid(int id);
2690 // int zaurusUid() const; 2700 // int zaurusUid() const;
2691 // void setZaurusStat(int id); 2701 // void setZaurusStat(int id);
2692 // int zaurusStat() const; 2702 // int zaurusStat() const;
2693 // 0 equal 2703 // 0 equal
2694 // 1 take local 2704 // 1 take local
2695 // 2 take remote 2705 // 2 take remote
2696 // 3 cancel 2706 // 3 cancel
2697 QDateTime lastSync = mLastAddressbookSync; 2707 QDateTime lastSync = mLastAddressbookSync;
2698 QDateTime localMod = local->revision(); 2708 QDateTime localMod = local->revision();
2699 QDateTime remoteMod = remote->revision(); 2709 QDateTime remoteMod = remote->revision();
2700 2710
2701 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2711 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2702 2712
2703 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2713 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2704 bool remCh, locCh; 2714 bool remCh, locCh;
2705 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 2715 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
2706 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 2716 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
2707 locCh = ( localMod > mLastAddressbookSync ); 2717 locCh = ( localMod > mLastAddressbookSync );
2708 //qDebug("cahnged rem %d loc %d",remCh, locCh ); 2718 //qDebug("cahnged rem %d loc %d",remCh, locCh );
2709 if ( !remCh && ! locCh ) { 2719 if ( !remCh && ! locCh ) {
2710 //qDebug("both not changed "); 2720 //qDebug("both not changed ");
2711 lastSync = localMod.addDays(1); 2721 lastSync = localMod.addDays(1);
2712 if ( mode <= SYNC_PREF_ASK ) 2722 if ( mode <= SYNC_PREF_ASK )
2713 return 0; 2723 return 0;
2714 } else { 2724 } else {
2715 if ( locCh ) { 2725 if ( locCh ) {
2716 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); 2726 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1());
2717 lastSync = localMod.addDays( -1 ); 2727 lastSync = localMod.addDays( -1 );
2718 if ( !remCh ) 2728 if ( !remCh )
2719 remoteMod =( lastSync.addDays( -1 ) ); 2729 remoteMod =( lastSync.addDays( -1 ) );
2720 } else { 2730 } else {
2721 //qDebug(" not loc changed "); 2731 //qDebug(" not loc changed ");
2722 lastSync = localMod.addDays( 1 ); 2732 lastSync = localMod.addDays( 1 );
2723 if ( remCh ) { 2733 if ( remCh ) {
2724 //qDebug("rem changed "); 2734 //qDebug("rem changed ");
2725 remoteMod =( lastSync.addDays( 1 ) ); 2735 remoteMod =( lastSync.addDays( 1 ) );
2726 } 2736 }
2727 2737
2728 } 2738 }
2729 } 2739 }
2730 full = true; 2740 full = true;
2731 if ( mode < SYNC_PREF_ASK ) 2741 if ( mode < SYNC_PREF_ASK )
2732 mode = SYNC_PREF_ASK; 2742 mode = SYNC_PREF_ASK;
2733 } else { 2743 } else {
2734 if ( localMod == remoteMod ) 2744 if ( localMod == remoteMod )
2735 return 0; 2745 return 0;
2736 2746
2737 } 2747 }
2738 //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); 2748 //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec());
2739 //qDebug("lastsync %s ", lastSync.toString().latin1() ); 2749 //qDebug("lastsync %s ", lastSync.toString().latin1() );
2740 //full = true; //debug only 2750 //full = true; //debug only
2741 if ( full ) { 2751 if ( full ) {
2742 bool equ = ( (*local) == (*remote) ); 2752 bool equ = ( (*local) == (*remote) );
2743 if ( equ ) { 2753 if ( equ ) {
2744 //qDebug("equal "); 2754 //qDebug("equal ");
2745 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2755 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2746 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 2756 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
2747 } 2757 }
2748 if ( mode < SYNC_PREF_FORCE_LOCAL ) 2758 if ( mode < SYNC_PREF_FORCE_LOCAL )
2749 return 0; 2759 return 0;
2750 2760
2751 }//else //debug only 2761 }//else //debug only
2752 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 2762 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
2753 } 2763 }
2754 int result; 2764 int result;
2755 bool localIsNew; 2765 bool localIsNew;
2756 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); 2766 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() );
2757 2767
2758 if ( full && mode < SYNC_PREF_NEWEST ) 2768 if ( full && mode < SYNC_PREF_NEWEST )
2759 mode = SYNC_PREF_ASK; 2769 mode = SYNC_PREF_ASK;
2760 2770
2761 switch( mode ) { 2771 switch( mode ) {
2762 case SYNC_PREF_LOCAL: 2772 case SYNC_PREF_LOCAL:
2763 if ( lastSync > remoteMod ) 2773 if ( lastSync > remoteMod )
2764 return 1; 2774 return 1;
2765 if ( lastSync > localMod ) 2775 if ( lastSync > localMod )
2766 return 2; 2776 return 2;
2767 return 1; 2777 return 1;
2768 break; 2778 break;
2769 case SYNC_PREF_REMOTE: 2779 case SYNC_PREF_REMOTE:
2770 if ( lastSync > remoteMod ) 2780 if ( lastSync > remoteMod )
2771 return 1; 2781 return 1;
2772 if ( lastSync > localMod ) 2782 if ( lastSync > localMod )
2773 return 2; 2783 return 2;
2774 return 2; 2784 return 2;
2775 break; 2785 break;
2776 case SYNC_PREF_NEWEST: 2786 case SYNC_PREF_NEWEST:
2777 if ( localMod > remoteMod ) 2787 if ( localMod > remoteMod )
2778 return 1; 2788 return 1;
2779 else 2789 else
2780 return 2; 2790 return 2;
2781 break; 2791 break;
2782 case SYNC_PREF_ASK: 2792 case SYNC_PREF_ASK:
2783 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 2793 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
2784 if ( lastSync > remoteMod ) 2794 if ( lastSync > remoteMod )
2785 return 1; 2795 return 1;
2786 if ( lastSync > localMod ) { 2796 if ( lastSync > localMod ) {
2787 return 2; 2797 return 2;
2788 } 2798 }
2789 localIsNew = localMod >= remoteMod; 2799 localIsNew = localMod >= remoteMod;
2790 //qDebug("conflict! ************************************** "); 2800 //qDebug("conflict! ************************************** ");
2791 { 2801 {
2792 KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this ); 2802 KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this );
2793 result = acd.executeD(localIsNew); 2803 result = acd.executeD(localIsNew);
2794 return result; 2804 return result;
2795 } 2805 }
2796 break; 2806 break;
2797 case SYNC_PREF_FORCE_LOCAL: 2807 case SYNC_PREF_FORCE_LOCAL:
2798 return 1; 2808 return 1;
2799 break; 2809 break;
2800 case SYNC_PREF_FORCE_REMOTE: 2810 case SYNC_PREF_FORCE_REMOTE:
2801 return 2; 2811 return 2;
2802 break; 2812 break;
2803 2813
2804 default: 2814 default:
2805 // SYNC_PREF_TAKE_BOTH not implemented 2815 // SYNC_PREF_TAKE_BOTH not implemented
2806 break; 2816 break;
2807 } 2817 }
2808 return 0; 2818 return 0;
2809} 2819}
2810 2820
2811 2821
2812bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) 2822bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode)
2813{ 2823{
2814 bool syncOK = true; 2824 bool syncOK = true;
2815 int addedAddressee = 0; 2825 int addedAddressee = 0;
2816 int addedAddresseeR = 0; 2826 int addedAddresseeR = 0;
2817 int deletedAddresseeR = 0; 2827 int deletedAddresseeR = 0;
2818 int deletedAddresseeL = 0; 2828 int deletedAddresseeL = 0;
2819 int changedLocal = 0; 2829 int changedLocal = 0;
2820 int changedRemote = 0; 2830 int changedRemote = 0;
2821 int filteredIN = 0; 2831 int filteredIN = 0;
2822 int filteredOUT = 0; 2832 int filteredOUT = 0;
2823 2833
2824 QString mCurrentSyncName = syncManager->getCurrentSyncName(); 2834 QString mCurrentSyncName = syncManager->getCurrentSyncName();
2825 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2835 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2826 2836
2827 //QPtrList<Addressee> el = local->rawAddressees(); 2837 //QPtrList<Addressee> el = local->rawAddressees();
2828 Addressee addresseeR; 2838 Addressee addresseeR;
2829 QString uid; 2839 QString uid;
2830 int take; 2840 int take;
2831 Addressee addresseeL; 2841 Addressee addresseeL;
2832 Addressee addresseeRSync; 2842 Addressee addresseeRSync;
2833 Addressee addresseeLSync; 2843 Addressee addresseeLSync;
2834 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); 2844 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees();
2835 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); 2845 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees();
2836 bool fullDateRange = false; 2846 bool fullDateRange = false;
2837 local->resetTempSyncStat(); 2847 local->resetTempSyncStat();
2838 mLastAddressbookSync = QDateTime::currentDateTime(); 2848 mLastAddressbookSync = QDateTime::currentDateTime();
2839 if ( syncManager->syncWithDesktop() ) { 2849 if ( syncManager->syncWithDesktop() ) {
2840 // remote->removeSyncInfo( QString());//remove all info 2850 // remote->removeSyncInfo( QString());//remove all info
2841 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 2851 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
2842 mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; 2852 mLastAddressbookSync = KSyncManager::mRequestedSyncEvent;
2843 qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); 2853 qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() );
2844 } else { 2854 } else {
2845 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 2855 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
2846 } 2856 }
2847 } 2857 }
2848 QDateTime modifiedCalendar = mLastAddressbookSync; 2858 QDateTime modifiedCalendar = mLastAddressbookSync;
2849 addresseeLSync = getLastSyncAddressee(); 2859 addresseeLSync = getLastSyncAddressee();
2850 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); 2860 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1());
2851 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); 2861 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName );
2852 if ( !addresseeR.isEmpty() ) { 2862 if ( !addresseeR.isEmpty() ) {
2853 addresseeRSync = addresseeR; 2863 addresseeRSync = addresseeR;
2854 remote->removeAddressee(addresseeR ); 2864 remote->removeAddressee(addresseeR );
2855 2865
2856 } else { 2866 } else {
2857 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2867 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2858 addresseeRSync = addresseeLSync ; 2868 addresseeRSync = addresseeLSync ;
2859 } else { 2869 } else {
2860 //qDebug("FULLDATE 1"); 2870 //qDebug("FULLDATE 1");
2861 fullDateRange = true; 2871 fullDateRange = true;
2862 Addressee newAdd; 2872 Addressee newAdd;
2863 addresseeRSync = newAdd; 2873 addresseeRSync = newAdd;
2864 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); 2874 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee"));
2865 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); 2875 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName );
2866 addresseeRSync.setRevision( mLastAddressbookSync ); 2876 addresseeRSync.setRevision( mLastAddressbookSync );
2867 addresseeRSync.setCategories( i18n("SyncAddressee") ); 2877 addresseeRSync.setCategories( i18n("SyncAddressee") );
2868 } 2878 }
2869 } 2879 }
2870 if ( addresseeLSync.revision() == mLastAddressbookSync ) { 2880 if ( addresseeLSync.revision() == mLastAddressbookSync ) {
2871 // qDebug("FULLDATE 2"); 2881 // qDebug("FULLDATE 2");
2872 fullDateRange = true; 2882 fullDateRange = true;
2873 } 2883 }
2874 if ( ! fullDateRange ) { 2884 if ( ! fullDateRange ) {
2875 if ( addresseeLSync.revision() != addresseeRSync.revision() ) { 2885 if ( addresseeLSync.revision() != addresseeRSync.revision() ) {
2876 2886
2877 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); 2887 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() );
2878 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); 2888 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec());
2879 fullDateRange = true; 2889 fullDateRange = true;
2880 //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); 2890 //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() );
2881 } 2891 }
2882 } 2892 }
2883 // fullDateRange = true; // debug only! 2893 // fullDateRange = true; // debug only!
2884 if ( fullDateRange ) 2894 if ( fullDateRange )
2885 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); 2895 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365);
2886 else 2896 else
2887 mLastAddressbookSync = addresseeLSync.revision(); 2897 mLastAddressbookSync = addresseeLSync.revision();
2888 // for resyncing if own file has changed 2898 // for resyncing if own file has changed
2889 // PENDING fixme later when implemented 2899 // PENDING fixme later when implemented
2890#if 0 2900#if 0
2891 if ( mCurrentSyncDevice == "deleteaftersync" ) { 2901 if ( mCurrentSyncDevice == "deleteaftersync" ) {
2892 mLastAddressbookSync = loadedFileVersion; 2902 mLastAddressbookSync = loadedFileVersion;
2893 qDebug("setting mLastAddressbookSync "); 2903 qDebug("setting mLastAddressbookSync ");
2894 } 2904 }
2895#endif 2905#endif
2896 2906
2897 2907
2898 // ********** setting filters **************** 2908 // ********** setting filters ****************
2899 Filter filterIN = mViewManager->getFilterByName( syncManager->mFilterInAB ); 2909 Filter filterIN = mViewManager->getFilterByName( syncManager->mFilterInAB );
2900 Filter filterOUT = mViewManager->getFilterByName( syncManager->mFilterOutAB ); 2910 Filter filterOUT = mViewManager->getFilterByName( syncManager->mFilterOutAB );
2901 2911
2902 //qDebug("*************************** "); 2912 //qDebug("*************************** ");
2903 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); 2913 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() );
2904 QStringList er = remote->uidList(); 2914 QStringList er = remote->uidList();
2905 Addressee inR ;//= er.first(); 2915 Addressee inR ;//= er.first();
2906 Addressee inL; 2916 Addressee inL;
2907 2917
2908 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); 2918 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count());
2909 2919
2910 int modulo = (er.count()/10)+1; 2920 int modulo = (er.count()/10)+1;
2911 int incCounter = 0; 2921 int incCounter = 0;
2912 while ( incCounter < er.count()) { 2922 while ( incCounter < er.count()) {
2913 if (syncManager->isProgressBarCanceled()) 2923 if (syncManager->isProgressBarCanceled())
2914 return false; 2924 return false;
2915 if ( incCounter % modulo == 0 ) 2925 if ( incCounter % modulo == 0 )
2916 syncManager->showProgressBar(incCounter); 2926 syncManager->showProgressBar(incCounter);
2917 2927
2918 uid = er[ incCounter ]; 2928 uid = er[ incCounter ];
2919 bool skipIncidence = false; 2929 bool skipIncidence = false;
2920 if ( uid.left(19) == QString("last-syncAddressee-") ) 2930 if ( uid.left(19) == QString("last-syncAddressee-") )
2921 skipIncidence = true; 2931 skipIncidence = true;
2922 QString idS,OidS; 2932 QString idS,OidS;
2923 qApp->processEvents(); 2933 qApp->processEvents();
2924 if ( !skipIncidence ) { 2934 if ( !skipIncidence ) {
2925 inL = local->findByUid( uid ); 2935 inL = local->findByUid( uid );
2926 inR = remote->findByUid( uid ); 2936 inR = remote->findByUid( uid );
2927 //inL.setResource( 0 ); 2937 //inL.setResource( 0 );
2928 //inR.setResource( 0 ); 2938 //inR.setResource( 0 );
2929 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars 2939 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars
2930 if ( !inL.resource() || inL.resource()->includeInSync() ) { 2940 if ( !inL.resource() || inL.resource()->includeInSync() ) {
2931 if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) { 2941 if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) {
2932 //qDebug("take %d %s ", take, inL.summary().latin1()); 2942 //qDebug("take %d %s ", take, inL.summary().latin1());
2933 if ( take == 3 ) 2943 if ( take == 3 )
2934 return false; 2944 return false;
2935 if ( take == 1 ) {// take local ********************** 2945 if ( take == 1 ) {// take local **********************
2936 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2946 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2937 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2947 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2938 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2948 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2939 local->insertAddressee( inL, false ); 2949 local->insertAddressee( inL, false );
2940 idS = inR.externalUID(); 2950 idS = inR.externalUID();
2941 OidS = inR.originalExternalUID(); 2951 OidS = inR.originalExternalUID();
2942 } 2952 }
2943 else 2953 else
2944 idS = inR.IDStr(); 2954 idS = inR.IDStr();
2945 remote->removeAddressee( inR ); 2955 remote->removeAddressee( inR );
2946 inR = inL; 2956 inR = inL;
2947 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 2957 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
2948 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2958 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2949 inR.setOriginalExternalUID( OidS ); 2959 inR.setOriginalExternalUID( OidS );
2950 inR.setExternalUID( idS ); 2960 inR.setExternalUID( idS );
2951 if ( syncManager->syncWithDesktop() ) { 2961 if ( syncManager->syncWithDesktop() ) {
2952 inR.setIDStr("changed" ); 2962 inR.setIDStr("changed" );
2953 } 2963 }
2954 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); 2964 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" );
2955 } else { 2965 } else {
2956 inR.setIDStr( idS ); 2966 inR.setIDStr( idS );
2957 } 2967 }
2958 inR.setResource( 0 ); 2968 inR.setResource( 0 );
2959 remote->insertAddressee( inR , false); 2969 remote->insertAddressee( inR , false);
2960 ++changedRemote; 2970 ++changedRemote;
2961 } else { // take == 2 take remote ********************** 2971 } else { // take == 2 take remote **********************
2962 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2972 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2963 if ( inR.revision().date().year() < 2004 ) 2973 if ( inR.revision().date().year() < 2004 )
2964 inR.setRevision( modifiedCalendar ); 2974 inR.setRevision( modifiedCalendar );
2965 } 2975 }
2966 idS = inL.IDStr(); 2976 idS = inL.IDStr();
2967 local->removeAddressee( inL ); 2977 local->removeAddressee( inL );
2968 inL = inR; 2978 inL = inR;
2969 inL.setIDStr( idS ); 2979 inL.setIDStr( idS );
2970 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2980 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2971 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2981 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2972 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2982 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2973 } 2983 }
2974 inL.setResource( 0 ); 2984 inL.setResource( 0 );
2975 local->insertAddressee( inL , false ); 2985 local->insertAddressee( inL , false );
2976 ++changedLocal; 2986 ++changedLocal;
2977 } 2987 }
2978 } 2988 }
2979 } 2989 }
2980 } else { // no conflict ********** add or delete remote 2990 } else { // no conflict ********** add or delete remote
2981 if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) { 2991 if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) {
2982 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2992 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2983 QString des = addresseeLSync.note(); 2993 QString des = addresseeLSync.note();
2984 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 2994 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
2985 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 2995 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE );
2986 remote->insertAddressee( inR, false ); 2996 remote->insertAddressee( inR, false );
2987 ++deletedAddresseeR; 2997 ++deletedAddresseeR;
2988 } else { 2998 } else {
2989 inR.setRevision( modifiedCalendar ); 2999 inR.setRevision( modifiedCalendar );
2990 remote->insertAddressee( inR, false ); 3000 remote->insertAddressee( inR, false );
2991 inL = inR; 3001 inL = inR;
2992 inL.setIDStr( ":" ); 3002 inL.setIDStr( ":" );
2993 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 3003 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2994 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 3004 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2995 inL.setResource( 0 ); 3005 inL.setResource( 0 );
2996 local->insertAddressee( inL , false); 3006 local->insertAddressee( inL , false);
2997 ++addedAddressee; 3007 ++addedAddressee;
2998 } 3008 }
2999 } else { 3009 } else {
3000 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { 3010 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) {
3001 inR.setRevision( modifiedCalendar ); 3011 inR.setRevision( modifiedCalendar );
3002 remote->insertAddressee( inR, false ); 3012 remote->insertAddressee( inR, false );
3003 inR.setResource( 0 ); 3013 inR.setResource( 0 );
3004 local->insertAddressee( inR, false ); 3014 local->insertAddressee( inR, false );
3005 ++addedAddressee; 3015 ++addedAddressee;
3006 } else { 3016 } else {
3007 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); 3017 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
3008 remote->removeAddressee( inR ); 3018 remote->removeAddressee( inR );
3009 ++deletedAddresseeR; 3019 ++deletedAddresseeR;
3010 } 3020 }
3011 } 3021 }
3012 } else { 3022 } else {
3013 ++filteredIN; 3023 ++filteredIN;
3014 } 3024 }
3015 } 3025 }
3016 } 3026 }
3017 ++incCounter; 3027 ++incCounter;
3018 } 3028 }
3019 er.clear(); 3029 er.clear();
3020 QStringList el = local->uidList(); 3030 QStringList el = local->uidList();
3021 modulo = (el.count()/10)+1; 3031 modulo = (el.count()/10)+1;
3022 3032
3023 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); 3033 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count());
3024 incCounter = 0; 3034 incCounter = 0;
3025 while ( incCounter < el.count()) { 3035 while ( incCounter < el.count()) {
3026 qApp->processEvents(); 3036 qApp->processEvents();
3027 if (syncManager->isProgressBarCanceled()) 3037 if (syncManager->isProgressBarCanceled())
3028 return false; 3038 return false;
3029 if ( incCounter % modulo == 0 ) 3039 if ( incCounter % modulo == 0 )
3030 syncManager->showProgressBar(incCounter); 3040 syncManager->showProgressBar(incCounter);
3031 uid = el[ incCounter ]; 3041 uid = el[ incCounter ];
3032 bool skipIncidence = false; 3042 bool skipIncidence = false;
3033 if ( uid.left(19) == QString("last-syncAddressee-") ) 3043 if ( uid.left(19) == QString("last-syncAddressee-") )
3034 skipIncidence = true; 3044 skipIncidence = true;
3035 if ( !skipIncidence ) { 3045 if ( !skipIncidence ) {
3036 inL = local->findByUid( uid ); 3046 inL = local->findByUid( uid );
3037 if ( !inL.resource() || inL.resource()->includeInSync() ) { 3047 if ( !inL.resource() || inL.resource()->includeInSync() ) {
3038 inR = remote->findByUid( uid ); 3048 inR = remote->findByUid( uid );
3039 if ( inR.isEmpty() ){ 3049 if ( inR.isEmpty() ){
3040 if ( filterOUT.name().isEmpty() || filterOUT.filterAddressee( inL ) ) { 3050 if ( filterOUT.name().isEmpty() || filterOUT.filterAddressee( inL ) ) {
3041 // no conflict ********** add or delete local 3051 // no conflict ********** add or delete local
3042 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3052 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3043 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 3053 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
3044 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 3054 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
3045 local->removeAddressee( inL ); 3055 local->removeAddressee( inL );
3046 ++deletedAddresseeL; 3056 ++deletedAddresseeL;
3047 } else { 3057 } else {
3048 if ( ! syncManager->mWriteBackExistingOnly ) { 3058 if ( ! syncManager->mWriteBackExistingOnly ) {
3049 inL.removeID(mCurrentSyncDevice ); 3059 inL.removeID(mCurrentSyncDevice );
3050 ++addedAddresseeR; 3060 ++addedAddresseeR;
3051 inL.setRevision( modifiedCalendar ); 3061 inL.setRevision( modifiedCalendar );
3052 local->insertAddressee( inL, false ); 3062 local->insertAddressee( inL, false );
3053 inR = inL; 3063 inR = inL;
3054 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); 3064 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL );
3055 inR.setResource( 0 ); 3065 inR.setResource( 0 );
3056 remote->insertAddressee( inR, false ); 3066 remote->insertAddressee( inR, false );
3057 } 3067 }
3058 } 3068 }
3059 } else { 3069 } else {
3060 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { 3070 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) {
3061 //qDebug("data %s ", inL.revision().toString().latin1()); 3071 //qDebug("data %s ", inL.revision().toString().latin1());
3062 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 3072 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
3063 local->removeAddressee( inL ); 3073 local->removeAddressee( inL );
3064 ++deletedAddresseeL; 3074 ++deletedAddresseeL;
3065 } else { 3075 } else {
3066 if ( ! syncManager->mWriteBackExistingOnly ) { 3076 if ( ! syncManager->mWriteBackExistingOnly ) {
3067 ++addedAddresseeR; 3077 ++addedAddresseeR;
3068 inL.setRevision( modifiedCalendar ); 3078 inL.setRevision( modifiedCalendar );
3069 local->insertAddressee( inL, false ); 3079 local->insertAddressee( inL, false );
3070 inR = inL; 3080 inR = inL;
3071 inR.setIDStr( ":" ); 3081 inR.setIDStr( ":" );
3072 inR.setResource( 0 ); 3082 inR.setResource( 0 );
3073 remote->insertAddressee( inR, false ); 3083 remote->insertAddressee( inR, false );
3074 } 3084 }
3075 } 3085 }
3076 } 3086 }
3077 } else { 3087 } else {
3078 ++filteredOUT; 3088 ++filteredOUT;
3079 } 3089 }
3080 } 3090 }
3081 } 3091 }
3082 } 3092 }
3083 ++incCounter; 3093 ++incCounter;
3084 } 3094 }
3085 el.clear(); 3095 el.clear();
3086 syncManager->hideProgressBar(); 3096 syncManager->hideProgressBar();
3087 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); 3097 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 );
3088 // get rid of micro seconds 3098 // get rid of micro seconds
3089 QTime t = mLastAddressbookSync.time(); 3099 QTime t = mLastAddressbookSync.time();
3090 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 3100 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
3091 addresseeLSync.setRevision( mLastAddressbookSync ); 3101 addresseeLSync.setRevision( mLastAddressbookSync );
3092 addresseeRSync.setRevision( mLastAddressbookSync ); 3102 addresseeRSync.setRevision( mLastAddressbookSync );
3093 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; 3103 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ;
3094 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); 3104 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName );
3095 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; 3105 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ;
3096 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); 3106 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") );
3097 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; 3107 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ;
3098 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); 3108 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() );
3099 addresseeRSync.setNote( "" ) ; 3109 addresseeRSync.setNote( "" ) ;
3100 addresseeLSync.setNote( "" ); 3110 addresseeLSync.setNote( "" );
3101 3111
3102 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 3112 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
3103 remote->insertAddressee( addresseeRSync, false ); 3113 remote->insertAddressee( addresseeRSync, false );
3104 local->insertAddressee( addresseeLSync, false ); 3114 local->insertAddressee( addresseeLSync, false );
3105 QString mes; 3115 QString mes;
3106 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR, filteredIN, filteredOUT ); 3116 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR, filteredIN, filteredOUT );
3107 qDebug( mes ); 3117 qDebug( mes );
3108 mes = i18n("Local addressbook changed!\n") +mes; 3118 mes = i18n("Local addressbook changed!\n") +mes;
3109 if ( syncManager->mShowSyncSummary ) { 3119 if ( syncManager->mShowSyncSummary ) {
3110 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 3120 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
3111 i18n("KA/Pi Synchronization"),i18n("Write back"))) { 3121 i18n("KA/Pi Synchronization"),i18n("Write back"))) {
3112 qDebug("cancelled "); 3122 qDebug("cancelled ");
3113 return false; 3123 return false;
3114 } 3124 }
3115 } 3125 }
3116 return syncOK; 3126 return syncOK;
3117} 3127}
3118 3128
3119 3129
3120//this is a overwritten callbackmethods from the syncinterface 3130//this is a overwritten callbackmethods from the syncinterface
3121bool KABCore::sync(KSyncManager* manager, QString filename, int mode) 3131bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
3122{ 3132{
3123 3133
3124 //pending prepare addresseeview for output 3134 //pending prepare addresseeview for output
3125 //pending detect, if remote file has REV field. if not switch to external sync 3135 //pending detect, if remote file has REV field. if not switch to external sync
3126 mGlobalSyncMode = SYNC_MODE_NORMAL; 3136 mGlobalSyncMode = SYNC_MODE_NORMAL;
3127 if ( manager != syncManager ) 3137 if ( manager != syncManager )
3128 qDebug("KABCore::sync:: ERROR! :: manager != syncManager "); 3138 qDebug("KABCore::sync:: ERROR! :: manager != syncManager ");
3129 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3139 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3130 3140
3131 AddressBook abLocal(filename,"syncContact"); 3141 AddressBook abLocal(filename,"syncContact");
3132 bool syncOK = false; 3142 bool syncOK = false;
3133 if ( abLocal.load() ) { 3143 if ( abLocal.load() ) {
3134 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); 3144 qDebug("Sync:AB loaded %s,sync mode %d",filename.latin1(), mode );
3135 bool external = false; 3145 bool external = false;
3136 bool isXML = false; 3146 bool isXML = false;
3137 if ( filename.right(4) == ".xml") { 3147 if ( filename.right(4) == ".xml") {
3138 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3148 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3139 isXML = true; 3149 isXML = true;
3140 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 3150 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
3141 } else { 3151 } else {
3142 external = !manager->mIsKapiFile; 3152 external = !manager->mIsKapiFile;
3143 if ( external ) { 3153 if ( external ) {
3144 qDebug("Setting vcf mode to external "); 3154 qDebug("Sync:Setting vcf mode to external ");
3145 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3155 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3146 AddressBook::Iterator it; 3156 AddressBook::Iterator it;
3147 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 3157 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
3148 (*it).setID( mCurrentSyncDevice, (*it).uid() ); 3158 (*it).setID( mCurrentSyncDevice, (*it).uid() );
3149 (*it).computeCsum( mCurrentSyncDevice ); 3159 (*it).computeCsum( mCurrentSyncDevice );
3150 } 3160 }
3151 } 3161 }
3152 } 3162 }
3153 //AddressBook::Iterator it; 3163 //AddressBook::Iterator it;
3154 //QStringList vcards; 3164 //QStringList vcards;
3155 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 3165 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
3156 // qDebug("Name %s ", (*it).familyName().latin1()); 3166 // qDebug("Name %s ", (*it).familyName().latin1());
3157 //} 3167 //}
3158 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); 3168 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
3159 if ( syncOK ) { 3169 if ( syncOK ) {
3160 if ( syncManager->mWriteBackFile ) 3170 if ( syncManager->mWriteBackFile )
3161 { 3171 {
3162 if ( external ) 3172 if ( external )
3163 abLocal.removeSyncAddressees( !isXML); 3173 abLocal.removeSyncAddressees( !isXML);
3164 qDebug("Saving remote AB "); 3174 qDebug("Sync:Saving remote AB ");
3165 if ( ! abLocal.saveAB()) 3175 if ( ! abLocal.saveAB())
3166 qDebug("Error writing back AB to file "); 3176 qDebug("Error writing back AB to file ");
3167 if ( external ) { 3177 if ( external ) {
3168 // afterwrite processing 3178 // afterwrite processing
3169 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); 3179 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML);
3170 } 3180 }
3171 } 3181 }
3172 } 3182 }
3173 setModified(); 3183 setModified();
3174 3184
3175 } 3185 }
3176 abLocal.removeResources(); 3186 abLocal.removeResources();
3177 if ( syncOK ) 3187 if ( syncOK )
3178 mViewManager->refreshView(); 3188 mViewManager->refreshView();
3179 return syncOK; 3189 return syncOK;
3180 3190
3181} 3191}
3182void KABCore::removeSyncInfo( QString syncProfile) 3192void KABCore::removeSyncInfo( QString syncProfile)
3183{ 3193{
3184 qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); 3194 qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1());
3185 mAddressBook->removeSyncInfo( syncProfile ); 3195 mAddressBook->removeSyncInfo( syncProfile );
3186 setModified(); 3196 setModified();
3187} 3197}
3188 3198
3189 3199
3190//this is a overwritten callbackmethods from the syncinterface 3200//this is a overwritten callbackmethods from the syncinterface
3191bool KABCore::syncExternal(KSyncManager* manager, QString resource) 3201bool KABCore::syncExternal(KSyncManager* manager, QString resource)
3192{ 3202{
3193 if ( resource == "phone" ) 3203 if ( resource == "phone" )
3194 return syncPhone(); 3204 return syncPhone();
3195 disableBR( true ); 3205 disableBR( true );
3196 if ( manager != syncManager ) 3206 if ( manager != syncManager )
3197 qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager "); 3207 qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager ");
3198 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3208 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3199 3209
3200 AddressBook abLocal( resource,"syncContact"); 3210 AddressBook abLocal( resource,"syncContact");
3201 bool syncOK = false; 3211 bool syncOK = false;
3202 message(i18n("Loading DTM address data..."), false); 3212 message(i18n("Loading DTM address data..."), false);
3203 if ( abLocal.load() ) { 3213 if ( abLocal.load() ) {
3204 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); 3214 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
3205 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3215 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3206 message(i18n("Sync preprocessing..."),false); 3216 message(i18n("Sync preprocessing..."),false);
3207 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); 3217 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false );
3208 message(i18n("Synchronizing..."),false); 3218 message(i18n("Synchronizing..."),false);
3209 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 3219 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
3210 if ( syncOK ) { 3220 if ( syncOK ) {
3211 if ( syncManager->mWriteBackFile ) { 3221 if ( syncManager->mWriteBackFile ) {
3212 abLocal.removeSyncAddressees( false ); 3222 abLocal.removeSyncAddressees( false );
3213 message(i18n("Saving DTM address data..."),false); 3223 message(i18n("Saving DTM address data..."),false);
3214 abLocal.saveAB(); 3224 abLocal.saveAB();
3215 message(i18n("Sync postprocessing..."),false); 3225 message(i18n("Sync postprocessing..."),false);
3216 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 3226 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
3217 } 3227 }
3218 } else 3228 } else
3219 message( i18n("Sync cancelled or failed.") ); 3229 message( i18n("Sync cancelled or failed.") );
3220 setModified(); 3230 setModified();
3221 } 3231 }
3222 abLocal.removeResources(); 3232 abLocal.removeResources();
3223 if ( syncOK ) { 3233 if ( syncOK ) {
3224 mViewManager->refreshView(); 3234 mViewManager->refreshView();
3225 message(i18n("DTM syncing finished.")); 3235 message(i18n("DTM syncing finished."));
3226 } 3236 }
3227 disableBR( false ); 3237 disableBR( false );
3228 return syncOK; 3238 return syncOK;
3229 3239
3230} 3240}
3231void KABCore::message( QString m, bool startTimer) 3241void KABCore::message( QString m, bool startTimer)
3232{ 3242{
3233 topLevelWidget()->setCaption( m ); 3243 topLevelWidget()->setCaption( m );
3234 qApp->processEvents(); 3244 qApp->processEvents();
3235 if ( startTimer ) 3245 if ( startTimer )
3236 mMessageTimer->start( 15000, true ); 3246 mMessageTimer->start( 15000, true );
3237 else 3247 else
3238 mMessageTimer->stop(); 3248 mMessageTimer->stop();
3239} 3249}
3240bool KABCore::syncPhone() 3250bool KABCore::syncPhone()
3241{ 3251{
3242 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 3252 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
3243 QString fileName = getPhoneFile(); 3253 QString fileName = getPhoneFile();
3244 if ( !PhoneAccess::readFromPhone( fileName) ) { 3254 if ( !PhoneAccess::readFromPhone( fileName) ) {
3245 message(i18n("Phone access failed!")); 3255 message(i18n("Phone access failed!"));
3246 return false; 3256 return false;
3247 } 3257 }
3248 AddressBook abLocal( fileName,"syncContact"); 3258 AddressBook abLocal( fileName,"syncContact");
3249 bool syncOK = false; 3259 bool syncOK = false;
3250 { 3260 {
3251 abLocal.importFromFile( fileName ); 3261 abLocal.importFromFile( fileName );
3252 qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); 3262 qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1());
3253 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3263 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3254 abLocal.preparePhoneSync( mCurrentSyncDevice, true ); 3264 abLocal.preparePhoneSync( mCurrentSyncDevice, true );
3255 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 3265 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
3256 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 3266 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
3257 if ( syncOK ) { 3267 if ( syncOK ) {
3258 if ( syncManager->mWriteBackFile ) { 3268 if ( syncManager->mWriteBackFile ) {
3259 abLocal.removeSyncAddressees( true ); 3269 abLocal.removeSyncAddressees( true );
3260 abLocal.saveABphone( fileName ); 3270 abLocal.saveABphone( fileName );
3261 abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); 3271 abLocal.findNewExtIds( fileName, mCurrentSyncDevice );
3262 //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); 3272 //abLocal.preparePhoneSync( mCurrentSyncDevice, false );
3263 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 3273 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
3264 } 3274 }
3265 } 3275 }
3266 setModified(); 3276 setModified();
3267 } 3277 }
3268 abLocal.removeResources(); 3278 abLocal.removeResources();
3269 if ( syncOK ) 3279 if ( syncOK )
3270 mViewManager->refreshView(); 3280 mViewManager->refreshView();
3271 return syncOK; 3281 return syncOK;
3272} 3282}
3273void KABCore::getFile( bool success ) 3283void KABCore::getFile( bool success )
3274{ 3284{
3275 if ( ! success ) { 3285 if ( ! success ) {
3276 message( i18n("Error receiving file. Nothing changed!") ); 3286 message( i18n("Error receiving file. Nothing changed!") );
3277 return; 3287 return;
3278 } 3288 }
3279 int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); 3289 int count = mAddressBook->importFromFile( sentSyncFile() , false, true );
3280 if ( count ) 3290 if ( count )
3281 setModified( true ); 3291 setModified( true );
3282 message( i18n("Pi-Sync successful!") ); 3292 message( i18n("Pi-Sync successful!") );
3283 mViewManager->refreshView(); 3293 mViewManager->refreshView();
3284} 3294}
3285void KABCore::syncFileRequest() 3295void KABCore::syncFileRequest()
3286{ 3296{
3287 if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { 3297 if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) {
3288 syncManager->slotSyncMenu( 999 ); 3298 syncManager->slotSyncMenu( 999 );
3289 } 3299 }
3290 mAddressBook->export2File( sentSyncFile() ); 3300 mAddressBook->export2File( sentSyncFile() );
3291} 3301}
3292QString KABCore::sentSyncFile() 3302QString KABCore::sentSyncFile()
3293{ 3303{
3294#ifdef DESKTOP_VERSION 3304#ifdef DESKTOP_VERSION
3295 return locateLocal( "tmp", "copysyncab.vcf" ); 3305 return locateLocal( "tmp", "copysyncab.vcf" );
3296#else 3306#else
3297 return QString( "/tmp/copysyncab.vcf" ); 3307 return QString( "/tmp/copysyncab.vcf" );
3298#endif 3308#endif
3299} 3309}
3300 3310
3301void KABCore::setCaptionBack() 3311void KABCore::setCaptionBack()
3302{ 3312{
3303 mMessageTimer->stop(); 3313 mMessageTimer->stop();
3304 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); 3314 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") );
3305} 3315}