-rw-r--r-- | kaddressbook/kabcore.cpp | 6 | ||||
-rw-r--r-- | korganizer/calendarview.cpp | 16 |
2 files changed, 17 insertions, 5 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index eba74a6..20b107e 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -1335,2076 +1335,2078 @@ void KABCore::importFromOL() | |||
1335 | if ( listNew.count() > 0 ) { | 1335 | if ( listNew.count() > 0 ) { |
1336 | pasteWithNewUid = false; | 1336 | pasteWithNewUid = false; |
1337 | pasteContacts( listNew ); | 1337 | pasteContacts( listNew ); |
1338 | pasteWithNewUid = true; | 1338 | pasteWithNewUid = true; |
1339 | } | 1339 | } |
1340 | } | 1340 | } |
1341 | delete idgl; | 1341 | delete idgl; |
1342 | #endif | 1342 | #endif |
1343 | } | 1343 | } |
1344 | 1344 | ||
1345 | void KABCore::importVCard( const QString &vCard, bool showPreview ) | 1345 | void KABCore::importVCard( const QString &vCard, bool showPreview ) |
1346 | { | 1346 | { |
1347 | mXXPortManager->importVCard( vCard, showPreview ); | 1347 | mXXPortManager->importVCard( vCard, showPreview ); |
1348 | } | 1348 | } |
1349 | 1349 | ||
1350 | //US added a second method without defaultparameter | 1350 | //US added a second method without defaultparameter |
1351 | void KABCore::editContact2() { | 1351 | void KABCore::editContact2() { |
1352 | editContact( QString::null ); | 1352 | editContact( QString::null ); |
1353 | } | 1353 | } |
1354 | 1354 | ||
1355 | void KABCore::editContact( const QString &uid ) | 1355 | void KABCore::editContact( const QString &uid ) |
1356 | { | 1356 | { |
1357 | 1357 | ||
1358 | if ( mExtensionManager->isQuickEditVisible() ) | 1358 | if ( mExtensionManager->isQuickEditVisible() ) |
1359 | return; | 1359 | return; |
1360 | 1360 | ||
1361 | // First, locate the contact entry | 1361 | // First, locate the contact entry |
1362 | QString localUID = uid; | 1362 | QString localUID = uid; |
1363 | if ( localUID.isNull() ) { | 1363 | if ( localUID.isNull() ) { |
1364 | QStringList uidList = mViewManager->selectedUids(); | 1364 | QStringList uidList = mViewManager->selectedUids(); |
1365 | if ( uidList.count() > 0 ) | 1365 | if ( uidList.count() > 0 ) |
1366 | localUID = *( uidList.at( 0 ) ); | 1366 | localUID = *( uidList.at( 0 ) ); |
1367 | } | 1367 | } |
1368 | 1368 | ||
1369 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); | 1369 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); |
1370 | if ( !addr.isEmpty() ) { | 1370 | if ( !addr.isEmpty() ) { |
1371 | mEditorDialog->setAddressee( addr ); | 1371 | mEditorDialog->setAddressee( addr ); |
1372 | KApplication::execDialog ( mEditorDialog ); | 1372 | KApplication::execDialog ( mEditorDialog ); |
1373 | } | 1373 | } |
1374 | } | 1374 | } |
1375 | 1375 | ||
1376 | /** | 1376 | /** |
1377 | Shows or edits the detail view for the given uid. If the uid is QString::null, | 1377 | Shows or edits the detail view for the given uid. If the uid is QString::null, |
1378 | the method will try to find a selected addressee in the view. | 1378 | the method will try to find a selected addressee in the view. |
1379 | */ | 1379 | */ |
1380 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) | 1380 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) |
1381 | { | 1381 | { |
1382 | if ( mMultipleViewsAtOnce ) | 1382 | if ( mMultipleViewsAtOnce ) |
1383 | { | 1383 | { |
1384 | editContact( uid ); | 1384 | editContact( uid ); |
1385 | } | 1385 | } |
1386 | else | 1386 | else |
1387 | { | 1387 | { |
1388 | setDetailsVisible( true ); | 1388 | setDetailsVisible( true ); |
1389 | mActionDetails->setChecked(true); | 1389 | mActionDetails->setChecked(true); |
1390 | } | 1390 | } |
1391 | 1391 | ||
1392 | } | 1392 | } |
1393 | 1393 | ||
1394 | void KABCore::save() | 1394 | void KABCore::save() |
1395 | { | 1395 | { |
1396 | if (syncManager->blockSave()) | 1396 | if (syncManager->blockSave()) |
1397 | return; | 1397 | return; |
1398 | if ( !mModified ) | 1398 | if ( !mModified ) |
1399 | return; | 1399 | return; |
1400 | 1400 | ||
1401 | syncManager->setBlockSave(true); | 1401 | syncManager->setBlockSave(true); |
1402 | QString text = i18n( "There was an error while attempting to save\n the " | 1402 | QString text = i18n( "There was an error while attempting to save\n the " |
1403 | "address book. Please check that some \nother application is " | 1403 | "address book. Please check that some \nother application is " |
1404 | "not using it. " ); | 1404 | "not using it. " ); |
1405 | message(i18n("Saving ... please wait! "), false); | 1405 | message(i18n("Saving ... please wait! "), false); |
1406 | //qApp->processEvents(); | 1406 | //qApp->processEvents(); |
1407 | #ifndef KAB_EMBEDDED | 1407 | #ifndef KAB_EMBEDDED |
1408 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); | 1408 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); |
1409 | if ( !b || !b->save() ) { | 1409 | if ( !b || !b->save() ) { |
1410 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); | 1410 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); |
1411 | } | 1411 | } |
1412 | #else //KAB_EMBEDDED | 1412 | #else //KAB_EMBEDDED |
1413 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); | 1413 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); |
1414 | if ( !b || !b->save() ) { | 1414 | if ( !b || !b->save() ) { |
1415 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); | 1415 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); |
1416 | } | 1416 | } |
1417 | #endif //KAB_EMBEDDED | 1417 | #endif //KAB_EMBEDDED |
1418 | 1418 | ||
1419 | message(i18n("Addressbook saved!")); | 1419 | message(i18n("Addressbook saved!")); |
1420 | setModified( false ); | 1420 | setModified( false ); |
1421 | syncManager->setBlockSave(false); | 1421 | syncManager->setBlockSave(false); |
1422 | } | 1422 | } |
1423 | 1423 | ||
1424 | 1424 | ||
1425 | void KABCore::undo() | 1425 | void KABCore::undo() |
1426 | { | 1426 | { |
1427 | UndoStack::instance()->undo(); | 1427 | UndoStack::instance()->undo(); |
1428 | 1428 | ||
1429 | // Refresh the view | 1429 | // Refresh the view |
1430 | mViewManager->refreshView(); | 1430 | mViewManager->refreshView(); |
1431 | } | 1431 | } |
1432 | 1432 | ||
1433 | void KABCore::redo() | 1433 | void KABCore::redo() |
1434 | { | 1434 | { |
1435 | RedoStack::instance()->redo(); | 1435 | RedoStack::instance()->redo(); |
1436 | 1436 | ||
1437 | // Refresh the view | 1437 | // Refresh the view |
1438 | mViewManager->refreshView(); | 1438 | mViewManager->refreshView(); |
1439 | } | 1439 | } |
1440 | void KABCore::setJumpButtonBar( bool visible ) | 1440 | void KABCore::setJumpButtonBar( bool visible ) |
1441 | { | 1441 | { |
1442 | setJumpButtonBarVisible(visible ); | 1442 | setJumpButtonBarVisible(visible ); |
1443 | saveSettings(); | 1443 | saveSettings(); |
1444 | } | 1444 | } |
1445 | void KABCore::setJumpButtonBarVisible( bool visible ) | 1445 | void KABCore::setJumpButtonBarVisible( bool visible ) |
1446 | { | 1446 | { |
1447 | if (mMultipleViewsAtOnce) | 1447 | if (mMultipleViewsAtOnce) |
1448 | { | 1448 | { |
1449 | if ( visible ) | 1449 | if ( visible ) |
1450 | mJumpButtonBar->show(); | 1450 | mJumpButtonBar->show(); |
1451 | else | 1451 | else |
1452 | mJumpButtonBar->hide(); | 1452 | mJumpButtonBar->hide(); |
1453 | } | 1453 | } |
1454 | else | 1454 | else |
1455 | { | 1455 | { |
1456 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" | 1456 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" |
1457 | if (mViewManager->isVisible()) | 1457 | if (mViewManager->isVisible()) |
1458 | { | 1458 | { |
1459 | if ( visible ) | 1459 | if ( visible ) |
1460 | mJumpButtonBar->show(); | 1460 | mJumpButtonBar->show(); |
1461 | else | 1461 | else |
1462 | mJumpButtonBar->hide(); | 1462 | mJumpButtonBar->hide(); |
1463 | } | 1463 | } |
1464 | else | 1464 | else |
1465 | { | 1465 | { |
1466 | mJumpButtonBar->hide(); | 1466 | mJumpButtonBar->hide(); |
1467 | } | 1467 | } |
1468 | } | 1468 | } |
1469 | if ( visible ) { | 1469 | if ( visible ) { |
1470 | if ( mIncSearchWidget->currentItem() == 0 ) { | 1470 | if ( mIncSearchWidget->currentItem() == 0 ) { |
1471 | message( i18n("Change search field enable jump bar") ); | 1471 | message( i18n("Change search field enable jump bar") ); |
1472 | } | 1472 | } |
1473 | } | 1473 | } |
1474 | } | 1474 | } |
1475 | 1475 | ||
1476 | 1476 | ||
1477 | void KABCore::setDetailsToState() | 1477 | void KABCore::setDetailsToState() |
1478 | { | 1478 | { |
1479 | setDetailsVisible( mActionDetails->isChecked() ); | 1479 | setDetailsVisible( mActionDetails->isChecked() ); |
1480 | } | 1480 | } |
1481 | void KABCore::setDetailsToggle() | 1481 | void KABCore::setDetailsToggle() |
1482 | { | 1482 | { |
1483 | mActionDetails->setChecked( !mActionDetails->isChecked() ); | 1483 | mActionDetails->setChecked( !mActionDetails->isChecked() ); |
1484 | setDetailsToState(); | 1484 | setDetailsToState(); |
1485 | } | 1485 | } |
1486 | 1486 | ||
1487 | 1487 | ||
1488 | 1488 | ||
1489 | void KABCore::setDetailsVisible( bool visible ) | 1489 | void KABCore::setDetailsVisible( bool visible ) |
1490 | { | 1490 | { |
1491 | if (visible && mDetails->isHidden()) | 1491 | if (visible && mDetails->isHidden()) |
1492 | { | 1492 | { |
1493 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 1493 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
1494 | if ( addrList.count() > 0 ) | 1494 | if ( addrList.count() > 0 ) |
1495 | mDetails->setAddressee( addrList[ 0 ] ); | 1495 | mDetails->setAddressee( addrList[ 0 ] ); |
1496 | } | 1496 | } |
1497 | 1497 | ||
1498 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between | 1498 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between |
1499 | // the listview and the detailview. We do that by changing the splitbar size. | 1499 | // the listview and the detailview. We do that by changing the splitbar size. |
1500 | if (mMultipleViewsAtOnce) | 1500 | if (mMultipleViewsAtOnce) |
1501 | { | 1501 | { |
1502 | if ( visible ) | 1502 | if ( visible ) |
1503 | mDetails->show(); | 1503 | mDetails->show(); |
1504 | else | 1504 | else |
1505 | mDetails->hide(); | 1505 | mDetails->hide(); |
1506 | } | 1506 | } |
1507 | else | 1507 | else |
1508 | { | 1508 | { |
1509 | if ( visible ) { | 1509 | if ( visible ) { |
1510 | mViewManager->hide(); | 1510 | mViewManager->hide(); |
1511 | mDetails->show(); | 1511 | mDetails->show(); |
1512 | mIncSearchWidget->setFocus(); | 1512 | mIncSearchWidget->setFocus(); |
1513 | } | 1513 | } |
1514 | else { | 1514 | else { |
1515 | mViewManager->show(); | 1515 | mViewManager->show(); |
1516 | mDetails->hide(); | 1516 | mDetails->hide(); |
1517 | mViewManager->setFocusAV(); | 1517 | mViewManager->setFocusAV(); |
1518 | } | 1518 | } |
1519 | setJumpButtonBarVisible( !visible ); | 1519 | setJumpButtonBarVisible( !visible ); |
1520 | } | 1520 | } |
1521 | 1521 | ||
1522 | } | 1522 | } |
1523 | 1523 | ||
1524 | void KABCore::extensionChanged( int id ) | 1524 | void KABCore::extensionChanged( int id ) |
1525 | { | 1525 | { |
1526 | //change the details view only for non desktop systems | 1526 | //change the details view only for non desktop systems |
1527 | #ifndef DESKTOP_VERSION | 1527 | #ifndef DESKTOP_VERSION |
1528 | 1528 | ||
1529 | if (id == 0) | 1529 | if (id == 0) |
1530 | { | 1530 | { |
1531 | //the user disabled the extension. | 1531 | //the user disabled the extension. |
1532 | 1532 | ||
1533 | if (mMultipleViewsAtOnce) | 1533 | if (mMultipleViewsAtOnce) |
1534 | { // enable detailsview again | 1534 | { // enable detailsview again |
1535 | setDetailsVisible( true ); | 1535 | setDetailsVisible( true ); |
1536 | mActionDetails->setChecked( true ); | 1536 | mActionDetails->setChecked( true ); |
1537 | } | 1537 | } |
1538 | else | 1538 | else |
1539 | { //go back to the listview | 1539 | { //go back to the listview |
1540 | setDetailsVisible( false ); | 1540 | setDetailsVisible( false ); |
1541 | mActionDetails->setChecked( false ); | 1541 | mActionDetails->setChecked( false ); |
1542 | mActionDetails->setEnabled(true); | 1542 | mActionDetails->setEnabled(true); |
1543 | } | 1543 | } |
1544 | 1544 | ||
1545 | } | 1545 | } |
1546 | else | 1546 | else |
1547 | { | 1547 | { |
1548 | //the user enabled the extension. | 1548 | //the user enabled the extension. |
1549 | setDetailsVisible( false ); | 1549 | setDetailsVisible( false ); |
1550 | mActionDetails->setChecked( false ); | 1550 | mActionDetails->setChecked( false ); |
1551 | 1551 | ||
1552 | if (!mMultipleViewsAtOnce) | 1552 | if (!mMultipleViewsAtOnce) |
1553 | { | 1553 | { |
1554 | mActionDetails->setEnabled(false); | 1554 | mActionDetails->setEnabled(false); |
1555 | } | 1555 | } |
1556 | 1556 | ||
1557 | mExtensionManager->setSelectionChanged(); | 1557 | mExtensionManager->setSelectionChanged(); |
1558 | 1558 | ||
1559 | } | 1559 | } |
1560 | 1560 | ||
1561 | #endif// DESKTOP_VERSION | 1561 | #endif// DESKTOP_VERSION |
1562 | 1562 | ||
1563 | } | 1563 | } |
1564 | 1564 | ||
1565 | 1565 | ||
1566 | void KABCore::extensionModified( const KABC::Addressee::List &list ) | 1566 | void KABCore::extensionModified( const KABC::Addressee::List &list ) |
1567 | { | 1567 | { |
1568 | 1568 | ||
1569 | if ( list.count() != 0 ) { | 1569 | if ( list.count() != 0 ) { |
1570 | KABC::Addressee::List::ConstIterator it; | 1570 | KABC::Addressee::List::ConstIterator it; |
1571 | for ( it = list.begin(); it != list.end(); ++it ) | 1571 | for ( it = list.begin(); it != list.end(); ++it ) |
1572 | mAddressBook->insertAddressee( *it ); | 1572 | mAddressBook->insertAddressee( *it ); |
1573 | if ( list.count() > 1 ) | 1573 | if ( list.count() > 1 ) |
1574 | setModified(); | 1574 | setModified(); |
1575 | else | 1575 | else |
1576 | setModifiedWOrefresh(); | 1576 | setModifiedWOrefresh(); |
1577 | } | 1577 | } |
1578 | if ( list.count() == 0 ) | 1578 | if ( list.count() == 0 ) |
1579 | mViewManager->refreshView(); | 1579 | mViewManager->refreshView(); |
1580 | else | 1580 | else |
1581 | mViewManager->refreshView( list[ 0 ].uid() ); | 1581 | mViewManager->refreshView( list[ 0 ].uid() ); |
1582 | 1582 | ||
1583 | 1583 | ||
1584 | 1584 | ||
1585 | } | 1585 | } |
1586 | 1586 | ||
1587 | QString KABCore::getNameByPhone( const QString &phone ) | 1587 | QString KABCore::getNameByPhone( const QString &phone ) |
1588 | { | 1588 | { |
1589 | #ifndef KAB_EMBEDDED | 1589 | #ifndef KAB_EMBEDDED |
1590 | QRegExp r( "[/*/-/ ]" ); | 1590 | QRegExp r( "[/*/-/ ]" ); |
1591 | QString localPhone( phone ); | 1591 | QString localPhone( phone ); |
1592 | 1592 | ||
1593 | bool found = false; | 1593 | bool found = false; |
1594 | QString ownerName = ""; | 1594 | QString ownerName = ""; |
1595 | KABC::AddressBook::Iterator iter; | 1595 | KABC::AddressBook::Iterator iter; |
1596 | KABC::PhoneNumber::List::Iterator phoneIter; | 1596 | KABC::PhoneNumber::List::Iterator phoneIter; |
1597 | KABC::PhoneNumber::List phoneList; | 1597 | KABC::PhoneNumber::List phoneList; |
1598 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { | 1598 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { |
1599 | phoneList = (*iter).phoneNumbers(); | 1599 | phoneList = (*iter).phoneNumbers(); |
1600 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); | 1600 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); |
1601 | ++phoneIter) { | 1601 | ++phoneIter) { |
1602 | // Get rid of separator chars so just the numbers are compared. | 1602 | // Get rid of separator chars so just the numbers are compared. |
1603 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { | 1603 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { |
1604 | ownerName = (*iter).formattedName(); | 1604 | ownerName = (*iter).formattedName(); |
1605 | found = true; | 1605 | found = true; |
1606 | } | 1606 | } |
1607 | } | 1607 | } |
1608 | } | 1608 | } |
1609 | 1609 | ||
1610 | return ownerName; | 1610 | return ownerName; |
1611 | #else //KAB_EMBEDDED | 1611 | #else //KAB_EMBEDDED |
1612 | qDebug("KABCore::getNameByPhone finsih method"); | 1612 | qDebug("KABCore::getNameByPhone finsih method"); |
1613 | return ""; | 1613 | return ""; |
1614 | #endif //KAB_EMBEDDED | 1614 | #endif //KAB_EMBEDDED |
1615 | 1615 | ||
1616 | } | 1616 | } |
1617 | 1617 | ||
1618 | void KABCore::openConfigDialog() | 1618 | void KABCore::openConfigDialog() |
1619 | { | 1619 | { |
1620 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); | 1620 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); |
1621 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); | 1621 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); |
1622 | ConfigureDialog->addModule(kabcfg ); | 1622 | ConfigureDialog->addModule(kabcfg ); |
1623 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); | 1623 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); |
1624 | ConfigureDialog->addModule(kdelibcfg ); | 1624 | ConfigureDialog->addModule(kdelibcfg ); |
1625 | 1625 | ||
1626 | connect( ConfigureDialog, SIGNAL( applyClicked() ), | 1626 | connect( ConfigureDialog, SIGNAL( applyClicked() ), |
1627 | this, SLOT( configurationChanged() ) ); | 1627 | this, SLOT( configurationChanged() ) ); |
1628 | connect( ConfigureDialog, SIGNAL( okClicked() ), | 1628 | connect( ConfigureDialog, SIGNAL( okClicked() ), |
1629 | this, SLOT( configurationChanged() ) ); | 1629 | this, SLOT( configurationChanged() ) ); |
1630 | saveSettings(); | 1630 | saveSettings(); |
1631 | #ifndef DESKTOP_VERSION | 1631 | #ifndef DESKTOP_VERSION |
1632 | ConfigureDialog->showMaximized(); | 1632 | ConfigureDialog->showMaximized(); |
1633 | #endif | 1633 | #endif |
1634 | if ( ConfigureDialog->exec() ) | 1634 | if ( ConfigureDialog->exec() ) |
1635 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); | 1635 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); |
1636 | delete ConfigureDialog; | 1636 | delete ConfigureDialog; |
1637 | } | 1637 | } |
1638 | 1638 | ||
1639 | void KABCore::openLDAPDialog() | 1639 | void KABCore::openLDAPDialog() |
1640 | { | 1640 | { |
1641 | #ifndef KAB_EMBEDDED | 1641 | #ifndef KAB_EMBEDDED |
1642 | if ( !mLdapSearchDialog ) { | 1642 | if ( !mLdapSearchDialog ) { |
1643 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); | 1643 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); |
1644 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, | 1644 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, |
1645 | SLOT( refreshView() ) ); | 1645 | SLOT( refreshView() ) ); |
1646 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, | 1646 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, |
1647 | SLOT( setModified() ) ); | 1647 | SLOT( setModified() ) ); |
1648 | } else | 1648 | } else |
1649 | mLdapSearchDialog->restoreSettings(); | 1649 | mLdapSearchDialog->restoreSettings(); |
1650 | 1650 | ||
1651 | if ( mLdapSearchDialog->isOK() ) | 1651 | if ( mLdapSearchDialog->isOK() ) |
1652 | mLdapSearchDialog->exec(); | 1652 | mLdapSearchDialog->exec(); |
1653 | #else //KAB_EMBEDDED | 1653 | #else //KAB_EMBEDDED |
1654 | qDebug("KABCore::openLDAPDialog() finsih method"); | 1654 | qDebug("KABCore::openLDAPDialog() finsih method"); |
1655 | #endif //KAB_EMBEDDED | 1655 | #endif //KAB_EMBEDDED |
1656 | } | 1656 | } |
1657 | 1657 | ||
1658 | void KABCore::print() | 1658 | void KABCore::print() |
1659 | { | 1659 | { |
1660 | #ifndef KAB_EMBEDDED | 1660 | #ifndef KAB_EMBEDDED |
1661 | KPrinter printer; | 1661 | KPrinter printer; |
1662 | if ( !printer.setup( this ) ) | 1662 | if ( !printer.setup( this ) ) |
1663 | return; | 1663 | return; |
1664 | 1664 | ||
1665 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, | 1665 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, |
1666 | mViewManager->selectedUids(), this ); | 1666 | mViewManager->selectedUids(), this ); |
1667 | 1667 | ||
1668 | wizard.exec(); | 1668 | wizard.exec(); |
1669 | #else //KAB_EMBEDDED | 1669 | #else //KAB_EMBEDDED |
1670 | qDebug("KABCore::print() finsih method"); | 1670 | qDebug("KABCore::print() finsih method"); |
1671 | #endif //KAB_EMBEDDED | 1671 | #endif //KAB_EMBEDDED |
1672 | 1672 | ||
1673 | } | 1673 | } |
1674 | 1674 | ||
1675 | 1675 | ||
1676 | void KABCore::addGUIClient( KXMLGUIClient *client ) | 1676 | void KABCore::addGUIClient( KXMLGUIClient *client ) |
1677 | { | 1677 | { |
1678 | if ( mGUIClient ) | 1678 | if ( mGUIClient ) |
1679 | mGUIClient->insertChildClient( client ); | 1679 | mGUIClient->insertChildClient( client ); |
1680 | else | 1680 | else |
1681 | KMessageBox::error( this, "no KXMLGUICLient"); | 1681 | KMessageBox::error( this, "no KXMLGUICLient"); |
1682 | } | 1682 | } |
1683 | 1683 | ||
1684 | 1684 | ||
1685 | void KABCore::configurationChanged() | 1685 | void KABCore::configurationChanged() |
1686 | { | 1686 | { |
1687 | mExtensionManager->reconfigure(); | 1687 | mExtensionManager->reconfigure(); |
1688 | } | 1688 | } |
1689 | 1689 | ||
1690 | void KABCore::addressBookChanged() | 1690 | void KABCore::addressBookChanged() |
1691 | { | 1691 | { |
1692 | /*US | 1692 | /*US |
1693 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); | 1693 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); |
1694 | while ( it.current() ) { | 1694 | while ( it.current() ) { |
1695 | if ( it.current()->dirty() ) { | 1695 | if ( it.current()->dirty() ) { |
1696 | QString text = i18n( "Data has been changed externally. Unsaved " | 1696 | QString text = i18n( "Data has been changed externally. Unsaved " |
1697 | "changes will be lost." ); | 1697 | "changes will be lost." ); |
1698 | KMessageBox::information( this, text ); | 1698 | KMessageBox::information( this, text ); |
1699 | } | 1699 | } |
1700 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); | 1700 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); |
1701 | ++it; | 1701 | ++it; |
1702 | } | 1702 | } |
1703 | */ | 1703 | */ |
1704 | if (mEditorDialog) | 1704 | if (mEditorDialog) |
1705 | { | 1705 | { |
1706 | if (mEditorDialog->dirty()) | 1706 | if (mEditorDialog->dirty()) |
1707 | { | 1707 | { |
1708 | QString text = i18n( "Data has been changed externally. Unsaved " | 1708 | QString text = i18n( "Data has been changed externally. Unsaved " |
1709 | "changes will be lost." ); | 1709 | "changes will be lost." ); |
1710 | KMessageBox::information( this, text ); | 1710 | KMessageBox::information( this, text ); |
1711 | } | 1711 | } |
1712 | QString currentuid = mEditorDialog->addressee().uid(); | 1712 | QString currentuid = mEditorDialog->addressee().uid(); |
1713 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); | 1713 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); |
1714 | } | 1714 | } |
1715 | mViewManager->refreshView(); | 1715 | mViewManager->refreshView(); |
1716 | 1716 | ||
1717 | 1717 | ||
1718 | } | 1718 | } |
1719 | 1719 | ||
1720 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, | 1720 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, |
1721 | const char *name ) | 1721 | const char *name ) |
1722 | { | 1722 | { |
1723 | 1723 | ||
1724 | if ( mEditorDialog == 0 ) { | 1724 | if ( mEditorDialog == 0 ) { |
1725 | mEditorDialog = new AddresseeEditorDialog( this, parent, | 1725 | mEditorDialog = new AddresseeEditorDialog( this, parent, |
1726 | name ? name : "editorDialog" ); | 1726 | name ? name : "editorDialog" ); |
1727 | 1727 | ||
1728 | 1728 | ||
1729 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), | 1729 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), |
1730 | SLOT( contactModified( const KABC::Addressee& ) ) ); | 1730 | SLOT( contactModified( const KABC::Addressee& ) ) ); |
1731 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), | 1731 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), |
1732 | // SLOT( slotEditorDestroyed( const QString& ) ) ; | 1732 | // SLOT( slotEditorDestroyed( const QString& ) ) ; |
1733 | } | 1733 | } |
1734 | 1734 | ||
1735 | return mEditorDialog; | 1735 | return mEditorDialog; |
1736 | } | 1736 | } |
1737 | 1737 | ||
1738 | void KABCore::slotEditorDestroyed( const QString &uid ) | 1738 | void KABCore::slotEditorDestroyed( const QString &uid ) |
1739 | { | 1739 | { |
1740 | //mEditorDict.remove( uid ); | 1740 | //mEditorDict.remove( uid ); |
1741 | } | 1741 | } |
1742 | 1742 | ||
1743 | void KABCore::initGUI() | 1743 | void KABCore::initGUI() |
1744 | { | 1744 | { |
1745 | #ifndef KAB_EMBEDDED | 1745 | #ifndef KAB_EMBEDDED |
1746 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1746 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1747 | topLayout->setSpacing( KDialogBase::spacingHint() ); | 1747 | topLayout->setSpacing( KDialogBase::spacingHint() ); |
1748 | 1748 | ||
1749 | mExtensionBarSplitter = new QSplitter( this ); | 1749 | mExtensionBarSplitter = new QSplitter( this ); |
1750 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); | 1750 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); |
1751 | 1751 | ||
1752 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); | 1752 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); |
1753 | 1753 | ||
1754 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1754 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1755 | mIncSearchWidget = new IncSearchWidget( viewSpace ); | 1755 | mIncSearchWidget = new IncSearchWidget( viewSpace ); |
1756 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1756 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1757 | SLOT( incrementalSearch( const QString& ) ) ); | 1757 | SLOT( incrementalSearch( const QString& ) ) ); |
1758 | 1758 | ||
1759 | mViewManager = new ViewManager( this, viewSpace ); | 1759 | mViewManager = new ViewManager( this, viewSpace ); |
1760 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1760 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1761 | 1761 | ||
1762 | mDetails = new ViewContainer( mDetailsSplitter ); | 1762 | mDetails = new ViewContainer( mDetailsSplitter ); |
1763 | 1763 | ||
1764 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1764 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1765 | 1765 | ||
1766 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1766 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1767 | 1767 | ||
1768 | topLayout->addWidget( mExtensionBarSplitter ); | 1768 | topLayout->addWidget( mExtensionBarSplitter ); |
1769 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); | 1769 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); |
1770 | topLayout->addWidget( mJumpButtonBar ); | 1770 | topLayout->addWidget( mJumpButtonBar ); |
1771 | //topLayout->setStretchFactor( mJumpButtonBar, 1 ); | 1771 | //topLayout->setStretchFactor( mJumpButtonBar, 1 ); |
1772 | 1772 | ||
1773 | mXXPortManager = new XXPortManager( this, this ); | 1773 | mXXPortManager = new XXPortManager( this, this ); |
1774 | 1774 | ||
1775 | #else //KAB_EMBEDDED | 1775 | #else //KAB_EMBEDDED |
1776 | //US initialize viewMenu before settingup viewmanager. | 1776 | //US initialize viewMenu before settingup viewmanager. |
1777 | // Viewmanager needs this menu to plugin submenues. | 1777 | // Viewmanager needs this menu to plugin submenues. |
1778 | viewMenu = new QPopupMenu( this ); | 1778 | viewMenu = new QPopupMenu( this ); |
1779 | settingsMenu = new QPopupMenu( this ); | 1779 | settingsMenu = new QPopupMenu( this ); |
1780 | //filterMenu = new QPopupMenu( this ); | 1780 | //filterMenu = new QPopupMenu( this ); |
1781 | ImportMenu = new QPopupMenu( this ); | 1781 | ImportMenu = new QPopupMenu( this ); |
1782 | ExportMenu = new QPopupMenu( this ); | 1782 | ExportMenu = new QPopupMenu( this ); |
1783 | syncMenu = new QPopupMenu( this ); | 1783 | syncMenu = new QPopupMenu( this ); |
1784 | changeMenu= new QPopupMenu( this ); | 1784 | changeMenu= new QPopupMenu( this ); |
1785 | beamMenu= new QPopupMenu( this ); | 1785 | beamMenu= new QPopupMenu( this ); |
1786 | 1786 | ||
1787 | //US since we have no splitter for the embedded system, setup | 1787 | //US since we have no splitter for the embedded system, setup |
1788 | // a layout with two frames. One left and one right. | 1788 | // a layout with two frames. One left and one right. |
1789 | 1789 | ||
1790 | QBoxLayout *topLayout; | 1790 | QBoxLayout *topLayout; |
1791 | 1791 | ||
1792 | // = new QHBoxLayout( this ); | 1792 | // = new QHBoxLayout( this ); |
1793 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); | 1793 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); |
1794 | 1794 | ||
1795 | // QWidget *mainBox = new QWidget( this ); | 1795 | // QWidget *mainBox = new QWidget( this ); |
1796 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); | 1796 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); |
1797 | 1797 | ||
1798 | #ifdef DESKTOP_VERSION | 1798 | #ifdef DESKTOP_VERSION |
1799 | topLayout = new QHBoxLayout( this ); | 1799 | topLayout = new QHBoxLayout( this ); |
1800 | 1800 | ||
1801 | 1801 | ||
1802 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1802 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1803 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1803 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1804 | 1804 | ||
1805 | topLayout->addWidget(mMiniSplitter ); | 1805 | topLayout->addWidget(mMiniSplitter ); |
1806 | 1806 | ||
1807 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); | 1807 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); |
1808 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1808 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1809 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); | 1809 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); |
1810 | mDetails = new ViewContainer( mMiniSplitter ); | 1810 | mDetails = new ViewContainer( mMiniSplitter ); |
1811 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1811 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1812 | #else | 1812 | #else |
1813 | if ( QApplication::desktop()->width() > 480 ) { | 1813 | if ( QApplication::desktop()->width() > 480 ) { |
1814 | topLayout = new QHBoxLayout( this ); | 1814 | topLayout = new QHBoxLayout( this ); |
1815 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1815 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1816 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1816 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1817 | } else { | 1817 | } else { |
1818 | 1818 | ||
1819 | topLayout = new QHBoxLayout( this ); | 1819 | topLayout = new QHBoxLayout( this ); |
1820 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); | 1820 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); |
1821 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1821 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1822 | } | 1822 | } |
1823 | 1823 | ||
1824 | topLayout->addWidget(mMiniSplitter ); | 1824 | topLayout->addWidget(mMiniSplitter ); |
1825 | mViewManager = new ViewManager( this, mMiniSplitter ); | 1825 | mViewManager = new ViewManager( this, mMiniSplitter ); |
1826 | mDetails = new ViewContainer( mMiniSplitter ); | 1826 | mDetails = new ViewContainer( mMiniSplitter ); |
1827 | 1827 | ||
1828 | 1828 | ||
1829 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); | 1829 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); |
1830 | #endif | 1830 | #endif |
1831 | //eh->hide(); | 1831 | //eh->hide(); |
1832 | // topLayout->addWidget(mExtensionManager ); | 1832 | // topLayout->addWidget(mExtensionManager ); |
1833 | 1833 | ||
1834 | 1834 | ||
1835 | /*US | 1835 | /*US |
1836 | #ifndef KAB_NOSPLITTER | 1836 | #ifndef KAB_NOSPLITTER |
1837 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1837 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1838 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1838 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1839 | topLayout->setSpacing( 10 ); | 1839 | topLayout->setSpacing( 10 ); |
1840 | 1840 | ||
1841 | mDetailsSplitter = new QSplitter( this ); | 1841 | mDetailsSplitter = new QSplitter( this ); |
1842 | 1842 | ||
1843 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1843 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1844 | 1844 | ||
1845 | mViewManager = new ViewManager( this, viewSpace ); | 1845 | mViewManager = new ViewManager( this, viewSpace ); |
1846 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1846 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1847 | 1847 | ||
1848 | mDetails = new ViewContainer( mDetailsSplitter ); | 1848 | mDetails = new ViewContainer( mDetailsSplitter ); |
1849 | 1849 | ||
1850 | topLayout->addWidget( mDetailsSplitter ); | 1850 | topLayout->addWidget( mDetailsSplitter ); |
1851 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1851 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1852 | #else //KAB_NOSPLITTER | 1852 | #else //KAB_NOSPLITTER |
1853 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1853 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1854 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1854 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1855 | topLayout->setSpacing( 10 ); | 1855 | topLayout->setSpacing( 10 ); |
1856 | 1856 | ||
1857 | // mDetailsSplitter = new QSplitter( this ); | 1857 | // mDetailsSplitter = new QSplitter( this ); |
1858 | 1858 | ||
1859 | QVBox *viewSpace = new QVBox( this ); | 1859 | QVBox *viewSpace = new QVBox( this ); |
1860 | 1860 | ||
1861 | mViewManager = new ViewManager( this, viewSpace ); | 1861 | mViewManager = new ViewManager( this, viewSpace ); |
1862 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1862 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1863 | 1863 | ||
1864 | mDetails = new ViewContainer( this ); | 1864 | mDetails = new ViewContainer( this ); |
1865 | 1865 | ||
1866 | topLayout->addWidget( viewSpace ); | 1866 | topLayout->addWidget( viewSpace ); |
1867 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1867 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1868 | topLayout->addWidget( mDetails ); | 1868 | topLayout->addWidget( mDetails ); |
1869 | #endif //KAB_NOSPLITTER | 1869 | #endif //KAB_NOSPLITTER |
1870 | */ | 1870 | */ |
1871 | 1871 | ||
1872 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); | 1872 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); |
1873 | syncManager->setBlockSave(false); | 1873 | syncManager->setBlockSave(false); |
1874 | 1874 | ||
1875 | connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); | 1875 | connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); |
1876 | connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); | 1876 | connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); |
1877 | QString sync_file = sentSyncFile(); | 1877 | QString sync_file = sentSyncFile(); |
1878 | //qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1()); | 1878 | //qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1()); |
1879 | syncManager->setDefaultFileName( sync_file ); | 1879 | syncManager->setDefaultFileName( sync_file ); |
1880 | //connect(syncManager , SIGNAL( ), this, SLOT( ) ); | 1880 | //connect(syncManager , SIGNAL( ), this, SLOT( ) ); |
1881 | 1881 | ||
1882 | #endif //KAB_EMBEDDED | 1882 | #endif //KAB_EMBEDDED |
1883 | initActions(); | 1883 | initActions(); |
1884 | 1884 | ||
1885 | #ifdef KAB_EMBEDDED | 1885 | #ifdef KAB_EMBEDDED |
1886 | addActionsManually(); | 1886 | addActionsManually(); |
1887 | //US make sure the export and import menues are initialized before creating the xxPortManager. | 1887 | //US make sure the export and import menues are initialized before creating the xxPortManager. |
1888 | mXXPortManager = new XXPortManager( this, this ); | 1888 | mXXPortManager = new XXPortManager( this, this ); |
1889 | 1889 | ||
1890 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); | 1890 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); |
1891 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); | 1891 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); |
1892 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1892 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1893 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); | 1893 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); |
1894 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); | 1894 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); |
1895 | // mIncSearchWidget->hide(); | 1895 | // mIncSearchWidget->hide(); |
1896 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1896 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1897 | SLOT( incrementalSearch( const QString& ) ) ); | 1897 | SLOT( incrementalSearch( const QString& ) ) ); |
1898 | connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); | 1898 | connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); |
1899 | connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); | 1899 | connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); |
1900 | 1900 | ||
1901 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1901 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1902 | 1902 | ||
1903 | topLayout->addWidget( mJumpButtonBar ); | 1903 | topLayout->addWidget( mJumpButtonBar ); |
1904 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); | 1904 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); |
1905 | 1905 | ||
1906 | // mMainWindow->getIconToolBar()->raise(); | 1906 | // mMainWindow->getIconToolBar()->raise(); |
1907 | 1907 | ||
1908 | #endif //KAB_EMBEDDED | 1908 | #endif //KAB_EMBEDDED |
1909 | 1909 | ||
1910 | } | 1910 | } |
1911 | void KABCore::initActions() | 1911 | void KABCore::initActions() |
1912 | { | 1912 | { |
1913 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1913 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1914 | 1914 | ||
1915 | #ifndef KAB_EMBEDDED | 1915 | #ifndef KAB_EMBEDDED |
1916 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), | 1916 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), |
1917 | SLOT( clipboardDataChanged() ) ); | 1917 | SLOT( clipboardDataChanged() ) ); |
1918 | #endif //KAB_EMBEDDED | 1918 | #endif //KAB_EMBEDDED |
1919 | 1919 | ||
1920 | // file menu | 1920 | // file menu |
1921 | 1921 | ||
1922 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); | 1922 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); |
1923 | //mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); | 1923 | //mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); |
1924 | mActionPrint = new KAction( i18n( "&Print View" ), "fileprint", CTRL + Key_P, mViewManager, | 1924 | mActionPrint = new KAction( i18n( "&Print View" ), "fileprint", CTRL + Key_P, mViewManager, |
1925 | SLOT( printView() ), actionCollection(), "kaddressbook_print" ); | 1925 | SLOT( printView() ), actionCollection(), "kaddressbook_print" ); |
1926 | 1926 | ||
1927 | 1927 | ||
1928 | mActionPrintDetails = new KAction( i18n( "&Print Details" ), "fileprint", 0, mDetails, | 1928 | mActionPrintDetails = new KAction( i18n( "&Print Details" ), "fileprint", 0, mDetails, |
1929 | SLOT( printView() ), actionCollection(), "kaddressbook_print2" ); | 1929 | SLOT( printView() ), actionCollection(), "kaddressbook_print2" ); |
1930 | 1930 | ||
1931 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, | 1931 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, |
1932 | SLOT( save() ), actionCollection(), "file_sync" ); | 1932 | SLOT( save() ), actionCollection(), "file_sync" ); |
1933 | 1933 | ||
1934 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, | 1934 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, |
1935 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); | 1935 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); |
1936 | 1936 | ||
1937 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, | 1937 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, |
1938 | this, SLOT( mailVCard() ), | 1938 | this, SLOT( mailVCard() ), |
1939 | actionCollection(), "file_mail_vcard"); | 1939 | actionCollection(), "file_mail_vcard"); |
1940 | 1940 | ||
1941 | mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this, | 1941 | mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this, |
1942 | SLOT( export2phone() ), actionCollection(), | 1942 | SLOT( export2phone() ), actionCollection(), |
1943 | "kaddressbook_ex2phone" ); | 1943 | "kaddressbook_ex2phone" ); |
1944 | 1944 | ||
1945 | mActionBeamVCard = 0; | 1945 | mActionBeamVCard = 0; |
1946 | mActionBeam = 0; | 1946 | mActionBeam = 0; |
1947 | 1947 | ||
1948 | #ifndef DESKTOP_VERSION | 1948 | #ifndef DESKTOP_VERSION |
1949 | if ( Ir::supported() ) { | 1949 | if ( Ir::supported() ) { |
1950 | mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this, | 1950 | mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this, |
1951 | SLOT( beamVCard() ), actionCollection(), | 1951 | SLOT( beamVCard() ), actionCollection(), |
1952 | "kaddressbook_beam_vcard" ); | 1952 | "kaddressbook_beam_vcard" ); |
1953 | 1953 | ||
1954 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, | 1954 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, |
1955 | SLOT( beamMySelf() ), actionCollection(), | 1955 | SLOT( beamMySelf() ), actionCollection(), |
1956 | "kaddressbook_beam_myself" ); | 1956 | "kaddressbook_beam_myself" ); |
1957 | } | 1957 | } |
1958 | #endif | 1958 | #endif |
1959 | 1959 | ||
1960 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, | 1960 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, |
1961 | this, SLOT( editContact2() ), | 1961 | this, SLOT( editContact2() ), |
1962 | actionCollection(), "file_properties" ); | 1962 | actionCollection(), "file_properties" ); |
1963 | 1963 | ||
1964 | #ifdef KAB_EMBEDDED | 1964 | #ifdef KAB_EMBEDDED |
1965 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); | 1965 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); |
1966 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, | 1966 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, |
1967 | mMainWindow, SLOT( exit() ), | 1967 | mMainWindow, SLOT( exit() ), |
1968 | actionCollection(), "quit" ); | 1968 | actionCollection(), "quit" ); |
1969 | #endif //KAB_EMBEDDED | 1969 | #endif //KAB_EMBEDDED |
1970 | 1970 | ||
1971 | // edit menu | 1971 | // edit menu |
1972 | if ( mIsPart ) { | 1972 | if ( mIsPart ) { |
1973 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, | 1973 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, |
1974 | SLOT( copyContacts() ), actionCollection(), | 1974 | SLOT( copyContacts() ), actionCollection(), |
1975 | "kaddressbook_copy" ); | 1975 | "kaddressbook_copy" ); |
1976 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, | 1976 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, |
1977 | SLOT( cutContacts() ), actionCollection(), | 1977 | SLOT( cutContacts() ), actionCollection(), |
1978 | "kaddressbook_cut" ); | 1978 | "kaddressbook_cut" ); |
1979 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, | 1979 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, |
1980 | SLOT( pasteContacts() ), actionCollection(), | 1980 | SLOT( pasteContacts() ), actionCollection(), |
1981 | "kaddressbook_paste" ); | 1981 | "kaddressbook_paste" ); |
1982 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, | 1982 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, |
1983 | SLOT( selectAllContacts() ), actionCollection(), | 1983 | SLOT( selectAllContacts() ), actionCollection(), |
1984 | "kaddressbook_select_all" ); | 1984 | "kaddressbook_select_all" ); |
1985 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, | 1985 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, |
1986 | SLOT( undo() ), actionCollection(), | 1986 | SLOT( undo() ), actionCollection(), |
1987 | "kaddressbook_undo" ); | 1987 | "kaddressbook_undo" ); |
1988 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, | 1988 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, |
1989 | this, SLOT( redo() ), actionCollection(), | 1989 | this, SLOT( redo() ), actionCollection(), |
1990 | "kaddressbook_redo" ); | 1990 | "kaddressbook_redo" ); |
1991 | } else { | 1991 | } else { |
1992 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); | 1992 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); |
1993 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); | 1993 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); |
1994 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); | 1994 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); |
1995 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); | 1995 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); |
1996 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); | 1996 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); |
1997 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); | 1997 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); |
1998 | } | 1998 | } |
1999 | 1999 | ||
2000 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", | 2000 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", |
2001 | Key_Delete, this, SLOT( deleteContacts() ), | 2001 | Key_Delete, this, SLOT( deleteContacts() ), |
2002 | actionCollection(), "edit_delete" ); | 2002 | actionCollection(), "edit_delete" ); |
2003 | 2003 | ||
2004 | mActionUndo->setEnabled( false ); | 2004 | mActionUndo->setEnabled( false ); |
2005 | mActionRedo->setEnabled( false ); | 2005 | mActionRedo->setEnabled( false ); |
2006 | 2006 | ||
2007 | // settings menu | 2007 | // settings menu |
2008 | #ifdef KAB_EMBEDDED | 2008 | #ifdef KAB_EMBEDDED |
2009 | //US special menuentry to configure the addressbook resources. On KDE | 2009 | //US special menuentry to configure the addressbook resources. On KDE |
2010 | // you do that through the control center !!! | 2010 | // you do that through the control center !!! |
2011 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, | 2011 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, |
2012 | SLOT( configureResources() ), actionCollection(), | 2012 | SLOT( configureResources() ), actionCollection(), |
2013 | "kaddressbook_configure_resources" ); | 2013 | "kaddressbook_configure_resources" ); |
2014 | #endif //KAB_EMBEDDED | 2014 | #endif //KAB_EMBEDDED |
2015 | 2015 | ||
2016 | if ( mIsPart ) { | 2016 | if ( mIsPart ) { |
2017 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, | 2017 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, |
2018 | SLOT( openConfigDialog() ), actionCollection(), | 2018 | SLOT( openConfigDialog() ), actionCollection(), |
2019 | "kaddressbook_configure" ); | 2019 | "kaddressbook_configure" ); |
2020 | 2020 | ||
2021 | //US not implemented yet | 2021 | //US not implemented yet |
2022 | //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, | 2022 | //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, |
2023 | // this, SLOT( configureKeyBindings() ), actionCollection(), | 2023 | // this, SLOT( configureKeyBindings() ), actionCollection(), |
2024 | // "kaddressbook_configure_shortcuts" ); | 2024 | // "kaddressbook_configure_shortcuts" ); |
2025 | #ifdef KAB_EMBEDDED | 2025 | #ifdef KAB_EMBEDDED |
2026 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); | 2026 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); |
2027 | mActionConfigureToolbars->setEnabled( false ); | 2027 | mActionConfigureToolbars->setEnabled( false ); |
2028 | #endif //KAB_EMBEDDED | 2028 | #endif //KAB_EMBEDDED |
2029 | 2029 | ||
2030 | } else { | 2030 | } else { |
2031 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); | 2031 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); |
2032 | 2032 | ||
2033 | //US not implemented yet | 2033 | //US not implemented yet |
2034 | //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); | 2034 | //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); |
2035 | } | 2035 | } |
2036 | 2036 | ||
2037 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, | 2037 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, |
2038 | actionCollection(), "options_show_jump_bar" ); | 2038 | actionCollection(), "options_show_jump_bar" ); |
2039 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBar( bool ) ) ); | 2039 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBar( bool ) ) ); |
2040 | 2040 | ||
2041 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, | 2041 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, |
2042 | actionCollection(), "options_show_details" ); | 2042 | actionCollection(), "options_show_details" ); |
2043 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); | 2043 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); |
2044 | 2044 | ||
2045 | 2045 | ||
2046 | mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, | 2046 | mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, |
2047 | SLOT( toggleBeamReceive() ), actionCollection(), | 2047 | SLOT( toggleBeamReceive() ), actionCollection(), |
2048 | "kaddressbook_beam_rec" ); | 2048 | "kaddressbook_beam_rec" ); |
2049 | 2049 | ||
2050 | 2050 | ||
2051 | // misc | 2051 | // misc |
2052 | // only enable LDAP lookup if we can handle the protocol | 2052 | // only enable LDAP lookup if we can handle the protocol |
2053 | #ifndef KAB_EMBEDDED | 2053 | #ifndef KAB_EMBEDDED |
2054 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { | 2054 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { |
2055 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, | 2055 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, |
2056 | this, SLOT( openLDAPDialog() ), actionCollection(), | 2056 | this, SLOT( openLDAPDialog() ), actionCollection(), |
2057 | "ldap_lookup" ); | 2057 | "ldap_lookup" ); |
2058 | } | 2058 | } |
2059 | #else //KAB_EMBEDDED | 2059 | #else //KAB_EMBEDDED |
2060 | //qDebug("KABCore::initActions() LDAP has to be implemented"); | 2060 | //qDebug("KABCore::initActions() LDAP has to be implemented"); |
2061 | #endif //KAB_EMBEDDED | 2061 | #endif //KAB_EMBEDDED |
2062 | 2062 | ||
2063 | 2063 | ||
2064 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, | 2064 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, |
2065 | SLOT( setWhoAmI() ), actionCollection(), | 2065 | SLOT( setWhoAmI() ), actionCollection(), |
2066 | "set_personal" ); | 2066 | "set_personal" ); |
2067 | 2067 | ||
2068 | 2068 | ||
2069 | mActionCategories = new KAction( i18n( "Set Categories for Contacts..." ), 0, this, | 2069 | mActionCategories = new KAction( i18n( "Set Categories for Contacts..." ), 0, this, |
2070 | SLOT( setCategories() ), actionCollection(), | 2070 | SLOT( setCategories() ), actionCollection(), |
2071 | "edit_set_categories" ); | 2071 | "edit_set_categories" ); |
2072 | mActionEditCategories = new KAction( i18n( "Edit Category List..." ), 0, this, | 2072 | mActionEditCategories = new KAction( i18n( "Edit Category List..." ), 0, this, |
2073 | SLOT( editCategories() ), actionCollection(), | 2073 | SLOT( editCategories() ), actionCollection(), |
2074 | "edit__categories" ); | 2074 | "edit__categories" ); |
2075 | 2075 | ||
2076 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, | 2076 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, |
2077 | SLOT( removeVoice() ), actionCollection(), | 2077 | SLOT( removeVoice() ), actionCollection(), |
2078 | "remove_voice" ); | 2078 | "remove_voice" ); |
2079 | mActionSetFormattedName = new KAction( i18n( "Set formatted name..." ), 0, this, | 2079 | mActionSetFormattedName = new KAction( i18n( "Set formatted name..." ), 0, this, |
2080 | SLOT( setFormattedName() ), actionCollection(), | 2080 | SLOT( setFormattedName() ), actionCollection(), |
2081 | "set_formatted" ); | 2081 | "set_formatted" ); |
2082 | 2082 | ||
2083 | mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this, | 2083 | mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this, |
2084 | SLOT( manageCategories() ), actionCollection(), | 2084 | SLOT( manageCategories() ), actionCollection(), |
2085 | "remove_voice" ); | 2085 | "remove_voice" ); |
2086 | 2086 | ||
2087 | 2087 | ||
2088 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, | 2088 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, |
2089 | SLOT( importFromOL() ), actionCollection(), | 2089 | SLOT( importFromOL() ), actionCollection(), |
2090 | "import_OL" ); | 2090 | "import_OL" ); |
2091 | #ifdef KAB_EMBEDDED | 2091 | #ifdef KAB_EMBEDDED |
2092 | mActionLicence = new KAction( i18n( "Licence" ), 0, | 2092 | mActionLicence = new KAction( i18n( "Licence" ), 0, |
2093 | this, SLOT( showLicence() ), actionCollection(), | 2093 | this, SLOT( showLicence() ), actionCollection(), |
2094 | "licence_about_data" ); | 2094 | "licence_about_data" ); |
2095 | mActionFaq = new KAction( i18n( "Faq" ), 0, | 2095 | mActionFaq = new KAction( i18n( "Faq" ), 0, |
2096 | this, SLOT( faq() ), actionCollection(), | 2096 | this, SLOT( faq() ), actionCollection(), |
2097 | "faq_about_data" ); | 2097 | "faq_about_data" ); |
2098 | mActionWN = new KAction( i18n( "What's New?" ), 0, | 2098 | mActionWN = new KAction( i18n( "What's New?" ), 0, |
2099 | this, SLOT( whatsnew() ), actionCollection(), | 2099 | this, SLOT( whatsnew() ), actionCollection(), |
2100 | "wn" ); | 2100 | "wn" ); |
2101 | 2101 | ||
2102 | 2102 | ||
2103 | 2103 | ||
2104 | mActionStorageHowto = new KAction( i18n( "Storage HowTo" ), 0, | 2104 | mActionStorageHowto = new KAction( i18n( "Storage HowTo" ), 0, |
2105 | this, SLOT( storagehowto() ), actionCollection(), | 2105 | this, SLOT( storagehowto() ), actionCollection(), |
2106 | "storage" ); | 2106 | "storage" ); |
2107 | 2107 | ||
2108 | mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, | 2108 | mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, |
2109 | this, SLOT( synchowto() ), actionCollection(), | 2109 | this, SLOT( synchowto() ), actionCollection(), |
2110 | "sync" ); | 2110 | "sync" ); |
2111 | mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, | 2111 | mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, |
2112 | this, SLOT( kdesynchowto() ), actionCollection(), | 2112 | this, SLOT( kdesynchowto() ), actionCollection(), |
2113 | "kdesync" ); | 2113 | "kdesync" ); |
2114 | mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, | 2114 | mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, |
2115 | this, SLOT( multisynchowto() ), actionCollection(), | 2115 | this, SLOT( multisynchowto() ), actionCollection(), |
2116 | "multisync" ); | 2116 | "multisync" ); |
2117 | 2117 | ||
2118 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, | 2118 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, |
2119 | this, SLOT( createAboutData() ), actionCollection(), | 2119 | this, SLOT( createAboutData() ), actionCollection(), |
2120 | "kaddressbook_about_data" ); | 2120 | "kaddressbook_about_data" ); |
2121 | #endif //KAB_EMBEDDED | 2121 | #endif //KAB_EMBEDDED |
2122 | 2122 | ||
2123 | clipboardDataChanged(); | 2123 | clipboardDataChanged(); |
2124 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 2124 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
2125 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 2125 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
2126 | } | 2126 | } |
2127 | 2127 | ||
2128 | //US we need this function, to plug all actions into the correct menues. | 2128 | //US we need this function, to plug all actions into the correct menues. |
2129 | // KDE uses a XML format to plug the actions, but we work her without this overhead. | 2129 | // KDE uses a XML format to plug the actions, but we work her without this overhead. |
2130 | void KABCore::addActionsManually() | 2130 | void KABCore::addActionsManually() |
2131 | { | 2131 | { |
2132 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 2132 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
2133 | 2133 | ||
2134 | #ifdef KAB_EMBEDDED | 2134 | #ifdef KAB_EMBEDDED |
2135 | QPopupMenu *fileMenu = new QPopupMenu( this ); | 2135 | QPopupMenu *fileMenu = new QPopupMenu( this ); |
2136 | QPopupMenu *editMenu = new QPopupMenu( this ); | 2136 | QPopupMenu *editMenu = new QPopupMenu( this ); |
2137 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 2137 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
2138 | 2138 | ||
2139 | KToolBar* tb = mMainWindow->toolBar(); | 2139 | KToolBar* tb = mMainWindow->toolBar(); |
2140 | mMainWindow->setToolBarsMovable (false ); | 2140 | mMainWindow->setToolBarsMovable (false ); |
2141 | #ifndef DESKTOP_VERSION | 2141 | #ifndef DESKTOP_VERSION |
2142 | if ( KABPrefs::instance()->mFullMenuBarVisible ) { | 2142 | if ( KABPrefs::instance()->mFullMenuBarVisible ) { |
2143 | #endif | 2143 | #endif |
2144 | QMenuBar* mb = mMainWindow->menuBar(); | 2144 | QMenuBar* mb = mMainWindow->menuBar(); |
2145 | 2145 | ||
2146 | //US setup menubar. | 2146 | //US setup menubar. |
2147 | //Disable the following block if you do not want to have a menubar. | 2147 | //Disable the following block if you do not want to have a menubar. |
2148 | mb->insertItem( i18n("&File"), fileMenu ); | 2148 | mb->insertItem( i18n("&File"), fileMenu ); |
2149 | mb->insertItem( i18n("&Edit"), editMenu ); | 2149 | mb->insertItem( i18n("&Edit"), editMenu ); |
2150 | mb->insertItem( i18n("&View"), viewMenu ); | 2150 | mb->insertItem( i18n("&View"), viewMenu ); |
2151 | mb->insertItem( i18n("&Settings"), settingsMenu ); | 2151 | mb->insertItem( i18n("&Settings"), settingsMenu ); |
2152 | #ifdef DESKTOP_VERSION | 2152 | #ifdef DESKTOP_VERSION |
2153 | mb->insertItem( i18n("Synchronize"), syncMenu ); | 2153 | mb->insertItem( i18n("Synchronize"), syncMenu ); |
2154 | #else | 2154 | #else |
2155 | mb->insertItem( i18n("Sync"), syncMenu ); | 2155 | mb->insertItem( i18n("Sync"), syncMenu ); |
2156 | #endif | 2156 | #endif |
2157 | //mb->insertItem( i18n("&Change"), changeMenu ); | 2157 | //mb->insertItem( i18n("&Change"), changeMenu ); |
2158 | mb->insertItem( i18n("&Help"), helpMenu ); | 2158 | mb->insertItem( i18n("&Help"), helpMenu ); |
2159 | mIncSearchWidget = new IncSearchWidget( tb ); | 2159 | mIncSearchWidget = new IncSearchWidget( tb ); |
2160 | // tb->insertWidget(-1, 0, mIncSearchWidget); | 2160 | // tb->insertWidget(-1, 0, mIncSearchWidget); |
2161 | #ifndef DESKTOP_VERSION | 2161 | #ifndef DESKTOP_VERSION |
2162 | } else { | 2162 | } else { |
2163 | //US setup toolbar | 2163 | //US setup toolbar |
2164 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); | 2164 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); |
2165 | QPopupMenu *popupBarTB = new QPopupMenu( this ); | 2165 | QPopupMenu *popupBarTB = new QPopupMenu( this ); |
2166 | menuBarTB->insertItem( SmallIcon( "z_menu" ) , popupBarTB); | 2166 | menuBarTB->insertItem( SmallIcon( "z_menu" ) , popupBarTB); |
2167 | tb->insertWidget(-1, 0, menuBarTB); | 2167 | tb->insertWidget(-1, 0, menuBarTB); |
2168 | mIncSearchWidget = new IncSearchWidget( tb ); | 2168 | mIncSearchWidget = new IncSearchWidget( tb ); |
2169 | tb->enableMoving(false); | 2169 | tb->enableMoving(false); |
2170 | popupBarTB->insertItem( i18n("&File"), fileMenu ); | 2170 | popupBarTB->insertItem( i18n("&File"), fileMenu ); |
2171 | popupBarTB->insertItem( i18n("&Edit"), editMenu ); | 2171 | popupBarTB->insertItem( i18n("&Edit"), editMenu ); |
2172 | popupBarTB->insertItem( i18n("&View"), viewMenu ); | 2172 | popupBarTB->insertItem( i18n("&View"), viewMenu ); |
2173 | popupBarTB->insertItem( i18n("&Settings"), settingsMenu ); | 2173 | popupBarTB->insertItem( i18n("&Settings"), settingsMenu ); |
2174 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); | 2174 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); |
2175 | mViewManager->getFilterAction()->plug ( popupBarTB); | 2175 | mViewManager->getFilterAction()->plug ( popupBarTB); |
2176 | //popupBarTB->insertItem( i18n("&Change selected"), changeMenu ); | 2176 | //popupBarTB->insertItem( i18n("&Change selected"), changeMenu ); |
2177 | popupBarTB->insertItem( i18n("&Help"), helpMenu ); | 2177 | popupBarTB->insertItem( i18n("&Help"), helpMenu ); |
2178 | if (QApplication::desktop()->width() > 320 ) { | 2178 | if (QApplication::desktop()->width() > 320 ) { |
2179 | // mViewManager->getFilterAction()->plug ( tb); | 2179 | // mViewManager->getFilterAction()->plug ( tb); |
2180 | } | 2180 | } |
2181 | } | 2181 | } |
2182 | #endif | 2182 | #endif |
2183 | mIncSearchWidget->setSize(); | 2183 | mIncSearchWidget->setSize(); |
2184 | // mActionQuit->plug ( mMainWindow->toolBar()); | 2184 | // mActionQuit->plug ( mMainWindow->toolBar()); |
2185 | 2185 | ||
2186 | 2186 | ||
2187 | 2187 | ||
2188 | //US Now connect the actions with the menue entries. | 2188 | //US Now connect the actions with the menue entries. |
2189 | #ifdef DESKTOP_VERSION | 2189 | #ifdef DESKTOP_VERSION |
2190 | mActionPrint->plug( fileMenu ); | 2190 | mActionPrint->plug( fileMenu ); |
2191 | mActionPrintDetails->plug( fileMenu ); | 2191 | mActionPrintDetails->plug( fileMenu ); |
2192 | fileMenu->insertSeparator(); | 2192 | fileMenu->insertSeparator(); |
2193 | #endif | 2193 | #endif |
2194 | mActionMail->plug( fileMenu ); | 2194 | mActionMail->plug( fileMenu ); |
2195 | fileMenu->insertSeparator(); | 2195 | fileMenu->insertSeparator(); |
2196 | 2196 | ||
2197 | mActionNewContact->plug( editMenu ); | 2197 | mActionNewContact->plug( editMenu ); |
2198 | mActionNewContact->plug( tb ); | 2198 | mActionNewContact->plug( tb ); |
2199 | 2199 | ||
2200 | mActionEditAddressee->plug( editMenu ); | 2200 | mActionEditAddressee->plug( editMenu ); |
2201 | editMenu->insertSeparator(); | 2201 | editMenu->insertSeparator(); |
2202 | // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || | 2202 | // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || |
2203 | // (!KABPrefs::instance()->mMultipleViewsAtOnce )) | 2203 | // (!KABPrefs::instance()->mMultipleViewsAtOnce )) |
2204 | mActionEditAddressee->plug( tb ); | 2204 | mActionEditAddressee->plug( tb ); |
2205 | 2205 | ||
2206 | // fileMenu->insertSeparator(); | 2206 | // fileMenu->insertSeparator(); |
2207 | mActionSave->plug( fileMenu ); | 2207 | mActionSave->plug( fileMenu ); |
2208 | fileMenu->insertItem( "&Import", ImportMenu ); | 2208 | fileMenu->insertItem( "&Import", ImportMenu ); |
2209 | fileMenu->insertItem( "&Export", ExportMenu ); | 2209 | fileMenu->insertItem( "&Export", ExportMenu ); |
2210 | editMenu->insertItem( i18n("&Change"), changeMenu ); | 2210 | editMenu->insertItem( i18n("&Change"), changeMenu ); |
2211 | editMenu->insertSeparator(); | 2211 | editMenu->insertSeparator(); |
2212 | #ifndef DESKTOP_VERSION | 2212 | #ifndef DESKTOP_VERSION |
2213 | if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu ); | 2213 | if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu ); |
2214 | #endif | 2214 | #endif |
2215 | #if 0 | 2215 | #if 0 |
2216 | // PENDING fix MailVCard | 2216 | // PENDING fix MailVCard |
2217 | fileMenu->insertSeparator(); | 2217 | fileMenu->insertSeparator(); |
2218 | mActionMailVCard->plug( fileMenu ); | 2218 | mActionMailVCard->plug( fileMenu ); |
2219 | #endif | 2219 | #endif |
2220 | #ifndef DESKTOP_VERSION | 2220 | #ifndef DESKTOP_VERSION |
2221 | if ( Ir::supported() ) mActionBR->plug( beamMenu ); | 2221 | if ( Ir::supported() ) mActionBR->plug( beamMenu ); |
2222 | if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu ); | 2222 | if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu ); |
2223 | if ( Ir::supported() ) mActionBeam->plug( beamMenu ); | 2223 | if ( Ir::supported() ) mActionBeam->plug( beamMenu ); |
2224 | #endif | 2224 | #endif |
2225 | fileMenu->insertSeparator(); | 2225 | fileMenu->insertSeparator(); |
2226 | mActionQuit->plug( fileMenu ); | 2226 | mActionQuit->plug( fileMenu ); |
2227 | #ifdef _OL_IMPORT_ | 2227 | #ifdef _OL_IMPORT_ |
2228 | mActionImportOL->plug( ImportMenu ); | 2228 | mActionImportOL->plug( ImportMenu ); |
2229 | #endif | 2229 | #endif |
2230 | // edit menu | 2230 | // edit menu |
2231 | mActionUndo->plug( editMenu ); | 2231 | mActionUndo->plug( editMenu ); |
2232 | mActionRedo->plug( editMenu ); | 2232 | mActionRedo->plug( editMenu ); |
2233 | editMenu->insertSeparator(); | 2233 | editMenu->insertSeparator(); |
2234 | mActionCut->plug( editMenu ); | 2234 | mActionCut->plug( editMenu ); |
2235 | mActionCopy->plug( editMenu ); | 2235 | mActionCopy->plug( editMenu ); |
2236 | mActionPaste->plug( editMenu ); | 2236 | mActionPaste->plug( editMenu ); |
2237 | mActionDelete->plug( editMenu ); | 2237 | mActionDelete->plug( editMenu ); |
2238 | editMenu->insertSeparator(); | 2238 | editMenu->insertSeparator(); |
2239 | mActionSelectAll->plug( editMenu ); | 2239 | mActionSelectAll->plug( editMenu ); |
2240 | 2240 | ||
2241 | mActionSetFormattedName->plug( changeMenu ); | 2241 | mActionSetFormattedName->plug( changeMenu ); |
2242 | mActionRemoveVoice->plug( changeMenu ); | 2242 | mActionRemoveVoice->plug( changeMenu ); |
2243 | // settingsmings menu | 2243 | // settingsmings menu |
2244 | //US special menuentry to configure the addressbook resources. On KDE | 2244 | //US special menuentry to configure the addressbook resources. On KDE |
2245 | // you do that through the control center !!! | 2245 | // you do that through the control center !!! |
2246 | // settingsMenu->insertSeparator(); | 2246 | // settingsMenu->insertSeparator(); |
2247 | 2247 | ||
2248 | mActionConfigKAddressbook->plug( settingsMenu, 0 ); | 2248 | mActionConfigKAddressbook->plug( settingsMenu, 0 ); |
2249 | mActionConfigResources->plug( settingsMenu,1 ); | 2249 | mActionConfigResources->plug( settingsMenu,1 ); |
2250 | settingsMenu->insertSeparator(2); | 2250 | settingsMenu->insertSeparator(2); |
2251 | 2251 | ||
2252 | if ( mIsPart ) { | 2252 | if ( mIsPart ) { |
2253 | //US not implemented yet | 2253 | //US not implemented yet |
2254 | //mActionConfigShortcuts->plug( settingsMenu ); | 2254 | //mActionConfigShortcuts->plug( settingsMenu ); |
2255 | //mActionConfigureToolbars->plug( settingsMenu ); | 2255 | //mActionConfigureToolbars->plug( settingsMenu ); |
2256 | 2256 | ||
2257 | } else { | 2257 | } else { |
2258 | //US not implemented yet | 2258 | //US not implemented yet |
2259 | //mActionKeyBindings->plug( settingsMenu ); | 2259 | //mActionKeyBindings->plug( settingsMenu ); |
2260 | } | 2260 | } |
2261 | 2261 | ||
2262 | mActionEditCategories->plug( settingsMenu ); | 2262 | mActionEditCategories->plug( settingsMenu ); |
2263 | mActionManageCategories->plug( settingsMenu ); | 2263 | mActionManageCategories->plug( settingsMenu ); |
2264 | mActionJumpBar->plug( viewMenu,0 ); | 2264 | mActionJumpBar->plug( viewMenu,0 ); |
2265 | mActionDetails->plug( viewMenu,0 ); | 2265 | mActionDetails->plug( viewMenu,0 ); |
2266 | //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) | 2266 | //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) |
2267 | mActionDetails->plug( tb ); | 2267 | mActionDetails->plug( tb ); |
2268 | settingsMenu->insertSeparator(); | 2268 | settingsMenu->insertSeparator(); |
2269 | #ifndef DESKTOP_VERSION | 2269 | #ifndef DESKTOP_VERSION |
2270 | if ( Ir::supported() ) mActionBR->plug(settingsMenu ); | 2270 | if ( Ir::supported() ) mActionBR->plug(settingsMenu ); |
2271 | settingsMenu->insertSeparator(); | 2271 | settingsMenu->insertSeparator(); |
2272 | #endif | 2272 | #endif |
2273 | 2273 | ||
2274 | mActionWhoAmI->plug( settingsMenu ); | 2274 | mActionWhoAmI->plug( settingsMenu ); |
2275 | //mActionEditCategories->plug( changeMenu ); | 2275 | //mActionEditCategories->plug( changeMenu ); |
2276 | mActionCategories->plug( changeMenu ); | 2276 | mActionCategories->plug( changeMenu ); |
2277 | //mActionManageCategories->plug( changeMenu ); | 2277 | //mActionManageCategories->plug( changeMenu ); |
2278 | 2278 | ||
2279 | //mActionCategories->plug( settingsMenu ); | 2279 | //mActionCategories->plug( settingsMenu ); |
2280 | 2280 | ||
2281 | 2281 | ||
2282 | mActionWN->plug( helpMenu ); | 2282 | mActionWN->plug( helpMenu ); |
2283 | mActionStorageHowto->plug( helpMenu ); | 2283 | mActionStorageHowto->plug( helpMenu ); |
2284 | mActionSyncHowto->plug( helpMenu ); | 2284 | mActionSyncHowto->plug( helpMenu ); |
2285 | mActionKdeSyncHowto->plug( helpMenu ); | 2285 | mActionKdeSyncHowto->plug( helpMenu ); |
2286 | mActionMultiSyncHowto->plug( helpMenu ); | 2286 | mActionMultiSyncHowto->plug( helpMenu ); |
2287 | mActionFaq->plug( helpMenu ); | 2287 | mActionFaq->plug( helpMenu ); |
2288 | mActionLicence->plug( helpMenu ); | 2288 | mActionLicence->plug( helpMenu ); |
2289 | mActionAboutKAddressbook->plug( helpMenu ); | 2289 | mActionAboutKAddressbook->plug( helpMenu ); |
2290 | 2290 | ||
2291 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { | 2291 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { |
2292 | 2292 | ||
2293 | mActionSave->plug( tb ); | 2293 | mActionSave->plug( tb ); |
2294 | mViewManager->getFilterAction()->plug ( tb); | 2294 | mViewManager->getFilterAction()->plug ( tb); |
2295 | //LR hide filteraction on started in 480x640 | 2295 | //LR hide filteraction on started in 480x640 |
2296 | if (QApplication::desktop()->width() == 480 ) { | 2296 | if (QApplication::desktop()->width() == 480 ) { |
2297 | mViewManager->getFilterAction()->setComboWidth( 0 ); | 2297 | mViewManager->getFilterAction()->setComboWidth( 0 ); |
2298 | } | 2298 | } |
2299 | mActionUndo->plug( tb ); | 2299 | mActionUndo->plug( tb ); |
2300 | mActionDelete->plug( tb ); | 2300 | mActionDelete->plug( tb ); |
2301 | mActionRedo->plug( tb ); | 2301 | mActionRedo->plug( tb ); |
2302 | } else { | 2302 | } else { |
2303 | mActionSave->plug( tb ); | 2303 | mActionSave->plug( tb ); |
2304 | tb->enableMoving(false); | 2304 | tb->enableMoving(false); |
2305 | } | 2305 | } |
2306 | //mActionQuit->plug ( tb ); | 2306 | //mActionQuit->plug ( tb ); |
2307 | //tb->insertWidget(-1, 0, mIncSearchWidget, 6); | 2307 | //tb->insertWidget(-1, 0, mIncSearchWidget, 6); |
2308 | 2308 | ||
2309 | //US link the searchwidget first to this. | 2309 | //US link the searchwidget first to this. |
2310 | // The real linkage to the toolbar happens later. | 2310 | // The real linkage to the toolbar happens later. |
2311 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); | 2311 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); |
2312 | //US tb->insertItem( mIncSearchWidget ); | 2312 | //US tb->insertItem( mIncSearchWidget ); |
2313 | /*US | 2313 | /*US |
2314 | mIncSearchWidget = new IncSearchWidget( tb ); | 2314 | mIncSearchWidget = new IncSearchWidget( tb ); |
2315 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 2315 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
2316 | SLOT( incrementalSearch( const QString& ) ) ); | 2316 | SLOT( incrementalSearch( const QString& ) ) ); |
2317 | 2317 | ||
2318 | mJumpButtonBar = new JumpButtonBar( this, this ); | 2318 | mJumpButtonBar = new JumpButtonBar( this, this ); |
2319 | 2319 | ||
2320 | //US topLayout->addWidget( mJumpButtonBar ); | 2320 | //US topLayout->addWidget( mJumpButtonBar ); |
2321 | this->layout()->add( mJumpButtonBar ); | 2321 | this->layout()->add( mJumpButtonBar ); |
2322 | */ | 2322 | */ |
2323 | 2323 | ||
2324 | #endif //KAB_EMBEDDED | 2324 | #endif //KAB_EMBEDDED |
2325 | 2325 | ||
2326 | mActionExport2phone->plug( ExportMenu ); | 2326 | mActionExport2phone->plug( ExportMenu ); |
2327 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); | 2327 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); |
2328 | syncManager->fillSyncMenu(); | 2328 | syncManager->fillSyncMenu(); |
2329 | 2329 | ||
2330 | } | 2330 | } |
2331 | void KABCore::showLicence() | 2331 | void KABCore::showLicence() |
2332 | { | 2332 | { |
2333 | KApplication::showLicence(); | 2333 | KApplication::showLicence(); |
2334 | } | 2334 | } |
2335 | 2335 | ||
2336 | void KABCore::manageCategories( ) | 2336 | void KABCore::manageCategories( ) |
2337 | { | 2337 | { |
2338 | KABCatPrefs* cp = new KABCatPrefs(); | 2338 | KABCatPrefs* cp = new KABCatPrefs(); |
2339 | cp->show(); | 2339 | cp->show(); |
2340 | int w =cp->sizeHint().width() ; | 2340 | int w =cp->sizeHint().width() ; |
2341 | int h = cp->sizeHint().height() ; | 2341 | int h = cp->sizeHint().height() ; |
2342 | int dw = QApplication::desktop()->width(); | 2342 | int dw = QApplication::desktop()->width(); |
2343 | int dh = QApplication::desktop()->height(); | 2343 | int dh = QApplication::desktop()->height(); |
2344 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2344 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2345 | if ( !cp->exec() ) { | 2345 | if ( !cp->exec() ) { |
2346 | delete cp; | 2346 | delete cp; |
2347 | return; | 2347 | return; |
2348 | } | 2348 | } |
2349 | int count = 0; | 2349 | int count = 0; |
2350 | int cc = 0; | 2350 | int cc = 0; |
2351 | message( i18n("Please wait, processing categories...")); | 2351 | message( i18n("Please wait, processing categories...")); |
2352 | if ( cp->addCat() ) { | 2352 | if ( cp->addCat() ) { |
2353 | KABC::AddressBook::Iterator it; | 2353 | KABC::AddressBook::Iterator it; |
2354 | QStringList catList = KABPrefs::instance()->mCustomCategories; | 2354 | QStringList catList = KABPrefs::instance()->mCustomCategories; |
2355 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2355 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2356 | ++cc; | 2356 | ++cc; |
2357 | if ( cc %10 == 0) | 2357 | if ( cc %10 == 0) |
2358 | message(i18n("Processing contact #%1").arg(cc)); | 2358 | message(i18n("Processing contact #%1").arg(cc)); |
2359 | QStringList catIncList = (*it).categories(); | 2359 | QStringList catIncList = (*it).categories(); |
2360 | int i; | 2360 | int i; |
2361 | for( i = 0; i< catIncList.count(); ++i ) { | 2361 | for( i = 0; i< catIncList.count(); ++i ) { |
2362 | if ( !catList.contains (catIncList[i])) { | 2362 | if ( !catList.contains (catIncList[i])) { |
2363 | catList.append( catIncList[i] ); | 2363 | catList.append( catIncList[i] ); |
2364 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2364 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2365 | ++count; | 2365 | ++count; |
2366 | } | 2366 | } |
2367 | } | 2367 | } |
2368 | } | 2368 | } |
2369 | catList.sort(); | 2369 | catList.sort(); |
2370 | KABPrefs::instance()->mCustomCategories = catList; | 2370 | KABPrefs::instance()->mCustomCategories = catList; |
2371 | KABPrefs::instance()->writeConfig(); | 2371 | KABPrefs::instance()->writeConfig(); |
2372 | message(QString::number( count )+ i18n(" categories added to list! ")); | 2372 | message(QString::number( count )+ i18n(" categories added to list! ")); |
2373 | } else { | 2373 | } else { |
2374 | QStringList catList = KABPrefs::instance()->mCustomCategories; | 2374 | QStringList catList = KABPrefs::instance()->mCustomCategories; |
2375 | QStringList catIncList; | 2375 | QStringList catIncList; |
2376 | QStringList newCatList; | 2376 | QStringList newCatList; |
2377 | KABC::AddressBook::Iterator it; | 2377 | KABC::AddressBook::Iterator it; |
2378 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2378 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2379 | ++cc; | 2379 | ++cc; |
2380 | if ( cc %10 == 0) | 2380 | if ( cc %10 == 0) |
2381 | message(i18n("Processing contact #%1").arg(cc)); | 2381 | message(i18n("Processing contact #%1").arg(cc)); |
2382 | QStringList catIncList = (*it).categories(); | 2382 | QStringList catIncList = (*it).categories(); |
2383 | int i; | 2383 | int i; |
2384 | if ( catIncList.count() ) { | 2384 | if ( catIncList.count() ) { |
2385 | newCatList.clear(); | 2385 | newCatList.clear(); |
2386 | for( i = 0; i< catIncList.count(); ++i ) { | 2386 | for( i = 0; i< catIncList.count(); ++i ) { |
2387 | if ( catList.contains (catIncList[i])) { | 2387 | if ( catList.contains (catIncList[i])) { |
2388 | newCatList.append( catIncList[i] ); | 2388 | newCatList.append( catIncList[i] ); |
2389 | } | 2389 | } |
2390 | } | 2390 | } |
2391 | newCatList.sort(); | 2391 | newCatList.sort(); |
2392 | (*it).setCategories( newCatList ); | 2392 | (*it).setCategories( newCatList ); |
2393 | mAddressBook->insertAddressee( (*it) ); | 2393 | mAddressBook->insertAddressee( (*it) ); |
2394 | } | 2394 | } |
2395 | } | 2395 | } |
2396 | setModified( true ); | 2396 | setModified( true ); |
2397 | mViewManager->refreshView(); | 2397 | mViewManager->refreshView(); |
2398 | message( i18n("Removing categories done!")); | 2398 | message( i18n("Removing categories done!")); |
2399 | } | 2399 | } |
2400 | delete cp; | 2400 | delete cp; |
2401 | } | 2401 | } |
2402 | void KABCore::removeVoice() | 2402 | void KABCore::removeVoice() |
2403 | { | 2403 | { |
2404 | 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 ) | 2404 | 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 ) |
2405 | return; | 2405 | return; |
2406 | XXPortSelectDialog dlg( this, false, this ); | 2406 | XXPortSelectDialog dlg( this, false, this ); |
2407 | if ( !dlg.exec() ) | 2407 | if ( !dlg.exec() ) |
2408 | return; | 2408 | return; |
2409 | mAddressBook->setUntagged(); | 2409 | mAddressBook->setUntagged(); |
2410 | dlg.tagSelected(); | 2410 | dlg.tagSelected(); |
2411 | message(i18n("Removing voice..."), false ); | 2411 | message(i18n("Removing voice..."), false ); |
2412 | KABC::AddressBook::Iterator it; | 2412 | KABC::AddressBook::Iterator it; |
2413 | for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2413 | for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2414 | if ( (*it).tagged() ) { | 2414 | if ( (*it).tagged() ) { |
2415 | (*it).removeVoice(); | 2415 | (*it).removeVoice(); |
2416 | } | 2416 | } |
2417 | } | 2417 | } |
2418 | message(i18n("Refreshing view...") ); | 2418 | message(i18n("Refreshing view...") ); |
2419 | qApp->processEvents(); | 2419 | qApp->processEvents(); |
2420 | mViewManager->refreshView( "" ); | 2420 | mViewManager->refreshView( "" ); |
2421 | Addressee add; | 2421 | Addressee add; |
2422 | mDetails->setAddressee( add ); | 2422 | mDetails->setAddressee( add ); |
2423 | message(i18n("Remove voice completed!") ); | 2423 | message(i18n("Remove voice completed!") ); |
2424 | 2424 | ||
2425 | 2425 | ||
2426 | 2426 | ||
2427 | } | 2427 | } |
2428 | 2428 | ||
2429 | void KABCore::setFormattedName() | 2429 | void KABCore::setFormattedName() |
2430 | { | 2430 | { |
2431 | KABFormatPrefs setpref; | 2431 | KABFormatPrefs setpref; |
2432 | if ( !setpref.exec() ) { | 2432 | if ( !setpref.exec() ) { |
2433 | return; | 2433 | return; |
2434 | } | 2434 | } |
2435 | XXPortSelectDialog dlg( this, false, this ); | 2435 | XXPortSelectDialog dlg( this, false, this ); |
2436 | if ( !dlg.exec() ) | 2436 | if ( !dlg.exec() ) |
2437 | return; | 2437 | return; |
2438 | mAddressBook->setUntagged(); | 2438 | mAddressBook->setUntagged(); |
2439 | dlg.tagSelected(); | 2439 | dlg.tagSelected(); |
2440 | int count = 0; | 2440 | int count = 0; |
2441 | KABC::AddressBook::Iterator it; | 2441 | KABC::AddressBook::Iterator it; |
2442 | for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2442 | for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2443 | if ( (*it).tagged() ) { | 2443 | if ( (*it).tagged() ) { |
2444 | ++count; | 2444 | ++count; |
2445 | if ( count %10 == 0 ) | 2445 | if ( count %10 == 0 ) |
2446 | message(i18n("Changing contact #%1").arg( count ) ); | 2446 | message(i18n("Changing contact #%1").arg( count ) ); |
2447 | qApp->processEvents(); | 2447 | qApp->processEvents(); |
2448 | QString fName; | 2448 | QString fName; |
2449 | if ( setpref.simple->isChecked() ) | 2449 | if ( setpref.simple->isChecked() ) |
2450 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName ); | 2450 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName ); |
2451 | else if ( setpref.full->isChecked() ) | 2451 | else if ( setpref.full->isChecked() ) |
2452 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName ); | 2452 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName ); |
2453 | else if ( setpref.reverse->isChecked() ) | 2453 | else if ( setpref.reverse->isChecked() ) |
2454 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName ); | 2454 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName ); |
2455 | else | 2455 | else |
2456 | fName = (*it).organization(); | 2456 | fName = (*it).organization(); |
2457 | if ( setpref.setCompany->isChecked() ) | 2457 | if ( setpref.setCompany->isChecked() ) |
2458 | if ( fName.isEmpty() || fName =="," ) | 2458 | if ( fName.isEmpty() || fName =="," ) |
2459 | fName = (*it).organization(); | 2459 | fName = (*it).organization(); |
2460 | (*it).setFormattedName( fName ); | 2460 | (*it).setFormattedName( fName ); |
2461 | } | 2461 | } |
2462 | } | 2462 | } |
2463 | message(i18n("Refreshing view...") ); | 2463 | message(i18n("Refreshing view...") ); |
2464 | qApp->processEvents(); | 2464 | qApp->processEvents(); |
2465 | mViewManager->refreshView( "" ); | 2465 | mViewManager->refreshView( "" ); |
2466 | Addressee add; | 2466 | Addressee add; |
2467 | mDetails->setAddressee( add ); | 2467 | mDetails->setAddressee( add ); |
2468 | message(i18n("Setting formatted name completed!") ); | 2468 | message(i18n("Setting formatted name completed!") ); |
2469 | } | 2469 | } |
2470 | 2470 | ||
2471 | void KABCore::clipboardDataChanged() | 2471 | void KABCore::clipboardDataChanged() |
2472 | { | 2472 | { |
2473 | 2473 | ||
2474 | if ( mReadWrite ) | 2474 | if ( mReadWrite ) |
2475 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); | 2475 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); |
2476 | 2476 | ||
2477 | } | 2477 | } |
2478 | 2478 | ||
2479 | void KABCore::updateActionMenu() | 2479 | void KABCore::updateActionMenu() |
2480 | { | 2480 | { |
2481 | UndoStack *undo = UndoStack::instance(); | 2481 | UndoStack *undo = UndoStack::instance(); |
2482 | RedoStack *redo = RedoStack::instance(); | 2482 | RedoStack *redo = RedoStack::instance(); |
2483 | 2483 | ||
2484 | if ( undo->isEmpty() ) | 2484 | if ( undo->isEmpty() ) |
2485 | mActionUndo->setText( i18n( "Undo" ) ); | 2485 | mActionUndo->setText( i18n( "Undo" ) ); |
2486 | else | 2486 | else |
2487 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); | 2487 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); |
2488 | 2488 | ||
2489 | mActionUndo->setEnabled( !undo->isEmpty() ); | 2489 | mActionUndo->setEnabled( !undo->isEmpty() ); |
2490 | 2490 | ||
2491 | if ( !redo->top() ) | 2491 | if ( !redo->top() ) |
2492 | mActionRedo->setText( i18n( "Redo" ) ); | 2492 | mActionRedo->setText( i18n( "Redo" ) ); |
2493 | else | 2493 | else |
2494 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); | 2494 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); |
2495 | 2495 | ||
2496 | mActionRedo->setEnabled( !redo->isEmpty() ); | 2496 | mActionRedo->setEnabled( !redo->isEmpty() ); |
2497 | } | 2497 | } |
2498 | 2498 | ||
2499 | void KABCore::configureKeyBindings() | 2499 | void KABCore::configureKeyBindings() |
2500 | { | 2500 | { |
2501 | #ifndef KAB_EMBEDDED | 2501 | #ifndef KAB_EMBEDDED |
2502 | KKeyDialog::configure( actionCollection(), true ); | 2502 | KKeyDialog::configure( actionCollection(), true ); |
2503 | #else //KAB_EMBEDDED | 2503 | #else //KAB_EMBEDDED |
2504 | qDebug("KABCore::configureKeyBindings() not implemented"); | 2504 | qDebug("KABCore::configureKeyBindings() not implemented"); |
2505 | #endif //KAB_EMBEDDED | 2505 | #endif //KAB_EMBEDDED |
2506 | } | 2506 | } |
2507 | 2507 | ||
2508 | #ifdef KAB_EMBEDDED | 2508 | #ifdef KAB_EMBEDDED |
2509 | void KABCore::configureResources() | 2509 | void KABCore::configureResources() |
2510 | { | 2510 | { |
2511 | KRES::KCMKResources dlg( this, "" , 0 ); | 2511 | KRES::KCMKResources dlg( this, "" , 0 ); |
2512 | 2512 | ||
2513 | if ( !dlg.exec() ) | 2513 | if ( !dlg.exec() ) |
2514 | return; | 2514 | return; |
2515 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); | 2515 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); |
2516 | } | 2516 | } |
2517 | #endif //KAB_EMBEDDED | 2517 | #endif //KAB_EMBEDDED |
2518 | 2518 | ||
2519 | 2519 | ||
2520 | /* this method will be called through the QCop interface from Ko/Pi to select addresses | 2520 | /* this method will be called through the QCop interface from Ko/Pi to select addresses |
2521 | * for the attendees list of an event. | 2521 | * for the attendees list of an event. |
2522 | */ | 2522 | */ |
2523 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) | 2523 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) |
2524 | { | 2524 | { |
2525 | 2525 | ||
2526 | bool ok = false; | 2526 | bool ok = false; |
2527 | mEmailSourceChannel = sourceChannel; | 2527 | mEmailSourceChannel = sourceChannel; |
2528 | mEmailSourceUID = uid; | 2528 | mEmailSourceUID = uid; |
2529 | callContactdialog(); | 2529 | callContactdialog(); |
2530 | #if 0 | 2530 | #if 0 |
2531 | int wid = uid.toInt( &ok ); | 2531 | int wid = uid.toInt( &ok ); |
2532 | qDebug("UID %s ", uid.latin1()); | 2532 | qDebug("UID %s ", uid.latin1()); |
2533 | if ( ok ) { | 2533 | if ( ok ) { |
2534 | if ( wid != QApplication::desktop()->width() ) { | 2534 | if ( wid != QApplication::desktop()->width() ) { |
2535 | qDebug("KA/Pi: Request from different desktop geometry. Resizing ..."); | 2535 | qDebug("KA/Pi: Request from different desktop geometry. Resizing ..."); |
2536 | message( i18n("Resizing, please wait...") ); | 2536 | message( i18n("Resizing, please wait...") ); |
2537 | mMainWindow->showMinimized(); | 2537 | mMainWindow->showMinimized(); |
2538 | /* | 2538 | /* |
2539 | { | 2539 | { |
2540 | QCopEnvelope e("QPE/Application/kapi", "callContactdialog()"); | 2540 | QCopEnvelope e("QPE/Application/kapi", "callContactdialog()"); |
2541 | } | 2541 | } |
2542 | */ | 2542 | */ |
2543 | QTimer::singleShot( 1,this, SLOT ( resizeAndCallContactdialog() ) ); | 2543 | QTimer::singleShot( 1,this, SLOT ( resizeAndCallContactdialog() ) ); |
2544 | return; | 2544 | return; |
2545 | } | 2545 | } |
2546 | 2546 | ||
2547 | } else { | 2547 | } else { |
2548 | qDebug("KABCore::requestForNameEmailUidList:: Got invalid uid "); | 2548 | qDebug("KABCore::requestForNameEmailUidList:: Got invalid uid "); |
2549 | } | 2549 | } |
2550 | callContactdialog(); | 2550 | callContactdialog(); |
2551 | //QCopEnvelope e("QPE/Application/kapi", "callContactdialog()"); | 2551 | //QCopEnvelope e("QPE/Application/kapi", "callContactdialog()"); |
2552 | #endif | 2552 | #endif |
2553 | } | 2553 | } |
2554 | void KABCore::resizeAndCallContactdialog() | 2554 | void KABCore::resizeAndCallContactdialog() |
2555 | { | 2555 | { |
2556 | updateMainWindow(); | 2556 | updateMainWindow(); |
2557 | QTimer::singleShot( 100,this, SLOT ( callContactdialog() ) ); | 2557 | QTimer::singleShot( 100,this, SLOT ( callContactdialog() ) ); |
2558 | } | 2558 | } |
2559 | 2559 | ||
2560 | void KABCore::callContactdialog() | 2560 | void KABCore::callContactdialog() |
2561 | { | 2561 | { |
2562 | QStringList nameList; | 2562 | QStringList nameList; |
2563 | QStringList emailList; | 2563 | QStringList emailList; |
2564 | QStringList uidList; | 2564 | QStringList uidList; |
2565 | qDebug(" KABCore::callContactdialog:DESKTOP WIDTH %d ", QApplication::desktop()->width() ); | 2565 | qDebug(" KABCore::callContactdialog:DESKTOP WIDTH %d ", QApplication::desktop()->width() ); |
2566 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); | 2566 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); |
2567 | uint i=0; | 2567 | uint i=0; |
2568 | for (i=0; i < list.count(); i++) | 2568 | for (i=0; i < list.count(); i++) |
2569 | { | 2569 | { |
2570 | nameList.append(list[i].realName()); | 2570 | nameList.append(list[i].realName()); |
2571 | emailList.append(list[i].preferredEmail()); | 2571 | emailList.append(list[i].preferredEmail()); |
2572 | uidList.append(list[i].uid()); | 2572 | uidList.append(list[i].uid()); |
2573 | } | 2573 | } |
2574 | QString uid = mEmailSourceUID; | 2574 | QString uid = mEmailSourceUID; |
2575 | //qDebug("%s %s ", sourceChannel.latin1(), uid.latin1()); | 2575 | //qDebug("%s %s ", sourceChannel.latin1(), uid.latin1()); |
2576 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(mEmailSourceChannel, uid, nameList, emailList, uidList); | 2576 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(mEmailSourceChannel, uid, nameList, emailList, uidList); |
2577 | 2577 | ||
2578 | } | 2578 | } |
2579 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays | 2579 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays |
2580 | * to put them into the calendar. | 2580 | * to put them into the calendar. |
2581 | */ | 2581 | */ |
2582 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) | 2582 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) |
2583 | { | 2583 | { |
2584 | // qDebug("KABCore::requestForBirthdayList"); | 2584 | // qDebug("KABCore::requestForBirthdayList"); |
2585 | QStringList birthdayList; | 2585 | QStringList birthdayList; |
2586 | QStringList anniversaryList; | 2586 | QStringList anniversaryList; |
2587 | QStringList realNameList; | 2587 | QStringList realNameList; |
2588 | QStringList preferredEmailList; | 2588 | QStringList preferredEmailList; |
2589 | QStringList assembledNameList; | 2589 | QStringList assembledNameList; |
2590 | QStringList uidList; | 2590 | QStringList uidList; |
2591 | 2591 | ||
2592 | KABC::AddressBook::Iterator it; | 2592 | KABC::AddressBook::Iterator it; |
2593 | 2593 | ||
2594 | int count = 0; | 2594 | int count = 0; |
2595 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2595 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2596 | ++count; | 2596 | ++count; |
2597 | } | 2597 | } |
2598 | QProgressBar bar(count,0 ); | 2598 | QProgressBar bar(count,0 ); |
2599 | int w = 300; | 2599 | int w = 300; |
2600 | if ( QApplication::desktop()->width() < 320 ) | 2600 | if ( QApplication::desktop()->width() < 320 ) |
2601 | w = 220; | 2601 | w = 220; |
2602 | int h = bar.sizeHint().height() ; | 2602 | int h = bar.sizeHint().height() ; |
2603 | int dw = QApplication::desktop()->width(); | 2603 | int dw = QApplication::desktop()->width(); |
2604 | int dh = QApplication::desktop()->height(); | 2604 | int dh = QApplication::desktop()->height(); |
2605 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2605 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2606 | bar.show(); | 2606 | bar.show(); |
2607 | bar.setCaption (i18n("Collecting birthdays - close to abort!") ); | 2607 | bar.setCaption (i18n("Collecting birthdays - close to abort!") ); |
2608 | qApp->processEvents(); | 2608 | qApp->processEvents(); |
2609 | 2609 | ||
2610 | QDate bday; | 2610 | QDate bday; |
2611 | QString anni; | 2611 | QString anni; |
2612 | QString formattedbday; | 2612 | QString formattedbday; |
2613 | 2613 | ||
2614 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) | 2614 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) |
2615 | { | 2615 | { |
2616 | if ( ! bar.isVisible() ) | 2616 | if ( ! bar.isVisible() ) |
2617 | return; | 2617 | return; |
2618 | bar.setProgress( count++ ); | 2618 | bar.setProgress( count++ ); |
2619 | qApp->processEvents(); | 2619 | qApp->processEvents(); |
2620 | bday = (*it).birthday().date(); | 2620 | bday = (*it).birthday().date(); |
2621 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); | 2621 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); |
2622 | 2622 | ||
2623 | if ( bday.isValid() || !anni.isEmpty()) | 2623 | if ( bday.isValid() || !anni.isEmpty()) |
2624 | { | 2624 | { |
2625 | if (bday.isValid()) | 2625 | if (bday.isValid()) |
2626 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); | 2626 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); |
2627 | else | 2627 | else |
2628 | formattedbday = "NOTVALID"; | 2628 | formattedbday = "NOTVALID"; |
2629 | if (anni.isEmpty()) | 2629 | if (anni.isEmpty()) |
2630 | anni = "INVALID"; | 2630 | anni = "INVALID"; |
2631 | 2631 | ||
2632 | birthdayList.append(formattedbday); | 2632 | birthdayList.append(formattedbday); |
2633 | anniversaryList.append(anni); //should be ISODate | 2633 | anniversaryList.append(anni); //should be ISODate |
2634 | realNameList.append((*it).realName()); | 2634 | realNameList.append((*it).realName()); |
2635 | preferredEmailList.append((*it).preferredEmail()); | 2635 | preferredEmailList.append((*it).preferredEmail()); |
2636 | assembledNameList.append((*it).assembledName()); | 2636 | assembledNameList.append((*it).assembledName()); |
2637 | uidList.append((*it).uid()); | 2637 | uidList.append((*it).uid()); |
2638 | 2638 | ||
2639 | //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() ); | 2639 | //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() ); |
2640 | } | 2640 | } |
2641 | } | 2641 | } |
2642 | 2642 | ||
2643 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); | 2643 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); |
2644 | 2644 | ||
2645 | } | 2645 | } |
2646 | 2646 | ||
2647 | /* this method will be called through the QCop interface from other apps to show details of a contact. | 2647 | /* this method will be called through the QCop interface from other apps to show details of a contact. |
2648 | */ | 2648 | */ |
2649 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) | 2649 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) |
2650 | { | 2650 | { |
2651 | //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); | 2651 | //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); |
2652 | 2652 | ||
2653 | QString foundUid = QString::null; | 2653 | QString foundUid = QString::null; |
2654 | if ( ! uid.isEmpty() ) { | 2654 | if ( ! uid.isEmpty() ) { |
2655 | Addressee adrr = mAddressBook->findByUid( uid ); | 2655 | Addressee adrr = mAddressBook->findByUid( uid ); |
2656 | if ( !adrr.isEmpty() ) { | 2656 | if ( !adrr.isEmpty() ) { |
2657 | foundUid = uid; | 2657 | foundUid = uid; |
2658 | } | 2658 | } |
2659 | if ( email == "sendbacklist" ) { | 2659 | if ( email == "sendbacklist" ) { |
2660 | //qDebug("ssssssssssssssssssssssend "); | 2660 | //qDebug("ssssssssssssssssssssssend "); |
2661 | QStringList nameList; | 2661 | QStringList nameList; |
2662 | QStringList emailList; | 2662 | QStringList emailList; |
2663 | QStringList uidList; | 2663 | QStringList uidList; |
2664 | nameList.append(adrr.realName()); | 2664 | nameList.append(adrr.realName()); |
2665 | emailList = adrr.emails(); | 2665 | emailList = adrr.emails(); |
2666 | uidList.append( adrr.preferredEmail()); | 2666 | uidList.append( adrr.preferredEmail()); |
2667 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); | 2667 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); |
2668 | return; | 2668 | return; |
2669 | } | 2669 | } |
2670 | 2670 | ||
2671 | } | 2671 | } |
2672 | 2672 | ||
2673 | if ( email == "sendbacklist" ) | 2673 | if ( email == "sendbacklist" ) |
2674 | return; | 2674 | return; |
2675 | if (foundUid.isEmpty()) | 2675 | if (foundUid.isEmpty()) |
2676 | { | 2676 | { |
2677 | //find the uid of the person first | 2677 | //find the uid of the person first |
2678 | Addressee::List namelist; | 2678 | Addressee::List namelist; |
2679 | Addressee::List emaillist; | 2679 | Addressee::List emaillist; |
2680 | 2680 | ||
2681 | if (!name.isEmpty()) | 2681 | if (!name.isEmpty()) |
2682 | namelist = mAddressBook->findByName( name ); | 2682 | namelist = mAddressBook->findByName( name ); |
2683 | 2683 | ||
2684 | if (!email.isEmpty()) | 2684 | if (!email.isEmpty()) |
2685 | emaillist = mAddressBook->findByEmail( email ); | 2685 | emaillist = mAddressBook->findByEmail( email ); |
2686 | //qDebug("count %d %d ", namelist.count(),emaillist.count() ); | 2686 | //qDebug("count %d %d ", namelist.count(),emaillist.count() ); |
2687 | //check if we have a match in Namelist and Emaillist | 2687 | //check if we have a match in Namelist and Emaillist |
2688 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { | 2688 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { |
2689 | foundUid = emaillist[0].uid(); | 2689 | foundUid = emaillist[0].uid(); |
2690 | } | 2690 | } |
2691 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) | 2691 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) |
2692 | foundUid = namelist[0].uid(); | 2692 | foundUid = namelist[0].uid(); |
2693 | else | 2693 | else |
2694 | { | 2694 | { |
2695 | for (int i = 0; i < namelist.count(); i++) | 2695 | for (int i = 0; i < namelist.count(); i++) |
2696 | { | 2696 | { |
2697 | for (int j = 0; j < emaillist.count(); j++) | 2697 | for (int j = 0; j < emaillist.count(); j++) |
2698 | { | 2698 | { |
2699 | if (namelist[i] == emaillist[j]) | 2699 | if (namelist[i] == emaillist[j]) |
2700 | { | 2700 | { |
2701 | foundUid = namelist[i].uid(); | 2701 | foundUid = namelist[i].uid(); |
2702 | } | 2702 | } |
2703 | } | 2703 | } |
2704 | } | 2704 | } |
2705 | } | 2705 | } |
2706 | } | 2706 | } |
2707 | else | 2707 | else |
2708 | { | 2708 | { |
2709 | foundUid = uid; | 2709 | foundUid = uid; |
2710 | } | 2710 | } |
2711 | 2711 | ||
2712 | if (!foundUid.isEmpty()) | 2712 | if (!foundUid.isEmpty()) |
2713 | { | 2713 | { |
2714 | 2714 | ||
2715 | // raise Ka/Pi if it is in the background | 2715 | // raise Ka/Pi if it is in the background |
2716 | #ifndef DESKTOP_VERSION | 2716 | #ifndef DESKTOP_VERSION |
2717 | #ifndef KORG_NODCOP | 2717 | #ifndef KORG_NODCOP |
2718 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); | 2718 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); |
2719 | #endif | 2719 | #endif |
2720 | #endif | 2720 | #endif |
2721 | 2721 | ||
2722 | mMainWindow->showMaximized(); | 2722 | mMainWindow->showMaximized(); |
2723 | mMainWindow-> raise(); | 2723 | mMainWindow-> raise(); |
2724 | 2724 | ||
2725 | mViewManager->setSelected( "", false); | 2725 | mViewManager->setSelected( "", false); |
2726 | mViewManager->refreshView( "" ); | 2726 | mViewManager->refreshView( "" ); |
2727 | mViewManager->setSelected( foundUid, true ); | 2727 | mViewManager->setSelected( foundUid, true ); |
2728 | mViewManager->refreshView( foundUid ); | 2728 | mViewManager->refreshView( foundUid ); |
2729 | 2729 | ||
2730 | if ( !mMultipleViewsAtOnce ) | 2730 | if ( !mMultipleViewsAtOnce ) |
2731 | { | 2731 | { |
2732 | setDetailsVisible( true ); | 2732 | setDetailsVisible( true ); |
2733 | mActionDetails->setChecked(true); | 2733 | mActionDetails->setChecked(true); |
2734 | } | 2734 | } |
2735 | } | 2735 | } |
2736 | } | 2736 | } |
2737 | void KABCore::storagehowto() | 2737 | void KABCore::storagehowto() |
2738 | { | 2738 | { |
2739 | KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" ); | 2739 | KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" ); |
2740 | } | 2740 | } |
2741 | void KABCore::whatsnew() | 2741 | void KABCore::whatsnew() |
2742 | { | 2742 | { |
2743 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); | 2743 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); |
2744 | } | 2744 | } |
2745 | void KABCore::synchowto() | 2745 | void KABCore::synchowto() |
2746 | { | 2746 | { |
2747 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); | 2747 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); |
2748 | } | 2748 | } |
2749 | void KABCore::kdesynchowto() | 2749 | void KABCore::kdesynchowto() |
2750 | { | 2750 | { |
2751 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); | 2751 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); |
2752 | } | 2752 | } |
2753 | void KABCore::multisynchowto() | 2753 | void KABCore::multisynchowto() |
2754 | { | 2754 | { |
2755 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); | 2755 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); |
2756 | } | 2756 | } |
2757 | void KABCore::faq() | 2757 | void KABCore::faq() |
2758 | { | 2758 | { |
2759 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); | 2759 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); |
2760 | } | 2760 | } |
2761 | 2761 | ||
2762 | #include <libkcal/syncdefines.h> | 2762 | #include <libkcal/syncdefines.h> |
2763 | 2763 | ||
2764 | KABC::Addressee KABCore::getLastSyncAddressee() | 2764 | KABC::Addressee KABCore::getLastSyncAddressee() |
2765 | { | 2765 | { |
2766 | Addressee lse; | 2766 | Addressee lse; |
2767 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2767 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2768 | 2768 | ||
2769 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 2769 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
2770 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2770 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2771 | if (lse.isEmpty()) { | 2771 | if (lse.isEmpty()) { |
2772 | qDebug("KA: Creating new last-syncAddressee "); | 2772 | qDebug("KA: Creating new last-syncAddressee "); |
2773 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2773 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2774 | QString sum = ""; | 2774 | QString sum = ""; |
2775 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 2775 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
2776 | sum = "E: "; | 2776 | sum = "E: "; |
2777 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); | 2777 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); |
2778 | lse.setRevision( mLastAddressbookSync ); | 2778 | lse.setRevision( mLastAddressbookSync ); |
2779 | lse.setCategories( i18n("SyncEvent") ); | 2779 | lse.setCategories( i18n("SyncEvent") ); |
2780 | mAddressBook->insertAddressee( lse ); | 2780 | mAddressBook->insertAddressee( lse ); |
2781 | } | 2781 | } |
2782 | return lse; | 2782 | return lse; |
2783 | } | 2783 | } |
2784 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) | 2784 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) |
2785 | { | 2785 | { |
2786 | 2786 | ||
2787 | //void setZaurusId(int id); | 2787 | //void setZaurusId(int id); |
2788 | // int zaurusId() const; | 2788 | // int zaurusId() const; |
2789 | // void setZaurusUid(int id); | 2789 | // void setZaurusUid(int id); |
2790 | // int zaurusUid() const; | 2790 | // int zaurusUid() const; |
2791 | // void setZaurusStat(int id); | 2791 | // void setZaurusStat(int id); |
2792 | // int zaurusStat() const; | 2792 | // int zaurusStat() const; |
2793 | // 0 equal | 2793 | // 0 equal |
2794 | // 1 take local | 2794 | // 1 take local |
2795 | // 2 take remote | 2795 | // 2 take remote |
2796 | // 3 cancel | 2796 | // 3 cancel |
2797 | QDateTime lastSync = mLastAddressbookSync; | 2797 | QDateTime lastSync = mLastAddressbookSync; |
2798 | QDateTime localMod = local->revision(); | 2798 | QDateTime localMod = local->revision(); |
2799 | QDateTime remoteMod = remote->revision(); | 2799 | QDateTime remoteMod = remote->revision(); |
2800 | 2800 | ||
2801 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2801 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2802 | 2802 | ||
2803 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2803 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2804 | bool remCh, locCh; | 2804 | bool remCh, locCh; |
2805 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 2805 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
2806 | //if ( remCh ) | 2806 | //if ( remCh ) |
2807 | // qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 2807 | // qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
2808 | locCh = ( localMod > mLastAddressbookSync ); | 2808 | locCh = ( localMod > mLastAddressbookSync ); |
2809 | //qDebug("cahnged rem %d loc %d",remCh, locCh ); | 2809 | //qDebug("cahnged rem %d loc %d",remCh, locCh ); |
2810 | if ( !remCh && ! locCh ) { | 2810 | if ( !remCh && ! locCh ) { |
2811 | //qDebug("both not changed "); | 2811 | //qDebug("both not changed "); |
2812 | lastSync = localMod.addDays(1); | 2812 | lastSync = localMod.addDays(1); |
2813 | if ( mode <= SYNC_PREF_ASK ) | 2813 | if ( mode <= SYNC_PREF_ASK ) |
2814 | return 0; | 2814 | return 0; |
2815 | } else { | 2815 | } else { |
2816 | if ( locCh ) { | 2816 | if ( locCh ) { |
2817 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); | 2817 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); |
2818 | lastSync = localMod.addDays( -1 ); | 2818 | lastSync = localMod.addDays( -1 ); |
2819 | if ( !remCh ) | 2819 | if ( !remCh ) |
2820 | remoteMod =( lastSync.addDays( -1 ) ); | 2820 | remoteMod =( lastSync.addDays( -1 ) ); |
2821 | } else { | 2821 | } else { |
2822 | //qDebug(" not loc changed "); | 2822 | //qDebug(" not loc changed "); |
2823 | lastSync = localMod.addDays( 1 ); | 2823 | lastSync = localMod.addDays( 1 ); |
2824 | if ( remCh ) { | 2824 | if ( remCh ) { |
2825 | //qDebug("rem changed "); | 2825 | //qDebug("rem changed "); |
2826 | remoteMod =( lastSync.addDays( 1 ) ); | 2826 | remoteMod =( lastSync.addDays( 1 ) ); |
2827 | } | 2827 | } |
2828 | 2828 | ||
2829 | } | 2829 | } |
2830 | } | 2830 | } |
2831 | full = true; | 2831 | full = true; |
2832 | if ( mode < SYNC_PREF_ASK ) | 2832 | if ( mode < SYNC_PREF_ASK ) |
2833 | mode = SYNC_PREF_ASK; | 2833 | mode = SYNC_PREF_ASK; |
2834 | } else { | 2834 | } else { |
2835 | if ( localMod == remoteMod ) | 2835 | if ( localMod == remoteMod ) |
2836 | return 0; | 2836 | return 0; |
2837 | 2837 | ||
2838 | } | 2838 | } |
2839 | //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); | 2839 | //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); |
2840 | //qDebug("lastsync %s ", lastSync.toString().latin1() ); | 2840 | //qDebug("lastsync %s ", lastSync.toString().latin1() ); |
2841 | //full = true; //debug only | 2841 | //full = true; //debug only |
2842 | if ( full ) { | 2842 | if ( full ) { |
2843 | bool equ = ( (*local) == (*remote) ); | 2843 | bool equ = ( (*local) == (*remote) ); |
2844 | if ( equ ) { | 2844 | if ( equ ) { |
2845 | //qDebug("equal "); | 2845 | //qDebug("equal "); |
2846 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2846 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2847 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 2847 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
2848 | } | 2848 | } |
2849 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 2849 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
2850 | return 0; | 2850 | return 0; |
2851 | 2851 | ||
2852 | }//else //debug only | 2852 | }//else //debug only |
2853 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 2853 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
2854 | } | 2854 | } |
2855 | int result; | 2855 | int result; |
2856 | bool localIsNew; | 2856 | bool localIsNew; |
2857 | //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() ); | 2857 | //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() ); |
2858 | 2858 | ||
2859 | if ( full && mode < SYNC_PREF_NEWEST ) | 2859 | if ( full && mode < SYNC_PREF_NEWEST ) |
2860 | mode = SYNC_PREF_ASK; | 2860 | mode = SYNC_PREF_ASK; |
2861 | 2861 | ||
2862 | switch( mode ) { | 2862 | switch( mode ) { |
2863 | case SYNC_PREF_LOCAL: | 2863 | case SYNC_PREF_LOCAL: |
2864 | if ( lastSync > remoteMod ) | 2864 | if ( lastSync > remoteMod ) |
2865 | return 1; | 2865 | return 1; |
2866 | if ( lastSync > localMod ) | 2866 | if ( lastSync > localMod ) |
2867 | return 2; | 2867 | return 2; |
2868 | return 1; | 2868 | return 1; |
2869 | break; | 2869 | break; |
2870 | case SYNC_PREF_REMOTE: | 2870 | case SYNC_PREF_REMOTE: |
2871 | if ( lastSync > remoteMod ) | ||
2872 | return 1; | ||
2873 | if ( lastSync > localMod ) | 2871 | if ( lastSync > localMod ) |
2874 | return 2; | 2872 | return 2; |
2873 | if ( lastSync > remoteMod ) | ||
2874 | return 1; | ||
2875 | return 2; | 2875 | return 2; |
2876 | break; | 2876 | break; |
2877 | case SYNC_PREF_NEWEST: | 2877 | case SYNC_PREF_NEWEST: |
2878 | if ( localMod > remoteMod ) | 2878 | if ( localMod > remoteMod ) |
2879 | return 1; | 2879 | return 1; |
2880 | else | 2880 | else |
2881 | return 2; | 2881 | return 2; |
2882 | break; | 2882 | break; |
2883 | case SYNC_PREF_ASK: | 2883 | case SYNC_PREF_ASK: |
2884 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 2884 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
2885 | if ( lastSync > remoteMod && lastSync > localMod) | ||
2886 | return 0; | ||
2885 | if ( lastSync > remoteMod ) | 2887 | if ( lastSync > remoteMod ) |
2886 | return 1; | 2888 | return 1; |
2887 | if ( lastSync > localMod ) { | 2889 | if ( lastSync > localMod ) { |
2888 | return 2; | 2890 | return 2; |
2889 | } | 2891 | } |
2890 | localIsNew = localMod >= remoteMod; | 2892 | localIsNew = localMod >= remoteMod; |
2891 | //qDebug("conflict! ************************************** "); | 2893 | //qDebug("conflict! ************************************** "); |
2892 | { | 2894 | { |
2893 | KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this ); | 2895 | KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this ); |
2894 | result = acd.executeD(localIsNew); | 2896 | result = acd.executeD(localIsNew); |
2895 | return result; | 2897 | return result; |
2896 | } | 2898 | } |
2897 | break; | 2899 | break; |
2898 | case SYNC_PREF_FORCE_LOCAL: | 2900 | case SYNC_PREF_FORCE_LOCAL: |
2899 | return 1; | 2901 | return 1; |
2900 | break; | 2902 | break; |
2901 | case SYNC_PREF_FORCE_REMOTE: | 2903 | case SYNC_PREF_FORCE_REMOTE: |
2902 | return 2; | 2904 | return 2; |
2903 | break; | 2905 | break; |
2904 | 2906 | ||
2905 | default: | 2907 | default: |
2906 | // SYNC_PREF_TAKE_BOTH not implemented | 2908 | // SYNC_PREF_TAKE_BOTH not implemented |
2907 | break; | 2909 | break; |
2908 | } | 2910 | } |
2909 | return 0; | 2911 | return 0; |
2910 | } | 2912 | } |
2911 | 2913 | ||
2912 | 2914 | ||
2913 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) | 2915 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) |
2914 | { | 2916 | { |
2915 | bool syncOK = true; | 2917 | bool syncOK = true; |
2916 | int addedAddressee = 0; | 2918 | int addedAddressee = 0; |
2917 | int addedAddresseeR = 0; | 2919 | int addedAddresseeR = 0; |
2918 | int deletedAddresseeR = 0; | 2920 | int deletedAddresseeR = 0; |
2919 | int deletedAddresseeL = 0; | 2921 | int deletedAddresseeL = 0; |
2920 | int changedLocal = 0; | 2922 | int changedLocal = 0; |
2921 | int changedRemote = 0; | 2923 | int changedRemote = 0; |
2922 | int filteredIN = 0; | 2924 | int filteredIN = 0; |
2923 | int filteredOUT = 0; | 2925 | int filteredOUT = 0; |
2924 | 2926 | ||
2925 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); | 2927 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); |
2926 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2928 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2927 | 2929 | ||
2928 | //QPtrList<Addressee> el = local->rawAddressees(); | 2930 | //QPtrList<Addressee> el = local->rawAddressees(); |
2929 | Addressee addresseeR; | 2931 | Addressee addresseeR; |
2930 | QString uid; | 2932 | QString uid; |
2931 | int take; | 2933 | int take; |
2932 | Addressee addresseeL; | 2934 | Addressee addresseeL; |
2933 | Addressee addresseeRSync; | 2935 | Addressee addresseeRSync; |
2934 | Addressee addresseeLSync; | 2936 | Addressee addresseeLSync; |
2935 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); | 2937 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); |
2936 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); | 2938 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); |
2937 | bool fullDateRange = false; | 2939 | bool fullDateRange = false; |
2938 | local->resetTempSyncStat(); | 2940 | local->resetTempSyncStat(); |
2939 | mLastAddressbookSync = QDateTime::currentDateTime(); | 2941 | mLastAddressbookSync = QDateTime::currentDateTime(); |
2940 | if ( syncManager->syncWithDesktop() ) { | 2942 | if ( syncManager->syncWithDesktop() ) { |
2941 | // remote->removeSyncInfo( QString());//remove all info | 2943 | // remote->removeSyncInfo( QString());//remove all info |
2942 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 2944 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
2943 | mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; | 2945 | mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; |
2944 | qDebug("KA: using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); | 2946 | qDebug("KA: using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); |
2945 | } else { | 2947 | } else { |
2946 | qDebug("KA: KSyncManager::mRequestedSyncEvent has invalid datatime "); | 2948 | qDebug("KA: KSyncManager::mRequestedSyncEvent has invalid datatime "); |
2947 | } | 2949 | } |
2948 | } | 2950 | } |
2949 | QDateTime modifiedCalendar = mLastAddressbookSync; | 2951 | QDateTime modifiedCalendar = mLastAddressbookSync; |
2950 | addresseeLSync = getLastSyncAddressee(); | 2952 | addresseeLSync = getLastSyncAddressee(); |
2951 | qDebug("KA: Last Sync %s ", addresseeLSync.revision().toString().latin1()); | 2953 | qDebug("KA: Last Sync %s ", addresseeLSync.revision().toString().latin1()); |
2952 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); | 2954 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); |
2953 | if ( !addresseeR.isEmpty() ) { | 2955 | if ( !addresseeR.isEmpty() ) { |
2954 | addresseeRSync = addresseeR; | 2956 | addresseeRSync = addresseeR; |
2955 | remote->removeAddressee(addresseeR ); | 2957 | remote->removeAddressee(addresseeR ); |
2956 | 2958 | ||
2957 | } else { | 2959 | } else { |
2958 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2960 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2959 | addresseeRSync = addresseeLSync ; | 2961 | addresseeRSync = addresseeLSync ; |
2960 | } else { | 2962 | } else { |
2961 | //qDebug("FULLDATE 1"); | 2963 | //qDebug("FULLDATE 1"); |
2962 | fullDateRange = true; | 2964 | fullDateRange = true; |
2963 | Addressee newAdd; | 2965 | Addressee newAdd; |
2964 | addresseeRSync = newAdd; | 2966 | addresseeRSync = newAdd; |
2965 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); | 2967 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); |
2966 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); | 2968 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); |
2967 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2969 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2968 | addresseeRSync.setCategories( i18n("SyncAddressee") ); | 2970 | addresseeRSync.setCategories( i18n("SyncAddressee") ); |
2969 | } | 2971 | } |
2970 | } | 2972 | } |
2971 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { | 2973 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { |
2972 | // qDebug("FULLDATE 2"); | 2974 | // qDebug("FULLDATE 2"); |
2973 | fullDateRange = true; | 2975 | fullDateRange = true; |
2974 | } | 2976 | } |
2975 | if ( ! fullDateRange ) { | 2977 | if ( ! fullDateRange ) { |
2976 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { | 2978 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { |
2977 | 2979 | ||
2978 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); | 2980 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); |
2979 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); | 2981 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); |
2980 | fullDateRange = true; | 2982 | fullDateRange = true; |
2981 | //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); | 2983 | //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); |
2982 | } | 2984 | } |
2983 | } | 2985 | } |
2984 | // fullDateRange = true; // debug only! | 2986 | // fullDateRange = true; // debug only! |
2985 | if ( fullDateRange ) | 2987 | if ( fullDateRange ) |
2986 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); | 2988 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); |
2987 | else | 2989 | else |
2988 | mLastAddressbookSync = addresseeLSync.revision(); | 2990 | mLastAddressbookSync = addresseeLSync.revision(); |
2989 | // for resyncing if own file has changed | 2991 | // for resyncing if own file has changed |
2990 | // PENDING fixme later when implemented | 2992 | // PENDING fixme later when implemented |
2991 | #if 0 | 2993 | #if 0 |
2992 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 2994 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
2993 | mLastAddressbookSync = loadedFileVersion; | 2995 | mLastAddressbookSync = loadedFileVersion; |
2994 | qDebug("setting mLastAddressbookSync "); | 2996 | qDebug("setting mLastAddressbookSync "); |
2995 | } | 2997 | } |
2996 | #endif | 2998 | #endif |
2997 | 2999 | ||
2998 | 3000 | ||
2999 | // ********** setting filters **************** | 3001 | // ********** setting filters **************** |
3000 | Filter filterIN = mViewManager->getFilterByName( syncManager->mFilterInAB ); | 3002 | Filter filterIN = mViewManager->getFilterByName( syncManager->mFilterInAB ); |
3001 | Filter filterOUT = mViewManager->getFilterByName( syncManager->mFilterOutAB ); | 3003 | Filter filterOUT = mViewManager->getFilterByName( syncManager->mFilterOutAB ); |
3002 | 3004 | ||
3003 | //qDebug("*************************** "); | 3005 | //qDebug("*************************** "); |
3004 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); | 3006 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); |
3005 | QStringList er = remote->uidList(); | 3007 | QStringList er = remote->uidList(); |
3006 | Addressee inR ;//= er.first(); | 3008 | Addressee inR ;//= er.first(); |
3007 | Addressee inL; | 3009 | Addressee inL; |
3008 | 3010 | ||
3009 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); | 3011 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); |
3010 | 3012 | ||
3011 | int modulo = (er.count()/10)+1; | 3013 | int modulo = (er.count()/10)+1; |
3012 | int incCounter = 0; | 3014 | int incCounter = 0; |
3013 | while ( incCounter < er.count()) { | 3015 | while ( incCounter < er.count()) { |
3014 | if (syncManager->isProgressBarCanceled()) | 3016 | if (syncManager->isProgressBarCanceled()) |
3015 | return false; | 3017 | return false; |
3016 | if ( incCounter % modulo == 0 ) | 3018 | if ( incCounter % modulo == 0 ) |
3017 | syncManager->showProgressBar(incCounter); | 3019 | syncManager->showProgressBar(incCounter); |
3018 | 3020 | ||
3019 | uid = er[ incCounter ]; | 3021 | uid = er[ incCounter ]; |
3020 | bool skipIncidence = false; | 3022 | bool skipIncidence = false; |
3021 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 3023 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
3022 | skipIncidence = true; | 3024 | skipIncidence = true; |
3023 | QString idS,OidS; | 3025 | QString idS,OidS; |
3024 | qApp->processEvents(); | 3026 | qApp->processEvents(); |
3025 | if ( !skipIncidence ) { | 3027 | if ( !skipIncidence ) { |
3026 | inL = local->findByUid( uid ); | 3028 | inL = local->findByUid( uid ); |
3027 | inR = remote->findByUid( uid ); | 3029 | inR = remote->findByUid( uid ); |
3028 | //inL.setResource( 0 ); | 3030 | //inL.setResource( 0 ); |
3029 | //inR.setResource( 0 ); | 3031 | //inR.setResource( 0 ); |
3030 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars | 3032 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars |
3031 | if ( !inL.resource() || inL.resource()->includeInSync() ) { | 3033 | if ( !inL.resource() || inL.resource()->includeInSync() ) { |
3032 | if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) { | 3034 | if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) { |
3033 | //qDebug("take %d %s ", take, inL.summary().latin1()); | 3035 | //qDebug("take %d %s ", take, inL.summary().latin1()); |
3034 | if ( take == 3 ) | 3036 | if ( take == 3 ) |
3035 | return false; | 3037 | return false; |
3036 | if ( take == 1 ) {// take local ********************** | 3038 | if ( take == 1 ) {// take local ********************** |
3037 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 3039 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
3038 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 3040 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
3039 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 3041 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
3040 | local->insertAddressee( inL, false ); | 3042 | local->insertAddressee( inL, false ); |
3041 | idS = inR.externalUID(); | 3043 | idS = inR.externalUID(); |
3042 | OidS = inR.originalExternalUID(); | 3044 | OidS = inR.originalExternalUID(); |
3043 | } | 3045 | } |
3044 | else | 3046 | else |
3045 | idS = inR.IDStr(); | 3047 | idS = inR.IDStr(); |
3046 | remote->removeAddressee( inR ); | 3048 | remote->removeAddressee( inR ); |
3047 | inR = inL; | 3049 | inR = inL; |
3048 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 3050 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
3049 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 3051 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
3050 | inR.setOriginalExternalUID( OidS ); | 3052 | inR.setOriginalExternalUID( OidS ); |
3051 | inR.setExternalUID( idS ); | 3053 | inR.setExternalUID( idS ); |
3052 | if ( syncManager->syncWithDesktop() ) { | 3054 | if ( syncManager->syncWithDesktop() ) { |
3053 | inR.setIDStr("changed" ); | 3055 | inR.setIDStr("changed" ); |
3054 | } | 3056 | } |
3055 | //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); | 3057 | //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); |
3056 | } else { | 3058 | } else { |
3057 | inR.setIDStr( idS ); | 3059 | inR.setIDStr( idS ); |
3058 | } | 3060 | } |
3059 | inR.setResource( 0 ); | 3061 | inR.setResource( 0 ); |
3060 | remote->insertAddressee( inR , false); | 3062 | remote->insertAddressee( inR , false); |
3061 | ++changedRemote; | 3063 | ++changedRemote; |
3062 | } else { // take == 2 take remote ********************** | 3064 | } else { // take == 2 take remote ********************** |
3063 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 3065 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
3064 | if ( inR.revision().date().year() < 2004 ) | 3066 | if ( inR.revision().date().year() < 2004 ) |
3065 | inR.setRevision( modifiedCalendar ); | 3067 | inR.setRevision( modifiedCalendar ); |
3066 | } | 3068 | } |
3067 | idS = inL.IDStr(); | 3069 | idS = inL.IDStr(); |
3068 | local->removeAddressee( inL ); | 3070 | local->removeAddressee( inL ); |
3069 | inL = inR; | 3071 | inL = inR; |
3070 | inL.setIDStr( idS ); | 3072 | inL.setIDStr( idS ); |
3071 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 3073 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
3072 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 3074 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
3073 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 3075 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
3074 | } | 3076 | } |
3075 | inL.setResource( 0 ); | 3077 | inL.setResource( 0 ); |
3076 | local->insertAddressee( inL , false ); | 3078 | local->insertAddressee( inL , false ); |
3077 | ++changedLocal; | 3079 | ++changedLocal; |
3078 | } | 3080 | } |
3079 | } | 3081 | } |
3080 | } | 3082 | } |
3081 | } else { // no conflict ********** add or delete remote | 3083 | } else { // no conflict ********** add or delete remote |
3082 | if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) { | 3084 | if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) { |
3083 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 3085 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
3084 | QString des = addresseeLSync.note(); | 3086 | QString des = addresseeLSync.note(); |
3085 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 3087 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
3086 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 3088 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
3087 | remote->insertAddressee( inR, false ); | 3089 | remote->insertAddressee( inR, false ); |
3088 | ++deletedAddresseeR; | 3090 | ++deletedAddresseeR; |
3089 | } else { | 3091 | } else { |
3090 | inR.setRevision( modifiedCalendar ); | 3092 | inR.setRevision( modifiedCalendar ); |
3091 | remote->insertAddressee( inR, false ); | 3093 | remote->insertAddressee( inR, false ); |
3092 | inL = inR; | 3094 | inL = inR; |
3093 | inL.setIDStr( ":" ); | 3095 | inL.setIDStr( ":" ); |
3094 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 3096 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
3095 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 3097 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
3096 | inL.setResource( 0 ); | 3098 | inL.setResource( 0 ); |
3097 | local->insertAddressee( inL , false); | 3099 | local->insertAddressee( inL , false); |
3098 | ++addedAddressee; | 3100 | ++addedAddressee; |
3099 | } | 3101 | } |
3100 | } else { | 3102 | } else { |
3101 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { | 3103 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { |
3102 | inR.setRevision( modifiedCalendar ); | 3104 | inR.setRevision( modifiedCalendar ); |
3103 | remote->insertAddressee( inR, false ); | 3105 | remote->insertAddressee( inR, false ); |
3104 | inR.setResource( 0 ); | 3106 | inR.setResource( 0 ); |
3105 | local->insertAddressee( inR, false ); | 3107 | local->insertAddressee( inR, false ); |
3106 | ++addedAddressee; | 3108 | ++addedAddressee; |
3107 | } else { | 3109 | } else { |
3108 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); | 3110 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); |
3109 | remote->removeAddressee( inR ); | 3111 | remote->removeAddressee( inR ); |
3110 | ++deletedAddresseeR; | 3112 | ++deletedAddresseeR; |
3111 | } | 3113 | } |
3112 | } | 3114 | } |
3113 | } else { | 3115 | } else { |
3114 | ++filteredIN; | 3116 | ++filteredIN; |
3115 | } | 3117 | } |
3116 | } | 3118 | } |
3117 | } | 3119 | } |
3118 | ++incCounter; | 3120 | ++incCounter; |
3119 | } | 3121 | } |
3120 | er.clear(); | 3122 | er.clear(); |
3121 | QStringList el = local->uidList(); | 3123 | QStringList el = local->uidList(); |
3122 | modulo = (el.count()/10)+1; | 3124 | modulo = (el.count()/10)+1; |
3123 | 3125 | ||
3124 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); | 3126 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); |
3125 | incCounter = 0; | 3127 | incCounter = 0; |
3126 | while ( incCounter < el.count()) { | 3128 | while ( incCounter < el.count()) { |
3127 | qApp->processEvents(); | 3129 | qApp->processEvents(); |
3128 | if (syncManager->isProgressBarCanceled()) | 3130 | if (syncManager->isProgressBarCanceled()) |
3129 | return false; | 3131 | return false; |
3130 | if ( incCounter % modulo == 0 ) | 3132 | if ( incCounter % modulo == 0 ) |
3131 | syncManager->showProgressBar(incCounter); | 3133 | syncManager->showProgressBar(incCounter); |
3132 | uid = el[ incCounter ]; | 3134 | uid = el[ incCounter ]; |
3133 | bool skipIncidence = false; | 3135 | bool skipIncidence = false; |
3134 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 3136 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
3135 | skipIncidence = true; | 3137 | skipIncidence = true; |
3136 | if ( !skipIncidence ) { | 3138 | if ( !skipIncidence ) { |
3137 | inL = local->findByUid( uid ); | 3139 | inL = local->findByUid( uid ); |
3138 | if ( !inL.resource() || inL.resource()->includeInSync() ) { | 3140 | if ( !inL.resource() || inL.resource()->includeInSync() ) { |
3139 | inR = remote->findByUid( uid ); | 3141 | inR = remote->findByUid( uid ); |
3140 | if ( inR.isEmpty() ){ | 3142 | if ( inR.isEmpty() ){ |
3141 | if ( filterOUT.name().isEmpty() || filterOUT.filterAddressee( inL ) ) { | 3143 | if ( filterOUT.name().isEmpty() || filterOUT.filterAddressee( inL ) ) { |
3142 | // no conflict ********** add or delete local | 3144 | // no conflict ********** add or delete local |
3143 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 3145 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
3144 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 3146 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
3145 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 3147 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
3146 | local->removeAddressee( inL ); | 3148 | local->removeAddressee( inL ); |
3147 | ++deletedAddresseeL; | 3149 | ++deletedAddresseeL; |
3148 | } else { | 3150 | } else { |
3149 | if ( ! syncManager->mWriteBackExistingOnly ) { | 3151 | if ( ! syncManager->mWriteBackExistingOnly ) { |
3150 | inL.removeID(mCurrentSyncDevice ); | 3152 | inL.removeID(mCurrentSyncDevice ); |
3151 | ++addedAddresseeR; | 3153 | ++addedAddresseeR; |
3152 | inL.setRevision( modifiedCalendar ); | 3154 | inL.setRevision( modifiedCalendar ); |
3153 | local->insertAddressee( inL, false ); | 3155 | local->insertAddressee( inL, false ); |
3154 | inR = inL; | 3156 | inR = inL; |
3155 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); | 3157 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); |
3156 | inR.setResource( 0 ); | 3158 | inR.setResource( 0 ); |
3157 | remote->insertAddressee( inR, false ); | 3159 | remote->insertAddressee( inR, false ); |
3158 | } | 3160 | } |
3159 | } | 3161 | } |
3160 | } else { | 3162 | } else { |
3161 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { | 3163 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { |
3162 | //qDebug("data %s ", inL.revision().toString().latin1()); | 3164 | //qDebug("data %s ", inL.revision().toString().latin1()); |
3163 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 3165 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
3164 | local->removeAddressee( inL ); | 3166 | local->removeAddressee( inL ); |
3165 | ++deletedAddresseeL; | 3167 | ++deletedAddresseeL; |
3166 | } else { | 3168 | } else { |
3167 | if ( ! syncManager->mWriteBackExistingOnly ) { | 3169 | if ( ! syncManager->mWriteBackExistingOnly ) { |
3168 | ++addedAddresseeR; | 3170 | ++addedAddresseeR; |
3169 | inL.setRevision( modifiedCalendar ); | 3171 | inL.setRevision( modifiedCalendar ); |
3170 | local->insertAddressee( inL, false ); | 3172 | local->insertAddressee( inL, false ); |
3171 | inR = inL; | 3173 | inR = inL; |
3172 | inR.setIDStr( ":" ); | 3174 | inR.setIDStr( ":" ); |
3173 | inR.setResource( 0 ); | 3175 | inR.setResource( 0 ); |
3174 | remote->insertAddressee( inR, false ); | 3176 | remote->insertAddressee( inR, false ); |
3175 | } | 3177 | } |
3176 | } | 3178 | } |
3177 | } | 3179 | } |
3178 | } else { | 3180 | } else { |
3179 | ++filteredOUT; | 3181 | ++filteredOUT; |
3180 | } | 3182 | } |
3181 | } | 3183 | } |
3182 | } | 3184 | } |
3183 | } | 3185 | } |
3184 | ++incCounter; | 3186 | ++incCounter; |
3185 | } | 3187 | } |
3186 | el.clear(); | 3188 | el.clear(); |
3187 | syncManager->hideProgressBar(); | 3189 | syncManager->hideProgressBar(); |
3188 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); | 3190 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); |
3189 | // get rid of micro seconds | 3191 | // get rid of micro seconds |
3190 | QTime t = mLastAddressbookSync.time(); | 3192 | QTime t = mLastAddressbookSync.time(); |
3191 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 3193 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
3192 | addresseeLSync.setRevision( mLastAddressbookSync ); | 3194 | addresseeLSync.setRevision( mLastAddressbookSync ); |
3193 | addresseeRSync.setRevision( mLastAddressbookSync ); | 3195 | addresseeRSync.setRevision( mLastAddressbookSync ); |
3194 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; | 3196 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; |
3195 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); | 3197 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); |
3196 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; | 3198 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; |
3197 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); | 3199 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); |
3198 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; | 3200 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; |
3199 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); | 3201 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); |
3200 | addresseeRSync.setNote( "" ) ; | 3202 | addresseeRSync.setNote( "" ) ; |
3201 | addresseeLSync.setNote( "" ); | 3203 | addresseeLSync.setNote( "" ); |
3202 | 3204 | ||
3203 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 3205 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
3204 | remote->insertAddressee( addresseeRSync, false ); | 3206 | remote->insertAddressee( addresseeRSync, false ); |
3205 | local->insertAddressee( addresseeLSync, false ); | 3207 | local->insertAddressee( addresseeLSync, false ); |
3206 | QString mes; | 3208 | QString mes; |
3207 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR, filteredIN, filteredOUT ); | 3209 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR, filteredIN, filteredOUT ); |
3208 | qDebug( mes ); | 3210 | qDebug( mes ); |
3209 | mes = i18n("Local addressbook changed!\n") +mes; | 3211 | mes = i18n("Local addressbook changed!\n") +mes; |
3210 | if ( syncManager->mShowSyncSummary ) { | 3212 | if ( syncManager->mShowSyncSummary ) { |
3211 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 3213 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
3212 | i18n("KA/Pi Synchronization"),i18n("Write back"))) { | 3214 | i18n("KA/Pi Synchronization"),i18n("Write back"))) { |
3213 | qDebug("KA: WB cancelled "); | 3215 | qDebug("KA: WB cancelled "); |
3214 | syncManager->mWriteBackFile = false; | 3216 | syncManager->mWriteBackFile = false; |
3215 | return syncOK; | 3217 | return syncOK; |
3216 | } | 3218 | } |
3217 | } | 3219 | } |
3218 | return syncOK; | 3220 | return syncOK; |
3219 | } | 3221 | } |
3220 | 3222 | ||
3221 | 3223 | ||
3222 | //this is a overwritten callbackmethods from the syncinterface | 3224 | //this is a overwritten callbackmethods from the syncinterface |
3223 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) | 3225 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) |
3224 | { | 3226 | { |
3225 | 3227 | ||
3226 | //pending prepare addresseeview for output | 3228 | //pending prepare addresseeview for output |
3227 | //pending detect, if remote file has REV field. if not switch to external sync | 3229 | //pending detect, if remote file has REV field. if not switch to external sync |
3228 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 3230 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
3229 | if ( manager != syncManager ) | 3231 | if ( manager != syncManager ) |
3230 | qDebug("KABCore::sync:: ERROR! :: manager != syncManager "); | 3232 | qDebug("KABCore::sync:: ERROR! :: manager != syncManager "); |
3231 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 3233 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
3232 | 3234 | ||
3233 | AddressBook abLocal(filename,"syncContact"); | 3235 | AddressBook abLocal(filename,"syncContact"); |
3234 | bool syncOK = false; | 3236 | bool syncOK = false; |
3235 | if ( abLocal.load() ) { | 3237 | if ( abLocal.load() ) { |
3236 | qDebug("KA: Sync::AB loaded %s,sync mode %d",filename.latin1(), mode ); | 3238 | qDebug("KA: Sync::AB loaded %s,sync mode %d",filename.latin1(), mode ); |
3237 | bool external = false; | 3239 | bool external = false; |
3238 | bool isXML = false; | 3240 | bool isXML = false; |
3239 | if ( filename.right(4) == ".xml") { | 3241 | if ( filename.right(4) == ".xml") { |
3240 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3242 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3241 | isXML = true; | 3243 | isXML = true; |
3242 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); | 3244 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
3243 | } else { | 3245 | } else { |
3244 | external = !manager->mIsKapiFile; | 3246 | external = !manager->mIsKapiFile; |
3245 | if ( external ) { | 3247 | if ( external ) { |
3246 | qDebug("KA: Sync::Setting vcf mode to external "); | 3248 | qDebug("KA: Sync::Setting vcf mode to external "); |
3247 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3249 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3248 | AddressBook::Iterator it; | 3250 | AddressBook::Iterator it; |
3249 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 3251 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
3250 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); | 3252 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); |
3251 | (*it).computeCsum( mCurrentSyncDevice ); | 3253 | (*it).computeCsum( mCurrentSyncDevice ); |
3252 | } | 3254 | } |
3253 | } | 3255 | } |
3254 | } | 3256 | } |
3255 | //AddressBook::Iterator it; | 3257 | //AddressBook::Iterator it; |
3256 | //QStringList vcards; | 3258 | //QStringList vcards; |
3257 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 3259 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
3258 | // qDebug("Name %s ", (*it).familyName().latin1()); | 3260 | // qDebug("Name %s ", (*it).familyName().latin1()); |
3259 | //} | 3261 | //} |
3260 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); | 3262 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); |
3261 | syncManager->hideProgressBar(); | 3263 | syncManager->hideProgressBar(); |
3262 | if ( syncOK ) { | 3264 | if ( syncOK ) { |
3263 | if ( syncManager->mWriteBackFile ) | 3265 | if ( syncManager->mWriteBackFile ) |
3264 | { | 3266 | { |
3265 | if ( external ) | 3267 | if ( external ) |
3266 | abLocal.removeSyncAddressees( !isXML); | 3268 | abLocal.removeSyncAddressees( !isXML); |
3267 | qDebug("KA: Sync::Saving remote AB "); | 3269 | qDebug("KA: Sync::Saving remote AB "); |
3268 | if ( ! abLocal.saveAB()) | 3270 | if ( ! abLocal.saveAB()) |
3269 | qDebug("KA: sync::Error writing back AB to file "); | 3271 | qDebug("KA: sync::Error writing back AB to file "); |
3270 | if ( external ) { | 3272 | if ( external ) { |
3271 | // afterwrite processing | 3273 | // afterwrite processing |
3272 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); | 3274 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); |
3273 | } | 3275 | } |
3274 | } | 3276 | } |
3275 | } | 3277 | } |
3276 | setModified(); | 3278 | setModified(); |
3277 | 3279 | ||
3278 | } | 3280 | } |
3279 | abLocal.removeResources(); | 3281 | abLocal.removeResources(); |
3280 | if ( syncOK ) | 3282 | if ( syncOK ) |
3281 | mViewManager->refreshView(); | 3283 | mViewManager->refreshView(); |
3282 | return syncOK; | 3284 | return syncOK; |
3283 | 3285 | ||
3284 | } | 3286 | } |
3285 | void KABCore::removeSyncInfo( QString syncProfile) | 3287 | void KABCore::removeSyncInfo( QString syncProfile) |
3286 | { | 3288 | { |
3287 | qDebug("KA: AB:removeSyncInfo for profile %s ", syncProfile.latin1()); | 3289 | qDebug("KA: AB:removeSyncInfo for profile %s ", syncProfile.latin1()); |
3288 | mAddressBook->removeSyncInfo( syncProfile ); | 3290 | mAddressBook->removeSyncInfo( syncProfile ); |
3289 | setModified(); | 3291 | setModified(); |
3290 | } | 3292 | } |
3291 | 3293 | ||
3292 | 3294 | ||
3293 | //this is a overwritten callbackmethods from the syncinterface | 3295 | //this is a overwritten callbackmethods from the syncinterface |
3294 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) | 3296 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) |
3295 | { | 3297 | { |
3296 | if ( resource == "phone" ) | 3298 | if ( resource == "phone" ) |
3297 | return syncPhone(); | 3299 | return syncPhone(); |
3298 | disableBR( true ); | 3300 | disableBR( true ); |
3299 | if ( manager != syncManager ) | 3301 | if ( manager != syncManager ) |
3300 | qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager "); | 3302 | qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager "); |
3301 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 3303 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
3302 | 3304 | ||
3303 | AddressBook abLocal( resource,"syncContact"); | 3305 | AddressBook abLocal( resource,"syncContact"); |
3304 | bool syncOK = false; | 3306 | bool syncOK = false; |
3305 | message(i18n("Loading DTM address data..."), false); | 3307 | message(i18n("Loading DTM address data..."), false); |
3306 | if ( abLocal.load() ) { | 3308 | if ( abLocal.load() ) { |
3307 | qDebug("KA: AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 3309 | qDebug("KA: AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
3308 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3310 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3309 | message(i18n("Sync preprocessing..."),false); | 3311 | message(i18n("Sync preprocessing..."),false); |
3310 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); | 3312 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); |
3311 | message(i18n("Synchronizing..."),false); | 3313 | message(i18n("Synchronizing..."),false); |
3312 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 3314 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
3313 | syncManager->hideProgressBar(); | 3315 | syncManager->hideProgressBar(); |
3314 | if ( syncOK ) { | 3316 | if ( syncOK ) { |
3315 | if ( syncManager->mWriteBackFile ) { | 3317 | if ( syncManager->mWriteBackFile ) { |
3316 | abLocal.removeSyncAddressees( false ); | 3318 | abLocal.removeSyncAddressees( false ); |
3317 | message(i18n("Saving DTM address data..."),false); | 3319 | message(i18n("Saving DTM address data..."),false); |
3318 | abLocal.saveAB(); | 3320 | abLocal.saveAB(); |
3319 | message(i18n("Sync postprocessing..."),false); | 3321 | message(i18n("Sync postprocessing..."),false); |
3320 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); | 3322 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); |
3321 | } | 3323 | } |
3322 | } else | 3324 | } else |
3323 | message( i18n("Sync cancelled or failed.") ); | 3325 | message( i18n("Sync cancelled or failed.") ); |
3324 | setModified(); | 3326 | setModified(); |
3325 | } | 3327 | } |
3326 | abLocal.removeResources(); | 3328 | abLocal.removeResources(); |
3327 | if ( syncOK ) { | 3329 | if ( syncOK ) { |
3328 | mViewManager->refreshView(); | 3330 | mViewManager->refreshView(); |
3329 | message(i18n("DTM syncing finished.")); | 3331 | message(i18n("DTM syncing finished.")); |
3330 | } | 3332 | } |
3331 | disableBR( false ); | 3333 | disableBR( false ); |
3332 | return syncOK; | 3334 | return syncOK; |
3333 | 3335 | ||
3334 | } | 3336 | } |
3335 | void KABCore::message( QString m, bool startTimer) | 3337 | void KABCore::message( QString m, bool startTimer) |
3336 | { | 3338 | { |
3337 | topLevelWidget()->setCaption( m ); | 3339 | topLevelWidget()->setCaption( m ); |
3338 | qApp->processEvents(); | 3340 | qApp->processEvents(); |
3339 | if ( startTimer ) | 3341 | if ( startTimer ) |
3340 | mMessageTimer->start( 15000, true ); | 3342 | mMessageTimer->start( 15000, true ); |
3341 | else | 3343 | else |
3342 | mMessageTimer->stop(); | 3344 | mMessageTimer->stop(); |
3343 | } | 3345 | } |
3344 | bool KABCore::syncPhone() | 3346 | bool KABCore::syncPhone() |
3345 | { | 3347 | { |
3346 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 3348 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
3347 | QString fileName = getPhoneFile(); | 3349 | QString fileName = getPhoneFile(); |
3348 | if ( !PhoneAccess::readFromPhone( fileName) ) { | 3350 | if ( !PhoneAccess::readFromPhone( fileName) ) { |
3349 | message(i18n("Phone access failed!")); | 3351 | message(i18n("Phone access failed!")); |
3350 | return false; | 3352 | return false; |
3351 | } | 3353 | } |
3352 | AddressBook abLocal( fileName,"syncContact"); | 3354 | AddressBook abLocal( fileName,"syncContact"); |
3353 | bool syncOK = false; | 3355 | bool syncOK = false; |
3354 | { | 3356 | { |
3355 | abLocal.importFromFile( fileName ); | 3357 | abLocal.importFromFile( fileName ); |
3356 | qDebug("KA: AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 3358 | qDebug("KA: AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
3357 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3359 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3358 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); | 3360 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); |
3359 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); | 3361 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
3360 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 3362 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
3361 | syncManager->hideProgressBar(); | 3363 | syncManager->hideProgressBar(); |
3362 | if ( syncOK ) { | 3364 | if ( syncOK ) { |
3363 | if ( syncManager->mWriteBackFile ) { | 3365 | if ( syncManager->mWriteBackFile ) { |
3364 | abLocal.removeSyncAddressees( true ); | 3366 | abLocal.removeSyncAddressees( true ); |
3365 | abLocal.saveABphone( fileName ); | 3367 | abLocal.saveABphone( fileName ); |
3366 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); | 3368 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); |
3367 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); | 3369 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); |
3368 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); | 3370 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); |
3369 | } | 3371 | } |
3370 | } | 3372 | } |
3371 | setModified(); | 3373 | setModified(); |
3372 | } | 3374 | } |
3373 | abLocal.removeResources(); | 3375 | abLocal.removeResources(); |
3374 | if ( syncOK ) | 3376 | if ( syncOK ) |
3375 | mViewManager->refreshView(); | 3377 | mViewManager->refreshView(); |
3376 | return syncOK; | 3378 | return syncOK; |
3377 | } | 3379 | } |
3378 | void KABCore::getFile( bool success ) | 3380 | void KABCore::getFile( bool success ) |
3379 | { | 3381 | { |
3380 | if ( ! success ) { | 3382 | if ( ! success ) { |
3381 | message( i18n("Error receiving file. Nothing changed!") ); | 3383 | message( i18n("Error receiving file. Nothing changed!") ); |
3382 | return; | 3384 | return; |
3383 | } | 3385 | } |
3384 | int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); | 3386 | int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); |
3385 | if ( count ) | 3387 | if ( count ) |
3386 | setModified( true ); | 3388 | setModified( true ); |
3387 | message( i18n("Pi-Sync successful!") ); | 3389 | message( i18n("Pi-Sync successful!") ); |
3388 | mViewManager->refreshView(); | 3390 | mViewManager->refreshView(); |
3389 | } | 3391 | } |
3390 | void KABCore::syncFileRequest() | 3392 | void KABCore::syncFileRequest() |
3391 | { | 3393 | { |
3392 | if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { | 3394 | if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { |
3393 | syncManager->slotSyncMenu( 999 ); | 3395 | syncManager->slotSyncMenu( 999 ); |
3394 | } | 3396 | } |
3395 | mAddressBook->export2File( sentSyncFile() ); | 3397 | mAddressBook->export2File( sentSyncFile() ); |
3396 | } | 3398 | } |
3397 | QString KABCore::sentSyncFile() | 3399 | QString KABCore::sentSyncFile() |
3398 | { | 3400 | { |
3399 | #ifdef DESKTOP_VERSION | 3401 | #ifdef DESKTOP_VERSION |
3400 | return locateLocal( "tmp", "copysyncab.vcf" ); | 3402 | return locateLocal( "tmp", "copysyncab.vcf" ); |
3401 | #else | 3403 | #else |
3402 | return QString( "/tmp/copysyncab.vcf" ); | 3404 | return QString( "/tmp/copysyncab.vcf" ); |
3403 | #endif | 3405 | #endif |
3404 | } | 3406 | } |
3405 | 3407 | ||
3406 | void KABCore::setCaptionBack() | 3408 | void KABCore::setCaptionBack() |
3407 | { | 3409 | { |
3408 | mMessageTimer->stop(); | 3410 | mMessageTimer->stop(); |
3409 | topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); | 3411 | topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); |
3410 | } | 3412 | } |
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 76cce26..00ef145 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1,2380 +1,2390 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | 3 | ||
4 | Requires the Qt and KDE widget libraries, available at no cost at | 4 | Requires the Qt and KDE widget libraries, available at no cost at |
5 | http://www.troll.no and http://www.kde.org respectively | 5 | http://www.troll.no and http://www.kde.org respectively |
6 | 6 | ||
7 | Copyright (c) 1997, 1998, 1999 | 7 | Copyright (c) 1997, 1998, 1999 |
8 | Preston Brown (preston.brown@yale.edu) | 8 | Preston Brown (preston.brown@yale.edu) |
9 | Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) | 9 | Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) |
10 | Ian Dawes (iadawes@globalserve.net) | 10 | Ian Dawes (iadawes@globalserve.net) |
11 | Laszlo Boloni (boloni@cs.purdue.edu) | 11 | Laszlo Boloni (boloni@cs.purdue.edu) |
12 | 12 | ||
13 | Copyright (c) 2000, 2001, 2002 | 13 | Copyright (c) 2000, 2001, 2002 |
14 | Cornelius Schumacher <schumacher@kde.org> | 14 | Cornelius Schumacher <schumacher@kde.org> |
15 | 15 | ||
16 | This program is free software; you can redistribute it and/or modify | 16 | This program is free software; you can redistribute it and/or modify |
17 | it under the terms of the GNU General Public License as published by | 17 | it under the terms of the GNU General Public License as published by |
18 | the Free Software Foundation; either version 2 of the License, or | 18 | the Free Software Foundation; either version 2 of the License, or |
19 | (at your option) any later version. | 19 | (at your option) any later version. |
20 | 20 | ||
21 | This program is distributed in the hope that it will be useful, | 21 | This program is distributed in the hope that it will be useful, |
22 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 22 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the | 23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the |
24 | GNU General Public License for more details. | 24 | GNU General Public License for more details. |
25 | 25 | ||
26 | You should have received a copy of the GNU General Public License | 26 | You should have received a copy of the GNU General Public License |
27 | along with this program; if not, write to the Free Software | 27 | along with this program; if not, write to the Free Software |
28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <stdlib.h> | 31 | #include <stdlib.h> |
32 | 32 | ||
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #include <qradiobutton.h> | 34 | #include <qradiobutton.h> |
35 | #include <qbuttongroup.h> | 35 | #include <qbuttongroup.h> |
36 | #include <qlayout.h> | 36 | #include <qlayout.h> |
37 | #include <qclipboard.h> | 37 | #include <qclipboard.h> |
38 | #include <qcursor.h> | 38 | #include <qcursor.h> |
39 | #include <qmessagebox.h> | 39 | #include <qmessagebox.h> |
40 | #include <qprogressbar.h> | 40 | #include <qprogressbar.h> |
41 | #include <qmultilineedit.h> | 41 | #include <qmultilineedit.h> |
42 | #include <qtimer.h> | 42 | #include <qtimer.h> |
43 | #include <qwidgetstack.h> | 43 | #include <qwidgetstack.h> |
44 | #include <qptrlist.h> | 44 | #include <qptrlist.h> |
45 | #include <qregexp.h> | 45 | #include <qregexp.h> |
46 | #include <qgroupbox.h> | 46 | #include <qgroupbox.h> |
47 | #include <qfile.h> | 47 | #include <qfile.h> |
48 | #include <qdir.h> | 48 | #include <qdir.h> |
49 | #ifndef KORG_NOSPLITTER | 49 | #ifndef KORG_NOSPLITTER |
50 | #include <qsplitter.h> | 50 | #include <qsplitter.h> |
51 | #endif | 51 | #endif |
52 | 52 | ||
53 | #include <kglobal.h> | 53 | #include <kglobal.h> |
54 | #include <kdebug.h> | 54 | #include <kdebug.h> |
55 | #include <kstandarddirs.h> | 55 | #include <kstandarddirs.h> |
56 | #include <kfiledialog.h> | 56 | #include <kfiledialog.h> |
57 | #include <kmessagebox.h> | 57 | #include <kmessagebox.h> |
58 | #include <knotifyclient.h> | 58 | #include <knotifyclient.h> |
59 | #include <kconfig.h> | 59 | #include <kconfig.h> |
60 | 60 | ||
61 | #include <libkdepim/ksyncprefsdialog.h> | 61 | #include <libkdepim/ksyncprefsdialog.h> |
62 | #include <krun.h> | 62 | #include <krun.h> |
63 | #include <kdirwatch.h> | 63 | #include <kdirwatch.h> |
64 | #include <libkdepim/kdatepicker.h> | 64 | #include <libkdepim/kdatepicker.h> |
65 | #include <libkdepim/ksyncprofile.h> | 65 | #include <libkdepim/ksyncprofile.h> |
66 | #include <libkdepim/kpimglobalprefs.h> | 66 | #include <libkdepim/kpimglobalprefs.h> |
67 | 67 | ||
68 | #include <libkcal/vcaldrag.h> | 68 | #include <libkcal/vcaldrag.h> |
69 | #include <libkcal/icaldrag.h> | 69 | #include <libkcal/icaldrag.h> |
70 | #include <libkcal/icalformat.h> | 70 | #include <libkcal/icalformat.h> |
71 | #include <libkcal/vcalformat.h> | 71 | #include <libkcal/vcalformat.h> |
72 | #include <libkcal/scheduler.h> | 72 | #include <libkcal/scheduler.h> |
73 | #include <libkcal/calendarlocal.h> | 73 | #include <libkcal/calendarlocal.h> |
74 | #include <libkcal/journal.h> | 74 | #include <libkcal/journal.h> |
75 | #include <libkcal/calfilter.h> | 75 | #include <libkcal/calfilter.h> |
76 | #include <libkcal/attendee.h> | 76 | #include <libkcal/attendee.h> |
77 | #include <libkcal/dndfactory.h> | 77 | #include <libkcal/dndfactory.h> |
78 | #include <libkcal/freebusy.h> | 78 | #include <libkcal/freebusy.h> |
79 | #include <libkcal/filestorage.h> | 79 | #include <libkcal/filestorage.h> |
80 | #include <libkcal/calendarresources.h> | 80 | #include <libkcal/calendarresources.h> |
81 | #include <libkcal/qtopiaformat.h> | 81 | #include <libkcal/qtopiaformat.h> |
82 | #include "../kalarmd/alarmdialog.h" | 82 | #include "../kalarmd/alarmdialog.h" |
83 | 83 | ||
84 | #ifndef DESKTOP_VERSION | 84 | #ifndef DESKTOP_VERSION |
85 | #include <libkcal/sharpformat.h> | 85 | #include <libkcal/sharpformat.h> |
86 | #include <externalapphandler.h> | 86 | #include <externalapphandler.h> |
87 | #endif | 87 | #endif |
88 | #include <libkcal/phoneformat.h> | 88 | #include <libkcal/phoneformat.h> |
89 | #ifndef KORG_NOMAIL | 89 | #ifndef KORG_NOMAIL |
90 | #include "komailclient.h" | 90 | #include "komailclient.h" |
91 | #endif | 91 | #endif |
92 | #ifndef KORG_NOPRINTER | 92 | #ifndef KORG_NOPRINTER |
93 | #include "calprinter.h" | 93 | #include "calprinter.h" |
94 | #endif | 94 | #endif |
95 | #ifndef KORG_NOPLUGINS | 95 | #ifndef KORG_NOPLUGINS |
96 | #include "kocore.h" | 96 | #include "kocore.h" |
97 | #endif | 97 | #endif |
98 | #include "koeventeditor.h" | 98 | #include "koeventeditor.h" |
99 | #include "kotodoeditor.h" | 99 | #include "kotodoeditor.h" |
100 | #include "koprefs.h" | 100 | #include "koprefs.h" |
101 | #include "koeventviewerdialog.h" | 101 | #include "koeventviewerdialog.h" |
102 | #include "publishdialog.h" | 102 | #include "publishdialog.h" |
103 | #include "kofilterview.h" | 103 | #include "kofilterview.h" |
104 | #include "koglobals.h" | 104 | #include "koglobals.h" |
105 | #include "koviewmanager.h" | 105 | #include "koviewmanager.h" |
106 | #include "koagendaview.h" | 106 | #include "koagendaview.h" |
107 | #include "kodialogmanager.h" | 107 | #include "kodialogmanager.h" |
108 | #include "outgoingdialog.h" | 108 | #include "outgoingdialog.h" |
109 | #include "incomingdialog.h" | 109 | #include "incomingdialog.h" |
110 | #include "datenavigatorcontainer.h" | 110 | #include "datenavigatorcontainer.h" |
111 | #include "statusdialog.h" | 111 | #include "statusdialog.h" |
112 | #include "kdatenavigator.h" | 112 | #include "kdatenavigator.h" |
113 | #include "kotodoview.h" | 113 | #include "kotodoview.h" |
114 | #include "datenavigator.h" | 114 | #include "datenavigator.h" |
115 | #include "resourceview.h" | 115 | #include "resourceview.h" |
116 | #include "navigatorbar.h" | 116 | #include "navigatorbar.h" |
117 | #include "searchdialog.h" | 117 | #include "searchdialog.h" |
118 | #include "mainwindow.h" | 118 | #include "mainwindow.h" |
119 | 119 | ||
120 | #include "calendarview.h" | 120 | #include "calendarview.h" |
121 | #ifndef DESKTOP_VERSION | 121 | #ifndef DESKTOP_VERSION |
122 | #include <qtopia/alarmserver.h> | 122 | #include <qtopia/alarmserver.h> |
123 | #endif | 123 | #endif |
124 | #ifndef _WIN32_ | 124 | #ifndef _WIN32_ |
125 | #include <stdlib.h> | 125 | #include <stdlib.h> |
126 | #include <stdio.h> | 126 | #include <stdio.h> |
127 | #include <unistd.h> | 127 | #include <unistd.h> |
128 | #else | 128 | #else |
129 | #include <qprocess.h> | 129 | #include <qprocess.h> |
130 | #endif | 130 | #endif |
131 | 131 | ||
132 | #ifdef DESKTOP_VERSION | 132 | #ifdef DESKTOP_VERSION |
133 | #include <kabc/stdaddressbook.h> | 133 | #include <kabc/stdaddressbook.h> |
134 | #endif | 134 | #endif |
135 | using namespace KOrg; | 135 | using namespace KOrg; |
136 | using namespace KCal; | 136 | using namespace KCal; |
137 | extern int globalFlagBlockAgenda; | 137 | extern int globalFlagBlockAgenda; |
138 | extern int globalFlagBlockStartup; | 138 | extern int globalFlagBlockStartup; |
139 | 139 | ||
140 | 140 | ||
141 | 141 | ||
142 | class KOBeamPrefs : public QDialog | 142 | class KOBeamPrefs : public QDialog |
143 | { | 143 | { |
144 | public: | 144 | public: |
145 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : | 145 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : |
146 | QDialog( parent, name, true ) | 146 | QDialog( parent, name, true ) |
147 | { | 147 | { |
148 | setCaption( i18n("Beam Options") ); | 148 | setCaption( i18n("Beam Options") ); |
149 | QVBoxLayout* lay = new QVBoxLayout( this ); | 149 | QVBoxLayout* lay = new QVBoxLayout( this ); |
150 | lay->setSpacing( 3 ); | 150 | lay->setSpacing( 3 ); |
151 | lay->setMargin( 3 ); | 151 | lay->setMargin( 3 ); |
152 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); | 152 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); |
153 | lay->addWidget( format ); | 153 | lay->addWidget( format ); |
154 | format->setExclusive ( true ) ; | 154 | format->setExclusive ( true ) ; |
155 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); | 155 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); |
156 | lay->addWidget( time ); time->setExclusive ( true ) ; | 156 | lay->addWidget( time ); time->setExclusive ( true ) ; |
157 | vcal = new QRadioButton(" vCalendar ", format ); | 157 | vcal = new QRadioButton(" vCalendar ", format ); |
158 | ical = new QRadioButton(" iCalendar ", format ); | 158 | ical = new QRadioButton(" iCalendar ", format ); |
159 | vcal->setChecked( true ); | 159 | vcal->setChecked( true ); |
160 | tz = new QRadioButton(i18n(" With timezone "), time ); | 160 | tz = new QRadioButton(i18n(" With timezone "), time ); |
161 | local = new QRadioButton(i18n(" Local time "), time ); | 161 | local = new QRadioButton(i18n(" Local time "), time ); |
162 | tz->setChecked( true ); | 162 | tz->setChecked( true ); |
163 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); | 163 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); |
164 | lay->addWidget( ok ); | 164 | lay->addWidget( ok ); |
165 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 165 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
166 | lay->addWidget( cancel ); | 166 | lay->addWidget( cancel ); |
167 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 167 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
168 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 168 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
169 | resize( 200, 200 ); | 169 | resize( 200, 200 ); |
170 | } | 170 | } |
171 | 171 | ||
172 | bool beamVcal() { return vcal->isChecked(); } | 172 | bool beamVcal() { return vcal->isChecked(); } |
173 | bool beamLocal() { return local->isChecked(); } | 173 | bool beamLocal() { return local->isChecked(); } |
174 | private: | 174 | private: |
175 | QRadioButton* vcal, *ical, *local, *tz; | 175 | QRadioButton* vcal, *ical, *local, *tz; |
176 | }; | 176 | }; |
177 | class KOCatPrefs : public QDialog | 177 | class KOCatPrefs : public QDialog |
178 | { | 178 | { |
179 | public: | 179 | public: |
180 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : | 180 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : |
181 | QDialog( parent, name, true ) | 181 | QDialog( parent, name, true ) |
182 | { | 182 | { |
183 | setCaption( i18n("Manage new Categories") ); | 183 | setCaption( i18n("Manage new Categories") ); |
184 | QVBoxLayout* lay = new QVBoxLayout( this ); | 184 | QVBoxLayout* lay = new QVBoxLayout( this ); |
185 | lay->setSpacing( 3 ); | 185 | lay->setSpacing( 3 ); |
186 | lay->setMargin( 3 ); | 186 | lay->setMargin( 3 ); |
187 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); | 187 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); |
188 | lay->addWidget( lab ); | 188 | lay->addWidget( lab ); |
189 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); | 189 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); |
190 | lay->addWidget( format ); | 190 | lay->addWidget( format ); |
191 | format->setExclusive ( true ) ; | 191 | format->setExclusive ( true ) ; |
192 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 192 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
193 | new QRadioButton(i18n("Remove from Events/Todos"), format ); | 193 | new QRadioButton(i18n("Remove from Events/Todos"), format ); |
194 | addCatBut->setChecked( true ); | 194 | addCatBut->setChecked( true ); |
195 | QPushButton * ok = new QPushButton( i18n("OK"), this ); | 195 | QPushButton * ok = new QPushButton( i18n("OK"), this ); |
196 | lay->addWidget( ok ); | 196 | lay->addWidget( ok ); |
197 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 197 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
198 | lay->addWidget( cancel ); | 198 | lay->addWidget( cancel ); |
199 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 199 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
200 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 200 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
201 | resize( 200, 200 ); | 201 | resize( 200, 200 ); |
202 | } | 202 | } |
203 | 203 | ||
204 | bool addCat() { return addCatBut->isChecked(); } | 204 | bool addCat() { return addCatBut->isChecked(); } |
205 | private: | 205 | private: |
206 | QRadioButton* addCatBut; | 206 | QRadioButton* addCatBut; |
207 | }; | 207 | }; |
208 | 208 | ||
209 | 209 | ||
210 | 210 | ||
211 | CalendarView::CalendarView( CalendarResources *calendar, | 211 | CalendarView::CalendarView( CalendarResources *calendar, |
212 | QWidget *parent, const char *name ) | 212 | QWidget *parent, const char *name ) |
213 | : CalendarViewBase( parent, name ), | 213 | : CalendarViewBase( parent, name ), |
214 | mCalendar( calendar ), | 214 | mCalendar( calendar ), |
215 | mResourceManager( calendar->resourceManager() ) | 215 | mResourceManager( calendar->resourceManager() ) |
216 | { | 216 | { |
217 | 217 | ||
218 | mEventEditor = 0; | 218 | mEventEditor = 0; |
219 | mTodoEditor = 0; | 219 | mTodoEditor = 0; |
220 | 220 | ||
221 | init(); | 221 | init(); |
222 | } | 222 | } |
223 | 223 | ||
224 | CalendarView::CalendarView( Calendar *calendar, | 224 | CalendarView::CalendarView( Calendar *calendar, |
225 | QWidget *parent, const char *name ) | 225 | QWidget *parent, const char *name ) |
226 | : CalendarViewBase( parent, name ), | 226 | : CalendarViewBase( parent, name ), |
227 | mCalendar( calendar ), | 227 | mCalendar( calendar ), |
228 | mResourceManager( 0 ) | 228 | mResourceManager( 0 ) |
229 | { | 229 | { |
230 | 230 | ||
231 | mEventEditor = 0; | 231 | mEventEditor = 0; |
232 | mTodoEditor = 0; | 232 | mTodoEditor = 0; |
233 | init(); | 233 | init(); |
234 | } | 234 | } |
235 | 235 | ||
236 | void CalendarView::init() | 236 | void CalendarView::init() |
237 | { | 237 | { |
238 | mNextAlarmDateTime = QDateTime::currentDateTime(); | 238 | mNextAlarmDateTime = QDateTime::currentDateTime(); |
239 | setFocusPolicy ( WheelFocus ); | 239 | setFocusPolicy ( WheelFocus ); |
240 | mViewerCallerIsSearchDialog = false; | 240 | mViewerCallerIsSearchDialog = false; |
241 | mBlockShowDates = false; | 241 | mBlockShowDates = false; |
242 | beamDialog = new KOBeamPrefs(); | 242 | beamDialog = new KOBeamPrefs(); |
243 | mDatePickerMode = 0; | 243 | mDatePickerMode = 0; |
244 | mCurrentSyncDevice = ""; | 244 | mCurrentSyncDevice = ""; |
245 | writeLocale(); | 245 | writeLocale(); |
246 | mViewManager = new KOViewManager( this ); | 246 | mViewManager = new KOViewManager( this ); |
247 | mDialogManager = new KODialogManager( this ); | 247 | mDialogManager = new KODialogManager( this ); |
248 | mEventViewerDialog = 0; | 248 | mEventViewerDialog = 0; |
249 | mModified = false; | 249 | mModified = false; |
250 | mReadOnly = false; | 250 | mReadOnly = false; |
251 | mSelectedIncidence = 0; | 251 | mSelectedIncidence = 0; |
252 | mCalPrinter = 0; | 252 | mCalPrinter = 0; |
253 | mFilters.setAutoDelete(true); | 253 | mFilters.setAutoDelete(true); |
254 | 254 | ||
255 | mCalendar->registerObserver( this ); | 255 | mCalendar->registerObserver( this ); |
256 | // TODO: Make sure that view is updated, when calendar is changed. | 256 | // TODO: Make sure that view is updated, when calendar is changed. |
257 | 257 | ||
258 | mStorage = new FileStorage( mCalendar ); | 258 | mStorage = new FileStorage( mCalendar ); |
259 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); | 259 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); |
260 | 260 | ||
261 | QBoxLayout *topLayout = (QBoxLayout*)layout(); | 261 | QBoxLayout *topLayout = (QBoxLayout*)layout(); |
262 | #ifndef KORG_NOSPLITTER | 262 | #ifndef KORG_NOSPLITTER |
263 | // create the main layout frames. | 263 | // create the main layout frames. |
264 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); | 264 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); |
265 | topLayout->addWidget(mPanner); | 265 | topLayout->addWidget(mPanner); |
266 | 266 | ||
267 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, | 267 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, |
268 | "CalendarView::LeftFrame"); | 268 | "CalendarView::LeftFrame"); |
269 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); | 269 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); |
270 | 270 | ||
271 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, | 271 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, |
272 | "CalendarView::DateNavigator" ); | 272 | "CalendarView::DateNavigator" ); |
273 | 273 | ||
274 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); | 274 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); |
275 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); | 275 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); |
276 | mTodoList->setNavigator( mNavigator ); | 276 | mTodoList->setNavigator( mNavigator ); |
277 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); | 277 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); |
278 | 278 | ||
279 | #ifdef KORG_NORESOURCEVIEW | 279 | #ifdef KORG_NORESOURCEVIEW |
280 | mResourceView = 0; | 280 | mResourceView = 0; |
281 | #else | 281 | #else |
282 | if ( mResourceManager ) { | 282 | if ( mResourceManager ) { |
283 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); | 283 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); |
284 | mResourceView->updateView(); | 284 | mResourceView->updateView(); |
285 | connect( mResourceView, SIGNAL( resourcesChanged() ), | 285 | connect( mResourceView, SIGNAL( resourcesChanged() ), |
286 | SLOT( updateView() ) ); | 286 | SLOT( updateView() ) ); |
287 | } else { | 287 | } else { |
288 | mResourceView = 0; | 288 | mResourceView = 0; |
289 | } | 289 | } |
290 | #endif | 290 | #endif |
291 | QWidget *rightBox = new QWidget( mPanner ); | 291 | QWidget *rightBox = new QWidget( mPanner ); |
292 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 292 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
293 | 293 | ||
294 | mRightFrame = new QWidgetStack( rightBox ); | 294 | mRightFrame = new QWidgetStack( rightBox ); |
295 | rightLayout->addWidget( mRightFrame, 1 ); | 295 | rightLayout->addWidget( mRightFrame, 1 ); |
296 | 296 | ||
297 | mLeftFrame = mLeftSplitter; | 297 | mLeftFrame = mLeftSplitter; |
298 | #else | 298 | #else |
299 | //QWidget *mainBox = new QWidget( this ); | 299 | //QWidget *mainBox = new QWidget( this ); |
300 | //QWidget *leftFrame = new QWidget( mainBox ); | 300 | //QWidget *leftFrame = new QWidget( mainBox ); |
301 | //QBoxLayout * mainBoxLayout; | 301 | //QBoxLayout * mainBoxLayout; |
302 | if ( KOPrefs::instance()->mVerticalScreen ) { | 302 | if ( KOPrefs::instance()->mVerticalScreen ) { |
303 | //mainBoxLayout = new QVBoxLayout(mainBox); | 303 | //mainBoxLayout = new QVBoxLayout(mainBox); |
304 | //leftFrameLayout = new QHBoxLayout(leftFrame ); | 304 | //leftFrameLayout = new QHBoxLayout(leftFrame ); |
305 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); | 305 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); |
306 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 306 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
307 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; | 307 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; |
308 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 308 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
309 | } else { | 309 | } else { |
310 | //mainBoxLayout = new QHBoxLayout(mainBox); | 310 | //mainBoxLayout = new QHBoxLayout(mainBox); |
311 | //leftFrameLayout = new QVBoxLayout(leftFrame ); | 311 | //leftFrameLayout = new QVBoxLayout(leftFrame ); |
312 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 312 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
313 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); | 313 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); |
314 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); | 314 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); |
315 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 315 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
316 | } | 316 | } |
317 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); | 317 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); |
318 | //QBoxLayout * leftFrameLayout; | 318 | //QBoxLayout * leftFrameLayout; |
319 | topLayout->addWidget( mMainFrame ); | 319 | topLayout->addWidget( mMainFrame ); |
320 | //mainBoxLayout->addWidget (mLeftFrame); | 320 | //mainBoxLayout->addWidget (mLeftFrame); |
321 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, | 321 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, |
322 | "CalendarView::DateNavigator" ); | 322 | "CalendarView::DateNavigator" ); |
323 | #if 0 | 323 | #if 0 |
324 | // FIXME | 324 | // FIXME |
325 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, | 325 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, |
326 | "CalendarView::DateNavigator", QDate::currentDate()); | 326 | "CalendarView::DateNavigator", QDate::currentDate()); |
327 | #endif | 327 | #endif |
328 | // mDateNavigator->blockSignals( true ); | 328 | // mDateNavigator->blockSignals( true ); |
329 | //leftFrameLayout->addWidget( mDateNavigator ); | 329 | //leftFrameLayout->addWidget( mDateNavigator ); |
330 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); | 330 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); |
331 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); | 331 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); |
332 | mTodoList->setNavigator( mNavigator ); | 332 | mTodoList->setNavigator( mNavigator ); |
333 | #if 0 | 333 | #if 0 |
334 | if ( QApplication::desktop()->width() < 480 ) { | 334 | if ( QApplication::desktop()->width() < 480 ) { |
335 | leftFrameLayout->addWidget(mFilterView); | 335 | leftFrameLayout->addWidget(mFilterView); |
336 | leftFrameLayout->addWidget(mTodoList, 2 ); | 336 | leftFrameLayout->addWidget(mTodoList, 2 ); |
337 | 337 | ||
338 | } else { | 338 | } else { |
339 | leftFrameLayout->addWidget(mTodoList,2 ); | 339 | leftFrameLayout->addWidget(mTodoList,2 ); |
340 | leftFrameLayout->addWidget(mFilterView ); | 340 | leftFrameLayout->addWidget(mFilterView ); |
341 | } | 341 | } |
342 | #endif | 342 | #endif |
343 | mFilterView->hide(); | 343 | mFilterView->hide(); |
344 | QWidget *rightBox = new QWidget( mMainFrame ); | 344 | QWidget *rightBox = new QWidget( mMainFrame ); |
345 | //mainBoxLayout->addWidget ( rightBox, 10 ); | 345 | //mainBoxLayout->addWidget ( rightBox, 10 ); |
346 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 346 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
347 | mRightFrame = new QWidgetStack( rightBox ); | 347 | mRightFrame = new QWidgetStack( rightBox ); |
348 | rightLayout->addWidget( mRightFrame, 10 ); | 348 | rightLayout->addWidget( mRightFrame, 10 ); |
349 | 349 | ||
350 | //mLeftFrame = (QWidget *)leftFrame; | 350 | //mLeftFrame = (QWidget *)leftFrame; |
351 | if ( KOPrefs::instance()->mVerticalScreen ) { | 351 | if ( KOPrefs::instance()->mVerticalScreen ) { |
352 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); | 352 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); |
353 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); | 353 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); |
354 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | 354 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); |
355 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | 355 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); |
356 | } else { | 356 | } else { |
357 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); | 357 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); |
358 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); | 358 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); |
359 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | 359 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); |
360 | } | 360 | } |
361 | if ( !KOPrefs::instance()->mShowDateNavigator) | 361 | if ( !KOPrefs::instance()->mShowDateNavigator) |
362 | mDateNavigator->hide(); | 362 | mDateNavigator->hide(); |
363 | //qDebug("Calendarview Size %d %d ", width(), height()); | 363 | //qDebug("Calendarview Size %d %d ", width(), height()); |
364 | #endif | 364 | #endif |
365 | 365 | ||
366 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 366 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
367 | SLOT( showDates( const KCal::DateList & ) ) ); | 367 | SLOT( showDates( const KCal::DateList & ) ) ); |
368 | 368 | ||
369 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 369 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
370 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 370 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
371 | 371 | ||
372 | 372 | ||
373 | 373 | ||
374 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), | 374 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), |
375 | mViewManager, SLOT( showMonth( const QDate & ) ) ); | 375 | mViewManager, SLOT( showMonth( const QDate & ) ) ); |
376 | 376 | ||
377 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), | 377 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), |
378 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); | 378 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); |
379 | 379 | ||
380 | connect( mDateNavigator, SIGNAL( goPrevYear() ), | 380 | connect( mDateNavigator, SIGNAL( goPrevYear() ), |
381 | mNavigator, SLOT( selectPreviousYear() ) ); | 381 | mNavigator, SLOT( selectPreviousYear() ) ); |
382 | connect( mDateNavigator, SIGNAL( goNextYear() ), | 382 | connect( mDateNavigator, SIGNAL( goNextYear() ), |
383 | mNavigator, SLOT( selectNextYear() ) ); | 383 | mNavigator, SLOT( selectNextYear() ) ); |
384 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), | 384 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), |
385 | mNavigator, SLOT( selectPreviousMonth() ) ); | 385 | mNavigator, SLOT( selectPreviousMonth() ) ); |
386 | connect( mDateNavigator, SIGNAL( goNextMonth() ), | 386 | connect( mDateNavigator, SIGNAL( goNextMonth() ), |
387 | mNavigator, SLOT( selectNextMonth() ) ); | 387 | mNavigator, SLOT( selectNextMonth() ) ); |
388 | 388 | ||
389 | connect( mDateNavigator, SIGNAL( goPrevious() ), | 389 | connect( mDateNavigator, SIGNAL( goPrevious() ), |
390 | mNavigator, SLOT( selectPrevious() ) ); | 390 | mNavigator, SLOT( selectPrevious() ) ); |
391 | connect( mDateNavigator, SIGNAL( goNext() ), | 391 | connect( mDateNavigator, SIGNAL( goNext() ), |
392 | mNavigator, SLOT( selectNext() ) ); | 392 | mNavigator, SLOT( selectNext() ) ); |
393 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 393 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
394 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 394 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
395 | 395 | ||
396 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 396 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
397 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 397 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
398 | #if 0 | 398 | #if 0 |
399 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), | 399 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), |
400 | SLOT( incidenceAdded( Incidence *) ) ); | 400 | SLOT( incidenceAdded( Incidence *) ) ); |
401 | #endif | 401 | #endif |
402 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 402 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
403 | 403 | ||
404 | connect( this, SIGNAL( configChanged() ), | 404 | connect( this, SIGNAL( configChanged() ), |
405 | mDateNavigator, SLOT( updateConfig() ) ); | 405 | mDateNavigator, SLOT( updateConfig() ) ); |
406 | 406 | ||
407 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 407 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
408 | SLOT( newTodo() ) ); | 408 | SLOT( newTodo() ) ); |
409 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 409 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
410 | SLOT( newSubTodo( Todo * ) ) ); | 410 | SLOT( newSubTodo( Todo * ) ) ); |
411 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 411 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
412 | SLOT( editTodo( Todo * ) ) ); | 412 | SLOT( editTodo( Todo * ) ) ); |
413 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 413 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
414 | SLOT( showTodo( Todo *) ) ); | 414 | SLOT( showTodo( Todo *) ) ); |
415 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 415 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
416 | SLOT( deleteTodo( Todo *) ) ); | 416 | SLOT( deleteTodo( Todo *) ) ); |
417 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 417 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
418 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 418 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
419 | SLOT( purgeCompleted() ) ); | 419 | SLOT( purgeCompleted() ) ); |
420 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 420 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
421 | SIGNAL( todoModified( Todo *, int ) ) ); | 421 | SIGNAL( todoModified( Todo *, int ) ) ); |
422 | 422 | ||
423 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 423 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
424 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 424 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
425 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 425 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
426 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 426 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
427 | 427 | ||
428 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 428 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
429 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 429 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
430 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 430 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
431 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 431 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
432 | 432 | ||
433 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 433 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
434 | this, SLOT ( todo_unsub( Todo * ) ) ); | 434 | this, SLOT ( todo_unsub( Todo * ) ) ); |
435 | 435 | ||
436 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 436 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
437 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); | 437 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); |
438 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 438 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
439 | SLOT( updateTodo( Todo *, int ) ) ); | 439 | SLOT( updateTodo( Todo *, int ) ) ); |
440 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 440 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
441 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 441 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
442 | 442 | ||
443 | 443 | ||
444 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 444 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
445 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 445 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
446 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 446 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
447 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 447 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
448 | 448 | ||
449 | 449 | ||
450 | 450 | ||
451 | 451 | ||
452 | 452 | ||
453 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 453 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
454 | SLOT(checkClipboard())); | 454 | SLOT(checkClipboard())); |
455 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 455 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
456 | SLOT( processTodoListSelection( Incidence * ) ) ); | 456 | SLOT( processTodoListSelection( Incidence * ) ) ); |
457 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 457 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
458 | 458 | ||
459 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 459 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
460 | 460 | ||
461 | mDateFrame = new QVBox(0,0,WType_Popup); | 461 | mDateFrame = new QVBox(0,0,WType_Popup); |
462 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 462 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
463 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 463 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
464 | mDateFrame->setLineWidth(3); | 464 | mDateFrame->setLineWidth(3); |
465 | mDateFrame->hide(); | 465 | mDateFrame->hide(); |
466 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 466 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
467 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 467 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
468 | 468 | ||
469 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 469 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
470 | 470 | ||
471 | mEventEditor = mDialogManager->getEventEditor(); | 471 | mEventEditor = mDialogManager->getEventEditor(); |
472 | mTodoEditor = mDialogManager->getTodoEditor(); | 472 | mTodoEditor = mDialogManager->getTodoEditor(); |
473 | 473 | ||
474 | mFlagEditDescription = false; | 474 | mFlagEditDescription = false; |
475 | 475 | ||
476 | mSuspendTimer = new QTimer( this ); | 476 | mSuspendTimer = new QTimer( this ); |
477 | mAlarmTimer = new QTimer( this ); | 477 | mAlarmTimer = new QTimer( this ); |
478 | mRecheckAlarmTimer = new QTimer( this ); | 478 | mRecheckAlarmTimer = new QTimer( this ); |
479 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 479 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
480 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 480 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
481 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 481 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
482 | mAlarmDialog = new AlarmDialog( this ); | 482 | mAlarmDialog = new AlarmDialog( this ); |
483 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 483 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
484 | mAlarmDialog->setServerNotification( false ); | 484 | mAlarmDialog->setServerNotification( false ); |
485 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 485 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
486 | 486 | ||
487 | 487 | ||
488 | #ifndef DESKTOP_VERSION | 488 | #ifndef DESKTOP_VERSION |
489 | //US listen for arriving address resultsets | 489 | //US listen for arriving address resultsets |
490 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), | 490 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), |
491 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 491 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
492 | #endif | 492 | #endif |
493 | mDateNavigator->setCalendar( mCalendar ); | 493 | mDateNavigator->setCalendar( mCalendar ); |
494 | } | 494 | } |
495 | 495 | ||
496 | 496 | ||
497 | CalendarView::~CalendarView() | 497 | CalendarView::~CalendarView() |
498 | { | 498 | { |
499 | // kdDebug() << "~CalendarView()" << endl; | 499 | // kdDebug() << "~CalendarView()" << endl; |
500 | //qDebug("CalendarView::~CalendarView() "); | 500 | //qDebug("CalendarView::~CalendarView() "); |
501 | delete mDialogManager; | 501 | delete mDialogManager; |
502 | delete mViewManager; | 502 | delete mViewManager; |
503 | delete mStorage; | 503 | delete mStorage; |
504 | delete mDateFrame ; | 504 | delete mDateFrame ; |
505 | delete beamDialog; | 505 | delete beamDialog; |
506 | delete mEventViewerDialog; | 506 | delete mEventViewerDialog; |
507 | //kdDebug() << "~CalendarView() done" << endl; | 507 | //kdDebug() << "~CalendarView() done" << endl; |
508 | } | 508 | } |
509 | 509 | ||
510 | void CalendarView::showDay( QDate d ) | 510 | void CalendarView::showDay( QDate d ) |
511 | { | 511 | { |
512 | dateNavigator()->blockSignals( true ); | 512 | dateNavigator()->blockSignals( true ); |
513 | dateNavigator()->selectDate( d ); | 513 | dateNavigator()->selectDate( d ); |
514 | dateNavigator()->blockSignals( false ); | 514 | dateNavigator()->blockSignals( false ); |
515 | mViewManager->showDayView(); | 515 | mViewManager->showDayView(); |
516 | //dateNavigator()->selectDate( d ); | 516 | //dateNavigator()->selectDate( d ); |
517 | } | 517 | } |
518 | void CalendarView::timerAlarm() | 518 | void CalendarView::timerAlarm() |
519 | { | 519 | { |
520 | //qDebug("CalendarView::timerAlarm() "); | 520 | //qDebug("CalendarView::timerAlarm() "); |
521 | computeAlarm(mAlarmNotification ); | 521 | computeAlarm(mAlarmNotification ); |
522 | } | 522 | } |
523 | 523 | ||
524 | void CalendarView::suspendAlarm() | 524 | void CalendarView::suspendAlarm() |
525 | { | 525 | { |
526 | //qDebug(" CalendarView::suspendAlarm() "); | 526 | //qDebug(" CalendarView::suspendAlarm() "); |
527 | computeAlarm(mSuspendAlarmNotification ); | 527 | computeAlarm(mSuspendAlarmNotification ); |
528 | 528 | ||
529 | } | 529 | } |
530 | 530 | ||
531 | void CalendarView::startAlarm( QString mess , QString filename) | 531 | void CalendarView::startAlarm( QString mess , QString filename) |
532 | { | 532 | { |
533 | 533 | ||
534 | topLevelWidget()->showNormal(); | 534 | topLevelWidget()->showNormal(); |
535 | topLevelWidget()->setActiveWindow(); | 535 | topLevelWidget()->setActiveWindow(); |
536 | topLevelWidget()->raise(); | 536 | topLevelWidget()->raise(); |
537 | 537 | ||
538 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 538 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
539 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); | 539 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); |
540 | 540 | ||
541 | } | 541 | } |
542 | 542 | ||
543 | void CalendarView::checkNextTimerAlarm() | 543 | void CalendarView::checkNextTimerAlarm() |
544 | { | 544 | { |
545 | mCalendar->checkAlarmForIncidence( 0, true ); | 545 | mCalendar->checkAlarmForIncidence( 0, true ); |
546 | } | 546 | } |
547 | 547 | ||
548 | void CalendarView::computeAlarm( QString msg ) | 548 | void CalendarView::computeAlarm( QString msg ) |
549 | { | 549 | { |
550 | 550 | ||
551 | QString mess = msg; | 551 | QString mess = msg; |
552 | QString mAlarmMessage = mess.mid( 9 ); | 552 | QString mAlarmMessage = mess.mid( 9 ); |
553 | QString filename = MainWindow::resourcePath(); | 553 | QString filename = MainWindow::resourcePath(); |
554 | filename += "koalarm.wav"; | 554 | filename += "koalarm.wav"; |
555 | QString tempfilename; | 555 | QString tempfilename; |
556 | if ( mess.left( 13 ) == "suspend_alarm") { | 556 | if ( mess.left( 13 ) == "suspend_alarm") { |
557 | bool error = false; | 557 | bool error = false; |
558 | int len = mess.mid( 13 ).find("+++"); | 558 | int len = mess.mid( 13 ).find("+++"); |
559 | if ( len < 2 ) | 559 | if ( len < 2 ) |
560 | error = true; | 560 | error = true; |
561 | else { | 561 | else { |
562 | tempfilename = mess.mid( 13, len ); | 562 | tempfilename = mess.mid( 13, len ); |
563 | if ( !QFile::exists( tempfilename ) ) | 563 | if ( !QFile::exists( tempfilename ) ) |
564 | error = true; | 564 | error = true; |
565 | } | 565 | } |
566 | if ( ! error ) { | 566 | if ( ! error ) { |
567 | filename = tempfilename; | 567 | filename = tempfilename; |
568 | } | 568 | } |
569 | mAlarmMessage = mess.mid( 13+len+3 ); | 569 | mAlarmMessage = mess.mid( 13+len+3 ); |
570 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 570 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
571 | startAlarm( mAlarmMessage, filename); | 571 | startAlarm( mAlarmMessage, filename); |
572 | return; | 572 | return; |
573 | } | 573 | } |
574 | if ( mess.left( 11 ) == "timer_alarm") { | 574 | if ( mess.left( 11 ) == "timer_alarm") { |
575 | //mTimerTime = 0; | 575 | //mTimerTime = 0; |
576 | startAlarm( mess.mid( 11 ), filename ); | 576 | startAlarm( mess.mid( 11 ), filename ); |
577 | return; | 577 | return; |
578 | } | 578 | } |
579 | if ( mess.left( 10 ) == "proc_alarm") { | 579 | if ( mess.left( 10 ) == "proc_alarm") { |
580 | bool error = false; | 580 | bool error = false; |
581 | int len = mess.mid( 10 ).find("+++"); | 581 | int len = mess.mid( 10 ).find("+++"); |
582 | if ( len < 2 ) | 582 | if ( len < 2 ) |
583 | error = true; | 583 | error = true; |
584 | else { | 584 | else { |
585 | tempfilename = mess.mid( 10, len ); | 585 | tempfilename = mess.mid( 10, len ); |
586 | if ( !QFile::exists( tempfilename ) ) | 586 | if ( !QFile::exists( tempfilename ) ) |
587 | error = true; | 587 | error = true; |
588 | } | 588 | } |
589 | if ( error ) { | 589 | if ( error ) { |
590 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 590 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
591 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 591 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
592 | } else { | 592 | } else { |
593 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 593 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
594 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 594 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
595 | #ifndef _WIN32_ | 595 | #ifndef _WIN32_ |
596 | if ( vfork () == 0 ) { | 596 | if ( vfork () == 0 ) { |
597 | execl ( tempfilename.latin1(), 0 ); | 597 | execl ( tempfilename.latin1(), 0 ); |
598 | return; | 598 | return; |
599 | } | 599 | } |
600 | #else | 600 | #else |
601 | QProcess* p = new QProcess(); | 601 | QProcess* p = new QProcess(); |
602 | p->addArgument( tempfilename.latin1() ); | 602 | p->addArgument( tempfilename.latin1() ); |
603 | p->start(); | 603 | p->start(); |
604 | return; | 604 | return; |
605 | #endif | 605 | #endif |
606 | 606 | ||
607 | return; | 607 | return; |
608 | } | 608 | } |
609 | 609 | ||
610 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 610 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
611 | } | 611 | } |
612 | if ( mess.left( 11 ) == "audio_alarm") { | 612 | if ( mess.left( 11 ) == "audio_alarm") { |
613 | bool error = false; | 613 | bool error = false; |
614 | int len = mess.mid( 11 ).find("+++"); | 614 | int len = mess.mid( 11 ).find("+++"); |
615 | if ( len < 2 ) | 615 | if ( len < 2 ) |
616 | error = true; | 616 | error = true; |
617 | else { | 617 | else { |
618 | tempfilename = mess.mid( 11, len ); | 618 | tempfilename = mess.mid( 11, len ); |
619 | if ( !QFile::exists( tempfilename ) ) | 619 | if ( !QFile::exists( tempfilename ) ) |
620 | error = true; | 620 | error = true; |
621 | } | 621 | } |
622 | if ( ! error ) { | 622 | if ( ! error ) { |
623 | filename = tempfilename; | 623 | filename = tempfilename; |
624 | } | 624 | } |
625 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 625 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
626 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 626 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
627 | } | 627 | } |
628 | if ( mess.left( 9 ) == "cal_alarm") { | 628 | if ( mess.left( 9 ) == "cal_alarm") { |
629 | mAlarmMessage = mess.mid( 9 ) ; | 629 | mAlarmMessage = mess.mid( 9 ) ; |
630 | } | 630 | } |
631 | 631 | ||
632 | startAlarm( mAlarmMessage, filename ); | 632 | startAlarm( mAlarmMessage, filename ); |
633 | 633 | ||
634 | 634 | ||
635 | } | 635 | } |
636 | 636 | ||
637 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 637 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
638 | { | 638 | { |
639 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 639 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
640 | 640 | ||
641 | mSuspendAlarmNotification = noti; | 641 | mSuspendAlarmNotification = noti; |
642 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 642 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
643 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 643 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
644 | mSuspendTimer->start( ms , true ); | 644 | mSuspendTimer->start( ms , true ); |
645 | 645 | ||
646 | } | 646 | } |
647 | 647 | ||
648 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 648 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
649 | { | 649 | { |
650 | mNextAlarmDateTime = qdt; | 650 | mNextAlarmDateTime = qdt; |
651 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 651 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
652 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 652 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
653 | #ifndef DESKTOP_VERSION | 653 | #ifndef DESKTOP_VERSION |
654 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); | 654 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); |
655 | #endif | 655 | #endif |
656 | return; | 656 | return; |
657 | } | 657 | } |
658 | int maxSec; | 658 | int maxSec; |
659 | //maxSec = 5; //testing only | 659 | //maxSec = 5; //testing only |
660 | maxSec = 86400+3600; // one day+1hour | 660 | maxSec = 86400+3600; // one day+1hour |
661 | mAlarmNotification = noti; | 661 | mAlarmNotification = noti; |
662 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 662 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
663 | if ( sec > maxSec ) { | 663 | if ( sec > maxSec ) { |
664 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 664 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
665 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 665 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
666 | return; | 666 | return; |
667 | } else { | 667 | } else { |
668 | mRecheckAlarmTimer->stop(); | 668 | mRecheckAlarmTimer->stop(); |
669 | } | 669 | } |
670 | //qDebug("Alarm timer started with secs: %d ", sec); | 670 | //qDebug("Alarm timer started with secs: %d ", sec); |
671 | mAlarmTimer->start( sec *1000 , true ); | 671 | mAlarmTimer->start( sec *1000 , true ); |
672 | 672 | ||
673 | } | 673 | } |
674 | // called by mRecheckAlarmTimer to get next alarm | 674 | // called by mRecheckAlarmTimer to get next alarm |
675 | // we need this, because a QTimer has only a max range of 25 days | 675 | // we need this, because a QTimer has only a max range of 25 days |
676 | void CalendarView::recheckTimerAlarm() | 676 | void CalendarView::recheckTimerAlarm() |
677 | { | 677 | { |
678 | mAlarmTimer->stop(); | 678 | mAlarmTimer->stop(); |
679 | mRecheckAlarmTimer->stop(); | 679 | mRecheckAlarmTimer->stop(); |
680 | mCalendar->checkAlarmForIncidence( 0, true ); | 680 | mCalendar->checkAlarmForIncidence( 0, true ); |
681 | } | 681 | } |
682 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 682 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
683 | { | 683 | { |
684 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 684 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
685 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 685 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
686 | #ifndef DESKTOP_VERSION | 686 | #ifndef DESKTOP_VERSION |
687 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); | 687 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); |
688 | #endif | 688 | #endif |
689 | return; | 689 | return; |
690 | } | 690 | } |
691 | mAlarmTimer->stop(); | 691 | mAlarmTimer->stop(); |
692 | } | 692 | } |
693 | void CalendarView::selectWeekNum ( int num ) | 693 | void CalendarView::selectWeekNum ( int num ) |
694 | { | 694 | { |
695 | dateNavigator()->blockSignals( true ); | 695 | dateNavigator()->blockSignals( true ); |
696 | dateNavigator()->selectWeek( num ); | 696 | dateNavigator()->selectWeek( num ); |
697 | dateNavigator()->blockSignals( false ); | 697 | dateNavigator()->blockSignals( false ); |
698 | mViewManager->showWeekView(); | 698 | mViewManager->showWeekView(); |
699 | } | 699 | } |
700 | KOViewManager *CalendarView::viewManager() | 700 | KOViewManager *CalendarView::viewManager() |
701 | { | 701 | { |
702 | return mViewManager; | 702 | return mViewManager; |
703 | } | 703 | } |
704 | 704 | ||
705 | KODialogManager *CalendarView::dialogManager() | 705 | KODialogManager *CalendarView::dialogManager() |
706 | { | 706 | { |
707 | return mDialogManager; | 707 | return mDialogManager; |
708 | } | 708 | } |
709 | 709 | ||
710 | QDate CalendarView::startDate() | 710 | QDate CalendarView::startDate() |
711 | { | 711 | { |
712 | DateList dates = mNavigator->selectedDates(); | 712 | DateList dates = mNavigator->selectedDates(); |
713 | 713 | ||
714 | return dates.first(); | 714 | return dates.first(); |
715 | } | 715 | } |
716 | 716 | ||
717 | QDate CalendarView::endDate() | 717 | QDate CalendarView::endDate() |
718 | { | 718 | { |
719 | DateList dates = mNavigator->selectedDates(); | 719 | DateList dates = mNavigator->selectedDates(); |
720 | 720 | ||
721 | return dates.last(); | 721 | return dates.last(); |
722 | } | 722 | } |
723 | 723 | ||
724 | 724 | ||
725 | void CalendarView::createPrinter() | 725 | void CalendarView::createPrinter() |
726 | { | 726 | { |
727 | #ifndef KORG_NOPRINTER | 727 | #ifndef KORG_NOPRINTER |
728 | if (!mCalPrinter) { | 728 | if (!mCalPrinter) { |
729 | mCalPrinter = new CalPrinter(this, mCalendar); | 729 | mCalPrinter = new CalPrinter(this, mCalendar); |
730 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 730 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
731 | } | 731 | } |
732 | #endif | 732 | #endif |
733 | } | 733 | } |
734 | 734 | ||
735 | 735 | ||
736 | //KOPrefs::instance()->mWriteBackFile | 736 | //KOPrefs::instance()->mWriteBackFile |
737 | //KOPrefs::instance()->mWriteBackExistingOnly | 737 | //KOPrefs::instance()->mWriteBackExistingOnly |
738 | 738 | ||
739 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 739 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
740 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 740 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
741 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 741 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
742 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 742 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
743 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 743 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
744 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 744 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
745 | 745 | ||
746 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 746 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
747 | { | 747 | { |
748 | 748 | ||
749 | // 0 equal | 749 | // 0 equal |
750 | // 1 take local | 750 | // 1 take local |
751 | // 2 take remote | 751 | // 2 take remote |
752 | // 3 cancel | 752 | // 3 cancel |
753 | QDateTime lastSync = mLastCalendarSync; | 753 | QDateTime lastSync = mLastCalendarSync; |
754 | QDateTime localMod = local->lastModified(); | 754 | QDateTime localMod = local->lastModified(); |
755 | QDateTime remoteMod = remote->lastModified(); | 755 | QDateTime remoteMod = remote->lastModified(); |
756 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 756 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
757 | bool remCh, locCh; | 757 | bool remCh, locCh; |
758 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 758 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
759 | //if ( remCh ) | 759 | //if ( remCh ) |
760 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 760 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
761 | locCh = ( localMod > mLastCalendarSync ); | 761 | locCh = ( localMod > mLastCalendarSync ); |
762 | if ( !remCh && ! locCh ) { | 762 | if ( !remCh && ! locCh ) { |
763 | //qDebug("both not changed "); | 763 | //qDebug("both not changed "); |
764 | lastSync = localMod.addDays(1); | 764 | lastSync = localMod.addDays(1); |
765 | if ( mode <= SYNC_PREF_ASK ) | 765 | if ( mode <= SYNC_PREF_ASK ) |
766 | return 0; | 766 | return 0; |
767 | } else { | 767 | } else { |
768 | if ( locCh ) { | 768 | if ( locCh ) { |
769 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); | 769 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
770 | lastSync = localMod.addDays( -1 ); | 770 | lastSync = localMod.addDays( -1 ); |
771 | if ( !remCh ) | 771 | if ( !remCh ) |
772 | remoteMod = ( lastSync.addDays( -1 ) ); | 772 | remoteMod = ( lastSync.addDays( -1 ) ); |
773 | } else { | 773 | } else { |
774 | //qDebug(" not loc changed "); | 774 | //qDebug(" not loc changed "); |
775 | lastSync = localMod.addDays( 1 ); | 775 | lastSync = localMod.addDays( 1 ); |
776 | if ( remCh ) | 776 | if ( remCh ) |
777 | remoteMod =( lastSync.addDays( 1 ) ); | 777 | remoteMod =( lastSync.addDays( 1 ) ); |
778 | 778 | ||
779 | } | 779 | } |
780 | } | 780 | } |
781 | full = true; | 781 | full = true; |
782 | if ( mode < SYNC_PREF_ASK ) | 782 | if ( mode < SYNC_PREF_ASK ) |
783 | mode = SYNC_PREF_ASK; | 783 | mode = SYNC_PREF_ASK; |
784 | } else { | 784 | } else { |
785 | if ( localMod == remoteMod ) | 785 | if ( localMod == remoteMod ) |
786 | // if ( local->revision() == remote->revision() ) | 786 | // if ( local->revision() == remote->revision() ) |
787 | return 0; | 787 | return 0; |
788 | 788 | ||
789 | } | 789 | } |
790 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 790 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
791 | 791 | ||
792 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); | 792 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
793 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); | 793 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
794 | //full = true; //debug only | 794 | //full = true; //debug only |
795 | if ( full ) { | 795 | if ( full ) { |
796 | bool equ = false; | 796 | bool equ = false; |
797 | if ( local->type() == "Event" ) { | 797 | if ( local->type() == "Event" ) { |
798 | equ = (*((Event*) local) == *((Event*) remote)); | 798 | equ = (*((Event*) local) == *((Event*) remote)); |
799 | } | 799 | } |
800 | else if ( local->type() =="Todo" ) | 800 | else if ( local->type() =="Todo" ) |
801 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 801 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
802 | else if ( local->type() =="Journal" ) | 802 | else if ( local->type() =="Journal" ) |
803 | equ = (*((Journal*) local) == *((Journal*) remote)); | 803 | equ = (*((Journal*) local) == *((Journal*) remote)); |
804 | if ( equ ) { | 804 | if ( equ ) { |
805 | //qDebug("equal "); | 805 | //qDebug("equal "); |
806 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 806 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
807 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 807 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
808 | } | 808 | } |
809 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 809 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
810 | return 0; | 810 | return 0; |
811 | 811 | ||
812 | }//else //debug only | 812 | }//else //debug only |
813 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 813 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
814 | } | 814 | } |
815 | int result; | 815 | int result; |
816 | bool localIsNew; | 816 | bool localIsNew; |
817 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); | 817 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); |
818 | 818 | ||
819 | |||
820 | // ************************************************ | ||
821 | // ************************************************ | ||
822 | // ************************************************ | ||
823 | // We may have that lastSync > remoteMod AND lastSync > localMod | ||
824 | // BUT remoteMod != localMod | ||
825 | |||
826 | |||
819 | if ( full && mode < SYNC_PREF_NEWEST ) | 827 | if ( full && mode < SYNC_PREF_NEWEST ) |
820 | mode = SYNC_PREF_ASK; | 828 | mode = SYNC_PREF_ASK; |
821 | 829 | ||
822 | switch( mode ) { | 830 | switch( mode ) { |
823 | case SYNC_PREF_LOCAL: | 831 | case SYNC_PREF_LOCAL: |
824 | if ( lastSync > remoteMod ) | 832 | if ( lastSync > remoteMod ) |
825 | return 1; | 833 | return 1; |
826 | if ( lastSync > localMod ) | 834 | if ( lastSync > localMod ) |
827 | return 2; | 835 | return 2; |
828 | return 1; | 836 | return 1; |
829 | break; | 837 | break; |
830 | case SYNC_PREF_REMOTE: | 838 | case SYNC_PREF_REMOTE: |
831 | if ( lastSync > remoteMod ) | ||
832 | return 1; | ||
833 | if ( lastSync > localMod ) | 839 | if ( lastSync > localMod ) |
834 | return 2; | 840 | return 2; |
841 | if ( lastSync > remoteMod ) | ||
842 | return 1; | ||
835 | return 2; | 843 | return 2; |
836 | break; | 844 | break; |
837 | case SYNC_PREF_NEWEST: | 845 | case SYNC_PREF_NEWEST: |
838 | if ( localMod > remoteMod ) | 846 | if ( localMod >= remoteMod ) |
839 | return 1; | 847 | return 1; |
840 | else | 848 | else |
841 | return 2; | 849 | return 2; |
842 | break; | 850 | break; |
843 | case SYNC_PREF_ASK: | 851 | case SYNC_PREF_ASK: |
844 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 852 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
853 | if ( lastSync > remoteMod && lastSync > localMod) | ||
854 | return 0; | ||
845 | if ( lastSync > remoteMod ) | 855 | if ( lastSync > remoteMod ) |
846 | return 1; | 856 | return 1; |
847 | if ( lastSync > localMod ) | 857 | if ( lastSync > localMod ) |
848 | return 2; | 858 | return 2; |
849 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 859 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
850 | localIsNew = localMod >= remoteMod; | 860 | localIsNew = localMod >= remoteMod; |
851 | if ( localIsNew ) | 861 | if ( localIsNew ) |
852 | getEventViewerDialog()->setColorMode( 1 ); | 862 | getEventViewerDialog()->setColorMode( 1 ); |
853 | else | 863 | else |
854 | getEventViewerDialog()->setColorMode( 2 ); | 864 | getEventViewerDialog()->setColorMode( 2 ); |
855 | getEventViewerDialog()->setIncidence(local); | 865 | getEventViewerDialog()->setIncidence(local); |
856 | if ( localIsNew ) | 866 | if ( localIsNew ) |
857 | getEventViewerDialog()->setColorMode( 2 ); | 867 | getEventViewerDialog()->setColorMode( 2 ); |
858 | else | 868 | else |
859 | getEventViewerDialog()->setColorMode( 1 ); | 869 | getEventViewerDialog()->setColorMode( 1 ); |
860 | getEventViewerDialog()->addIncidence(remote); | 870 | getEventViewerDialog()->addIncidence(remote); |
861 | getEventViewerDialog()->setColorMode( 0 ); | 871 | getEventViewerDialog()->setColorMode( 0 ); |
862 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 872 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
863 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 873 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
864 | getEventViewerDialog()->showMe(); | 874 | getEventViewerDialog()->showMe(); |
865 | result = getEventViewerDialog()->executeS( localIsNew ); | 875 | result = getEventViewerDialog()->executeS( localIsNew ); |
866 | return result; | 876 | return result; |
867 | 877 | ||
868 | break; | 878 | break; |
869 | case SYNC_PREF_FORCE_LOCAL: | 879 | case SYNC_PREF_FORCE_LOCAL: |
870 | return 1; | 880 | return 1; |
871 | break; | 881 | break; |
872 | case SYNC_PREF_FORCE_REMOTE: | 882 | case SYNC_PREF_FORCE_REMOTE: |
873 | return 2; | 883 | return 2; |
874 | break; | 884 | break; |
875 | 885 | ||
876 | default: | 886 | default: |
877 | // SYNC_PREF_TAKE_BOTH not implemented | 887 | // SYNC_PREF_TAKE_BOTH not implemented |
878 | break; | 888 | break; |
879 | } | 889 | } |
880 | return 0; | 890 | return 0; |
881 | } | 891 | } |
882 | Event* CalendarView::getLastSyncEvent() | 892 | Event* CalendarView::getLastSyncEvent() |
883 | { | 893 | { |
884 | Event* lse; | 894 | Event* lse; |
885 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 895 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
886 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 896 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
887 | if (!lse) { | 897 | if (!lse) { |
888 | lse = new Event(); | 898 | lse = new Event(); |
889 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 899 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
890 | QString sum = ""; | 900 | QString sum = ""; |
891 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 901 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
892 | sum = "E: "; | 902 | sum = "E: "; |
893 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 903 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
894 | lse->setDtStart( mLastCalendarSync ); | 904 | lse->setDtStart( mLastCalendarSync ); |
895 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 905 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
896 | lse->setCategories( i18n("SyncEvent") ); | 906 | lse->setCategories( i18n("SyncEvent") ); |
897 | lse->setReadOnly( true ); | 907 | lse->setReadOnly( true ); |
898 | mCalendar->addEvent( lse ); | 908 | mCalendar->addEvent( lse ); |
899 | } | 909 | } |
900 | 910 | ||
901 | return lse; | 911 | return lse; |
902 | 912 | ||
903 | } | 913 | } |
904 | 914 | ||
905 | // we check, if the to delete event has a id for a profile | 915 | // we check, if the to delete event has a id for a profile |
906 | // if yes, we set this id in the profile to delete | 916 | // if yes, we set this id in the profile to delete |
907 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 917 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
908 | { | 918 | { |
909 | if ( lastSync.count() == 0 ) { | 919 | if ( lastSync.count() == 0 ) { |
910 | //qDebug(" lastSync.count() == 0"); | 920 | //qDebug(" lastSync.count() == 0"); |
911 | return; | 921 | return; |
912 | } | 922 | } |
913 | if ( toDelete->type() == "Journal" ) | 923 | if ( toDelete->type() == "Journal" ) |
914 | return; | 924 | return; |
915 | 925 | ||
916 | Event* eve = lastSync.first(); | 926 | Event* eve = lastSync.first(); |
917 | 927 | ||
918 | while ( eve ) { | 928 | while ( eve ) { |
919 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 929 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
920 | if ( !id.isEmpty() ) { | 930 | if ( !id.isEmpty() ) { |
921 | QString des = eve->description(); | 931 | QString des = eve->description(); |
922 | QString pref = "e"; | 932 | QString pref = "e"; |
923 | if ( toDelete->type() == "Todo" ) | 933 | if ( toDelete->type() == "Todo" ) |
924 | pref = "t"; | 934 | pref = "t"; |
925 | des += pref+ id + ","; | 935 | des += pref+ id + ","; |
926 | eve->setReadOnly( false ); | 936 | eve->setReadOnly( false ); |
927 | eve->setDescription( des ); | 937 | eve->setDescription( des ); |
928 | //qDebug("setdes %s ", des.latin1()); | 938 | //qDebug("setdes %s ", des.latin1()); |
929 | eve->setReadOnly( true ); | 939 | eve->setReadOnly( true ); |
930 | } | 940 | } |
931 | eve = lastSync.next(); | 941 | eve = lastSync.next(); |
932 | } | 942 | } |
933 | 943 | ||
934 | } | 944 | } |
935 | void CalendarView::checkExternalId( Incidence * inc ) | 945 | void CalendarView::checkExternalId( Incidence * inc ) |
936 | { | 946 | { |
937 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 947 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
938 | checkExternSyncEvent( lastSync, inc ); | 948 | checkExternSyncEvent( lastSync, inc ); |
939 | 949 | ||
940 | } | 950 | } |
941 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 951 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
942 | { | 952 | { |
943 | bool syncOK = true; | 953 | bool syncOK = true; |
944 | int addedEvent = 0; | 954 | int addedEvent = 0; |
945 | int addedEventR = 0; | 955 | int addedEventR = 0; |
946 | int deletedEventR = 0; | 956 | int deletedEventR = 0; |
947 | int deletedEventL = 0; | 957 | int deletedEventL = 0; |
948 | int changedLocal = 0; | 958 | int changedLocal = 0; |
949 | int changedRemote = 0; | 959 | int changedRemote = 0; |
950 | int filteredIN = 0; | 960 | int filteredIN = 0; |
951 | int filteredOUT = 0; | 961 | int filteredOUT = 0; |
952 | //QPtrList<Event> el = local->rawEvents(); | 962 | //QPtrList<Event> el = local->rawEvents(); |
953 | Event* eventR; | 963 | Event* eventR; |
954 | QString uid; | 964 | QString uid; |
955 | int take; | 965 | int take; |
956 | Event* eventL; | 966 | Event* eventL; |
957 | Event* eventRSync; | 967 | Event* eventRSync; |
958 | Event* eventLSync; | 968 | Event* eventLSync; |
959 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 969 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
960 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 970 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
961 | bool fullDateRange = false; | 971 | bool fullDateRange = false; |
962 | local->resetTempSyncStat(); | 972 | local->resetTempSyncStat(); |
963 | mLastCalendarSync = QDateTime::currentDateTime(); | 973 | mLastCalendarSync = QDateTime::currentDateTime(); |
964 | if ( mSyncManager->syncWithDesktop() ) { | 974 | if ( mSyncManager->syncWithDesktop() ) { |
965 | remote->resetPilotStat(1); | 975 | remote->resetPilotStat(1); |
966 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 976 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
967 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; | 977 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; |
968 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); | 978 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); |
969 | } else { | 979 | } else { |
970 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 980 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
971 | } | 981 | } |
972 | } | 982 | } |
973 | QDateTime modifiedCalendar = mLastCalendarSync; | 983 | QDateTime modifiedCalendar = mLastCalendarSync; |
974 | eventLSync = getLastSyncEvent(); | 984 | eventLSync = getLastSyncEvent(); |
975 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 985 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
976 | if ( eventR ) { | 986 | if ( eventR ) { |
977 | eventRSync = (Event*) eventR->clone(); | 987 | eventRSync = (Event*) eventR->clone(); |
978 | remote->deleteEvent(eventR ); | 988 | remote->deleteEvent(eventR ); |
979 | 989 | ||
980 | } else { | 990 | } else { |
981 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { | 991 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { |
982 | eventRSync = (Event*)eventLSync->clone(); | 992 | eventRSync = (Event*)eventLSync->clone(); |
983 | } else { | 993 | } else { |
984 | fullDateRange = true; | 994 | fullDateRange = true; |
985 | eventRSync = new Event(); | 995 | eventRSync = new Event(); |
986 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 996 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
987 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 997 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
988 | eventRSync->setDtStart( mLastCalendarSync ); | 998 | eventRSync->setDtStart( mLastCalendarSync ); |
989 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 999 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
990 | eventRSync->setCategories( i18n("SyncEvent") ); | 1000 | eventRSync->setCategories( i18n("SyncEvent") ); |
991 | } | 1001 | } |
992 | } | 1002 | } |
993 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 1003 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
994 | fullDateRange = true; | 1004 | fullDateRange = true; |
995 | 1005 | ||
996 | if ( ! fullDateRange ) { | 1006 | if ( ! fullDateRange ) { |
997 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 1007 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
998 | 1008 | ||
999 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 1009 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
1000 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 1010 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
1001 | fullDateRange = true; | 1011 | fullDateRange = true; |
1002 | } | 1012 | } |
1003 | } | 1013 | } |
1004 | if ( mSyncManager->syncWithDesktop() ) { | 1014 | if ( mSyncManager->syncWithDesktop() ) { |
1005 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); | 1015 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); |
1006 | } | 1016 | } |
1007 | if ( fullDateRange ) | 1017 | if ( fullDateRange ) |
1008 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 1018 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
1009 | else | 1019 | else |
1010 | mLastCalendarSync = eventLSync->dtStart(); | 1020 | mLastCalendarSync = eventLSync->dtStart(); |
1011 | // for resyncing if own file has changed | 1021 | // for resyncing if own file has changed |
1012 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 1022 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
1013 | mLastCalendarSync = loadedFileVersion; | 1023 | mLastCalendarSync = loadedFileVersion; |
1014 | //qDebug("setting mLastCalendarSync "); | 1024 | //qDebug("setting mLastCalendarSync "); |
1015 | } | 1025 | } |
1016 | //qDebug("*************************** "); | 1026 | //qDebug("*************************** "); |
1017 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); | 1027 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); |
1018 | QPtrList<Incidence> er = remote->rawIncidences(); | 1028 | QPtrList<Incidence> er = remote->rawIncidences(); |
1019 | Incidence* inR = er.first(); | 1029 | Incidence* inR = er.first(); |
1020 | Incidence* inL; | 1030 | Incidence* inL; |
1021 | QProgressBar bar( er.count(),0 ); | 1031 | QProgressBar bar( er.count(),0 ); |
1022 | bar.setCaption (i18n("Syncing - close to abort!") ); | 1032 | bar.setCaption (i18n("Syncing - close to abort!") ); |
1023 | 1033 | ||
1024 | // ************** setting up filter ************* | 1034 | // ************** setting up filter ************* |
1025 | CalFilter *filterIN = 0; | 1035 | CalFilter *filterIN = 0; |
1026 | CalFilter *filterOUT = 0; | 1036 | CalFilter *filterOUT = 0; |
1027 | CalFilter *filter = mFilters.first(); | 1037 | CalFilter *filter = mFilters.first(); |
1028 | while(filter) { | 1038 | while(filter) { |
1029 | if ( filter->name() == mSyncManager->mFilterInCal ) | 1039 | if ( filter->name() == mSyncManager->mFilterInCal ) |
1030 | filterIN = filter; | 1040 | filterIN = filter; |
1031 | if ( filter->name() == mSyncManager->mFilterOutCal ) | 1041 | if ( filter->name() == mSyncManager->mFilterOutCal ) |
1032 | filterOUT = filter; | 1042 | filterOUT = filter; |
1033 | filter = mFilters.next(); | 1043 | filter = mFilters.next(); |
1034 | } | 1044 | } |
1035 | int w = 300; | 1045 | int w = 300; |
1036 | if ( QApplication::desktop()->width() < 320 ) | 1046 | if ( QApplication::desktop()->width() < 320 ) |
1037 | w = 220; | 1047 | w = 220; |
1038 | int h = bar.sizeHint().height() ; | 1048 | int h = bar.sizeHint().height() ; |
1039 | int dw = QApplication::desktop()->width(); | 1049 | int dw = QApplication::desktop()->width(); |
1040 | int dh = QApplication::desktop()->height(); | 1050 | int dh = QApplication::desktop()->height(); |
1041 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1051 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1042 | bar.show(); | 1052 | bar.show(); |
1043 | int modulo = (er.count()/10)+1; | 1053 | int modulo = (er.count()/10)+1; |
1044 | int incCounter = 0; | 1054 | int incCounter = 0; |
1045 | while ( inR ) { | 1055 | while ( inR ) { |
1046 | if ( ! bar.isVisible() ) | 1056 | if ( ! bar.isVisible() ) |
1047 | return false; | 1057 | return false; |
1048 | if ( incCounter % modulo == 0 ) | 1058 | if ( incCounter % modulo == 0 ) |
1049 | bar.setProgress( incCounter ); | 1059 | bar.setProgress( incCounter ); |
1050 | ++incCounter; | 1060 | ++incCounter; |
1051 | uid = inR->uid(); | 1061 | uid = inR->uid(); |
1052 | bool skipIncidence = false; | 1062 | bool skipIncidence = false; |
1053 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1063 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1054 | skipIncidence = true; | 1064 | skipIncidence = true; |
1055 | QString idS; | 1065 | QString idS; |
1056 | qApp->processEvents(); | 1066 | qApp->processEvents(); |
1057 | if ( !skipIncidence ) { | 1067 | if ( !skipIncidence ) { |
1058 | inL = local->incidence( uid ); | 1068 | inL = local->incidence( uid ); |
1059 | if ( inL ) { // maybe conflict - same uid in both calendars | 1069 | if ( inL ) { // maybe conflict - same uid in both calendars |
1060 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1070 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1061 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1071 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1062 | if ( take == 3 ) | 1072 | if ( take == 3 ) |
1063 | return false; | 1073 | return false; |
1064 | if ( take == 1 ) {// take local ********************** | 1074 | if ( take == 1 ) {// take local ********************** |
1065 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1075 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1066 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1076 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1067 | else | 1077 | else |
1068 | idS = inR->IDStr(); | 1078 | idS = inR->IDStr(); |
1069 | remote->deleteIncidence( inR ); | 1079 | remote->deleteIncidence( inR ); |
1070 | inR = inL->clone(); | 1080 | inR = inL->clone(); |
1071 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1081 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1072 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1082 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1073 | inR->setIDStr( idS ); | 1083 | inR->setIDStr( idS ); |
1074 | remote->addIncidence( inR ); | 1084 | remote->addIncidence( inR ); |
1075 | if ( mSyncManager->syncWithDesktop() ) | 1085 | if ( mSyncManager->syncWithDesktop() ) |
1076 | inR->setPilotId( 2 ); | 1086 | inR->setPilotId( 2 ); |
1077 | ++changedRemote; | 1087 | ++changedRemote; |
1078 | } else {// take remote ********************** | 1088 | } else {// take remote ********************** |
1079 | idS = inL->IDStr(); | 1089 | idS = inL->IDStr(); |
1080 | int pid = inL->pilotId(); | 1090 | int pid = inL->pilotId(); |
1081 | local->deleteIncidence( inL ); | 1091 | local->deleteIncidence( inL ); |
1082 | inL = inR->clone(); | 1092 | inL = inR->clone(); |
1083 | if ( mSyncManager->syncWithDesktop() ) | 1093 | if ( mSyncManager->syncWithDesktop() ) |
1084 | inL->setPilotId( pid ); | 1094 | inL->setPilotId( pid ); |
1085 | inL->setIDStr( idS ); | 1095 | inL->setIDStr( idS ); |
1086 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1096 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1087 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1097 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1088 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1098 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1089 | } | 1099 | } |
1090 | local->addIncidence( inL ); | 1100 | local->addIncidence( inL ); |
1091 | ++changedLocal; | 1101 | ++changedLocal; |
1092 | } | 1102 | } |
1093 | } | 1103 | } |
1094 | } else { // no conflict ********** add or delete remote | 1104 | } else { // no conflict ********** add or delete remote |
1095 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ | 1105 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ |
1096 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1106 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1097 | QString des = eventLSync->description(); | 1107 | QString des = eventLSync->description(); |
1098 | QString pref = "e"; | 1108 | QString pref = "e"; |
1099 | if ( inR->type() == "Todo" ) | 1109 | if ( inR->type() == "Todo" ) |
1100 | pref = "t"; | 1110 | pref = "t"; |
1101 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1111 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1102 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1112 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1103 | //remote->deleteIncidence( inR ); | 1113 | //remote->deleteIncidence( inR ); |
1104 | ++deletedEventR; | 1114 | ++deletedEventR; |
1105 | } else { | 1115 | } else { |
1106 | inR->setLastModified( modifiedCalendar ); | 1116 | inR->setLastModified( modifiedCalendar ); |
1107 | inL = inR->clone(); | 1117 | inL = inR->clone(); |
1108 | inL->setIDStr( ":" ); | 1118 | inL->setIDStr( ":" ); |
1109 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1119 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1110 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1120 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1111 | local->addIncidence( inL ); | 1121 | local->addIncidence( inL ); |
1112 | ++addedEvent; | 1122 | ++addedEvent; |
1113 | 1123 | ||
1114 | } | 1124 | } |
1115 | } else { | 1125 | } else { |
1116 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1126 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1117 | inR->setLastModified( modifiedCalendar ); | 1127 | inR->setLastModified( modifiedCalendar ); |
1118 | inL = inR->clone(); | 1128 | inL = inR->clone(); |
1119 | inL->setIDStr( ":" ); | 1129 | inL->setIDStr( ":" ); |
1120 | local->addIncidence( inL ); | 1130 | local->addIncidence( inL ); |
1121 | ++addedEvent; | 1131 | ++addedEvent; |
1122 | 1132 | ||
1123 | } else { | 1133 | } else { |
1124 | checkExternSyncEvent(eventRSyncSharp, inR); | 1134 | checkExternSyncEvent(eventRSyncSharp, inR); |
1125 | remote->deleteIncidence( inR ); | 1135 | remote->deleteIncidence( inR ); |
1126 | ++deletedEventR; | 1136 | ++deletedEventR; |
1127 | } | 1137 | } |
1128 | } | 1138 | } |
1129 | } else { | 1139 | } else { |
1130 | ++filteredIN; | 1140 | ++filteredIN; |
1131 | } | 1141 | } |
1132 | } | 1142 | } |
1133 | } | 1143 | } |
1134 | inR = er.next(); | 1144 | inR = er.next(); |
1135 | } | 1145 | } |
1136 | QPtrList<Incidence> el = local->rawIncidences(); | 1146 | QPtrList<Incidence> el = local->rawIncidences(); |
1137 | inL = el.first(); | 1147 | inL = el.first(); |
1138 | modulo = (el.count()/10)+1; | 1148 | modulo = (el.count()/10)+1; |
1139 | bar.setCaption (i18n("Add / remove events") ); | 1149 | bar.setCaption (i18n("Add / remove events") ); |
1140 | bar.setTotalSteps ( el.count() ) ; | 1150 | bar.setTotalSteps ( el.count() ) ; |
1141 | bar.show(); | 1151 | bar.show(); |
1142 | incCounter = 0; | 1152 | incCounter = 0; |
1143 | 1153 | ||
1144 | while ( inL ) { | 1154 | while ( inL ) { |
1145 | 1155 | ||
1146 | qApp->processEvents(); | 1156 | qApp->processEvents(); |
1147 | if ( ! bar.isVisible() ) | 1157 | if ( ! bar.isVisible() ) |
1148 | return false; | 1158 | return false; |
1149 | if ( incCounter % modulo == 0 ) | 1159 | if ( incCounter % modulo == 0 ) |
1150 | bar.setProgress( incCounter ); | 1160 | bar.setProgress( incCounter ); |
1151 | ++incCounter; | 1161 | ++incCounter; |
1152 | uid = inL->uid(); | 1162 | uid = inL->uid(); |
1153 | bool skipIncidence = false; | 1163 | bool skipIncidence = false; |
1154 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1164 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1155 | skipIncidence = true; | 1165 | skipIncidence = true; |
1156 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) | 1166 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) |
1157 | skipIncidence = true; | 1167 | skipIncidence = true; |
1158 | if ( !skipIncidence ) { | 1168 | if ( !skipIncidence ) { |
1159 | inR = remote->incidence( uid ); | 1169 | inR = remote->incidence( uid ); |
1160 | if ( ! inR ) { | 1170 | if ( ! inR ) { |
1161 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ | 1171 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ |
1162 | // no conflict ********** add or delete local | 1172 | // no conflict ********** add or delete local |
1163 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1173 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1164 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1174 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1165 | checkExternSyncEvent(eventLSyncSharp, inL); | 1175 | checkExternSyncEvent(eventLSyncSharp, inL); |
1166 | local->deleteIncidence( inL ); | 1176 | local->deleteIncidence( inL ); |
1167 | ++deletedEventL; | 1177 | ++deletedEventL; |
1168 | } else { | 1178 | } else { |
1169 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1179 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1170 | inL->removeID(mCurrentSyncDevice ); | 1180 | inL->removeID(mCurrentSyncDevice ); |
1171 | ++addedEventR; | 1181 | ++addedEventR; |
1172 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1182 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1173 | inL->setLastModified( modifiedCalendar ); | 1183 | inL->setLastModified( modifiedCalendar ); |
1174 | inR = inL->clone(); | 1184 | inR = inL->clone(); |
1175 | inR->setIDStr( ":" ); | 1185 | inR->setIDStr( ":" ); |
1176 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1186 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1177 | remote->addIncidence( inR ); | 1187 | remote->addIncidence( inR ); |
1178 | } | 1188 | } |
1179 | } | 1189 | } |
1180 | } else { | 1190 | } else { |
1181 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1191 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1182 | checkExternSyncEvent(eventLSyncSharp, inL); | 1192 | checkExternSyncEvent(eventLSyncSharp, inL); |
1183 | local->deleteIncidence( inL ); | 1193 | local->deleteIncidence( inL ); |
1184 | ++deletedEventL; | 1194 | ++deletedEventL; |
1185 | } else { | 1195 | } else { |
1186 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1196 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1187 | ++addedEventR; | 1197 | ++addedEventR; |
1188 | inL->setLastModified( modifiedCalendar ); | 1198 | inL->setLastModified( modifiedCalendar ); |
1189 | inR = inL->clone(); | 1199 | inR = inL->clone(); |
1190 | inR->setIDStr( ":" ); | 1200 | inR->setIDStr( ":" ); |
1191 | remote->addIncidence( inR ); | 1201 | remote->addIncidence( inR ); |
1192 | } | 1202 | } |
1193 | } | 1203 | } |
1194 | } | 1204 | } |
1195 | } else { | 1205 | } else { |
1196 | ++filteredOUT; | 1206 | ++filteredOUT; |
1197 | } | 1207 | } |
1198 | } | 1208 | } |
1199 | } | 1209 | } |
1200 | inL = el.next(); | 1210 | inL = el.next(); |
1201 | } | 1211 | } |
1202 | int delFut = 0; | 1212 | int delFut = 0; |
1203 | int remRem = 0; | 1213 | int remRem = 0; |
1204 | if ( mSyncManager->mWriteBackInFuture ) { | 1214 | if ( mSyncManager->mWriteBackInFuture ) { |
1205 | er = remote->rawIncidences(); | 1215 | er = remote->rawIncidences(); |
1206 | remRem = er.count(); | 1216 | remRem = er.count(); |
1207 | inR = er.first(); | 1217 | inR = er.first(); |
1208 | QDateTime dt; | 1218 | QDateTime dt; |
1209 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); | 1219 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); |
1210 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); | 1220 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); |
1211 | while ( inR ) { | 1221 | while ( inR ) { |
1212 | if ( inR->type() == "Todo" ) { | 1222 | if ( inR->type() == "Todo" ) { |
1213 | Todo * t = (Todo*)inR; | 1223 | Todo * t = (Todo*)inR; |
1214 | if ( t->hasDueDate() ) | 1224 | if ( t->hasDueDate() ) |
1215 | dt = t->dtDue(); | 1225 | dt = t->dtDue(); |
1216 | else | 1226 | else |
1217 | dt = cur.addSecs( 62 ); | 1227 | dt = cur.addSecs( 62 ); |
1218 | } | 1228 | } |
1219 | else if (inR->type() == "Event" ) { | 1229 | else if (inR->type() == "Event" ) { |
1220 | bool ok; | 1230 | bool ok; |
1221 | dt = inR->getNextOccurence( cur, &ok ); | 1231 | dt = inR->getNextOccurence( cur, &ok ); |
1222 | if ( !ok ) | 1232 | if ( !ok ) |
1223 | dt = cur.addSecs( -62 ); | 1233 | dt = cur.addSecs( -62 ); |
1224 | } | 1234 | } |
1225 | else | 1235 | else |
1226 | dt = inR->dtStart(); | 1236 | dt = inR->dtStart(); |
1227 | if ( dt < cur || dt > end ) { | 1237 | if ( dt < cur || dt > end ) { |
1228 | remote->deleteIncidence( inR ); | 1238 | remote->deleteIncidence( inR ); |
1229 | ++delFut; | 1239 | ++delFut; |
1230 | } | 1240 | } |
1231 | inR = er.next(); | 1241 | inR = er.next(); |
1232 | } | 1242 | } |
1233 | } | 1243 | } |
1234 | bar.hide(); | 1244 | bar.hide(); |
1235 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1245 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1236 | eventLSync->setReadOnly( false ); | 1246 | eventLSync->setReadOnly( false ); |
1237 | eventLSync->setDtStart( mLastCalendarSync ); | 1247 | eventLSync->setDtStart( mLastCalendarSync ); |
1238 | eventRSync->setDtStart( mLastCalendarSync ); | 1248 | eventRSync->setDtStart( mLastCalendarSync ); |
1239 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1249 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1240 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1250 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1241 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1251 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1242 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1252 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1243 | eventLSync->setReadOnly( true ); | 1253 | eventLSync->setReadOnly( true ); |
1244 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); | 1254 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); |
1245 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... | 1255 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... |
1246 | remote->addEvent( eventRSync ); | 1256 | remote->addEvent( eventRSync ); |
1247 | else | 1257 | else |
1248 | delete eventRSync; | 1258 | delete eventRSync; |
1249 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); | 1259 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); |
1250 | QString mes; | 1260 | QString mes; |
1251 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); | 1261 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); |
1252 | QString delmess; | 1262 | QString delmess; |
1253 | if ( delFut ) { | 1263 | if ( delFut ) { |
1254 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); | 1264 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); |
1255 | mes += delmess; | 1265 | mes += delmess; |
1256 | } | 1266 | } |
1257 | mes = i18n("Local calendar changed!\n") +mes; | 1267 | mes = i18n("Local calendar changed!\n") +mes; |
1258 | mCalendar->checkAlarmForIncidence( 0, true ); | 1268 | mCalendar->checkAlarmForIncidence( 0, true ); |
1259 | qDebug( mes ); | 1269 | qDebug( mes ); |
1260 | if ( mSyncManager->mShowSyncSummary ) { | 1270 | if ( mSyncManager->mShowSyncSummary ) { |
1261 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 1271 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
1262 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { | 1272 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { |
1263 | qDebug("KO: WB cancelled "); | 1273 | qDebug("KO: WB cancelled "); |
1264 | mSyncManager->mWriteBackFile = false; | 1274 | mSyncManager->mWriteBackFile = false; |
1265 | return syncOK; | 1275 | return syncOK; |
1266 | } | 1276 | } |
1267 | } | 1277 | } |
1268 | return syncOK; | 1278 | return syncOK; |
1269 | } | 1279 | } |
1270 | 1280 | ||
1271 | void CalendarView::setSyncDevice( QString s ) | 1281 | void CalendarView::setSyncDevice( QString s ) |
1272 | { | 1282 | { |
1273 | mCurrentSyncDevice= s; | 1283 | mCurrentSyncDevice= s; |
1274 | } | 1284 | } |
1275 | void CalendarView::setSyncName( QString s ) | 1285 | void CalendarView::setSyncName( QString s ) |
1276 | { | 1286 | { |
1277 | mCurrentSyncName= s; | 1287 | mCurrentSyncName= s; |
1278 | } | 1288 | } |
1279 | bool CalendarView::syncCalendar(QString filename, int mode) | 1289 | bool CalendarView::syncCalendar(QString filename, int mode) |
1280 | { | 1290 | { |
1281 | //qDebug("syncCalendar %s ", filename.latin1()); | 1291 | //qDebug("syncCalendar %s ", filename.latin1()); |
1282 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1292 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1283 | CalendarLocal* calendar = new CalendarLocal(); | 1293 | CalendarLocal* calendar = new CalendarLocal(); |
1284 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1294 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1285 | FileStorage* storage = new FileStorage( calendar ); | 1295 | FileStorage* storage = new FileStorage( calendar ); |
1286 | bool syncOK = false; | 1296 | bool syncOK = false; |
1287 | storage->setFileName( filename ); | 1297 | storage->setFileName( filename ); |
1288 | // qDebug("loading ... "); | 1298 | // qDebug("loading ... "); |
1289 | if ( storage->load() ) { | 1299 | if ( storage->load() ) { |
1290 | getEventViewerDialog()->setSyncMode( true ); | 1300 | getEventViewerDialog()->setSyncMode( true ); |
1291 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1301 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1292 | getEventViewerDialog()->setSyncMode( false ); | 1302 | getEventViewerDialog()->setSyncMode( false ); |
1293 | if ( syncOK ) { | 1303 | if ( syncOK ) { |
1294 | if ( mSyncManager->mWriteBackFile ) | 1304 | if ( mSyncManager->mWriteBackFile ) |
1295 | { | 1305 | { |
1296 | storage->setSaveFormat( new ICalFormat() ); | 1306 | storage->setSaveFormat( new ICalFormat() ); |
1297 | storage->save(); | 1307 | storage->save(); |
1298 | } | 1308 | } |
1299 | } | 1309 | } |
1300 | setModified( true ); | 1310 | setModified( true ); |
1301 | } | 1311 | } |
1302 | delete storage; | 1312 | delete storage; |
1303 | delete calendar; | 1313 | delete calendar; |
1304 | if ( syncOK ) | 1314 | if ( syncOK ) |
1305 | updateView(); | 1315 | updateView(); |
1306 | return syncOK; | 1316 | return syncOK; |
1307 | } | 1317 | } |
1308 | 1318 | ||
1309 | void CalendarView::syncExternal( int mode ) | 1319 | void CalendarView::syncExternal( int mode ) |
1310 | { | 1320 | { |
1311 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1321 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1312 | 1322 | ||
1313 | qApp->processEvents(); | 1323 | qApp->processEvents(); |
1314 | CalendarLocal* calendar = new CalendarLocal(); | 1324 | CalendarLocal* calendar = new CalendarLocal(); |
1315 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1325 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1316 | bool syncOK = false; | 1326 | bool syncOK = false; |
1317 | bool loadSuccess = false; | 1327 | bool loadSuccess = false; |
1318 | PhoneFormat* phoneFormat = 0; | 1328 | PhoneFormat* phoneFormat = 0; |
1319 | emit tempDisableBR(true); | 1329 | emit tempDisableBR(true); |
1320 | #ifndef DESKTOP_VERSION | 1330 | #ifndef DESKTOP_VERSION |
1321 | SharpFormat* sharpFormat = 0; | 1331 | SharpFormat* sharpFormat = 0; |
1322 | if ( mode == 0 ) { // sharp | 1332 | if ( mode == 0 ) { // sharp |
1323 | sharpFormat = new SharpFormat () ; | 1333 | sharpFormat = new SharpFormat () ; |
1324 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1334 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1325 | 1335 | ||
1326 | } else | 1336 | } else |
1327 | #endif | 1337 | #endif |
1328 | if ( mode == 1 ) { // phone | 1338 | if ( mode == 1 ) { // phone |
1329 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1339 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1330 | mSyncManager->mPhoneDevice, | 1340 | mSyncManager->mPhoneDevice, |
1331 | mSyncManager->mPhoneConnection, | 1341 | mSyncManager->mPhoneConnection, |
1332 | mSyncManager->mPhoneModel); | 1342 | mSyncManager->mPhoneModel); |
1333 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1343 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1334 | 1344 | ||
1335 | } else { | 1345 | } else { |
1336 | emit tempDisableBR(false); | 1346 | emit tempDisableBR(false); |
1337 | return; | 1347 | return; |
1338 | } | 1348 | } |
1339 | if ( loadSuccess ) { | 1349 | if ( loadSuccess ) { |
1340 | getEventViewerDialog()->setSyncMode( true ); | 1350 | getEventViewerDialog()->setSyncMode( true ); |
1341 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1351 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1342 | getEventViewerDialog()->setSyncMode( false ); | 1352 | getEventViewerDialog()->setSyncMode( false ); |
1343 | qApp->processEvents(); | 1353 | qApp->processEvents(); |
1344 | if ( syncOK ) { | 1354 | if ( syncOK ) { |
1345 | if ( mSyncManager->mWriteBackFile ) | 1355 | if ( mSyncManager->mWriteBackFile ) |
1346 | { | 1356 | { |
1347 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1357 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1348 | Incidence* inc = iL.first(); | 1358 | Incidence* inc = iL.first(); |
1349 | if ( phoneFormat ) { | 1359 | if ( phoneFormat ) { |
1350 | while ( inc ) { | 1360 | while ( inc ) { |
1351 | inc->removeID(mCurrentSyncDevice); | 1361 | inc->removeID(mCurrentSyncDevice); |
1352 | inc = iL.next(); | 1362 | inc = iL.next(); |
1353 | } | 1363 | } |
1354 | } | 1364 | } |
1355 | #ifndef DESKTOP_VERSION | 1365 | #ifndef DESKTOP_VERSION |
1356 | if ( sharpFormat ) | 1366 | if ( sharpFormat ) |
1357 | sharpFormat->save(calendar); | 1367 | sharpFormat->save(calendar); |
1358 | #endif | 1368 | #endif |
1359 | if ( phoneFormat ) | 1369 | if ( phoneFormat ) |
1360 | phoneFormat->save(calendar); | 1370 | phoneFormat->save(calendar); |
1361 | iL = calendar->rawIncidences(); | 1371 | iL = calendar->rawIncidences(); |
1362 | inc = iL.first(); | 1372 | inc = iL.first(); |
1363 | Incidence* loc; | 1373 | Incidence* loc; |
1364 | while ( inc ) { | 1374 | while ( inc ) { |
1365 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1375 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1366 | loc = mCalendar->incidence(inc->uid() ); | 1376 | loc = mCalendar->incidence(inc->uid() ); |
1367 | if ( loc ) { | 1377 | if ( loc ) { |
1368 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1378 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1369 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1379 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1370 | } | 1380 | } |
1371 | } | 1381 | } |
1372 | inc = iL.next(); | 1382 | inc = iL.next(); |
1373 | } | 1383 | } |
1374 | Incidence* lse = getLastSyncEvent(); | 1384 | Incidence* lse = getLastSyncEvent(); |
1375 | if ( lse ) { | 1385 | if ( lse ) { |
1376 | lse->setReadOnly( false ); | 1386 | lse->setReadOnly( false ); |
1377 | lse->setDescription( "" ); | 1387 | lse->setDescription( "" ); |
1378 | lse->setReadOnly( true ); | 1388 | lse->setReadOnly( true ); |
1379 | } | 1389 | } |
1380 | } | 1390 | } |
1381 | } else { | 1391 | } else { |
1382 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 1392 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
1383 | } | 1393 | } |
1384 | setModified( true ); | 1394 | setModified( true ); |
1385 | } else { | 1395 | } else { |
1386 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1396 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1387 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1397 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1388 | question, i18n("Ok")) ; | 1398 | question, i18n("Ok")) ; |
1389 | 1399 | ||
1390 | } | 1400 | } |
1391 | delete calendar; | 1401 | delete calendar; |
1392 | updateView(); | 1402 | updateView(); |
1393 | emit tempDisableBR(false); | 1403 | emit tempDisableBR(false); |
1394 | return ;//syncOK; | 1404 | return ;//syncOK; |
1395 | 1405 | ||
1396 | } | 1406 | } |
1397 | 1407 | ||
1398 | bool CalendarView::importBday() | 1408 | bool CalendarView::importBday() |
1399 | { | 1409 | { |
1400 | #ifndef KORG_NOKABC | 1410 | #ifndef KORG_NOKABC |
1401 | 1411 | ||
1402 | #ifdef DESKTOP_VERSION | 1412 | #ifdef DESKTOP_VERSION |
1403 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1413 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1404 | KABC::AddressBook::Iterator it; | 1414 | KABC::AddressBook::Iterator it; |
1405 | int count = 0; | 1415 | int count = 0; |
1406 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1416 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1407 | ++count; | 1417 | ++count; |
1408 | } | 1418 | } |
1409 | QProgressBar bar(count,0 ); | 1419 | QProgressBar bar(count,0 ); |
1410 | int w = 300; | 1420 | int w = 300; |
1411 | if ( QApplication::desktop()->width() < 320 ) | 1421 | if ( QApplication::desktop()->width() < 320 ) |
1412 | w = 220; | 1422 | w = 220; |
1413 | int h = bar.sizeHint().height() ; | 1423 | int h = bar.sizeHint().height() ; |
1414 | int dw = QApplication::desktop()->width(); | 1424 | int dw = QApplication::desktop()->width(); |
1415 | int dh = QApplication::desktop()->height(); | 1425 | int dh = QApplication::desktop()->height(); |
1416 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1426 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1417 | bar.show(); | 1427 | bar.show(); |
1418 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1428 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1419 | qApp->processEvents(); | 1429 | qApp->processEvents(); |
1420 | count = 0; | 1430 | count = 0; |
1421 | int addCount = 0; | 1431 | int addCount = 0; |
1422 | KCal::Attendee* a = 0; | 1432 | KCal::Attendee* a = 0; |
1423 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1433 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1424 | if ( ! bar.isVisible() ) | 1434 | if ( ! bar.isVisible() ) |
1425 | return false; | 1435 | return false; |
1426 | bar.setProgress( count++ ); | 1436 | bar.setProgress( count++ ); |
1427 | qApp->processEvents(); | 1437 | qApp->processEvents(); |
1428 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1438 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1429 | if ( (*it).birthday().date().isValid() ){ | 1439 | if ( (*it).birthday().date().isValid() ){ |
1430 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1440 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1431 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 1441 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1432 | ++addCount; | 1442 | ++addCount; |
1433 | } | 1443 | } |
1434 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1444 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1435 | if ( anni.isValid() ){ | 1445 | if ( anni.isValid() ){ |
1436 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1446 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1437 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 1447 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1438 | ++addCount; | 1448 | ++addCount; |
1439 | } | 1449 | } |
1440 | } | 1450 | } |
1441 | updateView(); | 1451 | updateView(); |
1442 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1452 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1443 | #else //DESKTOP_VERSION | 1453 | #else //DESKTOP_VERSION |
1444 | 1454 | ||
1445 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 1455 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
1446 | // the result should now arrive through method insertBirthdays | 1456 | // the result should now arrive through method insertBirthdays |
1447 | 1457 | ||
1448 | #endif //DESKTOP_VERSION | 1458 | #endif //DESKTOP_VERSION |
1449 | 1459 | ||
1450 | #endif //KORG_NOKABC | 1460 | #endif //KORG_NOKABC |
1451 | 1461 | ||
1452 | 1462 | ||
1453 | return true; | 1463 | return true; |
1454 | } | 1464 | } |
1455 | 1465 | ||
1456 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 1466 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
1457 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 1467 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
1458 | const QStringList& anniversaryList, const QStringList& realNameList, | 1468 | const QStringList& anniversaryList, const QStringList& realNameList, |
1459 | const QStringList& emailList, const QStringList& assembledNameList, | 1469 | const QStringList& emailList, const QStringList& assembledNameList, |
1460 | const QStringList& uidList) | 1470 | const QStringList& uidList) |
1461 | { | 1471 | { |
1462 | //qDebug("KO::CalendarView::insertBirthdays"); | 1472 | //qDebug("KO::CalendarView::insertBirthdays"); |
1463 | if (uid == this->name()) | 1473 | if (uid == this->name()) |
1464 | { | 1474 | { |
1465 | int count = birthdayList.count(); | 1475 | int count = birthdayList.count(); |
1466 | int addCount = 0; | 1476 | int addCount = 0; |
1467 | KCal::Attendee* a = 0; | 1477 | KCal::Attendee* a = 0; |
1468 | 1478 | ||
1469 | //qDebug("CalView 1 %i", count); | 1479 | //qDebug("CalView 1 %i", count); |
1470 | 1480 | ||
1471 | QProgressBar bar(count,0 ); | 1481 | QProgressBar bar(count,0 ); |
1472 | int w = 300; | 1482 | int w = 300; |
1473 | if ( QApplication::desktop()->width() < 320 ) | 1483 | if ( QApplication::desktop()->width() < 320 ) |
1474 | w = 220; | 1484 | w = 220; |
1475 | int h = bar.sizeHint().height() ; | 1485 | int h = bar.sizeHint().height() ; |
1476 | int dw = QApplication::desktop()->width(); | 1486 | int dw = QApplication::desktop()->width(); |
1477 | int dh = QApplication::desktop()->height(); | 1487 | int dh = QApplication::desktop()->height(); |
1478 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1488 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1479 | bar.show(); | 1489 | bar.show(); |
1480 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 1490 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
1481 | qApp->processEvents(); | 1491 | qApp->processEvents(); |
1482 | 1492 | ||
1483 | QDate birthday; | 1493 | QDate birthday; |
1484 | QDate anniversary; | 1494 | QDate anniversary; |
1485 | QString realName; | 1495 | QString realName; |
1486 | QString email; | 1496 | QString email; |
1487 | QString assembledName; | 1497 | QString assembledName; |
1488 | QString uid; | 1498 | QString uid; |
1489 | bool ok = true; | 1499 | bool ok = true; |
1490 | for ( int i = 0; i < count; i++) | 1500 | for ( int i = 0; i < count; i++) |
1491 | { | 1501 | { |
1492 | if ( ! bar.isVisible() ) | 1502 | if ( ! bar.isVisible() ) |
1493 | return; | 1503 | return; |
1494 | bar.setProgress( i ); | 1504 | bar.setProgress( i ); |
1495 | qApp->processEvents(); | 1505 | qApp->processEvents(); |
1496 | 1506 | ||
1497 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 1507 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
1498 | if (!ok) { | 1508 | if (!ok) { |
1499 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 1509 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
1500 | } | 1510 | } |
1501 | 1511 | ||
1502 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 1512 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
1503 | if (!ok) { | 1513 | if (!ok) { |
1504 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 1514 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
1505 | } | 1515 | } |
1506 | realName = realNameList[i]; | 1516 | realName = realNameList[i]; |
1507 | email = emailList[i]; | 1517 | email = emailList[i]; |
1508 | assembledName = assembledNameList[i]; | 1518 | assembledName = assembledNameList[i]; |
1509 | uid = uidList[i]; | 1519 | uid = uidList[i]; |
1510 | //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); | 1520 | //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); |
1511 | 1521 | ||
1512 | if ( birthday.isValid() ){ | 1522 | if ( birthday.isValid() ){ |
1513 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1523 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1514 | KCal::Attendee::ReqParticipant,uid) ; | 1524 | KCal::Attendee::ReqParticipant,uid) ; |
1515 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 1525 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
1516 | ++addCount; | 1526 | ++addCount; |
1517 | } | 1527 | } |
1518 | 1528 | ||
1519 | if ( anniversary.isValid() ){ | 1529 | if ( anniversary.isValid() ){ |
1520 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1530 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1521 | KCal::Attendee::ReqParticipant,uid) ; | 1531 | KCal::Attendee::ReqParticipant,uid) ; |
1522 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 1532 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
1523 | ++addCount; | 1533 | ++addCount; |
1524 | } | 1534 | } |
1525 | } | 1535 | } |
1526 | 1536 | ||
1527 | updateView(); | 1537 | updateView(); |
1528 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1538 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1529 | 1539 | ||
1530 | } | 1540 | } |
1531 | 1541 | ||
1532 | } | 1542 | } |
1533 | 1543 | ||
1534 | 1544 | ||
1535 | 1545 | ||
1536 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1546 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1537 | { | 1547 | { |
1538 | //qDebug("addAnni "); | 1548 | //qDebug("addAnni "); |
1539 | Event * ev = new Event(); | 1549 | Event * ev = new Event(); |
1540 | ev->setOrganizer(KOPrefs::instance()->email()); | 1550 | ev->setOrganizer(KOPrefs::instance()->email()); |
1541 | if ( a ) { | 1551 | if ( a ) { |
1542 | ev->addAttendee( a ); | 1552 | ev->addAttendee( a ); |
1543 | } | 1553 | } |
1544 | QString kind; | 1554 | QString kind; |
1545 | if ( birthday ) { | 1555 | if ( birthday ) { |
1546 | kind = i18n( "Birthday" ); | 1556 | kind = i18n( "Birthday" ); |
1547 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); | 1557 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); |
1548 | } | 1558 | } |
1549 | else { | 1559 | else { |
1550 | kind = i18n( "Anniversary" ); | 1560 | kind = i18n( "Anniversary" ); |
1551 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); | 1561 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); |
1552 | } | 1562 | } |
1553 | ev->setCategories( kind ); | 1563 | ev->setCategories( kind ); |
1554 | ev->setDtStart( QDateTime(date) ); | 1564 | ev->setDtStart( QDateTime(date) ); |
1555 | ev->setDtEnd( QDateTime(date) ); | 1565 | ev->setDtEnd( QDateTime(date) ); |
1556 | ev->setFloats( true ); | 1566 | ev->setFloats( true ); |
1557 | Recurrence * rec = ev->recurrence(); | 1567 | Recurrence * rec = ev->recurrence(); |
1558 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1568 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1559 | rec->addYearlyNum( date.month() ); | 1569 | rec->addYearlyNum( date.month() ); |
1560 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1570 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1561 | delete ev; | 1571 | delete ev; |
1562 | return false; | 1572 | return false; |
1563 | } | 1573 | } |
1564 | return true; | 1574 | return true; |
1565 | 1575 | ||
1566 | } | 1576 | } |
1567 | bool CalendarView::importQtopia( const QString &categories, | 1577 | bool CalendarView::importQtopia( const QString &categories, |
1568 | const QString &datebook, | 1578 | const QString &datebook, |
1569 | const QString &todolist ) | 1579 | const QString &todolist ) |
1570 | { | 1580 | { |
1571 | 1581 | ||
1572 | QtopiaFormat qtopiaFormat; | 1582 | QtopiaFormat qtopiaFormat; |
1573 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1583 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1574 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 1584 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
1575 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 1585 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
1576 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 1586 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
1577 | 1587 | ||
1578 | updateView(); | 1588 | updateView(); |
1579 | return true; | 1589 | return true; |
1580 | 1590 | ||
1581 | #if 0 | 1591 | #if 0 |
1582 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 1592 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
1583 | mCurrentSyncDevice = "qtopia-XML"; | 1593 | mCurrentSyncDevice = "qtopia-XML"; |
1584 | if ( mSyncManager->mAskForPreferences ) | 1594 | if ( mSyncManager->mAskForPreferences ) |
1585 | edit_sync_options(); | 1595 | edit_sync_options(); |
1586 | qApp->processEvents(); | 1596 | qApp->processEvents(); |
1587 | CalendarLocal* calendar = new CalendarLocal(); | 1597 | CalendarLocal* calendar = new CalendarLocal(); |
1588 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1598 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1589 | bool syncOK = false; | 1599 | bool syncOK = false; |
1590 | QtopiaFormat qtopiaFormat; | 1600 | QtopiaFormat qtopiaFormat; |
1591 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1601 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1592 | bool loadOk = true; | 1602 | bool loadOk = true; |
1593 | if ( !categories.isEmpty() ) | 1603 | if ( !categories.isEmpty() ) |
1594 | loadOk = qtopiaFormat.load( calendar, categories ); | 1604 | loadOk = qtopiaFormat.load( calendar, categories ); |
1595 | if ( loadOk && !datebook.isEmpty() ) | 1605 | if ( loadOk && !datebook.isEmpty() ) |
1596 | loadOk = qtopiaFormat.load( calendar, datebook ); | 1606 | loadOk = qtopiaFormat.load( calendar, datebook ); |
1597 | if ( loadOk && !todolist.isEmpty() ) | 1607 | if ( loadOk && !todolist.isEmpty() ) |
1598 | loadOk = qtopiaFormat.load( calendar, todolist ); | 1608 | loadOk = qtopiaFormat.load( calendar, todolist ); |
1599 | 1609 | ||
1600 | if ( loadOk ) { | 1610 | if ( loadOk ) { |
1601 | getEventViewerDialog()->setSyncMode( true ); | 1611 | getEventViewerDialog()->setSyncMode( true ); |
1602 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1612 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1603 | getEventViewerDialog()->setSyncMode( false ); | 1613 | getEventViewerDialog()->setSyncMode( false ); |
1604 | qApp->processEvents(); | 1614 | qApp->processEvents(); |
1605 | if ( syncOK ) { | 1615 | if ( syncOK ) { |
1606 | if ( mSyncManager->mWriteBackFile ) | 1616 | if ( mSyncManager->mWriteBackFile ) |
1607 | { | 1617 | { |
1608 | // write back XML file | 1618 | // write back XML file |
1609 | 1619 | ||
1610 | } | 1620 | } |
1611 | setModified( true ); | 1621 | setModified( true ); |
1612 | } | 1622 | } |
1613 | } else { | 1623 | } else { |
1614 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 1624 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
1615 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 1625 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
1616 | question, i18n("Ok")) ; | 1626 | question, i18n("Ok")) ; |
1617 | } | 1627 | } |
1618 | delete calendar; | 1628 | delete calendar; |
1619 | updateView(); | 1629 | updateView(); |
1620 | return syncOK; | 1630 | return syncOK; |
1621 | 1631 | ||
1622 | 1632 | ||
1623 | #endif | 1633 | #endif |
1624 | 1634 | ||
1625 | } | 1635 | } |
1626 | 1636 | ||
1627 | void CalendarView::setSyncEventsReadOnly() | 1637 | void CalendarView::setSyncEventsReadOnly() |
1628 | { | 1638 | { |
1629 | Event * ev; | 1639 | Event * ev; |
1630 | QPtrList<Event> eL = mCalendar->rawEvents(); | 1640 | QPtrList<Event> eL = mCalendar->rawEvents(); |
1631 | ev = eL.first(); | 1641 | ev = eL.first(); |
1632 | while ( ev ) { | 1642 | while ( ev ) { |
1633 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) | 1643 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) |
1634 | ev->setReadOnly( true ); | 1644 | ev->setReadOnly( true ); |
1635 | ev = eL.next(); | 1645 | ev = eL.next(); |
1636 | } | 1646 | } |
1637 | } | 1647 | } |
1638 | bool CalendarView::openCalendar(QString filename, bool merge) | 1648 | bool CalendarView::openCalendar(QString filename, bool merge) |
1639 | { | 1649 | { |
1640 | 1650 | ||
1641 | if (filename.isEmpty()) { | 1651 | if (filename.isEmpty()) { |
1642 | return false; | 1652 | return false; |
1643 | } | 1653 | } |
1644 | 1654 | ||
1645 | if (!QFile::exists(filename)) { | 1655 | if (!QFile::exists(filename)) { |
1646 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 1656 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
1647 | return false; | 1657 | return false; |
1648 | } | 1658 | } |
1649 | 1659 | ||
1650 | globalFlagBlockAgenda = 1; | 1660 | globalFlagBlockAgenda = 1; |
1651 | if (!merge) mCalendar->close(); | 1661 | if (!merge) mCalendar->close(); |
1652 | 1662 | ||
1653 | mStorage->setFileName( filename ); | 1663 | mStorage->setFileName( filename ); |
1654 | 1664 | ||
1655 | if ( mStorage->load() ) { | 1665 | if ( mStorage->load() ) { |
1656 | if ( merge ) ;//setModified( true ); | 1666 | if ( merge ) ;//setModified( true ); |
1657 | else { | 1667 | else { |
1658 | //setModified( true ); | 1668 | //setModified( true ); |
1659 | mViewManager->setDocumentId( filename ); | 1669 | mViewManager->setDocumentId( filename ); |
1660 | mDialogManager->setDocumentId( filename ); | 1670 | mDialogManager->setDocumentId( filename ); |
1661 | mTodoList->setDocumentId( filename ); | 1671 | mTodoList->setDocumentId( filename ); |
1662 | } | 1672 | } |
1663 | globalFlagBlockAgenda = 2; | 1673 | globalFlagBlockAgenda = 2; |
1664 | // if ( getLastSyncEvent() ) | 1674 | // if ( getLastSyncEvent() ) |
1665 | // getLastSyncEvent()->setReadOnly( true ); | 1675 | // getLastSyncEvent()->setReadOnly( true ); |
1666 | mCalendar->reInitAlarmSettings(); | 1676 | mCalendar->reInitAlarmSettings(); |
1667 | setSyncEventsReadOnly(); | 1677 | setSyncEventsReadOnly(); |
1668 | updateUnmanagedViews(); | 1678 | updateUnmanagedViews(); |
1669 | updateView(); | 1679 | updateView(); |
1670 | if ( filename != MainWindow::defaultFileName() ) { | 1680 | if ( filename != MainWindow::defaultFileName() ) { |
1671 | saveCalendar( MainWindow::defaultFileName() ); | 1681 | saveCalendar( MainWindow::defaultFileName() ); |
1672 | } else { | 1682 | } else { |
1673 | QFileInfo finf ( MainWindow::defaultFileName()); | 1683 | QFileInfo finf ( MainWindow::defaultFileName()); |
1674 | if ( finf.exists() ) { | 1684 | if ( finf.exists() ) { |
1675 | setLoadedFileVersion( finf.lastModified () ); | 1685 | setLoadedFileVersion( finf.lastModified () ); |
1676 | } | 1686 | } |
1677 | } | 1687 | } |
1678 | return true; | 1688 | return true; |
1679 | } else { | 1689 | } else { |
1680 | // while failing to load, the calendar object could | 1690 | // while failing to load, the calendar object could |
1681 | // have become partially populated. Clear it out. | 1691 | // have become partially populated. Clear it out. |
1682 | if ( !merge ) { | 1692 | if ( !merge ) { |
1683 | mCalendar->close(); | 1693 | mCalendar->close(); |
1684 | mViewManager->setDocumentId( filename ); | 1694 | mViewManager->setDocumentId( filename ); |
1685 | mDialogManager->setDocumentId( filename ); | 1695 | mDialogManager->setDocumentId( filename ); |
1686 | mTodoList->setDocumentId( filename ); | 1696 | mTodoList->setDocumentId( filename ); |
1687 | } | 1697 | } |
1688 | 1698 | ||
1689 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 1699 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
1690 | 1700 | ||
1691 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 1701 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
1692 | globalFlagBlockAgenda = 2; | 1702 | globalFlagBlockAgenda = 2; |
1693 | mCalendar->reInitAlarmSettings(); | 1703 | mCalendar->reInitAlarmSettings(); |
1694 | setSyncEventsReadOnly(); | 1704 | setSyncEventsReadOnly(); |
1695 | updateUnmanagedViews(); | 1705 | updateUnmanagedViews(); |
1696 | updateView(); | 1706 | updateView(); |
1697 | } | 1707 | } |
1698 | return false; | 1708 | return false; |
1699 | } | 1709 | } |
1700 | void CalendarView::showOpenError() | 1710 | void CalendarView::showOpenError() |
1701 | { | 1711 | { |
1702 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 1712 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
1703 | } | 1713 | } |
1704 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 1714 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
1705 | { | 1715 | { |
1706 | loadedFileVersion = dt; | 1716 | loadedFileVersion = dt; |
1707 | } | 1717 | } |
1708 | bool CalendarView::checkFileChanged(QString fn) | 1718 | bool CalendarView::checkFileChanged(QString fn) |
1709 | { | 1719 | { |
1710 | QFileInfo finf ( fn ); | 1720 | QFileInfo finf ( fn ); |
1711 | if ( !finf.exists() ) | 1721 | if ( !finf.exists() ) |
1712 | return true; | 1722 | return true; |
1713 | QDateTime dt = finf.lastModified (); | 1723 | QDateTime dt = finf.lastModified (); |
1714 | if ( dt <= loadedFileVersion ) | 1724 | if ( dt <= loadedFileVersion ) |
1715 | return false; | 1725 | return false; |
1716 | return true; | 1726 | return true; |
1717 | 1727 | ||
1718 | } | 1728 | } |
1719 | void CalendarView::watchSavedFile() | 1729 | void CalendarView::watchSavedFile() |
1720 | { | 1730 | { |
1721 | QFileInfo finf ( MainWindow::defaultFileName()); | 1731 | QFileInfo finf ( MainWindow::defaultFileName()); |
1722 | if ( !finf.exists() ) | 1732 | if ( !finf.exists() ) |
1723 | return; | 1733 | return; |
1724 | QDateTime dt = finf.lastModified (); | 1734 | QDateTime dt = finf.lastModified (); |
1725 | if ( dt < loadedFileVersion ) { | 1735 | if ( dt < loadedFileVersion ) { |
1726 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 1736 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
1727 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 1737 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
1728 | return; | 1738 | return; |
1729 | } | 1739 | } |
1730 | loadedFileVersion = dt; | 1740 | loadedFileVersion = dt; |
1731 | } | 1741 | } |
1732 | 1742 | ||
1733 | bool CalendarView::checkFileVersion(QString fn) | 1743 | bool CalendarView::checkFileVersion(QString fn) |
1734 | { | 1744 | { |
1735 | QFileInfo finf ( fn ); | 1745 | QFileInfo finf ( fn ); |
1736 | if ( !finf.exists() ) | 1746 | if ( !finf.exists() ) |
1737 | return true; | 1747 | return true; |
1738 | QDateTime dt = finf.lastModified (); | 1748 | QDateTime dt = finf.lastModified (); |
1739 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); | 1749 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); |
1740 | //qDebug("file on disk version %s",dt.toString().latin1()); | 1750 | //qDebug("file on disk version %s",dt.toString().latin1()); |
1741 | if ( dt <= loadedFileVersion ) | 1751 | if ( dt <= loadedFileVersion ) |
1742 | return true; | 1752 | return true; |
1743 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , | 1753 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , |
1744 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 1754 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
1745 | i18n("Sync+save")); | 1755 | i18n("Sync+save")); |
1746 | 1756 | ||
1747 | if ( km == KMessageBox::Cancel ) | 1757 | if ( km == KMessageBox::Cancel ) |
1748 | return false; | 1758 | return false; |
1749 | if ( km == KMessageBox::Yes ) | 1759 | if ( km == KMessageBox::Yes ) |
1750 | return true; | 1760 | return true; |
1751 | 1761 | ||
1752 | setSyncDevice("deleteaftersync" ); | 1762 | setSyncDevice("deleteaftersync" ); |
1753 | mSyncManager->mAskForPreferences = true; | 1763 | mSyncManager->mAskForPreferences = true; |
1754 | mSyncManager->mSyncAlgoPrefs = 3; | 1764 | mSyncManager->mSyncAlgoPrefs = 3; |
1755 | mSyncManager->mWriteBackFile = false; | 1765 | mSyncManager->mWriteBackFile = false; |
1756 | mSyncManager->mWriteBackExistingOnly = false; | 1766 | mSyncManager->mWriteBackExistingOnly = false; |
1757 | mSyncManager->mShowSyncSummary = false; | 1767 | mSyncManager->mShowSyncSummary = false; |
1758 | syncCalendar( fn, 3 ); | 1768 | syncCalendar( fn, 3 ); |
1759 | Event * e = getLastSyncEvent(); | 1769 | Event * e = getLastSyncEvent(); |
1760 | mCalendar->deleteEvent ( e ); | 1770 | mCalendar->deleteEvent ( e ); |
1761 | updateView(); | 1771 | updateView(); |
1762 | return true; | 1772 | return true; |
1763 | } | 1773 | } |
1764 | 1774 | ||
1765 | bool CalendarView::saveCalendar( QString filename ) | 1775 | bool CalendarView::saveCalendar( QString filename ) |
1766 | { | 1776 | { |
1767 | 1777 | ||
1768 | // Store back all unsaved data into calendar object | 1778 | // Store back all unsaved data into calendar object |
1769 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 1779 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
1770 | if ( mViewManager->currentView() ) | 1780 | if ( mViewManager->currentView() ) |
1771 | mViewManager->currentView()->flushView(); | 1781 | mViewManager->currentView()->flushView(); |
1772 | 1782 | ||
1773 | 1783 | ||
1774 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 1784 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
1775 | mStorage->setSaveFormat( new ICalFormat() ); | 1785 | mStorage->setSaveFormat( new ICalFormat() ); |
1776 | mStorage->setFileName( filename ); | 1786 | mStorage->setFileName( filename ); |
1777 | bool success; | 1787 | bool success; |
1778 | success = mStorage->save(); | 1788 | success = mStorage->save(); |
1779 | if ( !success ) { | 1789 | if ( !success ) { |
1780 | return false; | 1790 | return false; |
1781 | } | 1791 | } |
1782 | if ( filename == MainWindow::defaultFileName() ) { | 1792 | if ( filename == MainWindow::defaultFileName() ) { |
1783 | setLoadedFileVersion( lfv ); | 1793 | setLoadedFileVersion( lfv ); |
1784 | watchSavedFile(); | 1794 | watchSavedFile(); |
1785 | } | 1795 | } |
1786 | return true; | 1796 | return true; |
1787 | } | 1797 | } |
1788 | 1798 | ||
1789 | void CalendarView::closeCalendar() | 1799 | void CalendarView::closeCalendar() |
1790 | { | 1800 | { |
1791 | 1801 | ||
1792 | // child windows no longer valid | 1802 | // child windows no longer valid |
1793 | emit closingDown(); | 1803 | emit closingDown(); |
1794 | 1804 | ||
1795 | mCalendar->close(); | 1805 | mCalendar->close(); |
1796 | setModified(false); | 1806 | setModified(false); |
1797 | updateView(); | 1807 | updateView(); |
1798 | } | 1808 | } |
1799 | 1809 | ||
1800 | void CalendarView::archiveCalendar() | 1810 | void CalendarView::archiveCalendar() |
1801 | { | 1811 | { |
1802 | mDialogManager->showArchiveDialog(); | 1812 | mDialogManager->showArchiveDialog(); |
1803 | } | 1813 | } |
1804 | 1814 | ||
1805 | 1815 | ||
1806 | void CalendarView::readSettings() | 1816 | void CalendarView::readSettings() |
1807 | { | 1817 | { |
1808 | 1818 | ||
1809 | 1819 | ||
1810 | // mViewManager->showAgendaView(); | 1820 | // mViewManager->showAgendaView(); |
1811 | QString str; | 1821 | QString str; |
1812 | //qDebug("CalendarView::readSettings() "); | 1822 | //qDebug("CalendarView::readSettings() "); |
1813 | // read settings from the KConfig, supplying reasonable | 1823 | // read settings from the KConfig, supplying reasonable |
1814 | // defaults where none are to be found | 1824 | // defaults where none are to be found |
1815 | KConfig *config = KOGlobals::config(); | 1825 | KConfig *config = KOGlobals::config(); |
1816 | #ifndef KORG_NOSPLITTER | 1826 | #ifndef KORG_NOSPLITTER |
1817 | config->setGroup("KOrganizer Geometry"); | 1827 | config->setGroup("KOrganizer Geometry"); |
1818 | 1828 | ||
1819 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 1829 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
1820 | if (sizes.count() != 2) { | 1830 | if (sizes.count() != 2) { |
1821 | sizes << mDateNavigator->minimumSizeHint().width(); | 1831 | sizes << mDateNavigator->minimumSizeHint().width(); |
1822 | sizes << 300; | 1832 | sizes << 300; |
1823 | } | 1833 | } |
1824 | mPanner->setSizes(sizes); | 1834 | mPanner->setSizes(sizes); |
1825 | 1835 | ||
1826 | sizes = config->readIntListEntry("Separator2"); | 1836 | sizes = config->readIntListEntry("Separator2"); |
1827 | if ( ( mResourceView && sizes.count() == 4 ) || | 1837 | if ( ( mResourceView && sizes.count() == 4 ) || |
1828 | ( !mResourceView && sizes.count() == 3 ) ) { | 1838 | ( !mResourceView && sizes.count() == 3 ) ) { |
1829 | mLeftSplitter->setSizes(sizes); | 1839 | mLeftSplitter->setSizes(sizes); |
1830 | } | 1840 | } |
1831 | #endif | 1841 | #endif |
1832 | globalFlagBlockAgenda = 1; | 1842 | globalFlagBlockAgenda = 1; |
1833 | mViewManager->showAgendaView(); | 1843 | mViewManager->showAgendaView(); |
1834 | //mViewManager->readSettings( config ); | 1844 | //mViewManager->readSettings( config ); |
1835 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 1845 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
1836 | readFilterSettings(config); | 1846 | readFilterSettings(config); |
1837 | 1847 | ||
1838 | #ifdef DESKTOP_VERSION | 1848 | #ifdef DESKTOP_VERSION |
1839 | config->setGroup("WidgetLayout"); | 1849 | config->setGroup("WidgetLayout"); |
1840 | QStringList list; | 1850 | QStringList list; |
1841 | list = config->readListEntry("MainLayout"); | 1851 | list = config->readListEntry("MainLayout"); |
1842 | int x,y,w,h; | 1852 | int x,y,w,h; |
1843 | if ( ! list.isEmpty() ) { | 1853 | if ( ! list.isEmpty() ) { |
1844 | x = list[0].toInt(); | 1854 | x = list[0].toInt(); |
1845 | y = list[1].toInt(); | 1855 | y = list[1].toInt(); |
1846 | w = list[2].toInt(); | 1856 | w = list[2].toInt(); |
1847 | h = list[3].toInt(); | 1857 | h = list[3].toInt(); |
1848 | KApplication::testCoords( &x,&y,&w,&h ); | 1858 | KApplication::testCoords( &x,&y,&w,&h ); |
1849 | topLevelWidget()->setGeometry(x,y,w,h); | 1859 | topLevelWidget()->setGeometry(x,y,w,h); |
1850 | 1860 | ||
1851 | } else { | 1861 | } else { |
1852 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 1862 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
1853 | } | 1863 | } |
1854 | list = config->readListEntry("EditEventLayout"); | 1864 | list = config->readListEntry("EditEventLayout"); |
1855 | if ( ! list.isEmpty() ) { | 1865 | if ( ! list.isEmpty() ) { |
1856 | x = list[0].toInt(); | 1866 | x = list[0].toInt(); |
1857 | y = list[1].toInt(); | 1867 | y = list[1].toInt(); |
1858 | w = list[2].toInt(); | 1868 | w = list[2].toInt(); |
1859 | h = list[3].toInt(); | 1869 | h = list[3].toInt(); |
1860 | KApplication::testCoords( &x,&y,&w,&h ); | 1870 | KApplication::testCoords( &x,&y,&w,&h ); |
1861 | mEventEditor->setGeometry(x,y,w,h); | 1871 | mEventEditor->setGeometry(x,y,w,h); |
1862 | 1872 | ||
1863 | } | 1873 | } |
1864 | list = config->readListEntry("EditTodoLayout"); | 1874 | list = config->readListEntry("EditTodoLayout"); |
1865 | if ( ! list.isEmpty() ) { | 1875 | if ( ! list.isEmpty() ) { |
1866 | x = list[0].toInt(); | 1876 | x = list[0].toInt(); |
1867 | y = list[1].toInt(); | 1877 | y = list[1].toInt(); |
1868 | w = list[2].toInt(); | 1878 | w = list[2].toInt(); |
1869 | h = list[3].toInt(); | 1879 | h = list[3].toInt(); |
1870 | KApplication::testCoords( &x,&y,&w,&h ); | 1880 | KApplication::testCoords( &x,&y,&w,&h ); |
1871 | mTodoEditor->setGeometry(x,y,w,h); | 1881 | mTodoEditor->setGeometry(x,y,w,h); |
1872 | 1882 | ||
1873 | } | 1883 | } |
1874 | list = config->readListEntry("ViewerLayout"); | 1884 | list = config->readListEntry("ViewerLayout"); |
1875 | if ( ! list.isEmpty() ) { | 1885 | if ( ! list.isEmpty() ) { |
1876 | x = list[0].toInt(); | 1886 | x = list[0].toInt(); |
1877 | y = list[1].toInt(); | 1887 | y = list[1].toInt(); |
1878 | w = list[2].toInt(); | 1888 | w = list[2].toInt(); |
1879 | h = list[3].toInt(); | 1889 | h = list[3].toInt(); |
1880 | KApplication::testCoords( &x,&y,&w,&h ); | 1890 | KApplication::testCoords( &x,&y,&w,&h ); |
1881 | getEventViewerDialog()->setGeometry(x,y,w,h); | 1891 | getEventViewerDialog()->setGeometry(x,y,w,h); |
1882 | } | 1892 | } |
1883 | #endif | 1893 | #endif |
1884 | config->setGroup( "Views" ); | 1894 | config->setGroup( "Views" ); |
1885 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 1895 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
1886 | 1896 | ||
1887 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); | 1897 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); |
1888 | 1898 | ||
1889 | int resetval = 0; | 1899 | int resetval = 0; |
1890 | int maxVal = 0; | 1900 | int maxVal = 0; |
1891 | if (sizes.count() != 3) { | 1901 | if (sizes.count() != 3) { |
1892 | if ( KOPrefs::instance()->mVerticalScreen ) { | 1902 | if ( KOPrefs::instance()->mVerticalScreen ) { |
1893 | resetval = mDateNavigator->sizeHint().width()+2; | 1903 | resetval = mDateNavigator->sizeHint().width()+2; |
1894 | } else { | 1904 | } else { |
1895 | resetval = mDateNavigator->sizeHint().height()+2; | 1905 | resetval = mDateNavigator->sizeHint().height()+2; |
1896 | } | 1906 | } |
1897 | } | 1907 | } |
1898 | if ( resetval ) { | 1908 | if ( resetval ) { |
1899 | sizes.clear(); | 1909 | sizes.clear(); |
1900 | if ( KOPrefs::instance()->mVerticalScreen ) { | 1910 | if ( KOPrefs::instance()->mVerticalScreen ) { |
1901 | maxVal = QApplication::desktop()->width() -10; | 1911 | maxVal = QApplication::desktop()->width() -10; |
1902 | } else { | 1912 | } else { |
1903 | maxVal = QApplication::desktop()->height()-10; | 1913 | maxVal = QApplication::desktop()->height()-10; |
1904 | } | 1914 | } |
1905 | sizes << resetval; | 1915 | sizes << resetval; |
1906 | if ( maxVal < resetval + resetval) | 1916 | if ( maxVal < resetval + resetval) |
1907 | resetval = maxVal - resetval; | 1917 | resetval = maxVal - resetval; |
1908 | sizes << resetval; | 1918 | sizes << resetval; |
1909 | sizes << 100; | 1919 | sizes << 100; |
1910 | } | 1920 | } |
1911 | mLeftFrame->setSizes(sizes); | 1921 | mLeftFrame->setSizes(sizes); |
1912 | sizes = config->readIntListEntry("Main Splitter Frame"); | 1922 | sizes = config->readIntListEntry("Main Splitter Frame"); |
1913 | resetval = 0; | 1923 | resetval = 0; |
1914 | maxVal = 0; | 1924 | maxVal = 0; |
1915 | if (sizes.count() != 2) { | 1925 | if (sizes.count() != 2) { |
1916 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 1926 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
1917 | resetval = mDateNavigator->sizeHint().width()+2; | 1927 | resetval = mDateNavigator->sizeHint().width()+2; |
1918 | } else { | 1928 | } else { |
1919 | resetval = mDateNavigator->sizeHint().height()+2; | 1929 | resetval = mDateNavigator->sizeHint().height()+2; |
1920 | } | 1930 | } |
1921 | } | 1931 | } |
1922 | if ( resetval ) { | 1932 | if ( resetval ) { |
1923 | sizes.clear(); | 1933 | sizes.clear(); |
1924 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 1934 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
1925 | maxVal = QApplication::desktop()->width() -10; | 1935 | maxVal = QApplication::desktop()->width() -10; |
1926 | } else { | 1936 | } else { |
1927 | maxVal = QApplication::desktop()->height()-10; | 1937 | maxVal = QApplication::desktop()->height()-10; |
1928 | } | 1938 | } |
1929 | sizes << resetval; | 1939 | sizes << resetval; |
1930 | if ( maxVal < resetval + resetval) | 1940 | if ( maxVal < resetval + resetval) |
1931 | resetval = maxVal - resetval; | 1941 | resetval = maxVal - resetval; |
1932 | sizes << resetval; | 1942 | sizes << resetval; |
1933 | } | 1943 | } |
1934 | mMainFrame->setSizes(sizes); | 1944 | mMainFrame->setSizes(sizes); |
1935 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 1945 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
1936 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 1946 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
1937 | else mNavigator->selectDates( dateCount ); | 1947 | else mNavigator->selectDates( dateCount ); |
1938 | // mViewManager->readSettings( config ); | 1948 | // mViewManager->readSettings( config ); |
1939 | updateConfig(); | 1949 | updateConfig(); |
1940 | globalFlagBlockAgenda = 2; | 1950 | globalFlagBlockAgenda = 2; |
1941 | mViewManager->readSettings( config ); | 1951 | mViewManager->readSettings( config ); |
1942 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); | 1952 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); |
1943 | } | 1953 | } |
1944 | 1954 | ||
1945 | 1955 | ||
1946 | void CalendarView::writeSettings() | 1956 | void CalendarView::writeSettings() |
1947 | { | 1957 | { |
1948 | // kdDebug() << "CalendarView::writeSettings" << endl; | 1958 | // kdDebug() << "CalendarView::writeSettings" << endl; |
1949 | 1959 | ||
1950 | KConfig *config = KOGlobals::config(); | 1960 | KConfig *config = KOGlobals::config(); |
1951 | 1961 | ||
1952 | mViewManager->writeSettings( config ); | 1962 | mViewManager->writeSettings( config ); |
1953 | mTodoList->saveLayout(config,QString("Todo Layout")); | 1963 | mTodoList->saveLayout(config,QString("Todo Layout")); |
1954 | mDialogManager->writeSettings( config ); | 1964 | mDialogManager->writeSettings( config ); |
1955 | //KOPrefs::instance()->usrWriteConfig(); | 1965 | //KOPrefs::instance()->usrWriteConfig(); |
1956 | KOPrefs::instance()->writeConfig(); | 1966 | KOPrefs::instance()->writeConfig(); |
1957 | 1967 | ||
1958 | writeFilterSettings(config); | 1968 | writeFilterSettings(config); |
1959 | 1969 | ||
1960 | config->setGroup( "Views" ); | 1970 | config->setGroup( "Views" ); |
1961 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 1971 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
1962 | 1972 | ||
1963 | QValueList<int> listINT = mLeftFrame->sizes(); | 1973 | QValueList<int> listINT = mLeftFrame->sizes(); |
1964 | config->writeEntry("Left Splitter Frame",listINT); | 1974 | config->writeEntry("Left Splitter Frame",listINT); |
1965 | QValueList<int> listINT2 = mMainFrame->sizes(); | 1975 | QValueList<int> listINT2 = mMainFrame->sizes(); |
1966 | config->writeEntry("Main Splitter Frame",listINT2); | 1976 | config->writeEntry("Main Splitter Frame",listINT2); |
1967 | #ifdef DESKTOP_VERSION | 1977 | #ifdef DESKTOP_VERSION |
1968 | config->setGroup("WidgetLayout"); | 1978 | config->setGroup("WidgetLayout"); |
1969 | QStringList list ;//= config->readListEntry("MainLayout"); | 1979 | QStringList list ;//= config->readListEntry("MainLayout"); |
1970 | int x,y,w,h; | 1980 | int x,y,w,h; |
1971 | QWidget* wid; | 1981 | QWidget* wid; |
1972 | wid = topLevelWidget(); | 1982 | wid = topLevelWidget(); |
1973 | x = wid->geometry().x(); | 1983 | x = wid->geometry().x(); |
1974 | y = wid->geometry().y(); | 1984 | y = wid->geometry().y(); |
1975 | w = wid->width(); | 1985 | w = wid->width(); |
1976 | h = wid->height(); | 1986 | h = wid->height(); |
1977 | list.clear(); | 1987 | list.clear(); |
1978 | list << QString::number( x ); | 1988 | list << QString::number( x ); |
1979 | list << QString::number( y ); | 1989 | list << QString::number( y ); |
1980 | list << QString::number( w ); | 1990 | list << QString::number( w ); |
1981 | list << QString::number( h ); | 1991 | list << QString::number( h ); |
1982 | config->writeEntry("MainLayout",list ); | 1992 | config->writeEntry("MainLayout",list ); |
1983 | 1993 | ||
1984 | wid = mEventEditor; | 1994 | wid = mEventEditor; |
1985 | x = wid->geometry().x(); | 1995 | x = wid->geometry().x(); |
1986 | y = wid->geometry().y(); | 1996 | y = wid->geometry().y(); |
1987 | w = wid->width(); | 1997 | w = wid->width(); |
1988 | h = wid->height(); | 1998 | h = wid->height(); |
1989 | list.clear(); | 1999 | list.clear(); |
1990 | list << QString::number( x ); | 2000 | list << QString::number( x ); |
1991 | list << QString::number( y ); | 2001 | list << QString::number( y ); |
1992 | list << QString::number( w ); | 2002 | list << QString::number( w ); |
1993 | list << QString::number( h ); | 2003 | list << QString::number( h ); |
1994 | config->writeEntry("EditEventLayout",list ); | 2004 | config->writeEntry("EditEventLayout",list ); |
1995 | 2005 | ||
1996 | wid = mTodoEditor; | 2006 | wid = mTodoEditor; |
1997 | x = wid->geometry().x(); | 2007 | x = wid->geometry().x(); |
1998 | y = wid->geometry().y(); | 2008 | y = wid->geometry().y(); |
1999 | w = wid->width(); | 2009 | w = wid->width(); |
2000 | h = wid->height(); | 2010 | h = wid->height(); |
2001 | list.clear(); | 2011 | list.clear(); |
2002 | list << QString::number( x ); | 2012 | list << QString::number( x ); |
2003 | list << QString::number( y ); | 2013 | list << QString::number( y ); |
2004 | list << QString::number( w ); | 2014 | list << QString::number( w ); |
2005 | list << QString::number( h ); | 2015 | list << QString::number( h ); |
2006 | config->writeEntry("EditTodoLayout",list ); | 2016 | config->writeEntry("EditTodoLayout",list ); |
2007 | wid = getEventViewerDialog(); | 2017 | wid = getEventViewerDialog(); |
2008 | x = wid->geometry().x(); | 2018 | x = wid->geometry().x(); |
2009 | y = wid->geometry().y(); | 2019 | y = wid->geometry().y(); |
2010 | w = wid->width(); | 2020 | w = wid->width(); |
2011 | h = wid->height(); | 2021 | h = wid->height(); |
2012 | list.clear(); | 2022 | list.clear(); |
2013 | list << QString::number( x ); | 2023 | list << QString::number( x ); |
2014 | list << QString::number( y ); | 2024 | list << QString::number( y ); |
2015 | list << QString::number( w ); | 2025 | list << QString::number( w ); |
2016 | list << QString::number( h ); | 2026 | list << QString::number( h ); |
2017 | config->writeEntry("ViewerLayout",list ); | 2027 | config->writeEntry("ViewerLayout",list ); |
2018 | wid = mDialogManager->getSearchDialog(); | 2028 | wid = mDialogManager->getSearchDialog(); |
2019 | if ( wid ) { | 2029 | if ( wid ) { |
2020 | x = wid->geometry().x(); | 2030 | x = wid->geometry().x(); |
2021 | y = wid->geometry().y(); | 2031 | y = wid->geometry().y(); |
2022 | w = wid->width(); | 2032 | w = wid->width(); |
2023 | h = wid->height(); | 2033 | h = wid->height(); |
2024 | list.clear(); | 2034 | list.clear(); |
2025 | list << QString::number( x ); | 2035 | list << QString::number( x ); |
2026 | list << QString::number( y ); | 2036 | list << QString::number( y ); |
2027 | list << QString::number( w ); | 2037 | list << QString::number( w ); |
2028 | list << QString::number( h ); | 2038 | list << QString::number( h ); |
2029 | config->writeEntry("SearchLayout",list ); | 2039 | config->writeEntry("SearchLayout",list ); |
2030 | } | 2040 | } |
2031 | #endif | 2041 | #endif |
2032 | 2042 | ||
2033 | 2043 | ||
2034 | config->sync(); | 2044 | config->sync(); |
2035 | } | 2045 | } |
2036 | 2046 | ||
2037 | void CalendarView::readFilterSettings(KConfig *config) | 2047 | void CalendarView::readFilterSettings(KConfig *config) |
2038 | { | 2048 | { |
2039 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 2049 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
2040 | 2050 | ||
2041 | mFilters.clear(); | 2051 | mFilters.clear(); |
2042 | 2052 | ||
2043 | config->setGroup("General"); | 2053 | config->setGroup("General"); |
2044 | QStringList filterList = config->readListEntry("CalendarFilters"); | 2054 | QStringList filterList = config->readListEntry("CalendarFilters"); |
2045 | 2055 | ||
2046 | QStringList::ConstIterator it = filterList.begin(); | 2056 | QStringList::ConstIterator it = filterList.begin(); |
2047 | QStringList::ConstIterator end = filterList.end(); | 2057 | QStringList::ConstIterator end = filterList.end(); |
2048 | while(it != end) { | 2058 | while(it != end) { |
2049 | // kdDebug() << " filter: " << (*it) << endl; | 2059 | // kdDebug() << " filter: " << (*it) << endl; |
2050 | 2060 | ||
2051 | CalFilter *filter; | 2061 | CalFilter *filter; |
2052 | filter = new CalFilter(*it); | 2062 | filter = new CalFilter(*it); |
2053 | config->setGroup("Filter_" + (*it).utf8()); | 2063 | config->setGroup("Filter_" + (*it).utf8()); |
2054 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 2064 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
2055 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 2065 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
2056 | filter->setCategoryList(config->readListEntry("CategoryList")); | 2066 | filter->setCategoryList(config->readListEntry("CategoryList")); |
2057 | mFilters.append(filter); | 2067 | mFilters.append(filter); |
2058 | 2068 | ||
2059 | ++it; | 2069 | ++it; |
2060 | } | 2070 | } |
2061 | 2071 | ||
2062 | if (mFilters.count() == 0) { | 2072 | if (mFilters.count() == 0) { |
2063 | CalFilter *filter = new CalFilter(i18n("Default")); | 2073 | CalFilter *filter = new CalFilter(i18n("Default")); |
2064 | mFilters.append(filter); | 2074 | mFilters.append(filter); |
2065 | } | 2075 | } |
2066 | mFilterView->updateFilters(); | 2076 | mFilterView->updateFilters(); |
2067 | config->setGroup("FilterView"); | 2077 | config->setGroup("FilterView"); |
2068 | 2078 | ||
2069 | mFilterView->blockSignals(true); | 2079 | mFilterView->blockSignals(true); |
2070 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 2080 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
2071 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 2081 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
2072 | mFilterView->blockSignals(false); | 2082 | mFilterView->blockSignals(false); |
2073 | // We do it manually to avoid it being done twice by the above calls | 2083 | // We do it manually to avoid it being done twice by the above calls |
2074 | updateFilter(); | 2084 | updateFilter(); |
2075 | } | 2085 | } |
2076 | 2086 | ||
2077 | void CalendarView::writeFilterSettings(KConfig *config) | 2087 | void CalendarView::writeFilterSettings(KConfig *config) |
2078 | { | 2088 | { |
2079 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 2089 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
2080 | 2090 | ||
2081 | QStringList filterList; | 2091 | QStringList filterList; |
2082 | 2092 | ||
2083 | CalFilter *filter = mFilters.first(); | 2093 | CalFilter *filter = mFilters.first(); |
2084 | while(filter) { | 2094 | while(filter) { |
2085 | // kdDebug() << " fn: " << filter->name() << endl; | 2095 | // kdDebug() << " fn: " << filter->name() << endl; |
2086 | filterList << filter->name(); | 2096 | filterList << filter->name(); |
2087 | config->setGroup("Filter_" + filter->name().utf8()); | 2097 | config->setGroup("Filter_" + filter->name().utf8()); |
2088 | config->writeEntry("Criteria",filter->criteria()); | 2098 | config->writeEntry("Criteria",filter->criteria()); |
2089 | config->writeEntry("CategoryList",filter->categoryList()); | 2099 | config->writeEntry("CategoryList",filter->categoryList()); |
2090 | filter = mFilters.next(); | 2100 | filter = mFilters.next(); |
2091 | } | 2101 | } |
2092 | config->setGroup("General"); | 2102 | config->setGroup("General"); |
2093 | config->writeEntry("CalendarFilters",filterList); | 2103 | config->writeEntry("CalendarFilters",filterList); |
2094 | 2104 | ||
2095 | config->setGroup("FilterView"); | 2105 | config->setGroup("FilterView"); |
2096 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 2106 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
2097 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 2107 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
2098 | } | 2108 | } |
2099 | 2109 | ||
2100 | 2110 | ||
2101 | void CalendarView::goToday() | 2111 | void CalendarView::goToday() |
2102 | { | 2112 | { |
2103 | if ( mViewManager->currentView()->isMonthView() ) | 2113 | if ( mViewManager->currentView()->isMonthView() ) |
2104 | mNavigator->selectTodayMonth(); | 2114 | mNavigator->selectTodayMonth(); |
2105 | else | 2115 | else |
2106 | mNavigator->selectToday(); | 2116 | mNavigator->selectToday(); |
2107 | } | 2117 | } |
2108 | 2118 | ||
2109 | void CalendarView::goNext() | 2119 | void CalendarView::goNext() |
2110 | { | 2120 | { |
2111 | mNavigator->selectNext(); | 2121 | mNavigator->selectNext(); |
2112 | } | 2122 | } |
2113 | 2123 | ||
2114 | void CalendarView::goPrevious() | 2124 | void CalendarView::goPrevious() |
2115 | { | 2125 | { |
2116 | mNavigator->selectPrevious(); | 2126 | mNavigator->selectPrevious(); |
2117 | } | 2127 | } |
2118 | void CalendarView::goNextMonth() | 2128 | void CalendarView::goNextMonth() |
2119 | { | 2129 | { |
2120 | mNavigator->selectNextMonth(); | 2130 | mNavigator->selectNextMonth(); |
2121 | } | 2131 | } |
2122 | 2132 | ||
2123 | void CalendarView::goPreviousMonth() | 2133 | void CalendarView::goPreviousMonth() |
2124 | { | 2134 | { |
2125 | mNavigator->selectPreviousMonth(); | 2135 | mNavigator->selectPreviousMonth(); |
2126 | } | 2136 | } |
2127 | void CalendarView::writeLocale() | 2137 | void CalendarView::writeLocale() |
2128 | { | 2138 | { |
2129 | //KPimGlobalPrefs::instance()->setGlobalConfig(); | 2139 | //KPimGlobalPrefs::instance()->setGlobalConfig(); |
2130 | #if 0 | 2140 | #if 0 |
2131 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); | 2141 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); |
2132 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); | 2142 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); |
2133 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); | 2143 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); |
2134 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); | 2144 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); |
2135 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; | 2145 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; |
2136 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); | 2146 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); |
2137 | dummy = KOPrefs::instance()->mUserDateFormatShort; | 2147 | dummy = KOPrefs::instance()->mUserDateFormatShort; |
2138 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | 2148 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); |
2139 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, | 2149 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, |
2140 | KOPrefs::instance()->mDaylightsavingStart, | 2150 | KOPrefs::instance()->mDaylightsavingStart, |
2141 | KOPrefs::instance()->mDaylightsavingEnd ); | 2151 | KOPrefs::instance()->mDaylightsavingEnd ); |
2142 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); | 2152 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); |
2143 | #endif | 2153 | #endif |
2144 | } | 2154 | } |
2145 | void CalendarView::updateConfig() | 2155 | void CalendarView::updateConfig() |
2146 | { | 2156 | { |
2147 | writeLocale(); | 2157 | writeLocale(); |
2148 | if ( KOPrefs::instance()->mUseAppColors ) | 2158 | if ( KOPrefs::instance()->mUseAppColors ) |
2149 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 2159 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
2150 | emit configChanged(); | 2160 | emit configChanged(); |
2151 | mTodoList->updateConfig(); | 2161 | mTodoList->updateConfig(); |
2152 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 2162 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
2153 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2163 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2154 | // To make the "fill window" configurations work | 2164 | // To make the "fill window" configurations work |
2155 | //mViewManager->raiseCurrentView(); | 2165 | //mViewManager->raiseCurrentView(); |
2156 | } | 2166 | } |
2157 | 2167 | ||
2158 | 2168 | ||
2159 | void CalendarView::eventChanged(Event *event) | 2169 | void CalendarView::eventChanged(Event *event) |
2160 | { | 2170 | { |
2161 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 2171 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
2162 | //updateUnmanagedViews(); | 2172 | //updateUnmanagedViews(); |
2163 | } | 2173 | } |
2164 | 2174 | ||
2165 | void CalendarView::eventAdded(Event *event) | 2175 | void CalendarView::eventAdded(Event *event) |
2166 | { | 2176 | { |
2167 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 2177 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
2168 | } | 2178 | } |
2169 | 2179 | ||
2170 | void CalendarView::eventToBeDeleted(Event *) | 2180 | void CalendarView::eventToBeDeleted(Event *) |
2171 | { | 2181 | { |
2172 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 2182 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
2173 | } | 2183 | } |
2174 | 2184 | ||
2175 | void CalendarView::eventDeleted() | 2185 | void CalendarView::eventDeleted() |
2176 | { | 2186 | { |
2177 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 2187 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
2178 | } | 2188 | } |
2179 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 2189 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2180 | { | 2190 | { |
2181 | changeIncidenceDisplay((Incidence *)which, action); | 2191 | changeIncidenceDisplay((Incidence *)which, action); |
2182 | mDateNavigator->updateView(); //LR | 2192 | mDateNavigator->updateView(); //LR |
2183 | //mDialogManager->updateSearchDialog(); | 2193 | //mDialogManager->updateSearchDialog(); |
2184 | 2194 | ||
2185 | if (which) { | 2195 | if (which) { |
2186 | mViewManager->updateWNview(); | 2196 | mViewManager->updateWNview(); |
2187 | //mTodoList->updateView(); | 2197 | //mTodoList->updateView(); |
2188 | } | 2198 | } |
2189 | 2199 | ||
2190 | } | 2200 | } |
2191 | 2201 | ||
2192 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 2202 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
2193 | { | 2203 | { |
2194 | updateUnmanagedViews(); | 2204 | updateUnmanagedViews(); |
2195 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 2205 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
2196 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 2206 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
2197 | mCalendar->checkAlarmForIncidence( 0, true ); | 2207 | mCalendar->checkAlarmForIncidence( 0, true ); |
2198 | if ( mEventViewerDialog ) | 2208 | if ( mEventViewerDialog ) |
2199 | mEventViewerDialog->hide(); | 2209 | mEventViewerDialog->hide(); |
2200 | } | 2210 | } |
2201 | else | 2211 | else |
2202 | mCalendar->checkAlarmForIncidence( which , false ); | 2212 | mCalendar->checkAlarmForIncidence( which , false ); |
2203 | } | 2213 | } |
2204 | 2214 | ||
2205 | // most of the changeEventDisplays() right now just call the view's | 2215 | // most of the changeEventDisplays() right now just call the view's |
2206 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 2216 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
2207 | void CalendarView::changeEventDisplay(Event *which, int action) | 2217 | void CalendarView::changeEventDisplay(Event *which, int action) |
2208 | { | 2218 | { |
2209 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 2219 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
2210 | changeIncidenceDisplay((Incidence *)which, action); | 2220 | changeIncidenceDisplay((Incidence *)which, action); |
2211 | mDateNavigator->updateView(); | 2221 | mDateNavigator->updateView(); |
2212 | //mDialogManager->updateSearchDialog(); | 2222 | //mDialogManager->updateSearchDialog(); |
2213 | 2223 | ||
2214 | if (which) { | 2224 | if (which) { |
2215 | // If there is an event view visible update the display | 2225 | // If there is an event view visible update the display |
2216 | mViewManager->currentView()->changeEventDisplay(which,action); | 2226 | mViewManager->currentView()->changeEventDisplay(which,action); |
2217 | // TODO: check, if update needed | 2227 | // TODO: check, if update needed |
2218 | // if (which->getTodoStatus()) { | 2228 | // if (which->getTodoStatus()) { |
2219 | mTodoList->updateView(); | 2229 | mTodoList->updateView(); |
2220 | // } | 2230 | // } |
2221 | } else { | 2231 | } else { |
2222 | mViewManager->currentView()->updateView(); | 2232 | mViewManager->currentView()->updateView(); |
2223 | } | 2233 | } |
2224 | } | 2234 | } |
2225 | 2235 | ||
2226 | 2236 | ||
2227 | void CalendarView::updateTodoViews() | 2237 | void CalendarView::updateTodoViews() |
2228 | { | 2238 | { |
2229 | mTodoList->updateView(); | 2239 | mTodoList->updateView(); |
2230 | mViewManager->currentView()->updateView(); | 2240 | mViewManager->currentView()->updateView(); |
2231 | 2241 | ||
2232 | } | 2242 | } |
2233 | 2243 | ||
2234 | 2244 | ||
2235 | void CalendarView::updateView(const QDate &start, const QDate &end) | 2245 | void CalendarView::updateView(const QDate &start, const QDate &end) |
2236 | { | 2246 | { |
2237 | mTodoList->updateView(); | 2247 | mTodoList->updateView(); |
2238 | mViewManager->updateView(start, end); | 2248 | mViewManager->updateView(start, end); |
2239 | //mDateNavigator->updateView(); | 2249 | //mDateNavigator->updateView(); |
2240 | } | 2250 | } |
2241 | 2251 | ||
2242 | void CalendarView::updateView() | 2252 | void CalendarView::updateView() |
2243 | { | 2253 | { |
2244 | DateList tmpList = mNavigator->selectedDates(); | 2254 | DateList tmpList = mNavigator->selectedDates(); |
2245 | 2255 | ||
2246 | if ( KOPrefs::instance()->mHideNonStartedTodos ) | 2256 | if ( KOPrefs::instance()->mHideNonStartedTodos ) |
2247 | mTodoList->updateView(); | 2257 | mTodoList->updateView(); |
2248 | // We assume that the navigator only selects consecutive days. | 2258 | // We assume that the navigator only selects consecutive days. |
2249 | updateView( tmpList.first(), tmpList.last() ); | 2259 | updateView( tmpList.first(), tmpList.last() ); |
2250 | } | 2260 | } |
2251 | 2261 | ||
2252 | void CalendarView::updateUnmanagedViews() | 2262 | void CalendarView::updateUnmanagedViews() |
2253 | { | 2263 | { |
2254 | mDateNavigator->updateDayMatrix(); | 2264 | mDateNavigator->updateDayMatrix(); |
2255 | } | 2265 | } |
2256 | 2266 | ||
2257 | int CalendarView::msgItemDelete(const QString name) | 2267 | int CalendarView::msgItemDelete(const QString name) |
2258 | { | 2268 | { |
2259 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ | 2269 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ |
2260 | i18n("This item will be\npermanently deleted."), | 2270 | i18n("This item will be\npermanently deleted."), |
2261 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2271 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2262 | } | 2272 | } |
2263 | 2273 | ||
2264 | 2274 | ||
2265 | void CalendarView::edit_cut() | 2275 | void CalendarView::edit_cut() |
2266 | { | 2276 | { |
2267 | Event *anEvent=0; | 2277 | Event *anEvent=0; |
2268 | 2278 | ||
2269 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2279 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2270 | 2280 | ||
2271 | if (mViewManager->currentView()->isEventView()) { | 2281 | if (mViewManager->currentView()->isEventView()) { |
2272 | if ( incidence && incidence->type() == "Event" ) { | 2282 | if ( incidence && incidence->type() == "Event" ) { |
2273 | anEvent = static_cast<Event *>(incidence); | 2283 | anEvent = static_cast<Event *>(incidence); |
2274 | } | 2284 | } |
2275 | } | 2285 | } |
2276 | 2286 | ||
2277 | if (!anEvent) { | 2287 | if (!anEvent) { |
2278 | KNotifyClient::beep(); | 2288 | KNotifyClient::beep(); |
2279 | return; | 2289 | return; |
2280 | } | 2290 | } |
2281 | DndFactory factory( mCalendar ); | 2291 | DndFactory factory( mCalendar ); |
2282 | factory.cutIncidence(anEvent); | 2292 | factory.cutIncidence(anEvent); |
2283 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2293 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2284 | } | 2294 | } |
2285 | 2295 | ||
2286 | void CalendarView::edit_copy() | 2296 | void CalendarView::edit_copy() |
2287 | { | 2297 | { |
2288 | Event *anEvent=0; | 2298 | Event *anEvent=0; |
2289 | 2299 | ||
2290 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2300 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2291 | 2301 | ||
2292 | if (mViewManager->currentView()->isEventView()) { | 2302 | if (mViewManager->currentView()->isEventView()) { |
2293 | if ( incidence && incidence->type() == "Event" ) { | 2303 | if ( incidence && incidence->type() == "Event" ) { |
2294 | anEvent = static_cast<Event *>(incidence); | 2304 | anEvent = static_cast<Event *>(incidence); |
2295 | } | 2305 | } |
2296 | } | 2306 | } |
2297 | 2307 | ||
2298 | if (!anEvent) { | 2308 | if (!anEvent) { |
2299 | KNotifyClient::beep(); | 2309 | KNotifyClient::beep(); |
2300 | return; | 2310 | return; |
2301 | } | 2311 | } |
2302 | DndFactory factory( mCalendar ); | 2312 | DndFactory factory( mCalendar ); |
2303 | factory.copyIncidence(anEvent); | 2313 | factory.copyIncidence(anEvent); |
2304 | } | 2314 | } |
2305 | 2315 | ||
2306 | void CalendarView::edit_paste() | 2316 | void CalendarView::edit_paste() |
2307 | { | 2317 | { |
2308 | QDate date = mNavigator->selectedDates().first(); | 2318 | QDate date = mNavigator->selectedDates().first(); |
2309 | 2319 | ||
2310 | DndFactory factory( mCalendar ); | 2320 | DndFactory factory( mCalendar ); |
2311 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); | 2321 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); |
2312 | 2322 | ||
2313 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2323 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2314 | } | 2324 | } |
2315 | 2325 | ||
2316 | void CalendarView::edit_options() | 2326 | void CalendarView::edit_options() |
2317 | { | 2327 | { |
2318 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; | 2328 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; |
2319 | emit save(); | 2329 | emit save(); |
2320 | emit saveStopTimer(); | 2330 | emit saveStopTimer(); |
2321 | mDialogManager->showOptionsDialog(); | 2331 | mDialogManager->showOptionsDialog(); |
2322 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { | 2332 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { |
2323 | emit saveStopTimer(); | 2333 | emit saveStopTimer(); |
2324 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto apply timezone changes?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), | 2334 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto apply timezone changes?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), |
2325 | i18n("Timezone settings"),i18n("Reload"))) { | 2335 | i18n("Timezone settings"),i18n("Reload"))) { |
2326 | qDebug("KO: TZ reload cancelled "); | 2336 | qDebug("KO: TZ reload cancelled "); |
2327 | return; | 2337 | return; |
2328 | } | 2338 | } |
2329 | qDebug("KO: Timezone change "); | 2339 | qDebug("KO: Timezone change "); |
2330 | openCalendar( MainWindow::defaultFileName() ); | 2340 | openCalendar( MainWindow::defaultFileName() ); |
2331 | setModified(true); | 2341 | setModified(true); |
2332 | } | 2342 | } |
2333 | else | 2343 | else |
2334 | qDebug("KO: No tz change "); | 2344 | qDebug("KO: No tz change "); |
2335 | 2345 | ||
2336 | } | 2346 | } |
2337 | 2347 | ||
2338 | 2348 | ||
2339 | void CalendarView::slotSelectPickerDate( QDate d) | 2349 | void CalendarView::slotSelectPickerDate( QDate d) |
2340 | { | 2350 | { |
2341 | mDateFrame->hide(); | 2351 | mDateFrame->hide(); |
2342 | if ( mDatePickerMode == 1 ) { | 2352 | if ( mDatePickerMode == 1 ) { |
2343 | mNavigator->slotDaySelect( d ); | 2353 | mNavigator->slotDaySelect( d ); |
2344 | } else if ( mDatePickerMode == 2 ) { | 2354 | } else if ( mDatePickerMode == 2 ) { |
2345 | if ( mMoveIncidence->type() == "Todo" ) { | 2355 | if ( mMoveIncidence->type() == "Todo" ) { |
2346 | Todo * to = (Todo *) mMoveIncidence; | 2356 | Todo * to = (Todo *) mMoveIncidence; |
2347 | QTime tim; | 2357 | QTime tim; |
2348 | int len = 0; | 2358 | int len = 0; |
2349 | if ( to->hasStartDate() && to->hasDueDate() ) | 2359 | if ( to->hasStartDate() && to->hasDueDate() ) |
2350 | len = to->dtStart().secsTo( to->dtDue()); | 2360 | len = to->dtStart().secsTo( to->dtDue()); |
2351 | if ( to->hasDueDate() ) | 2361 | if ( to->hasDueDate() ) |
2352 | tim = to->dtDue().time(); | 2362 | tim = to->dtDue().time(); |
2353 | else { | 2363 | else { |
2354 | tim = QTime ( 0,0,0 ); | 2364 | tim = QTime ( 0,0,0 ); |
2355 | to->setFloats( true ); | 2365 | to->setFloats( true ); |
2356 | to->setHasDueDate( true ); | 2366 | to->setHasDueDate( true ); |
2357 | } | 2367 | } |
2358 | QDateTime dt ( d,tim ); | 2368 | QDateTime dt ( d,tim ); |
2359 | to->setDtDue( dt ); | 2369 | to->setDtDue( dt ); |
2360 | 2370 | ||
2361 | if ( to->hasStartDate() ) { | 2371 | if ( to->hasStartDate() ) { |
2362 | if ( len>0 ) | 2372 | if ( len>0 ) |
2363 | to->setDtStart(to->dtDue().addSecs( -len )); | 2373 | to->setDtStart(to->dtDue().addSecs( -len )); |
2364 | else | 2374 | else |
2365 | if (to->dtStart() > to->dtDue() ) | 2375 | if (to->dtStart() > to->dtDue() ) |
2366 | to->setDtStart(to->dtDue().addDays( -3 )); | 2376 | to->setDtStart(to->dtDue().addDays( -3 )); |
2367 | } | 2377 | } |
2368 | 2378 | ||
2369 | todoChanged( to ); | 2379 | todoChanged( to ); |
2370 | } else { | 2380 | } else { |
2371 | if ( mMoveIncidence->doesRecur() ) { | 2381 | if ( mMoveIncidence->doesRecur() ) { |
2372 | #if 0 | 2382 | #if 0 |
2373 | // PENDING implement this | 2383 | // PENDING implement this |
2374 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); | 2384 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); |
2375 | mCalendar()->addIncidence( newInc ); | 2385 | mCalendar()->addIncidence( newInc ); |
2376 | if ( mMoveIncidence->type() == "Todo" ) | 2386 | if ( mMoveIncidence->type() == "Todo" ) |
2377 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); | 2387 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); |
2378 | else | 2388 | else |
2379 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); | 2389 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); |
2380 | mMoveIncidence = newInc; | 2390 | mMoveIncidence = newInc; |