author | zautrix <zautrix> | 2004-10-07 12:19:25 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-07 12:19:25 (UTC) |
commit | 826dc960353e47a60aba13916189c45ef3392c1e (patch) (unidiff) | |
tree | 52ef4058d7a1fa8d77e678391ed9165009634182 /kaddressbook | |
parent | 43c82cc5393522d2c34f34a4339cb6a1d1c6c555 (diff) | |
download | kdepimpi-826dc960353e47a60aba13916189c45ef3392c1e.zip kdepimpi-826dc960353e47a60aba13916189c45ef3392c1e.tar.gz kdepimpi-826dc960353e47a60aba13916189c45ef3392c1e.tar.bz2 |
sync fixes
-rw-r--r-- | kaddressbook/kabcore.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index fa80f5c..12502b0 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -1325,1563 +1325,1563 @@ void KABCore::setDetailsVisible( bool visible ) | |||
1325 | } | 1325 | } |
1326 | else { | 1326 | else { |
1327 | mViewManager->show(); | 1327 | mViewManager->show(); |
1328 | mDetails->hide(); | 1328 | mDetails->hide(); |
1329 | } | 1329 | } |
1330 | setJumpButtonBarVisible( !visible ); | 1330 | setJumpButtonBarVisible( !visible ); |
1331 | } | 1331 | } |
1332 | 1332 | ||
1333 | } | 1333 | } |
1334 | 1334 | ||
1335 | void KABCore::extensionChanged( int id ) | 1335 | void KABCore::extensionChanged( int id ) |
1336 | { | 1336 | { |
1337 | //change the details view only for non desktop systems | 1337 | //change the details view only for non desktop systems |
1338 | #ifndef DESKTOP_VERSION | 1338 | #ifndef DESKTOP_VERSION |
1339 | 1339 | ||
1340 | if (id == 0) | 1340 | if (id == 0) |
1341 | { | 1341 | { |
1342 | //the user disabled the extension. | 1342 | //the user disabled the extension. |
1343 | 1343 | ||
1344 | if (mMultipleViewsAtOnce) | 1344 | if (mMultipleViewsAtOnce) |
1345 | { // enable detailsview again | 1345 | { // enable detailsview again |
1346 | setDetailsVisible( true ); | 1346 | setDetailsVisible( true ); |
1347 | mActionDetails->setChecked( true ); | 1347 | mActionDetails->setChecked( true ); |
1348 | } | 1348 | } |
1349 | else | 1349 | else |
1350 | { //go back to the listview | 1350 | { //go back to the listview |
1351 | setDetailsVisible( false ); | 1351 | setDetailsVisible( false ); |
1352 | mActionDetails->setChecked( false ); | 1352 | mActionDetails->setChecked( false ); |
1353 | mActionDetails->setEnabled(true); | 1353 | mActionDetails->setEnabled(true); |
1354 | } | 1354 | } |
1355 | 1355 | ||
1356 | } | 1356 | } |
1357 | else | 1357 | else |
1358 | { | 1358 | { |
1359 | //the user enabled the extension. | 1359 | //the user enabled the extension. |
1360 | setDetailsVisible( false ); | 1360 | setDetailsVisible( false ); |
1361 | mActionDetails->setChecked( false ); | 1361 | mActionDetails->setChecked( false ); |
1362 | 1362 | ||
1363 | if (!mMultipleViewsAtOnce) | 1363 | if (!mMultipleViewsAtOnce) |
1364 | { | 1364 | { |
1365 | mActionDetails->setEnabled(false); | 1365 | mActionDetails->setEnabled(false); |
1366 | } | 1366 | } |
1367 | 1367 | ||
1368 | mExtensionManager->setSelectionChanged(); | 1368 | mExtensionManager->setSelectionChanged(); |
1369 | 1369 | ||
1370 | } | 1370 | } |
1371 | 1371 | ||
1372 | #endif// DESKTOP_VERSION | 1372 | #endif// DESKTOP_VERSION |
1373 | 1373 | ||
1374 | } | 1374 | } |
1375 | 1375 | ||
1376 | 1376 | ||
1377 | void KABCore::extensionModified( const KABC::Addressee::List &list ) | 1377 | void KABCore::extensionModified( const KABC::Addressee::List &list ) |
1378 | { | 1378 | { |
1379 | 1379 | ||
1380 | if ( list.count() != 0 ) { | 1380 | if ( list.count() != 0 ) { |
1381 | KABC::Addressee::List::ConstIterator it; | 1381 | KABC::Addressee::List::ConstIterator it; |
1382 | for ( it = list.begin(); it != list.end(); ++it ) | 1382 | for ( it = list.begin(); it != list.end(); ++it ) |
1383 | mAddressBook->insertAddressee( *it ); | 1383 | mAddressBook->insertAddressee( *it ); |
1384 | if ( list.count() > 1 ) | 1384 | if ( list.count() > 1 ) |
1385 | setModified(); | 1385 | setModified(); |
1386 | else | 1386 | else |
1387 | setModifiedWOrefresh(); | 1387 | setModifiedWOrefresh(); |
1388 | } | 1388 | } |
1389 | if ( list.count() == 0 ) | 1389 | if ( list.count() == 0 ) |
1390 | mViewManager->refreshView(); | 1390 | mViewManager->refreshView(); |
1391 | else | 1391 | else |
1392 | mViewManager->refreshView( list[ 0 ].uid() ); | 1392 | mViewManager->refreshView( list[ 0 ].uid() ); |
1393 | 1393 | ||
1394 | 1394 | ||
1395 | 1395 | ||
1396 | } | 1396 | } |
1397 | 1397 | ||
1398 | QString KABCore::getNameByPhone( const QString &phone ) | 1398 | QString KABCore::getNameByPhone( const QString &phone ) |
1399 | { | 1399 | { |
1400 | #ifndef KAB_EMBEDDED | 1400 | #ifndef KAB_EMBEDDED |
1401 | QRegExp r( "[/*/-/ ]" ); | 1401 | QRegExp r( "[/*/-/ ]" ); |
1402 | QString localPhone( phone ); | 1402 | QString localPhone( phone ); |
1403 | 1403 | ||
1404 | bool found = false; | 1404 | bool found = false; |
1405 | QString ownerName = ""; | 1405 | QString ownerName = ""; |
1406 | KABC::AddressBook::Iterator iter; | 1406 | KABC::AddressBook::Iterator iter; |
1407 | KABC::PhoneNumber::List::Iterator phoneIter; | 1407 | KABC::PhoneNumber::List::Iterator phoneIter; |
1408 | KABC::PhoneNumber::List phoneList; | 1408 | KABC::PhoneNumber::List phoneList; |
1409 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { | 1409 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { |
1410 | phoneList = (*iter).phoneNumbers(); | 1410 | phoneList = (*iter).phoneNumbers(); |
1411 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); | 1411 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); |
1412 | ++phoneIter) { | 1412 | ++phoneIter) { |
1413 | // Get rid of separator chars so just the numbers are compared. | 1413 | // Get rid of separator chars so just the numbers are compared. |
1414 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { | 1414 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { |
1415 | ownerName = (*iter).formattedName(); | 1415 | ownerName = (*iter).formattedName(); |
1416 | found = true; | 1416 | found = true; |
1417 | } | 1417 | } |
1418 | } | 1418 | } |
1419 | } | 1419 | } |
1420 | 1420 | ||
1421 | return ownerName; | 1421 | return ownerName; |
1422 | #else //KAB_EMBEDDED | 1422 | #else //KAB_EMBEDDED |
1423 | qDebug("KABCore::getNameByPhone finsih method"); | 1423 | qDebug("KABCore::getNameByPhone finsih method"); |
1424 | return ""; | 1424 | return ""; |
1425 | #endif //KAB_EMBEDDED | 1425 | #endif //KAB_EMBEDDED |
1426 | 1426 | ||
1427 | } | 1427 | } |
1428 | 1428 | ||
1429 | void KABCore::openConfigDialog() | 1429 | void KABCore::openConfigDialog() |
1430 | { | 1430 | { |
1431 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); | 1431 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); |
1432 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); | 1432 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); |
1433 | ConfigureDialog->addModule(kabcfg ); | 1433 | ConfigureDialog->addModule(kabcfg ); |
1434 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); | 1434 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); |
1435 | ConfigureDialog->addModule(kdelibcfg ); | 1435 | ConfigureDialog->addModule(kdelibcfg ); |
1436 | 1436 | ||
1437 | connect( ConfigureDialog, SIGNAL( applyClicked() ), | 1437 | connect( ConfigureDialog, SIGNAL( applyClicked() ), |
1438 | this, SLOT( configurationChanged() ) ); | 1438 | this, SLOT( configurationChanged() ) ); |
1439 | connect( ConfigureDialog, SIGNAL( okClicked() ), | 1439 | connect( ConfigureDialog, SIGNAL( okClicked() ), |
1440 | this, SLOT( configurationChanged() ) ); | 1440 | this, SLOT( configurationChanged() ) ); |
1441 | saveSettings(); | 1441 | saveSettings(); |
1442 | #ifndef DESKTOP_VERSION | 1442 | #ifndef DESKTOP_VERSION |
1443 | ConfigureDialog->showMaximized(); | 1443 | ConfigureDialog->showMaximized(); |
1444 | #endif | 1444 | #endif |
1445 | if ( ConfigureDialog->exec() ) | 1445 | if ( ConfigureDialog->exec() ) |
1446 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); | 1446 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); |
1447 | delete ConfigureDialog; | 1447 | delete ConfigureDialog; |
1448 | } | 1448 | } |
1449 | 1449 | ||
1450 | void KABCore::openLDAPDialog() | 1450 | void KABCore::openLDAPDialog() |
1451 | { | 1451 | { |
1452 | #ifndef KAB_EMBEDDED | 1452 | #ifndef KAB_EMBEDDED |
1453 | if ( !mLdapSearchDialog ) { | 1453 | if ( !mLdapSearchDialog ) { |
1454 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); | 1454 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); |
1455 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, | 1455 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, |
1456 | SLOT( refreshView() ) ); | 1456 | SLOT( refreshView() ) ); |
1457 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, | 1457 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, |
1458 | SLOT( setModified() ) ); | 1458 | SLOT( setModified() ) ); |
1459 | } else | 1459 | } else |
1460 | mLdapSearchDialog->restoreSettings(); | 1460 | mLdapSearchDialog->restoreSettings(); |
1461 | 1461 | ||
1462 | if ( mLdapSearchDialog->isOK() ) | 1462 | if ( mLdapSearchDialog->isOK() ) |
1463 | mLdapSearchDialog->exec(); | 1463 | mLdapSearchDialog->exec(); |
1464 | #else //KAB_EMBEDDED | 1464 | #else //KAB_EMBEDDED |
1465 | qDebug("KABCore::openLDAPDialog() finsih method"); | 1465 | qDebug("KABCore::openLDAPDialog() finsih method"); |
1466 | #endif //KAB_EMBEDDED | 1466 | #endif //KAB_EMBEDDED |
1467 | } | 1467 | } |
1468 | 1468 | ||
1469 | void KABCore::print() | 1469 | void KABCore::print() |
1470 | { | 1470 | { |
1471 | #ifndef KAB_EMBEDDED | 1471 | #ifndef KAB_EMBEDDED |
1472 | KPrinter printer; | 1472 | KPrinter printer; |
1473 | if ( !printer.setup( this ) ) | 1473 | if ( !printer.setup( this ) ) |
1474 | return; | 1474 | return; |
1475 | 1475 | ||
1476 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, | 1476 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, |
1477 | mViewManager->selectedUids(), this ); | 1477 | mViewManager->selectedUids(), this ); |
1478 | 1478 | ||
1479 | wizard.exec(); | 1479 | wizard.exec(); |
1480 | #else //KAB_EMBEDDED | 1480 | #else //KAB_EMBEDDED |
1481 | qDebug("KABCore::print() finsih method"); | 1481 | qDebug("KABCore::print() finsih method"); |
1482 | #endif //KAB_EMBEDDED | 1482 | #endif //KAB_EMBEDDED |
1483 | 1483 | ||
1484 | } | 1484 | } |
1485 | 1485 | ||
1486 | 1486 | ||
1487 | void KABCore::addGUIClient( KXMLGUIClient *client ) | 1487 | void KABCore::addGUIClient( KXMLGUIClient *client ) |
1488 | { | 1488 | { |
1489 | if ( mGUIClient ) | 1489 | if ( mGUIClient ) |
1490 | mGUIClient->insertChildClient( client ); | 1490 | mGUIClient->insertChildClient( client ); |
1491 | else | 1491 | else |
1492 | KMessageBox::error( this, "no KXMLGUICLient"); | 1492 | KMessageBox::error( this, "no KXMLGUICLient"); |
1493 | } | 1493 | } |
1494 | 1494 | ||
1495 | 1495 | ||
1496 | void KABCore::configurationChanged() | 1496 | void KABCore::configurationChanged() |
1497 | { | 1497 | { |
1498 | mExtensionManager->reconfigure(); | 1498 | mExtensionManager->reconfigure(); |
1499 | } | 1499 | } |
1500 | 1500 | ||
1501 | void KABCore::addressBookChanged() | 1501 | void KABCore::addressBookChanged() |
1502 | { | 1502 | { |
1503 | /*US | 1503 | /*US |
1504 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); | 1504 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); |
1505 | while ( it.current() ) { | 1505 | while ( it.current() ) { |
1506 | if ( it.current()->dirty() ) { | 1506 | if ( it.current()->dirty() ) { |
1507 | QString text = i18n( "Data has been changed externally. Unsaved " | 1507 | QString text = i18n( "Data has been changed externally. Unsaved " |
1508 | "changes will be lost." ); | 1508 | "changes will be lost." ); |
1509 | KMessageBox::information( this, text ); | 1509 | KMessageBox::information( this, text ); |
1510 | } | 1510 | } |
1511 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); | 1511 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); |
1512 | ++it; | 1512 | ++it; |
1513 | } | 1513 | } |
1514 | */ | 1514 | */ |
1515 | if (mEditorDialog) | 1515 | if (mEditorDialog) |
1516 | { | 1516 | { |
1517 | if (mEditorDialog->dirty()) | 1517 | if (mEditorDialog->dirty()) |
1518 | { | 1518 | { |
1519 | QString text = i18n( "Data has been changed externally. Unsaved " | 1519 | QString text = i18n( "Data has been changed externally. Unsaved " |
1520 | "changes will be lost." ); | 1520 | "changes will be lost." ); |
1521 | KMessageBox::information( this, text ); | 1521 | KMessageBox::information( this, text ); |
1522 | } | 1522 | } |
1523 | QString currentuid = mEditorDialog->addressee().uid(); | 1523 | QString currentuid = mEditorDialog->addressee().uid(); |
1524 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); | 1524 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); |
1525 | } | 1525 | } |
1526 | mViewManager->refreshView(); | 1526 | mViewManager->refreshView(); |
1527 | // mDetails->refreshView(); | 1527 | // mDetails->refreshView(); |
1528 | 1528 | ||
1529 | 1529 | ||
1530 | } | 1530 | } |
1531 | 1531 | ||
1532 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, | 1532 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, |
1533 | const char *name ) | 1533 | const char *name ) |
1534 | { | 1534 | { |
1535 | 1535 | ||
1536 | if ( mEditorDialog == 0 ) { | 1536 | if ( mEditorDialog == 0 ) { |
1537 | mEditorDialog = new AddresseeEditorDialog( this, parent, | 1537 | mEditorDialog = new AddresseeEditorDialog( this, parent, |
1538 | name ? name : "editorDialog" ); | 1538 | name ? name : "editorDialog" ); |
1539 | 1539 | ||
1540 | 1540 | ||
1541 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), | 1541 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), |
1542 | SLOT( contactModified( const KABC::Addressee& ) ) ); | 1542 | SLOT( contactModified( const KABC::Addressee& ) ) ); |
1543 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), | 1543 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), |
1544 | // SLOT( slotEditorDestroyed( const QString& ) ) ; | 1544 | // SLOT( slotEditorDestroyed( const QString& ) ) ; |
1545 | } | 1545 | } |
1546 | 1546 | ||
1547 | return mEditorDialog; | 1547 | return mEditorDialog; |
1548 | } | 1548 | } |
1549 | 1549 | ||
1550 | void KABCore::slotEditorDestroyed( const QString &uid ) | 1550 | void KABCore::slotEditorDestroyed( const QString &uid ) |
1551 | { | 1551 | { |
1552 | //mEditorDict.remove( uid ); | 1552 | //mEditorDict.remove( uid ); |
1553 | } | 1553 | } |
1554 | 1554 | ||
1555 | void KABCore::initGUI() | 1555 | void KABCore::initGUI() |
1556 | { | 1556 | { |
1557 | #ifndef KAB_EMBEDDED | 1557 | #ifndef KAB_EMBEDDED |
1558 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1558 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1559 | topLayout->setSpacing( KDialogBase::spacingHint() ); | 1559 | topLayout->setSpacing( KDialogBase::spacingHint() ); |
1560 | 1560 | ||
1561 | mExtensionBarSplitter = new QSplitter( this ); | 1561 | mExtensionBarSplitter = new QSplitter( this ); |
1562 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); | 1562 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); |
1563 | 1563 | ||
1564 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); | 1564 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); |
1565 | 1565 | ||
1566 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1566 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1567 | mIncSearchWidget = new IncSearchWidget( viewSpace ); | 1567 | mIncSearchWidget = new IncSearchWidget( viewSpace ); |
1568 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1568 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1569 | SLOT( incrementalSearch( const QString& ) ) ); | 1569 | SLOT( incrementalSearch( const QString& ) ) ); |
1570 | 1570 | ||
1571 | mViewManager = new ViewManager( this, viewSpace ); | 1571 | mViewManager = new ViewManager( this, viewSpace ); |
1572 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1572 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1573 | 1573 | ||
1574 | mDetails = new ViewContainer( mDetailsSplitter ); | 1574 | mDetails = new ViewContainer( mDetailsSplitter ); |
1575 | 1575 | ||
1576 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1576 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1577 | 1577 | ||
1578 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1578 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1579 | 1579 | ||
1580 | topLayout->addWidget( mExtensionBarSplitter ); | 1580 | topLayout->addWidget( mExtensionBarSplitter ); |
1581 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); | 1581 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); |
1582 | topLayout->addWidget( mJumpButtonBar ); | 1582 | topLayout->addWidget( mJumpButtonBar ); |
1583 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); | 1583 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); |
1584 | 1584 | ||
1585 | mXXPortManager = new XXPortManager( this, this ); | 1585 | mXXPortManager = new XXPortManager( this, this ); |
1586 | 1586 | ||
1587 | #else //KAB_EMBEDDED | 1587 | #else //KAB_EMBEDDED |
1588 | //US initialize viewMenu before settingup viewmanager. | 1588 | //US initialize viewMenu before settingup viewmanager. |
1589 | // Viewmanager needs this menu to plugin submenues. | 1589 | // Viewmanager needs this menu to plugin submenues. |
1590 | viewMenu = new QPopupMenu( this ); | 1590 | viewMenu = new QPopupMenu( this ); |
1591 | settingsMenu = new QPopupMenu( this ); | 1591 | settingsMenu = new QPopupMenu( this ); |
1592 | //filterMenu = new QPopupMenu( this ); | 1592 | //filterMenu = new QPopupMenu( this ); |
1593 | ImportMenu = new QPopupMenu( this ); | 1593 | ImportMenu = new QPopupMenu( this ); |
1594 | ExportMenu = new QPopupMenu( this ); | 1594 | ExportMenu = new QPopupMenu( this ); |
1595 | syncMenu = new QPopupMenu( this ); | 1595 | syncMenu = new QPopupMenu( this ); |
1596 | changeMenu= new QPopupMenu( this ); | 1596 | changeMenu= new QPopupMenu( this ); |
1597 | 1597 | ||
1598 | //US since we have no splitter for the embedded system, setup | 1598 | //US since we have no splitter for the embedded system, setup |
1599 | // a layout with two frames. One left and one right. | 1599 | // a layout with two frames. One left and one right. |
1600 | 1600 | ||
1601 | QBoxLayout *topLayout; | 1601 | QBoxLayout *topLayout; |
1602 | 1602 | ||
1603 | // = new QHBoxLayout( this ); | 1603 | // = new QHBoxLayout( this ); |
1604 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); | 1604 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); |
1605 | 1605 | ||
1606 | // QWidget *mainBox = new QWidget( this ); | 1606 | // QWidget *mainBox = new QWidget( this ); |
1607 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); | 1607 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); |
1608 | 1608 | ||
1609 | #ifdef DESKTOP_VERSION | 1609 | #ifdef DESKTOP_VERSION |
1610 | topLayout = new QHBoxLayout( this ); | 1610 | topLayout = new QHBoxLayout( this ); |
1611 | 1611 | ||
1612 | 1612 | ||
1613 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1613 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1614 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1614 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1615 | 1615 | ||
1616 | topLayout->addWidget(mMiniSplitter ); | 1616 | topLayout->addWidget(mMiniSplitter ); |
1617 | 1617 | ||
1618 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); | 1618 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); |
1619 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1619 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1620 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); | 1620 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); |
1621 | mDetails = new ViewContainer( mMiniSplitter ); | 1621 | mDetails = new ViewContainer( mMiniSplitter ); |
1622 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1622 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1623 | #else | 1623 | #else |
1624 | if ( QApplication::desktop()->width() > 480 ) { | 1624 | if ( QApplication::desktop()->width() > 480 ) { |
1625 | topLayout = new QHBoxLayout( this ); | 1625 | topLayout = new QHBoxLayout( this ); |
1626 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1626 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1627 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1627 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1628 | } else { | 1628 | } else { |
1629 | 1629 | ||
1630 | topLayout = new QHBoxLayout( this ); | 1630 | topLayout = new QHBoxLayout( this ); |
1631 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); | 1631 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); |
1632 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1632 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1633 | } | 1633 | } |
1634 | 1634 | ||
1635 | topLayout->addWidget(mMiniSplitter ); | 1635 | topLayout->addWidget(mMiniSplitter ); |
1636 | mViewManager = new ViewManager( this, mMiniSplitter ); | 1636 | mViewManager = new ViewManager( this, mMiniSplitter ); |
1637 | mDetails = new ViewContainer( mMiniSplitter ); | 1637 | mDetails = new ViewContainer( mMiniSplitter ); |
1638 | 1638 | ||
1639 | 1639 | ||
1640 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); | 1640 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); |
1641 | #endif | 1641 | #endif |
1642 | //eh->hide(); | 1642 | //eh->hide(); |
1643 | // topLayout->addWidget(mExtensionManager ); | 1643 | // topLayout->addWidget(mExtensionManager ); |
1644 | 1644 | ||
1645 | 1645 | ||
1646 | /*US | 1646 | /*US |
1647 | #ifndef KAB_NOSPLITTER | 1647 | #ifndef KAB_NOSPLITTER |
1648 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1648 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1649 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1649 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1650 | topLayout->setSpacing( 10 ); | 1650 | topLayout->setSpacing( 10 ); |
1651 | 1651 | ||
1652 | mDetailsSplitter = new QSplitter( this ); | 1652 | mDetailsSplitter = new QSplitter( this ); |
1653 | 1653 | ||
1654 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1654 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1655 | 1655 | ||
1656 | mViewManager = new ViewManager( this, viewSpace ); | 1656 | mViewManager = new ViewManager( this, viewSpace ); |
1657 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1657 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1658 | 1658 | ||
1659 | mDetails = new ViewContainer( mDetailsSplitter ); | 1659 | mDetails = new ViewContainer( mDetailsSplitter ); |
1660 | 1660 | ||
1661 | topLayout->addWidget( mDetailsSplitter ); | 1661 | topLayout->addWidget( mDetailsSplitter ); |
1662 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1662 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1663 | #else //KAB_NOSPLITTER | 1663 | #else //KAB_NOSPLITTER |
1664 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1664 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1665 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1665 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1666 | topLayout->setSpacing( 10 ); | 1666 | topLayout->setSpacing( 10 ); |
1667 | 1667 | ||
1668 | // mDetailsSplitter = new QSplitter( this ); | 1668 | // mDetailsSplitter = new QSplitter( this ); |
1669 | 1669 | ||
1670 | QVBox *viewSpace = new QVBox( this ); | 1670 | QVBox *viewSpace = new QVBox( this ); |
1671 | 1671 | ||
1672 | mViewManager = new ViewManager( this, viewSpace ); | 1672 | mViewManager = new ViewManager( this, viewSpace ); |
1673 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1673 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1674 | 1674 | ||
1675 | mDetails = new ViewContainer( this ); | 1675 | mDetails = new ViewContainer( this ); |
1676 | 1676 | ||
1677 | topLayout->addWidget( viewSpace ); | 1677 | topLayout->addWidget( viewSpace ); |
1678 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1678 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1679 | topLayout->addWidget( mDetails ); | 1679 | topLayout->addWidget( mDetails ); |
1680 | #endif //KAB_NOSPLITTER | 1680 | #endif //KAB_NOSPLITTER |
1681 | */ | 1681 | */ |
1682 | 1682 | ||
1683 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); | 1683 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); |
1684 | syncManager->setBlockSave(false); | 1684 | syncManager->setBlockSave(false); |
1685 | 1685 | ||
1686 | connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); | 1686 | connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); |
1687 | connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); | 1687 | connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); |
1688 | syncManager->setDefaultFileName( sentSyncFile()); | 1688 | syncManager->setDefaultFileName( sentSyncFile()); |
1689 | //connect(syncManager , SIGNAL( ), this, SLOT( ) ); | 1689 | //connect(syncManager , SIGNAL( ), this, SLOT( ) ); |
1690 | 1690 | ||
1691 | #endif //KAB_EMBEDDED | 1691 | #endif //KAB_EMBEDDED |
1692 | initActions(); | 1692 | initActions(); |
1693 | 1693 | ||
1694 | #ifdef KAB_EMBEDDED | 1694 | #ifdef KAB_EMBEDDED |
1695 | addActionsManually(); | 1695 | addActionsManually(); |
1696 | //US make sure the export and import menues are initialized before creating the xxPortManager. | 1696 | //US make sure the export and import menues are initialized before creating the xxPortManager. |
1697 | mXXPortManager = new XXPortManager( this, this ); | 1697 | mXXPortManager = new XXPortManager( this, this ); |
1698 | 1698 | ||
1699 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); | 1699 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); |
1700 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); | 1700 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); |
1701 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1701 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1702 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); | 1702 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); |
1703 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); | 1703 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); |
1704 | // mIncSearchWidget->hide(); | 1704 | // mIncSearchWidget->hide(); |
1705 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1705 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1706 | SLOT( incrementalSearch( const QString& ) ) ); | 1706 | SLOT( incrementalSearch( const QString& ) ) ); |
1707 | 1707 | ||
1708 | 1708 | ||
1709 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1709 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1710 | 1710 | ||
1711 | topLayout->addWidget( mJumpButtonBar ); | 1711 | topLayout->addWidget( mJumpButtonBar ); |
1712 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); | 1712 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); |
1713 | 1713 | ||
1714 | // mMainWindow->getIconToolBar()->raise(); | 1714 | // mMainWindow->getIconToolBar()->raise(); |
1715 | 1715 | ||
1716 | #endif //KAB_EMBEDDED | 1716 | #endif //KAB_EMBEDDED |
1717 | 1717 | ||
1718 | } | 1718 | } |
1719 | void KABCore::initActions() | 1719 | void KABCore::initActions() |
1720 | { | 1720 | { |
1721 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1721 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1722 | 1722 | ||
1723 | #ifndef KAB_EMBEDDED | 1723 | #ifndef KAB_EMBEDDED |
1724 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), | 1724 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), |
1725 | SLOT( clipboardDataChanged() ) ); | 1725 | SLOT( clipboardDataChanged() ) ); |
1726 | #endif //KAB_EMBEDDED | 1726 | #endif //KAB_EMBEDDED |
1727 | 1727 | ||
1728 | // file menu | 1728 | // file menu |
1729 | if ( mIsPart ) { | 1729 | if ( mIsPart ) { |
1730 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, | 1730 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, |
1731 | SLOT( sendMail() ), actionCollection(), | 1731 | SLOT( sendMail() ), actionCollection(), |
1732 | "kaddressbook_mail" ); | 1732 | "kaddressbook_mail" ); |
1733 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, | 1733 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, |
1734 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); | 1734 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); |
1735 | 1735 | ||
1736 | } else { | 1736 | } else { |
1737 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); | 1737 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); |
1738 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); | 1738 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); |
1739 | } | 1739 | } |
1740 | 1740 | ||
1741 | 1741 | ||
1742 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, | 1742 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, |
1743 | SLOT( save() ), actionCollection(), "file_sync" ); | 1743 | SLOT( save() ), actionCollection(), "file_sync" ); |
1744 | 1744 | ||
1745 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, | 1745 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, |
1746 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); | 1746 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); |
1747 | 1747 | ||
1748 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, | 1748 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, |
1749 | this, SLOT( mailVCard() ), | 1749 | this, SLOT( mailVCard() ), |
1750 | actionCollection(), "file_mail_vcard"); | 1750 | actionCollection(), "file_mail_vcard"); |
1751 | 1751 | ||
1752 | mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this, | 1752 | mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this, |
1753 | SLOT( export2phone() ), actionCollection(), | 1753 | SLOT( export2phone() ), actionCollection(), |
1754 | "kaddressbook_ex2phone" ); | 1754 | "kaddressbook_ex2phone" ); |
1755 | 1755 | ||
1756 | mActionBeamVCard = 0; | 1756 | mActionBeamVCard = 0; |
1757 | mActionBeam = 0; | 1757 | mActionBeam = 0; |
1758 | 1758 | ||
1759 | #ifndef DESKTOP_VERSION | 1759 | #ifndef DESKTOP_VERSION |
1760 | if ( Ir::supported() ) { | 1760 | if ( Ir::supported() ) { |
1761 | mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, | 1761 | mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, |
1762 | SLOT( beamVCard() ), actionCollection(), | 1762 | SLOT( beamVCard() ), actionCollection(), |
1763 | "kaddressbook_beam_vcard" ); | 1763 | "kaddressbook_beam_vcard" ); |
1764 | 1764 | ||
1765 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, | 1765 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, |
1766 | SLOT( beamMySelf() ), actionCollection(), | 1766 | SLOT( beamMySelf() ), actionCollection(), |
1767 | "kaddressbook_beam_myself" ); | 1767 | "kaddressbook_beam_myself" ); |
1768 | } | 1768 | } |
1769 | #endif | 1769 | #endif |
1770 | 1770 | ||
1771 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, | 1771 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, |
1772 | this, SLOT( editContact2() ), | 1772 | this, SLOT( editContact2() ), |
1773 | actionCollection(), "file_properties" ); | 1773 | actionCollection(), "file_properties" ); |
1774 | 1774 | ||
1775 | #ifdef KAB_EMBEDDED | 1775 | #ifdef KAB_EMBEDDED |
1776 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); | 1776 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); |
1777 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, | 1777 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, |
1778 | mMainWindow, SLOT( exit() ), | 1778 | mMainWindow, SLOT( exit() ), |
1779 | actionCollection(), "quit" ); | 1779 | actionCollection(), "quit" ); |
1780 | #endif //KAB_EMBEDDED | 1780 | #endif //KAB_EMBEDDED |
1781 | 1781 | ||
1782 | // edit menu | 1782 | // edit menu |
1783 | if ( mIsPart ) { | 1783 | if ( mIsPart ) { |
1784 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, | 1784 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, |
1785 | SLOT( copyContacts() ), actionCollection(), | 1785 | SLOT( copyContacts() ), actionCollection(), |
1786 | "kaddressbook_copy" ); | 1786 | "kaddressbook_copy" ); |
1787 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, | 1787 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, |
1788 | SLOT( cutContacts() ), actionCollection(), | 1788 | SLOT( cutContacts() ), actionCollection(), |
1789 | "kaddressbook_cut" ); | 1789 | "kaddressbook_cut" ); |
1790 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, | 1790 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, |
1791 | SLOT( pasteContacts() ), actionCollection(), | 1791 | SLOT( pasteContacts() ), actionCollection(), |
1792 | "kaddressbook_paste" ); | 1792 | "kaddressbook_paste" ); |
1793 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, | 1793 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, |
1794 | SLOT( selectAllContacts() ), actionCollection(), | 1794 | SLOT( selectAllContacts() ), actionCollection(), |
1795 | "kaddressbook_select_all" ); | 1795 | "kaddressbook_select_all" ); |
1796 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, | 1796 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, |
1797 | SLOT( undo() ), actionCollection(), | 1797 | SLOT( undo() ), actionCollection(), |
1798 | "kaddressbook_undo" ); | 1798 | "kaddressbook_undo" ); |
1799 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, | 1799 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, |
1800 | this, SLOT( redo() ), actionCollection(), | 1800 | this, SLOT( redo() ), actionCollection(), |
1801 | "kaddressbook_redo" ); | 1801 | "kaddressbook_redo" ); |
1802 | } else { | 1802 | } else { |
1803 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); | 1803 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); |
1804 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); | 1804 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); |
1805 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); | 1805 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); |
1806 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); | 1806 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); |
1807 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); | 1807 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); |
1808 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); | 1808 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); |
1809 | } | 1809 | } |
1810 | 1810 | ||
1811 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", | 1811 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", |
1812 | Key_Delete, this, SLOT( deleteContacts() ), | 1812 | Key_Delete, this, SLOT( deleteContacts() ), |
1813 | actionCollection(), "edit_delete" ); | 1813 | actionCollection(), "edit_delete" ); |
1814 | 1814 | ||
1815 | mActionUndo->setEnabled( false ); | 1815 | mActionUndo->setEnabled( false ); |
1816 | mActionRedo->setEnabled( false ); | 1816 | mActionRedo->setEnabled( false ); |
1817 | 1817 | ||
1818 | // settings menu | 1818 | // settings menu |
1819 | #ifdef KAB_EMBEDDED | 1819 | #ifdef KAB_EMBEDDED |
1820 | //US special menuentry to configure the addressbook resources. On KDE | 1820 | //US special menuentry to configure the addressbook resources. On KDE |
1821 | // you do that through the control center !!! | 1821 | // you do that through the control center !!! |
1822 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, | 1822 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, |
1823 | SLOT( configureResources() ), actionCollection(), | 1823 | SLOT( configureResources() ), actionCollection(), |
1824 | "kaddressbook_configure_resources" ); | 1824 | "kaddressbook_configure_resources" ); |
1825 | #endif //KAB_EMBEDDED | 1825 | #endif //KAB_EMBEDDED |
1826 | 1826 | ||
1827 | if ( mIsPart ) { | 1827 | if ( mIsPart ) { |
1828 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, | 1828 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, |
1829 | SLOT( openConfigDialog() ), actionCollection(), | 1829 | SLOT( openConfigDialog() ), actionCollection(), |
1830 | "kaddressbook_configure" ); | 1830 | "kaddressbook_configure" ); |
1831 | 1831 | ||
1832 | mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, | 1832 | mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, |
1833 | this, SLOT( configureKeyBindings() ), actionCollection(), | 1833 | this, SLOT( configureKeyBindings() ), actionCollection(), |
1834 | "kaddressbook_configure_shortcuts" ); | 1834 | "kaddressbook_configure_shortcuts" ); |
1835 | #ifdef KAB_EMBEDDED | 1835 | #ifdef KAB_EMBEDDED |
1836 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); | 1836 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); |
1837 | mActionConfigureToolbars->setEnabled( false ); | 1837 | mActionConfigureToolbars->setEnabled( false ); |
1838 | #endif //KAB_EMBEDDED | 1838 | #endif //KAB_EMBEDDED |
1839 | 1839 | ||
1840 | } else { | 1840 | } else { |
1841 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); | 1841 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); |
1842 | 1842 | ||
1843 | mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); | 1843 | mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); |
1844 | } | 1844 | } |
1845 | 1845 | ||
1846 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, | 1846 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, |
1847 | actionCollection(), "options_show_jump_bar" ); | 1847 | actionCollection(), "options_show_jump_bar" ); |
1848 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); | 1848 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); |
1849 | 1849 | ||
1850 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, | 1850 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, |
1851 | actionCollection(), "options_show_details" ); | 1851 | actionCollection(), "options_show_details" ); |
1852 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); | 1852 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); |
1853 | 1853 | ||
1854 | // misc | 1854 | // misc |
1855 | // only enable LDAP lookup if we can handle the protocol | 1855 | // only enable LDAP lookup if we can handle the protocol |
1856 | #ifndef KAB_EMBEDDED | 1856 | #ifndef KAB_EMBEDDED |
1857 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { | 1857 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { |
1858 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, | 1858 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, |
1859 | this, SLOT( openLDAPDialog() ), actionCollection(), | 1859 | this, SLOT( openLDAPDialog() ), actionCollection(), |
1860 | "ldap_lookup" ); | 1860 | "ldap_lookup" ); |
1861 | } | 1861 | } |
1862 | #else //KAB_EMBEDDED | 1862 | #else //KAB_EMBEDDED |
1863 | //qDebug("KABCore::initActions() LDAP has to be implemented"); | 1863 | //qDebug("KABCore::initActions() LDAP has to be implemented"); |
1864 | #endif //KAB_EMBEDDED | 1864 | #endif //KAB_EMBEDDED |
1865 | 1865 | ||
1866 | 1866 | ||
1867 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, | 1867 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, |
1868 | SLOT( setWhoAmI() ), actionCollection(), | 1868 | SLOT( setWhoAmI() ), actionCollection(), |
1869 | "set_personal" ); | 1869 | "set_personal" ); |
1870 | 1870 | ||
1871 | 1871 | ||
1872 | 1872 | ||
1873 | 1873 | ||
1874 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, | 1874 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, |
1875 | SLOT( setCategories() ), actionCollection(), | 1875 | SLOT( setCategories() ), actionCollection(), |
1876 | "edit_set_categories" ); | 1876 | "edit_set_categories" ); |
1877 | 1877 | ||
1878 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, | 1878 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, |
1879 | SLOT( removeVoice() ), actionCollection(), | 1879 | SLOT( removeVoice() ), actionCollection(), |
1880 | "remove_voice" ); | 1880 | "remove_voice" ); |
1881 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, | 1881 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, |
1882 | SLOT( importFromOL() ), actionCollection(), | 1882 | SLOT( importFromOL() ), actionCollection(), |
1883 | "import_OL" ); | 1883 | "import_OL" ); |
1884 | #ifdef KAB_EMBEDDED | 1884 | #ifdef KAB_EMBEDDED |
1885 | mActionLicence = new KAction( i18n( "Licence" ), 0, | 1885 | mActionLicence = new KAction( i18n( "Licence" ), 0, |
1886 | this, SLOT( showLicence() ), actionCollection(), | 1886 | this, SLOT( showLicence() ), actionCollection(), |
1887 | "licence_about_data" ); | 1887 | "licence_about_data" ); |
1888 | mActionFaq = new KAction( i18n( "Faq" ), 0, | 1888 | mActionFaq = new KAction( i18n( "Faq" ), 0, |
1889 | this, SLOT( faq() ), actionCollection(), | 1889 | this, SLOT( faq() ), actionCollection(), |
1890 | "faq_about_data" ); | 1890 | "faq_about_data" ); |
1891 | 1891 | ||
1892 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, | 1892 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, |
1893 | this, SLOT( createAboutData() ), actionCollection(), | 1893 | this, SLOT( createAboutData() ), actionCollection(), |
1894 | "kaddressbook_about_data" ); | 1894 | "kaddressbook_about_data" ); |
1895 | #endif //KAB_EMBEDDED | 1895 | #endif //KAB_EMBEDDED |
1896 | 1896 | ||
1897 | clipboardDataChanged(); | 1897 | clipboardDataChanged(); |
1898 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1898 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1899 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1899 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1900 | } | 1900 | } |
1901 | 1901 | ||
1902 | //US we need this function, to plug all actions into the correct menues. | 1902 | //US we need this function, to plug all actions into the correct menues. |
1903 | // KDE uses a XML format to plug the actions, but we work her without this overhead. | 1903 | // KDE uses a XML format to plug the actions, but we work her without this overhead. |
1904 | void KABCore::addActionsManually() | 1904 | void KABCore::addActionsManually() |
1905 | { | 1905 | { |
1906 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1906 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1907 | 1907 | ||
1908 | #ifdef KAB_EMBEDDED | 1908 | #ifdef KAB_EMBEDDED |
1909 | QPopupMenu *fileMenu = new QPopupMenu( this ); | 1909 | QPopupMenu *fileMenu = new QPopupMenu( this ); |
1910 | QPopupMenu *editMenu = new QPopupMenu( this ); | 1910 | QPopupMenu *editMenu = new QPopupMenu( this ); |
1911 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 1911 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
1912 | 1912 | ||
1913 | KToolBar* tb = mMainWindow->toolBar(); | 1913 | KToolBar* tb = mMainWindow->toolBar(); |
1914 | 1914 | ||
1915 | #ifdef DESKTOP_VERSION | 1915 | #ifdef DESKTOP_VERSION |
1916 | QMenuBar* mb = mMainWindow->menuBar(); | 1916 | QMenuBar* mb = mMainWindow->menuBar(); |
1917 | 1917 | ||
1918 | //US setup menubar. | 1918 | //US setup menubar. |
1919 | //Disable the following block if you do not want to have a menubar. | 1919 | //Disable the following block if you do not want to have a menubar. |
1920 | mb->insertItem( "&File", fileMenu ); | 1920 | mb->insertItem( "&File", fileMenu ); |
1921 | mb->insertItem( "&Edit", editMenu ); | 1921 | mb->insertItem( "&Edit", editMenu ); |
1922 | mb->insertItem( "&View", viewMenu ); | 1922 | mb->insertItem( "&View", viewMenu ); |
1923 | mb->insertItem( "&Settings", settingsMenu ); | 1923 | mb->insertItem( "&Settings", settingsMenu ); |
1924 | mb->insertItem( i18n("Synchronize"), syncMenu ); | 1924 | mb->insertItem( i18n("Synchronize"), syncMenu ); |
1925 | mb->insertItem( "&Change selected", changeMenu ); | 1925 | mb->insertItem( "&Change selected", changeMenu ); |
1926 | mb->insertItem( "&Help", helpMenu ); | 1926 | mb->insertItem( "&Help", helpMenu ); |
1927 | mIncSearchWidget = new IncSearchWidget( tb ); | 1927 | mIncSearchWidget = new IncSearchWidget( tb ); |
1928 | // tb->insertWidget(-1, 0, mIncSearchWidget); | 1928 | // tb->insertWidget(-1, 0, mIncSearchWidget); |
1929 | 1929 | ||
1930 | #else | 1930 | #else |
1931 | //US setup toolbar | 1931 | //US setup toolbar |
1932 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); | 1932 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); |
1933 | QPopupMenu *popupBarTB = new QPopupMenu( this ); | 1933 | QPopupMenu *popupBarTB = new QPopupMenu( this ); |
1934 | menuBarTB->insertItem( "ME", popupBarTB); | 1934 | menuBarTB->insertItem( "ME", popupBarTB); |
1935 | tb->insertWidget(-1, 0, menuBarTB); | 1935 | tb->insertWidget(-1, 0, menuBarTB); |
1936 | mIncSearchWidget = new IncSearchWidget( tb ); | 1936 | mIncSearchWidget = new IncSearchWidget( tb ); |
1937 | 1937 | ||
1938 | tb->enableMoving(false); | 1938 | tb->enableMoving(false); |
1939 | popupBarTB->insertItem( "&File", fileMenu ); | 1939 | popupBarTB->insertItem( "&File", fileMenu ); |
1940 | popupBarTB->insertItem( "&Edit", editMenu ); | 1940 | popupBarTB->insertItem( "&Edit", editMenu ); |
1941 | popupBarTB->insertItem( "&View", viewMenu ); | 1941 | popupBarTB->insertItem( "&View", viewMenu ); |
1942 | popupBarTB->insertItem( "&Settings", settingsMenu ); | 1942 | popupBarTB->insertItem( "&Settings", settingsMenu ); |
1943 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); | 1943 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); |
1944 | mViewManager->getFilterAction()->plug ( popupBarTB); | 1944 | mViewManager->getFilterAction()->plug ( popupBarTB); |
1945 | popupBarTB->insertItem( "&Change selected", changeMenu ); | 1945 | popupBarTB->insertItem( "&Change selected", changeMenu ); |
1946 | popupBarTB->insertItem( "&Help", helpMenu ); | 1946 | popupBarTB->insertItem( "&Help", helpMenu ); |
1947 | if (QApplication::desktop()->width() > 320 ) { | 1947 | if (QApplication::desktop()->width() > 320 ) { |
1948 | // mViewManager->getFilterAction()->plug ( tb); | 1948 | // mViewManager->getFilterAction()->plug ( tb); |
1949 | } | 1949 | } |
1950 | #endif | 1950 | #endif |
1951 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1951 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1952 | 1952 | ||
1953 | 1953 | ||
1954 | 1954 | ||
1955 | //US Now connect the actions with the menue entries. | 1955 | //US Now connect the actions with the menue entries. |
1956 | mActionPrint->plug( fileMenu ); | 1956 | mActionPrint->plug( fileMenu ); |
1957 | mActionMail->plug( fileMenu ); | 1957 | mActionMail->plug( fileMenu ); |
1958 | fileMenu->insertSeparator(); | 1958 | fileMenu->insertSeparator(); |
1959 | 1959 | ||
1960 | mActionNewContact->plug( fileMenu ); | 1960 | mActionNewContact->plug( fileMenu ); |
1961 | mActionNewContact->plug( tb ); | 1961 | mActionNewContact->plug( tb ); |
1962 | 1962 | ||
1963 | mActionEditAddressee->plug( fileMenu ); | 1963 | mActionEditAddressee->plug( fileMenu ); |
1964 | if ((KGlobal::getDesktopSize() > KGlobal::Small ) || | 1964 | if ((KGlobal::getDesktopSize() > KGlobal::Small ) || |
1965 | (!KABPrefs::instance()->mMultipleViewsAtOnce )) | 1965 | (!KABPrefs::instance()->mMultipleViewsAtOnce )) |
1966 | mActionEditAddressee->plug( tb ); | 1966 | mActionEditAddressee->plug( tb ); |
1967 | 1967 | ||
1968 | fileMenu->insertSeparator(); | 1968 | fileMenu->insertSeparator(); |
1969 | mActionSave->plug( fileMenu ); | 1969 | mActionSave->plug( fileMenu ); |
1970 | fileMenu->insertItem( "&Import", ImportMenu ); | 1970 | fileMenu->insertItem( "&Import", ImportMenu ); |
1971 | fileMenu->insertItem( "&Export", ExportMenu ); | 1971 | fileMenu->insertItem( "&Export", ExportMenu ); |
1972 | fileMenu->insertSeparator(); | 1972 | fileMenu->insertSeparator(); |
1973 | mActionMailVCard->plug( fileMenu ); | 1973 | mActionMailVCard->plug( fileMenu ); |
1974 | #ifndef DESKTOP_VERSION | 1974 | #ifndef DESKTOP_VERSION |
1975 | if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); | 1975 | if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); |
1976 | if ( Ir::supported() ) mActionBeam->plug(fileMenu ); | 1976 | if ( Ir::supported() ) mActionBeam->plug(fileMenu ); |
1977 | #endif | 1977 | #endif |
1978 | fileMenu->insertSeparator(); | 1978 | fileMenu->insertSeparator(); |
1979 | mActionQuit->plug( fileMenu ); | 1979 | mActionQuit->plug( fileMenu ); |
1980 | #ifdef _WIN32_ | 1980 | #ifdef _WIN32_ |
1981 | mActionImportOL->plug( ImportMenu ); | 1981 | mActionImportOL->plug( ImportMenu ); |
1982 | #endif | 1982 | #endif |
1983 | // edit menu | 1983 | // edit menu |
1984 | mActionUndo->plug( editMenu ); | 1984 | mActionUndo->plug( editMenu ); |
1985 | mActionRedo->plug( editMenu ); | 1985 | mActionRedo->plug( editMenu ); |
1986 | editMenu->insertSeparator(); | 1986 | editMenu->insertSeparator(); |
1987 | mActionCut->plug( editMenu ); | 1987 | mActionCut->plug( editMenu ); |
1988 | mActionCopy->plug( editMenu ); | 1988 | mActionCopy->plug( editMenu ); |
1989 | mActionPaste->plug( editMenu ); | 1989 | mActionPaste->plug( editMenu ); |
1990 | mActionDelete->plug( editMenu ); | 1990 | mActionDelete->plug( editMenu ); |
1991 | editMenu->insertSeparator(); | 1991 | editMenu->insertSeparator(); |
1992 | mActionSelectAll->plug( editMenu ); | 1992 | mActionSelectAll->plug( editMenu ); |
1993 | 1993 | ||
1994 | mActionRemoveVoice->plug( changeMenu ); | 1994 | mActionRemoveVoice->plug( changeMenu ); |
1995 | // settings menu | 1995 | // settings menu |
1996 | //US special menuentry to configure the addressbook resources. On KDE | 1996 | //US special menuentry to configure the addressbook resources. On KDE |
1997 | // you do that through the control center !!! | 1997 | // you do that through the control center !!! |
1998 | mActionConfigResources->plug( settingsMenu ); | 1998 | mActionConfigResources->plug( settingsMenu ); |
1999 | settingsMenu->insertSeparator(); | 1999 | settingsMenu->insertSeparator(); |
2000 | 2000 | ||
2001 | mActionConfigKAddressbook->plug( settingsMenu ); | 2001 | mActionConfigKAddressbook->plug( settingsMenu ); |
2002 | 2002 | ||
2003 | if ( mIsPart ) { | 2003 | if ( mIsPart ) { |
2004 | mActionConfigShortcuts->plug( settingsMenu ); | 2004 | mActionConfigShortcuts->plug( settingsMenu ); |
2005 | mActionConfigureToolbars->plug( settingsMenu ); | 2005 | mActionConfigureToolbars->plug( settingsMenu ); |
2006 | 2006 | ||
2007 | } else { | 2007 | } else { |
2008 | mActionKeyBindings->plug( settingsMenu ); | 2008 | mActionKeyBindings->plug( settingsMenu ); |
2009 | } | 2009 | } |
2010 | 2010 | ||
2011 | settingsMenu->insertSeparator(); | 2011 | settingsMenu->insertSeparator(); |
2012 | 2012 | ||
2013 | mActionJumpBar->plug( settingsMenu ); | 2013 | mActionJumpBar->plug( settingsMenu ); |
2014 | mActionDetails->plug( settingsMenu ); | 2014 | mActionDetails->plug( settingsMenu ); |
2015 | if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) | 2015 | if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) |
2016 | mActionDetails->plug( tb ); | 2016 | mActionDetails->plug( tb ); |
2017 | settingsMenu->insertSeparator(); | 2017 | settingsMenu->insertSeparator(); |
2018 | 2018 | ||
2019 | mActionWhoAmI->plug( settingsMenu ); | 2019 | mActionWhoAmI->plug( settingsMenu ); |
2020 | mActionCategories->plug( settingsMenu ); | 2020 | mActionCategories->plug( settingsMenu ); |
2021 | 2021 | ||
2022 | mActionLicence->plug( helpMenu ); | 2022 | mActionLicence->plug( helpMenu ); |
2023 | mActionFaq->plug( helpMenu ); | 2023 | mActionFaq->plug( helpMenu ); |
2024 | mActionAboutKAddressbook->plug( helpMenu ); | 2024 | mActionAboutKAddressbook->plug( helpMenu ); |
2025 | 2025 | ||
2026 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { | 2026 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { |
2027 | 2027 | ||
2028 | mActionSave->plug( tb ); | 2028 | mActionSave->plug( tb ); |
2029 | mViewManager->getFilterAction()->plug ( tb); | 2029 | mViewManager->getFilterAction()->plug ( tb); |
2030 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { | 2030 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { |
2031 | mActionUndo->plug( tb ); | 2031 | mActionUndo->plug( tb ); |
2032 | mActionDelete->plug( tb ); | 2032 | mActionDelete->plug( tb ); |
2033 | mActionRedo->plug( tb ); | 2033 | mActionRedo->plug( tb ); |
2034 | } | 2034 | } |
2035 | } | 2035 | } |
2036 | //mActionQuit->plug ( tb ); | 2036 | //mActionQuit->plug ( tb ); |
2037 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); | 2037 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); |
2038 | 2038 | ||
2039 | //US link the searchwidget first to this. | 2039 | //US link the searchwidget first to this. |
2040 | // The real linkage to the toolbar happens later. | 2040 | // The real linkage to the toolbar happens later. |
2041 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); | 2041 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); |
2042 | //US tb->insertItem( mIncSearchWidget ); | 2042 | //US tb->insertItem( mIncSearchWidget ); |
2043 | /*US | 2043 | /*US |
2044 | mIncSearchWidget = new IncSearchWidget( tb ); | 2044 | mIncSearchWidget = new IncSearchWidget( tb ); |
2045 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 2045 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
2046 | SLOT( incrementalSearch( const QString& ) ) ); | 2046 | SLOT( incrementalSearch( const QString& ) ) ); |
2047 | 2047 | ||
2048 | mJumpButtonBar = new JumpButtonBar( this, this ); | 2048 | mJumpButtonBar = new JumpButtonBar( this, this ); |
2049 | 2049 | ||
2050 | //US topLayout->addWidget( mJumpButtonBar ); | 2050 | //US topLayout->addWidget( mJumpButtonBar ); |
2051 | this->layout()->add( mJumpButtonBar ); | 2051 | this->layout()->add( mJumpButtonBar ); |
2052 | */ | 2052 | */ |
2053 | 2053 | ||
2054 | #endif //KAB_EMBEDDED | 2054 | #endif //KAB_EMBEDDED |
2055 | 2055 | ||
2056 | mActionExport2phone->plug( ExportMenu ); | 2056 | mActionExport2phone->plug( ExportMenu ); |
2057 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); | 2057 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); |
2058 | syncManager->fillSyncMenu(); | 2058 | syncManager->fillSyncMenu(); |
2059 | 2059 | ||
2060 | } | 2060 | } |
2061 | void KABCore::showLicence() | 2061 | void KABCore::showLicence() |
2062 | { | 2062 | { |
2063 | KApplication::showLicence(); | 2063 | KApplication::showLicence(); |
2064 | } | 2064 | } |
2065 | void KABCore::removeVoice() | 2065 | void KABCore::removeVoice() |
2066 | { | 2066 | { |
2067 | 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 ) | 2067 | 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 ) |
2068 | return; | 2068 | return; |
2069 | KABC::Addressee::List list = mViewManager->selectedAddressees(); | 2069 | KABC::Addressee::List list = mViewManager->selectedAddressees(); |
2070 | KABC::Addressee::List::Iterator it; | 2070 | KABC::Addressee::List::Iterator it; |
2071 | for ( it = list.begin(); it != list.end(); ++it ) { | 2071 | for ( it = list.begin(); it != list.end(); ++it ) { |
2072 | PhoneNumber::List phoneNumbers = (*it).phoneNumbers(); | 2072 | PhoneNumber::List phoneNumbers = (*it).phoneNumbers(); |
2073 | PhoneNumber::List::Iterator phoneIt; | 2073 | PhoneNumber::List::Iterator phoneIt; |
2074 | bool found = false; | 2074 | bool found = false; |
2075 | for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) { | 2075 | for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) { |
2076 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found | 2076 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found |
2077 | if ((*phoneIt).type() - PhoneNumber::Voice ) { | 2077 | if ((*phoneIt).type() - PhoneNumber::Voice ) { |
2078 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); | 2078 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); |
2079 | (*it).insertPhoneNumber( (*phoneIt) ); | 2079 | (*it).insertPhoneNumber( (*phoneIt) ); |
2080 | found = true; | 2080 | found = true; |
2081 | } | 2081 | } |
2082 | } | 2082 | } |
2083 | 2083 | ||
2084 | } | 2084 | } |
2085 | if ( found ) | 2085 | if ( found ) |
2086 | contactModified((*it) ); | 2086 | contactModified((*it) ); |
2087 | } | 2087 | } |
2088 | } | 2088 | } |
2089 | 2089 | ||
2090 | 2090 | ||
2091 | 2091 | ||
2092 | void KABCore::clipboardDataChanged() | 2092 | void KABCore::clipboardDataChanged() |
2093 | { | 2093 | { |
2094 | 2094 | ||
2095 | if ( mReadWrite ) | 2095 | if ( mReadWrite ) |
2096 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); | 2096 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); |
2097 | 2097 | ||
2098 | } | 2098 | } |
2099 | 2099 | ||
2100 | void KABCore::updateActionMenu() | 2100 | void KABCore::updateActionMenu() |
2101 | { | 2101 | { |
2102 | UndoStack *undo = UndoStack::instance(); | 2102 | UndoStack *undo = UndoStack::instance(); |
2103 | RedoStack *redo = RedoStack::instance(); | 2103 | RedoStack *redo = RedoStack::instance(); |
2104 | 2104 | ||
2105 | if ( undo->isEmpty() ) | 2105 | if ( undo->isEmpty() ) |
2106 | mActionUndo->setText( i18n( "Undo" ) ); | 2106 | mActionUndo->setText( i18n( "Undo" ) ); |
2107 | else | 2107 | else |
2108 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); | 2108 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); |
2109 | 2109 | ||
2110 | mActionUndo->setEnabled( !undo->isEmpty() ); | 2110 | mActionUndo->setEnabled( !undo->isEmpty() ); |
2111 | 2111 | ||
2112 | if ( !redo->top() ) | 2112 | if ( !redo->top() ) |
2113 | mActionRedo->setText( i18n( "Redo" ) ); | 2113 | mActionRedo->setText( i18n( "Redo" ) ); |
2114 | else | 2114 | else |
2115 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); | 2115 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); |
2116 | 2116 | ||
2117 | mActionRedo->setEnabled( !redo->isEmpty() ); | 2117 | mActionRedo->setEnabled( !redo->isEmpty() ); |
2118 | } | 2118 | } |
2119 | 2119 | ||
2120 | void KABCore::configureKeyBindings() | 2120 | void KABCore::configureKeyBindings() |
2121 | { | 2121 | { |
2122 | #ifndef KAB_EMBEDDED | 2122 | #ifndef KAB_EMBEDDED |
2123 | KKeyDialog::configure( actionCollection(), true ); | 2123 | KKeyDialog::configure( actionCollection(), true ); |
2124 | #else //KAB_EMBEDDED | 2124 | #else //KAB_EMBEDDED |
2125 | qDebug("KABCore::configureKeyBindings() not implemented"); | 2125 | qDebug("KABCore::configureKeyBindings() not implemented"); |
2126 | #endif //KAB_EMBEDDED | 2126 | #endif //KAB_EMBEDDED |
2127 | } | 2127 | } |
2128 | 2128 | ||
2129 | #ifdef KAB_EMBEDDED | 2129 | #ifdef KAB_EMBEDDED |
2130 | void KABCore::configureResources() | 2130 | void KABCore::configureResources() |
2131 | { | 2131 | { |
2132 | KRES::KCMKResources dlg( this, "" , 0 ); | 2132 | KRES::KCMKResources dlg( this, "" , 0 ); |
2133 | 2133 | ||
2134 | if ( !dlg.exec() ) | 2134 | if ( !dlg.exec() ) |
2135 | return; | 2135 | return; |
2136 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); | 2136 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); |
2137 | } | 2137 | } |
2138 | #endif //KAB_EMBEDDED | 2138 | #endif //KAB_EMBEDDED |
2139 | 2139 | ||
2140 | 2140 | ||
2141 | /* this method will be called through the QCop interface from Ko/Pi to select addresses | 2141 | /* this method will be called through the QCop interface from Ko/Pi to select addresses |
2142 | * for the attendees list of an event. | 2142 | * for the attendees list of an event. |
2143 | */ | 2143 | */ |
2144 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) | 2144 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) |
2145 | { | 2145 | { |
2146 | QStringList nameList; | 2146 | QStringList nameList; |
2147 | QStringList emailList; | 2147 | QStringList emailList; |
2148 | QStringList uidList; | 2148 | QStringList uidList; |
2149 | 2149 | ||
2150 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); | 2150 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); |
2151 | uint i=0; | 2151 | uint i=0; |
2152 | for (i=0; i < list.count(); i++) | 2152 | for (i=0; i < list.count(); i++) |
2153 | { | 2153 | { |
2154 | nameList.append(list[i].realName()); | 2154 | nameList.append(list[i].realName()); |
2155 | emailList.append(list[i].preferredEmail()); | 2155 | emailList.append(list[i].preferredEmail()); |
2156 | uidList.append(list[i].uid()); | 2156 | uidList.append(list[i].uid()); |
2157 | } | 2157 | } |
2158 | 2158 | ||
2159 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); | 2159 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); |
2160 | 2160 | ||
2161 | } | 2161 | } |
2162 | 2162 | ||
2163 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays | 2163 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays |
2164 | * to put them into the calendar. | 2164 | * to put them into the calendar. |
2165 | */ | 2165 | */ |
2166 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) | 2166 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) |
2167 | { | 2167 | { |
2168 | // qDebug("KABCore::requestForBirthdayList"); | 2168 | // qDebug("KABCore::requestForBirthdayList"); |
2169 | QStringList birthdayList; | 2169 | QStringList birthdayList; |
2170 | QStringList anniversaryList; | 2170 | QStringList anniversaryList; |
2171 | QStringList realNameList; | 2171 | QStringList realNameList; |
2172 | QStringList preferredEmailList; | 2172 | QStringList preferredEmailList; |
2173 | QStringList assembledNameList; | 2173 | QStringList assembledNameList; |
2174 | QStringList uidList; | 2174 | QStringList uidList; |
2175 | 2175 | ||
2176 | KABC::AddressBook::Iterator it; | 2176 | KABC::AddressBook::Iterator it; |
2177 | 2177 | ||
2178 | int count = 0; | 2178 | int count = 0; |
2179 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2179 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2180 | ++count; | 2180 | ++count; |
2181 | } | 2181 | } |
2182 | QProgressBar bar(count,0 ); | 2182 | QProgressBar bar(count,0 ); |
2183 | int w = 300; | 2183 | int w = 300; |
2184 | if ( QApplication::desktop()->width() < 320 ) | 2184 | if ( QApplication::desktop()->width() < 320 ) |
2185 | w = 220; | 2185 | w = 220; |
2186 | int h = bar.sizeHint().height() ; | 2186 | int h = bar.sizeHint().height() ; |
2187 | int dw = QApplication::desktop()->width(); | 2187 | int dw = QApplication::desktop()->width(); |
2188 | int dh = QApplication::desktop()->height(); | 2188 | int dh = QApplication::desktop()->height(); |
2189 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2189 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2190 | bar.show(); | 2190 | bar.show(); |
2191 | bar.setCaption (i18n("collecting birthdays - close to abort!") ); | 2191 | bar.setCaption (i18n("collecting birthdays - close to abort!") ); |
2192 | qApp->processEvents(); | 2192 | qApp->processEvents(); |
2193 | 2193 | ||
2194 | QDate bday; | 2194 | QDate bday; |
2195 | QString anni; | 2195 | QString anni; |
2196 | QString formattedbday; | 2196 | QString formattedbday; |
2197 | 2197 | ||
2198 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) | 2198 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) |
2199 | { | 2199 | { |
2200 | if ( ! bar.isVisible() ) | 2200 | if ( ! bar.isVisible() ) |
2201 | return; | 2201 | return; |
2202 | bar.setProgress( count++ ); | 2202 | bar.setProgress( count++ ); |
2203 | qApp->processEvents(); | 2203 | qApp->processEvents(); |
2204 | bday = (*it).birthday().date(); | 2204 | bday = (*it).birthday().date(); |
2205 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); | 2205 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); |
2206 | 2206 | ||
2207 | if ( bday.isValid() || !anni.isEmpty()) | 2207 | if ( bday.isValid() || !anni.isEmpty()) |
2208 | { | 2208 | { |
2209 | if (bday.isValid()) | 2209 | if (bday.isValid()) |
2210 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); | 2210 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); |
2211 | else | 2211 | else |
2212 | formattedbday = "NOTVALID"; | 2212 | formattedbday = "NOTVALID"; |
2213 | if (anni.isEmpty()) | 2213 | if (anni.isEmpty()) |
2214 | anni = "INVALID"; | 2214 | anni = "INVALID"; |
2215 | 2215 | ||
2216 | birthdayList.append(formattedbday); | 2216 | birthdayList.append(formattedbday); |
2217 | anniversaryList.append(anni); //should be ISODate | 2217 | anniversaryList.append(anni); //should be ISODate |
2218 | realNameList.append((*it).realName()); | 2218 | realNameList.append((*it).realName()); |
2219 | preferredEmailList.append((*it).preferredEmail()); | 2219 | preferredEmailList.append((*it).preferredEmail()); |
2220 | assembledNameList.append((*it).assembledName()); | 2220 | assembledNameList.append((*it).assembledName()); |
2221 | uidList.append((*it).uid()); | 2221 | uidList.append((*it).uid()); |
2222 | 2222 | ||
2223 | 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() ); | 2223 | 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() ); |
2224 | } | 2224 | } |
2225 | } | 2225 | } |
2226 | 2226 | ||
2227 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); | 2227 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); |
2228 | 2228 | ||
2229 | } | 2229 | } |
2230 | 2230 | ||
2231 | /* this method will be called through the QCop interface from other apps to show details of a contact. | 2231 | /* this method will be called through the QCop interface from other apps to show details of a contact. |
2232 | */ | 2232 | */ |
2233 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) | 2233 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) |
2234 | { | 2234 | { |
2235 | qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); | 2235 | qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); |
2236 | 2236 | ||
2237 | QString foundUid = QString::null; | 2237 | QString foundUid = QString::null; |
2238 | if ( ! uid.isEmpty() ) { | 2238 | if ( ! uid.isEmpty() ) { |
2239 | Addressee adrr = mAddressBook->findByUid( uid ); | 2239 | Addressee adrr = mAddressBook->findByUid( uid ); |
2240 | if ( !adrr.isEmpty() ) { | 2240 | if ( !adrr.isEmpty() ) { |
2241 | foundUid = uid; | 2241 | foundUid = uid; |
2242 | } | 2242 | } |
2243 | if ( email == "sendbacklist" ) { | 2243 | if ( email == "sendbacklist" ) { |
2244 | //qDebug("ssssssssssssssssssssssend "); | 2244 | //qDebug("ssssssssssssssssssssssend "); |
2245 | QStringList nameList; | 2245 | QStringList nameList; |
2246 | QStringList emailList; | 2246 | QStringList emailList; |
2247 | QStringList uidList; | 2247 | QStringList uidList; |
2248 | nameList.append(adrr.realName()); | 2248 | nameList.append(adrr.realName()); |
2249 | emailList = adrr.emails(); | 2249 | emailList = adrr.emails(); |
2250 | uidList.append( adrr.preferredEmail()); | 2250 | uidList.append( adrr.preferredEmail()); |
2251 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); | 2251 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); |
2252 | return; | 2252 | return; |
2253 | } | 2253 | } |
2254 | 2254 | ||
2255 | } | 2255 | } |
2256 | 2256 | ||
2257 | if ( email == "sendbacklist" ) | 2257 | if ( email == "sendbacklist" ) |
2258 | return; | 2258 | return; |
2259 | if (foundUid.isEmpty()) | 2259 | if (foundUid.isEmpty()) |
2260 | { | 2260 | { |
2261 | //find the uid of the person first | 2261 | //find the uid of the person first |
2262 | Addressee::List namelist; | 2262 | Addressee::List namelist; |
2263 | Addressee::List emaillist; | 2263 | Addressee::List emaillist; |
2264 | 2264 | ||
2265 | if (!name.isEmpty()) | 2265 | if (!name.isEmpty()) |
2266 | namelist = mAddressBook->findByName( name ); | 2266 | namelist = mAddressBook->findByName( name ); |
2267 | 2267 | ||
2268 | if (!email.isEmpty()) | 2268 | if (!email.isEmpty()) |
2269 | emaillist = mAddressBook->findByEmail( email ); | 2269 | emaillist = mAddressBook->findByEmail( email ); |
2270 | qDebug("count %d %d ", namelist.count(),emaillist.count() ); | 2270 | qDebug("count %d %d ", namelist.count(),emaillist.count() ); |
2271 | //check if we have a match in Namelist and Emaillist | 2271 | //check if we have a match in Namelist and Emaillist |
2272 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { | 2272 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { |
2273 | foundUid = emaillist[0].uid(); | 2273 | foundUid = emaillist[0].uid(); |
2274 | } | 2274 | } |
2275 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) | 2275 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) |
2276 | foundUid = namelist[0].uid(); | 2276 | foundUid = namelist[0].uid(); |
2277 | else | 2277 | else |
2278 | { | 2278 | { |
2279 | for (int i = 0; i < namelist.count(); i++) | 2279 | for (int i = 0; i < namelist.count(); i++) |
2280 | { | 2280 | { |
2281 | for (int j = 0; j < emaillist.count(); j++) | 2281 | for (int j = 0; j < emaillist.count(); j++) |
2282 | { | 2282 | { |
2283 | if (namelist[i] == emaillist[j]) | 2283 | if (namelist[i] == emaillist[j]) |
2284 | { | 2284 | { |
2285 | foundUid = namelist[i].uid(); | 2285 | foundUid = namelist[i].uid(); |
2286 | } | 2286 | } |
2287 | } | 2287 | } |
2288 | } | 2288 | } |
2289 | } | 2289 | } |
2290 | } | 2290 | } |
2291 | else | 2291 | else |
2292 | { | 2292 | { |
2293 | foundUid = uid; | 2293 | foundUid = uid; |
2294 | } | 2294 | } |
2295 | 2295 | ||
2296 | if (!foundUid.isEmpty()) | 2296 | if (!foundUid.isEmpty()) |
2297 | { | 2297 | { |
2298 | 2298 | ||
2299 | // raise Ka/Pi if it is in the background | 2299 | // raise Ka/Pi if it is in the background |
2300 | #ifndef DESKTOP_VERSION | 2300 | #ifndef DESKTOP_VERSION |
2301 | #ifndef KORG_NODCOP | 2301 | #ifndef KORG_NODCOP |
2302 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); | 2302 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); |
2303 | #endif | 2303 | #endif |
2304 | #endif | 2304 | #endif |
2305 | 2305 | ||
2306 | mMainWindow->showMaximized(); | 2306 | mMainWindow->showMaximized(); |
2307 | mMainWindow-> raise(); | 2307 | mMainWindow-> raise(); |
2308 | 2308 | ||
2309 | mViewManager->setSelected( "", false); | 2309 | mViewManager->setSelected( "", false); |
2310 | mViewManager->refreshView( "" ); | 2310 | mViewManager->refreshView( "" ); |
2311 | mViewManager->setSelected( foundUid, true ); | 2311 | mViewManager->setSelected( foundUid, true ); |
2312 | mViewManager->refreshView( foundUid ); | 2312 | mViewManager->refreshView( foundUid ); |
2313 | 2313 | ||
2314 | if ( !mMultipleViewsAtOnce ) | 2314 | if ( !mMultipleViewsAtOnce ) |
2315 | { | 2315 | { |
2316 | setDetailsVisible( true ); | 2316 | setDetailsVisible( true ); |
2317 | mActionDetails->setChecked(true); | 2317 | mActionDetails->setChecked(true); |
2318 | } | 2318 | } |
2319 | } | 2319 | } |
2320 | } | 2320 | } |
2321 | 2321 | ||
2322 | 2322 | ||
2323 | void KABCore::faq() | 2323 | void KABCore::faq() |
2324 | { | 2324 | { |
2325 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); | 2325 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); |
2326 | } | 2326 | } |
2327 | 2327 | ||
2328 | #include <libkcal/syncdefines.h> | 2328 | #include <libkcal/syncdefines.h> |
2329 | 2329 | ||
2330 | KABC::Addressee KABCore::getLastSyncAddressee() | 2330 | KABC::Addressee KABCore::getLastSyncAddressee() |
2331 | { | 2331 | { |
2332 | Addressee lse; | 2332 | Addressee lse; |
2333 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2333 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2334 | 2334 | ||
2335 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 2335 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
2336 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2336 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2337 | if (lse.isEmpty()) { | 2337 | if (lse.isEmpty()) { |
2338 | qDebug("Creating new last-syncAddressee "); | 2338 | qDebug("Creating new last-syncAddressee "); |
2339 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2339 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2340 | QString sum = ""; | 2340 | QString sum = ""; |
2341 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 2341 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
2342 | sum = "E: "; | 2342 | sum = "E: "; |
2343 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); | 2343 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); |
2344 | lse.setRevision( mLastAddressbookSync ); | 2344 | lse.setRevision( mLastAddressbookSync ); |
2345 | lse.setCategories( i18n("SyncEvent") ); | 2345 | lse.setCategories( i18n("SyncEvent") ); |
2346 | mAddressBook->insertAddressee( lse ); | 2346 | mAddressBook->insertAddressee( lse ); |
2347 | } | 2347 | } |
2348 | return lse; | 2348 | return lse; |
2349 | } | 2349 | } |
2350 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) | 2350 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) |
2351 | { | 2351 | { |
2352 | 2352 | ||
2353 | //void setZaurusId(int id); | 2353 | //void setZaurusId(int id); |
2354 | // int zaurusId() const; | 2354 | // int zaurusId() const; |
2355 | // void setZaurusUid(int id); | 2355 | // void setZaurusUid(int id); |
2356 | // int zaurusUid() const; | 2356 | // int zaurusUid() const; |
2357 | // void setZaurusStat(int id); | 2357 | // void setZaurusStat(int id); |
2358 | // int zaurusStat() const; | 2358 | // int zaurusStat() const; |
2359 | // 0 equal | 2359 | // 0 equal |
2360 | // 1 take local | 2360 | // 1 take local |
2361 | // 2 take remote | 2361 | // 2 take remote |
2362 | // 3 cancel | 2362 | // 3 cancel |
2363 | QDateTime lastSync = mLastAddressbookSync; | 2363 | QDateTime lastSync = mLastAddressbookSync; |
2364 | QDateTime localMod = local->revision(); | 2364 | QDateTime localMod = local->revision(); |
2365 | QDateTime remoteMod = remote->revision(); | 2365 | QDateTime remoteMod = remote->revision(); |
2366 | 2366 | ||
2367 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2367 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2368 | 2368 | ||
2369 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2369 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2370 | bool remCh, locCh; | 2370 | bool remCh, locCh; |
2371 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 2371 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
2372 | 2372 | ||
2373 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 2373 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
2374 | locCh = ( localMod > mLastAddressbookSync ); | 2374 | locCh = ( localMod > mLastAddressbookSync ); |
2375 | if ( !remCh && ! locCh ) { | 2375 | if ( !remCh && ! locCh ) { |
2376 | //qDebug("both not changed "); | 2376 | //qDebug("both not changed "); |
2377 | lastSync = localMod.addDays(1); | 2377 | lastSync = localMod.addDays(1); |
2378 | if ( mode <= SYNC_PREF_ASK ) | 2378 | if ( mode <= SYNC_PREF_ASK ) |
2379 | return 0; | 2379 | return 0; |
2380 | } else { | 2380 | } else { |
2381 | if ( locCh ) { | 2381 | if ( locCh ) { |
2382 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); | 2382 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); |
2383 | lastSync = localMod.addDays( -1 ); | 2383 | lastSync = localMod.addDays( -1 ); |
2384 | if ( !remCh ) | 2384 | if ( !remCh ) |
2385 | remoteMod =( lastSync.addDays( -1 ) ); | 2385 | remoteMod =( lastSync.addDays( -1 ) ); |
2386 | } else { | 2386 | } else { |
2387 | //qDebug(" not loc changed "); | 2387 | //qDebug(" not loc changed "); |
2388 | lastSync = localMod.addDays( 1 ); | 2388 | lastSync = localMod.addDays( 1 ); |
2389 | if ( remCh ) | 2389 | if ( remCh ) |
2390 | remoteMod =( lastSync.addDays( 1 ) ); | 2390 | remoteMod =( lastSync.addDays( 1 ) ); |
2391 | 2391 | ||
2392 | } | 2392 | } |
2393 | } | 2393 | } |
2394 | full = true; | 2394 | full = true; |
2395 | if ( mode < SYNC_PREF_ASK ) | 2395 | if ( mode < SYNC_PREF_ASK ) |
2396 | mode = SYNC_PREF_ASK; | 2396 | mode = SYNC_PREF_ASK; |
2397 | } else { | 2397 | } else { |
2398 | if ( localMod == remoteMod ) | 2398 | if ( localMod == remoteMod ) |
2399 | return 0; | 2399 | return 0; |
2400 | 2400 | ||
2401 | } | 2401 | } |
2402 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 2402 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
2403 | 2403 | ||
2404 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); | 2404 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); |
2405 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); | 2405 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); |
2406 | //full = true; //debug only | 2406 | //full = true; //debug only |
2407 | if ( full ) { | 2407 | if ( full ) { |
2408 | bool equ = ( (*local) == (*remote) ); | 2408 | bool equ = ( (*local) == (*remote) ); |
2409 | if ( equ ) { | 2409 | if ( equ ) { |
2410 | //qDebug("equal "); | 2410 | //qDebug("equal "); |
2411 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2411 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2412 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 2412 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
2413 | } | 2413 | } |
2414 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 2414 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
2415 | return 0; | 2415 | return 0; |
2416 | 2416 | ||
2417 | }//else //debug only | 2417 | }//else //debug only |
2418 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 2418 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
2419 | } | 2419 | } |
2420 | int result; | 2420 | int result; |
2421 | bool localIsNew; | 2421 | bool localIsNew; |
2422 | //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() ); | 2422 | //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() ); |
2423 | 2423 | ||
2424 | if ( full && mode < SYNC_PREF_NEWEST ) | 2424 | if ( full && mode < SYNC_PREF_NEWEST ) |
2425 | mode = SYNC_PREF_ASK; | 2425 | mode = SYNC_PREF_ASK; |
2426 | 2426 | ||
2427 | switch( mode ) { | 2427 | switch( mode ) { |
2428 | case SYNC_PREF_LOCAL: | 2428 | case SYNC_PREF_LOCAL: |
2429 | if ( lastSync > remoteMod ) | 2429 | if ( lastSync > remoteMod ) |
2430 | return 1; | 2430 | return 1; |
2431 | if ( lastSync > localMod ) | 2431 | if ( lastSync > localMod ) |
2432 | return 2; | 2432 | return 2; |
2433 | return 1; | 2433 | return 1; |
2434 | break; | 2434 | break; |
2435 | case SYNC_PREF_REMOTE: | 2435 | case SYNC_PREF_REMOTE: |
2436 | if ( lastSync > remoteMod ) | 2436 | if ( lastSync > remoteMod ) |
2437 | return 1; | 2437 | return 1; |
2438 | if ( lastSync > localMod ) | 2438 | if ( lastSync > localMod ) |
2439 | return 2; | 2439 | return 2; |
2440 | return 2; | 2440 | return 2; |
2441 | break; | 2441 | break; |
2442 | case SYNC_PREF_NEWEST: | 2442 | case SYNC_PREF_NEWEST: |
2443 | if ( localMod > remoteMod ) | 2443 | if ( localMod > remoteMod ) |
2444 | return 1; | 2444 | return 1; |
2445 | else | 2445 | else |
2446 | return 2; | 2446 | return 2; |
2447 | break; | 2447 | break; |
2448 | case SYNC_PREF_ASK: | 2448 | case SYNC_PREF_ASK: |
2449 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 2449 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
2450 | if ( lastSync > remoteMod ) | 2450 | if ( lastSync > remoteMod ) |
2451 | return 1; | 2451 | return 1; |
2452 | if ( lastSync > localMod ) | 2452 | if ( lastSync > localMod ) |
2453 | return 2; | 2453 | return 2; |
2454 | localIsNew = localMod >= remoteMod; | 2454 | localIsNew = localMod >= remoteMod; |
2455 | //qDebug("conflict! ************************************** "); | 2455 | //qDebug("conflict! ************************************** "); |
2456 | { | 2456 | { |
2457 | KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); | 2457 | KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); |
2458 | result = acd.executeD(localIsNew); | 2458 | result = acd.executeD(localIsNew); |
2459 | return result; | 2459 | return result; |
2460 | } | 2460 | } |
2461 | break; | 2461 | break; |
2462 | case SYNC_PREF_FORCE_LOCAL: | 2462 | case SYNC_PREF_FORCE_LOCAL: |
2463 | return 1; | 2463 | return 1; |
2464 | break; | 2464 | break; |
2465 | case SYNC_PREF_FORCE_REMOTE: | 2465 | case SYNC_PREF_FORCE_REMOTE: |
2466 | return 2; | 2466 | return 2; |
2467 | break; | 2467 | break; |
2468 | 2468 | ||
2469 | default: | 2469 | default: |
2470 | // SYNC_PREF_TAKE_BOTH not implemented | 2470 | // SYNC_PREF_TAKE_BOTH not implemented |
2471 | break; | 2471 | break; |
2472 | } | 2472 | } |
2473 | return 0; | 2473 | return 0; |
2474 | } | 2474 | } |
2475 | 2475 | ||
2476 | 2476 | ||
2477 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) | 2477 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) |
2478 | { | 2478 | { |
2479 | bool syncOK = true; | 2479 | bool syncOK = true; |
2480 | int addedAddressee = 0; | 2480 | int addedAddressee = 0; |
2481 | int addedAddresseeR = 0; | 2481 | int addedAddresseeR = 0; |
2482 | int deletedAddresseeR = 0; | 2482 | int deletedAddresseeR = 0; |
2483 | int deletedAddresseeL = 0; | 2483 | int deletedAddresseeL = 0; |
2484 | int changedLocal = 0; | 2484 | int changedLocal = 0; |
2485 | int changedRemote = 0; | 2485 | int changedRemote = 0; |
2486 | 2486 | ||
2487 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); | 2487 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); |
2488 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2488 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2489 | 2489 | ||
2490 | //QPtrList<Addressee> el = local->rawAddressees(); | 2490 | //QPtrList<Addressee> el = local->rawAddressees(); |
2491 | Addressee addresseeR; | 2491 | Addressee addresseeR; |
2492 | QString uid; | 2492 | QString uid; |
2493 | int take; | 2493 | int take; |
2494 | Addressee addresseeL; | 2494 | Addressee addresseeL; |
2495 | Addressee addresseeRSync; | 2495 | Addressee addresseeRSync; |
2496 | Addressee addresseeLSync; | 2496 | Addressee addresseeLSync; |
2497 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); | 2497 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); |
2498 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); | 2498 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); |
2499 | bool fullDateRange = false; | 2499 | bool fullDateRange = false; |
2500 | local->resetTempSyncStat(); | 2500 | local->resetTempSyncStat(); |
2501 | mLastAddressbookSync = QDateTime::currentDateTime(); | 2501 | mLastAddressbookSync = QDateTime::currentDateTime(); |
2502 | QDateTime modifiedCalendar = mLastAddressbookSync;; | 2502 | QDateTime modifiedCalendar = mLastAddressbookSync;; |
2503 | addresseeLSync = getLastSyncAddressee(); | 2503 | addresseeLSync = getLastSyncAddressee(); |
2504 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); | 2504 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); |
2505 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); | 2505 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); |
2506 | if ( !addresseeR.isEmpty() ) { | 2506 | if ( !addresseeR.isEmpty() ) { |
2507 | addresseeRSync = addresseeR; | 2507 | addresseeRSync = addresseeR; |
2508 | remote->removeAddressee(addresseeR ); | 2508 | remote->removeAddressee(addresseeR ); |
2509 | 2509 | ||
2510 | } else { | 2510 | } else { |
2511 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2511 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2512 | addresseeRSync = addresseeLSync ; | 2512 | addresseeRSync = addresseeLSync ; |
2513 | } else { | 2513 | } else { |
2514 | qDebug("FULLDATE 1"); | 2514 | qDebug("FULLDATE 1"); |
2515 | fullDateRange = true; | 2515 | fullDateRange = true; |
2516 | Addressee newAdd; | 2516 | Addressee newAdd; |
2517 | addresseeRSync = newAdd; | 2517 | addresseeRSync = newAdd; |
2518 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); | 2518 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); |
2519 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); | 2519 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); |
2520 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2520 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2521 | addresseeRSync.setCategories( i18n("SyncAddressee") ); | 2521 | addresseeRSync.setCategories( i18n("SyncAddressee") ); |
2522 | } | 2522 | } |
2523 | } | 2523 | } |
2524 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { | 2524 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { |
2525 | qDebug("FULLDATE 2"); | 2525 | qDebug("FULLDATE 2"); |
2526 | fullDateRange = true; | 2526 | fullDateRange = true; |
2527 | } | 2527 | } |
2528 | if ( ! fullDateRange ) { | 2528 | if ( ! fullDateRange ) { |
2529 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { | 2529 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { |
2530 | 2530 | ||
2531 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); | 2531 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); |
2532 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); | 2532 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); |
2533 | fullDateRange = true; | 2533 | fullDateRange = true; |
2534 | qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); | 2534 | qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); |
2535 | } | 2535 | } |
2536 | } | 2536 | } |
2537 | // fullDateRange = true; // debug only! | 2537 | // fullDateRange = true; // debug only! |
2538 | if ( fullDateRange ) | 2538 | if ( fullDateRange ) |
2539 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); | 2539 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); |
2540 | else | 2540 | else |
2541 | mLastAddressbookSync = addresseeLSync.revision(); | 2541 | mLastAddressbookSync = addresseeLSync.revision(); |
2542 | // for resyncing if own file has changed | 2542 | // for resyncing if own file has changed |
2543 | // PENDING fixme later when implemented | 2543 | // PENDING fixme later when implemented |
2544 | #if 0 | 2544 | #if 0 |
2545 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 2545 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
2546 | mLastAddressbookSync = loadedFileVersion; | 2546 | mLastAddressbookSync = loadedFileVersion; |
2547 | qDebug("setting mLastAddressbookSync "); | 2547 | qDebug("setting mLastAddressbookSync "); |
2548 | } | 2548 | } |
2549 | #endif | 2549 | #endif |
2550 | 2550 | ||
2551 | //qDebug("*************************** "); | 2551 | //qDebug("*************************** "); |
2552 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); | 2552 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); |
2553 | QStringList er = remote->uidList(); | 2553 | QStringList er = remote->uidList(); |
2554 | Addressee inR ;//= er.first(); | 2554 | Addressee inR ;//= er.first(); |
2555 | Addressee inL; | 2555 | Addressee inL; |
2556 | 2556 | ||
2557 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); | 2557 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); |
2558 | 2558 | ||
2559 | int modulo = (er.count()/10)+1; | 2559 | int modulo = (er.count()/10)+1; |
2560 | int incCounter = 0; | 2560 | int incCounter = 0; |
2561 | while ( incCounter < er.count()) { | 2561 | while ( incCounter < er.count()) { |
2562 | if (syncManager->isProgressBarCanceled()) | 2562 | if (syncManager->isProgressBarCanceled()) |
2563 | return false; | 2563 | return false; |
2564 | if ( incCounter % modulo == 0 ) | 2564 | if ( incCounter % modulo == 0 ) |
2565 | syncManager->showProgressBar(incCounter); | 2565 | syncManager->showProgressBar(incCounter); |
2566 | 2566 | ||
2567 | uid = er[ incCounter ]; | 2567 | uid = er[ incCounter ]; |
2568 | bool skipIncidence = false; | 2568 | bool skipIncidence = false; |
2569 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2569 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2570 | skipIncidence = true; | 2570 | skipIncidence = true; |
2571 | QString idS,OidS; | 2571 | QString idS,OidS; |
2572 | qApp->processEvents(); | 2572 | qApp->processEvents(); |
2573 | if ( !skipIncidence ) { | 2573 | if ( !skipIncidence ) { |
2574 | inL = local->findByUid( uid ); | 2574 | inL = local->findByUid( uid ); |
2575 | inR = remote->findByUid( uid ); | 2575 | inR = remote->findByUid( uid ); |
2576 | //inL.setResource( 0 ); | 2576 | //inL.setResource( 0 ); |
2577 | //inR.setResource( 0 ); | 2577 | //inR.setResource( 0 ); |
2578 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars | 2578 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars |
2579 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { | 2579 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { |
2580 | //qDebug("take %d %s ", take, inL.summary().latin1()); | 2580 | //qDebug("take %d %s ", take, inL.summary().latin1()); |
2581 | if ( take == 3 ) | 2581 | if ( take == 3 ) |
2582 | return false; | 2582 | return false; |
2583 | if ( take == 1 ) {// take local | 2583 | if ( take == 1 ) {// take local |
2584 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2584 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2585 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2585 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2586 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2586 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2587 | local->insertAddressee( inL, false ); | 2587 | local->insertAddressee( inL, false ); |
2588 | idS = inR.externalUID(); | 2588 | idS = inR.externalUID(); |
2589 | OidS = inR.originalExternalUID(); | 2589 | OidS = inR.originalExternalUID(); |
2590 | } | 2590 | } |
2591 | else | 2591 | else |
2592 | idS = inR.IDStr(); | 2592 | idS = inR.IDStr(); |
2593 | remote->removeAddressee( inR ); | 2593 | remote->removeAddressee( inR ); |
2594 | inR = inL; | 2594 | inR = inL; |
2595 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 2595 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
2596 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2596 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2597 | inR.setOriginalExternalUID( OidS ); | 2597 | inR.setOriginalExternalUID( OidS ); |
2598 | inR.setExternalUID( idS ); | 2598 | inR.setExternalUID( idS ); |
2599 | } else { | 2599 | } else { |
2600 | inR.setIDStr( idS ); | 2600 | inR.setIDStr( idS ); |
2601 | } | 2601 | } |
2602 | inR.setResource( 0 ); | 2602 | inR.setResource( 0 ); |
2603 | remote->insertAddressee( inR , false); | 2603 | remote->insertAddressee( inR , false); |
2604 | ++changedRemote; | 2604 | ++changedRemote; |
2605 | } else { // take == 2 take remote | 2605 | } else { // take == 2 take remote |
2606 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2606 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2607 | if ( inR.revision().date().year() < 2004 ) | 2607 | if ( inR.revision().date().year() < 2004 ) |
2608 | inR.setRevision( modifiedCalendar ); | 2608 | inR.setRevision( modifiedCalendar ); |
2609 | } | 2609 | } |
2610 | idS = inL.IDStr(); | 2610 | idS = inL.IDStr(); |
2611 | local->removeAddressee( inL ); | 2611 | local->removeAddressee( inL ); |
2612 | inL = inR; | 2612 | inL = inR; |
2613 | inL.setIDStr( idS ); | 2613 | inL.setIDStr( idS ); |
2614 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2614 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2615 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2615 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2616 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2616 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2617 | } | 2617 | } |
2618 | inL.setResource( 0 ); | 2618 | inL.setResource( 0 ); |
2619 | local->insertAddressee( inL , false ); | 2619 | local->insertAddressee( inL , false ); |
2620 | ++changedLocal; | 2620 | ++changedLocal; |
2621 | } | 2621 | } |
2622 | } | 2622 | } |
2623 | } else { // no conflict | 2623 | } else { // no conflict |
2624 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2624 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2625 | QString des = addresseeLSync.note(); | 2625 | QString des = addresseeLSync.note(); |
2626 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 2626 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
2627 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 2627 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
2628 | remote->insertAddressee( inR, false ); | 2628 | remote->insertAddressee( inR, false ); |
2629 | ++deletedAddresseeR; | 2629 | ++deletedAddresseeR; |
2630 | } else { | 2630 | } else { |
2631 | inR.setRevision( modifiedCalendar ); | 2631 | inR.setRevision( modifiedCalendar ); |
2632 | remote->insertAddressee( inR, false ); | 2632 | remote->insertAddressee( inR, false ); |
2633 | inL = inR; | 2633 | inL = inR; |
2634 | inL.setResource( 0 ); | 2634 | inL.setResource( 0 ); |
2635 | local->insertAddressee( inL , false); | 2635 | local->insertAddressee( inL , false); |
2636 | ++addedAddressee; | 2636 | ++addedAddressee; |
2637 | } | 2637 | } |
2638 | } else { | 2638 | } else { |
2639 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { | 2639 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { |
2640 | inR.setRevision( modifiedCalendar ); | 2640 | inR.setRevision( modifiedCalendar ); |
2641 | remote->insertAddressee( inR, false ); | 2641 | remote->insertAddressee( inR, false ); |
2642 | inR.setResource( 0 ); | 2642 | inR.setResource( 0 ); |
2643 | local->insertAddressee( inR, false ); | 2643 | local->insertAddressee( inR, false ); |
2644 | ++addedAddressee; | 2644 | ++addedAddressee; |
2645 | } else { | 2645 | } else { |
2646 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); | 2646 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); |
2647 | remote->removeAddressee( inR ); | 2647 | remote->removeAddressee( inR ); |
2648 | ++deletedAddresseeR; | 2648 | ++deletedAddresseeR; |
2649 | } | 2649 | } |
2650 | } | 2650 | } |
2651 | } | 2651 | } |
2652 | } | 2652 | } |
2653 | ++incCounter; | 2653 | ++incCounter; |
2654 | } | 2654 | } |
2655 | er.clear(); | 2655 | er.clear(); |
2656 | QStringList el = local->uidList(); | 2656 | QStringList el = local->uidList(); |
2657 | modulo = (el.count()/10)+1; | 2657 | modulo = (el.count()/10)+1; |
2658 | 2658 | ||
2659 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); | 2659 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); |
2660 | incCounter = 0; | 2660 | incCounter = 0; |
2661 | while ( incCounter < el.count()) { | 2661 | while ( incCounter < el.count()) { |
2662 | qApp->processEvents(); | 2662 | qApp->processEvents(); |
2663 | if (syncManager->isProgressBarCanceled()) | 2663 | if (syncManager->isProgressBarCanceled()) |
2664 | return false; | 2664 | return false; |
2665 | if ( incCounter % modulo == 0 ) | 2665 | if ( incCounter % modulo == 0 ) |
2666 | syncManager->showProgressBar(incCounter); | 2666 | syncManager->showProgressBar(incCounter); |
2667 | uid = el[ incCounter ]; | 2667 | uid = el[ incCounter ]; |
2668 | bool skipIncidence = false; | 2668 | bool skipIncidence = false; |
2669 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2669 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2670 | skipIncidence = true; | 2670 | skipIncidence = true; |
2671 | if ( !skipIncidence ) { | 2671 | if ( !skipIncidence ) { |
2672 | inL = local->findByUid( uid ); | 2672 | inL = local->findByUid( uid ); |
2673 | inR = remote->findByUid( uid ); | 2673 | inR = remote->findByUid( uid ); |
2674 | if ( inR.isEmpty() ) { | 2674 | if ( inR.isEmpty() ) { |
2675 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2675 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2676 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 2676 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
2677 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2677 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2678 | local->removeAddressee( inL ); | 2678 | local->removeAddressee( inL ); |
2679 | ++deletedAddresseeL; | 2679 | ++deletedAddresseeL; |
2680 | } else { | 2680 | } else { |
2681 | if ( ! syncManager->mWriteBackExistingOnly ) { | 2681 | if ( ! syncManager->mWriteBackExistingOnly ) { |
2682 | inL.removeID(mCurrentSyncDevice ); | 2682 | inL.removeID(mCurrentSyncDevice ); |
2683 | ++addedAddresseeR; | 2683 | ++addedAddresseeR; |
2684 | inL.setRevision( modifiedCalendar ); | 2684 | inL.setRevision( modifiedCalendar ); |
2685 | local->insertAddressee( inL, false ); | 2685 | local->insertAddressee( inL, false ); |
2686 | inR = inL; | 2686 | inR = inL; |
2687 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); | 2687 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); |
2688 | inR.setResource( 0 ); | 2688 | inR.setResource( 0 ); |
2689 | remote->insertAddressee( inR, false ); | 2689 | remote->insertAddressee( inR, false ); |
2690 | } | 2690 | } |
2691 | } | 2691 | } |
2692 | } else { | 2692 | } else { |
2693 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { | 2693 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { |
2694 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2694 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2695 | local->removeAddressee( inL ); | 2695 | local->removeAddressee( inL ); |
2696 | ++deletedAddresseeL; | 2696 | ++deletedAddresseeL; |
2697 | } else { | 2697 | } else { |
2698 | if ( ! syncManager->mWriteBackExistingOnly ) { | 2698 | if ( ! syncManager->mWriteBackExistingOnly ) { |
2699 | ++addedAddresseeR; | 2699 | ++addedAddresseeR; |
2700 | inL.setRevision( modifiedCalendar ); | 2700 | inL.setRevision( modifiedCalendar ); |
2701 | local->insertAddressee( inL, false ); | 2701 | local->insertAddressee( inL, false ); |
2702 | inR = inL; | 2702 | inR = inL; |
2703 | inR.setResource( 0 ); | 2703 | inR.setResource( 0 ); |
2704 | remote->insertAddressee( inR, false ); | 2704 | remote->insertAddressee( inR, false ); |
2705 | } | 2705 | } |
2706 | } | 2706 | } |
2707 | } | 2707 | } |
2708 | } | 2708 | } |
2709 | } | 2709 | } |
2710 | ++incCounter; | 2710 | ++incCounter; |
2711 | } | 2711 | } |
2712 | el.clear(); | 2712 | el.clear(); |
2713 | syncManager->hideProgressBar(); | 2713 | syncManager->hideProgressBar(); |
2714 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); | 2714 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); |
2715 | // get rid of micro seconds | 2715 | // get rid of micro seconds |
2716 | QTime t = mLastAddressbookSync.time(); | 2716 | QTime t = mLastAddressbookSync.time(); |
2717 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 2717 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
2718 | addresseeLSync.setRevision( mLastAddressbookSync ); | 2718 | addresseeLSync.setRevision( mLastAddressbookSync ); |
2719 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2719 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2720 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; | 2720 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; |
2721 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); | 2721 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); |
2722 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; | 2722 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; |
2723 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); | 2723 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); |
2724 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; | 2724 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; |
2725 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); | 2725 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); |
2726 | addresseeRSync.setNote( "" ) ; | 2726 | addresseeRSync.setNote( "" ) ; |
2727 | addresseeLSync.setNote( "" ); | 2727 | addresseeLSync.setNote( "" ); |
2728 | 2728 | ||
2729 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 2729 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
2730 | remote->insertAddressee( addresseeRSync, false ); | 2730 | remote->insertAddressee( addresseeRSync, false ); |
2731 | local->insertAddressee( addresseeLSync, false ); | 2731 | local->insertAddressee( addresseeLSync, false ); |
2732 | QString mes; | 2732 | QString mes; |
2733 | 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 ); | 2733 | 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 ); |
2734 | if ( syncManager->mShowSyncSummary ) { | 2734 | if ( syncManager->mShowSyncSummary ) { |
2735 | KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); | 2735 | KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); |
2736 | } | 2736 | } |
2737 | qDebug( mes ); | 2737 | qDebug( mes ); |
2738 | return syncOK; | 2738 | return syncOK; |
2739 | } | 2739 | } |
2740 | 2740 | ||
2741 | 2741 | ||
2742 | //this is a overwritten callbackmethods from the syncinterface | 2742 | //this is a overwritten callbackmethods from the syncinterface |
2743 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) | 2743 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) |
2744 | { | 2744 | { |
2745 | 2745 | ||
2746 | //pending prepare addresseeview for output | 2746 | //pending prepare addresseeview for output |
2747 | //pending detect, if remote file has REV field. if not switch to external sync | 2747 | //pending detect, if remote file has REV field. if not switch to external sync |
2748 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 2748 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
2749 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 2749 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
2750 | 2750 | ||
2751 | AddressBook abLocal(filename,"syncContact"); | 2751 | AddressBook abLocal(filename,"syncContact"); |
2752 | bool syncOK = false; | 2752 | bool syncOK = false; |
2753 | if ( abLocal.load() ) { | 2753 | if ( abLocal.load() ) { |
2754 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); | 2754 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); |
2755 | bool external = false; | 2755 | bool external = false; |
2756 | bool isXML = false; | 2756 | bool isXML = false; |
2757 | if ( filename.right(4) == ".xml") { | 2757 | if ( filename.right(4) == ".xml") { |
2758 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2758 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2759 | isXML = true; | 2759 | isXML = true; |
2760 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); | 2760 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); |
2761 | } else { | 2761 | } else { |
2762 | Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2762 | Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2763 | if ( ! lse.isEmpty() ) { | 2763 | if ( ! lse.isEmpty() ) { |
2764 | if ( lse.familyName().left(4) == "!E: " ) | 2764 | if ( lse.familyName().left(4) == "!E: " ) |
2765 | external = true; | 2765 | external = true; |
2766 | } else { | 2766 | } else { |
2767 | bool found = false; | 2767 | bool found = false; |
2768 | AddressBook::Iterator it; | 2768 | AddressBook::Iterator it; |
2769 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2769 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2770 | if ( (*it).revision().date().year() > 2003 ) { | 2770 | if ( (*it).revision().date().year() > 2003 ) { |
2771 | found = true; | 2771 | found = true; |
2772 | break; | 2772 | break; |
2773 | } | 2773 | } |
2774 | } | 2774 | } |
2775 | external = ! found; | 2775 | external = ! found; |
2776 | } | 2776 | } |
2777 | 2777 | ||
2778 | if ( external ) { | 2778 | if ( external ) { |
2779 | qDebug("Setting vcf mode to external "); | 2779 | qDebug("Setting vcf mode to external "); |
2780 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2780 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2781 | AddressBook::Iterator it; | 2781 | AddressBook::Iterator it; |
2782 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2782 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2783 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); | 2783 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); |
2784 | (*it).computeCsum( mCurrentSyncDevice ); | 2784 | (*it).computeCsum( mCurrentSyncDevice ); |
2785 | } | 2785 | } |
2786 | } | 2786 | } |
2787 | } | 2787 | } |
2788 | //AddressBook::Iterator it; | 2788 | //AddressBook::Iterator it; |
2789 | //QStringList vcards; | 2789 | //QStringList vcards; |
2790 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2790 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2791 | // qDebug("Name %s ", (*it).familyName().latin1()); | 2791 | // qDebug("Name %s ", (*it).familyName().latin1()); |
2792 | //} | 2792 | //} |
2793 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); | 2793 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); |
2794 | if ( syncOK ) { | 2794 | if ( syncOK ) { |
2795 | if ( syncManager->mWriteBackFile ) | 2795 | if ( syncManager->mWriteBackFile ) |
2796 | { | 2796 | { |
2797 | if ( external ) | 2797 | if ( external ) |
2798 | abLocal.removeSyncAddressees( !isXML); | 2798 | abLocal.removeSyncAddressees( !isXML); |
2799 | qDebug("Saving remote AB "); | 2799 | qDebug("Saving remote AB "); |
2800 | abLocal.saveAB(); | 2800 | abLocal.saveAB(); |
2801 | if ( isXML ) { | 2801 | if ( isXML ) { |
2802 | // afterwrite processing | 2802 | // afterwrite processing |
2803 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); | 2803 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); |
2804 | } | 2804 | } |
2805 | } | 2805 | } |
2806 | } | 2806 | } |
2807 | setModified(); | 2807 | setModified(); |
2808 | 2808 | ||
2809 | } | 2809 | } |
2810 | if ( syncOK ) | 2810 | if ( syncOK ) |
2811 | mViewManager->refreshView(); | 2811 | mViewManager->refreshView(); |
2812 | return syncOK; | 2812 | return syncOK; |
2813 | #if 0 | 2813 | #if 0 |
2814 | 2814 | ||
2815 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { | 2815 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { |
2816 | getEventViewerDialog()->setSyncMode( true ); | 2816 | getEventViewerDialog()->setSyncMode( true ); |
2817 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 2817 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
2818 | getEventViewerDialog()->setSyncMode( false ); | 2818 | getEventViewerDialog()->setSyncMode( false ); |
2819 | if ( syncOK ) { | 2819 | if ( syncOK ) { |
2820 | if ( KOPrefs::instance()->mWriteBackFile ) | 2820 | if ( KOPrefs::instance()->mWriteBackFile ) |
2821 | { | 2821 | { |
2822 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); | 2822 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); |
2823 | storage->save(); | 2823 | storage->save(); |
2824 | } | 2824 | } |
2825 | } | 2825 | } |
2826 | setModified(); | 2826 | setModified(); |
2827 | } | 2827 | } |
2828 | 2828 | ||
2829 | #endif | 2829 | #endif |
2830 | } | 2830 | } |
2831 | 2831 | ||
2832 | 2832 | ||
2833 | //this is a overwritten callbackmethods from the syncinterface | 2833 | //this is a overwritten callbackmethods from the syncinterface |
2834 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) | 2834 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) |
2835 | { | 2835 | { |
2836 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 2836 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
2837 | 2837 | ||
2838 | AddressBook abLocal( resource,"syncContact"); | 2838 | AddressBook abLocal( resource,"syncContact"); |
2839 | bool syncOK = false; | 2839 | bool syncOK = false; |
2840 | if ( abLocal.load() ) { | 2840 | if ( abLocal.load() ) { |
2841 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 2841 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
2842 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2842 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2843 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); | 2843 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); |
2844 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 2844 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
2845 | if ( syncOK ) { | 2845 | if ( syncOK ) { |
2846 | if ( syncManager->mWriteBackFile ) { | 2846 | if ( syncManager->mWriteBackFile ) { |
2847 | abLocal.saveAB(); | 2847 | abLocal.saveAB(); |
2848 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); | 2848 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); |
2849 | } | 2849 | } |
2850 | } | 2850 | } |
2851 | setModified(); | 2851 | setModified(); |
2852 | } | 2852 | } |
2853 | if ( syncOK ) | 2853 | if ( syncOK ) |
2854 | mViewManager->refreshView(); | 2854 | mViewManager->refreshView(); |
2855 | return syncOK; | 2855 | return syncOK; |
2856 | 2856 | ||
2857 | } | 2857 | } |
2858 | 2858 | ||
2859 | void KABCore::getFile( bool success ) | 2859 | void KABCore::getFile( bool success ) |
2860 | { | 2860 | { |
2861 | qDebug("KABCore::getFile "); | ||
2862 | QTimer::singleShot( 15000, this , SLOT ( setCaptionBack())); | 2861 | QTimer::singleShot( 15000, this , SLOT ( setCaptionBack())); |
2863 | if ( ! success ) { | 2862 | if ( ! success ) { |
2864 | setCaption( i18n("Error receiving file. Nothing changed!") ); | 2863 | setCaption( i18n("Error receiving file. Nothing changed!") ); |
2865 | return; | 2864 | return; |
2866 | } | 2865 | } |
2867 | mAddressBook->importFromFile( sentSyncFile() ); | 2866 | mAddressBook->importFromFile( sentSyncFile() ); |
2868 | topLevelWidget()->setCaption( i18n("Pi-Sync successful!") ); | 2867 | topLevelWidget()->setCaption( i18n("Pi-Sync successful!") ); |
2868 | mViewManager->refreshView(); | ||
2869 | } | 2869 | } |
2870 | void KABCore::syncFileRequest() | 2870 | void KABCore::syncFileRequest() |
2871 | { | 2871 | { |
2872 | mAddressBook->export2File( sentSyncFile() ); | 2872 | mAddressBook->export2File( sentSyncFile() ); |
2873 | } | 2873 | } |
2874 | QString KABCore::sentSyncFile() | 2874 | QString KABCore::sentSyncFile() |
2875 | { | 2875 | { |
2876 | #ifdef _WIN32_ | 2876 | #ifdef _WIN32_ |
2877 | return locateLocal( "tmp", "copysyncab.vcf" ); | 2877 | return locateLocal( "tmp", "copysyncab.vcf" ); |
2878 | #else | 2878 | #else |
2879 | return QString( "/tmp/copysyncab.vcf" ); | 2879 | return QString( "/tmp/copysyncab.vcf" ); |
2880 | #endif | 2880 | #endif |
2881 | } | 2881 | } |
2882 | 2882 | ||
2883 | void KABCore::setCaptionBack() | 2883 | void KABCore::setCaptionBack() |
2884 | { | 2884 | { |
2885 | topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); | 2885 | topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); |
2886 | } | 2886 | } |
2887 | 2887 | ||