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