author | zautrix <zautrix> | 2004-10-07 17:51:17 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-07 17:51:17 (UTC) |
commit | 1f1538e5707b59bfcff2014901f29a65589229e3 (patch) (unidiff) | |
tree | 0d91a303524e6ac9f7c954f01a0e1d09d0e305e7 | |
parent | bb8293c794d82a57bc93af85ccd89b601356d577 (diff) | |
download | kdepimpi-1f1538e5707b59bfcff2014901f29a65589229e3.zip kdepimpi-1f1538e5707b59bfcff2014901f29a65589229e3.tar.gz kdepimpi-1f1538e5707b59bfcff2014901f29a65589229e3.tar.bz2 |
many cleanups
-rw-r--r-- | kaddressbook/kabcore.cpp | 1 | ||||
-rw-r--r-- | korganizer/calendarview.cpp | 136 | ||||
-rw-r--r-- | korganizer/calendarview.h | 11 | ||||
-rw-r--r-- | korganizer/koprefs.cpp | 3 | ||||
-rw-r--r-- | korganizer/koprefs.h | 20 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 556 | ||||
-rw-r--r-- | korganizer/mainwindow.h | 24 | ||||
-rw-r--r-- | libkdepim/kpimprefs.cpp | 9 | ||||
-rw-r--r-- | libkdepim/kpimprefs.h | 3 | ||||
-rw-r--r-- | libkdepim/ksyncmanager.cpp | 166 | ||||
-rw-r--r-- | libkdepim/ksyncmanager.h | 3 |
11 files changed, 186 insertions, 746 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 12502b0..c5406bf 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -2503,385 +2503,384 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo | |||
2503 | addresseeLSync = getLastSyncAddressee(); | 2503 | addresseeLSync = getLastSyncAddressee(); |
2504 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); | 2504 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); |
2505 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); | 2505 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); |
2506 | if ( !addresseeR.isEmpty() ) { | 2506 | if ( !addresseeR.isEmpty() ) { |
2507 | addresseeRSync = addresseeR; | 2507 | addresseeRSync = addresseeR; |
2508 | remote->removeAddressee(addresseeR ); | 2508 | remote->removeAddressee(addresseeR ); |
2509 | 2509 | ||
2510 | } else { | 2510 | } else { |
2511 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2511 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2512 | addresseeRSync = addresseeLSync ; | 2512 | addresseeRSync = addresseeLSync ; |
2513 | } else { | 2513 | } else { |
2514 | qDebug("FULLDATE 1"); | 2514 | qDebug("FULLDATE 1"); |
2515 | fullDateRange = true; | 2515 | fullDateRange = true; |
2516 | Addressee newAdd; | 2516 | Addressee newAdd; |
2517 | addresseeRSync = newAdd; | 2517 | addresseeRSync = newAdd; |
2518 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); | 2518 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); |
2519 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); | 2519 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); |
2520 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2520 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2521 | addresseeRSync.setCategories( i18n("SyncAddressee") ); | 2521 | addresseeRSync.setCategories( i18n("SyncAddressee") ); |
2522 | } | 2522 | } |
2523 | } | 2523 | } |
2524 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { | 2524 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { |
2525 | qDebug("FULLDATE 2"); | 2525 | qDebug("FULLDATE 2"); |
2526 | fullDateRange = true; | 2526 | fullDateRange = true; |
2527 | } | 2527 | } |
2528 | if ( ! fullDateRange ) { | 2528 | if ( ! fullDateRange ) { |
2529 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { | 2529 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { |
2530 | 2530 | ||
2531 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); | 2531 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); |
2532 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); | 2532 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); |
2533 | fullDateRange = true; | 2533 | fullDateRange = true; |
2534 | qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); | 2534 | qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); |
2535 | } | 2535 | } |
2536 | } | 2536 | } |
2537 | // fullDateRange = true; // debug only! | 2537 | // fullDateRange = true; // debug only! |
2538 | if ( fullDateRange ) | 2538 | if ( fullDateRange ) |
2539 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); | 2539 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); |
2540 | else | 2540 | else |
2541 | mLastAddressbookSync = addresseeLSync.revision(); | 2541 | mLastAddressbookSync = addresseeLSync.revision(); |
2542 | // for resyncing if own file has changed | 2542 | // for resyncing if own file has changed |
2543 | // PENDING fixme later when implemented | 2543 | // PENDING fixme later when implemented |
2544 | #if 0 | 2544 | #if 0 |
2545 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 2545 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
2546 | mLastAddressbookSync = loadedFileVersion; | 2546 | mLastAddressbookSync = loadedFileVersion; |
2547 | qDebug("setting mLastAddressbookSync "); | 2547 | qDebug("setting mLastAddressbookSync "); |
2548 | } | 2548 | } |
2549 | #endif | 2549 | #endif |
2550 | 2550 | ||
2551 | //qDebug("*************************** "); | 2551 | //qDebug("*************************** "); |
2552 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); | 2552 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); |
2553 | QStringList er = remote->uidList(); | 2553 | QStringList er = remote->uidList(); |
2554 | Addressee inR ;//= er.first(); | 2554 | Addressee inR ;//= er.first(); |
2555 | Addressee inL; | 2555 | Addressee inL; |
2556 | 2556 | ||
2557 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); | 2557 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); |
2558 | 2558 | ||
2559 | int modulo = (er.count()/10)+1; | 2559 | int modulo = (er.count()/10)+1; |
2560 | int incCounter = 0; | 2560 | int incCounter = 0; |
2561 | while ( incCounter < er.count()) { | 2561 | while ( incCounter < er.count()) { |
2562 | if (syncManager->isProgressBarCanceled()) | 2562 | if (syncManager->isProgressBarCanceled()) |
2563 | return false; | 2563 | return false; |
2564 | if ( incCounter % modulo == 0 ) | 2564 | if ( incCounter % modulo == 0 ) |
2565 | syncManager->showProgressBar(incCounter); | 2565 | syncManager->showProgressBar(incCounter); |
2566 | 2566 | ||
2567 | uid = er[ incCounter ]; | 2567 | uid = er[ incCounter ]; |
2568 | bool skipIncidence = false; | 2568 | bool skipIncidence = false; |
2569 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2569 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2570 | skipIncidence = true; | 2570 | skipIncidence = true; |
2571 | QString idS,OidS; | 2571 | QString idS,OidS; |
2572 | qApp->processEvents(); | 2572 | qApp->processEvents(); |
2573 | if ( !skipIncidence ) { | 2573 | if ( !skipIncidence ) { |
2574 | inL = local->findByUid( uid ); | 2574 | inL = local->findByUid( uid ); |
2575 | inR = remote->findByUid( uid ); | 2575 | inR = remote->findByUid( uid ); |
2576 | //inL.setResource( 0 ); | 2576 | //inL.setResource( 0 ); |
2577 | //inR.setResource( 0 ); | 2577 | //inR.setResource( 0 ); |
2578 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars | 2578 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars |
2579 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { | 2579 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { |
2580 | //qDebug("take %d %s ", take, inL.summary().latin1()); | 2580 | //qDebug("take %d %s ", take, inL.summary().latin1()); |
2581 | if ( take == 3 ) | 2581 | if ( take == 3 ) |
2582 | return false; | 2582 | return false; |
2583 | if ( take == 1 ) {// take local | 2583 | if ( take == 1 ) {// take local |
2584 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2584 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2585 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2585 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2586 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2586 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2587 | local->insertAddressee( inL, false ); | 2587 | local->insertAddressee( inL, false ); |
2588 | idS = inR.externalUID(); | 2588 | idS = inR.externalUID(); |
2589 | OidS = inR.originalExternalUID(); | 2589 | OidS = inR.originalExternalUID(); |
2590 | } | 2590 | } |
2591 | else | 2591 | else |
2592 | idS = inR.IDStr(); | 2592 | idS = inR.IDStr(); |
2593 | remote->removeAddressee( inR ); | 2593 | remote->removeAddressee( inR ); |
2594 | inR = inL; | 2594 | inR = inL; |
2595 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 2595 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
2596 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2596 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2597 | inR.setOriginalExternalUID( OidS ); | 2597 | inR.setOriginalExternalUID( OidS ); |
2598 | inR.setExternalUID( idS ); | 2598 | inR.setExternalUID( idS ); |
2599 | } else { | 2599 | } else { |
2600 | inR.setIDStr( idS ); | 2600 | inR.setIDStr( idS ); |
2601 | } | 2601 | } |
2602 | inR.setResource( 0 ); | 2602 | inR.setResource( 0 ); |
2603 | remote->insertAddressee( inR , false); | 2603 | remote->insertAddressee( inR , false); |
2604 | ++changedRemote; | 2604 | ++changedRemote; |
2605 | } else { // take == 2 take remote | 2605 | } else { // take == 2 take remote |
2606 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2606 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2607 | if ( inR.revision().date().year() < 2004 ) | 2607 | if ( inR.revision().date().year() < 2004 ) |
2608 | inR.setRevision( modifiedCalendar ); | 2608 | inR.setRevision( modifiedCalendar ); |
2609 | } | 2609 | } |
2610 | idS = inL.IDStr(); | 2610 | idS = inL.IDStr(); |
2611 | local->removeAddressee( inL ); | 2611 | local->removeAddressee( inL ); |
2612 | inL = inR; | 2612 | inL = inR; |
2613 | inL.setIDStr( idS ); | 2613 | inL.setIDStr( idS ); |
2614 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2614 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2615 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2615 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2616 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2616 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2617 | } | 2617 | } |
2618 | inL.setResource( 0 ); | 2618 | inL.setResource( 0 ); |
2619 | local->insertAddressee( inL , false ); | 2619 | local->insertAddressee( inL , false ); |
2620 | ++changedLocal; | 2620 | ++changedLocal; |
2621 | } | 2621 | } |
2622 | } | 2622 | } |
2623 | } else { // no conflict | 2623 | } else { // no conflict |
2624 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2624 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2625 | QString des = addresseeLSync.note(); | 2625 | QString des = addresseeLSync.note(); |
2626 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 2626 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
2627 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 2627 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
2628 | remote->insertAddressee( inR, false ); | 2628 | remote->insertAddressee( inR, false ); |
2629 | ++deletedAddresseeR; | 2629 | ++deletedAddresseeR; |
2630 | } else { | 2630 | } else { |
2631 | inR.setRevision( modifiedCalendar ); | 2631 | inR.setRevision( modifiedCalendar ); |
2632 | remote->insertAddressee( inR, false ); | 2632 | remote->insertAddressee( inR, false ); |
2633 | inL = inR; | 2633 | inL = inR; |
2634 | inL.setResource( 0 ); | 2634 | inL.setResource( 0 ); |
2635 | local->insertAddressee( inL , false); | 2635 | local->insertAddressee( inL , false); |
2636 | ++addedAddressee; | 2636 | ++addedAddressee; |
2637 | } | 2637 | } |
2638 | } else { | 2638 | } else { |
2639 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { | 2639 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { |
2640 | inR.setRevision( modifiedCalendar ); | 2640 | inR.setRevision( modifiedCalendar ); |
2641 | remote->insertAddressee( inR, false ); | 2641 | remote->insertAddressee( inR, false ); |
2642 | inR.setResource( 0 ); | 2642 | inR.setResource( 0 ); |
2643 | local->insertAddressee( inR, false ); | 2643 | local->insertAddressee( inR, false ); |
2644 | ++addedAddressee; | 2644 | ++addedAddressee; |
2645 | } else { | 2645 | } else { |
2646 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); | 2646 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); |
2647 | remote->removeAddressee( inR ); | 2647 | remote->removeAddressee( inR ); |
2648 | ++deletedAddresseeR; | 2648 | ++deletedAddresseeR; |
2649 | } | 2649 | } |
2650 | } | 2650 | } |
2651 | } | 2651 | } |
2652 | } | 2652 | } |
2653 | ++incCounter; | 2653 | ++incCounter; |
2654 | } | 2654 | } |
2655 | er.clear(); | 2655 | er.clear(); |
2656 | QStringList el = local->uidList(); | 2656 | QStringList el = local->uidList(); |
2657 | modulo = (el.count()/10)+1; | 2657 | modulo = (el.count()/10)+1; |
2658 | 2658 | ||
2659 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); | 2659 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); |
2660 | incCounter = 0; | 2660 | incCounter = 0; |
2661 | while ( incCounter < el.count()) { | 2661 | while ( incCounter < el.count()) { |
2662 | qApp->processEvents(); | 2662 | qApp->processEvents(); |
2663 | if (syncManager->isProgressBarCanceled()) | 2663 | if (syncManager->isProgressBarCanceled()) |
2664 | return false; | 2664 | return false; |
2665 | if ( incCounter % modulo == 0 ) | 2665 | if ( incCounter % modulo == 0 ) |
2666 | syncManager->showProgressBar(incCounter); | 2666 | syncManager->showProgressBar(incCounter); |
2667 | uid = el[ incCounter ]; | 2667 | uid = el[ incCounter ]; |
2668 | bool skipIncidence = false; | 2668 | bool skipIncidence = false; |
2669 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2669 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2670 | skipIncidence = true; | 2670 | skipIncidence = true; |
2671 | if ( !skipIncidence ) { | 2671 | if ( !skipIncidence ) { |
2672 | inL = local->findByUid( uid ); | 2672 | inL = local->findByUid( uid ); |
2673 | inR = remote->findByUid( uid ); | 2673 | inR = remote->findByUid( uid ); |
2674 | if ( inR.isEmpty() ) { | 2674 | if ( inR.isEmpty() ) { |
2675 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2675 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2676 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 2676 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
2677 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2677 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2678 | local->removeAddressee( inL ); | 2678 | local->removeAddressee( inL ); |
2679 | ++deletedAddresseeL; | 2679 | ++deletedAddresseeL; |
2680 | } else { | 2680 | } else { |
2681 | if ( ! syncManager->mWriteBackExistingOnly ) { | 2681 | if ( ! syncManager->mWriteBackExistingOnly ) { |
2682 | inL.removeID(mCurrentSyncDevice ); | 2682 | inL.removeID(mCurrentSyncDevice ); |
2683 | ++addedAddresseeR; | 2683 | ++addedAddresseeR; |
2684 | inL.setRevision( modifiedCalendar ); | 2684 | inL.setRevision( modifiedCalendar ); |
2685 | local->insertAddressee( inL, false ); | 2685 | local->insertAddressee( inL, false ); |
2686 | inR = inL; | 2686 | inR = inL; |
2687 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); | 2687 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); |
2688 | inR.setResource( 0 ); | 2688 | inR.setResource( 0 ); |
2689 | remote->insertAddressee( inR, false ); | 2689 | remote->insertAddressee( inR, false ); |
2690 | } | 2690 | } |
2691 | } | 2691 | } |
2692 | } else { | 2692 | } else { |
2693 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { | 2693 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { |
2694 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2694 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2695 | local->removeAddressee( inL ); | 2695 | local->removeAddressee( inL ); |
2696 | ++deletedAddresseeL; | 2696 | ++deletedAddresseeL; |
2697 | } else { | 2697 | } else { |
2698 | if ( ! syncManager->mWriteBackExistingOnly ) { | 2698 | if ( ! syncManager->mWriteBackExistingOnly ) { |
2699 | ++addedAddresseeR; | 2699 | ++addedAddresseeR; |
2700 | inL.setRevision( modifiedCalendar ); | 2700 | inL.setRevision( modifiedCalendar ); |
2701 | local->insertAddressee( inL, false ); | 2701 | local->insertAddressee( inL, false ); |
2702 | inR = inL; | 2702 | inR = inL; |
2703 | inR.setResource( 0 ); | 2703 | inR.setResource( 0 ); |
2704 | remote->insertAddressee( inR, false ); | 2704 | remote->insertAddressee( inR, false ); |
2705 | } | 2705 | } |
2706 | } | 2706 | } |
2707 | } | 2707 | } |
2708 | } | 2708 | } |
2709 | } | 2709 | } |
2710 | ++incCounter; | 2710 | ++incCounter; |
2711 | } | 2711 | } |
2712 | el.clear(); | 2712 | el.clear(); |
2713 | syncManager->hideProgressBar(); | 2713 | syncManager->hideProgressBar(); |
2714 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); | 2714 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); |
2715 | // get rid of micro seconds | 2715 | // get rid of micro seconds |
2716 | QTime t = mLastAddressbookSync.time(); | 2716 | QTime t = mLastAddressbookSync.time(); |
2717 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 2717 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
2718 | addresseeLSync.setRevision( mLastAddressbookSync ); | 2718 | addresseeLSync.setRevision( mLastAddressbookSync ); |
2719 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2719 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2720 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; | 2720 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; |
2721 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); | 2721 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); |
2722 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; | 2722 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; |
2723 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); | 2723 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); |
2724 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; | 2724 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; |
2725 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); | 2725 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); |
2726 | addresseeRSync.setNote( "" ) ; | 2726 | addresseeRSync.setNote( "" ) ; |
2727 | addresseeLSync.setNote( "" ); | 2727 | addresseeLSync.setNote( "" ); |
2728 | 2728 | ||
2729 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 2729 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
2730 | remote->insertAddressee( addresseeRSync, false ); | 2730 | remote->insertAddressee( addresseeRSync, false ); |
2731 | local->insertAddressee( addresseeLSync, false ); | 2731 | local->insertAddressee( addresseeLSync, false ); |
2732 | QString mes; | 2732 | QString mes; |
2733 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); | 2733 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); |
2734 | if ( syncManager->mShowSyncSummary ) { | 2734 | if ( syncManager->mShowSyncSummary ) { |
2735 | KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); | 2735 | KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); |
2736 | } | 2736 | } |
2737 | qDebug( mes ); | 2737 | qDebug( mes ); |
2738 | return syncOK; | 2738 | return syncOK; |
2739 | } | 2739 | } |
2740 | 2740 | ||
2741 | 2741 | ||
2742 | //this is a overwritten callbackmethods from the syncinterface | 2742 | //this is a overwritten callbackmethods from the syncinterface |
2743 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) | 2743 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) |
2744 | { | 2744 | { |
2745 | 2745 | ||
2746 | //pending prepare addresseeview for output | 2746 | //pending prepare addresseeview for output |
2747 | //pending detect, if remote file has REV field. if not switch to external sync | 2747 | //pending detect, if remote file has REV field. if not switch to external sync |
2748 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 2748 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
2749 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 2749 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
2750 | 2750 | ||
2751 | AddressBook abLocal(filename,"syncContact"); | 2751 | AddressBook abLocal(filename,"syncContact"); |
2752 | bool syncOK = false; | 2752 | bool syncOK = false; |
2753 | if ( abLocal.load() ) { | 2753 | if ( abLocal.load() ) { |
2754 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); | 2754 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); |
2755 | bool external = false; | 2755 | bool external = false; |
2756 | bool isXML = false; | 2756 | bool isXML = false; |
2757 | if ( filename.right(4) == ".xml") { | 2757 | if ( filename.right(4) == ".xml") { |
2758 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2758 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2759 | isXML = true; | 2759 | isXML = true; |
2760 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); | 2760 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); |
2761 | } else { | 2761 | } else { |
2762 | Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2762 | Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2763 | if ( ! lse.isEmpty() ) { | 2763 | if ( ! lse.isEmpty() ) { |
2764 | if ( lse.familyName().left(4) == "!E: " ) | 2764 | if ( lse.familyName().left(4) == "!E: " ) |
2765 | external = true; | 2765 | external = true; |
2766 | } else { | 2766 | } else { |
2767 | bool found = false; | 2767 | bool found = false; |
2768 | AddressBook::Iterator it; | 2768 | AddressBook::Iterator it; |
2769 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2769 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2770 | if ( (*it).revision().date().year() > 2003 ) { | 2770 | if ( (*it).revision().date().year() > 2003 ) { |
2771 | found = true; | 2771 | found = true; |
2772 | break; | 2772 | break; |
2773 | } | 2773 | } |
2774 | } | 2774 | } |
2775 | external = ! found; | 2775 | external = ! found; |
2776 | } | 2776 | } |
2777 | 2777 | ||
2778 | if ( external ) { | 2778 | if ( external ) { |
2779 | qDebug("Setting vcf mode to external "); | 2779 | qDebug("Setting vcf mode to external "); |
2780 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2780 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2781 | AddressBook::Iterator it; | 2781 | AddressBook::Iterator it; |
2782 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2782 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2783 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); | 2783 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); |
2784 | (*it).computeCsum( mCurrentSyncDevice ); | 2784 | (*it).computeCsum( mCurrentSyncDevice ); |
2785 | } | 2785 | } |
2786 | } | 2786 | } |
2787 | } | 2787 | } |
2788 | //AddressBook::Iterator it; | 2788 | //AddressBook::Iterator it; |
2789 | //QStringList vcards; | 2789 | //QStringList vcards; |
2790 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2790 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2791 | // qDebug("Name %s ", (*it).familyName().latin1()); | 2791 | // qDebug("Name %s ", (*it).familyName().latin1()); |
2792 | //} | 2792 | //} |
2793 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); | 2793 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); |
2794 | if ( syncOK ) { | 2794 | if ( syncOK ) { |
2795 | if ( syncManager->mWriteBackFile ) | 2795 | if ( syncManager->mWriteBackFile ) |
2796 | { | 2796 | { |
2797 | if ( external ) | 2797 | if ( external ) |
2798 | abLocal.removeSyncAddressees( !isXML); | 2798 | abLocal.removeSyncAddressees( !isXML); |
2799 | qDebug("Saving remote AB "); | 2799 | qDebug("Saving remote AB "); |
2800 | abLocal.saveAB(); | 2800 | abLocal.saveAB(); |
2801 | if ( isXML ) { | 2801 | if ( isXML ) { |
2802 | // afterwrite processing | 2802 | // afterwrite processing |
2803 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); | 2803 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); |
2804 | } | 2804 | } |
2805 | } | 2805 | } |
2806 | } | 2806 | } |
2807 | setModified(); | 2807 | setModified(); |
2808 | 2808 | ||
2809 | } | 2809 | } |
2810 | if ( syncOK ) | 2810 | if ( syncOK ) |
2811 | mViewManager->refreshView(); | 2811 | mViewManager->refreshView(); |
2812 | return syncOK; | 2812 | return syncOK; |
2813 | #if 0 | 2813 | #if 0 |
2814 | 2814 | ||
2815 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { | 2815 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { |
2816 | getEventViewerDialog()->setSyncMode( true ); | 2816 | getEventViewerDialog()->setSyncMode( true ); |
2817 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 2817 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
2818 | getEventViewerDialog()->setSyncMode( false ); | 2818 | getEventViewerDialog()->setSyncMode( false ); |
2819 | if ( syncOK ) { | 2819 | if ( syncOK ) { |
2820 | if ( KOPrefs::instance()->mWriteBackFile ) | 2820 | if ( KOPrefs::instance()->mWriteBackFile ) |
2821 | { | 2821 | { |
2822 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); | 2822 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); |
2823 | storage->save(); | 2823 | storage->save(); |
2824 | } | 2824 | } |
2825 | } | 2825 | } |
2826 | setModified(); | 2826 | setModified(); |
2827 | } | 2827 | } |
2828 | 2828 | ||
2829 | #endif | 2829 | #endif |
2830 | } | 2830 | } |
2831 | 2831 | ||
2832 | 2832 | ||
2833 | //this is a overwritten callbackmethods from the syncinterface | 2833 | //this is a overwritten callbackmethods from the syncinterface |
2834 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) | 2834 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) |
2835 | { | 2835 | { |
2836 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 2836 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
2837 | 2837 | ||
2838 | AddressBook abLocal( resource,"syncContact"); | 2838 | AddressBook abLocal( resource,"syncContact"); |
2839 | bool syncOK = false; | 2839 | bool syncOK = false; |
2840 | if ( abLocal.load() ) { | 2840 | if ( abLocal.load() ) { |
2841 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 2841 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
2842 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2842 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2843 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); | 2843 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); |
2844 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 2844 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
2845 | if ( syncOK ) { | 2845 | if ( syncOK ) { |
2846 | if ( syncManager->mWriteBackFile ) { | 2846 | if ( syncManager->mWriteBackFile ) { |
2847 | abLocal.saveAB(); | 2847 | abLocal.saveAB(); |
2848 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); | 2848 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); |
2849 | } | 2849 | } |
2850 | } | 2850 | } |
2851 | setModified(); | 2851 | setModified(); |
2852 | } | 2852 | } |
2853 | if ( syncOK ) | 2853 | if ( syncOK ) |
2854 | mViewManager->refreshView(); | 2854 | mViewManager->refreshView(); |
2855 | return syncOK; | 2855 | return syncOK; |
2856 | 2856 | ||
2857 | } | 2857 | } |
2858 | 2858 | ||
2859 | void KABCore::getFile( bool success ) | 2859 | void KABCore::getFile( bool success ) |
2860 | { | 2860 | { |
2861 | QTimer::singleShot( 15000, this , SLOT ( setCaptionBack())); | 2861 | QTimer::singleShot( 15000, this , SLOT ( setCaptionBack())); |
2862 | if ( ! success ) { | 2862 | if ( ! success ) { |
2863 | setCaption( i18n("Error receiving file. Nothing changed!") ); | 2863 | setCaption( i18n("Error receiving file. Nothing changed!") ); |
2864 | return; | 2864 | return; |
2865 | } | 2865 | } |
2866 | mAddressBook->importFromFile( sentSyncFile() ); | 2866 | mAddressBook->importFromFile( sentSyncFile() ); |
2867 | topLevelWidget()->setCaption( i18n("Pi-Sync successful!") ); | 2867 | topLevelWidget()->setCaption( i18n("Pi-Sync successful!") ); |
2868 | mViewManager->refreshView(); | 2868 | mViewManager->refreshView(); |
2869 | } | 2869 | } |
2870 | void KABCore::syncFileRequest() | 2870 | void KABCore::syncFileRequest() |
2871 | { | 2871 | { |
2872 | mAddressBook->export2File( sentSyncFile() ); | 2872 | mAddressBook->export2File( sentSyncFile() ); |
2873 | } | 2873 | } |
2874 | QString KABCore::sentSyncFile() | 2874 | QString KABCore::sentSyncFile() |
2875 | { | 2875 | { |
2876 | #ifdef _WIN32_ | 2876 | #ifdef _WIN32_ |
2877 | return locateLocal( "tmp", "copysyncab.vcf" ); | 2877 | return locateLocal( "tmp", "copysyncab.vcf" ); |
2878 | #else | 2878 | #else |
2879 | return QString( "/tmp/copysyncab.vcf" ); | 2879 | return QString( "/tmp/copysyncab.vcf" ); |
2880 | #endif | 2880 | #endif |
2881 | } | 2881 | } |
2882 | 2882 | ||
2883 | void KABCore::setCaptionBack() | 2883 | void KABCore::setCaptionBack() |
2884 | { | 2884 | { |
2885 | topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); | 2885 | topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); |
2886 | } | 2886 | } |
2887 | |||
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index ea9607d..b56f1f9 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -319,2313 +319,2253 @@ void CalendarView::init() | |||
319 | } else { | 319 | } else { |
320 | leftFrameLayout->addWidget(mTodoList,2 ); | 320 | leftFrameLayout->addWidget(mTodoList,2 ); |
321 | leftFrameLayout->addWidget(mFilterView ); | 321 | leftFrameLayout->addWidget(mFilterView ); |
322 | } | 322 | } |
323 | mFilterView->hide(); | 323 | mFilterView->hide(); |
324 | QWidget *rightBox = new QWidget( mainBox ); | 324 | QWidget *rightBox = new QWidget( mainBox ); |
325 | mainBoxLayout->addWidget ( rightBox, 10 ); | 325 | mainBoxLayout->addWidget ( rightBox, 10 ); |
326 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 326 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
327 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); | 327 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); |
328 | mRightFrame = new QWidgetStack( rightBox ); | 328 | mRightFrame = new QWidgetStack( rightBox ); |
329 | rightLayout->addWidget( mNavigatorBar ); | 329 | rightLayout->addWidget( mNavigatorBar ); |
330 | rightLayout->addWidget( mRightFrame, 10 ); | 330 | rightLayout->addWidget( mRightFrame, 10 ); |
331 | 331 | ||
332 | mLeftFrame = leftFrame; | 332 | mLeftFrame = leftFrame; |
333 | if ( KOPrefs::instance()->mVerticalScreen ) { | 333 | if ( KOPrefs::instance()->mVerticalScreen ) { |
334 | mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | 334 | mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); |
335 | leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | 335 | leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); |
336 | } else { | 336 | } else { |
337 | mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); | 337 | mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); |
338 | leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | 338 | leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); |
339 | } | 339 | } |
340 | 340 | ||
341 | //qDebug("Calendarview Size %d %d ", width(), height()); | 341 | //qDebug("Calendarview Size %d %d ", width(), height()); |
342 | #endif | 342 | #endif |
343 | 343 | ||
344 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 344 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
345 | SLOT( showDates( const KCal::DateList & ) ) ); | 345 | SLOT( showDates( const KCal::DateList & ) ) ); |
346 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 346 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
347 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 347 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
348 | 348 | ||
349 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), | 349 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), |
350 | mNavigator, SLOT( selectPreviousYear() ) ); | 350 | mNavigator, SLOT( selectPreviousYear() ) ); |
351 | connect( mNavigatorBar, SIGNAL( goNextYear() ), | 351 | connect( mNavigatorBar, SIGNAL( goNextYear() ), |
352 | mNavigator, SLOT( selectNextYear() ) ); | 352 | mNavigator, SLOT( selectNextYear() ) ); |
353 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), | 353 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), |
354 | mNavigator, SLOT( selectPreviousMonth() ) ); | 354 | mNavigator, SLOT( selectPreviousMonth() ) ); |
355 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), | 355 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), |
356 | mNavigator, SLOT( selectNextMonth() ) ); | 356 | mNavigator, SLOT( selectNextMonth() ) ); |
357 | 357 | ||
358 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 358 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
359 | mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); | 359 | mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); |
360 | 360 | ||
361 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), | 361 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), |
362 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); | 362 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); |
363 | 363 | ||
364 | connect( mDateNavigator, SIGNAL( goPrevYear() ), | 364 | connect( mDateNavigator, SIGNAL( goPrevYear() ), |
365 | mNavigator, SLOT( selectPreviousYear() ) ); | 365 | mNavigator, SLOT( selectPreviousYear() ) ); |
366 | connect( mDateNavigator, SIGNAL( goNextYear() ), | 366 | connect( mDateNavigator, SIGNAL( goNextYear() ), |
367 | mNavigator, SLOT( selectNextYear() ) ); | 367 | mNavigator, SLOT( selectNextYear() ) ); |
368 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), | 368 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), |
369 | mNavigator, SLOT( selectPreviousMonth() ) ); | 369 | mNavigator, SLOT( selectPreviousMonth() ) ); |
370 | connect( mDateNavigator, SIGNAL( goNextMonth() ), | 370 | connect( mDateNavigator, SIGNAL( goNextMonth() ), |
371 | mNavigator, SLOT( selectNextMonth() ) ); | 371 | mNavigator, SLOT( selectNextMonth() ) ); |
372 | 372 | ||
373 | connect( mDateNavigator, SIGNAL( goPrevious() ), | 373 | connect( mDateNavigator, SIGNAL( goPrevious() ), |
374 | mNavigator, SLOT( selectPrevious() ) ); | 374 | mNavigator, SLOT( selectPrevious() ) ); |
375 | connect( mDateNavigator, SIGNAL( goNext() ), | 375 | connect( mDateNavigator, SIGNAL( goNext() ), |
376 | mNavigator, SLOT( selectNext() ) ); | 376 | mNavigator, SLOT( selectNext() ) ); |
377 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 377 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
378 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 378 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
379 | connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), | 379 | connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), |
380 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 380 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
381 | 381 | ||
382 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 382 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
383 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 383 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
384 | 384 | ||
385 | connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), | 385 | connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), |
386 | SLOT( eventAdded( Event *) ) ); | 386 | SLOT( eventAdded( Event *) ) ); |
387 | 387 | ||
388 | connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 388 | connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
389 | 389 | ||
390 | connect( this, SIGNAL( configChanged() ), | 390 | connect( this, SIGNAL( configChanged() ), |
391 | mDateNavigator, SLOT( updateConfig() ) ); | 391 | mDateNavigator, SLOT( updateConfig() ) ); |
392 | 392 | ||
393 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 393 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
394 | SLOT( newTodo() ) ); | 394 | SLOT( newTodo() ) ); |
395 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 395 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
396 | SLOT( newSubTodo( Todo * ) ) ); | 396 | SLOT( newSubTodo( Todo * ) ) ); |
397 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 397 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
398 | SLOT( editTodo( Todo * ) ) ); | 398 | SLOT( editTodo( Todo * ) ) ); |
399 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 399 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
400 | SLOT( showTodo( Todo *) ) ); | 400 | SLOT( showTodo( Todo *) ) ); |
401 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 401 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
402 | SLOT( deleteTodo( Todo *) ) ); | 402 | SLOT( deleteTodo( Todo *) ) ); |
403 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 403 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
404 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 404 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
405 | SLOT( purgeCompleted() ) ); | 405 | SLOT( purgeCompleted() ) ); |
406 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 406 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
407 | SIGNAL( todoModified( Todo *, int ) ) ); | 407 | SIGNAL( todoModified( Todo *, int ) ) ); |
408 | 408 | ||
409 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 409 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
410 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 410 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
411 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 411 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
412 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 412 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
413 | 413 | ||
414 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 414 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
415 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 415 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
416 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 416 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
417 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 417 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
418 | 418 | ||
419 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 419 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
420 | this, SLOT ( todo_unsub( Todo * ) ) ); | 420 | this, SLOT ( todo_unsub( Todo * ) ) ); |
421 | 421 | ||
422 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 422 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
423 | SLOT( updateTodo( Todo *, int ) ) ); | 423 | SLOT( updateTodo( Todo *, int ) ) ); |
424 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 424 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
425 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 425 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
426 | 426 | ||
427 | 427 | ||
428 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 428 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
429 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 429 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
430 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 430 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
431 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 431 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
432 | 432 | ||
433 | 433 | ||
434 | 434 | ||
435 | 435 | ||
436 | 436 | ||
437 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 437 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
438 | SLOT(checkClipboard())); | 438 | SLOT(checkClipboard())); |
439 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 439 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
440 | SLOT( processTodoListSelection( Incidence * ) ) ); | 440 | SLOT( processTodoListSelection( Incidence * ) ) ); |
441 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 441 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
442 | 442 | ||
443 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 443 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
444 | 444 | ||
445 | mDateFrame = new QVBox(0,0,WType_Popup); | 445 | mDateFrame = new QVBox(0,0,WType_Popup); |
446 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 446 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
447 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 447 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
448 | mDateFrame->setLineWidth(3); | 448 | mDateFrame->setLineWidth(3); |
449 | mDateFrame->hide(); | 449 | mDateFrame->hide(); |
450 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 450 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
451 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 451 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
452 | 452 | ||
453 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 453 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
454 | 454 | ||
455 | mEventEditor = mDialogManager->getEventEditor(); | 455 | mEventEditor = mDialogManager->getEventEditor(); |
456 | mTodoEditor = mDialogManager->getTodoEditor(); | 456 | mTodoEditor = mDialogManager->getTodoEditor(); |
457 | 457 | ||
458 | mFlagEditDescription = false; | 458 | mFlagEditDescription = false; |
459 | 459 | ||
460 | mSuspendTimer = new QTimer( this ); | 460 | mSuspendTimer = new QTimer( this ); |
461 | mAlarmTimer = new QTimer( this ); | 461 | mAlarmTimer = new QTimer( this ); |
462 | mRecheckAlarmTimer = new QTimer( this ); | 462 | mRecheckAlarmTimer = new QTimer( this ); |
463 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 463 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
464 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 464 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
465 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 465 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
466 | mAlarmDialog = new AlarmDialog( this ); | 466 | mAlarmDialog = new AlarmDialog( this ); |
467 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 467 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
468 | mAlarmDialog->setServerNotification( false ); | 468 | mAlarmDialog->setServerNotification( false ); |
469 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 469 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
470 | 470 | ||
471 | 471 | ||
472 | #ifndef DESKTOP_VERSION | 472 | #ifndef DESKTOP_VERSION |
473 | //US listen for arriving address resultsets | 473 | //US listen for arriving address resultsets |
474 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), | 474 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), |
475 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 475 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
476 | #endif | 476 | #endif |
477 | 477 | ||
478 | } | 478 | } |
479 | 479 | ||
480 | 480 | ||
481 | CalendarView::~CalendarView() | 481 | CalendarView::~CalendarView() |
482 | { | 482 | { |
483 | // kdDebug() << "~CalendarView()" << endl; | 483 | // kdDebug() << "~CalendarView()" << endl; |
484 | //qDebug("CalendarView::~CalendarView() "); | 484 | //qDebug("CalendarView::~CalendarView() "); |
485 | delete mDialogManager; | 485 | delete mDialogManager; |
486 | delete mViewManager; | 486 | delete mViewManager; |
487 | delete mStorage; | 487 | delete mStorage; |
488 | delete mDateFrame ; | 488 | delete mDateFrame ; |
489 | delete beamDialog; | 489 | delete beamDialog; |
490 | //kdDebug() << "~CalendarView() done" << endl; | 490 | //kdDebug() << "~CalendarView() done" << endl; |
491 | } | 491 | } |
492 | void CalendarView::timerAlarm() | 492 | void CalendarView::timerAlarm() |
493 | { | 493 | { |
494 | //qDebug("CalendarView::timerAlarm() "); | 494 | //qDebug("CalendarView::timerAlarm() "); |
495 | computeAlarm(mAlarmNotification ); | 495 | computeAlarm(mAlarmNotification ); |
496 | } | 496 | } |
497 | 497 | ||
498 | void CalendarView::suspendAlarm() | 498 | void CalendarView::suspendAlarm() |
499 | { | 499 | { |
500 | //qDebug(" CalendarView::suspendAlarm() "); | 500 | //qDebug(" CalendarView::suspendAlarm() "); |
501 | computeAlarm(mSuspendAlarmNotification ); | 501 | computeAlarm(mSuspendAlarmNotification ); |
502 | 502 | ||
503 | } | 503 | } |
504 | 504 | ||
505 | void CalendarView::startAlarm( QString mess , QString filename) | 505 | void CalendarView::startAlarm( QString mess , QString filename) |
506 | { | 506 | { |
507 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 507 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
508 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); | 508 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); |
509 | 509 | ||
510 | } | 510 | } |
511 | 511 | ||
512 | void CalendarView::checkNextTimerAlarm() | 512 | void CalendarView::checkNextTimerAlarm() |
513 | { | 513 | { |
514 | mCalendar->checkAlarmForIncidence( 0, true ); | 514 | mCalendar->checkAlarmForIncidence( 0, true ); |
515 | } | 515 | } |
516 | 516 | ||
517 | void CalendarView::computeAlarm( QString msg ) | 517 | void CalendarView::computeAlarm( QString msg ) |
518 | { | 518 | { |
519 | 519 | ||
520 | QString mess = msg; | 520 | QString mess = msg; |
521 | QString mAlarmMessage = mess.mid( 9 ); | 521 | QString mAlarmMessage = mess.mid( 9 ); |
522 | QString filename = MainWindow::resourcePath(); | 522 | QString filename = MainWindow::resourcePath(); |
523 | filename += "koalarm.wav"; | 523 | filename += "koalarm.wav"; |
524 | QString tempfilename; | 524 | QString tempfilename; |
525 | if ( mess.left( 13 ) == "suspend_alarm") { | 525 | if ( mess.left( 13 ) == "suspend_alarm") { |
526 | bool error = false; | 526 | bool error = false; |
527 | int len = mess.mid( 13 ).find("+++"); | 527 | int len = mess.mid( 13 ).find("+++"); |
528 | if ( len < 2 ) | 528 | if ( len < 2 ) |
529 | error = true; | 529 | error = true; |
530 | else { | 530 | else { |
531 | tempfilename = mess.mid( 13, len ); | 531 | tempfilename = mess.mid( 13, len ); |
532 | if ( !QFile::exists( tempfilename ) ) | 532 | if ( !QFile::exists( tempfilename ) ) |
533 | error = true; | 533 | error = true; |
534 | } | 534 | } |
535 | if ( ! error ) { | 535 | if ( ! error ) { |
536 | filename = tempfilename; | 536 | filename = tempfilename; |
537 | } | 537 | } |
538 | mAlarmMessage = mess.mid( 13+len+3 ); | 538 | mAlarmMessage = mess.mid( 13+len+3 ); |
539 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 539 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
540 | startAlarm( mAlarmMessage, filename); | 540 | startAlarm( mAlarmMessage, filename); |
541 | return; | 541 | return; |
542 | } | 542 | } |
543 | if ( mess.left( 11 ) == "timer_alarm") { | 543 | if ( mess.left( 11 ) == "timer_alarm") { |
544 | //mTimerTime = 0; | 544 | //mTimerTime = 0; |
545 | startAlarm( mess.mid( 11 ), filename ); | 545 | startAlarm( mess.mid( 11 ), filename ); |
546 | return; | 546 | return; |
547 | } | 547 | } |
548 | if ( mess.left( 10 ) == "proc_alarm") { | 548 | if ( mess.left( 10 ) == "proc_alarm") { |
549 | bool error = false; | 549 | bool error = false; |
550 | int len = mess.mid( 10 ).find("+++"); | 550 | int len = mess.mid( 10 ).find("+++"); |
551 | if ( len < 2 ) | 551 | if ( len < 2 ) |
552 | error = true; | 552 | error = true; |
553 | else { | 553 | else { |
554 | tempfilename = mess.mid( 10, len ); | 554 | tempfilename = mess.mid( 10, len ); |
555 | if ( !QFile::exists( tempfilename ) ) | 555 | if ( !QFile::exists( tempfilename ) ) |
556 | error = true; | 556 | error = true; |
557 | } | 557 | } |
558 | if ( error ) { | 558 | if ( error ) { |
559 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 559 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
560 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 560 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
561 | } else { | 561 | } else { |
562 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 562 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
563 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 563 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
564 | #ifndef _WIN32_ | 564 | #ifndef _WIN32_ |
565 | if ( vfork () == 0 ) { | 565 | if ( vfork () == 0 ) { |
566 | execl ( tempfilename.latin1(), 0 ); | 566 | execl ( tempfilename.latin1(), 0 ); |
567 | return; | 567 | return; |
568 | } | 568 | } |
569 | #else | 569 | #else |
570 | QProcess* p = new QProcess(); | 570 | QProcess* p = new QProcess(); |
571 | p->addArgument( tempfilename.latin1() ); | 571 | p->addArgument( tempfilename.latin1() ); |
572 | p->start(); | 572 | p->start(); |
573 | return; | 573 | return; |
574 | #endif | 574 | #endif |
575 | 575 | ||
576 | return; | 576 | return; |
577 | } | 577 | } |
578 | 578 | ||
579 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 579 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
580 | } | 580 | } |
581 | if ( mess.left( 11 ) == "audio_alarm") { | 581 | if ( mess.left( 11 ) == "audio_alarm") { |
582 | bool error = false; | 582 | bool error = false; |
583 | int len = mess.mid( 11 ).find("+++"); | 583 | int len = mess.mid( 11 ).find("+++"); |
584 | if ( len < 2 ) | 584 | if ( len < 2 ) |
585 | error = true; | 585 | error = true; |
586 | else { | 586 | else { |
587 | tempfilename = mess.mid( 11, len ); | 587 | tempfilename = mess.mid( 11, len ); |
588 | if ( !QFile::exists( tempfilename ) ) | 588 | if ( !QFile::exists( tempfilename ) ) |
589 | error = true; | 589 | error = true; |
590 | } | 590 | } |
591 | if ( ! error ) { | 591 | if ( ! error ) { |
592 | filename = tempfilename; | 592 | filename = tempfilename; |
593 | } | 593 | } |
594 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 594 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
595 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 595 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
596 | } | 596 | } |
597 | if ( mess.left( 9 ) == "cal_alarm") { | 597 | if ( mess.left( 9 ) == "cal_alarm") { |
598 | mAlarmMessage = mess.mid( 9 ) ; | 598 | mAlarmMessage = mess.mid( 9 ) ; |
599 | } | 599 | } |
600 | 600 | ||
601 | startAlarm( mAlarmMessage, filename ); | 601 | startAlarm( mAlarmMessage, filename ); |
602 | 602 | ||
603 | 603 | ||
604 | } | 604 | } |
605 | 605 | ||
606 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 606 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
607 | { | 607 | { |
608 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 608 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
609 | 609 | ||
610 | mSuspendAlarmNotification = noti; | 610 | mSuspendAlarmNotification = noti; |
611 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 611 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
612 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 612 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
613 | mSuspendTimer->start( ms , true ); | 613 | mSuspendTimer->start( ms , true ); |
614 | 614 | ||
615 | } | 615 | } |
616 | 616 | ||
617 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 617 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
618 | { | 618 | { |
619 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 619 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
620 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 620 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
621 | #ifndef DESKTOP_VERSION | 621 | #ifndef DESKTOP_VERSION |
622 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); | 622 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); |
623 | #endif | 623 | #endif |
624 | return; | 624 | return; |
625 | } | 625 | } |
626 | int maxSec; | 626 | int maxSec; |
627 | //maxSec = 5; //testing only | 627 | //maxSec = 5; //testing only |
628 | maxSec = 86400+3600; // one day+1hour | 628 | maxSec = 86400+3600; // one day+1hour |
629 | mAlarmNotification = noti; | 629 | mAlarmNotification = noti; |
630 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 630 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
631 | if ( sec > maxSec ) { | 631 | if ( sec > maxSec ) { |
632 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 632 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
633 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 633 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
634 | return; | 634 | return; |
635 | } else { | 635 | } else { |
636 | mRecheckAlarmTimer->stop(); | 636 | mRecheckAlarmTimer->stop(); |
637 | } | 637 | } |
638 | //qDebug("Alarm timer started with secs: %d ", sec); | 638 | //qDebug("Alarm timer started with secs: %d ", sec); |
639 | mAlarmTimer->start( sec *1000 , true ); | 639 | mAlarmTimer->start( sec *1000 , true ); |
640 | 640 | ||
641 | } | 641 | } |
642 | // called by mRecheckAlarmTimer to get next alarm | 642 | // called by mRecheckAlarmTimer to get next alarm |
643 | // we need this, because a QTimer has only a max range of 25 days | 643 | // we need this, because a QTimer has only a max range of 25 days |
644 | void CalendarView::recheckTimerAlarm() | 644 | void CalendarView::recheckTimerAlarm() |
645 | { | 645 | { |
646 | mAlarmTimer->stop(); | 646 | mAlarmTimer->stop(); |
647 | mRecheckAlarmTimer->stop(); | 647 | mRecheckAlarmTimer->stop(); |
648 | mCalendar->checkAlarmForIncidence( 0, true ); | 648 | mCalendar->checkAlarmForIncidence( 0, true ); |
649 | } | 649 | } |
650 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 650 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
651 | { | 651 | { |
652 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 652 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
653 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 653 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
654 | #ifndef DESKTOP_VERSION | 654 | #ifndef DESKTOP_VERSION |
655 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); | 655 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); |
656 | #endif | 656 | #endif |
657 | return; | 657 | return; |
658 | } | 658 | } |
659 | mAlarmTimer->stop(); | 659 | mAlarmTimer->stop(); |
660 | } | 660 | } |
661 | void CalendarView::selectWeekNum ( int num ) | 661 | void CalendarView::selectWeekNum ( int num ) |
662 | { | 662 | { |
663 | dateNavigator()->selectWeek( num ); | 663 | dateNavigator()->selectWeek( num ); |
664 | mViewManager->showWeekView(); | 664 | mViewManager->showWeekView(); |
665 | } | 665 | } |
666 | KOViewManager *CalendarView::viewManager() | 666 | KOViewManager *CalendarView::viewManager() |
667 | { | 667 | { |
668 | return mViewManager; | 668 | return mViewManager; |
669 | } | 669 | } |
670 | 670 | ||
671 | KODialogManager *CalendarView::dialogManager() | 671 | KODialogManager *CalendarView::dialogManager() |
672 | { | 672 | { |
673 | return mDialogManager; | 673 | return mDialogManager; |
674 | } | 674 | } |
675 | 675 | ||
676 | QDate CalendarView::startDate() | 676 | QDate CalendarView::startDate() |
677 | { | 677 | { |
678 | DateList dates = mNavigator->selectedDates(); | 678 | DateList dates = mNavigator->selectedDates(); |
679 | 679 | ||
680 | return dates.first(); | 680 | return dates.first(); |
681 | } | 681 | } |
682 | 682 | ||
683 | QDate CalendarView::endDate() | 683 | QDate CalendarView::endDate() |
684 | { | 684 | { |
685 | DateList dates = mNavigator->selectedDates(); | 685 | DateList dates = mNavigator->selectedDates(); |
686 | 686 | ||
687 | return dates.last(); | 687 | return dates.last(); |
688 | } | 688 | } |
689 | 689 | ||
690 | 690 | ||
691 | void CalendarView::createPrinter() | 691 | void CalendarView::createPrinter() |
692 | { | 692 | { |
693 | #ifndef KORG_NOPRINTER | 693 | #ifndef KORG_NOPRINTER |
694 | if (!mCalPrinter) { | 694 | if (!mCalPrinter) { |
695 | mCalPrinter = new CalPrinter(this, mCalendar); | 695 | mCalPrinter = new CalPrinter(this, mCalendar); |
696 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 696 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
697 | } | 697 | } |
698 | #endif | 698 | #endif |
699 | } | 699 | } |
700 | 700 | ||
701 | void CalendarView::confSync() | 701 | void CalendarView::confSync() |
702 | { | 702 | { |
703 | static KSyncPrefsDialog* sp = 0; | 703 | //DELETE |
704 | if ( ! sp ) { | ||
705 | sp = new KSyncPrefsDialog( this, "syncprefs", true ); | ||
706 | } | ||
707 | sp->usrReadConfig(); | ||
708 | #ifndef DESKTOP_VERSION | ||
709 | sp->showMaximized(); | ||
710 | #else | ||
711 | sp->show(); | ||
712 | #endif | ||
713 | sp->exec(); | ||
714 | KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); | ||
715 | KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); | ||
716 | } | 704 | } |
717 | 705 | ||
718 | 706 | ||
719 | //KOPrefs::instance()->mWriteBackFile | 707 | //KOPrefs::instance()->mWriteBackFile |
720 | //KOPrefs::instance()->mWriteBackExistingOnly | 708 | //KOPrefs::instance()->mWriteBackExistingOnly |
721 | 709 | ||
722 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 710 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
723 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 711 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
724 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 712 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
725 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 713 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
726 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 714 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
727 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 715 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
728 | 716 | ||
729 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 717 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
730 | { | 718 | { |
731 | 719 | ||
732 | //void setZaurusId(int id); | 720 | //void setZaurusId(int id); |
733 | // int zaurusId() const; | 721 | // int zaurusId() const; |
734 | // void setZaurusUid(int id); | 722 | // void setZaurusUid(int id); |
735 | // int zaurusUid() const; | 723 | // int zaurusUid() const; |
736 | // void setZaurusStat(int id); | 724 | // void setZaurusStat(int id); |
737 | // int zaurusStat() const; | 725 | // int zaurusStat() const; |
738 | // 0 equal | 726 | // 0 equal |
739 | // 1 take local | 727 | // 1 take local |
740 | // 2 take remote | 728 | // 2 take remote |
741 | // 3 cancel | 729 | // 3 cancel |
742 | QDateTime lastSync = mLastCalendarSync; | 730 | QDateTime lastSync = mLastCalendarSync; |
743 | QDateTime localMod = local->lastModified(); | 731 | QDateTime localMod = local->lastModified(); |
744 | QDateTime remoteMod = remote->lastModified(); | 732 | QDateTime remoteMod = remote->lastModified(); |
745 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 733 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
746 | bool remCh, locCh; | 734 | bool remCh, locCh; |
747 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 735 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
748 | //if ( remCh ) | 736 | //if ( remCh ) |
749 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 737 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
750 | locCh = ( localMod > mLastCalendarSync ); | 738 | locCh = ( localMod > mLastCalendarSync ); |
751 | if ( !remCh && ! locCh ) { | 739 | if ( !remCh && ! locCh ) { |
752 | //qDebug("both not changed "); | 740 | //qDebug("both not changed "); |
753 | lastSync = localMod.addDays(1); | 741 | lastSync = localMod.addDays(1); |
754 | if ( mode <= SYNC_PREF_ASK ) | 742 | if ( mode <= SYNC_PREF_ASK ) |
755 | return 0; | 743 | return 0; |
756 | } else { | 744 | } else { |
757 | if ( locCh ) { | 745 | if ( locCh ) { |
758 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); | 746 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
759 | lastSync = localMod.addDays( -1 ); | 747 | lastSync = localMod.addDays( -1 ); |
760 | if ( !remCh ) | 748 | if ( !remCh ) |
761 | remoteMod = ( lastSync.addDays( -1 ) ); | 749 | remoteMod = ( lastSync.addDays( -1 ) ); |
762 | } else { | 750 | } else { |
763 | //qDebug(" not loc changed "); | 751 | //qDebug(" not loc changed "); |
764 | lastSync = localMod.addDays( 1 ); | 752 | lastSync = localMod.addDays( 1 ); |
765 | if ( remCh ) | 753 | if ( remCh ) |
766 | remoteMod =( lastSync.addDays( 1 ) ); | 754 | remoteMod =( lastSync.addDays( 1 ) ); |
767 | 755 | ||
768 | } | 756 | } |
769 | } | 757 | } |
770 | full = true; | 758 | full = true; |
771 | if ( mode < SYNC_PREF_ASK ) | 759 | if ( mode < SYNC_PREF_ASK ) |
772 | mode = SYNC_PREF_ASK; | 760 | mode = SYNC_PREF_ASK; |
773 | } else { | 761 | } else { |
774 | if ( localMod == remoteMod ) | 762 | if ( localMod == remoteMod ) |
775 | if ( local->revision() == remote->revision() ) | 763 | if ( local->revision() == remote->revision() ) |
776 | return 0; | 764 | return 0; |
777 | 765 | ||
778 | } | 766 | } |
779 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 767 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
780 | 768 | ||
781 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); | 769 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
782 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); | 770 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
783 | //full = true; //debug only | 771 | //full = true; //debug only |
784 | if ( full ) { | 772 | if ( full ) { |
785 | bool equ = false; | 773 | bool equ = false; |
786 | if ( local->type() == "Event" ) { | 774 | if ( local->type() == "Event" ) { |
787 | equ = (*((Event*) local) == *((Event*) remote)); | 775 | equ = (*((Event*) local) == *((Event*) remote)); |
788 | } | 776 | } |
789 | else if ( local->type() =="Todo" ) | 777 | else if ( local->type() =="Todo" ) |
790 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 778 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
791 | else if ( local->type() =="Journal" ) | 779 | else if ( local->type() =="Journal" ) |
792 | equ = (*((Journal*) local) == *((Journal*) remote)); | 780 | equ = (*((Journal*) local) == *((Journal*) remote)); |
793 | if ( equ ) { | 781 | if ( equ ) { |
794 | //qDebug("equal "); | 782 | //qDebug("equal "); |
795 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 783 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
796 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 784 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
797 | } | 785 | } |
798 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 786 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
799 | return 0; | 787 | return 0; |
800 | 788 | ||
801 | }//else //debug only | 789 | }//else //debug only |
802 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 790 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
803 | } | 791 | } |
804 | int result; | 792 | int result; |
805 | bool localIsNew; | 793 | bool localIsNew; |
806 | //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() ); | 794 | //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() ); |
807 | 795 | ||
808 | if ( full && mode < SYNC_PREF_NEWEST ) | 796 | if ( full && mode < SYNC_PREF_NEWEST ) |
809 | mode = SYNC_PREF_ASK; | 797 | mode = SYNC_PREF_ASK; |
810 | 798 | ||
811 | switch( mode ) { | 799 | switch( mode ) { |
812 | case SYNC_PREF_LOCAL: | 800 | case SYNC_PREF_LOCAL: |
813 | if ( lastSync > remoteMod ) | 801 | if ( lastSync > remoteMod ) |
814 | return 1; | 802 | return 1; |
815 | if ( lastSync > localMod ) | 803 | if ( lastSync > localMod ) |
816 | return 2; | 804 | return 2; |
817 | return 1; | 805 | return 1; |
818 | break; | 806 | break; |
819 | case SYNC_PREF_REMOTE: | 807 | case SYNC_PREF_REMOTE: |
820 | if ( lastSync > remoteMod ) | 808 | if ( lastSync > remoteMod ) |
821 | return 1; | 809 | return 1; |
822 | if ( lastSync > localMod ) | 810 | if ( lastSync > localMod ) |
823 | return 2; | 811 | return 2; |
824 | return 2; | 812 | return 2; |
825 | break; | 813 | break; |
826 | case SYNC_PREF_NEWEST: | 814 | case SYNC_PREF_NEWEST: |
827 | if ( localMod > remoteMod ) | 815 | if ( localMod > remoteMod ) |
828 | return 1; | 816 | return 1; |
829 | else | 817 | else |
830 | return 2; | 818 | return 2; |
831 | break; | 819 | break; |
832 | case SYNC_PREF_ASK: | 820 | case SYNC_PREF_ASK: |
833 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 821 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
834 | if ( lastSync > remoteMod ) | 822 | if ( lastSync > remoteMod ) |
835 | return 1; | 823 | return 1; |
836 | if ( lastSync > localMod ) | 824 | if ( lastSync > localMod ) |
837 | return 2; | 825 | return 2; |
838 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 826 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
839 | localIsNew = localMod >= remoteMod; | 827 | localIsNew = localMod >= remoteMod; |
840 | if ( localIsNew ) | 828 | if ( localIsNew ) |
841 | getEventViewerDialog()->setColorMode( 1 ); | 829 | getEventViewerDialog()->setColorMode( 1 ); |
842 | else | 830 | else |
843 | getEventViewerDialog()->setColorMode( 2 ); | 831 | getEventViewerDialog()->setColorMode( 2 ); |
844 | getEventViewerDialog()->setIncidence(local); | 832 | getEventViewerDialog()->setIncidence(local); |
845 | if ( localIsNew ) | 833 | if ( localIsNew ) |
846 | getEventViewerDialog()->setColorMode( 2 ); | 834 | getEventViewerDialog()->setColorMode( 2 ); |
847 | else | 835 | else |
848 | getEventViewerDialog()->setColorMode( 1 ); | 836 | getEventViewerDialog()->setColorMode( 1 ); |
849 | getEventViewerDialog()->addIncidence(remote); | 837 | getEventViewerDialog()->addIncidence(remote); |
850 | getEventViewerDialog()->setColorMode( 0 ); | 838 | getEventViewerDialog()->setColorMode( 0 ); |
851 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 839 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
852 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 840 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
853 | getEventViewerDialog()->showMe(); | 841 | getEventViewerDialog()->showMe(); |
854 | result = getEventViewerDialog()->executeS( localIsNew ); | 842 | result = getEventViewerDialog()->executeS( localIsNew ); |
855 | return result; | 843 | return result; |
856 | 844 | ||
857 | break; | 845 | break; |
858 | case SYNC_PREF_FORCE_LOCAL: | 846 | case SYNC_PREF_FORCE_LOCAL: |
859 | return 1; | 847 | return 1; |
860 | break; | 848 | break; |
861 | case SYNC_PREF_FORCE_REMOTE: | 849 | case SYNC_PREF_FORCE_REMOTE: |
862 | return 2; | 850 | return 2; |
863 | break; | 851 | break; |
864 | 852 | ||
865 | default: | 853 | default: |
866 | // SYNC_PREF_TAKE_BOTH not implemented | 854 | // SYNC_PREF_TAKE_BOTH not implemented |
867 | break; | 855 | break; |
868 | } | 856 | } |
869 | return 0; | 857 | return 0; |
870 | } | 858 | } |
871 | Event* CalendarView::getLastSyncEvent() | 859 | Event* CalendarView::getLastSyncEvent() |
872 | { | 860 | { |
873 | Event* lse; | 861 | Event* lse; |
874 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 862 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
875 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 863 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
876 | if (!lse) { | 864 | if (!lse) { |
877 | lse = new Event(); | 865 | lse = new Event(); |
878 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 866 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
879 | QString sum = ""; | 867 | QString sum = ""; |
880 | if ( KOPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 868 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
881 | sum = "E: "; | 869 | sum = "E: "; |
882 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 870 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
883 | lse->setDtStart( mLastCalendarSync ); | 871 | lse->setDtStart( mLastCalendarSync ); |
884 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 872 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
885 | lse->setCategories( i18n("SyncEvent") ); | 873 | lse->setCategories( i18n("SyncEvent") ); |
886 | lse->setReadOnly( true ); | 874 | lse->setReadOnly( true ); |
887 | mCalendar->addEvent( lse ); | 875 | mCalendar->addEvent( lse ); |
888 | } | 876 | } |
889 | 877 | ||
890 | return lse; | 878 | return lse; |
891 | 879 | ||
892 | } | 880 | } |
893 | 881 | ||
894 | // we check, if the to delete event has a id for a profile | 882 | // we check, if the to delete event has a id for a profile |
895 | // if yes, we set this id in the profile to delete | 883 | // if yes, we set this id in the profile to delete |
896 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 884 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
897 | { | 885 | { |
898 | if ( lastSync.count() == 0 ) { | 886 | if ( lastSync.count() == 0 ) { |
899 | //qDebug(" lastSync.count() == 0"); | 887 | //qDebug(" lastSync.count() == 0"); |
900 | return; | 888 | return; |
901 | } | 889 | } |
902 | if ( toDelete->type() == "Journal" ) | 890 | if ( toDelete->type() == "Journal" ) |
903 | return; | 891 | return; |
904 | 892 | ||
905 | Event* eve = lastSync.first(); | 893 | Event* eve = lastSync.first(); |
906 | 894 | ||
907 | while ( eve ) { | 895 | while ( eve ) { |
908 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 896 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
909 | if ( !id.isEmpty() ) { | 897 | if ( !id.isEmpty() ) { |
910 | QString des = eve->description(); | 898 | QString des = eve->description(); |
911 | QString pref = "e"; | 899 | QString pref = "e"; |
912 | if ( toDelete->type() == "Todo" ) | 900 | if ( toDelete->type() == "Todo" ) |
913 | pref = "t"; | 901 | pref = "t"; |
914 | des += pref+ id + ","; | 902 | des += pref+ id + ","; |
915 | eve->setReadOnly( false ); | 903 | eve->setReadOnly( false ); |
916 | eve->setDescription( des ); | 904 | eve->setDescription( des ); |
917 | //qDebug("setdes %s ", des.latin1()); | 905 | //qDebug("setdes %s ", des.latin1()); |
918 | eve->setReadOnly( true ); | 906 | eve->setReadOnly( true ); |
919 | } | 907 | } |
920 | eve = lastSync.next(); | 908 | eve = lastSync.next(); |
921 | } | 909 | } |
922 | 910 | ||
923 | } | 911 | } |
924 | void CalendarView::checkExternalId( Incidence * inc ) | 912 | void CalendarView::checkExternalId( Incidence * inc ) |
925 | { | 913 | { |
926 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 914 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
927 | checkExternSyncEvent( lastSync, inc ); | 915 | checkExternSyncEvent( lastSync, inc ); |
928 | 916 | ||
929 | } | 917 | } |
930 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 918 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
931 | { | 919 | { |
932 | bool syncOK = true; | 920 | bool syncOK = true; |
933 | int addedEvent = 0; | 921 | int addedEvent = 0; |
934 | int addedEventR = 0; | 922 | int addedEventR = 0; |
935 | int deletedEventR = 0; | 923 | int deletedEventR = 0; |
936 | int deletedEventL = 0; | 924 | int deletedEventL = 0; |
937 | int changedLocal = 0; | 925 | int changedLocal = 0; |
938 | int changedRemote = 0; | 926 | int changedRemote = 0; |
939 | //QPtrList<Event> el = local->rawEvents(); | 927 | //QPtrList<Event> el = local->rawEvents(); |
940 | Event* eventR; | 928 | Event* eventR; |
941 | QString uid; | 929 | QString uid; |
942 | int take; | 930 | int take; |
943 | Event* eventL; | 931 | Event* eventL; |
944 | Event* eventRSync; | 932 | Event* eventRSync; |
945 | Event* eventLSync; | 933 | Event* eventLSync; |
946 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 934 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
947 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 935 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
948 | bool fullDateRange = false; | 936 | bool fullDateRange = false; |
949 | local->resetTempSyncStat(); | 937 | local->resetTempSyncStat(); |
950 | mLastCalendarSync = QDateTime::currentDateTime(); | 938 | mLastCalendarSync = QDateTime::currentDateTime(); |
951 | QDateTime modifiedCalendar = mLastCalendarSync;; | 939 | QDateTime modifiedCalendar = mLastCalendarSync;; |
952 | eventLSync = getLastSyncEvent(); | 940 | eventLSync = getLastSyncEvent(); |
953 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 941 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
954 | if ( eventR ) { | 942 | if ( eventR ) { |
955 | eventRSync = (Event*) eventR->clone(); | 943 | eventRSync = (Event*) eventR->clone(); |
956 | remote->deleteEvent(eventR ); | 944 | remote->deleteEvent(eventR ); |
957 | 945 | ||
958 | } else { | 946 | } else { |
959 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 947 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
960 | eventRSync = (Event*)eventLSync->clone(); | 948 | eventRSync = (Event*)eventLSync->clone(); |
961 | } else { | 949 | } else { |
962 | fullDateRange = true; | 950 | fullDateRange = true; |
963 | eventRSync = new Event(); | 951 | eventRSync = new Event(); |
964 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 952 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
965 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 953 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
966 | eventRSync->setDtStart( mLastCalendarSync ); | 954 | eventRSync->setDtStart( mLastCalendarSync ); |
967 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 955 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
968 | eventRSync->setCategories( i18n("SyncEvent") ); | 956 | eventRSync->setCategories( i18n("SyncEvent") ); |
969 | } | 957 | } |
970 | } | 958 | } |
971 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 959 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
972 | fullDateRange = true; | 960 | fullDateRange = true; |
973 | 961 | ||
974 | if ( ! fullDateRange ) { | 962 | if ( ! fullDateRange ) { |
975 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 963 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
976 | 964 | ||
977 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 965 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
978 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 966 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
979 | fullDateRange = true; | 967 | fullDateRange = true; |
980 | } | 968 | } |
981 | } | 969 | } |
982 | if ( fullDateRange ) | 970 | if ( fullDateRange ) |
983 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 971 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
984 | else | 972 | else |
985 | mLastCalendarSync = eventLSync->dtStart(); | 973 | mLastCalendarSync = eventLSync->dtStart(); |
986 | // for resyncing if own file has changed | 974 | // for resyncing if own file has changed |
987 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 975 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
988 | mLastCalendarSync = loadedFileVersion; | 976 | mLastCalendarSync = loadedFileVersion; |
989 | qDebug("setting mLastCalendarSync "); | 977 | qDebug("setting mLastCalendarSync "); |
990 | } | 978 | } |
991 | //qDebug("*************************** "); | 979 | //qDebug("*************************** "); |
992 | qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); | 980 | qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); |
993 | QPtrList<Incidence> er = remote->rawIncidences(); | 981 | QPtrList<Incidence> er = remote->rawIncidences(); |
994 | Incidence* inR = er.first(); | 982 | Incidence* inR = er.first(); |
995 | Incidence* inL; | 983 | Incidence* inL; |
996 | QProgressBar bar( er.count(),0 ); | 984 | QProgressBar bar( er.count(),0 ); |
997 | bar.setCaption (i18n("Syncing - close to abort!") ); | 985 | bar.setCaption (i18n("Syncing - close to abort!") ); |
998 | 986 | ||
999 | int w = 300; | 987 | int w = 300; |
1000 | if ( QApplication::desktop()->width() < 320 ) | 988 | if ( QApplication::desktop()->width() < 320 ) |
1001 | w = 220; | 989 | w = 220; |
1002 | int h = bar.sizeHint().height() ; | 990 | int h = bar.sizeHint().height() ; |
1003 | int dw = QApplication::desktop()->width(); | 991 | int dw = QApplication::desktop()->width(); |
1004 | int dh = QApplication::desktop()->height(); | 992 | int dh = QApplication::desktop()->height(); |
1005 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 993 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1006 | bar.show(); | 994 | bar.show(); |
1007 | int modulo = (er.count()/10)+1; | 995 | int modulo = (er.count()/10)+1; |
1008 | int incCounter = 0; | 996 | int incCounter = 0; |
1009 | while ( inR ) { | 997 | while ( inR ) { |
1010 | if ( ! bar.isVisible() ) | 998 | if ( ! bar.isVisible() ) |
1011 | return false; | 999 | return false; |
1012 | if ( incCounter % modulo == 0 ) | 1000 | if ( incCounter % modulo == 0 ) |
1013 | bar.setProgress( incCounter ); | 1001 | bar.setProgress( incCounter ); |
1014 | ++incCounter; | 1002 | ++incCounter; |
1015 | uid = inR->uid(); | 1003 | uid = inR->uid(); |
1016 | bool skipIncidence = false; | 1004 | bool skipIncidence = false; |
1017 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1005 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1018 | skipIncidence = true; | 1006 | skipIncidence = true; |
1019 | QString idS; | 1007 | QString idS; |
1020 | qApp->processEvents(); | 1008 | qApp->processEvents(); |
1021 | if ( !skipIncidence ) { | 1009 | if ( !skipIncidence ) { |
1022 | inL = local->incidence( uid ); | 1010 | inL = local->incidence( uid ); |
1023 | if ( inL ) { // maybe conflict - same uid in both calendars | 1011 | if ( inL ) { // maybe conflict - same uid in both calendars |
1024 | int maxrev = inL->revision(); | 1012 | int maxrev = inL->revision(); |
1025 | if ( maxrev < inR->revision() ) | 1013 | if ( maxrev < inR->revision() ) |
1026 | maxrev = inR->revision(); | 1014 | maxrev = inR->revision(); |
1027 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1015 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1028 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1016 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1029 | if ( take == 3 ) | 1017 | if ( take == 3 ) |
1030 | return false; | 1018 | return false; |
1031 | if ( take == 1 ) {// take local | 1019 | if ( take == 1 ) {// take local |
1032 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1020 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1033 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1021 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1034 | else | 1022 | else |
1035 | idS = inR->IDStr(); | 1023 | idS = inR->IDStr(); |
1036 | remote->deleteIncidence( inR ); | 1024 | remote->deleteIncidence( inR ); |
1037 | if ( inL->revision() < maxrev ) | 1025 | if ( inL->revision() < maxrev ) |
1038 | inL->setRevision( maxrev ); | 1026 | inL->setRevision( maxrev ); |
1039 | inR = inL->clone(); | 1027 | inR = inL->clone(); |
1040 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1028 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1041 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1029 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1042 | inR->setIDStr( idS ); | 1030 | inR->setIDStr( idS ); |
1043 | remote->addIncidence( inR ); | 1031 | remote->addIncidence( inR ); |
1044 | ++changedRemote; | 1032 | ++changedRemote; |
1045 | } else { | 1033 | } else { |
1046 | if ( inR->revision() < maxrev ) | 1034 | if ( inR->revision() < maxrev ) |
1047 | inR->setRevision( maxrev ); | 1035 | inR->setRevision( maxrev ); |
1048 | idS = inL->IDStr(); | 1036 | idS = inL->IDStr(); |
1049 | local->deleteIncidence( inL ); | 1037 | local->deleteIncidence( inL ); |
1050 | inL = inR->clone(); | 1038 | inL = inR->clone(); |
1051 | inL->setIDStr( idS ); | 1039 | inL->setIDStr( idS ); |
1052 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1040 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1053 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1041 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1054 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1042 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1055 | } | 1043 | } |
1056 | local->addIncidence( inL ); | 1044 | local->addIncidence( inL ); |
1057 | ++changedLocal; | 1045 | ++changedLocal; |
1058 | } | 1046 | } |
1059 | } | 1047 | } |
1060 | } else { // no conflict | 1048 | } else { // no conflict |
1061 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1049 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1062 | QString des = eventLSync->description(); | 1050 | QString des = eventLSync->description(); |
1063 | QString pref = "e"; | 1051 | QString pref = "e"; |
1064 | if ( inR->type() == "Todo" ) | 1052 | if ( inR->type() == "Todo" ) |
1065 | pref = "t"; | 1053 | pref = "t"; |
1066 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1054 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1067 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1055 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1068 | //remote->deleteIncidence( inR ); | 1056 | //remote->deleteIncidence( inR ); |
1069 | ++deletedEventR; | 1057 | ++deletedEventR; |
1070 | } else { | 1058 | } else { |
1071 | inR->setLastModified( modifiedCalendar ); | 1059 | inR->setLastModified( modifiedCalendar ); |
1072 | inL = inR->clone(); | 1060 | inL = inR->clone(); |
1073 | local->addIncidence( inL ); | 1061 | local->addIncidence( inL ); |
1074 | ++addedEvent; | 1062 | ++addedEvent; |
1075 | } | 1063 | } |
1076 | } else { | 1064 | } else { |
1077 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1065 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1078 | inR->setLastModified( modifiedCalendar ); | 1066 | inR->setLastModified( modifiedCalendar ); |
1079 | local->addIncidence( inR->clone() ); | 1067 | local->addIncidence( inR->clone() ); |
1080 | ++addedEvent; | 1068 | ++addedEvent; |
1081 | } else { | 1069 | } else { |
1082 | checkExternSyncEvent(eventRSyncSharp, inR); | 1070 | checkExternSyncEvent(eventRSyncSharp, inR); |
1083 | remote->deleteIncidence( inR ); | 1071 | remote->deleteIncidence( inR ); |
1084 | ++deletedEventR; | 1072 | ++deletedEventR; |
1085 | } | 1073 | } |
1086 | } | 1074 | } |
1087 | } | 1075 | } |
1088 | } | 1076 | } |
1089 | inR = er.next(); | 1077 | inR = er.next(); |
1090 | } | 1078 | } |
1091 | QPtrList<Incidence> el = local->rawIncidences(); | 1079 | QPtrList<Incidence> el = local->rawIncidences(); |
1092 | inL = el.first(); | 1080 | inL = el.first(); |
1093 | modulo = (el.count()/10)+1; | 1081 | modulo = (el.count()/10)+1; |
1094 | bar.setCaption (i18n("Add / remove events") ); | 1082 | bar.setCaption (i18n("Add / remove events") ); |
1095 | bar.setTotalSteps ( el.count() ) ; | 1083 | bar.setTotalSteps ( el.count() ) ; |
1096 | bar.show(); | 1084 | bar.show(); |
1097 | incCounter = 0; | 1085 | incCounter = 0; |
1098 | 1086 | ||
1099 | while ( inL ) { | 1087 | while ( inL ) { |
1100 | 1088 | ||
1101 | qApp->processEvents(); | 1089 | qApp->processEvents(); |
1102 | if ( ! bar.isVisible() ) | 1090 | if ( ! bar.isVisible() ) |
1103 | return false; | 1091 | return false; |
1104 | if ( incCounter % modulo == 0 ) | 1092 | if ( incCounter % modulo == 0 ) |
1105 | bar.setProgress( incCounter ); | 1093 | bar.setProgress( incCounter ); |
1106 | ++incCounter; | 1094 | ++incCounter; |
1107 | uid = inL->uid(); | 1095 | uid = inL->uid(); |
1108 | bool skipIncidence = false; | 1096 | bool skipIncidence = false; |
1109 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1097 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1110 | skipIncidence = true; | 1098 | skipIncidence = true; |
1111 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) | 1099 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) |
1112 | skipIncidence = true; | 1100 | skipIncidence = true; |
1113 | if ( !skipIncidence ) { | 1101 | if ( !skipIncidence ) { |
1114 | inR = remote->incidence( uid ); | 1102 | inR = remote->incidence( uid ); |
1115 | if ( ! inR ) { | 1103 | if ( ! inR ) { |
1116 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1104 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1117 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1105 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1118 | checkExternSyncEvent(eventLSyncSharp, inL); | 1106 | checkExternSyncEvent(eventLSyncSharp, inL); |
1119 | local->deleteIncidence( inL ); | 1107 | local->deleteIncidence( inL ); |
1120 | ++deletedEventL; | 1108 | ++deletedEventL; |
1121 | } else { | 1109 | } else { |
1122 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { | 1110 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1123 | inL->removeID(mCurrentSyncDevice ); | 1111 | inL->removeID(mCurrentSyncDevice ); |
1124 | ++addedEventR; | 1112 | ++addedEventR; |
1125 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1113 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1126 | inL->setLastModified( modifiedCalendar ); | 1114 | inL->setLastModified( modifiedCalendar ); |
1127 | inR = inL->clone(); | 1115 | inR = inL->clone(); |
1128 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1116 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1129 | remote->addIncidence( inR ); | 1117 | remote->addIncidence( inR ); |
1130 | } | 1118 | } |
1131 | } | 1119 | } |
1132 | } else { | 1120 | } else { |
1133 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1121 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1134 | checkExternSyncEvent(eventLSyncSharp, inL); | 1122 | checkExternSyncEvent(eventLSyncSharp, inL); |
1135 | local->deleteIncidence( inL ); | 1123 | local->deleteIncidence( inL ); |
1136 | ++deletedEventL; | 1124 | ++deletedEventL; |
1137 | } else { | 1125 | } else { |
1138 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { | 1126 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1139 | ++addedEventR; | 1127 | ++addedEventR; |
1140 | inL->setLastModified( modifiedCalendar ); | 1128 | inL->setLastModified( modifiedCalendar ); |
1141 | remote->addIncidence( inL->clone() ); | 1129 | remote->addIncidence( inL->clone() ); |
1142 | } | 1130 | } |
1143 | } | 1131 | } |
1144 | } | 1132 | } |
1145 | } | 1133 | } |
1146 | } | 1134 | } |
1147 | inL = el.next(); | 1135 | inL = el.next(); |
1148 | } | 1136 | } |
1149 | int delFut = 0; | 1137 | int delFut = 0; |
1150 | if ( KOPrefs::instance()->mWriteBackInFuture ) { | 1138 | if ( mSyncManager->mWriteBackInFuture ) { |
1151 | er = remote->rawIncidences(); | 1139 | er = remote->rawIncidences(); |
1152 | inR = er.first(); | 1140 | inR = er.first(); |
1153 | QDateTime dt; | 1141 | QDateTime dt; |
1154 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); | 1142 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); |
1155 | QDateTime end = cur.addDays( (KOPrefs::instance()->mWriteBackInFuture +1 ) *7 ); | 1143 | QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 ); |
1156 | while ( inR ) { | 1144 | while ( inR ) { |
1157 | if ( inR->type() == "Todo" ) { | 1145 | if ( inR->type() == "Todo" ) { |
1158 | Todo * t = (Todo*)inR; | 1146 | Todo * t = (Todo*)inR; |
1159 | if ( t->hasDueDate() ) | 1147 | if ( t->hasDueDate() ) |
1160 | dt = t->dtDue(); | 1148 | dt = t->dtDue(); |
1161 | else | 1149 | else |
1162 | dt = cur.addSecs( 62 ); | 1150 | dt = cur.addSecs( 62 ); |
1163 | } | 1151 | } |
1164 | else if (inR->type() == "Event" ) { | 1152 | else if (inR->type() == "Event" ) { |
1165 | bool ok; | 1153 | bool ok; |
1166 | dt = inR->getNextOccurence( cur, &ok ); | 1154 | dt = inR->getNextOccurence( cur, &ok ); |
1167 | if ( !ok ) | 1155 | if ( !ok ) |
1168 | dt = cur.addSecs( -62 ); | 1156 | dt = cur.addSecs( -62 ); |
1169 | } | 1157 | } |
1170 | else | 1158 | else |
1171 | dt = inR->dtStart(); | 1159 | dt = inR->dtStart(); |
1172 | if ( dt < cur || dt > end ) { | 1160 | if ( dt < cur || dt > end ) { |
1173 | remote->deleteIncidence( inR ); | 1161 | remote->deleteIncidence( inR ); |
1174 | ++delFut; | 1162 | ++delFut; |
1175 | } | 1163 | } |
1176 | inR = er.next(); | 1164 | inR = er.next(); |
1177 | } | 1165 | } |
1178 | } | 1166 | } |
1179 | bar.hide(); | 1167 | bar.hide(); |
1180 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1168 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1181 | eventLSync->setReadOnly( false ); | 1169 | eventLSync->setReadOnly( false ); |
1182 | eventLSync->setDtStart( mLastCalendarSync ); | 1170 | eventLSync->setDtStart( mLastCalendarSync ); |
1183 | eventRSync->setDtStart( mLastCalendarSync ); | 1171 | eventRSync->setDtStart( mLastCalendarSync ); |
1184 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1172 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1185 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1173 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1186 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1174 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1187 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1175 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1188 | eventLSync->setReadOnly( true ); | 1176 | eventLSync->setReadOnly( true ); |
1189 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 1177 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
1190 | remote->addEvent( eventRSync ); | 1178 | remote->addEvent( eventRSync ); |
1191 | QString mes; | 1179 | QString mes; |
1192 | 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"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); | 1180 | 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"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); |
1193 | QString delmess; | 1181 | QString delmess; |
1194 | if ( delFut ) { | 1182 | if ( delFut ) { |
1195 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\n"),delFut, KOPrefs::instance()->mWriteBackInFuture ); | 1183 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\n"),delFut, mSyncManager->mWriteBackInFuture ); |
1196 | mes += delmess; | 1184 | mes += delmess; |
1197 | } | 1185 | } |
1198 | if ( KOPrefs::instance()->mShowSyncSummary ) { | 1186 | if ( mSyncManager->mShowSyncSummary ) { |
1199 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); | 1187 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); |
1200 | } | 1188 | } |
1201 | qDebug( mes ); | 1189 | qDebug( mes ); |
1202 | mCalendar->checkAlarmForIncidence( 0, true ); | 1190 | mCalendar->checkAlarmForIncidence( 0, true ); |
1203 | return syncOK; | 1191 | return syncOK; |
1204 | } | 1192 | } |
1205 | 1193 | ||
1206 | void CalendarView::setSyncDevice( QString s ) | 1194 | void CalendarView::setSyncDevice( QString s ) |
1207 | { | 1195 | { |
1208 | mCurrentSyncDevice= s; | 1196 | mCurrentSyncDevice= s; |
1209 | } | 1197 | } |
1210 | void CalendarView::setSyncName( QString s ) | 1198 | void CalendarView::setSyncName( QString s ) |
1211 | { | 1199 | { |
1212 | mCurrentSyncName= s; | 1200 | mCurrentSyncName= s; |
1213 | } | 1201 | } |
1214 | bool CalendarView::syncCalendar(QString filename, int mode) | 1202 | bool CalendarView::syncCalendar(QString filename, int mode) |
1215 | { | 1203 | { |
1216 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1204 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1217 | CalendarLocal* calendar = new CalendarLocal(); | 1205 | CalendarLocal* calendar = new CalendarLocal(); |
1218 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1206 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1219 | FileStorage* storage = new FileStorage( calendar ); | 1207 | FileStorage* storage = new FileStorage( calendar ); |
1220 | bool syncOK = false; | 1208 | bool syncOK = false; |
1221 | storage->setFileName( filename ); | 1209 | storage->setFileName( filename ); |
1222 | // qDebug("loading ... "); | 1210 | // qDebug("loading ... "); |
1223 | if ( storage->load() ) { | 1211 | if ( storage->load() ) { |
1224 | getEventViewerDialog()->setSyncMode( true ); | 1212 | getEventViewerDialog()->setSyncMode( true ); |
1225 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1213 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1226 | getEventViewerDialog()->setSyncMode( false ); | 1214 | getEventViewerDialog()->setSyncMode( false ); |
1227 | if ( syncOK ) { | 1215 | if ( syncOK ) { |
1228 | if ( KOPrefs::instance()->mWriteBackFile ) | 1216 | if ( mSyncManager->mWriteBackFile ) |
1229 | { | 1217 | { |
1230 | storage->setSaveFormat( new ICalFormat() ); | 1218 | storage->setSaveFormat( new ICalFormat() ); |
1231 | storage->save(); | 1219 | storage->save(); |
1232 | } | 1220 | } |
1233 | } | 1221 | } |
1234 | setModified( true ); | 1222 | setModified( true ); |
1235 | } | 1223 | } |
1236 | delete storage; | 1224 | delete storage; |
1237 | delete calendar; | 1225 | delete calendar; |
1238 | if ( syncOK ) | 1226 | if ( syncOK ) |
1239 | updateView(); | 1227 | updateView(); |
1240 | return syncOK; | 1228 | return syncOK; |
1241 | } | 1229 | } |
1242 | void CalendarView::syncPhone() | 1230 | void CalendarView::syncPhone() |
1243 | { | 1231 | { |
1244 | syncExternal( 1 ); | 1232 | //DELETE |
1245 | } | 1233 | } |
1246 | void CalendarView::syncExternal( int mode ) | 1234 | void CalendarView::syncExternal( int mode ) |
1247 | { | 1235 | { |
1248 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1236 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1249 | //mCurrentSyncDevice = "sharp-DTM"; | 1237 | |
1250 | if ( KOPrefs::instance()->mAskForPreferences ) | ||
1251 | edit_sync_options(); | ||
1252 | qApp->processEvents(); | 1238 | qApp->processEvents(); |
1253 | CalendarLocal* calendar = new CalendarLocal(); | 1239 | CalendarLocal* calendar = new CalendarLocal(); |
1254 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1240 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1255 | bool syncOK = false; | 1241 | bool syncOK = false; |
1256 | bool loadSuccess = false; | 1242 | bool loadSuccess = false; |
1257 | PhoneFormat* phoneFormat = 0; | 1243 | PhoneFormat* phoneFormat = 0; |
1258 | #ifndef DESKTOP_VERSION | 1244 | #ifndef DESKTOP_VERSION |
1259 | SharpFormat* sharpFormat = 0; | 1245 | SharpFormat* sharpFormat = 0; |
1260 | if ( mode == 0 ) { // sharp | 1246 | if ( mode == 0 ) { // sharp |
1261 | sharpFormat = new SharpFormat () ; | 1247 | sharpFormat = new SharpFormat () ; |
1262 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1248 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1263 | 1249 | ||
1264 | } else | 1250 | } else |
1265 | #endif | 1251 | #endif |
1266 | if ( mode == 1 ) { // phone | 1252 | if ( mode == 1 ) { // phone |
1267 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1253 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1268 | KOPrefs::instance()->mPhoneDevice, | 1254 | mSyncManager->mPhoneDevice, |
1269 | KOPrefs::instance()->mPhoneConnection, | 1255 | mSyncManager->mPhoneConnection, |
1270 | KOPrefs::instance()->mPhoneModel); | 1256 | mSyncManager->mPhoneModel); |
1271 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1257 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1272 | 1258 | ||
1273 | } else | 1259 | } else |
1274 | return; | 1260 | return; |
1275 | if ( loadSuccess ) { | 1261 | if ( loadSuccess ) { |
1276 | getEventViewerDialog()->setSyncMode( true ); | 1262 | getEventViewerDialog()->setSyncMode( true ); |
1277 | syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); | 1263 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1278 | getEventViewerDialog()->setSyncMode( false ); | 1264 | getEventViewerDialog()->setSyncMode( false ); |
1279 | qApp->processEvents(); | 1265 | qApp->processEvents(); |
1280 | if ( syncOK ) { | 1266 | if ( syncOK ) { |
1281 | if ( KOPrefs::instance()->mWriteBackFile ) | 1267 | if ( mSyncManager->mWriteBackFile ) |
1282 | { | 1268 | { |
1283 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1269 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1284 | Incidence* inc = iL.first(); | 1270 | Incidence* inc = iL.first(); |
1285 | if ( phoneFormat ) { | 1271 | if ( phoneFormat ) { |
1286 | while ( inc ) { | 1272 | while ( inc ) { |
1287 | inc->removeID(mCurrentSyncDevice); | 1273 | inc->removeID(mCurrentSyncDevice); |
1288 | inc = iL.next(); | 1274 | inc = iL.next(); |
1289 | } | 1275 | } |
1290 | } | 1276 | } |
1291 | #ifndef DESKTOP_VERSION | 1277 | #ifndef DESKTOP_VERSION |
1292 | if ( sharpFormat ) | 1278 | if ( sharpFormat ) |
1293 | sharpFormat->save(calendar); | 1279 | sharpFormat->save(calendar); |
1294 | #endif | 1280 | #endif |
1295 | if ( phoneFormat ) | 1281 | if ( phoneFormat ) |
1296 | phoneFormat->save(calendar); | 1282 | phoneFormat->save(calendar); |
1297 | iL = calendar->rawIncidences(); | 1283 | iL = calendar->rawIncidences(); |
1298 | inc = iL.first(); | 1284 | inc = iL.first(); |
1299 | Incidence* loc; | 1285 | Incidence* loc; |
1300 | while ( inc ) { | 1286 | while ( inc ) { |
1301 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1287 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1302 | loc = mCalendar->incidence(inc->uid() ); | 1288 | loc = mCalendar->incidence(inc->uid() ); |
1303 | if ( loc ) { | 1289 | if ( loc ) { |
1304 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1290 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1305 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1291 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1306 | } | 1292 | } |
1307 | } | 1293 | } |
1308 | inc = iL.next(); | 1294 | inc = iL.next(); |
1309 | } | 1295 | } |
1310 | Incidence* lse = getLastSyncEvent(); | 1296 | Incidence* lse = getLastSyncEvent(); |
1311 | if ( lse ) { | 1297 | if ( lse ) { |
1312 | lse->setReadOnly( false ); | 1298 | lse->setReadOnly( false ); |
1313 | lse->setDescription( "" ); | 1299 | lse->setDescription( "" ); |
1314 | lse->setReadOnly( true ); | 1300 | lse->setReadOnly( true ); |
1315 | } | 1301 | } |
1316 | } | 1302 | } |
1317 | } | 1303 | } |
1318 | setModified( true ); | 1304 | setModified( true ); |
1319 | } else { | 1305 | } else { |
1320 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1306 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1321 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1307 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1322 | question, i18n("Ok")) ; | 1308 | question, i18n("Ok")) ; |
1323 | 1309 | ||
1324 | } | 1310 | } |
1325 | delete calendar; | 1311 | delete calendar; |
1326 | updateView(); | 1312 | updateView(); |
1327 | return ;//syncOK; | 1313 | return ;//syncOK; |
1328 | 1314 | ||
1329 | } | 1315 | } |
1330 | void CalendarView::syncSharp() | 1316 | void CalendarView::syncSharp() |
1331 | { | 1317 | { |
1332 | syncExternal( 0 ); | 1318 | //DELETE |
1333 | 1319 | ||
1334 | } | 1320 | } |
1335 | 1321 | ||
1336 | 1322 | ||
1337 | bool CalendarView::importBday() | 1323 | bool CalendarView::importBday() |
1338 | { | 1324 | { |
1339 | #ifndef KORG_NOKABC | 1325 | #ifndef KORG_NOKABC |
1340 | 1326 | ||
1341 | #ifdef DESKTOP_VERSION | 1327 | #ifdef DESKTOP_VERSION |
1342 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1328 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1343 | KABC::AddressBook::Iterator it; | 1329 | KABC::AddressBook::Iterator it; |
1344 | int count = 0; | 1330 | int count = 0; |
1345 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1331 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1346 | ++count; | 1332 | ++count; |
1347 | } | 1333 | } |
1348 | QProgressBar bar(count,0 ); | 1334 | QProgressBar bar(count,0 ); |
1349 | int w = 300; | 1335 | int w = 300; |
1350 | if ( QApplication::desktop()->width() < 320 ) | 1336 | if ( QApplication::desktop()->width() < 320 ) |
1351 | w = 220; | 1337 | w = 220; |
1352 | int h = bar.sizeHint().height() ; | 1338 | int h = bar.sizeHint().height() ; |
1353 | int dw = QApplication::desktop()->width(); | 1339 | int dw = QApplication::desktop()->width(); |
1354 | int dh = QApplication::desktop()->height(); | 1340 | int dh = QApplication::desktop()->height(); |
1355 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1341 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1356 | bar.show(); | 1342 | bar.show(); |
1357 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1343 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1358 | qApp->processEvents(); | 1344 | qApp->processEvents(); |
1359 | count = 0; | 1345 | count = 0; |
1360 | int addCount = 0; | 1346 | int addCount = 0; |
1361 | KCal::Attendee* a = 0; | 1347 | KCal::Attendee* a = 0; |
1362 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1348 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1363 | if ( ! bar.isVisible() ) | 1349 | if ( ! bar.isVisible() ) |
1364 | return false; | 1350 | return false; |
1365 | bar.setProgress( count++ ); | 1351 | bar.setProgress( count++ ); |
1366 | qApp->processEvents(); | 1352 | qApp->processEvents(); |
1367 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1353 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1368 | if ( (*it).birthday().date().isValid() ){ | 1354 | if ( (*it).birthday().date().isValid() ){ |
1369 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1355 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1370 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 1356 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1371 | ++addCount; | 1357 | ++addCount; |
1372 | } | 1358 | } |
1373 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1359 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1374 | if ( anni.isValid() ){ | 1360 | if ( anni.isValid() ){ |
1375 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1361 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1376 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 1362 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1377 | ++addCount; | 1363 | ++addCount; |
1378 | } | 1364 | } |
1379 | } | 1365 | } |
1380 | updateView(); | 1366 | updateView(); |
1381 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1367 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1382 | #else //DESKTOP_VERSION | 1368 | #else //DESKTOP_VERSION |
1383 | 1369 | ||
1384 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 1370 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
1385 | // the result should now arrive through method insertBirthdays | 1371 | // the result should now arrive through method insertBirthdays |
1386 | 1372 | ||
1387 | #endif //DESKTOP_VERSION | 1373 | #endif //DESKTOP_VERSION |
1388 | 1374 | ||
1389 | #endif //KORG_NOKABC | 1375 | #endif //KORG_NOKABC |
1390 | 1376 | ||
1391 | 1377 | ||
1392 | return true; | 1378 | return true; |
1393 | } | 1379 | } |
1394 | 1380 | ||
1395 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 1381 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
1396 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 1382 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
1397 | const QStringList& anniversaryList, const QStringList& realNameList, | 1383 | const QStringList& anniversaryList, const QStringList& realNameList, |
1398 | const QStringList& emailList, const QStringList& assembledNameList, | 1384 | const QStringList& emailList, const QStringList& assembledNameList, |
1399 | const QStringList& uidList) | 1385 | const QStringList& uidList) |
1400 | { | 1386 | { |
1401 | qDebug("CalendarView::insertBirthdays"); | 1387 | qDebug("CalendarView::insertBirthdays"); |
1402 | if (uid == this->name()) | 1388 | if (uid == this->name()) |
1403 | { | 1389 | { |
1404 | int count = birthdayList.count(); | 1390 | int count = birthdayList.count(); |
1405 | int addCount = 0; | 1391 | int addCount = 0; |
1406 | KCal::Attendee* a = 0; | 1392 | KCal::Attendee* a = 0; |
1407 | 1393 | ||
1408 | qDebug("CalView 1 %i", count); | 1394 | qDebug("CalView 1 %i", count); |
1409 | 1395 | ||
1410 | QProgressBar bar(count,0 ); | 1396 | QProgressBar bar(count,0 ); |
1411 | int w = 300; | 1397 | int w = 300; |
1412 | if ( QApplication::desktop()->width() < 320 ) | 1398 | if ( QApplication::desktop()->width() < 320 ) |
1413 | w = 220; | 1399 | w = 220; |
1414 | int h = bar.sizeHint().height() ; | 1400 | int h = bar.sizeHint().height() ; |
1415 | int dw = QApplication::desktop()->width(); | 1401 | int dw = QApplication::desktop()->width(); |
1416 | int dh = QApplication::desktop()->height(); | 1402 | int dh = QApplication::desktop()->height(); |
1417 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1403 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1418 | bar.show(); | 1404 | bar.show(); |
1419 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 1405 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
1420 | qApp->processEvents(); | 1406 | qApp->processEvents(); |
1421 | 1407 | ||
1422 | QDate birthday; | 1408 | QDate birthday; |
1423 | QDate anniversary; | 1409 | QDate anniversary; |
1424 | QString realName; | 1410 | QString realName; |
1425 | QString email; | 1411 | QString email; |
1426 | QString assembledName; | 1412 | QString assembledName; |
1427 | QString uid; | 1413 | QString uid; |
1428 | bool ok = true; | 1414 | bool ok = true; |
1429 | for ( int i = 0; i < count; i++) | 1415 | for ( int i = 0; i < count; i++) |
1430 | { | 1416 | { |
1431 | if ( ! bar.isVisible() ) | 1417 | if ( ! bar.isVisible() ) |
1432 | return; | 1418 | return; |
1433 | bar.setProgress( i ); | 1419 | bar.setProgress( i ); |
1434 | qApp->processEvents(); | 1420 | qApp->processEvents(); |
1435 | 1421 | ||
1436 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 1422 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
1437 | if (!ok) { | 1423 | if (!ok) { |
1438 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 1424 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
1439 | } | 1425 | } |
1440 | 1426 | ||
1441 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 1427 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
1442 | if (!ok) { | 1428 | if (!ok) { |
1443 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 1429 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
1444 | } | 1430 | } |
1445 | realName = realNameList[i]; | 1431 | realName = realNameList[i]; |
1446 | email = emailList[i]; | 1432 | email = emailList[i]; |
1447 | assembledName = assembledNameList[i]; | 1433 | assembledName = assembledNameList[i]; |
1448 | uid = uidList[i]; | 1434 | uid = uidList[i]; |
1449 | //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() ); | 1435 | //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() ); |
1450 | 1436 | ||
1451 | if ( birthday.isValid() ){ | 1437 | if ( birthday.isValid() ){ |
1452 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1438 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1453 | KCal::Attendee::ReqParticipant,uid) ; | 1439 | KCal::Attendee::ReqParticipant,uid) ; |
1454 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 1440 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
1455 | ++addCount; | 1441 | ++addCount; |
1456 | } | 1442 | } |
1457 | 1443 | ||
1458 | if ( anniversary.isValid() ){ | 1444 | if ( anniversary.isValid() ){ |
1459 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1445 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1460 | KCal::Attendee::ReqParticipant,uid) ; | 1446 | KCal::Attendee::ReqParticipant,uid) ; |
1461 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 1447 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
1462 | ++addCount; | 1448 | ++addCount; |
1463 | } | 1449 | } |
1464 | } | 1450 | } |
1465 | 1451 | ||
1466 | updateView(); | 1452 | updateView(); |
1467 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1453 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1468 | 1454 | ||
1469 | } | 1455 | } |
1470 | 1456 | ||
1471 | } | 1457 | } |
1472 | 1458 | ||
1473 | 1459 | ||
1474 | 1460 | ||
1475 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1461 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1476 | { | 1462 | { |
1477 | //qDebug("addAnni "); | 1463 | //qDebug("addAnni "); |
1478 | Event * ev = new Event(); | 1464 | Event * ev = new Event(); |
1479 | if ( a ) { | 1465 | if ( a ) { |
1480 | ev->addAttendee( a ); | 1466 | ev->addAttendee( a ); |
1481 | } | 1467 | } |
1482 | QString kind; | 1468 | QString kind; |
1483 | if ( birthday ) | 1469 | if ( birthday ) |
1484 | kind = i18n( "Birthday" ); | 1470 | kind = i18n( "Birthday" ); |
1485 | else | 1471 | else |
1486 | kind = i18n( "Anniversary" ); | 1472 | kind = i18n( "Anniversary" ); |
1487 | ev->setSummary( name + " - " + kind ); | 1473 | ev->setSummary( name + " - " + kind ); |
1488 | ev->setOrganizer( "nobody@nowhere" ); | 1474 | ev->setOrganizer( "nobody@nowhere" ); |
1489 | ev->setCategories( kind ); | 1475 | ev->setCategories( kind ); |
1490 | ev->setDtStart( QDateTime(date) ); | 1476 | ev->setDtStart( QDateTime(date) ); |
1491 | ev->setDtEnd( QDateTime(date) ); | 1477 | ev->setDtEnd( QDateTime(date) ); |
1492 | ev->setFloats( true ); | 1478 | ev->setFloats( true ); |
1493 | Recurrence * rec = ev->recurrence(); | 1479 | Recurrence * rec = ev->recurrence(); |
1494 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1480 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1495 | rec->addYearlyNum( date.month() ); | 1481 | rec->addYearlyNum( date.month() ); |
1496 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1482 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1497 | delete ev; | 1483 | delete ev; |
1498 | return false; | 1484 | return false; |
1499 | } | 1485 | } |
1500 | return true; | 1486 | return true; |
1501 | 1487 | ||
1502 | } | 1488 | } |
1503 | bool CalendarView::importQtopia( const QString &categories, | 1489 | bool CalendarView::importQtopia( const QString &categories, |
1504 | const QString &datebook, | 1490 | const QString &datebook, |
1505 | const QString &todolist ) | 1491 | const QString &todolist ) |
1506 | { | 1492 | { |
1507 | 1493 | ||
1508 | QtopiaFormat qtopiaFormat; | 1494 | QtopiaFormat qtopiaFormat; |
1509 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1495 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1510 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 1496 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
1511 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 1497 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
1512 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 1498 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
1513 | 1499 | ||
1514 | updateView(); | 1500 | updateView(); |
1515 | return true; | 1501 | return true; |
1516 | 1502 | ||
1517 | #if 0 | 1503 | #if 0 |
1518 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 1504 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
1519 | mCurrentSyncDevice = "qtopia-XML"; | 1505 | mCurrentSyncDevice = "qtopia-XML"; |
1520 | if ( KOPrefs::instance()->mAskForPreferences ) | 1506 | if ( mSyncManager->mAskForPreferences ) |
1521 | edit_sync_options(); | 1507 | edit_sync_options(); |
1522 | qApp->processEvents(); | 1508 | qApp->processEvents(); |
1523 | CalendarLocal* calendar = new CalendarLocal(); | 1509 | CalendarLocal* calendar = new CalendarLocal(); |
1524 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1510 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1525 | bool syncOK = false; | 1511 | bool syncOK = false; |
1526 | QtopiaFormat qtopiaFormat; | 1512 | QtopiaFormat qtopiaFormat; |
1527 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1513 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1528 | bool loadOk = true; | 1514 | bool loadOk = true; |
1529 | if ( !categories.isEmpty() ) | 1515 | if ( !categories.isEmpty() ) |
1530 | loadOk = qtopiaFormat.load( calendar, categories ); | 1516 | loadOk = qtopiaFormat.load( calendar, categories ); |
1531 | if ( loadOk && !datebook.isEmpty() ) | 1517 | if ( loadOk && !datebook.isEmpty() ) |
1532 | loadOk = qtopiaFormat.load( calendar, datebook ); | 1518 | loadOk = qtopiaFormat.load( calendar, datebook ); |
1533 | if ( loadOk && !todolist.isEmpty() ) | 1519 | if ( loadOk && !todolist.isEmpty() ) |
1534 | loadOk = qtopiaFormat.load( calendar, todolist ); | 1520 | loadOk = qtopiaFormat.load( calendar, todolist ); |
1535 | 1521 | ||
1536 | if ( loadOk ) { | 1522 | if ( loadOk ) { |
1537 | getEventViewerDialog()->setSyncMode( true ); | 1523 | getEventViewerDialog()->setSyncMode( true ); |
1538 | syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); | 1524 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1539 | getEventViewerDialog()->setSyncMode( false ); | 1525 | getEventViewerDialog()->setSyncMode( false ); |
1540 | qApp->processEvents(); | 1526 | qApp->processEvents(); |
1541 | if ( syncOK ) { | 1527 | if ( syncOK ) { |
1542 | if ( KOPrefs::instance()->mWriteBackFile ) | 1528 | if ( mSyncManager->mWriteBackFile ) |
1543 | { | 1529 | { |
1544 | // write back XML file | 1530 | // write back XML file |
1545 | 1531 | ||
1546 | } | 1532 | } |
1547 | setModified( true ); | 1533 | setModified( true ); |
1548 | } | 1534 | } |
1549 | } else { | 1535 | } else { |
1550 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 1536 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
1551 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 1537 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
1552 | question, i18n("Ok")) ; | 1538 | question, i18n("Ok")) ; |
1553 | } | 1539 | } |
1554 | delete calendar; | 1540 | delete calendar; |
1555 | updateView(); | 1541 | updateView(); |
1556 | return syncOK; | 1542 | return syncOK; |
1557 | 1543 | ||
1558 | 1544 | ||
1559 | #endif | 1545 | #endif |
1560 | 1546 | ||
1561 | } | 1547 | } |
1562 | 1548 | ||
1563 | void CalendarView::setSyncEventsReadOnly() | 1549 | void CalendarView::setSyncEventsReadOnly() |
1564 | { | 1550 | { |
1565 | Event * ev; | 1551 | Event * ev; |
1566 | QPtrList<Event> eL = mCalendar->rawEvents(); | 1552 | QPtrList<Event> eL = mCalendar->rawEvents(); |
1567 | ev = eL.first(); | 1553 | ev = eL.first(); |
1568 | while ( ev ) { | 1554 | while ( ev ) { |
1569 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) | 1555 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) |
1570 | ev->setReadOnly( true ); | 1556 | ev->setReadOnly( true ); |
1571 | ev = eL.next(); | 1557 | ev = eL.next(); |
1572 | } | 1558 | } |
1573 | } | 1559 | } |
1574 | bool CalendarView::openCalendar(QString filename, bool merge) | 1560 | bool CalendarView::openCalendar(QString filename, bool merge) |
1575 | { | 1561 | { |
1576 | 1562 | ||
1577 | if (filename.isEmpty()) { | 1563 | if (filename.isEmpty()) { |
1578 | return false; | 1564 | return false; |
1579 | } | 1565 | } |
1580 | 1566 | ||
1581 | if (!QFile::exists(filename)) { | 1567 | if (!QFile::exists(filename)) { |
1582 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 1568 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
1583 | return false; | 1569 | return false; |
1584 | } | 1570 | } |
1585 | 1571 | ||
1586 | globalFlagBlockAgenda = 1; | 1572 | globalFlagBlockAgenda = 1; |
1587 | if (!merge) mCalendar->close(); | 1573 | if (!merge) mCalendar->close(); |
1588 | 1574 | ||
1589 | mStorage->setFileName( filename ); | 1575 | mStorage->setFileName( filename ); |
1590 | 1576 | ||
1591 | if ( mStorage->load() ) { | 1577 | if ( mStorage->load() ) { |
1592 | if ( merge ) ;//setModified( true ); | 1578 | if ( merge ) ;//setModified( true ); |
1593 | else { | 1579 | else { |
1594 | //setModified( true ); | 1580 | //setModified( true ); |
1595 | mViewManager->setDocumentId( filename ); | 1581 | mViewManager->setDocumentId( filename ); |
1596 | mDialogManager->setDocumentId( filename ); | 1582 | mDialogManager->setDocumentId( filename ); |
1597 | mTodoList->setDocumentId( filename ); | 1583 | mTodoList->setDocumentId( filename ); |
1598 | } | 1584 | } |
1599 | globalFlagBlockAgenda = 2; | 1585 | globalFlagBlockAgenda = 2; |
1600 | // if ( getLastSyncEvent() ) | 1586 | // if ( getLastSyncEvent() ) |
1601 | // getLastSyncEvent()->setReadOnly( true ); | 1587 | // getLastSyncEvent()->setReadOnly( true ); |
1602 | mCalendar->reInitAlarmSettings(); | 1588 | mCalendar->reInitAlarmSettings(); |
1603 | setSyncEventsReadOnly(); | 1589 | setSyncEventsReadOnly(); |
1604 | updateUnmanagedViews(); | 1590 | updateUnmanagedViews(); |
1605 | updateView(); | 1591 | updateView(); |
1606 | setLoadedFileVersion( QDateTime::currentDateTime().addSecs( -1 )); | 1592 | setLoadedFileVersion( QDateTime::currentDateTime().addSecs( -1 )); |
1607 | if ( filename != MainWindow::defaultFileName() ) { | 1593 | if ( filename != MainWindow::defaultFileName() ) { |
1608 | saveCalendar( MainWindow::defaultFileName() ); | 1594 | saveCalendar( MainWindow::defaultFileName() ); |
1609 | watchSavedFile(); | 1595 | watchSavedFile(); |
1610 | } | 1596 | } |
1611 | return true; | 1597 | return true; |
1612 | } else { | 1598 | } else { |
1613 | // while failing to load, the calendar object could | 1599 | // while failing to load, the calendar object could |
1614 | // have become partially populated. Clear it out. | 1600 | // have become partially populated. Clear it out. |
1615 | if ( !merge ) { | 1601 | if ( !merge ) { |
1616 | mCalendar->close(); | 1602 | mCalendar->close(); |
1617 | mViewManager->setDocumentId( filename ); | 1603 | mViewManager->setDocumentId( filename ); |
1618 | mDialogManager->setDocumentId( filename ); | 1604 | mDialogManager->setDocumentId( filename ); |
1619 | mTodoList->setDocumentId( filename ); | 1605 | mTodoList->setDocumentId( filename ); |
1620 | } | 1606 | } |
1621 | 1607 | ||
1622 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 1608 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
1623 | 1609 | ||
1624 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 1610 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
1625 | globalFlagBlockAgenda = 2; | 1611 | globalFlagBlockAgenda = 2; |
1626 | mCalendar->reInitAlarmSettings(); | 1612 | mCalendar->reInitAlarmSettings(); |
1627 | setSyncEventsReadOnly(); | 1613 | setSyncEventsReadOnly(); |
1628 | updateUnmanagedViews(); | 1614 | updateUnmanagedViews(); |
1629 | updateView(); | 1615 | updateView(); |
1630 | } | 1616 | } |
1631 | return false; | 1617 | return false; |
1632 | } | 1618 | } |
1633 | void CalendarView::showOpenError() | 1619 | void CalendarView::showOpenError() |
1634 | { | 1620 | { |
1635 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 1621 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
1636 | } | 1622 | } |
1637 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 1623 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
1638 | { | 1624 | { |
1639 | loadedFileVersion = dt; | 1625 | loadedFileVersion = dt; |
1640 | } | 1626 | } |
1641 | bool CalendarView::checkFileChanged(QString fn) | 1627 | bool CalendarView::checkFileChanged(QString fn) |
1642 | { | 1628 | { |
1643 | QFileInfo finf ( fn ); | 1629 | QFileInfo finf ( fn ); |
1644 | if ( !finf.exists() ) | 1630 | if ( !finf.exists() ) |
1645 | return true; | 1631 | return true; |
1646 | QDateTime dt = finf.lastModified (); | 1632 | QDateTime dt = finf.lastModified (); |
1647 | if ( dt <= loadedFileVersion ) | 1633 | if ( dt <= loadedFileVersion ) |
1648 | return false; | 1634 | return false; |
1649 | return true; | 1635 | return true; |
1650 | 1636 | ||
1651 | } | 1637 | } |
1652 | void CalendarView::watchSavedFile() | 1638 | void CalendarView::watchSavedFile() |
1653 | { | 1639 | { |
1654 | QFileInfo finf ( MainWindow::defaultFileName()); | 1640 | QFileInfo finf ( MainWindow::defaultFileName()); |
1655 | if ( !finf.exists() ) | 1641 | if ( !finf.exists() ) |
1656 | return; | 1642 | return; |
1657 | QDateTime dt = finf.lastModified (); | 1643 | QDateTime dt = finf.lastModified (); |
1658 | if ( dt < loadedFileVersion ) { | 1644 | if ( dt < loadedFileVersion ) { |
1659 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 1645 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
1660 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 1646 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
1661 | return; | 1647 | return; |
1662 | } | 1648 | } |
1663 | loadedFileVersion = dt; | 1649 | loadedFileVersion = dt; |
1664 | } | 1650 | } |
1665 | 1651 | ||
1666 | bool CalendarView::checkFileVersion(QString fn) | 1652 | bool CalendarView::checkFileVersion(QString fn) |
1667 | { | 1653 | { |
1668 | QFileInfo finf ( fn ); | 1654 | QFileInfo finf ( fn ); |
1669 | if ( !finf.exists() ) | 1655 | if ( !finf.exists() ) |
1670 | return true; | 1656 | return true; |
1671 | QDateTime dt = finf.lastModified (); | 1657 | QDateTime dt = finf.lastModified (); |
1672 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); | 1658 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); |
1673 | //qDebug("file on disk version %s",dt.toString().latin1()); | 1659 | //qDebug("file on disk version %s",dt.toString().latin1()); |
1674 | if ( dt <= loadedFileVersion ) | 1660 | if ( dt <= loadedFileVersion ) |
1675 | return true; | 1661 | return true; |
1676 | 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)) , | 1662 | 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)) , |
1677 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 1663 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
1678 | i18n("Sync+save")); | 1664 | i18n("Sync+save")); |
1679 | 1665 | ||
1680 | if ( km == KMessageBox::Cancel ) | 1666 | if ( km == KMessageBox::Cancel ) |
1681 | return false; | 1667 | return false; |
1682 | if ( km == KMessageBox::Yes ) | 1668 | if ( km == KMessageBox::Yes ) |
1683 | return true; | 1669 | return true; |
1684 | 1670 | ||
1685 | setSyncDevice("deleteaftersync" ); | 1671 | setSyncDevice("deleteaftersync" ); |
1686 | KOPrefs::instance()->mAskForPreferences = true; | 1672 | mSyncManager->mAskForPreferences = true; |
1687 | KOPrefs::instance()->mSyncAlgoPrefs = 3; | 1673 | mSyncManager->mSyncAlgoPrefs = 3; |
1688 | KOPrefs::instance()->mWriteBackFile = false; | 1674 | mSyncManager->mWriteBackFile = false; |
1689 | KOPrefs::instance()->mWriteBackExistingOnly = false; | 1675 | mSyncManager->mWriteBackExistingOnly = false; |
1690 | KOPrefs::instance()->mShowSyncSummary = false; | 1676 | mSyncManager->mShowSyncSummary = false; |
1691 | syncCalendar( fn, 3 ); | 1677 | syncCalendar( fn, 3 ); |
1692 | Event * e = getLastSyncEvent(); | 1678 | Event * e = getLastSyncEvent(); |
1693 | mCalendar->deleteEvent ( e ); | 1679 | mCalendar->deleteEvent ( e ); |
1694 | updateView(); | 1680 | updateView(); |
1695 | return true; | 1681 | return true; |
1696 | } | 1682 | } |
1697 | 1683 | ||
1698 | bool CalendarView::saveCalendar( QString filename ) | 1684 | bool CalendarView::saveCalendar( QString filename ) |
1699 | { | 1685 | { |
1700 | 1686 | ||
1701 | // Store back all unsaved data into calendar object | 1687 | // Store back all unsaved data into calendar object |
1702 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 1688 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
1703 | if ( mViewManager->currentView() ) | 1689 | if ( mViewManager->currentView() ) |
1704 | mViewManager->currentView()->flushView(); | 1690 | mViewManager->currentView()->flushView(); |
1705 | 1691 | ||
1706 | //mStorage->setFileName( filename ); | 1692 | //mStorage->setFileName( filename ); |
1707 | 1693 | ||
1708 | mStorage->setSaveFormat( new ICalFormat() ); | 1694 | mStorage->setSaveFormat( new ICalFormat() ); |
1709 | mStorage->setFileName( filename ); | 1695 | mStorage->setFileName( filename ); |
1710 | bool success; | 1696 | bool success; |
1711 | success = mStorage->save(); | 1697 | success = mStorage->save(); |
1712 | if ( !success ) { | 1698 | if ( !success ) { |
1713 | return false; | 1699 | return false; |
1714 | } | 1700 | } |
1715 | 1701 | ||
1716 | return true; | 1702 | return true; |
1717 | } | 1703 | } |
1718 | 1704 | ||
1719 | void CalendarView::closeCalendar() | 1705 | void CalendarView::closeCalendar() |
1720 | { | 1706 | { |
1721 | 1707 | ||
1722 | // child windows no longer valid | 1708 | // child windows no longer valid |
1723 | emit closingDown(); | 1709 | emit closingDown(); |
1724 | 1710 | ||
1725 | mCalendar->close(); | 1711 | mCalendar->close(); |
1726 | setModified(false); | 1712 | setModified(false); |
1727 | updateView(); | 1713 | updateView(); |
1728 | } | 1714 | } |
1729 | 1715 | ||
1730 | void CalendarView::archiveCalendar() | 1716 | void CalendarView::archiveCalendar() |
1731 | { | 1717 | { |
1732 | mDialogManager->showArchiveDialog(); | 1718 | mDialogManager->showArchiveDialog(); |
1733 | } | 1719 | } |
1734 | 1720 | ||
1735 | 1721 | ||
1736 | void CalendarView::readSettings() | 1722 | void CalendarView::readSettings() |
1737 | { | 1723 | { |
1738 | 1724 | ||
1739 | 1725 | ||
1740 | // mViewManager->showAgendaView(); | 1726 | // mViewManager->showAgendaView(); |
1741 | QString str; | 1727 | QString str; |
1742 | //qDebug("CalendarView::readSettings() "); | 1728 | //qDebug("CalendarView::readSettings() "); |
1743 | // read settings from the KConfig, supplying reasonable | 1729 | // read settings from the KConfig, supplying reasonable |
1744 | // defaults where none are to be found | 1730 | // defaults where none are to be found |
1745 | KConfig *config = KOGlobals::config(); | 1731 | KConfig *config = KOGlobals::config(); |
1746 | #ifndef KORG_NOSPLITTER | 1732 | #ifndef KORG_NOSPLITTER |
1747 | config->setGroup("KOrganizer Geometry"); | 1733 | config->setGroup("KOrganizer Geometry"); |
1748 | 1734 | ||
1749 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 1735 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
1750 | if (sizes.count() != 2) { | 1736 | if (sizes.count() != 2) { |
1751 | sizes << mDateNavigator->minimumSizeHint().width(); | 1737 | sizes << mDateNavigator->minimumSizeHint().width(); |
1752 | sizes << 300; | 1738 | sizes << 300; |
1753 | } | 1739 | } |
1754 | mPanner->setSizes(sizes); | 1740 | mPanner->setSizes(sizes); |
1755 | 1741 | ||
1756 | sizes = config->readIntListEntry("Separator2"); | 1742 | sizes = config->readIntListEntry("Separator2"); |
1757 | if ( ( mResourceView && sizes.count() == 4 ) || | 1743 | if ( ( mResourceView && sizes.count() == 4 ) || |
1758 | ( !mResourceView && sizes.count() == 3 ) ) { | 1744 | ( !mResourceView && sizes.count() == 3 ) ) { |
1759 | mLeftSplitter->setSizes(sizes); | 1745 | mLeftSplitter->setSizes(sizes); |
1760 | } | 1746 | } |
1761 | #endif | 1747 | #endif |
1762 | globalFlagBlockAgenda = 1; | 1748 | globalFlagBlockAgenda = 1; |
1763 | mViewManager->showAgendaView(); | 1749 | mViewManager->showAgendaView(); |
1764 | //mViewManager->readSettings( config ); | 1750 | //mViewManager->readSettings( config ); |
1765 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 1751 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
1766 | readFilterSettings(config); | 1752 | readFilterSettings(config); |
1767 | config->setGroup( "Views" ); | 1753 | config->setGroup( "Views" ); |
1768 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 1754 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
1769 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 1755 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
1770 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 1756 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
1771 | else mNavigator->selectDates( dateCount ); | 1757 | else mNavigator->selectDates( dateCount ); |
1772 | // mViewManager->readSettings( config ); | 1758 | // mViewManager->readSettings( config ); |
1773 | updateConfig(); | 1759 | updateConfig(); |
1774 | globalFlagBlockAgenda = 2; | 1760 | globalFlagBlockAgenda = 2; |
1775 | mViewManager->readSettings( config ); | 1761 | mViewManager->readSettings( config ); |
1776 | #ifdef DESKTOP_VERSION | 1762 | #ifdef DESKTOP_VERSION |
1777 | config->setGroup("WidgetLayout"); | 1763 | config->setGroup("WidgetLayout"); |
1778 | QStringList list; | 1764 | QStringList list; |
1779 | list = config->readListEntry("MainLayout"); | 1765 | list = config->readListEntry("MainLayout"); |
1780 | int x,y,w,h; | 1766 | int x,y,w,h; |
1781 | if ( ! list.isEmpty() ) { | 1767 | if ( ! list.isEmpty() ) { |
1782 | x = list[0].toInt(); | 1768 | x = list[0].toInt(); |
1783 | y = list[1].toInt(); | 1769 | y = list[1].toInt(); |
1784 | w = list[2].toInt(); | 1770 | w = list[2].toInt(); |
1785 | h = list[3].toInt(); | 1771 | h = list[3].toInt(); |
1786 | topLevelWidget()->setGeometry(x,y,w,h); | 1772 | topLevelWidget()->setGeometry(x,y,w,h); |
1787 | 1773 | ||
1788 | } else { | 1774 | } else { |
1789 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 1775 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
1790 | } | 1776 | } |
1791 | list = config->readListEntry("EditEventLayout"); | 1777 | list = config->readListEntry("EditEventLayout"); |
1792 | if ( ! list.isEmpty() ) { | 1778 | if ( ! list.isEmpty() ) { |
1793 | x = list[0].toInt(); | 1779 | x = list[0].toInt(); |
1794 | y = list[1].toInt(); | 1780 | y = list[1].toInt(); |
1795 | w = list[2].toInt(); | 1781 | w = list[2].toInt(); |
1796 | h = list[3].toInt(); | 1782 | h = list[3].toInt(); |
1797 | mEventEditor->setGeometry(x,y,w,h); | 1783 | mEventEditor->setGeometry(x,y,w,h); |
1798 | 1784 | ||
1799 | } | 1785 | } |
1800 | list = config->readListEntry("EditTodoLayout"); | 1786 | list = config->readListEntry("EditTodoLayout"); |
1801 | if ( ! list.isEmpty() ) { | 1787 | if ( ! list.isEmpty() ) { |
1802 | x = list[0].toInt(); | 1788 | x = list[0].toInt(); |
1803 | y = list[1].toInt(); | 1789 | y = list[1].toInt(); |
1804 | w = list[2].toInt(); | 1790 | w = list[2].toInt(); |
1805 | h = list[3].toInt(); | 1791 | h = list[3].toInt(); |
1806 | mTodoEditor->setGeometry(x,y,w,h); | 1792 | mTodoEditor->setGeometry(x,y,w,h); |
1807 | 1793 | ||
1808 | } | 1794 | } |
1809 | list = config->readListEntry("ViewerLayout"); | 1795 | list = config->readListEntry("ViewerLayout"); |
1810 | if ( ! list.isEmpty() ) { | 1796 | if ( ! list.isEmpty() ) { |
1811 | x = list[0].toInt(); | 1797 | x = list[0].toInt(); |
1812 | y = list[1].toInt(); | 1798 | y = list[1].toInt(); |
1813 | w = list[2].toInt(); | 1799 | w = list[2].toInt(); |
1814 | h = list[3].toInt(); | 1800 | h = list[3].toInt(); |
1815 | getEventViewerDialog()->setGeometry(x,y,w,h); | 1801 | getEventViewerDialog()->setGeometry(x,y,w,h); |
1816 | } | 1802 | } |
1817 | #endif | 1803 | #endif |
1818 | 1804 | ||
1819 | } | 1805 | } |
1820 | 1806 | ||
1821 | 1807 | ||
1822 | void CalendarView::writeSettings() | 1808 | void CalendarView::writeSettings() |
1823 | { | 1809 | { |
1824 | // kdDebug() << "CalendarView::writeSettings" << endl; | 1810 | // kdDebug() << "CalendarView::writeSettings" << endl; |
1825 | 1811 | ||
1826 | KConfig *config = KOGlobals::config(); | 1812 | KConfig *config = KOGlobals::config(); |
1827 | 1813 | ||
1828 | #ifndef KORG_NOSPLITTER | 1814 | #ifndef KORG_NOSPLITTER |
1829 | config->setGroup("KOrganizer Geometry"); | 1815 | config->setGroup("KOrganizer Geometry"); |
1830 | 1816 | ||
1831 | QValueList<int> list = mPanner->sizes(); | 1817 | QValueList<int> list = mPanner->sizes(); |
1832 | config->writeEntry("Separator1",list); | 1818 | config->writeEntry("Separator1",list); |
1833 | 1819 | ||
1834 | list = mLeftSplitter->sizes(); | 1820 | list = mLeftSplitter->sizes(); |
1835 | config->writeEntry("Separator2",list); | 1821 | config->writeEntry("Separator2",list); |
1836 | #endif | 1822 | #endif |
1837 | 1823 | ||
1838 | mViewManager->writeSettings( config ); | 1824 | mViewManager->writeSettings( config ); |
1839 | mTodoList->saveLayout(config,QString("Todo Layout")); | 1825 | mTodoList->saveLayout(config,QString("Todo Layout")); |
1840 | mDialogManager->writeSettings( config ); | 1826 | mDialogManager->writeSettings( config ); |
1841 | //KOPrefs::instance()->usrWriteConfig(); | 1827 | //KOPrefs::instance()->usrWriteConfig(); |
1842 | KOPrefs::instance()->writeConfig(); | 1828 | KOPrefs::instance()->writeConfig(); |
1843 | 1829 | ||
1844 | writeFilterSettings(config); | 1830 | writeFilterSettings(config); |
1845 | 1831 | ||
1846 | config->setGroup( "Views" ); | 1832 | config->setGroup( "Views" ); |
1847 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 1833 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
1848 | 1834 | ||
1849 | #ifdef DESKTOP_VERSION | 1835 | #ifdef DESKTOP_VERSION |
1850 | config->setGroup("WidgetLayout"); | 1836 | config->setGroup("WidgetLayout"); |
1851 | QStringList list ;//= config->readListEntry("MainLayout"); | 1837 | QStringList list ;//= config->readListEntry("MainLayout"); |
1852 | int x,y,w,h; | 1838 | int x,y,w,h; |
1853 | QWidget* wid; | 1839 | QWidget* wid; |
1854 | wid = topLevelWidget(); | 1840 | wid = topLevelWidget(); |
1855 | x = wid->geometry().x(); | 1841 | x = wid->geometry().x(); |
1856 | y = wid->geometry().y(); | 1842 | y = wid->geometry().y(); |
1857 | w = wid->width(); | 1843 | w = wid->width(); |
1858 | h = wid->height(); | 1844 | h = wid->height(); |
1859 | list.clear(); | 1845 | list.clear(); |
1860 | list << QString::number( x ); | 1846 | list << QString::number( x ); |
1861 | list << QString::number( y ); | 1847 | list << QString::number( y ); |
1862 | list << QString::number( w ); | 1848 | list << QString::number( w ); |
1863 | list << QString::number( h ); | 1849 | list << QString::number( h ); |
1864 | config->writeEntry("MainLayout",list ); | 1850 | config->writeEntry("MainLayout",list ); |
1865 | 1851 | ||
1866 | wid = mEventEditor; | 1852 | wid = mEventEditor; |
1867 | x = wid->geometry().x(); | 1853 | x = wid->geometry().x(); |
1868 | y = wid->geometry().y(); | 1854 | y = wid->geometry().y(); |
1869 | w = wid->width(); | 1855 | w = wid->width(); |
1870 | h = wid->height(); | 1856 | h = wid->height(); |
1871 | list.clear(); | 1857 | list.clear(); |
1872 | list << QString::number( x ); | 1858 | list << QString::number( x ); |
1873 | list << QString::number( y ); | 1859 | list << QString::number( y ); |
1874 | list << QString::number( w ); | 1860 | list << QString::number( w ); |
1875 | list << QString::number( h ); | 1861 | list << QString::number( h ); |
1876 | config->writeEntry("EditEventLayout",list ); | 1862 | config->writeEntry("EditEventLayout",list ); |
1877 | 1863 | ||
1878 | wid = mTodoEditor; | 1864 | wid = mTodoEditor; |
1879 | x = wid->geometry().x(); | 1865 | x = wid->geometry().x(); |
1880 | y = wid->geometry().y(); | 1866 | y = wid->geometry().y(); |
1881 | w = wid->width(); | 1867 | w = wid->width(); |
1882 | h = wid->height(); | 1868 | h = wid->height(); |
1883 | list.clear(); | 1869 | list.clear(); |
1884 | list << QString::number( x ); | 1870 | list << QString::number( x ); |
1885 | list << QString::number( y ); | 1871 | list << QString::number( y ); |
1886 | list << QString::number( w ); | 1872 | list << QString::number( w ); |
1887 | list << QString::number( h ); | 1873 | list << QString::number( h ); |
1888 | config->writeEntry("EditTodoLayout",list ); | 1874 | config->writeEntry("EditTodoLayout",list ); |
1889 | wid = getEventViewerDialog(); | 1875 | wid = getEventViewerDialog(); |
1890 | x = wid->geometry().x(); | 1876 | x = wid->geometry().x(); |
1891 | y = wid->geometry().y(); | 1877 | y = wid->geometry().y(); |
1892 | w = wid->width(); | 1878 | w = wid->width(); |
1893 | h = wid->height(); | 1879 | h = wid->height(); |
1894 | list.clear(); | 1880 | list.clear(); |
1895 | list << QString::number( x ); | 1881 | list << QString::number( x ); |
1896 | list << QString::number( y ); | 1882 | list << QString::number( y ); |
1897 | list << QString::number( w ); | 1883 | list << QString::number( w ); |
1898 | list << QString::number( h ); | 1884 | list << QString::number( h ); |
1899 | config->writeEntry("ViewerLayout",list ); | 1885 | config->writeEntry("ViewerLayout",list ); |
1900 | wid = mDialogManager->getSearchDialog(); | 1886 | wid = mDialogManager->getSearchDialog(); |
1901 | if ( wid ) { | 1887 | if ( wid ) { |
1902 | x = wid->geometry().x(); | 1888 | x = wid->geometry().x(); |
1903 | y = wid->geometry().y(); | 1889 | y = wid->geometry().y(); |
1904 | w = wid->width(); | 1890 | w = wid->width(); |
1905 | h = wid->height(); | 1891 | h = wid->height(); |
1906 | list.clear(); | 1892 | list.clear(); |
1907 | list << QString::number( x ); | 1893 | list << QString::number( x ); |
1908 | list << QString::number( y ); | 1894 | list << QString::number( y ); |
1909 | list << QString::number( w ); | 1895 | list << QString::number( w ); |
1910 | list << QString::number( h ); | 1896 | list << QString::number( h ); |
1911 | config->writeEntry("SearchLayout",list ); | 1897 | config->writeEntry("SearchLayout",list ); |
1912 | } | 1898 | } |
1913 | #endif | 1899 | #endif |
1914 | 1900 | ||
1915 | 1901 | ||
1916 | config->sync(); | 1902 | config->sync(); |
1917 | } | 1903 | } |
1918 | 1904 | ||
1919 | void CalendarView::readFilterSettings(KConfig *config) | 1905 | void CalendarView::readFilterSettings(KConfig *config) |
1920 | { | 1906 | { |
1921 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 1907 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
1922 | 1908 | ||
1923 | mFilters.clear(); | 1909 | mFilters.clear(); |
1924 | 1910 | ||
1925 | config->setGroup("General"); | 1911 | config->setGroup("General"); |
1926 | QStringList filterList = config->readListEntry("CalendarFilters"); | 1912 | QStringList filterList = config->readListEntry("CalendarFilters"); |
1927 | 1913 | ||
1928 | QStringList::ConstIterator it = filterList.begin(); | 1914 | QStringList::ConstIterator it = filterList.begin(); |
1929 | QStringList::ConstIterator end = filterList.end(); | 1915 | QStringList::ConstIterator end = filterList.end(); |
1930 | while(it != end) { | 1916 | while(it != end) { |
1931 | // kdDebug() << " filter: " << (*it) << endl; | 1917 | // kdDebug() << " filter: " << (*it) << endl; |
1932 | 1918 | ||
1933 | CalFilter *filter; | 1919 | CalFilter *filter; |
1934 | filter = new CalFilter(*it); | 1920 | filter = new CalFilter(*it); |
1935 | config->setGroup("Filter_" + (*it)); | 1921 | config->setGroup("Filter_" + (*it)); |
1936 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 1922 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
1937 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 1923 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
1938 | filter->setCategoryList(config->readListEntry("CategoryList")); | 1924 | filter->setCategoryList(config->readListEntry("CategoryList")); |
1939 | mFilters.append(filter); | 1925 | mFilters.append(filter); |
1940 | 1926 | ||
1941 | ++it; | 1927 | ++it; |
1942 | } | 1928 | } |
1943 | 1929 | ||
1944 | if (mFilters.count() == 0) { | 1930 | if (mFilters.count() == 0) { |
1945 | CalFilter *filter = new CalFilter(i18n("Default")); | 1931 | CalFilter *filter = new CalFilter(i18n("Default")); |
1946 | mFilters.append(filter); | 1932 | mFilters.append(filter); |
1947 | } | 1933 | } |
1948 | mFilterView->updateFilters(); | 1934 | mFilterView->updateFilters(); |
1949 | config->setGroup("FilterView"); | 1935 | config->setGroup("FilterView"); |
1950 | 1936 | ||
1951 | mFilterView->blockSignals(true); | 1937 | mFilterView->blockSignals(true); |
1952 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 1938 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
1953 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 1939 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
1954 | mFilterView->blockSignals(false); | 1940 | mFilterView->blockSignals(false); |
1955 | // We do it manually to avoid it being done twice by the above calls | 1941 | // We do it manually to avoid it being done twice by the above calls |
1956 | updateFilter(); | 1942 | updateFilter(); |
1957 | } | 1943 | } |
1958 | 1944 | ||
1959 | void CalendarView::writeFilterSettings(KConfig *config) | 1945 | void CalendarView::writeFilterSettings(KConfig *config) |
1960 | { | 1946 | { |
1961 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 1947 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
1962 | 1948 | ||
1963 | QStringList filterList; | 1949 | QStringList filterList; |
1964 | 1950 | ||
1965 | CalFilter *filter = mFilters.first(); | 1951 | CalFilter *filter = mFilters.first(); |
1966 | while(filter) { | 1952 | while(filter) { |
1967 | // kdDebug() << " fn: " << filter->name() << endl; | 1953 | // kdDebug() << " fn: " << filter->name() << endl; |
1968 | filterList << filter->name(); | 1954 | filterList << filter->name(); |
1969 | config->setGroup("Filter_" + filter->name()); | 1955 | config->setGroup("Filter_" + filter->name()); |
1970 | config->writeEntry("Criteria",filter->criteria()); | 1956 | config->writeEntry("Criteria",filter->criteria()); |
1971 | config->writeEntry("CategoryList",filter->categoryList()); | 1957 | config->writeEntry("CategoryList",filter->categoryList()); |
1972 | filter = mFilters.next(); | 1958 | filter = mFilters.next(); |
1973 | } | 1959 | } |
1974 | config->setGroup("General"); | 1960 | config->setGroup("General"); |
1975 | config->writeEntry("CalendarFilters",filterList); | 1961 | config->writeEntry("CalendarFilters",filterList); |
1976 | 1962 | ||
1977 | config->setGroup("FilterView"); | 1963 | config->setGroup("FilterView"); |
1978 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 1964 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
1979 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 1965 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
1980 | } | 1966 | } |
1981 | 1967 | ||
1982 | 1968 | ||
1983 | void CalendarView::goToday() | 1969 | void CalendarView::goToday() |
1984 | { | 1970 | { |
1985 | mNavigator->selectToday(); | 1971 | mNavigator->selectToday(); |
1986 | } | 1972 | } |
1987 | 1973 | ||
1988 | void CalendarView::goNext() | 1974 | void CalendarView::goNext() |
1989 | { | 1975 | { |
1990 | mNavigator->selectNext(); | 1976 | mNavigator->selectNext(); |
1991 | } | 1977 | } |
1992 | 1978 | ||
1993 | void CalendarView::goPrevious() | 1979 | void CalendarView::goPrevious() |
1994 | { | 1980 | { |
1995 | mNavigator->selectPrevious(); | 1981 | mNavigator->selectPrevious(); |
1996 | } | 1982 | } |
1997 | void CalendarView::goNextMonth() | 1983 | void CalendarView::goNextMonth() |
1998 | { | 1984 | { |
1999 | mNavigator->selectNextMonth(); | 1985 | mNavigator->selectNextMonth(); |
2000 | } | 1986 | } |
2001 | 1987 | ||
2002 | void CalendarView::goPreviousMonth() | 1988 | void CalendarView::goPreviousMonth() |
2003 | { | 1989 | { |
2004 | mNavigator->selectPreviousMonth(); | 1990 | mNavigator->selectPreviousMonth(); |
2005 | } | 1991 | } |
2006 | void CalendarView::writeLocale() | 1992 | void CalendarView::writeLocale() |
2007 | { | 1993 | { |
2008 | //KPimGlobalPrefs::instance()->setGlobalConfig(); | 1994 | //KPimGlobalPrefs::instance()->setGlobalConfig(); |
2009 | #if 0 | 1995 | #if 0 |
2010 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); | 1996 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); |
2011 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); | 1997 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); |
2012 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); | 1998 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); |
2013 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); | 1999 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); |
2014 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; | 2000 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; |
2015 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); | 2001 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); |
2016 | dummy = KOPrefs::instance()->mUserDateFormatShort; | 2002 | dummy = KOPrefs::instance()->mUserDateFormatShort; |
2017 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | 2003 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); |
2018 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, | 2004 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, |
2019 | KOPrefs::instance()->mDaylightsavingStart, | 2005 | KOPrefs::instance()->mDaylightsavingStart, |
2020 | KOPrefs::instance()->mDaylightsavingEnd ); | 2006 | KOPrefs::instance()->mDaylightsavingEnd ); |
2021 | KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId ); | 2007 | KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId ); |
2022 | #endif | 2008 | #endif |
2023 | } | 2009 | } |
2024 | void CalendarView::updateConfig() | 2010 | void CalendarView::updateConfig() |
2025 | { | 2011 | { |
2026 | writeLocale(); | 2012 | writeLocale(); |
2027 | if ( KOPrefs::instance()->mUseAppColors ) | 2013 | if ( KOPrefs::instance()->mUseAppColors ) |
2028 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 2014 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
2029 | emit configChanged(); | 2015 | emit configChanged(); |
2030 | mTodoList->updateConfig(); | 2016 | mTodoList->updateConfig(); |
2031 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 2017 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
2032 | mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 2018 | mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
2033 | // To make the "fill window" configurations work | 2019 | // To make the "fill window" configurations work |
2034 | //mViewManager->raiseCurrentView(); | 2020 | //mViewManager->raiseCurrentView(); |
2035 | } | 2021 | } |
2036 | 2022 | ||
2037 | 2023 | ||
2038 | void CalendarView::eventChanged(Event *event) | 2024 | void CalendarView::eventChanged(Event *event) |
2039 | { | 2025 | { |
2040 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 2026 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
2041 | //updateUnmanagedViews(); | 2027 | //updateUnmanagedViews(); |
2042 | } | 2028 | } |
2043 | 2029 | ||
2044 | void CalendarView::eventAdded(Event *event) | 2030 | void CalendarView::eventAdded(Event *event) |
2045 | { | 2031 | { |
2046 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 2032 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
2047 | } | 2033 | } |
2048 | 2034 | ||
2049 | void CalendarView::eventToBeDeleted(Event *) | 2035 | void CalendarView::eventToBeDeleted(Event *) |
2050 | { | 2036 | { |
2051 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 2037 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
2052 | } | 2038 | } |
2053 | 2039 | ||
2054 | void CalendarView::eventDeleted() | 2040 | void CalendarView::eventDeleted() |
2055 | { | 2041 | { |
2056 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 2042 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
2057 | } | 2043 | } |
2058 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 2044 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2059 | { | 2045 | { |
2060 | changeIncidenceDisplay((Incidence *)which, action); | 2046 | changeIncidenceDisplay((Incidence *)which, action); |
2061 | mDateNavigator->updateView(); //LR | 2047 | mDateNavigator->updateView(); //LR |
2062 | //mDialogManager->updateSearchDialog(); | 2048 | //mDialogManager->updateSearchDialog(); |
2063 | 2049 | ||
2064 | if (which) { | 2050 | if (which) { |
2065 | mViewManager->updateWNview(); | 2051 | mViewManager->updateWNview(); |
2066 | //mTodoList->updateView(); | 2052 | //mTodoList->updateView(); |
2067 | } | 2053 | } |
2068 | 2054 | ||
2069 | } | 2055 | } |
2070 | 2056 | ||
2071 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 2057 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
2072 | { | 2058 | { |
2073 | updateUnmanagedViews(); | 2059 | updateUnmanagedViews(); |
2074 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 2060 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
2075 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 2061 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
2076 | mCalendar->checkAlarmForIncidence( 0, true ); | 2062 | mCalendar->checkAlarmForIncidence( 0, true ); |
2077 | if ( mEventViewerDialog ) | 2063 | if ( mEventViewerDialog ) |
2078 | mEventViewerDialog->hide(); | 2064 | mEventViewerDialog->hide(); |
2079 | } | 2065 | } |
2080 | else | 2066 | else |
2081 | mCalendar->checkAlarmForIncidence( which , false ); | 2067 | mCalendar->checkAlarmForIncidence( which , false ); |
2082 | } | 2068 | } |
2083 | 2069 | ||
2084 | // most of the changeEventDisplays() right now just call the view's | 2070 | // most of the changeEventDisplays() right now just call the view's |
2085 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 2071 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
2086 | void CalendarView::changeEventDisplay(Event *which, int action) | 2072 | void CalendarView::changeEventDisplay(Event *which, int action) |
2087 | { | 2073 | { |
2088 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 2074 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
2089 | changeIncidenceDisplay((Incidence *)which, action); | 2075 | changeIncidenceDisplay((Incidence *)which, action); |
2090 | mDateNavigator->updateView(); | 2076 | mDateNavigator->updateView(); |
2091 | //mDialogManager->updateSearchDialog(); | 2077 | //mDialogManager->updateSearchDialog(); |
2092 | 2078 | ||
2093 | if (which) { | 2079 | if (which) { |
2094 | // If there is an event view visible update the display | 2080 | // If there is an event view visible update the display |
2095 | mViewManager->currentView()->changeEventDisplay(which,action); | 2081 | mViewManager->currentView()->changeEventDisplay(which,action); |
2096 | // TODO: check, if update needed | 2082 | // TODO: check, if update needed |
2097 | // if (which->getTodoStatus()) { | 2083 | // if (which->getTodoStatus()) { |
2098 | mTodoList->updateView(); | 2084 | mTodoList->updateView(); |
2099 | // } | 2085 | // } |
2100 | } else { | 2086 | } else { |
2101 | mViewManager->currentView()->updateView(); | 2087 | mViewManager->currentView()->updateView(); |
2102 | } | 2088 | } |
2103 | } | 2089 | } |
2104 | 2090 | ||
2105 | 2091 | ||
2106 | void CalendarView::updateTodoViews() | 2092 | void CalendarView::updateTodoViews() |
2107 | { | 2093 | { |
2108 | 2094 | ||
2109 | mTodoList->updateView(); | 2095 | mTodoList->updateView(); |
2110 | mViewManager->currentView()->updateView(); | 2096 | mViewManager->currentView()->updateView(); |
2111 | 2097 | ||
2112 | } | 2098 | } |
2113 | 2099 | ||
2114 | 2100 | ||
2115 | void CalendarView::updateView(const QDate &start, const QDate &end) | 2101 | void CalendarView::updateView(const QDate &start, const QDate &end) |
2116 | { | 2102 | { |
2117 | mTodoList->updateView(); | 2103 | mTodoList->updateView(); |
2118 | mViewManager->updateView(start, end); | 2104 | mViewManager->updateView(start, end); |
2119 | //mDateNavigator->updateView(); | 2105 | //mDateNavigator->updateView(); |
2120 | } | 2106 | } |
2121 | 2107 | ||
2122 | void CalendarView::updateView() | 2108 | void CalendarView::updateView() |
2123 | { | 2109 | { |
2124 | DateList tmpList = mNavigator->selectedDates(); | 2110 | DateList tmpList = mNavigator->selectedDates(); |
2125 | 2111 | ||
2126 | // We assume that the navigator only selects consecutive days. | 2112 | // We assume that the navigator only selects consecutive days. |
2127 | updateView( tmpList.first(), tmpList.last() ); | 2113 | updateView( tmpList.first(), tmpList.last() ); |
2128 | } | 2114 | } |
2129 | 2115 | ||
2130 | void CalendarView::updateUnmanagedViews() | 2116 | void CalendarView::updateUnmanagedViews() |
2131 | { | 2117 | { |
2132 | mDateNavigator->updateDayMatrix(); | 2118 | mDateNavigator->updateDayMatrix(); |
2133 | } | 2119 | } |
2134 | 2120 | ||
2135 | int CalendarView::msgItemDelete() | 2121 | int CalendarView::msgItemDelete() |
2136 | { | 2122 | { |
2137 | return KMessageBox::warningContinueCancel(this, | 2123 | return KMessageBox::warningContinueCancel(this, |
2138 | i18n("This item will be\npermanently deleted."), | 2124 | i18n("This item will be\npermanently deleted."), |
2139 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2125 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2140 | } | 2126 | } |
2141 | 2127 | ||
2142 | 2128 | ||
2143 | void CalendarView::edit_cut() | 2129 | void CalendarView::edit_cut() |
2144 | { | 2130 | { |
2145 | Event *anEvent=0; | 2131 | Event *anEvent=0; |
2146 | 2132 | ||
2147 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2133 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2148 | 2134 | ||
2149 | if (mViewManager->currentView()->isEventView()) { | 2135 | if (mViewManager->currentView()->isEventView()) { |
2150 | if ( incidence && incidence->type() == "Event" ) { | 2136 | if ( incidence && incidence->type() == "Event" ) { |
2151 | anEvent = static_cast<Event *>(incidence); | 2137 | anEvent = static_cast<Event *>(incidence); |
2152 | } | 2138 | } |
2153 | } | 2139 | } |
2154 | 2140 | ||
2155 | if (!anEvent) { | 2141 | if (!anEvent) { |
2156 | KNotifyClient::beep(); | 2142 | KNotifyClient::beep(); |
2157 | return; | 2143 | return; |
2158 | } | 2144 | } |
2159 | DndFactory factory( mCalendar ); | 2145 | DndFactory factory( mCalendar ); |
2160 | factory.cutEvent(anEvent); | 2146 | factory.cutEvent(anEvent); |
2161 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2147 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2162 | } | 2148 | } |
2163 | 2149 | ||
2164 | void CalendarView::edit_copy() | 2150 | void CalendarView::edit_copy() |
2165 | { | 2151 | { |
2166 | Event *anEvent=0; | 2152 | Event *anEvent=0; |
2167 | 2153 | ||
2168 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2154 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2169 | 2155 | ||
2170 | if (mViewManager->currentView()->isEventView()) { | 2156 | if (mViewManager->currentView()->isEventView()) { |
2171 | if ( incidence && incidence->type() == "Event" ) { | 2157 | if ( incidence && incidence->type() == "Event" ) { |
2172 | anEvent = static_cast<Event *>(incidence); | 2158 | anEvent = static_cast<Event *>(incidence); |
2173 | } | 2159 | } |
2174 | } | 2160 | } |
2175 | 2161 | ||
2176 | if (!anEvent) { | 2162 | if (!anEvent) { |
2177 | KNotifyClient::beep(); | 2163 | KNotifyClient::beep(); |
2178 | return; | 2164 | return; |
2179 | } | 2165 | } |
2180 | DndFactory factory( mCalendar ); | 2166 | DndFactory factory( mCalendar ); |
2181 | factory.copyEvent(anEvent); | 2167 | factory.copyEvent(anEvent); |
2182 | } | 2168 | } |
2183 | 2169 | ||
2184 | void CalendarView::edit_paste() | 2170 | void CalendarView::edit_paste() |
2185 | { | 2171 | { |
2186 | QDate date = mNavigator->selectedDates().first(); | 2172 | QDate date = mNavigator->selectedDates().first(); |
2187 | 2173 | ||
2188 | DndFactory factory( mCalendar ); | 2174 | DndFactory factory( mCalendar ); |
2189 | Event *pastedEvent = factory.pasteEvent( date ); | 2175 | Event *pastedEvent = factory.pasteEvent( date ); |
2190 | 2176 | ||
2191 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2177 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2192 | } | 2178 | } |
2193 | 2179 | ||
2194 | void CalendarView::edit_options() | 2180 | void CalendarView::edit_options() |
2195 | { | 2181 | { |
2196 | mDialogManager->showOptionsDialog(); | 2182 | mDialogManager->showOptionsDialog(); |
2197 | //writeSettings(); | 2183 | //writeSettings(); |
2198 | } | 2184 | } |
2199 | void CalendarView::edit_sync_options() | 2185 | void CalendarView::edit_sync_options() |
2200 | { | 2186 | { |
2201 | //mDialogManager->showSyncOptions(); | 2187 | // DELETE |
2202 | //KOPrefs::instance()->mSyncAlgoPrefs | ||
2203 | QDialog dia( this, "dia", true ); | ||
2204 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); | ||
2205 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); | ||
2206 | QVBoxLayout lay ( &dia ); | ||
2207 | lay.setSpacing( 2 ); | ||
2208 | lay.setMargin( 3 ); | ||
2209 | lay.addWidget(&gr); | ||
2210 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); | ||
2211 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); | ||
2212 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); | ||
2213 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); | ||
2214 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); | ||
2215 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); | ||
2216 | //QRadioButton both( i18n("Take both on conflict"), &gr ); | ||
2217 | QPushButton pb ( "OK", &dia); | ||
2218 | lay.addWidget( &pb ); | ||
2219 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | ||
2220 | switch ( KOPrefs::instance()->mSyncAlgoPrefs ) { | ||
2221 | case 0: | ||
2222 | loc.setChecked( true); | ||
2223 | break; | ||
2224 | case 1: | ||
2225 | rem.setChecked( true ); | ||
2226 | break; | ||
2227 | case 2: | ||
2228 | newest.setChecked( true); | ||
2229 | break; | ||
2230 | case 3: | ||
2231 | ask.setChecked( true); | ||
2232 | break; | ||
2233 | case 4: | ||
2234 | f_loc.setChecked( true); | ||
2235 | break; | ||
2236 | case 5: | ||
2237 | f_rem.setChecked( true); | ||
2238 | break; | ||
2239 | case 6: | ||
2240 | // both.setChecked( true); | ||
2241 | break; | ||
2242 | default: | ||
2243 | break; | ||
2244 | } | ||
2245 | if ( dia.exec() ) { | ||
2246 | KOPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; | ||
2247 | } | ||
2248 | 2188 | ||
2249 | } | 2189 | } |
2250 | 2190 | ||
2251 | void CalendarView::slotSelectPickerDate( QDate d) | 2191 | void CalendarView::slotSelectPickerDate( QDate d) |
2252 | { | 2192 | { |
2253 | mDateFrame->hide(); | 2193 | mDateFrame->hide(); |
2254 | if ( mDatePickerMode == 1 ) { | 2194 | if ( mDatePickerMode == 1 ) { |
2255 | mNavigator->slotDaySelect( d ); | 2195 | mNavigator->slotDaySelect( d ); |
2256 | } else if ( mDatePickerMode == 2 ) { | 2196 | } else if ( mDatePickerMode == 2 ) { |
2257 | if ( mMoveIncidence->type() == "Todo" ) { | 2197 | if ( mMoveIncidence->type() == "Todo" ) { |
2258 | Todo * to = (Todo *) mMoveIncidence; | 2198 | Todo * to = (Todo *) mMoveIncidence; |
2259 | QTime tim; | 2199 | QTime tim; |
2260 | if ( to->hasDueDate() ) | 2200 | if ( to->hasDueDate() ) |
2261 | tim = to->dtDue().time(); | 2201 | tim = to->dtDue().time(); |
2262 | else { | 2202 | else { |
2263 | tim = QTime ( 0,0,0 ); | 2203 | tim = QTime ( 0,0,0 ); |
2264 | to->setFloats( true ); | 2204 | to->setFloats( true ); |
2265 | to->setHasDueDate( true ); | 2205 | to->setHasDueDate( true ); |
2266 | } | 2206 | } |
2267 | QDateTime dt ( d,tim ); | 2207 | QDateTime dt ( d,tim ); |
2268 | to->setDtDue( dt ); | 2208 | to->setDtDue( dt ); |
2269 | todoChanged( to ); | 2209 | todoChanged( to ); |
2270 | } else { | 2210 | } else { |
2271 | QTime tim = mMoveIncidence->dtStart().time(); | 2211 | QTime tim = mMoveIncidence->dtStart().time(); |
2272 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2212 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2273 | QDateTime dt ( d,tim ); | 2213 | QDateTime dt ( d,tim ); |
2274 | mMoveIncidence->setDtStart( dt ); | 2214 | mMoveIncidence->setDtStart( dt ); |
2275 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2215 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2276 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2216 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2277 | } | 2217 | } |
2278 | 2218 | ||
2279 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 2219 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
2280 | } | 2220 | } |
2281 | } | 2221 | } |
2282 | 2222 | ||
2283 | void CalendarView::removeCategories() | 2223 | void CalendarView::removeCategories() |
2284 | { | 2224 | { |
2285 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2225 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2286 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2226 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2287 | QStringList catIncList; | 2227 | QStringList catIncList; |
2288 | QStringList newCatList; | 2228 | QStringList newCatList; |
2289 | Incidence* inc = incList.first(); | 2229 | Incidence* inc = incList.first(); |
2290 | int i; | 2230 | int i; |
2291 | int count = 0; | 2231 | int count = 0; |
2292 | while ( inc ) { | 2232 | while ( inc ) { |
2293 | newCatList.clear(); | 2233 | newCatList.clear(); |
2294 | catIncList = inc->categories() ; | 2234 | catIncList = inc->categories() ; |
2295 | for( i = 0; i< catIncList.count(); ++i ) { | 2235 | for( i = 0; i< catIncList.count(); ++i ) { |
2296 | if ( catList.contains (catIncList[i])) | 2236 | if ( catList.contains (catIncList[i])) |
2297 | newCatList.append( catIncList[i] ); | 2237 | newCatList.append( catIncList[i] ); |
2298 | } | 2238 | } |
2299 | newCatList.sort(); | 2239 | newCatList.sort(); |
2300 | inc->setCategories( newCatList.join(",") ); | 2240 | inc->setCategories( newCatList.join(",") ); |
2301 | inc = incList.next(); | 2241 | inc = incList.next(); |
2302 | } | 2242 | } |
2303 | } | 2243 | } |
2304 | 2244 | ||
2305 | int CalendarView::addCategories() | 2245 | int CalendarView::addCategories() |
2306 | { | 2246 | { |
2307 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2247 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2308 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2248 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2309 | QStringList catIncList; | 2249 | QStringList catIncList; |
2310 | Incidence* inc = incList.first(); | 2250 | Incidence* inc = incList.first(); |
2311 | int i; | 2251 | int i; |
2312 | int count = 0; | 2252 | int count = 0; |
2313 | while ( inc ) { | 2253 | while ( inc ) { |
2314 | catIncList = inc->categories() ; | 2254 | catIncList = inc->categories() ; |
2315 | for( i = 0; i< catIncList.count(); ++i ) { | 2255 | for( i = 0; i< catIncList.count(); ++i ) { |
2316 | if ( !catList.contains (catIncList[i])) { | 2256 | if ( !catList.contains (catIncList[i])) { |
2317 | catList.append( catIncList[i] ); | 2257 | catList.append( catIncList[i] ); |
2318 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2258 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2319 | ++count; | 2259 | ++count; |
2320 | } | 2260 | } |
2321 | } | 2261 | } |
2322 | inc = incList.next(); | 2262 | inc = incList.next(); |
2323 | } | 2263 | } |
2324 | catList.sort(); | 2264 | catList.sort(); |
2325 | KOPrefs::instance()->mCustomCategories = catList; | 2265 | KOPrefs::instance()->mCustomCategories = catList; |
2326 | return count; | 2266 | return count; |
2327 | } | 2267 | } |
2328 | 2268 | ||
2329 | void CalendarView::manageCategories() | 2269 | void CalendarView::manageCategories() |
2330 | { | 2270 | { |
2331 | KOCatPrefs* cp = new KOCatPrefs(); | 2271 | KOCatPrefs* cp = new KOCatPrefs(); |
2332 | cp->show(); | 2272 | cp->show(); |
2333 | int w =cp->sizeHint().width() ; | 2273 | int w =cp->sizeHint().width() ; |
2334 | int h = cp->sizeHint().height() ; | 2274 | int h = cp->sizeHint().height() ; |
2335 | int dw = QApplication::desktop()->width(); | 2275 | int dw = QApplication::desktop()->width(); |
2336 | int dh = QApplication::desktop()->height(); | 2276 | int dh = QApplication::desktop()->height(); |
2337 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2277 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2338 | if ( !cp->exec() ) { | 2278 | if ( !cp->exec() ) { |
2339 | delete cp; | 2279 | delete cp; |
2340 | return; | 2280 | return; |
2341 | } | 2281 | } |
2342 | int count = 0; | 2282 | int count = 0; |
2343 | if ( cp->addCat() ) { | 2283 | if ( cp->addCat() ) { |
2344 | count = addCategories(); | 2284 | count = addCategories(); |
2345 | if ( count ) { | 2285 | if ( count ) { |
2346 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 2286 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
2347 | writeSettings(); | 2287 | writeSettings(); |
2348 | } | 2288 | } |
2349 | } else { | 2289 | } else { |
2350 | removeCategories(); | 2290 | removeCategories(); |
2351 | updateView(); | 2291 | updateView(); |
2352 | } | 2292 | } |
2353 | delete cp; | 2293 | delete cp; |
2354 | } | 2294 | } |
2355 | 2295 | ||
2356 | void CalendarView::beamIncidence(Incidence * Inc) | 2296 | void CalendarView::beamIncidence(Incidence * Inc) |
2357 | { | 2297 | { |
2358 | QPtrList<Incidence> delSel ; | 2298 | QPtrList<Incidence> delSel ; |
2359 | delSel.append(Inc); | 2299 | delSel.append(Inc); |
2360 | beamIncidenceList( delSel ); | 2300 | beamIncidenceList( delSel ); |
2361 | } | 2301 | } |
2362 | void CalendarView::beamCalendar() | 2302 | void CalendarView::beamCalendar() |
2363 | { | 2303 | { |
2364 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 2304 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
2365 | //qDebug("beamCalendar() "); | 2305 | //qDebug("beamCalendar() "); |
2366 | beamIncidenceList( delSel ); | 2306 | beamIncidenceList( delSel ); |
2367 | } | 2307 | } |
2368 | void CalendarView::beamFilteredCalendar() | 2308 | void CalendarView::beamFilteredCalendar() |
2369 | { | 2309 | { |
2370 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 2310 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
2371 | //qDebug("beamFilteredCalendar() "); | 2311 | //qDebug("beamFilteredCalendar() "); |
2372 | beamIncidenceList( delSel ); | 2312 | beamIncidenceList( delSel ); |
2373 | } | 2313 | } |
2374 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 2314 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
2375 | { | 2315 | { |
2376 | if ( beamDialog->exec () == QDialog::Rejected ) | 2316 | if ( beamDialog->exec () == QDialog::Rejected ) |
2377 | return; | 2317 | return; |
2378 | 2318 | ||
2379 | QString fn = "/tmp/kopibeamfile"; | 2319 | QString fn = "/tmp/kopibeamfile"; |
2380 | QString mes; | 2320 | QString mes; |
2381 | bool createbup = true; | 2321 | bool createbup = true; |
2382 | if ( createbup ) { | 2322 | if ( createbup ) { |
2383 | QString description = "\n"; | 2323 | QString description = "\n"; |
2384 | CalendarLocal* cal = new CalendarLocal(); | 2324 | CalendarLocal* cal = new CalendarLocal(); |
2385 | if ( beamDialog->beamLocal() ) | 2325 | if ( beamDialog->beamLocal() ) |
2386 | cal->setLocalTime(); | 2326 | cal->setLocalTime(); |
2387 | else | 2327 | else |
2388 | cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 2328 | cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
2389 | Incidence *incidence = delSel.first(); | 2329 | Incidence *incidence = delSel.first(); |
2390 | bool addText = false; | 2330 | bool addText = false; |
2391 | if ( delSel.count() < 10 ) | 2331 | if ( delSel.count() < 10 ) |
2392 | addText = true; | 2332 | addText = true; |
2393 | else { | 2333 | else { |
2394 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 2334 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
2395 | } | 2335 | } |
2396 | while ( incidence ) { | 2336 | while ( incidence ) { |
2397 | Incidence *in = incidence->clone(); | 2337 | Incidence *in = incidence->clone(); |
2398 | if ( addText ) | 2338 | if ( addText ) |
2399 | description += in->summary() + "\n"; | 2339 | description += in->summary() + "\n"; |
2400 | cal->addIncidence( in ); | 2340 | cal->addIncidence( in ); |
2401 | incidence = delSel.next(); | 2341 | incidence = delSel.next(); |
2402 | } | 2342 | } |
2403 | if ( beamDialog->beamVcal() ) { | 2343 | if ( beamDialog->beamVcal() ) { |
2404 | fn += ".vcs"; | 2344 | fn += ".vcs"; |
2405 | FileStorage storage( cal, fn, new VCalFormat ); | 2345 | FileStorage storage( cal, fn, new VCalFormat ); |
2406 | storage.save(); | 2346 | storage.save(); |
2407 | } else { | 2347 | } else { |
2408 | fn += ".ics"; | 2348 | fn += ".ics"; |
2409 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 2349 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
2410 | storage.save(); | 2350 | storage.save(); |
2411 | } | 2351 | } |
2412 | delete cal; | 2352 | delete cal; |
2413 | mes = i18n("KO/Pi: Ready for beaming"); | 2353 | mes = i18n("KO/Pi: Ready for beaming"); |
2414 | setCaption(mes); | 2354 | setCaption(mes); |
2415 | 2355 | ||
2416 | #ifndef DESKTOP_VERSION | 2356 | #ifndef DESKTOP_VERSION |
2417 | Ir *ir = new Ir( this ); | 2357 | Ir *ir = new Ir( this ); |
2418 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 2358 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
2419 | ir->send( fn, description, "text/x-vCalendar" ); | 2359 | ir->send( fn, description, "text/x-vCalendar" ); |
2420 | #endif | 2360 | #endif |
2421 | } | 2361 | } |
2422 | } | 2362 | } |
2423 | void CalendarView::beamDone( Ir *ir ) | 2363 | void CalendarView::beamDone( Ir *ir ) |
2424 | { | 2364 | { |
2425 | #ifndef DESKTOP_VERSION | 2365 | #ifndef DESKTOP_VERSION |
2426 | delete ir; | 2366 | delete ir; |
2427 | #endif | 2367 | #endif |
2428 | } | 2368 | } |
2429 | 2369 | ||
2430 | void CalendarView::moveIncidence(Incidence * inc ) | 2370 | void CalendarView::moveIncidence(Incidence * inc ) |
2431 | { | 2371 | { |
2432 | if ( !inc ) return; | 2372 | if ( !inc ) return; |
2433 | // qDebug("showDatePickerForIncidence( ) "); | 2373 | // qDebug("showDatePickerForIncidence( ) "); |
2434 | if ( mDateFrame->isVisible() ) | 2374 | if ( mDateFrame->isVisible() ) |
2435 | mDateFrame->hide(); | 2375 | mDateFrame->hide(); |
2436 | else { | 2376 | else { |
2437 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; | 2377 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; |
2438 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; | 2378 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; |
2439 | int dw = QApplication::desktop()->width(); | 2379 | int dw = QApplication::desktop()->width(); |
2440 | int dh = QApplication::desktop()->height(); | 2380 | int dh = QApplication::desktop()->height(); |
2441 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2381 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2442 | mDateFrame->show(); | 2382 | mDateFrame->show(); |
2443 | } | 2383 | } |
2444 | mDatePickerMode = 2; | 2384 | mDatePickerMode = 2; |
2445 | mMoveIncidence = inc ; | 2385 | mMoveIncidence = inc ; |
2446 | QDate da; | 2386 | QDate da; |
2447 | if ( mMoveIncidence->type() == "Todo" ) { | 2387 | if ( mMoveIncidence->type() == "Todo" ) { |
2448 | Todo * to = (Todo *) mMoveIncidence; | 2388 | Todo * to = (Todo *) mMoveIncidence; |
2449 | if ( to->hasDueDate() ) | 2389 | if ( to->hasDueDate() ) |
2450 | da = to->dtDue().date(); | 2390 | da = to->dtDue().date(); |
2451 | else | 2391 | else |
2452 | da = QDate::currentDate(); | 2392 | da = QDate::currentDate(); |
2453 | } else { | 2393 | } else { |
2454 | da = mMoveIncidence->dtStart().date(); | 2394 | da = mMoveIncidence->dtStart().date(); |
2455 | } | 2395 | } |
2456 | mDatePicker->setDate( da ); | 2396 | mDatePicker->setDate( da ); |
2457 | } | 2397 | } |
2458 | void CalendarView::showDatePicker( ) | 2398 | void CalendarView::showDatePicker( ) |
2459 | { | 2399 | { |
2460 | //qDebug("CalendarView::showDatePicker( ) "); | 2400 | //qDebug("CalendarView::showDatePicker( ) "); |
2461 | if ( mDateFrame->isVisible() ) | 2401 | if ( mDateFrame->isVisible() ) |
2462 | mDateFrame->hide(); | 2402 | mDateFrame->hide(); |
2463 | else { | 2403 | else { |
2464 | int w =mDatePicker->sizeHint().width() ; | 2404 | int w =mDatePicker->sizeHint().width() ; |
2465 | int h = mDatePicker->sizeHint().height() ; | 2405 | int h = mDatePicker->sizeHint().height() ; |
2466 | int dw = QApplication::desktop()->width(); | 2406 | int dw = QApplication::desktop()->width(); |
2467 | int dh = QApplication::desktop()->height(); | 2407 | int dh = QApplication::desktop()->height(); |
2468 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2408 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2469 | mDateFrame->show(); | 2409 | mDateFrame->show(); |
2470 | } | 2410 | } |
2471 | mDatePickerMode = 1; | 2411 | mDatePickerMode = 1; |
2472 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 2412 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
2473 | } | 2413 | } |
2474 | 2414 | ||
2475 | void CalendarView::showEventEditor() | 2415 | void CalendarView::showEventEditor() |
2476 | { | 2416 | { |
2477 | #ifdef DESKTOP_VERSION | 2417 | #ifdef DESKTOP_VERSION |
2478 | mEventEditor->show(); | 2418 | mEventEditor->show(); |
2479 | #else | 2419 | #else |
2480 | mEventEditor->showMaximized(); | 2420 | mEventEditor->showMaximized(); |
2481 | #endif | 2421 | #endif |
2482 | } | 2422 | } |
2483 | void CalendarView::showTodoEditor() | 2423 | void CalendarView::showTodoEditor() |
2484 | { | 2424 | { |
2485 | #ifdef DESKTOP_VERSION | 2425 | #ifdef DESKTOP_VERSION |
2486 | mTodoEditor->show(); | 2426 | mTodoEditor->show(); |
2487 | #else | 2427 | #else |
2488 | mTodoEditor->showMaximized(); | 2428 | mTodoEditor->showMaximized(); |
2489 | #endif | 2429 | #endif |
2490 | } | 2430 | } |
2491 | 2431 | ||
2492 | void CalendarView::cloneIncidence() | 2432 | void CalendarView::cloneIncidence() |
2493 | { | 2433 | { |
2494 | Incidence *incidence = currentSelection(); | 2434 | Incidence *incidence = currentSelection(); |
2495 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2435 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2496 | if ( incidence ) { | 2436 | if ( incidence ) { |
2497 | cloneIncidence(incidence); | 2437 | cloneIncidence(incidence); |
2498 | } | 2438 | } |
2499 | } | 2439 | } |
2500 | void CalendarView::moveIncidence() | 2440 | void CalendarView::moveIncidence() |
2501 | { | 2441 | { |
2502 | Incidence *incidence = currentSelection(); | 2442 | Incidence *incidence = currentSelection(); |
2503 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2443 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2504 | if ( incidence ) { | 2444 | if ( incidence ) { |
2505 | moveIncidence(incidence); | 2445 | moveIncidence(incidence); |
2506 | } | 2446 | } |
2507 | } | 2447 | } |
2508 | void CalendarView::beamIncidence() | 2448 | void CalendarView::beamIncidence() |
2509 | { | 2449 | { |
2510 | Incidence *incidence = currentSelection(); | 2450 | Incidence *incidence = currentSelection(); |
2511 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2451 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2512 | if ( incidence ) { | 2452 | if ( incidence ) { |
2513 | beamIncidence(incidence); | 2453 | beamIncidence(incidence); |
2514 | } | 2454 | } |
2515 | } | 2455 | } |
2516 | void CalendarView::toggleCancelIncidence() | 2456 | void CalendarView::toggleCancelIncidence() |
2517 | { | 2457 | { |
2518 | Incidence *incidence = currentSelection(); | 2458 | Incidence *incidence = currentSelection(); |
2519 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2459 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2520 | if ( incidence ) { | 2460 | if ( incidence ) { |
2521 | cancelIncidence(incidence); | 2461 | cancelIncidence(incidence); |
2522 | } | 2462 | } |
2523 | } | 2463 | } |
2524 | 2464 | ||
2525 | 2465 | ||
2526 | void CalendarView::cancelIncidence(Incidence * inc ) | 2466 | void CalendarView::cancelIncidence(Incidence * inc ) |
2527 | { | 2467 | { |
2528 | inc->setCancelled( ! inc->cancelled() ); | 2468 | inc->setCancelled( ! inc->cancelled() ); |
2529 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 2469 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
2530 | updateView(); | 2470 | updateView(); |
2531 | } | 2471 | } |
2532 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 2472 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
2533 | { | 2473 | { |
2534 | Incidence * newInc = orgInc->clone(); | 2474 | Incidence * newInc = orgInc->clone(); |
2535 | newInc->recreate(); | 2475 | newInc->recreate(); |
2536 | 2476 | ||
2537 | if ( newInc->type() == "Todo" ) { | 2477 | if ( newInc->type() == "Todo" ) { |
2538 | Todo* t = (Todo*) newInc; | 2478 | Todo* t = (Todo*) newInc; |
2539 | mTodoEditor->editTodo( t ); | 2479 | mTodoEditor->editTodo( t ); |
2540 | showTodoEditor(); | 2480 | showTodoEditor(); |
2541 | if ( mTodoEditor->exec() ) { | 2481 | if ( mTodoEditor->exec() ) { |
2542 | mCalendar->addTodo( t ); | 2482 | mCalendar->addTodo( t ); |
2543 | updateView(); | 2483 | updateView(); |
2544 | } else { | 2484 | } else { |
2545 | delete t; | 2485 | delete t; |
2546 | } | 2486 | } |
2547 | } | 2487 | } |
2548 | else { | 2488 | else { |
2549 | Event* e = (Event*) newInc; | 2489 | Event* e = (Event*) newInc; |
2550 | mEventEditor->editEvent( e ); | 2490 | mEventEditor->editEvent( e ); |
2551 | showEventEditor(); | 2491 | showEventEditor(); |
2552 | if ( mEventEditor->exec() ) { | 2492 | if ( mEventEditor->exec() ) { |
2553 | mCalendar->addEvent( e ); | 2493 | mCalendar->addEvent( e ); |
2554 | updateView(); | 2494 | updateView(); |
2555 | } else { | 2495 | } else { |
2556 | delete e; | 2496 | delete e; |
2557 | } | 2497 | } |
2558 | } | 2498 | } |
2559 | } | 2499 | } |
2560 | 2500 | ||
2561 | void CalendarView::newEvent() | 2501 | void CalendarView::newEvent() |
2562 | { | 2502 | { |
2563 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 2503 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
2564 | KOAgendaView *aView = mViewManager->agendaView(); | 2504 | KOAgendaView *aView = mViewManager->agendaView(); |
2565 | if (aView) { | 2505 | if (aView) { |
2566 | if (aView->selectionStart().isValid()) { | 2506 | if (aView->selectionStart().isValid()) { |
2567 | if (aView->selectedIsAllDay()) { | 2507 | if (aView->selectedIsAllDay()) { |
2568 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 2508 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
2569 | } else { | 2509 | } else { |
2570 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 2510 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
2571 | } | 2511 | } |
2572 | return; | 2512 | return; |
2573 | } | 2513 | } |
2574 | } | 2514 | } |
2575 | 2515 | ||
2576 | QDate date = mNavigator->selectedDates().first(); | 2516 | QDate date = mNavigator->selectedDates().first(); |
2577 | QDateTime current = QDateTime::currentDateTime(); | 2517 | QDateTime current = QDateTime::currentDateTime(); |
2578 | if ( date <= current.date() ) { | 2518 | if ( date <= current.date() ) { |
2579 | int hour = current.time().hour() +1; | 2519 | int hour = current.time().hour() +1; |
2580 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 2520 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
2581 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2521 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2582 | } else | 2522 | } else |
2583 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 2523 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
2584 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 2524 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
2585 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2525 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2586 | } | 2526 | } |
2587 | 2527 | ||
2588 | void CalendarView::newEvent(QDateTime fh) | 2528 | void CalendarView::newEvent(QDateTime fh) |
2589 | { | 2529 | { |
2590 | newEvent(fh, | 2530 | newEvent(fh, |
2591 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 2531 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
2592 | } | 2532 | } |
2593 | 2533 | ||
2594 | void CalendarView::newEvent(QDate dt) | 2534 | void CalendarView::newEvent(QDate dt) |
2595 | { | 2535 | { |
2596 | newEvent(QDateTime(dt, QTime(0,0,0)), | 2536 | newEvent(QDateTime(dt, QTime(0,0,0)), |
2597 | QDateTime(dt, QTime(0,0,0)), true); | 2537 | QDateTime(dt, QTime(0,0,0)), true); |
2598 | } | 2538 | } |
2599 | 2539 | ||
2600 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 2540 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
2601 | { | 2541 | { |
2602 | 2542 | ||
2603 | mEventEditor->newEvent(fromHint,toHint,allDay); | 2543 | mEventEditor->newEvent(fromHint,toHint,allDay); |
2604 | if ( mFilterView->filtersEnabled() ) { | 2544 | if ( mFilterView->filtersEnabled() ) { |
2605 | CalFilter *filter = mFilterView->selectedFilter(); | 2545 | CalFilter *filter = mFilterView->selectedFilter(); |
2606 | if (filter && filter->showCategories()) { | 2546 | if (filter && filter->showCategories()) { |
2607 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 2547 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
2608 | } | 2548 | } |
2609 | if ( filter ) | 2549 | if ( filter ) |
2610 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 2550 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
2611 | } | 2551 | } |
2612 | showEventEditor(); | 2552 | showEventEditor(); |
2613 | } | 2553 | } |
2614 | void CalendarView::todoAdded(Todo * t) | 2554 | void CalendarView::todoAdded(Todo * t) |
2615 | { | 2555 | { |
2616 | 2556 | ||
2617 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 2557 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
2618 | updateTodoViews(); | 2558 | updateTodoViews(); |
2619 | } | 2559 | } |
2620 | void CalendarView::todoChanged(Todo * t) | 2560 | void CalendarView::todoChanged(Todo * t) |
2621 | { | 2561 | { |
2622 | emit todoModified( t, 4 ); | 2562 | emit todoModified( t, 4 ); |
2623 | // updateTodoViews(); | 2563 | // updateTodoViews(); |
2624 | } | 2564 | } |
2625 | void CalendarView::todoToBeDeleted(Todo *) | 2565 | void CalendarView::todoToBeDeleted(Todo *) |
2626 | { | 2566 | { |
2627 | //qDebug("todoToBeDeleted(Todo *) "); | 2567 | //qDebug("todoToBeDeleted(Todo *) "); |
2628 | updateTodoViews(); | 2568 | updateTodoViews(); |
2629 | } | 2569 | } |
2630 | void CalendarView::todoDeleted() | 2570 | void CalendarView::todoDeleted() |
2631 | { | 2571 | { |
@@ -3387,387 +3327,407 @@ void CalendarView::processIncidenceSelection( Incidence *incidence ) | |||
3387 | return; | 3327 | return; |
3388 | } | 3328 | } |
3389 | 3329 | ||
3390 | /* if ( incidence && incidence->type() == "Todo" ) { | 3330 | /* if ( incidence && incidence->type() == "Todo" ) { |
3391 | emit todoSelected( true ); | 3331 | emit todoSelected( true ); |
3392 | } else { | 3332 | } else { |
3393 | emit todoSelected( false ); | 3333 | emit todoSelected( false ); |
3394 | }*/ | 3334 | }*/ |
3395 | } | 3335 | } |
3396 | 3336 | ||
3397 | 3337 | ||
3398 | void CalendarView::checkClipboard() | 3338 | void CalendarView::checkClipboard() |
3399 | { | 3339 | { |
3400 | #ifndef KORG_NODND | 3340 | #ifndef KORG_NODND |
3401 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { | 3341 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { |
3402 | emit pasteEnabled(true); | 3342 | emit pasteEnabled(true); |
3403 | } else { | 3343 | } else { |
3404 | emit pasteEnabled(false); | 3344 | emit pasteEnabled(false); |
3405 | } | 3345 | } |
3406 | #endif | 3346 | #endif |
3407 | } | 3347 | } |
3408 | 3348 | ||
3409 | void CalendarView::showDates(const DateList &selectedDates) | 3349 | void CalendarView::showDates(const DateList &selectedDates) |
3410 | { | 3350 | { |
3411 | // kdDebug() << "CalendarView::selectDates()" << endl; | 3351 | // kdDebug() << "CalendarView::selectDates()" << endl; |
3412 | 3352 | ||
3413 | if ( mViewManager->currentView() ) { | 3353 | if ( mViewManager->currentView() ) { |
3414 | updateView( selectedDates.first(), selectedDates.last() ); | 3354 | updateView( selectedDates.first(), selectedDates.last() ); |
3415 | } else { | 3355 | } else { |
3416 | mViewManager->showAgendaView(); | 3356 | mViewManager->showAgendaView(); |
3417 | } | 3357 | } |
3418 | 3358 | ||
3419 | QString selDates; | 3359 | QString selDates; |
3420 | selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); | 3360 | selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); |
3421 | if (selectedDates.first() < selectedDates.last() ) | 3361 | if (selectedDates.first() < selectedDates.last() ) |
3422 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); | 3362 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); |
3423 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); | 3363 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); |
3424 | 3364 | ||
3425 | } | 3365 | } |
3426 | 3366 | ||
3427 | QPtrList<CalFilter> CalendarView::filters() | 3367 | QPtrList<CalFilter> CalendarView::filters() |
3428 | { | 3368 | { |
3429 | return mFilters; | 3369 | return mFilters; |
3430 | 3370 | ||
3431 | } | 3371 | } |
3432 | void CalendarView::editFilters() | 3372 | void CalendarView::editFilters() |
3433 | { | 3373 | { |
3434 | // kdDebug() << "CalendarView::editFilters()" << endl; | 3374 | // kdDebug() << "CalendarView::editFilters()" << endl; |
3435 | 3375 | ||
3436 | CalFilter *filter = mFilters.first(); | 3376 | CalFilter *filter = mFilters.first(); |
3437 | while(filter) { | 3377 | while(filter) { |
3438 | kdDebug() << " Filter: " << filter->name() << endl; | 3378 | kdDebug() << " Filter: " << filter->name() << endl; |
3439 | filter = mFilters.next(); | 3379 | filter = mFilters.next(); |
3440 | } | 3380 | } |
3441 | 3381 | ||
3442 | mDialogManager->showFilterEditDialog(&mFilters); | 3382 | mDialogManager->showFilterEditDialog(&mFilters); |
3443 | } | 3383 | } |
3444 | void CalendarView::toggleFilter() | 3384 | void CalendarView::toggleFilter() |
3445 | { | 3385 | { |
3446 | showFilter(! mFilterView->isVisible()); | 3386 | showFilter(! mFilterView->isVisible()); |
3447 | } | 3387 | } |
3448 | 3388 | ||
3449 | KOFilterView *CalendarView::filterView() | 3389 | KOFilterView *CalendarView::filterView() |
3450 | { | 3390 | { |
3451 | return mFilterView; | 3391 | return mFilterView; |
3452 | } | 3392 | } |
3453 | void CalendarView::selectFilter( int fil ) | 3393 | void CalendarView::selectFilter( int fil ) |
3454 | { | 3394 | { |
3455 | mFilterView->setSelectedFilter( fil ); | 3395 | mFilterView->setSelectedFilter( fil ); |
3456 | } | 3396 | } |
3457 | void CalendarView::showFilter(bool visible) | 3397 | void CalendarView::showFilter(bool visible) |
3458 | { | 3398 | { |
3459 | if (visible) mFilterView->show(); | 3399 | if (visible) mFilterView->show(); |
3460 | else mFilterView->hide(); | 3400 | else mFilterView->hide(); |
3461 | } | 3401 | } |
3462 | void CalendarView::toggleFilerEnabled( ) | 3402 | void CalendarView::toggleFilerEnabled( ) |
3463 | { | 3403 | { |
3464 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); | 3404 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); |
3465 | if ( !mFilterView->filtersEnabled() ) | 3405 | if ( !mFilterView->filtersEnabled() ) |
3466 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); | 3406 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); |
3467 | 3407 | ||
3468 | } | 3408 | } |
3469 | void CalendarView::updateFilter() | 3409 | void CalendarView::updateFilter() |
3470 | { | 3410 | { |
3471 | CalFilter *filter = mFilterView->selectedFilter(); | 3411 | CalFilter *filter = mFilterView->selectedFilter(); |
3472 | if (filter) { | 3412 | if (filter) { |
3473 | if (mFilterView->filtersEnabled()) { | 3413 | if (mFilterView->filtersEnabled()) { |
3474 | topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); | 3414 | topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); |
3475 | filter->setEnabled(true); | 3415 | filter->setEnabled(true); |
3476 | } | 3416 | } |
3477 | else filter->setEnabled(false); | 3417 | else filter->setEnabled(false); |
3478 | mCalendar->setFilter(filter); | 3418 | mCalendar->setFilter(filter); |
3479 | updateView(); | 3419 | updateView(); |
3480 | } | 3420 | } |
3481 | } | 3421 | } |
3482 | 3422 | ||
3483 | void CalendarView::filterEdited() | 3423 | void CalendarView::filterEdited() |
3484 | { | 3424 | { |
3485 | mFilterView->updateFilters(); | 3425 | mFilterView->updateFilters(); |
3486 | updateFilter(); | 3426 | updateFilter(); |
3487 | writeSettings(); | 3427 | writeSettings(); |
3488 | } | 3428 | } |
3489 | 3429 | ||
3490 | 3430 | ||
3491 | void CalendarView::takeOverEvent() | 3431 | void CalendarView::takeOverEvent() |
3492 | { | 3432 | { |
3493 | Incidence *incidence = currentSelection(); | 3433 | Incidence *incidence = currentSelection(); |
3494 | 3434 | ||
3495 | if (!incidence) return; | 3435 | if (!incidence) return; |
3496 | 3436 | ||
3497 | incidence->setOrganizer(KOPrefs::instance()->email()); | 3437 | incidence->setOrganizer(KOPrefs::instance()->email()); |
3498 | incidence->recreate(); | 3438 | incidence->recreate(); |
3499 | incidence->setReadOnly(false); | 3439 | incidence->setReadOnly(false); |
3500 | 3440 | ||
3501 | updateView(); | 3441 | updateView(); |
3502 | } | 3442 | } |
3503 | 3443 | ||
3504 | void CalendarView::takeOverCalendar() | 3444 | void CalendarView::takeOverCalendar() |
3505 | { | 3445 | { |
3506 | // TODO: Create Calendar::allIncidences() function and use it here | 3446 | // TODO: Create Calendar::allIncidences() function and use it here |
3507 | 3447 | ||
3508 | QPtrList<Event> events = mCalendar->events(); | 3448 | QPtrList<Event> events = mCalendar->events(); |
3509 | for(uint i=0; i<events.count(); ++i) { | 3449 | for(uint i=0; i<events.count(); ++i) { |
3510 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3450 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3511 | events.at(i)->recreate(); | 3451 | events.at(i)->recreate(); |
3512 | events.at(i)->setReadOnly(false); | 3452 | events.at(i)->setReadOnly(false); |
3513 | } | 3453 | } |
3514 | 3454 | ||
3515 | QPtrList<Todo> todos = mCalendar->todos(); | 3455 | QPtrList<Todo> todos = mCalendar->todos(); |
3516 | for(uint i=0; i<todos.count(); ++i) { | 3456 | for(uint i=0; i<todos.count(); ++i) { |
3517 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3457 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3518 | todos.at(i)->recreate(); | 3458 | todos.at(i)->recreate(); |
3519 | todos.at(i)->setReadOnly(false); | 3459 | todos.at(i)->setReadOnly(false); |
3520 | } | 3460 | } |
3521 | 3461 | ||
3522 | QPtrList<Journal> journals = mCalendar->journals(); | 3462 | QPtrList<Journal> journals = mCalendar->journals(); |
3523 | for(uint i=0; i<journals.count(); ++i) { | 3463 | for(uint i=0; i<journals.count(); ++i) { |
3524 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3464 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3525 | journals.at(i)->recreate(); | 3465 | journals.at(i)->recreate(); |
3526 | journals.at(i)->setReadOnly(false); | 3466 | journals.at(i)->setReadOnly(false); |
3527 | } | 3467 | } |
3528 | 3468 | ||
3529 | updateView(); | 3469 | updateView(); |
3530 | } | 3470 | } |
3531 | 3471 | ||
3532 | void CalendarView::showIntro() | 3472 | void CalendarView::showIntro() |
3533 | { | 3473 | { |
3534 | kdDebug() << "To be implemented." << endl; | 3474 | kdDebug() << "To be implemented." << endl; |
3535 | } | 3475 | } |
3536 | 3476 | ||
3537 | QWidgetStack *CalendarView::viewStack() | 3477 | QWidgetStack *CalendarView::viewStack() |
3538 | { | 3478 | { |
3539 | return mRightFrame; | 3479 | return mRightFrame; |
3540 | } | 3480 | } |
3541 | 3481 | ||
3542 | QWidget *CalendarView::leftFrame() | 3482 | QWidget *CalendarView::leftFrame() |
3543 | { | 3483 | { |
3544 | return mLeftFrame; | 3484 | return mLeftFrame; |
3545 | } | 3485 | } |
3546 | 3486 | ||
3547 | DateNavigator *CalendarView::dateNavigator() | 3487 | DateNavigator *CalendarView::dateNavigator() |
3548 | { | 3488 | { |
3549 | return mNavigator; | 3489 | return mNavigator; |
3550 | } | 3490 | } |
3551 | 3491 | ||
3552 | KDateNavigator* CalendarView::dateNavigatorWidget() | 3492 | KDateNavigator* CalendarView::dateNavigatorWidget() |
3553 | { | 3493 | { |
3554 | return mDateNavigator; | 3494 | return mDateNavigator; |
3555 | } | 3495 | } |
3556 | void CalendarView::toggleDateNavigatorWidget() | 3496 | void CalendarView::toggleDateNavigatorWidget() |
3557 | { | 3497 | { |
3558 | if (mDateNavigator->isVisible()) | 3498 | if (mDateNavigator->isVisible()) |
3559 | mDateNavigator->hide(); | 3499 | mDateNavigator->hide(); |
3560 | else | 3500 | else |
3561 | mDateNavigator->show(); | 3501 | mDateNavigator->show(); |
3562 | } | 3502 | } |
3563 | void CalendarView::addView(KOrg::BaseView *view) | 3503 | void CalendarView::addView(KOrg::BaseView *view) |
3564 | { | 3504 | { |
3565 | mViewManager->addView(view); | 3505 | mViewManager->addView(view); |
3566 | } | 3506 | } |
3567 | 3507 | ||
3568 | void CalendarView::showView(KOrg::BaseView *view) | 3508 | void CalendarView::showView(KOrg::BaseView *view) |
3569 | { | 3509 | { |
3570 | mViewManager->showView(view, mLeftFrame->isVisible()); | 3510 | mViewManager->showView(view, mLeftFrame->isVisible()); |
3571 | } | 3511 | } |
3572 | 3512 | ||
3573 | Incidence *CalendarView::currentSelection() | 3513 | Incidence *CalendarView::currentSelection() |
3574 | { | 3514 | { |
3575 | return mViewManager->currentSelection(); | 3515 | return mViewManager->currentSelection(); |
3576 | } | 3516 | } |
3577 | void CalendarView::toggleAllDaySize() | 3517 | void CalendarView::toggleAllDaySize() |
3578 | { | 3518 | { |
3579 | /* | 3519 | /* |
3580 | if ( KOPrefs::instance()->mAllDaySize > 47 ) | 3520 | if ( KOPrefs::instance()->mAllDaySize > 47 ) |
3581 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; | 3521 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; |
3582 | else | 3522 | else |
3583 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; | 3523 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; |
3584 | */ | 3524 | */ |
3585 | viewManager()->agendaView()->toggleAllDay(); | 3525 | viewManager()->agendaView()->toggleAllDay(); |
3586 | } | 3526 | } |
3587 | void CalendarView::toggleExpand() | 3527 | void CalendarView::toggleExpand() |
3588 | { | 3528 | { |
3589 | // if ( mLeftFrame->isHidden() ) { | 3529 | // if ( mLeftFrame->isHidden() ) { |
3590 | // mLeftFrame->show(); | 3530 | // mLeftFrame->show(); |
3591 | // emit calendarViewExpanded( false ); | 3531 | // emit calendarViewExpanded( false ); |
3592 | // } else { | 3532 | // } else { |
3593 | // mLeftFrame->hide(); | 3533 | // mLeftFrame->hide(); |
3594 | // emit calendarViewExpanded( true ); | 3534 | // emit calendarViewExpanded( true ); |
3595 | // } | 3535 | // } |
3596 | 3536 | ||
3597 | globalFlagBlockAgenda = 1; | 3537 | globalFlagBlockAgenda = 1; |
3598 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); | 3538 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); |
3599 | globalFlagBlockAgenda = 5; | 3539 | globalFlagBlockAgenda = 5; |
3600 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); | 3540 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); |
3601 | //mViewManager->showView( 0, true ); | 3541 | //mViewManager->showView( 0, true ); |
3602 | } | 3542 | } |
3603 | 3543 | ||
3604 | void CalendarView::calendarModified( bool modified, Calendar * ) | 3544 | void CalendarView::calendarModified( bool modified, Calendar * ) |
3605 | { | 3545 | { |
3606 | setModified( modified ); | 3546 | setModified( modified ); |
3607 | } | 3547 | } |
3608 | 3548 | ||
3609 | Todo *CalendarView::selectedTodo() | 3549 | Todo *CalendarView::selectedTodo() |
3610 | { | 3550 | { |
3611 | Incidence *incidence = currentSelection(); | 3551 | Incidence *incidence = currentSelection(); |
3612 | if ( incidence && incidence->type() == "Todo" ) { | 3552 | if ( incidence && incidence->type() == "Todo" ) { |
3613 | return static_cast<Todo *>( incidence ); | 3553 | return static_cast<Todo *>( incidence ); |
3614 | } | 3554 | } |
3615 | 3555 | ||
3616 | incidence = mTodoList->selectedIncidences().first(); | 3556 | incidence = mTodoList->selectedIncidences().first(); |
3617 | if ( incidence && incidence->type() == "Todo" ) { | 3557 | if ( incidence && incidence->type() == "Todo" ) { |
3618 | return static_cast<Todo *>( incidence ); | 3558 | return static_cast<Todo *>( incidence ); |
3619 | } | 3559 | } |
3620 | 3560 | ||
3621 | return 0; | 3561 | return 0; |
3622 | } | 3562 | } |
3623 | 3563 | ||
3624 | void CalendarView::dialogClosing(Incidence *in) | 3564 | void CalendarView::dialogClosing(Incidence *in) |
3625 | { | 3565 | { |
3626 | // mDialogList.remove(in); | 3566 | // mDialogList.remove(in); |
3627 | } | 3567 | } |
3628 | 3568 | ||
3629 | void CalendarView::showIncidence() | 3569 | void CalendarView::showIncidence() |
3630 | { | 3570 | { |
3631 | Incidence *incidence = currentSelection(); | 3571 | Incidence *incidence = currentSelection(); |
3632 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3572 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3633 | if ( incidence ) { | 3573 | if ( incidence ) { |
3634 | ShowIncidenceVisitor v; | 3574 | ShowIncidenceVisitor v; |
3635 | v.act( incidence, this ); | 3575 | v.act( incidence, this ); |
3636 | } | 3576 | } |
3637 | } | 3577 | } |
3638 | void CalendarView::editIncidenceDescription() | 3578 | void CalendarView::editIncidenceDescription() |
3639 | { | 3579 | { |
3640 | mFlagEditDescription = true; | 3580 | mFlagEditDescription = true; |
3641 | editIncidence(); | 3581 | editIncidence(); |
3642 | mFlagEditDescription = false; | 3582 | mFlagEditDescription = false; |
3643 | } | 3583 | } |
3644 | void CalendarView::editIncidence() | 3584 | void CalendarView::editIncidence() |
3645 | { | 3585 | { |
3646 | // qDebug("editIncidence() "); | 3586 | // qDebug("editIncidence() "); |
3647 | Incidence *incidence = currentSelection(); | 3587 | Incidence *incidence = currentSelection(); |
3648 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3588 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3649 | if ( incidence ) { | 3589 | if ( incidence ) { |
3650 | EditIncidenceVisitor v; | 3590 | EditIncidenceVisitor v; |
3651 | v.act( incidence, this ); | 3591 | v.act( incidence, this ); |
3652 | } | 3592 | } |
3653 | } | 3593 | } |
3654 | 3594 | ||
3655 | void CalendarView::deleteIncidence() | 3595 | void CalendarView::deleteIncidence() |
3656 | { | 3596 | { |
3657 | Incidence *incidence = currentSelection(); | 3597 | Incidence *incidence = currentSelection(); |
3658 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3598 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3659 | if ( incidence ) { | 3599 | if ( incidence ) { |
3660 | deleteIncidence(incidence); | 3600 | deleteIncidence(incidence); |
3661 | } | 3601 | } |
3662 | } | 3602 | } |
3663 | 3603 | ||
3664 | void CalendarView::showIncidence(Incidence *incidence) | 3604 | void CalendarView::showIncidence(Incidence *incidence) |
3665 | { | 3605 | { |
3666 | if ( incidence ) { | 3606 | if ( incidence ) { |
3667 | ShowIncidenceVisitor v; | 3607 | ShowIncidenceVisitor v; |
3668 | v.act( incidence, this ); | 3608 | v.act( incidence, this ); |
3669 | } | 3609 | } |
3670 | } | 3610 | } |
3671 | 3611 | ||
3672 | void CalendarView::editIncidence(Incidence *incidence) | 3612 | void CalendarView::editIncidence(Incidence *incidence) |
3673 | { | 3613 | { |
3674 | if ( incidence ) { | 3614 | if ( incidence ) { |
3675 | 3615 | ||
3676 | EditIncidenceVisitor v; | 3616 | EditIncidenceVisitor v; |
3677 | v.act( incidence, this ); | 3617 | v.act( incidence, this ); |
3678 | 3618 | ||
3679 | } | 3619 | } |
3680 | } | 3620 | } |
3681 | 3621 | ||
3682 | void CalendarView::deleteIncidence(Incidence *incidence) | 3622 | void CalendarView::deleteIncidence(Incidence *incidence) |
3683 | { | 3623 | { |
3684 | //qDebug(" CalendarView::deleteIncidence "); | 3624 | //qDebug(" CalendarView::deleteIncidence "); |
3685 | if ( incidence ) { | 3625 | if ( incidence ) { |
3686 | DeleteIncidenceVisitor v; | 3626 | DeleteIncidenceVisitor v; |
3687 | v.act( incidence, this ); | 3627 | v.act( incidence, this ); |
3688 | } | 3628 | } |
3689 | } | 3629 | } |
3690 | 3630 | ||
3691 | 3631 | ||
3692 | void CalendarView::lookForOutgoingMessages() | 3632 | void CalendarView::lookForOutgoingMessages() |
3693 | { | 3633 | { |
3694 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); | 3634 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); |
3695 | ogd->loadMessages(); | 3635 | ogd->loadMessages(); |
3696 | } | 3636 | } |
3697 | 3637 | ||
3698 | void CalendarView::lookForIncomingMessages() | 3638 | void CalendarView::lookForIncomingMessages() |
3699 | { | 3639 | { |
3700 | IncomingDialog *icd = mDialogManager->incomingDialog(); | 3640 | IncomingDialog *icd = mDialogManager->incomingDialog(); |
3701 | icd->retrieve(); | 3641 | icd->retrieve(); |
3702 | } | 3642 | } |
3703 | 3643 | ||
3704 | bool CalendarView::removeCompletedSubTodos( Todo* t ) | 3644 | bool CalendarView::removeCompletedSubTodos( Todo* t ) |
3705 | { | 3645 | { |
3706 | bool deleteTodo = true; | 3646 | bool deleteTodo = true; |
3707 | QPtrList<Incidence> subTodos; | 3647 | QPtrList<Incidence> subTodos; |
3708 | Incidence *aTodo; | 3648 | Incidence *aTodo; |
3709 | subTodos = t->relations(); | 3649 | subTodos = t->relations(); |
3710 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { | 3650 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { |
3711 | if (! removeCompletedSubTodos( (Todo*) aTodo )) | 3651 | if (! removeCompletedSubTodos( (Todo*) aTodo )) |
3712 | deleteTodo = false; | 3652 | deleteTodo = false; |
3713 | } | 3653 | } |
3714 | if ( deleteTodo ) { | 3654 | if ( deleteTodo ) { |
3715 | if ( t->isCompleted() ) { | 3655 | if ( t->isCompleted() ) { |
3716 | checkExternalId( t ); | 3656 | checkExternalId( t ); |
3717 | mCalendar->deleteTodo( t ); | 3657 | mCalendar->deleteTodo( t ); |
3718 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); | 3658 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); |
3719 | } | 3659 | } |
3720 | else | 3660 | else |
3721 | deleteTodo = false; | 3661 | deleteTodo = false; |
3722 | } | 3662 | } |
3723 | return deleteTodo; | 3663 | return deleteTodo; |
3724 | 3664 | ||
3725 | } | 3665 | } |
3726 | void CalendarView::purgeCompleted() | 3666 | void CalendarView::purgeCompleted() |
3727 | { | 3667 | { |
3728 | int result = KMessageBox::warningContinueCancel(this, | 3668 | int result = KMessageBox::warningContinueCancel(this, |
3729 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); | 3669 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); |
3730 | 3670 | ||
3731 | if (result == KMessageBox::Continue) { | 3671 | if (result == KMessageBox::Continue) { |
3732 | 3672 | ||
3733 | QPtrList<Todo> todoCal; | 3673 | QPtrList<Todo> todoCal; |
3734 | QPtrList<Todo> rootTodos; | 3674 | QPtrList<Todo> rootTodos; |
3735 | //QPtrList<Incidence> rel; | 3675 | //QPtrList<Incidence> rel; |
3736 | Todo *aTodo;//, *rTodo; | 3676 | Todo *aTodo;//, *rTodo; |
3737 | Incidence *rIncidence; | 3677 | Incidence *rIncidence; |
3738 | bool childDelete = false; | 3678 | bool childDelete = false; |
3739 | bool deletedOne = true; | 3679 | bool deletedOne = true; |
3740 | todoCal = calendar()->todos(); | 3680 | todoCal = calendar()->todos(); |
3741 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { | 3681 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { |
3742 | if ( !aTodo->relatedTo() ) | 3682 | if ( !aTodo->relatedTo() ) |
3743 | rootTodos.append( aTodo ); | 3683 | rootTodos.append( aTodo ); |
3744 | } | 3684 | } |
3745 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { | 3685 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { |
3746 | removeCompletedSubTodos( aTodo ); | 3686 | removeCompletedSubTodos( aTodo ); |
3747 | } | 3687 | } |
3748 | 3688 | ||
3749 | updateView(); | 3689 | updateView(); |
3750 | } | 3690 | } |
3751 | } | 3691 | } |
3752 | 3692 | ||
3753 | void CalendarView::slotCalendarChanged() | 3693 | void CalendarView::slotCalendarChanged() |
3754 | { | 3694 | { |
3755 | ; | 3695 | ; |
3756 | } | 3696 | } |
3757 | 3697 | ||
3758 | NavigatorBar *CalendarView::navigatorBar() | 3698 | NavigatorBar *CalendarView::navigatorBar() |
3759 | { | 3699 | { |
3760 | return mNavigatorBar; | 3700 | return mNavigatorBar; |
3761 | } | 3701 | } |
3762 | 3702 | ||
3763 | 3703 | ||
3764 | 3704 | ||
3765 | void CalendarView::keyPressEvent ( QKeyEvent *e) | 3705 | void CalendarView::keyPressEvent ( QKeyEvent *e) |
3766 | { | 3706 | { |
3767 | //qDebug(" alendarView::keyPressEvent "); | 3707 | //qDebug(" alendarView::keyPressEvent "); |
3768 | e->ignore(); | 3708 | e->ignore(); |
3769 | } | 3709 | } |
3770 | 3710 | ||
3771 | //#include "calendarview.moc" | ||
3772 | 3711 | ||
3773 | //#include "calendarviewbase.moc" | 3712 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) |
3713 | { | ||
3714 | // mSyncManager = manager; | ||
3715 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | ||
3716 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | ||
3717 | return syncCalendar( filename, mode ); | ||
3718 | } | ||
3719 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) | ||
3720 | { | ||
3721 | //mSyncManager = manager; | ||
3722 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | ||
3723 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | ||
3724 | if ( resource == "sharp" ) | ||
3725 | syncExternal( 0 ); | ||
3726 | if ( resource == "phone" ) | ||
3727 | syncExternal( 1 ); | ||
3728 | // pending setmodified | ||
3729 | } | ||
3730 | void CalendarView::setSyncManager(KSyncManager* manager) | ||
3731 | { | ||
3732 | mSyncManager = manager; | ||
3733 | } | ||
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h index 8d329a9..751b8d9 100644 --- a/korganizer/calendarview.h +++ b/korganizer/calendarview.h | |||
@@ -1,599 +1,606 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000, 2001 | 3 | Copyright (c) 2000, 2001 |
4 | Cornelius Schumacher <schumacher@kde.org> | 4 | Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or | 8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | 9 | (at your option) any later version. |
10 | 10 | ||
11 | This program is distributed in the hope that it will be useful, | 11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. | 14 | GNU General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU General Public License | 16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software | 17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | 19 | ||
20 | As a special exception, permission is given to link this program | 20 | As a special exception, permission is given to link this program |
21 | with any edition of Qt, and distribute the resulting executable, | 21 | with any edition of Qt, and distribute the resulting executable, |
22 | without including the source code for Qt in the source distribution. | 22 | without including the source code for Qt in the source distribution. |
23 | */ | 23 | */ |
24 | #ifndef CALENDARVIEW_H | 24 | #ifndef CALENDARVIEW_H |
25 | #define CALENDARVIEW_H | 25 | #define CALENDARVIEW_H |
26 | 26 | ||
27 | #include <qframe.h> | 27 | #include <qframe.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include <qwidget.h> | 29 | #include <qwidget.h> |
30 | #include <qptrlist.h> | 30 | #include <qptrlist.h> |
31 | #include <qvbox.h> | 31 | #include <qvbox.h> |
32 | #include <qmap.h> | 32 | #include <qmap.h> |
33 | #ifndef DESKTOP_VERSION | 33 | #ifndef DESKTOP_VERSION |
34 | #include <qtopia/ir.h> | 34 | #include <qtopia/ir.h> |
35 | #else | 35 | #else |
36 | #define Ir char | 36 | #define Ir char |
37 | #endif | 37 | #endif |
38 | #include <libkcal/calendar.h> | 38 | #include <libkcal/calendar.h> |
39 | #include <libkcal/scheduler.h> | 39 | #include <libkcal/scheduler.h> |
40 | #include <libkcal/calendarresources.h> | 40 | #include <libkcal/calendarresources.h> |
41 | #include <libkcal/resourcecalendar.h> | 41 | #include <libkcal/resourcecalendar.h> |
42 | 42 | ||
43 | #include <korganizer/calendarviewbase.h> | 43 | #include <korganizer/calendarviewbase.h> |
44 | 44 | ||
45 | #include <ksyncmanager.h> | ||
46 | |||
45 | class QWidgetStack; | 47 | class QWidgetStack; |
46 | class QSplitter; | 48 | class QSplitter; |
47 | 49 | ||
48 | class CalPrinter; | 50 | class CalPrinter; |
49 | class KOFilterView; | 51 | class KOFilterView; |
50 | class KOViewManager; | 52 | class KOViewManager; |
51 | class KODialogManager; | 53 | class KODialogManager; |
52 | class KOTodoView; | 54 | class KOTodoView; |
53 | class KDateNavigator; | 55 | class KDateNavigator; |
54 | class DateNavigator; | 56 | class DateNavigator; |
55 | class KOIncidenceEditor; | 57 | class KOIncidenceEditor; |
56 | class KDatePicker; | 58 | class KDatePicker; |
57 | class ResourceView; | 59 | class ResourceView; |
58 | class NavigatorBar; | 60 | class NavigatorBar; |
59 | class KOEventEditor; | 61 | class KOEventEditor; |
60 | class KOTodoEditor ; | 62 | class KOTodoEditor ; |
61 | class KOEventViewerDialog; | 63 | class KOEventViewerDialog; |
62 | class KOBeamPrefs; | 64 | class KOBeamPrefs; |
63 | class KSyncProfile; | 65 | class KSyncProfile; |
64 | class AlarmDialog; | 66 | class AlarmDialog; |
65 | class KCal::Attendee; | 67 | class KCal::Attendee; |
66 | 68 | ||
67 | namespace KCal { class FileStorage; } | 69 | namespace KCal { class FileStorage; } |
68 | 70 | ||
69 | using namespace KCal; | 71 | using namespace KCal; |
70 | 72 | ||
71 | /** | 73 | /** |
72 | This is the main calendar widget. It provides the different vies on t he | 74 | This is the main calendar widget. It provides the different vies on t he |
73 | calendar data as well as the date navigator. It also handles synchronisation | 75 | calendar data as well as the date navigator. It also handles synchronisation |
74 | of the different views and controls the different dialogs like preferences, | 76 | of the different views and controls the different dialogs like preferences, |
75 | event editor, search dialog etc. | 77 | event editor, search dialog etc. |
76 | 78 | ||
77 | @short main calendar view widget | 79 | @short main calendar view widget |
78 | @author Cornelius Schumacher | 80 | @author Cornelius Schumacher |
79 | */ | 81 | */ |
80 | class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer | 82 | class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface |
81 | { | 83 | { |
82 | Q_OBJECT | 84 | Q_OBJECT |
83 | public: | 85 | public: |
84 | /** | 86 | /** |
85 | Constructs a new calendar view widget. | 87 | Constructs a new calendar view widget. |
86 | 88 | ||
87 | @param calendar calendar document | 89 | @param calendar calendar document |
88 | @param parent parent window | 90 | @param parent parent window |
89 | @param name Qt internal widget object name | 91 | @param name Qt internal widget object name |
90 | */ | 92 | */ |
91 | CalendarView( CalendarResources *calendar, QWidget *parent = 0, | 93 | CalendarView( CalendarResources *calendar, QWidget *parent = 0, |
92 | const char *name = 0 ); | 94 | const char *name = 0 ); |
93 | CalendarView( Calendar *calendar, QWidget *parent = 0, | 95 | CalendarView( Calendar *calendar, QWidget *parent = 0, |
94 | const char *name = 0 ); | 96 | const char *name = 0 ); |
95 | virtual ~CalendarView(); | 97 | virtual ~CalendarView(); |
96 | 98 | ||
97 | Calendar *calendar() { return mCalendar; } | 99 | Calendar *calendar() { return mCalendar; } |
98 | 100 | ||
99 | KOViewManager *viewManager(); | 101 | KOViewManager *viewManager(); |
100 | KODialogManager *dialogManager(); | 102 | KODialogManager *dialogManager(); |
101 | 103 | ||
102 | QDate startDate(); | 104 | QDate startDate(); |
103 | QDate endDate(); | 105 | QDate endDate(); |
104 | 106 | ||
105 | QWidgetStack *viewStack(); | 107 | QWidgetStack *viewStack(); |
106 | QWidget *leftFrame(); | 108 | QWidget *leftFrame(); |
107 | NavigatorBar *navigatorBar(); | 109 | NavigatorBar *navigatorBar(); |
108 | 110 | ||
109 | DateNavigator *dateNavigator(); | 111 | DateNavigator *dateNavigator(); |
110 | KDateNavigator *dateNavigatorWidget(); | 112 | KDateNavigator *dateNavigatorWidget(); |
111 | 113 | ||
112 | void addView(KOrg::BaseView *); | 114 | void addView(KOrg::BaseView *); |
113 | void showView(KOrg::BaseView *); | 115 | void showView(KOrg::BaseView *); |
114 | KOEventViewerDialog* getEventViewerDialog(); | 116 | KOEventViewerDialog* getEventViewerDialog(); |
115 | Incidence *currentSelection(); | 117 | Incidence *currentSelection(); |
116 | 118 | ||
117 | signals: | 119 | signals: |
118 | /** This todo has been modified */ | 120 | /** This todo has been modified */ |
119 | void todoModified(Todo *, int); | 121 | void todoModified(Todo *, int); |
120 | 122 | ||
121 | /** when change is made to options dialog, the topwidget will catch this | 123 | /** when change is made to options dialog, the topwidget will catch this |
122 | * and emit this signal which notifies all widgets which have registered | 124 | * and emit this signal which notifies all widgets which have registered |
123 | * for notification to update their settings. */ | 125 | * for notification to update their settings. */ |
124 | void configChanged(); | 126 | void configChanged(); |
125 | /** emitted when the topwidget is closing down, so that any attached | 127 | /** emitted when the topwidget is closing down, so that any attached |
126 | child windows can also close. */ | 128 | child windows can also close. */ |
127 | void closingDown(); | 129 | void closingDown(); |
128 | /** emitted right before we die */ | 130 | /** emitted right before we die */ |
129 | void closed(QWidget *); | 131 | void closed(QWidget *); |
130 | 132 | ||
131 | /** Emitted when state of modified flag changes */ | 133 | /** Emitted when state of modified flag changes */ |
132 | void modifiedChanged(bool); | 134 | void modifiedChanged(bool); |
133 | void signalmodified(); | 135 | void signalmodified(); |
134 | 136 | ||
135 | /** Emitted when state of read-only flag changes */ | 137 | /** Emitted when state of read-only flag changes */ |
136 | void readOnlyChanged(bool); | 138 | void readOnlyChanged(bool); |
137 | 139 | ||
138 | /** Emitted when the unit of navigation changes */ | 140 | /** Emitted when the unit of navigation changes */ |
139 | void changeNavStringPrev(const QString &); | 141 | void changeNavStringPrev(const QString &); |
140 | void changeNavStringNext(const QString &); | 142 | void changeNavStringNext(const QString &); |
141 | 143 | ||
142 | /** Emitted when state of events selection has changed and user is organizer*/ | 144 | /** Emitted when state of events selection has changed and user is organizer*/ |
143 | void organizerEventsSelected(bool); | 145 | void organizerEventsSelected(bool); |
144 | /** Emitted when state of events selection has changed and user is attendee*/ | 146 | /** Emitted when state of events selection has changed and user is attendee*/ |
145 | void groupEventsSelected(bool); | 147 | void groupEventsSelected(bool); |
146 | /** | 148 | /** |
147 | Emitted when an incidence gets selected. If the selection is cleared the | 149 | Emitted when an incidence gets selected. If the selection is cleared the |
148 | signal is emitted with 0 as argument. | 150 | signal is emitted with 0 as argument. |
149 | */ | 151 | */ |
150 | void incidenceSelected( Incidence * ); | 152 | void incidenceSelected( Incidence * ); |
151 | /** Emitted, when a todoitem is selected or deselected. */ | 153 | /** Emitted, when a todoitem is selected or deselected. */ |
152 | void todoSelected( bool ); | 154 | void todoSelected( bool ); |
153 | 155 | ||
154 | /** | 156 | /** |
155 | Emitted, when clipboard content changes. Parameter indicates if paste | 157 | Emitted, when clipboard content changes. Parameter indicates if paste |
156 | is possible or not. | 158 | is possible or not. |
157 | */ | 159 | */ |
158 | void pasteEnabled(bool); | 160 | void pasteEnabled(bool); |
159 | 161 | ||
160 | /** Emitted, when the number of incoming messages has changed. */ | 162 | /** Emitted, when the number of incoming messages has changed. */ |
161 | void numIncomingChanged(int); | 163 | void numIncomingChanged(int); |
162 | 164 | ||
163 | /** Emitted, when the number of outgoing messages has changed. */ | 165 | /** Emitted, when the number of outgoing messages has changed. */ |
164 | void numOutgoingChanged(int); | 166 | void numOutgoingChanged(int); |
165 | 167 | ||
166 | /** Send status message, which can e.g. be displayed in the status bar. */ | 168 | /** Send status message, which can e.g. be displayed in the status bar. */ |
167 | void statusMessage(const QString &); | 169 | void statusMessage(const QString &); |
168 | 170 | ||
169 | void calendarViewExpanded( bool ); | 171 | void calendarViewExpanded( bool ); |
170 | void updateSearchDialog(); | 172 | void updateSearchDialog(); |
171 | 173 | ||
172 | 174 | ||
173 | public slots: | 175 | public slots: |
174 | void showOpenError(); | 176 | void showOpenError(); |
175 | void watchSavedFile(); | 177 | void watchSavedFile(); |
176 | void recheckTimerAlarm(); | 178 | void recheckTimerAlarm(); |
177 | void checkNextTimerAlarm(); | 179 | void checkNextTimerAlarm(); |
178 | void addAlarm(const QDateTime &qdt, const QString ¬i ); | 180 | void addAlarm(const QDateTime &qdt, const QString ¬i ); |
179 | void addSuspendAlarm(const QDateTime &qdt, const QString ¬i ); | 181 | void addSuspendAlarm(const QDateTime &qdt, const QString ¬i ); |
180 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); | 182 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); |
181 | 183 | ||
182 | /** options dialog made a changed to the configuration. we catch this | 184 | /** options dialog made a changed to the configuration. we catch this |
183 | * and notify all widgets which need to update their configuration. */ | 185 | * and notify all widgets which need to update their configuration. */ |
184 | void updateConfig(); | 186 | void updateConfig(); |
185 | 187 | ||
186 | void insertBirthdays(const QString& uid, const QStringList& birthdayList, | 188 | void insertBirthdays(const QString& uid, const QStringList& birthdayList, |
187 | const QStringList& anniversaryList, const QStringList& realNameList, | 189 | const QStringList& anniversaryList, const QStringList& realNameList, |
188 | const QStringList& emailList, const QStringList& assembledNameList, | 190 | const QStringList& emailList, const QStringList& assembledNameList, |
189 | const QStringList& uidList); | 191 | const QStringList& uidList); |
190 | 192 | ||
191 | /** | 193 | /** |
192 | Load calendar from file \a filename. If \a merge is true, load | 194 | Load calendar from file \a filename. If \a merge is true, load |
193 | calendar into existing one, if it is false, clear calendar, before | 195 | calendar into existing one, if it is false, clear calendar, before |
194 | loading. Return true, if calendar could be successfully loaded. | 196 | loading. Return true, if calendar could be successfully loaded. |
195 | */ | 197 | */ |
196 | bool openCalendar(QString filename, bool merge=false); | 198 | bool openCalendar(QString filename, bool merge=false); |
197 | bool syncCalendar(QString filename,int mode = 0 ); | 199 | bool syncCalendar(QString filename,int mode = 0 ); |
198 | 200 | ||
199 | /** | 201 | /** |
200 | Save calendar data to file. Return true if calendar could be | 202 | Save calendar data to file. Return true if calendar could be |
201 | successfully saved. | 203 | successfully saved. |
202 | */ | 204 | */ |
203 | bool saveCalendar(QString filename); | 205 | bool saveCalendar(QString filename); |
204 | 206 | ||
205 | /** | 207 | /** |
206 | Close calendar. Clear calendar data and reset views to display an empty | 208 | Close calendar. Clear calendar data and reset views to display an empty |
207 | calendar. | 209 | calendar. |
208 | */ | 210 | */ |
209 | void closeCalendar(); | 211 | void closeCalendar(); |
210 | 212 | ||
211 | /** Archive old events of calendar */ | 213 | /** Archive old events of calendar */ |
212 | void archiveCalendar(); | 214 | void archiveCalendar(); |
213 | 215 | ||
214 | void showIncidence(); | 216 | void showIncidence(); |
215 | void editIncidence(); | 217 | void editIncidence(); |
216 | void editIncidenceDescription(); | 218 | void editIncidenceDescription(); |
217 | void deleteIncidence(); | 219 | void deleteIncidence(); |
218 | void cloneIncidence(); | 220 | void cloneIncidence(); |
219 | void moveIncidence(); | 221 | void moveIncidence(); |
220 | void beamIncidence(); | 222 | void beamIncidence(); |
221 | void toggleCancelIncidence(); | 223 | void toggleCancelIncidence(); |
222 | 224 | ||
223 | /** create an editeventwin with supplied date/time, and if bool is true, | 225 | /** create an editeventwin with supplied date/time, and if bool is true, |
224 | * make the event take all day. */ | 226 | * make the event take all day. */ |
225 | void newEvent(QDateTime, QDateTime, bool allDay = false); | 227 | void newEvent(QDateTime, QDateTime, bool allDay = false); |
226 | void newEvent(QDateTime fh); | 228 | void newEvent(QDateTime fh); |
227 | void newEvent(QDate dt); | 229 | void newEvent(QDate dt); |
228 | /** create new event without having a date hint. Takes current date as | 230 | /** create new event without having a date hint. Takes current date as |
229 | default hint. */ | 231 | default hint. */ |
230 | void newEvent(); | 232 | void newEvent(); |
231 | void newFloatingEvent(); | 233 | void newFloatingEvent(); |
232 | 234 | ||
233 | /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ | 235 | /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ |
234 | void showIncidence(Incidence *); | 236 | void showIncidence(Incidence *); |
235 | /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ | 237 | /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ |
236 | void editIncidence(Incidence *); | 238 | void editIncidence(Incidence *); |
237 | /** Delete the supplied incidence. It calls the correct deleteXXX method*/ | 239 | /** Delete the supplied incidence. It calls the correct deleteXXX method*/ |
238 | void deleteIncidence(Incidence *); | 240 | void deleteIncidence(Incidence *); |
239 | void cloneIncidence(Incidence *); | 241 | void cloneIncidence(Incidence *); |
240 | void cancelIncidence(Incidence *); | 242 | void cancelIncidence(Incidence *); |
241 | /** Create an editor for the supplied event. */ | 243 | /** Create an editor for the supplied event. */ |
242 | void editEvent(Event *); | 244 | void editEvent(Event *); |
243 | /** Delete the supplied event. */ | 245 | /** Delete the supplied event. */ |
244 | void deleteEvent(Event *); | 246 | void deleteEvent(Event *); |
245 | /** Delete the event with the given unique ID. Returns false, if event wasn't | 247 | /** Delete the event with the given unique ID. Returns false, if event wasn't |
246 | found. */ | 248 | found. */ |
247 | bool deleteEvent(const QString &uid); | 249 | bool deleteEvent(const QString &uid); |
248 | /** Create a read-only viewer dialog for the supplied event. */ | 250 | /** Create a read-only viewer dialog for the supplied event. */ |
249 | void showEvent(Event *); | 251 | void showEvent(Event *); |
250 | 252 | ||
251 | void editJournal(Journal *); | 253 | void editJournal(Journal *); |
252 | void showJournal(Journal *); | 254 | void showJournal(Journal *); |
253 | void deleteJournal(Journal *); | 255 | void deleteJournal(Journal *); |
254 | /** Create an editor dialog for a todo */ | 256 | /** Create an editor dialog for a todo */ |
255 | void editTodo(Todo *); | 257 | void editTodo(Todo *); |
256 | /** Create a read-only viewer dialog for the supplied todo */ | 258 | /** Create a read-only viewer dialog for the supplied todo */ |
257 | void showTodo(Todo *); | 259 | void showTodo(Todo *); |
258 | /** create new todo */ | 260 | /** create new todo */ |
259 | void newTodo(); | 261 | void newTodo(); |
260 | /** create new todo with a parent todo */ | 262 | /** create new todo with a parent todo */ |
261 | void newSubTodo(); | 263 | void newSubTodo(); |
262 | /** create new todo with a parent todo */ | 264 | /** create new todo with a parent todo */ |
263 | void newSubTodo(Todo *); | 265 | void newSubTodo(Todo *); |
264 | /** Delete todo */ | 266 | /** Delete todo */ |
265 | void deleteTodo(Todo *); | 267 | void deleteTodo(Todo *); |
266 | 268 | ||
267 | 269 | ||
268 | /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is | 270 | /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is |
269 | * emitted as result. */ | 271 | * emitted as result. */ |
270 | void checkClipboard(); | 272 | void checkClipboard(); |
271 | 273 | ||
272 | /** using the KConfig associated with the kapp variable, read in the | 274 | /** using the KConfig associated with the kapp variable, read in the |
273 | * settings from the config file. | 275 | * settings from the config file. |
274 | */ | 276 | */ |
275 | void readSettings(); | 277 | void readSettings(); |
276 | 278 | ||
277 | /** write current state to config file. */ | 279 | /** write current state to config file. */ |
278 | void writeSettings(); | 280 | void writeSettings(); |
279 | 281 | ||
280 | /** read settings for calendar filters */ | 282 | /** read settings for calendar filters */ |
281 | void readFilterSettings(KConfig *config); | 283 | void readFilterSettings(KConfig *config); |
282 | 284 | ||
283 | /** write settings for calendar filters */ | 285 | /** write settings for calendar filters */ |
284 | void writeFilterSettings(KConfig *config); | 286 | void writeFilterSettings(KConfig *config); |
285 | 287 | ||
286 | /** passes on the message that an event has changed to the currently | 288 | /** passes on the message that an event has changed to the currently |
287 | * activated view so that it can make appropriate display changes. */ | 289 | * activated view so that it can make appropriate display changes. */ |
288 | void changeEventDisplay(Event *, int); | 290 | void changeEventDisplay(Event *, int); |
289 | void changeIncidenceDisplay(Incidence *, int); | 291 | void changeIncidenceDisplay(Incidence *, int); |
290 | void changeTodoDisplay(Todo *, int); | 292 | void changeTodoDisplay(Todo *, int); |
291 | 293 | ||
292 | void eventAdded(Event *); | 294 | void eventAdded(Event *); |
293 | void eventChanged(Event *); | 295 | void eventChanged(Event *); |
294 | void eventToBeDeleted(Event *); | 296 | void eventToBeDeleted(Event *); |
295 | void eventDeleted(); | 297 | void eventDeleted(); |
296 | 298 | ||
297 | void todoAdded(Todo *); | 299 | void todoAdded(Todo *); |
298 | void todoChanged(Todo *); | 300 | void todoChanged(Todo *); |
299 | void todoToBeDeleted(Todo *); | 301 | void todoToBeDeleted(Todo *); |
300 | void todoDeleted(); | 302 | void todoDeleted(); |
301 | 303 | ||
302 | void updateView(const QDate &start, const QDate &end); | 304 | void updateView(const QDate &start, const QDate &end); |
303 | void updateView(); | 305 | void updateView(); |
304 | 306 | ||
305 | /** Full update of visible todo views */ | 307 | /** Full update of visible todo views */ |
306 | void updateTodoViews(); | 308 | void updateTodoViews(); |
307 | 309 | ||
308 | void updateUnmanagedViews(); | 310 | void updateUnmanagedViews(); |
309 | 311 | ||
310 | /** cut the current appointment to the clipboard */ | 312 | /** cut the current appointment to the clipboard */ |
311 | void edit_cut(); | 313 | void edit_cut(); |
312 | 314 | ||
313 | /** copy the current appointment(s) to the clipboard */ | 315 | /** copy the current appointment(s) to the clipboard */ |
314 | void edit_copy(); | 316 | void edit_copy(); |
315 | 317 | ||
316 | /** paste the current vobject(s) in the clipboard buffer into calendar */ | 318 | /** paste the current vobject(s) in the clipboard buffer into calendar */ |
317 | void edit_paste(); | 319 | void edit_paste(); |
318 | 320 | ||
319 | /** edit viewing and configuration options. */ | 321 | /** edit viewing and configuration options. */ |
320 | void edit_options(); | 322 | void edit_options(); |
321 | void edit_sync_options(); | 323 | void edit_sync_options(); |
322 | /** | 324 | /** |
323 | Functions for printing, previewing a print, and setting up printing | 325 | Functions for printing, previewing a print, and setting up printing |
324 | parameters. | 326 | parameters. |
325 | */ | 327 | */ |
326 | void print(); | 328 | void print(); |
327 | void printSetup(); | 329 | void printSetup(); |
328 | void printPreview(); | 330 | void printPreview(); |
329 | 331 | ||
330 | /** Export as iCalendar file */ | 332 | /** Export as iCalendar file */ |
331 | void exportICalendar(); | 333 | void exportICalendar(); |
332 | 334 | ||
333 | /** Export as vCalendar file */ | 335 | /** Export as vCalendar file */ |
334 | bool exportVCalendar( QString fn); | 336 | bool exportVCalendar( QString fn); |
335 | 337 | ||
336 | /** pop up a dialog to show an existing appointment. */ | 338 | /** pop up a dialog to show an existing appointment. */ |
337 | void appointment_show(); | 339 | void appointment_show(); |
338 | /** | 340 | /** |
339 | * pop up an Appointment Dialog to edit an existing appointment.Get | 341 | * pop up an Appointment Dialog to edit an existing appointment.Get |
340 | * information on the appointment from the list of unique IDs that is | 342 | * information on the appointment from the list of unique IDs that is |
341 | * currently in the View, called currIds. | 343 | * currently in the View, called currIds. |
342 | */ | 344 | */ |
343 | void appointment_edit(); | 345 | void appointment_edit(); |
344 | /** | 346 | /** |
345 | * pop up dialog confirming deletion of currently selected event in the | 347 | * pop up dialog confirming deletion of currently selected event in the |
346 | * View. | 348 | * View. |
347 | */ | 349 | */ |
348 | void appointment_delete(); | 350 | void appointment_delete(); |
349 | 351 | ||
350 | /** mails the currently selected event to a particular user as a vCalendar | 352 | /** mails the currently selected event to a particular user as a vCalendar |
351 | attachment. */ | 353 | attachment. */ |
352 | void action_mail(); | 354 | void action_mail(); |
353 | 355 | ||
354 | /* frees a subtodo from it's relation */ | 356 | /* frees a subtodo from it's relation */ |
355 | void todo_unsub( Todo * ); | 357 | void todo_unsub( Todo * ); |
356 | 358 | ||
357 | /** Take ownership of selected event. */ | 359 | /** Take ownership of selected event. */ |
358 | void takeOverEvent(); | 360 | void takeOverEvent(); |
359 | 361 | ||
360 | /** Take ownership of all events in calendar. */ | 362 | /** Take ownership of all events in calendar. */ |
361 | void takeOverCalendar(); | 363 | void takeOverCalendar(); |
362 | 364 | ||
363 | /** query whether or not the calendar is "dirty". */ | 365 | /** query whether or not the calendar is "dirty". */ |
364 | bool isModified(); | 366 | bool isModified(); |
365 | /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ | 367 | /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ |
366 | void setModified(bool modified=true); | 368 | void setModified(bool modified=true); |
367 | 369 | ||
368 | /** query if the calendar is read-only. */ | 370 | /** query if the calendar is read-only. */ |
369 | bool isReadOnly(); | 371 | bool isReadOnly(); |
370 | /** set state of calendar to read-only */ | 372 | /** set state of calendar to read-only */ |
371 | void setReadOnly(bool readOnly=true); | 373 | void setReadOnly(bool readOnly=true); |
372 | 374 | ||
373 | void eventUpdated(Incidence *); | 375 | void eventUpdated(Incidence *); |
374 | 376 | ||
375 | /* iTIP scheduling actions */ | 377 | /* iTIP scheduling actions */ |
376 | void schedule_publish(Incidence *incidence = 0); | 378 | void schedule_publish(Incidence *incidence = 0); |
377 | void schedule_request(Incidence *incidence = 0); | 379 | void schedule_request(Incidence *incidence = 0); |
378 | void schedule_refresh(Incidence *incidence = 0); | 380 | void schedule_refresh(Incidence *incidence = 0); |
379 | void schedule_cancel(Incidence *incidence = 0); | 381 | void schedule_cancel(Incidence *incidence = 0); |
380 | void schedule_add(Incidence *incidence = 0); | 382 | void schedule_add(Incidence *incidence = 0); |
381 | void schedule_reply(Incidence *incidence = 0); | 383 | void schedule_reply(Incidence *incidence = 0); |
382 | void schedule_counter(Incidence *incidence = 0); | 384 | void schedule_counter(Incidence *incidence = 0); |
383 | void schedule_declinecounter(Incidence *incidence = 0); | 385 | void schedule_declinecounter(Incidence *incidence = 0); |
384 | void schedule_publish_freebusy(int daysToPublish = 30); | 386 | void schedule_publish_freebusy(int daysToPublish = 30); |
385 | 387 | ||
386 | void openAddressbook(); | 388 | void openAddressbook(); |
387 | 389 | ||
388 | void editFilters(); | 390 | void editFilters(); |
389 | void toggleFilerEnabled(); | 391 | void toggleFilerEnabled(); |
390 | QPtrList<CalFilter> filters(); | 392 | QPtrList<CalFilter> filters(); |
391 | void toggleFilter(); | 393 | void toggleFilter(); |
392 | void showFilter(bool visible); | 394 | void showFilter(bool visible); |
393 | void updateFilter(); | 395 | void updateFilter(); |
394 | void filterEdited(); | 396 | void filterEdited(); |
395 | void selectFilter( int ); | 397 | void selectFilter( int ); |
396 | KOFilterView *filterView(); | 398 | KOFilterView *filterView(); |
397 | 399 | ||
398 | void showIntro(); | 400 | void showIntro(); |
399 | 401 | ||
400 | /** Move the curdatepient view date to today */ | 402 | /** Move the curdatepient view date to today */ |
401 | void goToday(); | 403 | void goToday(); |
402 | 404 | ||
403 | /** Move to the next date(s) in the current view */ | 405 | /** Move to the next date(s) in the current view */ |
404 | void goNext(); | 406 | void goNext(); |
405 | 407 | ||
406 | /** Move to the previous date(s) in the current view */ | 408 | /** Move to the previous date(s) in the current view */ |
407 | void goPrevious(); | 409 | void goPrevious(); |
408 | /** Move to the next date(s) in the current view */ | 410 | /** Move to the next date(s) in the current view */ |
409 | void goNextMonth(); | 411 | void goNextMonth(); |
410 | 412 | ||
411 | /** Move to the previous date(s) in the current view */ | 413 | /** Move to the previous date(s) in the current view */ |
412 | void goPreviousMonth(); | 414 | void goPreviousMonth(); |
413 | 415 | ||
414 | void toggleExpand(); | 416 | void toggleExpand(); |
415 | void toggleDateNavigatorWidget(); | 417 | void toggleDateNavigatorWidget(); |
416 | void toggleAllDaySize(); | 418 | void toggleAllDaySize(); |
417 | void dialogClosing(Incidence *); | 419 | void dialogClosing(Incidence *); |
418 | 420 | ||
419 | /** Look for new messages in the inbox */ | 421 | /** Look for new messages in the inbox */ |
420 | void lookForIncomingMessages(); | 422 | void lookForIncomingMessages(); |
421 | /** Look for new messages in the outbox */ | 423 | /** Look for new messages in the outbox */ |
422 | void lookForOutgoingMessages(); | 424 | void lookForOutgoingMessages(); |
423 | 425 | ||
424 | void processMainViewSelection( Incidence * ); | 426 | void processMainViewSelection( Incidence * ); |
425 | void processTodoListSelection( Incidence * ); | 427 | void processTodoListSelection( Incidence * ); |
426 | 428 | ||
427 | void processIncidenceSelection( Incidence * ); | 429 | void processIncidenceSelection( Incidence * ); |
428 | 430 | ||
429 | void purgeCompleted(); | 431 | void purgeCompleted(); |
430 | bool removeCompletedSubTodos( Todo* ); | 432 | bool removeCompletedSubTodos( Todo* ); |
431 | void slotCalendarChanged(); | 433 | void slotCalendarChanged(); |
432 | bool importBday(); | 434 | bool importBday(); |
433 | bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); | 435 | bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); |
434 | bool importQtopia( const QString &categoriesFile, | 436 | bool importQtopia( const QString &categoriesFile, |
435 | const QString &datebookFile, | 437 | const QString &datebookFile, |
436 | const QString &tasklistFile ); | 438 | const QString &tasklistFile ); |
437 | void syncSharp( ); | 439 | void syncSharp( ); |
438 | void syncPhone( ); | 440 | void syncPhone( ); |
439 | void syncExternal( int mode ); | 441 | void syncExternal( int mode ); |
440 | void slotSelectPickerDate( QDate ) ; | 442 | void slotSelectPickerDate( QDate ) ; |
441 | void showDatePicker( ) ; | 443 | void showDatePicker( ) ; |
442 | void moveIncidence(Incidence *) ; | 444 | void moveIncidence(Incidence *) ; |
443 | void beamIncidence(Incidence *) ; | 445 | void beamIncidence(Incidence *) ; |
444 | void beamCalendar() ; | 446 | void beamCalendar() ; |
445 | void beamFilteredCalendar() ; | 447 | void beamFilteredCalendar() ; |
446 | void beamIncidenceList(QPtrList<Incidence>) ; | 448 | void beamIncidenceList(QPtrList<Incidence>) ; |
447 | void manageCategories(); | 449 | void manageCategories(); |
448 | int addCategories(); | 450 | int addCategories(); |
449 | void removeCategories(); | 451 | void removeCategories(); |
450 | void setSyncDevice( QString ); | 452 | void setSyncDevice( QString ); |
451 | void setSyncName( QString ); | 453 | void setSyncName( QString ); |
452 | protected slots: | 454 | protected slots: |
453 | void timerAlarm(); | 455 | void timerAlarm(); |
454 | void suspendAlarm(); | 456 | void suspendAlarm(); |
455 | void beamDone( Ir *ir ); | 457 | void beamDone( Ir *ir ); |
456 | /** Select a view or adapt the current view to display the specified dates. */ | 458 | /** Select a view or adapt the current view to display the specified dates. */ |
457 | void showDates( const KCal::DateList & ); | 459 | void showDates( const KCal::DateList & ); |
458 | void selectWeekNum ( int ); | 460 | void selectWeekNum ( int ); |
459 | 461 | ||
460 | public: | 462 | public: |
461 | // show a standard warning | 463 | // show a standard warning |
462 | // returns KMsgBox::yesNoCancel() | 464 | // returns KMsgBox::yesNoCancel() |
463 | int msgCalModified(); | 465 | int msgCalModified(); |
466 | virtual bool sync(KSyncManager* manager, QString filename, int mode); | ||
467 | |||
468 | virtual bool syncExternal(KSyncManager* manager, QString resource); | ||
464 | void confSync(); | 469 | void confSync(); |
470 | void setSyncManager(KSyncManager* manager); | ||
465 | void setLoadedFileVersion(QDateTime); | 471 | void setLoadedFileVersion(QDateTime); |
466 | bool checkFileVersion(QString fn); | 472 | bool checkFileVersion(QString fn); |
467 | bool checkFileChanged(QString fn); | 473 | bool checkFileChanged(QString fn); |
468 | Event* getLastSyncEvent(); | 474 | Event* getLastSyncEvent(); |
469 | /** Adapt navigation units correpsonding to step size of navigation of the | 475 | /** Adapt navigation units correpsonding to step size of navigation of the |
470 | * current view. | 476 | * current view. |
471 | */ | 477 | */ |
472 | void adaptNavigationUnits(); | 478 | void adaptNavigationUnits(); |
473 | bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); | 479 | bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); |
474 | int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); | 480 | int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); |
475 | //Attendee* getYourAttendee(Event *event); | 481 | //Attendee* getYourAttendee(Event *event); |
476 | protected: | 482 | protected: |
477 | void schedule(Scheduler::Method, Incidence *incidence = 0); | 483 | void schedule(Scheduler::Method, Incidence *incidence = 0); |
478 | 484 | ||
479 | // returns KMsgBox::OKCandel() | 485 | // returns KMsgBox::OKCandel() |
480 | int msgItemDelete(); | 486 | int msgItemDelete(); |
481 | void showEventEditor(); | 487 | void showEventEditor(); |
482 | void showTodoEditor(); | 488 | void showTodoEditor(); |
483 | void writeLocale(); | 489 | void writeLocale(); |
484 | Todo *selectedTodo(); | 490 | Todo *selectedTodo(); |
485 | 491 | ||
486 | private: | 492 | private: |
493 | KSyncManager* mSyncManager; | ||
487 | AlarmDialog * mAlarmDialog; | 494 | AlarmDialog * mAlarmDialog; |
488 | QString mAlarmNotification; | 495 | QString mAlarmNotification; |
489 | QString mSuspendAlarmNotification; | 496 | QString mSuspendAlarmNotification; |
490 | QTimer* mSuspendTimer; | 497 | QTimer* mSuspendTimer; |
491 | QTimer* mAlarmTimer; | 498 | QTimer* mAlarmTimer; |
492 | QTimer* mRecheckAlarmTimer; | 499 | QTimer* mRecheckAlarmTimer; |
493 | void computeAlarm( QString ); | 500 | void computeAlarm( QString ); |
494 | void startAlarm( QString, QString ); | 501 | void startAlarm( QString, QString ); |
495 | void setSyncEventsReadOnly(); | 502 | void setSyncEventsReadOnly(); |
496 | 503 | ||
497 | QDateTime loadedFileVersion; | 504 | QDateTime loadedFileVersion; |
498 | void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); | 505 | void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); |
499 | void checkExternalId( Incidence * inc ); | 506 | void checkExternalId( Incidence * inc ); |
500 | int mGlobalSyncMode; | 507 | int mGlobalSyncMode; |
501 | QString mCurrentSyncDevice; | 508 | QString mCurrentSyncDevice; |
502 | QString mCurrentSyncName; | 509 | QString mCurrentSyncName; |
503 | KOBeamPrefs* beamDialog; | 510 | KOBeamPrefs* beamDialog; |
504 | void init(); | 511 | void init(); |
505 | int mDatePickerMode; | 512 | int mDatePickerMode; |
506 | bool mFlagEditDescription; | 513 | bool mFlagEditDescription; |
507 | QDateTime mLastCalendarSync; | 514 | QDateTime mLastCalendarSync; |
508 | void createPrinter(); | 515 | void createPrinter(); |
509 | 516 | ||
510 | void calendarModified( bool, Calendar * ); | 517 | void calendarModified( bool, Calendar * ); |
511 | 518 | ||
512 | CalPrinter *mCalPrinter; | 519 | CalPrinter *mCalPrinter; |
513 | 520 | ||
514 | QSplitter *mPanner; | 521 | QSplitter *mPanner; |
515 | QSplitter *mLeftSplitter; | 522 | QSplitter *mLeftSplitter; |
516 | QWidget *mLeftFrame; | 523 | QWidget *mLeftFrame; |
517 | QWidgetStack *mRightFrame; | 524 | QWidgetStack *mRightFrame; |
518 | 525 | ||
519 | KDatePicker* mDatePicker; | 526 | KDatePicker* mDatePicker; |
520 | QVBox* mDateFrame; | 527 | QVBox* mDateFrame; |
521 | NavigatorBar *mNavigatorBar; | 528 | NavigatorBar *mNavigatorBar; |
522 | 529 | ||
523 | KDateNavigator *mDateNavigator; // widget showing small month view. | 530 | KDateNavigator *mDateNavigator; // widget showing small month view. |
524 | 531 | ||
525 | KOFilterView *mFilterView; | 532 | KOFilterView *mFilterView; |
526 | 533 | ||
527 | ResourceView *mResourceView; | 534 | ResourceView *mResourceView; |
528 | 535 | ||
529 | // calendar object for this viewing instance | 536 | // calendar object for this viewing instance |
530 | Calendar *mCalendar; | 537 | Calendar *mCalendar; |
531 | 538 | ||
532 | CalendarResourceManager *mResourceManager; | 539 | CalendarResourceManager *mResourceManager; |
533 | 540 | ||
534 | FileStorage *mStorage; | 541 | FileStorage *mStorage; |
535 | 542 | ||
536 | DateNavigator *mNavigator; | 543 | DateNavigator *mNavigator; |
537 | 544 | ||
538 | KOViewManager *mViewManager; | 545 | KOViewManager *mViewManager; |
539 | KODialogManager *mDialogManager; | 546 | KODialogManager *mDialogManager; |
540 | 547 | ||
541 | // Calendar filters | 548 | // Calendar filters |
542 | QPtrList<CalFilter> mFilters; | 549 | QPtrList<CalFilter> mFilters; |
543 | 550 | ||
544 | // various housekeeping variables. | 551 | // various housekeeping variables. |
545 | bool mModified; // flag indicating if calendar is modified | 552 | bool mModified; // flag indicating if calendar is modified |
546 | bool mReadOnly; // flag indicating if calendar is read-only | 553 | bool mReadOnly; // flag indicating if calendar is read-only |
547 | QDate mSaveSingleDate; | 554 | QDate mSaveSingleDate; |
548 | 555 | ||
549 | Incidence *mSelectedIncidence; | 556 | Incidence *mSelectedIncidence; |
550 | Incidence *mMoveIncidence; | 557 | Incidence *mMoveIncidence; |
551 | KOTodoView *mTodoList; | 558 | KOTodoView *mTodoList; |
552 | KOEventEditor * mEventEditor; | 559 | KOEventEditor * mEventEditor; |
553 | KOTodoEditor * mTodoEditor; | 560 | KOTodoEditor * mTodoEditor; |
554 | KOEventViewerDialog * mEventViewerDialog; | 561 | KOEventViewerDialog * mEventViewerDialog; |
555 | void keyPressEvent ( QKeyEvent *e) ; | 562 | void keyPressEvent ( QKeyEvent *e) ; |
556 | //QMap<Incidence*,KOIncidenceEditor*> mDialogList; | 563 | //QMap<Incidence*,KOIncidenceEditor*> mDialogList; |
557 | }; | 564 | }; |
558 | 565 | ||
559 | 566 | ||
560 | class CalendarViewVisitor : public Incidence::Visitor | 567 | class CalendarViewVisitor : public Incidence::Visitor |
561 | { | 568 | { |
562 | public: | 569 | public: |
563 | CalendarViewVisitor() : mView( 0 ) {} | 570 | CalendarViewVisitor() : mView( 0 ) {} |
564 | 571 | ||
565 | bool act( Incidence *incidence, CalendarView *view ) | 572 | bool act( Incidence *incidence, CalendarView *view ) |
566 | { | 573 | { |
567 | mView = view; | 574 | mView = view; |
568 | return incidence->accept( *this ); | 575 | return incidence->accept( *this ); |
569 | } | 576 | } |
570 | 577 | ||
571 | protected: | 578 | protected: |
572 | CalendarView *mView; | 579 | CalendarView *mView; |
573 | }; | 580 | }; |
574 | 581 | ||
575 | class ShowIncidenceVisitor : public CalendarViewVisitor | 582 | class ShowIncidenceVisitor : public CalendarViewVisitor |
576 | { | 583 | { |
577 | protected: | 584 | protected: |
578 | bool visit( Event *event ) { mView->showEvent( event ); return true; } | 585 | bool visit( Event *event ) { mView->showEvent( event ); return true; } |
579 | bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } | 586 | bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } |
580 | bool visit( Journal * j ) { mView->showJournal( j );return true; } | 587 | bool visit( Journal * j ) { mView->showJournal( j );return true; } |
581 | }; | 588 | }; |
582 | 589 | ||
583 | class EditIncidenceVisitor : public CalendarViewVisitor | 590 | class EditIncidenceVisitor : public CalendarViewVisitor |
584 | { | 591 | { |
585 | protected: | 592 | protected: |
586 | bool visit( Event *event ) { mView->editEvent( event ); return true; } | 593 | bool visit( Event *event ) { mView->editEvent( event ); return true; } |
587 | bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } | 594 | bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } |
588 | bool visit( Journal *j ) { mView->editJournal( j); return true; } | 595 | bool visit( Journal *j ) { mView->editJournal( j); return true; } |
589 | }; | 596 | }; |
590 | 597 | ||
591 | class DeleteIncidenceVisitor : public CalendarViewVisitor | 598 | class DeleteIncidenceVisitor : public CalendarViewVisitor |
592 | { | 599 | { |
593 | protected: | 600 | protected: |
594 | bool visit( Event *event ) { mView->deleteEvent( event ); return true; } | 601 | bool visit( Event *event ) { mView->deleteEvent( event ); return true; } |
595 | bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } | 602 | bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } |
596 | bool visit( Journal * j) {mView->deleteJournal( j ); return true; } | 603 | bool visit( Journal * j) {mView->deleteJournal( j ); return true; } |
597 | }; | 604 | }; |
598 | 605 | ||
599 | #endif | 606 | #endif |
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp index 1210094..13035e0 100644 --- a/korganizer/koprefs.cpp +++ b/korganizer/koprefs.cpp | |||
@@ -1,573 +1,570 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <time.h> | 24 | #include <time.h> |
25 | #ifndef _WIN32_ | 25 | #ifndef _WIN32_ |
26 | #include <unistd.h> | 26 | #include <unistd.h> |
27 | #endif | 27 | #endif |
28 | #include <qdir.h> | 28 | #include <qdir.h> |
29 | #include <qtextstream.h> | 29 | #include <qtextstream.h> |
30 | #include <qtextcodec.h> | 30 | #include <qtextcodec.h> |
31 | #include <qstring.h> | 31 | #include <qstring.h> |
32 | #include <qregexp.h> | 32 | #include <qregexp.h> |
33 | #include <qfont.h> | 33 | #include <qfont.h> |
34 | #include <qcolor.h> | 34 | #include <qcolor.h> |
35 | #include <qstringlist.h> | 35 | #include <qstringlist.h> |
36 | #include <stdlib.h> | 36 | #include <stdlib.h> |
37 | 37 | ||
38 | #include <kglobal.h> | 38 | #include <kglobal.h> |
39 | #include <kconfig.h> | 39 | #include <kconfig.h> |
40 | #include <klocale.h> | 40 | #include <klocale.h> |
41 | #include <kdebug.h> | 41 | #include <kdebug.h> |
42 | #include <kemailsettings.h> | 42 | #include <kemailsettings.h> |
43 | #include <kstaticdeleter.h> | 43 | #include <kstaticdeleter.h> |
44 | #include <libkdepim/kpimglobalprefs.h> | 44 | #include <libkdepim/kpimglobalprefs.h> |
45 | 45 | ||
46 | #include "koprefs.h" | 46 | #include "koprefs.h" |
47 | #include "mainwindow.h" | 47 | #include "mainwindow.h" |
48 | 48 | ||
49 | const char *germanwords[][2] = { | 49 | const char *germanwords[][2] = { |
50 | #include "wordsgerman.h" | 50 | #include "wordsgerman.h" |
51 | "", "" | 51 | "", "" |
52 | }; | 52 | }; |
53 | 53 | ||
54 | KOPrefs *KOPrefs::mInstance = 0; | 54 | KOPrefs *KOPrefs::mInstance = 0; |
55 | static KStaticDeleter<KOPrefs> insd; | 55 | static KStaticDeleter<KOPrefs> insd; |
56 | 56 | ||
57 | KOPrefs::KOPrefs() : | 57 | KOPrefs::KOPrefs() : |
58 | KPimPrefs("korganizerrc") | 58 | KPimPrefs("korganizerrc") |
59 | { | 59 | { |
60 | mCategoryColors.setAutoDelete(true); | 60 | mCategoryColors.setAutoDelete(true); |
61 | mLocaleDict = 0; | 61 | mLocaleDict = 0; |
62 | fillMailDefaults(); | 62 | fillMailDefaults(); |
63 | mDefaultCategoryColor = QColor(175,210,255);//196,196,196); | 63 | mDefaultCategoryColor = QColor(175,210,255);//196,196,196); |
64 | QColor defaultHolidayColor = QColor(255,0,0); | 64 | QColor defaultHolidayColor = QColor(255,0,0); |
65 | QColor defaultHighlightColor = QColor(129,112,255);//64,64,255); | 65 | QColor defaultHighlightColor = QColor(129,112,255);//64,64,255); |
66 | QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128); | 66 | QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128); |
67 | QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160); | 67 | QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160); |
68 | QColor defaultTodoDueTodayColor = QColor(255,220,100); | 68 | QColor defaultTodoDueTodayColor = QColor(255,220,100); |
69 | QColor defaultTodoOverdueColor = QColor(255,153,125); | 69 | QColor defaultTodoOverdueColor = QColor(255,153,125); |
70 | 70 | ||
71 | mTimeBarFont = QFont("helvetica",10);//,QFont::Bold); | 71 | mTimeBarFont = QFont("helvetica",10);//,QFont::Bold); |
72 | mDefaultViewFont = QFont("helvetica",10); | 72 | mDefaultViewFont = QFont("helvetica",10); |
73 | mDefaultMonthViewFont = QFont("helvetica",8); | 73 | mDefaultMonthViewFont = QFont("helvetica",8); |
74 | mMarcusBainsFont= QFont("helvetica",10); | 74 | mMarcusBainsFont= QFont("helvetica",10); |
75 | mDateNavigatorFont= QFont("helvetica",10, QFont::Bold); | 75 | mDateNavigatorFont= QFont("helvetica",10, QFont::Bold); |
76 | mEditBoxFont = QFont("helvetica",12); | 76 | mEditBoxFont = QFont("helvetica",12); |
77 | mJornalViewFont = QFont("helvetica",12); | 77 | mJornalViewFont = QFont("helvetica",12); |
78 | 78 | ||
79 | KPrefs::setCurrentGroup("General"); | 79 | KPrefs::setCurrentGroup("General"); |
80 | 80 | ||
81 | 81 | ||
82 | addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); | 82 | addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); |
83 | 83 | ||
84 | addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true); | 84 | addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true); |
85 | addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true); | 85 | addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true); |
86 | addItemBool("ShowIconSearch",&mShowIconSearch,true); | 86 | addItemBool("ShowIconSearch",&mShowIconSearch,true); |
87 | addItemBool("ShowIconList",&mShowIconList,true); | 87 | addItemBool("ShowIconList",&mShowIconList,true); |
88 | addItemBool("ShowIconDay1",&mShowIconDay1,true); | 88 | addItemBool("ShowIconDay1",&mShowIconDay1,true); |
89 | addItemBool("ShowIconDay5",&mShowIconDay5,true); | 89 | addItemBool("ShowIconDay5",&mShowIconDay5,true); |
90 | addItemBool("ShowIconDay7",&mShowIconDay7,true); | 90 | addItemBool("ShowIconDay7",&mShowIconDay7,true); |
91 | addItemBool("ShowIconMonth",&mShowIconMonth,true); | 91 | addItemBool("ShowIconMonth",&mShowIconMonth,true); |
92 | addItemBool("ShowIconTodoview",&mShowIconTodoview,true); | 92 | addItemBool("ShowIconTodoview",&mShowIconTodoview,true); |
93 | addItemBool("ShowIconBackFast",&mShowIconBackFast,true); | 93 | addItemBool("ShowIconBackFast",&mShowIconBackFast,true); |
94 | addItemBool("ShowIconBack",&mShowIconBack,true); | 94 | addItemBool("ShowIconBack",&mShowIconBack,true); |
95 | addItemBool("ShowIconToday",&mShowIconToday,true); | 95 | addItemBool("ShowIconToday",&mShowIconToday,true); |
96 | addItemBool("ShowIconForward",&mShowIconForward,true); | 96 | addItemBool("ShowIconForward",&mShowIconForward,true); |
97 | addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true); | 97 | addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true); |
98 | addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,false); | 98 | addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,false); |
99 | addItemBool("ShowIconNextDays",&mShowIconNextDays,true); | 99 | addItemBool("ShowIconNextDays",&mShowIconNextDays,true); |
100 | addItemBool("ShowIconNext",&mShowIconNext,true); | 100 | addItemBool("ShowIconNext",&mShowIconNext,true); |
101 | addItemBool("ShowIconJournal",&mShowIconJournal,true); | 101 | addItemBool("ShowIconJournal",&mShowIconJournal,true); |
102 | addItemBool("ShowIconStretch",&mShowIconStretch,true); | 102 | addItemBool("ShowIconStretch",&mShowIconStretch,true); |
103 | addItemBool("LanguageChanged",&mLanguageChanged,false); | 103 | addItemBool("LanguageChanged",&mLanguageChanged,false); |
104 | 104 | ||
105 | addItemBool("AskForQuit",&mAskForQuit,false); | 105 | addItemBool("AskForQuit",&mAskForQuit,false); |
106 | 106 | ||
107 | #ifndef DESKTOP_VERSION | 107 | #ifndef DESKTOP_VERSION |
108 | addItemBool("ShowFullMenu",&mShowFullMenu,false); | 108 | addItemBool("ShowFullMenu",&mShowFullMenu,false); |
109 | #else | 109 | #else |
110 | addItemBool("ShowFullMenu",&mShowFullMenu,true); | 110 | addItemBool("ShowFullMenu",&mShowFullMenu,true); |
111 | #endif | 111 | #endif |
112 | addItemBool("ToolBarHor",&mToolBarHor, true ); | 112 | addItemBool("ToolBarHor",&mToolBarHor, true ); |
113 | addItemBool("ToolBarUp",&mToolBarUp, false ); | 113 | addItemBool("ToolBarUp",&mToolBarUp, false ); |
114 | addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false ); | 114 | addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false ); |
115 | addItemInt("Whats Next Days",&mWhatsNextDays,3); | 115 | addItemInt("Whats Next Days",&mWhatsNextDays,3); |
116 | addItemInt("Whats Next Prios",&mWhatsNextPrios,1); | 116 | addItemInt("Whats Next Prios",&mWhatsNextPrios,1); |
117 | 117 | ||
118 | addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true); | 118 | addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true); |
119 | addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true); | 119 | addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true); |
120 | addItemInt("AllDay Size",&mAllDaySize,28); | 120 | addItemInt("AllDay Size",&mAllDaySize,28); |
121 | QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav"; | 121 | QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav"; |
122 | addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm ); | 122 | addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm ); |
123 | 123 | ||
124 | addItemStringList("LocationDefaults",&mLocationDefaults ); | 124 | addItemStringList("LocationDefaults",&mLocationDefaults ); |
125 | addItemStringList("EventSummary User",&mEventSummaryUser); | 125 | addItemStringList("EventSummary User",&mEventSummaryUser); |
126 | addItemStringList("TodoSummary User",&mTodoSummaryUser); | 126 | addItemStringList("TodoSummary User",&mTodoSummaryUser); |
127 | 127 | ||
128 | addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); | 128 | addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); |
129 | addItemBool("Enable Project View",&mEnableProjectView,false); | 129 | addItemBool("Enable Project View",&mEnableProjectView,false); |
130 | addItemBool("Auto Save",&mAutoSave,false); | 130 | addItemBool("Auto Save",&mAutoSave,false); |
131 | addItemInt("Auto Save Interval",&mAutoSaveInterval,3); | 131 | addItemInt("Auto Save Interval",&mAutoSaveInterval,3); |
132 | addItemBool("Confirm Deletes",&mConfirm,true); | 132 | addItemBool("Confirm Deletes",&mConfirm,true); |
133 | addItemString("Archive File",&mArchiveFile); | 133 | addItemString("Archive File",&mArchiveFile); |
134 | addItemString("Html Export File",&mHtmlExportFile, | 134 | addItemString("Html Export File",&mHtmlExportFile, |
135 | QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html")); | 135 | QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html")); |
136 | addItemBool("Html With Save",&mHtmlWithSave,false); | 136 | addItemBool("Html With Save",&mHtmlWithSave,false); |
137 | 137 | ||
138 | KPrefs::setCurrentGroup("Personal Settings"); | 138 | KPrefs::setCurrentGroup("Personal Settings"); |
139 | 139 | ||
140 | addItemInt("Mail Client",&mMailClient,MailClientKMail); | 140 | addItemInt("Mail Client",&mMailClient,MailClientKMail); |
141 | addItemBool("Use Control Center Email",&mEmailControlCenter,false); | 141 | addItemBool("Use Control Center Email",&mEmailControlCenter,false); |
142 | addItemBool("Bcc",&mBcc,false); | 142 | addItemBool("Bcc",&mBcc,false); |
143 | 143 | ||
144 | KPrefs::setCurrentGroup("Time & Date"); | 144 | KPrefs::setCurrentGroup("Time & Date"); |
145 | 145 | ||
146 | // addItemString("Time Zone",&mTimeZone,"+0100"); | 146 | // addItemString("Time Zone",&mTimeZone,"+0100"); |
147 | addItemString("TimeZoneName",&mTimeZoneId,i18n ("+01:00 Europe/Oslo(CET)") ); | 147 | addItemString("TimeZoneName",&mTimeZoneId,i18n ("+01:00 Europe/Oslo(CET)") ); |
148 | // addItemInt("TimeZoneOffset",&mTimeZoneOffset,60); | 148 | // addItemInt("TimeZoneOffset",&mTimeZoneOffset,60); |
149 | addItemBool("UseDaylightsaving",&mUseDaylightsaving,true); | 149 | addItemBool("UseDaylightsaving",&mUseDaylightsaving,true); |
150 | addItemInt("DaylightsavingStart",&mDaylightsavingStart,90); | 150 | addItemInt("DaylightsavingStart",&mDaylightsavingStart,90); |
151 | addItemInt("DaylightsavingEnd",&mDaylightsavingEnd,304); | 151 | addItemInt("DaylightsavingEnd",&mDaylightsavingEnd,304); |
152 | 152 | ||
153 | 153 | ||
154 | addItemInt("Default Start Time",&mStartTime,10); | 154 | addItemInt("Default Start Time",&mStartTime,10); |
155 | addItemInt("Default Duration",&mDefaultDuration,2); | 155 | addItemInt("Default Duration",&mDefaultDuration,2); |
156 | addItemInt("Default Alarm Time",&mAlarmTime,3); | 156 | addItemInt("Default Alarm Time",&mAlarmTime,3); |
157 | addItemInt("Daylight Savings",&mDaylightSavings,0); | 157 | addItemInt("Daylight Savings",&mDaylightSavings,0); |
158 | KPrefs::setCurrentGroup("AlarmSettings"); | 158 | KPrefs::setCurrentGroup("AlarmSettings"); |
159 | addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20); | 159 | addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20); |
160 | addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7); | 160 | addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7); |
161 | addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5); | 161 | addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5); |
162 | addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3); | 162 | addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3); |
163 | 163 | ||
164 | 164 | ||
165 | KPrefs::setCurrentGroup("Calendar"); | 165 | KPrefs::setCurrentGroup("Calendar"); |
166 | 166 | ||
167 | addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar); | 167 | addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar); |
168 | 168 | ||
169 | KPrefs::setCurrentGroup("Fonts"); | 169 | KPrefs::setCurrentGroup("Fonts"); |
170 | // qDebug(" KPrefs::setCurrentGroup(Fonts); "); | 170 | // qDebug(" KPrefs::setCurrentGroup(Fonts); "); |
171 | addItemFont("TimeBar Font",&mTimeBarFont); | 171 | addItemFont("TimeBar Font",&mTimeBarFont); |
172 | addItemFont("MonthView Font",&mMonthViewFont); | 172 | addItemFont("MonthView Font",&mMonthViewFont); |
173 | addItemFont("AgendaView Font",&mAgendaViewFont); | 173 | addItemFont("AgendaView Font",&mAgendaViewFont); |
174 | addItemFont("MarcusBains Font",&mMarcusBainsFont); | 174 | addItemFont("MarcusBains Font",&mMarcusBainsFont); |
175 | addItemFont("TimeLabels Font",&mTimeLabelsFont); | 175 | addItemFont("TimeLabels Font",&mTimeLabelsFont); |
176 | addItemFont("TodoView Font",&mTodoViewFont); | 176 | addItemFont("TodoView Font",&mTodoViewFont); |
177 | addItemFont("ListView Font",&mListViewFont); | 177 | addItemFont("ListView Font",&mListViewFont); |
178 | addItemFont("DateNavigator Font",&mDateNavigatorFont); | 178 | addItemFont("DateNavigator Font",&mDateNavigatorFont); |
179 | addItemFont("EditBox Font",&mEditBoxFont); | 179 | addItemFont("EditBox Font",&mEditBoxFont); |
180 | addItemFont("JournalView Font",&mJornalViewFont); | 180 | addItemFont("JournalView Font",&mJornalViewFont); |
181 | addItemFont("WhatsNextView Font",&mWhatsNextFont); | 181 | addItemFont("WhatsNextView Font",&mWhatsNextFont); |
182 | addItemFont("EventView Font",&mEventViewFont); | 182 | addItemFont("EventView Font",&mEventViewFont); |
183 | 183 | ||
184 | // KPrefs::setCurrentGroup("SyncProfiles"); | 184 | // KPrefs::setCurrentGroup("SyncProfiles"); |
185 | // addItemString("LocalMachineName",&mLocalMachineName, "undefined"); | 185 | // addItemString("LocalMachineName",&mLocalMachineName, "undefined"); |
186 | // addItemStringList("SyncProfileNames",&mSyncProfileNames); | 186 | // addItemStringList("SyncProfileNames",&mSyncProfileNames); |
187 | // addItemStringList("ExternSyncProfiles",&mExternSyncProfileNames); | 187 | // addItemStringList("ExternSyncProfiles",&mExternSyncProfileNames); |
188 | 188 | ||
189 | KPrefs::setCurrentGroup("RemoteSyncing"); | 189 | KPrefs::setCurrentGroup("RemoteSyncing"); |
190 | // addItemBool("UsePasswd",&mUsePassWd,false); | 190 | // addItemBool("UsePasswd",&mUsePassWd,false); |
191 | // addItemBool("WriteBackFile",&mWriteBackFile,true); | 191 | // addItemBool("WriteBackFile",&mWriteBackFile,true); |
192 | // addItemBool("WriteBackExistingOnly",&mWriteBackExistingOnly,false); | 192 | // addItemBool("WriteBackExistingOnly",&mWriteBackExistingOnly,false); |
193 | // addItemBool("AskForPreferences",&mAskForPreferences,true); | 193 | // addItemBool("AskForPreferences",&mAskForPreferences,true); |
194 | // addItemBool("ShowSyncSummary",&mShowSyncSummary,true); | 194 | // addItemBool("ShowSyncSummary",&mShowSyncSummary,true); |
195 | addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" ); | 195 | addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" ); |
196 | addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" ); | 196 | addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" ); |
197 | addItemBool("ShowSyncEvents",&mShowSyncEvents,false); | 197 | addItemBool("ShowSyncEvents",&mShowSyncEvents,false); |
198 | addItemInt("LastSyncTime",&mLastSyncTime,0); | 198 | addItemInt("LastSyncTime",&mLastSyncTime,0); |
199 | addItemInt("SyncAlgoPrefs",&mSyncAlgoPrefs,3); | ||
200 | addItemInt("RingSyncAlgoPrefs",&mRingSyncAlgoPrefs,3); | ||
201 | 199 | ||
202 | #ifdef _WIN32_ | 200 | #ifdef _WIN32_ |
203 | QString hdp= locateLocal("data","korganizer")+"\\\\"; | 201 | QString hdp= locateLocal("data","korganizer")+"\\\\"; |
204 | #else | 202 | #else |
205 | QString hdp= locateLocal("data","korganizer")+"/"; | 203 | QString hdp= locateLocal("data","korganizer")+"/"; |
206 | #endif | 204 | #endif |
207 | // addItemString("RemoteIP",&mRemoteIP, "192.168.0.65"); | 205 | // addItemString("RemoteIP",&mRemoteIP, "192.168.0.65"); |
208 | // addItemString("RemoteUser",&mRemoteUser, "zaurus"); | 206 | // addItemString("RemoteUser",&mRemoteUser, "zaurus"); |
209 | // addItemString("RemotePassWd",&mRemotePassWd, ""); | 207 | // addItemString("RemotePassWd",&mRemotePassWd, ""); |
210 | // addItemString("RemoteFile", &mRemoteFile, hdp+"mycalendar.ics"); | 208 | // addItemString("RemoteFile", &mRemoteFile, hdp+"mycalendar.ics"); |
211 | // addItemString("LocalTempFile",&mLocalTempFile, "/tmp/tempsyncfile.ics" ); | 209 | // addItemString("LocalTempFile",&mLocalTempFile, "/tmp/tempsyncfile.ics" ); |
212 | 210 | ||
213 | 211 | ||
214 | KPrefs::setCurrentGroup("LoadSaveFileNames"); | 212 | KPrefs::setCurrentGroup("LoadSaveFileNames"); |
215 | 213 | ||
216 | addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" ); | 214 | addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" ); |
217 | addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" ); | 215 | addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" ); |
218 | addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" ); | 216 | addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" ); |
219 | addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" ); | 217 | addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" ); |
220 | addItemString("LastSyncedLocalFile", &mLastSyncedLocalFile ,hdp +"lastsync.ics" ); | ||
221 | 218 | ||
222 | 219 | ||
223 | KPrefs::setCurrentGroup("Locale"); | 220 | KPrefs::setCurrentGroup("Locale"); |
224 | addItemInt("PreferredLanguage",&mPreferredLanguage,0); | 221 | addItemInt("PreferredLanguage",&mPreferredLanguage,0); |
225 | addItemInt("PreferredTime",&mPreferredTime,0); | 222 | addItemInt("PreferredTime",&mPreferredTime,0); |
226 | addItemInt("PreferredDate",&mPreferredDate,0); | 223 | addItemInt("PreferredDate",&mPreferredDate,0); |
227 | addItemBool("WeekStartsOnSunday",&mWeekStartsOnSunday,false); | 224 | addItemBool("WeekStartsOnSunday",&mWeekStartsOnSunday,false); |
228 | addItemBool("ShortDateInViewer",&mShortDateInViewer,false); | 225 | addItemBool("ShortDateInViewer",&mShortDateInViewer,false); |
229 | addItemString("UserDateFormatLong", &mUserDateFormatLong, "%A %d %b %y"); | 226 | addItemString("UserDateFormatLong", &mUserDateFormatLong, "%A %d %b %y"); |
230 | addItemString("UserDateFormatShort", &mUserDateFormatShort, "%aK %d.%m.%y"); | 227 | addItemString("UserDateFormatShort", &mUserDateFormatShort, "%aK %d.%m.%y"); |
231 | 228 | ||
232 | 229 | ||
233 | KPrefs::setCurrentGroup("Colors"); | 230 | KPrefs::setCurrentGroup("Colors"); |
234 | addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor); | 231 | addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor); |
235 | addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor); | 232 | addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor); |
236 | addItemColor("Event Color",&mEventColor,mDefaultCategoryColor); | 233 | addItemColor("Event Color",&mEventColor,mDefaultCategoryColor); |
237 | addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor); | 234 | addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor); |
238 | addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor); | 235 | addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor); |
239 | addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor); | 236 | addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor); |
240 | addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor); | 237 | addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor); |
241 | addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 )); | 238 | addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 )); |
242 | addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 )); | 239 | addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 )); |
243 | addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 )); | 240 | addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 )); |
244 | addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true); | 241 | addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true); |
245 | addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true); | 242 | addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true); |
246 | addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false); | 243 | addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false); |
247 | addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 )); | 244 | addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 )); |
248 | addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 )); | 245 | addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 )); |
249 | addItemBool("UseAppColors",&mUseAppColors,false); | 246 | addItemBool("UseAppColors",&mUseAppColors,false); |
250 | 247 | ||
251 | 248 | ||
252 | 249 | ||
253 | KPrefs::setCurrentGroup("Views"); | 250 | KPrefs::setCurrentGroup("Views"); |
254 | addItemInt("Hour Size",&mHourSize,8); | 251 | addItemInt("Hour Size",&mHourSize,8); |
255 | addItemBool("Show Daily Recurrences",&mDailyRecur,true); | 252 | addItemBool("Show Daily Recurrences",&mDailyRecur,true); |
256 | addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true); | 253 | addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true); |
257 | addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true); | 254 | addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true); |
258 | addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true); | 255 | addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true); |
259 | addItemBool("ShowShortMonthName",&mMonthShowShort,false); | 256 | addItemBool("ShowShortMonthName",&mMonthShowShort,false); |
260 | addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true); | 257 | addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true); |
261 | addItemBool("Enable ToolTips",&mEnableToolTips,false); | 258 | addItemBool("Enable ToolTips",&mEnableToolTips,false); |
262 | addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false); | 259 | addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false); |
263 | addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false); | 260 | addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false); |
264 | addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true); | 261 | addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true); |
265 | addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true); | 262 | addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true); |
266 | addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,false); | 263 | addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,false); |
267 | addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false); | 264 | addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false); |
268 | addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false); | 265 | addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false); |
269 | addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true); | 266 | addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true); |
270 | addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true); | 267 | addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true); |
271 | addItemBool("WNViewShowsParents",&mWNViewShowsParents,true); | 268 | addItemBool("WNViewShowsParents",&mWNViewShowsParents,true); |
272 | addItemBool("WNViewShowLocation",&mWNViewShowLocation,false); | 269 | addItemBool("WNViewShowLocation",&mWNViewShowLocation,false); |
273 | addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false); | 270 | addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false); |
274 | addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true); | 271 | addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true); |
275 | addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false); | 272 | addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false); |
276 | addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false); | 273 | addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false); |
277 | addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,false); | 274 | addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,false); |
278 | addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false); | 275 | addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false); |
279 | addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false); | 276 | addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false); |
280 | #ifdef DESKTOP_VERSION | 277 | #ifdef DESKTOP_VERSION |
281 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true); | 278 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true); |
282 | #else | 279 | #else |
283 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false); | 280 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false); |
284 | #endif | 281 | #endif |
285 | addItemInt("Day Begins",&mDayBegins,7); | 282 | addItemInt("Day Begins",&mDayBegins,7); |
286 | addItemInt("Working Hours Start",&mWorkingHoursStart,8); | 283 | addItemInt("Working Hours Start",&mWorkingHoursStart,8); |
287 | addItemInt("Working Hours End",&mWorkingHoursEnd,17); | 284 | addItemInt("Working Hours End",&mWorkingHoursEnd,17); |
288 | addItemBool("Exclude Holidays",&mExcludeHolidays,true); | 285 | addItemBool("Exclude Holidays",&mExcludeHolidays,true); |
289 | addItemBool("Exclude Saturdays",&mExcludeSaturdays,true); | 286 | addItemBool("Exclude Saturdays",&mExcludeSaturdays,true); |
290 | 287 | ||
291 | addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false); | 288 | addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false); |
292 | addItemBool("Full View Month",&mFullViewMonth,true); | 289 | addItemBool("Full View Month",&mFullViewMonth,true); |
293 | addItemBool("Full View Todo",&mFullViewTodo,true); | 290 | addItemBool("Full View Todo",&mFullViewTodo,true); |
294 | addItemBool("Quick Todo",&mEnableQuickTodo,false); | 291 | addItemBool("Quick Todo",&mEnableQuickTodo,false); |
295 | 292 | ||
296 | addItemInt("Next X Days",&mNextXDays,3); | 293 | addItemInt("Next X Days",&mNextXDays,3); |
297 | 294 | ||
298 | KPrefs::setCurrentGroup("Printer"); | 295 | KPrefs::setCurrentGroup("Printer"); |
299 | 296 | ||
300 | KPrefs::setCurrentGroup("Layout"); | 297 | KPrefs::setCurrentGroup("Layout"); |
301 | 298 | ||
302 | addItemBool("CompactDialogs",&mCompactDialogs,false); | 299 | addItemBool("CompactDialogs",&mCompactDialogs,false); |
303 | addItemBool("VerticalScreen",&mVerticalScreen,true); | 300 | addItemBool("VerticalScreen",&mVerticalScreen,true); |
304 | 301 | ||
305 | KPrefs::setCurrentGroup("KOrganizer Plugins"); | 302 | KPrefs::setCurrentGroup("KOrganizer Plugins"); |
306 | 303 | ||
307 | addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays"); | 304 | addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays"); |
308 | 305 | ||
309 | KPrefs::setCurrentGroup("Group Scheduling"); | 306 | KPrefs::setCurrentGroup("Group Scheduling"); |
310 | 307 | ||
311 | addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail); | 308 | addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail); |
312 | addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend); | 309 | addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend); |
313 | addItemStringList("AdditionalMails",&mAdditionalMails,""); | 310 | addItemStringList("AdditionalMails",&mAdditionalMails,""); |
314 | addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto); | 311 | addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto); |
315 | addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto); | 312 | addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto); |
316 | addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto); | 313 | addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto); |
317 | addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto); | 314 | addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto); |
318 | addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto); | 315 | addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto); |
319 | 316 | ||
320 | KPrefs::setCurrentGroup( "Editors" ); | 317 | KPrefs::setCurrentGroup( "Editors" ); |
321 | 318 | ||
322 | addItemStringList( "EventTemplates", &mEventTemplates ); | 319 | addItemStringList( "EventTemplates", &mEventTemplates ); |
323 | addItemStringList( "TodoTemplates", &mTodoTemplates ); | 320 | addItemStringList( "TodoTemplates", &mTodoTemplates ); |
324 | 321 | ||
325 | addItemInt("DestinationPolicy",&mDestination,standardDestination); | 322 | addItemInt("DestinationPolicy",&mDestination,standardDestination); |
326 | 323 | ||
327 | 324 | ||
328 | 325 | ||
329 | } | 326 | } |
330 | 327 | ||
331 | 328 | ||
332 | KOPrefs::~KOPrefs() | 329 | KOPrefs::~KOPrefs() |
333 | { | 330 | { |
334 | if (mInstance == this) | 331 | if (mInstance == this) |
335 | mInstance = insd.setObject(0); | 332 | mInstance = insd.setObject(0); |
336 | setLocaleDict( 0 ); | 333 | setLocaleDict( 0 ); |
337 | if ( mLocaleDict ) | 334 | if ( mLocaleDict ) |
338 | delete mLocaleDict; | 335 | delete mLocaleDict; |
339 | //qDebug("KOPrefs::~KOPrefs() "); | 336 | //qDebug("KOPrefs::~KOPrefs() "); |
340 | } | 337 | } |
341 | 338 | ||
342 | 339 | ||
343 | KOPrefs *KOPrefs::instance() | 340 | KOPrefs *KOPrefs::instance() |
344 | { | 341 | { |
345 | if (!mInstance) { | 342 | if (!mInstance) { |
346 | mInstance = insd.setObject(new KOPrefs()); | 343 | mInstance = insd.setObject(new KOPrefs()); |
347 | mInstance->readConfig(); | 344 | mInstance->readConfig(); |
348 | } | 345 | } |
349 | 346 | ||
350 | return mInstance; | 347 | return mInstance; |
351 | } | 348 | } |
352 | 349 | ||
353 | void KOPrefs::usrSetDefaults() | 350 | void KOPrefs::usrSetDefaults() |
354 | { | 351 | { |
355 | 352 | ||
356 | } | 353 | } |
357 | 354 | ||
358 | void KOPrefs::fillMailDefaults() | 355 | void KOPrefs::fillMailDefaults() |
359 | { | 356 | { |
360 | if (mName.isEmpty()) mName = i18n("Anonymous"); | 357 | if (mName.isEmpty()) mName = i18n("Anonymous"); |
361 | if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere"); | 358 | if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere"); |
362 | } | 359 | } |
363 | 360 | ||
364 | void KOPrefs::setTimeZoneIdDefault() | 361 | void KOPrefs::setTimeZoneIdDefault() |
365 | { | 362 | { |
366 | mTimeZoneId = i18n("+01:00 Europe/Oslo(CET)"); | 363 | mTimeZoneId = i18n("+01:00 Europe/Oslo(CET)"); |
367 | } | 364 | } |
368 | 365 | ||
369 | void KOPrefs::setCategoryDefaults() | 366 | void KOPrefs::setCategoryDefaults() |
370 | { | 367 | { |
371 | mCustomCategories.clear(); | 368 | mCustomCategories.clear(); |
372 | mCustomCategories = getDefaultList(); | 369 | mCustomCategories = getDefaultList(); |
373 | 370 | ||
374 | QStringList::Iterator it; | 371 | QStringList::Iterator it; |
375 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { | 372 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { |
376 | setCategoryColor(*it,mDefaultCategoryColor); | 373 | setCategoryColor(*it,mDefaultCategoryColor); |
377 | } | 374 | } |
378 | } | 375 | } |
379 | 376 | ||
380 | QStringList KOPrefs::getDefaultList() | 377 | QStringList KOPrefs::getDefaultList() |
381 | { | 378 | { |
382 | QStringList retval ; | 379 | QStringList retval ; |
383 | retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Business Travel") << i18n("Cinema") << i18n("Customer") | 380 | retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Business Travel") << i18n("Cinema") << i18n("Customer") |
384 | << i18n("Break")<< i18n("Breakfast")<< i18n("Competition")<< i18n("Dinner") | 381 | << i18n("Break")<< i18n("Breakfast")<< i18n("Competition")<< i18n("Dinner") |
385 | << i18n("Education")<< i18n("Family") << i18n("Favorites") << i18n("Festival")<< i18n("Fishing")<< i18n("Flight") << i18n("Gifts") | 382 | << i18n("Education")<< i18n("Family") << i18n("Favorites") << i18n("Festival")<< i18n("Fishing")<< i18n("Flight") << i18n("Gifts") |
386 | << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") << i18n("Hiking") << i18n("Hunting") << i18n("Key Customer") << i18n("Kids") | 383 | << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") << i18n("Hiking") << i18n("Hunting") << i18n("Key Customer") << i18n("Kids") |
387 | << i18n("Lunch") << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner")<< i18n("Party") << i18n("Personal") << i18n("Personal Travel") | 384 | << i18n("Lunch") << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner")<< i18n("Party") << i18n("Personal") << i18n("Personal Travel") |
388 | << i18n("PHB") << i18n("Phone Calls") << i18n("Projects") << i18n("Recurring") << i18n("School") << i18n("Shopping") | 385 | << i18n("PHB") << i18n("Phone Calls") << i18n("Projects") << i18n("Recurring") << i18n("School") << i18n("Shopping") |
389 | << i18n("Speach") << i18n("Special Occasion") << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV")<< i18n("University") | 386 | << i18n("Speach") << i18n("Special Occasion") << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV")<< i18n("University") |
390 | << i18n("Vacation") << i18n("VIP") << i18n("SyncEvent") ; | 387 | << i18n("Vacation") << i18n("VIP") << i18n("SyncEvent") ; |
391 | retval.sort(); | 388 | retval.sort(); |
392 | return retval; | 389 | return retval; |
393 | } | 390 | } |
394 | 391 | ||
395 | void KOPrefs::usrReadConfig() | 392 | void KOPrefs::usrReadConfig() |
396 | { | 393 | { |
397 | mPreferredLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage; | 394 | mPreferredLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage; |
398 | mLocaleDict = 0; | 395 | mLocaleDict = 0; |
399 | // pending LR fix translation | 396 | // pending LR fix translation |
400 | // qDebug("KOPrefs::usrReadConfig() fix translation "); | 397 | // qDebug("KOPrefs::usrReadConfig() fix translation "); |
401 | if ( mPreferredLanguage > 0 && mPreferredLanguage < 4 ) { | 398 | if ( mPreferredLanguage > 0 && mPreferredLanguage < 4 ) { |
402 | if ( mPreferredLanguage == 1 ) { | 399 | if ( mPreferredLanguage == 1 ) { |
403 | mLocaleDict = new QDict<QString>; | 400 | mLocaleDict = new QDict<QString>; |
404 | int i = 0; | 401 | int i = 0; |
405 | QString fw ( germanwords[i] [0]); | 402 | QString fw ( germanwords[i] [0]); |
406 | while ( !fw.isEmpty() ) { | 403 | while ( !fw.isEmpty() ) { |
407 | mLocaleDict->insert( fw, new QString (germanwords[i] [1] )); | 404 | mLocaleDict->insert( fw, new QString (germanwords[i] [1] )); |
408 | ++i; | 405 | ++i; |
409 | fw = germanwords[i] [0]; | 406 | fw = germanwords[i] [0]; |
410 | } | 407 | } |
411 | 408 | ||
412 | setLocaleDict( mLocaleDict ); | 409 | setLocaleDict( mLocaleDict ); |
413 | } else { | 410 | } else { |
414 | QString fileName ; | 411 | QString fileName ; |
415 | if ( mPreferredLanguage == 3 ) | 412 | if ( mPreferredLanguage == 3 ) |
416 | fileName = MainWindow::resourcePath()+"usertranslation.txt"; | 413 | fileName = MainWindow::resourcePath()+"usertranslation.txt"; |
417 | else if ( mPreferredLanguage == 2 ) | 414 | else if ( mPreferredLanguage == 2 ) |
418 | fileName = MainWindow::resourcePath()+"frenchtranslation.txt"; | 415 | fileName = MainWindow::resourcePath()+"frenchtranslation.txt"; |
419 | QFile file( fileName ); | 416 | QFile file( fileName ); |
420 | if (file.open( IO_ReadOnly ) ) { | 417 | if (file.open( IO_ReadOnly ) ) { |
421 | QTextStream ts( &file ); | 418 | QTextStream ts( &file ); |
422 | ts.setEncoding( QTextStream::Latin1 ); | 419 | ts.setEncoding( QTextStream::Latin1 ); |
423 | //ts.setCodec( QTextCodec::latin1 ); | 420 | //ts.setCodec( QTextCodec::latin1 ); |
424 | QString text = ts.read(); | 421 | QString text = ts.read(); |
425 | file.close(); | 422 | file.close(); |
426 | text.replace( QRegExp("\\\\n"), "\n" ); | 423 | text.replace( QRegExp("\\\\n"), "\n" ); |
427 | QString line; | 424 | QString line; |
428 | QString we; | 425 | QString we; |
429 | QString wt; | 426 | QString wt; |
430 | int br = 0; | 427 | int br = 0; |
431 | int nbr; | 428 | int nbr; |
432 | nbr = text.find ( "},", br ); | 429 | nbr = text.find ( "},", br ); |
433 | line = text.mid( br, nbr - br ); | 430 | line = text.mid( br, nbr - br ); |
434 | br = nbr+1; | 431 | br = nbr+1; |
435 | int se, ee, st, et; | 432 | int se, ee, st, et; |
436 | mLocaleDict = new QDict<QString>; | 433 | mLocaleDict = new QDict<QString>; |
437 | QString end = "{ \"\",\"\" }"; | 434 | QString end = "{ \"\",\"\" }"; |
438 | while ( (line != end) && (br > 1) ) { | 435 | while ( (line != end) && (br > 1) ) { |
439 | //qDebug("%d *%s* ", br, line.latin1()); | 436 | //qDebug("%d *%s* ", br, line.latin1()); |
440 | se = line.find("\"")+1; | 437 | se = line.find("\"")+1; |
441 | et = line.findRev("\"",-1); | 438 | et = line.findRev("\"",-1); |
442 | ee = line.find("\",\""); | 439 | ee = line.find("\",\""); |
443 | st = ee+3; | 440 | st = ee+3; |
444 | we = line.mid( se, ee-se ); | 441 | we = line.mid( se, ee-se ); |
445 | wt = line.mid( st, et-st ); | 442 | wt = line.mid( st, et-st ); |
446 | //qDebug("*%s* *%s* ", we.latin1(), wt.latin1()); | 443 | //qDebug("*%s* *%s* ", we.latin1(), wt.latin1()); |
447 | mLocaleDict->insert( we, new QString (wt) ); | 444 | mLocaleDict->insert( we, new QString (wt) ); |
448 | nbr = text.find ( "}", br ); | 445 | nbr = text.find ( "}", br ); |
449 | line = text.mid( br, nbr - br ); | 446 | line = text.mid( br, nbr - br ); |
450 | br = nbr+1; | 447 | br = nbr+1; |
451 | } | 448 | } |
452 | //qDebug("end *%s* ", end.latin1()); | 449 | //qDebug("end *%s* ", end.latin1()); |
453 | 450 | ||
454 | setLocaleDict( mLocaleDict ); | 451 | setLocaleDict( mLocaleDict ); |
455 | } else { | 452 | } else { |
456 | qDebug("KO: Cannot find translation file %s",fileName.latin1() ); | 453 | qDebug("KO: Cannot find translation file %s",fileName.latin1() ); |
457 | } | 454 | } |
458 | 455 | ||
459 | } | 456 | } |
460 | } | 457 | } |
461 | config()->setGroup("General"); | 458 | config()->setGroup("General"); |
462 | 459 | ||
463 | mCustomCategories = config()->readListEntry("Custom Categories"); | 460 | mCustomCategories = config()->readListEntry("Custom Categories"); |
464 | if ( KOPrefs::instance()->mLanguageChanged ) { | 461 | if ( KOPrefs::instance()->mLanguageChanged ) { |
465 | mLocationDefaults.clear(); | 462 | mLocationDefaults.clear(); |
466 | mEventSummaryUser.clear(); | 463 | mEventSummaryUser.clear(); |
467 | mTodoSummaryUser.clear(); | 464 | mTodoSummaryUser.clear(); |
468 | } | 465 | } |
469 | if (mLocationDefaults.isEmpty()) { | 466 | if (mLocationDefaults.isEmpty()) { |
470 | mLocationDefaults << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach") | 467 | mLocationDefaults << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach") |
471 | << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room") << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten") | 468 | << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room") << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten") |
472 | << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ; | 469 | << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ; |
473 | // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") | 470 | // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") |
474 | mLocationDefaults.sort(); | 471 | mLocationDefaults.sort(); |
475 | } | 472 | } |
476 | 473 | ||
477 | if (mEventSummaryUser.isEmpty()) { | 474 | if (mEventSummaryUser.isEmpty()) { |
478 | mEventSummaryUser = getDefaultList() ; | 475 | mEventSummaryUser = getDefaultList() ; |
479 | } | 476 | } |
480 | if (mTodoSummaryUser.isEmpty()) { | 477 | if (mTodoSummaryUser.isEmpty()) { |
481 | mTodoSummaryUser = getDefaultList() ; | 478 | mTodoSummaryUser = getDefaultList() ; |
482 | } | 479 | } |
483 | 480 | ||
484 | if (mCustomCategories.isEmpty()) setCategoryDefaults(); | 481 | if (mCustomCategories.isEmpty()) setCategoryDefaults(); |
485 | 482 | ||
486 | config()->setGroup("Personal Settings"); | 483 | config()->setGroup("Personal Settings"); |
487 | mName = config()->readEntry("user_name",""); | 484 | mName = config()->readEntry("user_name",""); |
488 | mEmail = config()->readEntry("user_email",""); | 485 | mEmail = config()->readEntry("user_email",""); |
489 | fillMailDefaults(); | 486 | fillMailDefaults(); |
490 | 487 | ||
491 | config()->setGroup("Category Colors"); | 488 | config()->setGroup("Category Colors"); |
492 | QStringList::Iterator it; | 489 | QStringList::Iterator it; |
493 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { | 490 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { |
494 | setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor)); | 491 | setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor)); |
495 | 492 | ||
496 | } | 493 | } |
497 | 494 | ||
498 | if (mTimeZoneId.isEmpty()) { | 495 | if (mTimeZoneId.isEmpty()) { |
499 | setTimeZoneIdDefault(); | 496 | setTimeZoneIdDefault(); |
500 | } | 497 | } |
501 | KPimPrefs::usrReadConfig(); | 498 | KPimPrefs::usrReadConfig(); |
502 | } | 499 | } |
503 | 500 | ||
504 | 501 | ||
505 | void KOPrefs::usrWriteConfig() | 502 | void KOPrefs::usrWriteConfig() |
506 | { | 503 | { |
507 | config()->setGroup("General"); | 504 | config()->setGroup("General"); |
508 | config()->writeEntry("Custom Categories",mCustomCategories); | 505 | config()->writeEntry("Custom Categories",mCustomCategories); |
509 | 506 | ||
510 | config()->setGroup("Personal Settings"); | 507 | config()->setGroup("Personal Settings"); |
511 | config()->writeEntry("user_name",mName); | 508 | config()->writeEntry("user_name",mName); |
512 | config()->writeEntry("user_email",mEmail); | 509 | config()->writeEntry("user_email",mEmail); |
513 | 510 | ||
514 | config()->setGroup("Category Colors"); | 511 | config()->setGroup("Category Colors"); |
515 | QDictIterator<QColor> it(mCategoryColors); | 512 | QDictIterator<QColor> it(mCategoryColors); |
516 | while (it.current()) { | 513 | while (it.current()) { |
517 | config()->writeEntry(it.currentKey(),*(it.current())); | 514 | config()->writeEntry(it.currentKey(),*(it.current())); |
518 | ++it; | 515 | ++it; |
519 | } | 516 | } |
520 | 517 | ||
521 | 518 | ||
522 | KPimPrefs::usrWriteConfig(); | 519 | KPimPrefs::usrWriteConfig(); |
523 | } | 520 | } |
524 | 521 | ||
525 | void KOPrefs::setCategoryColor(QString cat,const QColor & color) | 522 | void KOPrefs::setCategoryColor(QString cat,const QColor & color) |
526 | { | 523 | { |
527 | mCategoryColors.replace(cat,new QColor(color)); | 524 | mCategoryColors.replace(cat,new QColor(color)); |
528 | } | 525 | } |
529 | 526 | ||
530 | QColor *KOPrefs::categoryColor(QString cat) | 527 | QColor *KOPrefs::categoryColor(QString cat) |
531 | { | 528 | { |
532 | QColor *color = 0; | 529 | QColor *color = 0; |
533 | 530 | ||
534 | if (!cat.isEmpty()) color = mCategoryColors[cat]; | 531 | if (!cat.isEmpty()) color = mCategoryColors[cat]; |
535 | 532 | ||
536 | if (color) return color; | 533 | if (color) return color; |
537 | else return &mDefaultCategoryColor; | 534 | else return &mDefaultCategoryColor; |
538 | } | 535 | } |
539 | 536 | ||
540 | void KOPrefs::setFullName(const QString &name) | 537 | void KOPrefs::setFullName(const QString &name) |
541 | { | 538 | { |
542 | mName = name; | 539 | mName = name; |
543 | } | 540 | } |
544 | 541 | ||
545 | void KOPrefs::setEmail(const QString &email) | 542 | void KOPrefs::setEmail(const QString &email) |
546 | { | 543 | { |
547 | //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() ); | 544 | //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() ); |
548 | mEmail = email; | 545 | mEmail = email; |
549 | } | 546 | } |
550 | 547 | ||
551 | QString KOPrefs::fullName() | 548 | QString KOPrefs::fullName() |
552 | { | 549 | { |
553 | if (mEmailControlCenter) { | 550 | if (mEmailControlCenter) { |
554 | KEMailSettings settings; | 551 | KEMailSettings settings; |
555 | return settings.getSetting(KEMailSettings::RealName); | 552 | return settings.getSetting(KEMailSettings::RealName); |
556 | } else { | 553 | } else { |
557 | return mName; | 554 | return mName; |
558 | } | 555 | } |
559 | } | 556 | } |
560 | 557 | ||
561 | QString KOPrefs::email() | 558 | QString KOPrefs::email() |
562 | { | 559 | { |
563 | if (mEmailControlCenter) { | 560 | if (mEmailControlCenter) { |
564 | KEMailSettings settings; | 561 | KEMailSettings settings; |
565 | return settings.getSetting(KEMailSettings::EmailAddress); | 562 | return settings.getSetting(KEMailSettings::EmailAddress); |
566 | } else { | 563 | } else { |
567 | return mEmail; | 564 | return mEmail; |
568 | } | 565 | } |
569 | } | 566 | } |
570 | KConfig* KOPrefs::getConfig() | 567 | KConfig* KOPrefs::getConfig() |
571 | { | 568 | { |
572 | return config(); | 569 | return config(); |
573 | } | 570 | } |
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h index ff09e19..03df59b 100644 --- a/korganizer/koprefs.h +++ b/korganizer/koprefs.h | |||
@@ -1,312 +1,292 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | #ifndef KOPREFS_H | 23 | #ifndef KOPREFS_H |
24 | #define KOPREFS_H | 24 | #define KOPREFS_H |
25 | 25 | ||
26 | #include <qdict.h> | 26 | #include <qdict.h> |
27 | 27 | ||
28 | #include <libkdepim/kpimprefs.h> | 28 | #include <libkdepim/kpimprefs.h> |
29 | 29 | ||
30 | class KConfig; | 30 | class KConfig; |
31 | class QFont; | 31 | class QFont; |
32 | class QColor; | 32 | class QColor; |
33 | class QStringList; | 33 | class QStringList; |
34 | 34 | ||
35 | class KOPrefs : public KPimPrefs | 35 | class KOPrefs : public KPimPrefs |
36 | { | 36 | { |
37 | public: | 37 | public: |
38 | enum { FormatVCalendar, FormatICalendar }; | 38 | enum { FormatVCalendar, FormatICalendar }; |
39 | enum { MailClientKMail, MailClientSendmail }; | 39 | enum { MailClientKMail, MailClientSendmail }; |
40 | enum { IMIPDummy, IMIPKMail }; | 40 | enum { IMIPDummy, IMIPKMail }; |
41 | enum { IMIPOutbox, IMIPdirectsend }; | 41 | enum { IMIPOutbox, IMIPdirectsend }; |
42 | enum { neverAuto, addressbookAuto, selectedAuto }; | 42 | enum { neverAuto, addressbookAuto, selectedAuto }; |
43 | enum { standardDestination, askDestination }; | 43 | enum { standardDestination, askDestination }; |
44 | 44 | ||
45 | virtual ~KOPrefs(); | 45 | virtual ~KOPrefs(); |
46 | 46 | ||
47 | /** Get instance of KOPrefs. It is made sure that there is only one | 47 | /** Get instance of KOPrefs. It is made sure that there is only one |
48 | instance. */ | 48 | instance. */ |
49 | static KOPrefs *instance(); | 49 | static KOPrefs *instance(); |
50 | 50 | ||
51 | /** Set preferences to default values */ | 51 | /** Set preferences to default values */ |
52 | void usrSetDefaults(); | 52 | void usrSetDefaults(); |
53 | 53 | ||
54 | /** Read preferences from config file */ | 54 | /** Read preferences from config file */ |
55 | void usrReadConfig(); | 55 | void usrReadConfig(); |
56 | 56 | ||
57 | /** Write preferences to config file */ | 57 | /** Write preferences to config file */ |
58 | void usrWriteConfig(); | 58 | void usrWriteConfig(); |
59 | void setCategoryDefaults(); | 59 | void setCategoryDefaults(); |
60 | 60 | ||
61 | protected: | 61 | protected: |
62 | void setTimeZoneIdDefault(); | 62 | void setTimeZoneIdDefault(); |
63 | 63 | ||
64 | /** Fill empty mail fields with default values. */ | 64 | /** Fill empty mail fields with default values. */ |
65 | void fillMailDefaults(); | 65 | void fillMailDefaults(); |
66 | 66 | ||
67 | private: | 67 | private: |
68 | /** Constructor disabled for public. Use instance() to create a KOPrefs | 68 | /** Constructor disabled for public. Use instance() to create a KOPrefs |
69 | object. */ | 69 | object. */ |
70 | KOPrefs(); | 70 | KOPrefs(); |
71 | 71 | ||
72 | static KOPrefs *mInstance; | 72 | static KOPrefs *mInstance; |
73 | QDict<QString> *mLocaleDict; | 73 | QDict<QString> *mLocaleDict; |
74 | QStringList getDefaultList(); | 74 | QStringList getDefaultList(); |
75 | public: | 75 | public: |
76 | // preferences data | 76 | // preferences data |
77 | KConfig* getConfig(); | 77 | KConfig* getConfig(); |
78 | void setFullName(const QString &); | 78 | void setFullName(const QString &); |
79 | QString fullName(); | 79 | QString fullName(); |
80 | void setEmail(const QString &); | 80 | void setEmail(const QString &); |
81 | QString email(); | 81 | QString email(); |
82 | 82 | ||
83 | QString mAdditional; | 83 | QString mAdditional; |
84 | 84 | ||
85 | bool mEmailControlCenter; | 85 | bool mEmailControlCenter; |
86 | 86 | ||
87 | bool mBcc; | 87 | bool mBcc; |
88 | bool mAutoSave; | 88 | bool mAutoSave; |
89 | int mAutoSaveInterval; | 89 | int mAutoSaveInterval; |
90 | bool mConfirm; | 90 | bool mConfirm; |
91 | 91 | ||
92 | bool mEnableGroupScheduling; | 92 | bool mEnableGroupScheduling; |
93 | bool mEnableProjectView; | 93 | bool mEnableProjectView; |
94 | 94 | ||
95 | int mDefaultFormat; | 95 | int mDefaultFormat; |
96 | int mMailClient; | 96 | int mMailClient; |
97 | 97 | ||
98 | QString mTimeZone; | 98 | QString mTimeZone; |
99 | //QString mTimeZoneName; // e.g. +00:04:00 Indian/Mauritius | 99 | //QString mTimeZoneName; // e.g. +00:04:00 Indian/Mauritius |
100 | //int mTimeZoneOffset; // e.g. -240 min | 100 | //int mTimeZoneOffset; // e.g. -240 min |
101 | int mStartTime; | 101 | int mStartTime; |
102 | int mDefaultDuration; | 102 | int mDefaultDuration; |
103 | int mAlarmTime; | 103 | int mAlarmTime; |
104 | int mDaylightSavings; | 104 | int mDaylightSavings; |
105 | 105 | ||
106 | int mWorkingHoursStart; | 106 | int mWorkingHoursStart; |
107 | int mWorkingHoursEnd; | 107 | int mWorkingHoursEnd; |
108 | bool mExcludeHolidays; | 108 | bool mExcludeHolidays; |
109 | bool mExcludeSaturdays; | 109 | bool mExcludeSaturdays; |
110 | bool mMarcusBainsShowSeconds; | 110 | bool mMarcusBainsShowSeconds; |
111 | 111 | ||
112 | QFont mTimeBarFont; | 112 | QFont mTimeBarFont; |
113 | QFont mMonthViewFont; | 113 | QFont mMonthViewFont; |
114 | QFont mAgendaViewFont; | 114 | QFont mAgendaViewFont; |
115 | QFont mMarcusBainsFont; | 115 | QFont mMarcusBainsFont; |
116 | QFont mTimeLabelsFont; | 116 | QFont mTimeLabelsFont; |
117 | QFont mTodoViewFont; | 117 | QFont mTodoViewFont; |
118 | QFont mListViewFont; | 118 | QFont mListViewFont; |
119 | QFont mDateNavigatorFont; | 119 | QFont mDateNavigatorFont; |
120 | QFont mEditBoxFont; | 120 | QFont mEditBoxFont; |
121 | QFont mJornalViewFont; | 121 | QFont mJornalViewFont; |
122 | QFont mWhatsNextFont; | 122 | QFont mWhatsNextFont; |
123 | QFont mEventViewFont; | 123 | QFont mEventViewFont; |
124 | 124 | ||
125 | 125 | ||
126 | 126 | ||
127 | 127 | ||
128 | QColor mHolidayColor; | 128 | QColor mHolidayColor; |
129 | QColor mHighlightColor; | 129 | QColor mHighlightColor; |
130 | QColor mEventColor; | 130 | QColor mEventColor; |
131 | QColor mAgendaBgColor; | 131 | QColor mAgendaBgColor; |
132 | QColor mWorkingHoursColor; | 132 | QColor mWorkingHoursColor; |
133 | QColor mTodoDueTodayColor; | 133 | QColor mTodoDueTodayColor; |
134 | QColor mTodoOverdueColor; | 134 | QColor mTodoOverdueColor; |
135 | QColor mMonthViewEvenColor; | 135 | QColor mMonthViewEvenColor; |
136 | QColor mMonthViewOddColor; | 136 | QColor mMonthViewOddColor; |
137 | QColor mMonthViewHolidayColor; | 137 | QColor mMonthViewHolidayColor; |
138 | bool mMonthViewUsesDayColors; | 138 | bool mMonthViewUsesDayColors; |
139 | bool mMonthViewSatSunTog; | 139 | bool mMonthViewSatSunTog; |
140 | QColor mAppColor1; | 140 | QColor mAppColor1; |
141 | QColor mAppColor2; | 141 | QColor mAppColor2; |
142 | bool mUseAppColors; | 142 | bool mUseAppColors; |
143 | 143 | ||
144 | int mDayBegins; | 144 | int mDayBegins; |
145 | int mHourSize; | 145 | int mHourSize; |
146 | int mAllDaySize; | 146 | int mAllDaySize; |
147 | bool mShowFullMenu; | 147 | bool mShowFullMenu; |
148 | bool mDailyRecur; | 148 | bool mDailyRecur; |
149 | bool mWeeklyRecur; | 149 | bool mWeeklyRecur; |
150 | bool mMonthDailyRecur; | 150 | bool mMonthDailyRecur; |
151 | bool mMonthWeeklyRecur; | 151 | bool mMonthWeeklyRecur; |
152 | bool mMonthShowIcons; | 152 | bool mMonthShowIcons; |
153 | bool mMonthShowShort; | 153 | bool mMonthShowShort; |
154 | bool mEnableToolTips; | 154 | bool mEnableToolTips; |
155 | bool mEnableMonthScroll; | 155 | bool mEnableMonthScroll; |
156 | bool mFullViewMonth; | 156 | bool mFullViewMonth; |
157 | bool mMonthViewUsesCategoryColor; | 157 | bool mMonthViewUsesCategoryColor; |
158 | bool mFullViewTodo; | 158 | bool mFullViewTodo; |
159 | bool mShowCompletedTodo; | 159 | bool mShowCompletedTodo; |
160 | bool mMarcusBainsEnabled; | 160 | bool mMarcusBainsEnabled; |
161 | int mNextXDays; | 161 | int mNextXDays; |
162 | int mWhatsNextDays; | 162 | int mWhatsNextDays; |
163 | int mWhatsNextPrios; | 163 | int mWhatsNextPrios; |
164 | bool mEnableQuickTodo; | 164 | bool mEnableQuickTodo; |
165 | bool mLanguageChanged; | 165 | bool mLanguageChanged; |
166 | 166 | ||
167 | bool mCompactDialogs; | 167 | bool mCompactDialogs; |
168 | bool mVerticalScreen; | 168 | bool mVerticalScreen; |
169 | 169 | ||
170 | bool mShowIconNewTodo; | 170 | bool mShowIconNewTodo; |
171 | bool mShowIconNewEvent; | 171 | bool mShowIconNewEvent; |
172 | bool mShowIconSearch; | 172 | bool mShowIconSearch; |
173 | bool mShowIconList; | 173 | bool mShowIconList; |
174 | bool mShowIconDay1; | 174 | bool mShowIconDay1; |
175 | bool mShowIconDay5; | 175 | bool mShowIconDay5; |
176 | bool mShowIconDay7; | 176 | bool mShowIconDay7; |
177 | bool mShowIconMonth; | 177 | bool mShowIconMonth; |
178 | bool mShowIconTodoview; | 178 | bool mShowIconTodoview; |
179 | bool mShowIconBackFast; | 179 | bool mShowIconBackFast; |
180 | bool mShowIconBack; | 180 | bool mShowIconBack; |
181 | bool mShowIconToday; | 181 | bool mShowIconToday; |
182 | bool mShowIconForward; | 182 | bool mShowIconForward; |
183 | bool mShowIconForwardFast; | 183 | bool mShowIconForwardFast; |
184 | bool mShowIconWhatsThis; | 184 | bool mShowIconWhatsThis; |
185 | bool mShowIconNextDays; | 185 | bool mShowIconNextDays; |
186 | bool mShowIconNext; | 186 | bool mShowIconNext; |
187 | bool mShowIconJournal; | 187 | bool mShowIconJournal; |
188 | 188 | ||
189 | bool mShowIconStretch; | 189 | bool mShowIconStretch; |
190 | 190 | ||
191 | bool mToolBarHor; | 191 | bool mToolBarHor; |
192 | bool mToolBarUp; | 192 | bool mToolBarUp; |
193 | bool mToolBarMiniIcons; | 193 | bool mToolBarMiniIcons; |
194 | 194 | ||
195 | bool mAskForQuit; | 195 | bool mAskForQuit; |
196 | bool mUsePassWd; | 196 | bool mUsePassWd; |
197 | bool mWriteBackFile; | ||
198 | int mWriteBackInFuture; | ||
199 | bool mAskForPreferences; | ||
200 | bool mShowSyncSummary; | ||
201 | bool mShowSyncEvents; | 197 | bool mShowSyncEvents; |
202 | bool mShowTodoInAgenda; | 198 | bool mShowTodoInAgenda; |
203 | bool mWriteBackExistingOnly; | ||
204 | |||
205 | QString mRemoteIP; | ||
206 | QString mRemoteUser; | ||
207 | QString mRemotePassWd; | ||
208 | QString mRemoteFile; | ||
209 | QString mLocalTempFile; | ||
210 | QString mPhoneDevice; | ||
211 | QString mPhoneConnection; | ||
212 | QString mPhoneModel; | ||
213 | 199 | ||
214 | int mLastSyncTime; | 200 | int mLastSyncTime; |
215 | int mSyncAlgoPrefs; | ||
216 | int mRingSyncAlgoPrefs; | ||
217 | QStringList mSyncProfileNames; | ||
218 | QStringList mExternSyncProfiles; | ||
219 | QString mLocalMachineName; | ||
220 | void setCategoryColor(QString cat,const QColor & color); | 201 | void setCategoryColor(QString cat,const QColor & color); |
221 | QColor *categoryColor(QString cat); | 202 | QColor *categoryColor(QString cat); |
222 | 203 | ||
223 | QString mArchiveFile; | 204 | QString mArchiveFile; |
224 | QString mHtmlExportFile; | 205 | QString mHtmlExportFile; |
225 | bool mHtmlWithSave; | 206 | bool mHtmlWithSave; |
226 | 207 | ||
227 | QStringList mSelectedPlugins; | 208 | QStringList mSelectedPlugins; |
228 | 209 | ||
229 | QString mLastImportFile; | 210 | QString mLastImportFile; |
230 | QString mLastVcalFile; | 211 | QString mLastVcalFile; |
231 | QString mLastSaveFile; | 212 | QString mLastSaveFile; |
232 | QString mLastLoadFile; | 213 | QString mLastLoadFile; |
233 | QString mLastSyncedLocalFile; | ||
234 | 214 | ||
235 | 215 | ||
236 | QString mDefaultAlarmFile; | 216 | QString mDefaultAlarmFile; |
237 | int mIMIPScheduler; | 217 | int mIMIPScheduler; |
238 | int mIMIPSend; | 218 | int mIMIPSend; |
239 | QStringList mAdditionalMails; | 219 | QStringList mAdditionalMails; |
240 | int mIMIPAutoRefresh; | 220 | int mIMIPAutoRefresh; |
241 | int mIMIPAutoInsertReply; | 221 | int mIMIPAutoInsertReply; |
242 | int mIMIPAutoInsertRequest; | 222 | int mIMIPAutoInsertRequest; |
243 | int mIMIPAutoFreeBusy; | 223 | int mIMIPAutoFreeBusy; |
244 | int mIMIPAutoFreeBusyReply; | 224 | int mIMIPAutoFreeBusyReply; |
245 | 225 | ||
246 | QStringList mTodoTemplates; | 226 | QStringList mTodoTemplates; |
247 | QStringList mEventTemplates; | 227 | QStringList mEventTemplates; |
248 | 228 | ||
249 | int mDestination; | 229 | int mDestination; |
250 | 230 | ||
251 | 231 | ||
252 | bool mEditOnDoubleClick; | 232 | bool mEditOnDoubleClick; |
253 | bool mViewChangeHoldFullscreen; | 233 | bool mViewChangeHoldFullscreen; |
254 | bool mViewChangeHoldNonFullscreen; | 234 | bool mViewChangeHoldNonFullscreen; |
255 | bool mCenterOnCurrentTime; | 235 | bool mCenterOnCurrentTime; |
256 | bool mSetTimeToDayStartAt; | 236 | bool mSetTimeToDayStartAt; |
257 | bool mHighlightCurrentDay; | 237 | bool mHighlightCurrentDay; |
258 | bool mUseHighlightLightColor; | 238 | bool mUseHighlightLightColor; |
259 | bool mListViewMonthTimespan; | 239 | bool mListViewMonthTimespan; |
260 | bool mWNViewShowsParents; | 240 | bool mWNViewShowsParents; |
261 | bool mWNViewShowLocation; | 241 | bool mWNViewShowLocation; |
262 | bool mTodoViewShowsPercentage; | 242 | bool mTodoViewShowsPercentage; |
263 | bool mTodoViewUsesCatColors; | 243 | bool mTodoViewUsesCatColors; |
264 | bool mTodoViewUsesSmallFont; | 244 | bool mTodoViewUsesSmallFont; |
265 | bool mTodoViewUsesForegroundColor; | 245 | bool mTodoViewUsesForegroundColor; |
266 | bool mMonthViewUsesForegroundColor; | 246 | bool mMonthViewUsesForegroundColor; |
267 | 247 | ||
268 | bool mHightlightDateTimeEdit; | 248 | bool mHightlightDateTimeEdit; |
269 | bool mShortDateInViewer; | 249 | bool mShortDateInViewer; |
270 | 250 | ||
271 | QStringList mLocationDefaults; | 251 | QStringList mLocationDefaults; |
272 | QStringList mEventSummaryUser; | 252 | QStringList mEventSummaryUser; |
273 | QStringList mTodoSummaryUser; | 253 | QStringList mTodoSummaryUser; |
274 | 254 | ||
275 | bool mUseInternalAlarmNotification; | 255 | bool mUseInternalAlarmNotification; |
276 | int mAlarmPlayBeeps; | 256 | int mAlarmPlayBeeps; |
277 | int mAlarmSuspendTime; | 257 | int mAlarmSuspendTime; |
278 | int mAlarmSuspendCount; | 258 | int mAlarmSuspendCount; |
279 | int mAlarmBeepInterval; | 259 | int mAlarmBeepInterval; |
280 | 260 | ||
281 | 261 | ||
282 | QString mActiveSyncPort; | 262 | QString mActiveSyncPort; |
283 | QString mActiveSyncIP; | 263 | QString mActiveSyncIP; |
284 | 264 | ||
285 | 265 | ||
286 | //US I copied the following settings into KPimGlobalPrefs | 266 | //US I copied the following settings into KPimGlobalPrefs |
287 | // that allows us later to easily remove the settings from here. | 267 | // that allows us later to easily remove the settings from here. |
288 | int mPreferredDate; | 268 | int mPreferredDate; |
289 | QString mUserDateFormatLong; | 269 | QString mUserDateFormatLong; |
290 | QString mUserDateFormatShort; | 270 | QString mUserDateFormatShort; |
291 | int mPreferredLanguage; | 271 | int mPreferredLanguage; |
292 | int mPreferredTime; | 272 | int mPreferredTime; |
293 | bool mWeekStartsOnSunday; | 273 | bool mWeekStartsOnSunday; |
294 | QString mTimeZoneId; | 274 | QString mTimeZoneId; |
295 | bool mUseDaylightsaving; | 275 | bool mUseDaylightsaving; |
296 | int mDaylightsavingStart; | 276 | int mDaylightsavingStart; |
297 | int mDaylightsavingEnd; | 277 | int mDaylightsavingEnd; |
298 | 278 | ||
299 | 279 | ||
300 | private: | 280 | private: |
301 | QDict<QColor> mCategoryColors; | 281 | QDict<QColor> mCategoryColors; |
302 | QColor mDefaultCategoryColor; | 282 | QColor mDefaultCategoryColor; |
303 | 283 | ||
304 | QFont mDefaultTimeBarFont; | 284 | QFont mDefaultTimeBarFont; |
305 | QFont mDefaultViewFont; | 285 | QFont mDefaultViewFont; |
306 | QFont mDefaultMonthViewFont; | 286 | QFont mDefaultMonthViewFont; |
307 | 287 | ||
308 | QString mName; | 288 | QString mName; |
309 | QString mEmail; | 289 | QString mEmail; |
310 | }; | 290 | }; |
311 | 291 | ||
312 | #endif | 292 | #endif |
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index e3324ee..f7766f8 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp | |||
@@ -1,2348 +1,1838 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | 2 | ||
3 | #include <qaction.h> | 3 | #include <qaction.h> |
4 | #include <qpopupmenu.h> | 4 | #include <qpopupmenu.h> |
5 | #include <qpainter.h> | 5 | #include <qpainter.h> |
6 | #include <qwhatsthis.h> | 6 | #include <qwhatsthis.h> |
7 | #include <qpushbutton.h> | 7 | #include <qpushbutton.h> |
8 | #include <qmessagebox.h> | 8 | #include <qmessagebox.h> |
9 | #include <qlineedit.h> | 9 | #include <qlineedit.h> |
10 | #include <qtextcodec.h> | 10 | #include <qtextcodec.h> |
11 | #include <qfile.h> | 11 | #include <qfile.h> |
12 | #include <qdir.h> | 12 | #include <qdir.h> |
13 | #include <qapp.h> | 13 | #include <qapp.h> |
14 | #include <qfileinfo.h> | 14 | #include <qfileinfo.h> |
15 | #include <qlabel.h> | 15 | #include <qlabel.h> |
16 | #include <qspinbox.h> | 16 | #include <qspinbox.h> |
17 | #include <qcheckbox.h> | 17 | #include <qcheckbox.h> |
18 | #include <qmap.h> | 18 | #include <qmap.h> |
19 | #include <qwmatrix.h> | 19 | #include <qwmatrix.h> |
20 | #include <qtextbrowser.h> | 20 | #include <qtextbrowser.h> |
21 | #include <qtextstream.h> | 21 | #include <qtextstream.h> |
22 | #ifndef DESKTOP_VERSION | 22 | #ifndef DESKTOP_VERSION |
23 | #include <qpe/global.h> | 23 | #include <qpe/global.h> |
24 | #include <qpe/qpemenubar.h> | 24 | #include <qpe/qpemenubar.h> |
25 | #include <qpe/qpetoolbar.h> | 25 | #include <qpe/qpetoolbar.h> |
26 | #include <qpe/resource.h> | 26 | #include <qpe/resource.h> |
27 | #include <qpe/qpeapplication.h> | 27 | #include <qpe/qpeapplication.h> |
28 | #include <qtopia/alarmserver.h> | 28 | #include <qtopia/alarmserver.h> |
29 | #include <qtopia/qcopenvelope_qws.h> | 29 | #include <qtopia/qcopenvelope_qws.h> |
30 | #include <unistd.h> // for sleep | 30 | #include <unistd.h> // for sleep |
31 | #else | 31 | #else |
32 | #include <qmenubar.h> | 32 | #include <qmenubar.h> |
33 | #include <qtoolbar.h> | 33 | #include <qtoolbar.h> |
34 | #include <qapplication.h> | 34 | #include <qapplication.h> |
35 | //#include <resource.h> | 35 | //#include <resource.h> |
36 | 36 | ||
37 | #endif | 37 | #endif |
38 | #include <libkcal/calendarlocal.h> | 38 | #include <libkcal/calendarlocal.h> |
39 | #include <libkcal/todo.h> | 39 | #include <libkcal/todo.h> |
40 | #include <libkcal/phoneformat.h> | 40 | #include <libkcal/phoneformat.h> |
41 | #include <libkdepim/ksyncprofile.h> | 41 | #include <libkdepim/ksyncprofile.h> |
42 | #include <libkdepim/phoneaccess.h> | 42 | #include <libkdepim/phoneaccess.h> |
43 | #include <libkcal/kincidenceformatter.h> | 43 | #include <libkcal/kincidenceformatter.h> |
44 | #include <libkdepim/kpimglobalprefs.h> | 44 | #include <libkdepim/kpimglobalprefs.h> |
45 | 45 | ||
46 | #include "calendarview.h" | 46 | #include "calendarview.h" |
47 | #include "koviewmanager.h" | 47 | #include "koviewmanager.h" |
48 | #include "datenavigator.h" | 48 | #include "datenavigator.h" |
49 | #include "koagendaview.h" | 49 | #include "koagendaview.h" |
50 | #include "koagenda.h" | 50 | #include "koagenda.h" |
51 | #include "kodialogmanager.h" | 51 | #include "kodialogmanager.h" |
52 | #include "kdialogbase.h" | 52 | #include "kdialogbase.h" |
53 | #include "kapplication.h" | 53 | #include "kapplication.h" |
54 | #include "kofilterview.h" | 54 | #include "kofilterview.h" |
55 | #include "kstandarddirs.h" | 55 | #include "kstandarddirs.h" |
56 | #include "koprefs.h" | 56 | #include "koprefs.h" |
57 | #include "kfiledialog.h" | 57 | #include "kfiledialog.h" |
58 | #include "koglobals.h" | 58 | #include "koglobals.h" |
59 | #include "kglobal.h" | 59 | #include "kglobal.h" |
60 | #include "klocale.h" | 60 | #include "klocale.h" |
61 | #include "kconfig.h" | 61 | #include "kconfig.h" |
62 | #include "simplealarmclient.h" | 62 | #include "simplealarmclient.h" |
63 | #include "externalapphandler.h" | 63 | #include "externalapphandler.h" |
64 | 64 | ||
65 | using namespace KCal; | 65 | using namespace KCal; |
66 | #ifndef _WIN32_ | 66 | #ifndef _WIN32_ |
67 | #include <unistd.h> | 67 | #include <unistd.h> |
68 | #else | 68 | #else |
69 | #include "koimportoldialog.h" | 69 | #include "koimportoldialog.h" |
70 | #endif | 70 | #endif |
71 | #include "mainwindow.h" | 71 | #include "mainwindow.h" |
72 | 72 | ||
73 | class KOex2phonePrefs : public QDialog | 73 | class KOex2phonePrefs : public QDialog |
74 | { | 74 | { |
75 | public: | 75 | public: |
76 | KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : | 76 | KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : |
77 | QDialog( parent, name, true ) | 77 | QDialog( parent, name, true ) |
78 | { | 78 | { |
79 | setCaption( i18n("Export to phone options") ); | 79 | setCaption( i18n("Export to phone options") ); |
80 | QVBoxLayout* lay = new QVBoxLayout( this ); | 80 | QVBoxLayout* lay = new QVBoxLayout( this ); |
81 | lay->setSpacing( 3 ); | 81 | lay->setSpacing( 3 ); |
82 | lay->setMargin( 3 ); | 82 | lay->setMargin( 3 ); |
83 | QLabel *lab; | 83 | QLabel *lab; |
84 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); | 84 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); |
85 | lab->setAlignment (AlignHCenter ); | 85 | lab->setAlignment (AlignHCenter ); |
86 | QHBox* temphb; | 86 | QHBox* temphb; |
87 | temphb = new QHBox( this ); | 87 | temphb = new QHBox( this ); |
88 | new QLabel( i18n("I/O device: "), temphb ); | 88 | new QLabel( i18n("I/O device: "), temphb ); |
89 | mPhoneDevice = new QLineEdit( temphb); | 89 | mPhoneDevice = new QLineEdit( temphb); |
90 | lay->addWidget( temphb ); | 90 | lay->addWidget( temphb ); |
91 | temphb = new QHBox( this ); | 91 | temphb = new QHBox( this ); |
92 | new QLabel( i18n("Connection: "), temphb ); | 92 | new QLabel( i18n("Connection: "), temphb ); |
93 | mPhoneConnection = new QLineEdit( temphb); | 93 | mPhoneConnection = new QLineEdit( temphb); |
94 | lay->addWidget( temphb ); | 94 | lay->addWidget( temphb ); |
95 | temphb = new QHBox( this ); | 95 | temphb = new QHBox( this ); |
96 | new QLabel( i18n("Model(opt.): "), temphb ); | 96 | new QLabel( i18n("Model(opt.): "), temphb ); |
97 | mPhoneModel = new QLineEdit( temphb); | 97 | mPhoneModel = new QLineEdit( temphb); |
98 | lay->addWidget( temphb ); | 98 | lay->addWidget( temphb ); |
99 | mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); | 99 | mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); |
100 | mWriteBackFuture->setChecked( true ); | 100 | mWriteBackFuture->setChecked( true ); |
101 | lay->addWidget( mWriteBackFuture ); | 101 | lay->addWidget( mWriteBackFuture ); |
102 | temphb = new QHBox( this ); | 102 | temphb = new QHBox( this ); |
103 | new QLabel( i18n("Max. weeks in future: ") , temphb ); | 103 | new QLabel( i18n("Max. weeks in future: ") , temphb ); |
104 | mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); | 104 | mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); |
105 | mWriteBackFutureWeeks->setValue( 8 ); | 105 | mWriteBackFutureWeeks->setValue( 8 ); |
106 | lay->addWidget( temphb ); | 106 | lay->addWidget( temphb ); |
107 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); | 107 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); |
108 | lab->setAlignment (AlignHCenter ); | 108 | lab->setAlignment (AlignHCenter ); |
109 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); | 109 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); |
110 | lay->addWidget( ok ); | 110 | lay->addWidget( ok ); |
111 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 111 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
112 | lay->addWidget( cancel ); | 112 | lay->addWidget( cancel ); |
113 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 113 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
114 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 114 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
115 | resize( 220, 240 ); | 115 | resize( 220, 240 ); |
116 | 116 | ||
117 | } | 117 | } |
118 | 118 | ||
119 | public: | 119 | public: |
120 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; | 120 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; |
121 | QCheckBox* mWriteBackFuture; | 121 | QCheckBox* mWriteBackFuture; |
122 | QSpinBox* mWriteBackFutureWeeks; | 122 | QSpinBox* mWriteBackFutureWeeks; |
123 | }; | 123 | }; |
124 | 124 | ||
125 | int globalFlagBlockStartup; | 125 | int globalFlagBlockStartup; |
126 | MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : | 126 | MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : |
127 | QMainWindow( parent, name ) | 127 | QMainWindow( parent, name ) |
128 | { | 128 | { |
129 | mPassWordPiSync = "abc"; | 129 | |
130 | #ifdef DESKTOP_VERSION | 130 | #ifdef DESKTOP_VERSION |
131 | setFont( QFont("Arial"), 14 ); | 131 | setFont( QFont("Arial"), 14 ); |
132 | #endif | 132 | #endif |
133 | mServerSocket = 0; | 133 | mServerSocket = 0; |
134 | mClosed = false; | 134 | mClosed = false; |
135 | //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; | 135 | //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; |
136 | QString confFile = locateLocal("config","korganizerrc"); | 136 | QString confFile = locateLocal("config","korganizerrc"); |
137 | QFileInfo finf ( confFile ); | 137 | QFileInfo finf ( confFile ); |
138 | bool showWarning = !finf.exists(); | 138 | bool showWarning = !finf.exists(); |
139 | setIcon(SmallIcon( "ko24" ) ); | 139 | setIcon(SmallIcon( "ko24" ) ); |
140 | mBlockAtStartup = true; | 140 | mBlockAtStartup = true; |
141 | mFlagKeyPressed = false; | 141 | mFlagKeyPressed = false; |
142 | setCaption("KOrganizer/Pi"); | 142 | setCaption("KOrganizer/Pi"); |
143 | KOPrefs *p = KOPrefs::instance(); | 143 | KOPrefs *p = KOPrefs::instance(); |
144 | KPimGlobalPrefs::instance()->setGlobalConfig(); | 144 | KPimGlobalPrefs::instance()->setGlobalConfig(); |
145 | // if ( QApplication::desktop()->height() > 480 ) { | ||
146 | // if ( p->mHourSize == 4 ) | ||
147 | // p->mHourSize = 6; | ||
148 | // } | ||
149 | if ( p->mHourSize > 18 ) | 145 | if ( p->mHourSize > 18 ) |
150 | p->mHourSize = 18; | 146 | p->mHourSize = 18; |
151 | QMainWindow::ToolBarDock tbd; | 147 | QMainWindow::ToolBarDock tbd; |
152 | if ( p->mToolBarHor ) { | 148 | if ( p->mToolBarHor ) { |
153 | if ( p->mToolBarUp ) | 149 | if ( p->mToolBarUp ) |
154 | tbd = Bottom; | 150 | tbd = Bottom; |
155 | else | 151 | else |
156 | tbd = Top; | 152 | tbd = Top; |
157 | } | 153 | } |
158 | else { | 154 | else { |
159 | if ( p->mToolBarUp ) | 155 | if ( p->mToolBarUp ) |
160 | tbd = Right; | 156 | tbd = Right; |
161 | else | 157 | else |
162 | tbd = Left; | 158 | tbd = Left; |
163 | } | 159 | } |
164 | if ( KOPrefs::instance()->mUseAppColors ) | 160 | if ( KOPrefs::instance()->mUseAppColors ) |
165 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 161 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
166 | globalFlagBlockStartup = 1; | 162 | globalFlagBlockStartup = 1; |
167 | iconToolBar = new QPEToolBar( this ); | 163 | iconToolBar = new QPEToolBar( this ); |
168 | addToolBar (iconToolBar , tbd ); | 164 | addToolBar (iconToolBar , tbd ); |
169 | mBlockSaveFlag = false; | ||
170 | mCalendarModifiedFlag = false; | 165 | mCalendarModifiedFlag = false; |
171 | 166 | ||
172 | QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); | 167 | QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); |
173 | splash->setAlignment ( AlignCenter ); | 168 | splash->setAlignment ( AlignCenter ); |
174 | setCentralWidget( splash ); | 169 | setCentralWidget( splash ); |
175 | #ifndef DESKTOP_VERSION | 170 | #ifndef DESKTOP_VERSION |
176 | showMaximized(); | 171 | showMaximized(); |
177 | #endif | 172 | #endif |
178 | //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); | 173 | //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); |
179 | setDefaultPreferences(); | 174 | setDefaultPreferences(); |
180 | mCalendar = new CalendarLocal(); | 175 | mCalendar = new CalendarLocal(); |
181 | mView = new CalendarView( mCalendar, this,"mCalendar " ); | 176 | mView = new CalendarView( mCalendar, this,"mCalendar " ); |
182 | mView->hide(); | 177 | mView->hide(); |
183 | //mView->resize(splash->size() ); | 178 | //mView->resize(splash->size() ); |
184 | initActions(); | 179 | initActions(); |
180 | mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); | ||
181 | mSyncManager->setBlockSave(false); | ||
182 | mView->setSyncManager(mSyncManager); | ||
185 | #ifndef DESKTOP_VERSION | 183 | #ifndef DESKTOP_VERSION |
186 | iconToolBar->show(); | 184 | iconToolBar->show(); |
187 | qApp->processEvents(); | 185 | qApp->processEvents(); |
188 | #endif | 186 | #endif |
189 | //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); | 187 | //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); |
190 | int vh = height() ; | 188 | int vh = height() ; |
191 | int vw = width(); | 189 | int vw = width(); |
192 | //qDebug("Toolbar hei %d ",iconToolBar->height() ); | 190 | //qDebug("Toolbar hei %d ",iconToolBar->height() ); |
193 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { | 191 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { |
194 | vh -= iconToolBar->height(); | 192 | vh -= iconToolBar->height(); |
195 | } else { | 193 | } else { |
196 | vw -= iconToolBar->height(); | 194 | vw -= iconToolBar->height(); |
197 | } | 195 | } |
198 | //mView->setMaximumSize( splash->size() ); | 196 | //mView->setMaximumSize( splash->size() ); |
199 | //mView->resize( splash->size() ); | 197 | //mView->resize( splash->size() ); |
200 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); | 198 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); |
201 | mView->readSettings(); | 199 | mView->readSettings(); |
202 | bool newFile = false; | 200 | bool newFile = false; |
203 | if( !QFile::exists( defaultFileName() ) ) { | 201 | if( !QFile::exists( defaultFileName() ) ) { |
204 | QFileInfo finfo ( defaultFileName() ); | 202 | QFileInfo finfo ( defaultFileName() ); |
205 | QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); | 203 | QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); |
206 | qDebug("oldfile %s ", oldFile.latin1()); | 204 | qDebug("oldfile %s ", oldFile.latin1()); |
207 | QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; | 205 | QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; |
208 | finfo.setFile( oldFile ); | 206 | finfo.setFile( oldFile ); |
209 | if (finfo.exists() ) { | 207 | if (finfo.exists() ) { |
210 | KMessageBox::information( this, message); | 208 | KMessageBox::information( this, message); |
211 | mView->openCalendar( oldFile ); | 209 | mView->openCalendar( oldFile ); |
212 | qApp->processEvents(); | 210 | qApp->processEvents(); |
213 | } else { | 211 | } else { |
214 | oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); | 212 | oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); |
215 | finfo.setFile( oldFile ); | 213 | finfo.setFile( oldFile ); |
216 | if (finfo.exists() ) { | 214 | if (finfo.exists() ) { |
217 | KMessageBox::information( this, message); | 215 | KMessageBox::information( this, message); |
218 | mView->openCalendar( oldFile ); | 216 | mView->openCalendar( oldFile ); |
219 | qApp->processEvents(); | 217 | qApp->processEvents(); |
220 | } | 218 | } |
221 | } | 219 | } |
222 | mView->saveCalendar( defaultFileName() ); | 220 | mView->saveCalendar( defaultFileName() ); |
223 | newFile = true; | 221 | newFile = true; |
224 | } | 222 | } |
225 | 223 | ||
226 | QTime neededSaveTime = QDateTime::currentDateTime().time(); | 224 | QTime neededSaveTime = QDateTime::currentDateTime().time(); |
227 | mView->openCalendar( defaultFileName() ); | 225 | mView->openCalendar( defaultFileName() ); |
228 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | 226 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); |
229 | qDebug("KO: Calendar loading time: %d ms",msNeeded ); | 227 | qDebug("KO: Calendar loading time: %d ms",msNeeded ); |
230 | 228 | ||
231 | if ( KOPrefs::instance()->mLanguageChanged ) { | 229 | if ( KOPrefs::instance()->mLanguageChanged ) { |
232 | KOPrefs::instance()->setCategoryDefaults(); | 230 | KOPrefs::instance()->setCategoryDefaults(); |
233 | int count = mView->addCategories(); | 231 | int count = mView->addCategories(); |
234 | KOPrefs::instance()->mLanguageChanged = false; | 232 | KOPrefs::instance()->mLanguageChanged = false; |
235 | } | 233 | } |
236 | processIncidenceSelection( 0 ); | 234 | processIncidenceSelection( 0 ); |
237 | connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), | 235 | connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), |
238 | SLOT( processIncidenceSelection( Incidence * ) ) ); | 236 | SLOT( processIncidenceSelection( Incidence * ) ) ); |
239 | connect( mView, SIGNAL( modifiedChanged( bool ) ), | 237 | connect( mView, SIGNAL( modifiedChanged( bool ) ), |
240 | SLOT( slotModifiedChanged( bool ) ) ); | 238 | SLOT( slotModifiedChanged( bool ) ) ); |
241 | 239 | ||
242 | 240 | ||
243 | connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); | 241 | connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); |
244 | mView->setModified( false ); | 242 | mView->setModified( false ); |
245 | mBlockAtStartup = false; | 243 | mBlockAtStartup = false; |
246 | mView->setModified( false ); | 244 | mView->setModified( false ); |
247 | setCentralWidget( mView ); | 245 | setCentralWidget( mView ); |
248 | globalFlagBlockStartup = 0; | 246 | globalFlagBlockStartup = 0; |
249 | mView->show(); | 247 | mView->show(); |
250 | delete splash; | 248 | delete splash; |
251 | if ( newFile ) | 249 | if ( newFile ) |
252 | mView->updateConfig(); | 250 | mView->updateConfig(); |
253 | // qApp->processEvents(); | 251 | // qApp->processEvents(); |
254 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); | 252 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); |
255 | fillSyncMenu(); | 253 | //fillSyncMenu(); |
254 | |||
255 | |||
256 | connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); | ||
257 | connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); | ||
258 | connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); | ||
259 | mSyncManager->setDefaultFileName( defaultFileName()); | ||
260 | mSyncManager->fillSyncMenu(); | ||
261 | |||
262 | |||
263 | |||
256 | mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); | 264 | mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); |
257 | if ( showWarning ) { | 265 | if ( showWarning ) { |
258 | KMessageBox::information( this, | 266 | KMessageBox::information( this, |
259 | "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); | 267 | "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); |
260 | qApp->processEvents(); | 268 | qApp->processEvents(); |
261 | mView->dialogManager()->showSyncOptions(); | 269 | mView->dialogManager()->showSyncOptions(); |
262 | } | 270 | } |
263 | 271 | ||
264 | //US listen for result adressed from Ka/Pi | 272 | //US listen for result adressed from Ka/Pi |
265 | #ifndef DESKTOP_VERSION | 273 | #ifndef DESKTOP_VERSION |
266 | connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); | 274 | connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); |
267 | #endif | 275 | #endif |
268 | } | 276 | } |
269 | MainWindow::~MainWindow() | 277 | MainWindow::~MainWindow() |
270 | { | 278 | { |
271 | //qDebug("MainWindow::~MainWindow() "); | 279 | //qDebug("MainWindow::~MainWindow() "); |
272 | //save toolbar location | 280 | //save toolbar location |
273 | delete mServerSocket; | 281 | delete mServerSocket; |
274 | delete mCalendar; | 282 | delete mCalendar; |
275 | delete KOPrefs::instance(); | 283 | delete KOPrefs::instance(); |
276 | delete KIncidenceFormatter::instance(); | 284 | delete KIncidenceFormatter::instance(); |
277 | 285 | ||
278 | 286 | ||
279 | } | 287 | } |
280 | void MainWindow::showMaximized () | 288 | void MainWindow::showMaximized () |
281 | { | 289 | { |
282 | #ifndef DESKTOP_VERSION | 290 | #ifndef DESKTOP_VERSION |
283 | if ( ! globalFlagBlockStartup ) | 291 | if ( ! globalFlagBlockStartup ) |
284 | if ( mClosed ) | 292 | if ( mClosed ) |
285 | mView->goToday(); | 293 | mView->goToday(); |
286 | #endif | 294 | #endif |
287 | QWidget::showMaximized () ; | 295 | QWidget::showMaximized () ; |
288 | mClosed = false; | 296 | mClosed = false; |
289 | } | 297 | } |
290 | void MainWindow::closeEvent( QCloseEvent* ce ) | 298 | void MainWindow::closeEvent( QCloseEvent* ce ) |
291 | { | 299 | { |
292 | 300 | ||
293 | 301 | ||
294 | 302 | ||
295 | if ( ! KOPrefs::instance()->mAskForQuit ) { | 303 | if ( ! KOPrefs::instance()->mAskForQuit ) { |
296 | saveOnClose(); | 304 | saveOnClose(); |
297 | mClosed = true; | 305 | mClosed = true; |
298 | ce->accept(); | 306 | ce->accept(); |
299 | return; | 307 | return; |
300 | 308 | ||
301 | } | 309 | } |
302 | 310 | ||
303 | switch( QMessageBox::information( this, "KO/Pi", | 311 | switch( QMessageBox::information( this, "KO/Pi", |
304 | i18n("Do you really want\nto close KO/Pi?"), | 312 | i18n("Do you really want\nto close KO/Pi?"), |
305 | i18n("Close"), i18n("No"), | 313 | i18n("Close"), i18n("No"), |
306 | 0, 0 ) ) { | 314 | 0, 0 ) ) { |
307 | case 0: | 315 | case 0: |
308 | saveOnClose(); | 316 | saveOnClose(); |
309 | mClosed = true; | 317 | mClosed = true; |
310 | ce->accept(); | 318 | ce->accept(); |
311 | break; | 319 | break; |
312 | case 1: | 320 | case 1: |
313 | ce->ignore(); | 321 | ce->ignore(); |
314 | break; | 322 | break; |
315 | case 2: | 323 | case 2: |
316 | 324 | ||
317 | default: | 325 | default: |
318 | break; | 326 | break; |
319 | } | 327 | } |
320 | 328 | ||
321 | 329 | ||
322 | } | 330 | } |
323 | 331 | ||
324 | void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) | 332 | void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) |
325 | { | 333 | { |
326 | QDataStream stream( data, IO_ReadOnly ); | 334 | QDataStream stream( data, IO_ReadOnly ); |
327 | // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); | 335 | // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); |
328 | //QString datamess; | 336 | //QString datamess; |
329 | //qDebug("message "); | 337 | //qDebug("message "); |
330 | qDebug("KO: QCOP message received: %s ", cmsg.data() ); | 338 | qDebug("KO: QCOP message received: %s ", cmsg.data() ); |
331 | 339 | ||
332 | if ( cmsg == "-writeFile" ) { | 340 | if ( cmsg == "-writeFile" ) { |
333 | // I made from the "-writeFile" an "-writeAlarm" | 341 | // I made from the "-writeFile" an "-writeAlarm" |
334 | mView->viewManager()->showWhatsNextView(); | 342 | mView->viewManager()->showWhatsNextView(); |
335 | mCalendar->checkAlarmForIncidence( 0, true); | 343 | mCalendar->checkAlarmForIncidence( 0, true); |
336 | showMaximized(); | 344 | showMaximized(); |
337 | raise(); | 345 | raise(); |
338 | return; | 346 | return; |
339 | } | 347 | } |
340 | 348 | ||
341 | if ( cmsg == "-writeFile" ) { | 349 | if ( cmsg == "-writeFile" ) { |
342 | // I made from the "-writeFile" an "-writeAlarm" | 350 | // I made from the "-writeFile" an "-writeAlarm" |
343 | mView->viewManager()->showWhatsNextView(); | 351 | mView->viewManager()->showWhatsNextView(); |
344 | mCalendar->checkAlarmForIncidence( 0, true); | 352 | mCalendar->checkAlarmForIncidence( 0, true); |
345 | showMaximized(); | 353 | showMaximized(); |
346 | raise(); | 354 | raise(); |
347 | return; | 355 | return; |
348 | 356 | ||
349 | } | 357 | } |
350 | if ( cmsg == "-writeFileSilent" ) { | 358 | if ( cmsg == "-writeFileSilent" ) { |
351 | // I made from the "-writeFile" an "-writeAlarm" | 359 | // I made from the "-writeFile" an "-writeAlarm" |
352 | // mView->viewManager()->showWhatsNextView(); | 360 | // mView->viewManager()->showWhatsNextView(); |
353 | mCalendar->checkAlarmForIncidence( 0, true); | 361 | mCalendar->checkAlarmForIncidence( 0, true); |
354 | //showMaximized(); | 362 | //showMaximized(); |
355 | //raise(); | 363 | //raise(); |
356 | hide(); | 364 | hide(); |
357 | return; | 365 | return; |
358 | } | 366 | } |
359 | if ( cmsg == "-newCountdown" ) { | 367 | if ( cmsg == "-newCountdown" ) { |
360 | qDebug("newCountdown "); | 368 | qDebug("newCountdown "); |
361 | 369 | ||
362 | } | 370 | } |
363 | QString msg ; | 371 | QString msg ; |
364 | QString allmsg = cmsg; | 372 | QString allmsg = cmsg; |
365 | while ( allmsg.length() > 0 ) { | 373 | while ( allmsg.length() > 0 ) { |
366 | int nextC = allmsg.find( "-", 1 ); | 374 | int nextC = allmsg.find( "-", 1 ); |
367 | if ( nextC == -1 ) { | 375 | if ( nextC == -1 ) { |
368 | msg = allmsg; | 376 | msg = allmsg; |
369 | allmsg = ""; | 377 | allmsg = ""; |
370 | } else{ | 378 | } else{ |
371 | msg = allmsg.left( nextC ); | 379 | msg = allmsg.left( nextC ); |
372 | allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); | 380 | allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); |
373 | } | 381 | } |
374 | //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); | 382 | //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); |
375 | if ( msg == "-newEvent" ) { | 383 | if ( msg == "-newEvent" ) { |
376 | mView->newEvent(); | 384 | mView->newEvent(); |
377 | } | 385 | } |
378 | if ( msg == "-newTodo" ) { | 386 | if ( msg == "-newTodo" ) { |
379 | mView->newTodo(); | 387 | mView->newTodo(); |
380 | 388 | ||
381 | } | 389 | } |
382 | if ( msg == "-showWN" ) { | 390 | if ( msg == "-showWN" ) { |
383 | mView->viewManager()->showWhatsNextView(); | 391 | mView->viewManager()->showWhatsNextView(); |
384 | } | 392 | } |
385 | if ( msg == "-showTodo" ) { | 393 | if ( msg == "-showTodo" ) { |
386 | mView->viewManager()->showTodoView(); | 394 | mView->viewManager()->showTodoView(); |
387 | } | 395 | } |
388 | if ( msg == "-showList" ) { | 396 | if ( msg == "-showList" ) { |
389 | mView->viewManager()->showListView(); | 397 | mView->viewManager()->showListView(); |
390 | } | 398 | } |
391 | else if ( msg == "-showDay" ) { | 399 | else if ( msg == "-showDay" ) { |
392 | mView->viewManager()->showDayView(); | 400 | mView->viewManager()->showDayView(); |
393 | } | 401 | } |
394 | else if ( msg == "-showWWeek" ) { | 402 | else if ( msg == "-showWWeek" ) { |
395 | mView->viewManager()->showWorkWeekView(); | 403 | mView->viewManager()->showWorkWeekView(); |
396 | } | 404 | } |
397 | else if ( msg == "-ringSync" ) { | 405 | else if ( msg == "-ringSync" ) { |
398 | multiSync( false ); | 406 | mSyncManager->multiSync( false ); |
399 | } | 407 | } |
400 | else if ( msg == "-showWeek" ) { | 408 | else if ( msg == "-showWeek" ) { |
401 | mView->viewManager()->showWeekView(); | 409 | mView->viewManager()->showWeekView(); |
402 | } | 410 | } |
403 | else if ( msg == "-showTodo" ) { | 411 | else if ( msg == "-showTodo" ) { |
404 | mView->viewManager()->showTodoView(); | 412 | mView->viewManager()->showTodoView(); |
405 | } | 413 | } |
406 | else if ( msg == "-showJournal" ) { | 414 | else if ( msg == "-showJournal" ) { |
407 | mView->dateNavigator()->selectDates( 1 ); | 415 | mView->dateNavigator()->selectDates( 1 ); |
408 | mView->dateNavigator()->selectToday(); | 416 | mView->dateNavigator()->selectToday(); |
409 | mView->viewManager()->showJournalView(); | 417 | mView->viewManager()->showJournalView(); |
410 | } | 418 | } |
411 | else if ( msg == "-showKO" ) { | 419 | else if ( msg == "-showKO" ) { |
412 | mView->viewManager()->showNextXView(); | 420 | mView->viewManager()->showNextXView(); |
413 | } | 421 | } |
414 | else if ( msg == "-showWNext" || msg == "nextView()" ) { | 422 | else if ( msg == "-showWNext" || msg == "nextView()" ) { |
415 | mView->viewManager()->showWhatsNextView(); | 423 | mView->viewManager()->showWhatsNextView(); |
416 | } | 424 | } |
417 | else if ( msg == "-showNextXView" ) { | 425 | else if ( msg == "-showNextXView" ) { |
418 | mView->viewManager()->showNextXView(); | 426 | mView->viewManager()->showNextXView(); |
419 | } | 427 | } |
420 | 428 | ||
421 | 429 | ||
422 | } | 430 | } |
423 | 431 | ||
424 | showMaximized(); | 432 | showMaximized(); |
425 | raise(); | 433 | raise(); |
426 | } | 434 | } |
427 | 435 | ||
428 | QPixmap MainWindow::loadPixmap( QString name ) | 436 | QPixmap MainWindow::loadPixmap( QString name ) |
429 | { | 437 | { |
430 | return SmallIcon( name ); | 438 | return SmallIcon( name ); |
431 | 439 | ||
432 | } | 440 | } |
433 | void MainWindow::initActions() | 441 | void MainWindow::initActions() |
434 | { | 442 | { |
435 | //KOPrefs::instance()->mShowFullMenu | 443 | //KOPrefs::instance()->mShowFullMenu |
436 | iconToolBar->clear(); | 444 | iconToolBar->clear(); |
437 | KOPrefs *p = KOPrefs::instance(); | 445 | KOPrefs *p = KOPrefs::instance(); |
438 | //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); | 446 | //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); |
439 | 447 | ||
440 | QPopupMenu *viewMenu = new QPopupMenu( this ); | 448 | QPopupMenu *viewMenu = new QPopupMenu( this ); |
441 | QPopupMenu *actionMenu = new QPopupMenu( this ); | 449 | QPopupMenu *actionMenu = new QPopupMenu( this ); |
442 | QPopupMenu *importMenu = new QPopupMenu( this ); | 450 | QPopupMenu *importMenu = new QPopupMenu( this ); |
443 | selectFilterMenu = new QPopupMenu( this ); | 451 | selectFilterMenu = new QPopupMenu( this ); |
444 | selectFilterMenu->setCheckable( true ); | 452 | selectFilterMenu->setCheckable( true ); |
445 | syncMenu = new QPopupMenu( this ); | 453 | syncMenu = new QPopupMenu( this ); |
446 | configureAgendaMenu = new QPopupMenu( this ); | 454 | configureAgendaMenu = new QPopupMenu( this ); |
447 | configureToolBarMenu = new QPopupMenu( this ); | 455 | configureToolBarMenu = new QPopupMenu( this ); |
448 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 456 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
449 | if ( KOPrefs::instance()->mShowFullMenu ) { | 457 | if ( KOPrefs::instance()->mShowFullMenu ) { |
450 | QMenuBar *menuBar1; | 458 | QMenuBar *menuBar1; |
451 | menuBar1 = menuBar(); | 459 | menuBar1 = menuBar(); |
452 | menuBar1->insertItem( i18n("File"), importMenu ); | 460 | menuBar1->insertItem( i18n("File"), importMenu ); |
453 | menuBar1->insertItem( i18n("View"), viewMenu ); | 461 | menuBar1->insertItem( i18n("View"), viewMenu ); |
454 | menuBar1->insertItem( i18n("Actions"), actionMenu ); | 462 | menuBar1->insertItem( i18n("Actions"), actionMenu ); |
455 | menuBar1->insertItem( i18n("Synchronize"), syncMenu ); | 463 | menuBar1->insertItem( i18n("Synchronize"), syncMenu ); |
456 | menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); | 464 | menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); |
457 | //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); | 465 | //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); |
458 | menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); | 466 | menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); |
459 | menuBar1->insertItem( i18n("Help"), helpMenu ); | 467 | menuBar1->insertItem( i18n("Help"), helpMenu ); |
460 | } else { | 468 | } else { |
461 | QPEMenuBar *menuBar1; | 469 | QPEMenuBar *menuBar1; |
462 | menuBar1 = new QPEMenuBar( iconToolBar ); | 470 | menuBar1 = new QPEMenuBar( iconToolBar ); |
463 | QPopupMenu *menuBar = new QPopupMenu( this ); | 471 | QPopupMenu *menuBar = new QPopupMenu( this ); |
464 | menuBar1->insertItem( i18n("ME"), menuBar); | 472 | menuBar1->insertItem( i18n("ME"), menuBar); |
465 | menuBar->insertItem( i18n("File"), importMenu ); | 473 | menuBar->insertItem( i18n("File"), importMenu ); |
466 | menuBar->insertItem( i18n("View"), viewMenu ); | 474 | menuBar->insertItem( i18n("View"), viewMenu ); |
467 | menuBar->insertItem( i18n("Actions"), actionMenu ); | 475 | menuBar->insertItem( i18n("Actions"), actionMenu ); |
468 | menuBar->insertItem( i18n("Synchronize"), syncMenu ); | 476 | menuBar->insertItem( i18n("Synchronize"), syncMenu ); |
469 | menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); | 477 | menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); |
470 | menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); | 478 | menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); |
471 | menuBar->insertItem( i18n("Filter"),selectFilterMenu ); | 479 | menuBar->insertItem( i18n("Filter"),selectFilterMenu ); |
472 | menuBar->insertItem( i18n("Help"), helpMenu ); | 480 | menuBar->insertItem( i18n("Help"), helpMenu ); |
473 | //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); | 481 | //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); |
474 | menuBar1->setMaximumSize( menuBar1->sizeHint( )); | 482 | menuBar1->setMaximumSize( menuBar1->sizeHint( )); |
475 | } | 483 | } |
476 | connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) ); | 484 | connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) ); |
477 | connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); | 485 | connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); |
478 | connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) ); | 486 | connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) ); |
479 | 487 | ||
480 | // ****************** | 488 | // ****************** |
481 | QAction *action; | 489 | QAction *action; |
482 | QIconSet icon; | 490 | QIconSet icon; |
483 | // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); | 491 | // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); |
484 | configureToolBarMenu->setCheckable( true ); | 492 | configureToolBarMenu->setCheckable( true ); |
485 | 493 | ||
486 | QString pathString = ""; | 494 | QString pathString = ""; |
487 | if ( !p->mToolBarMiniIcons ) { | 495 | if ( !p->mToolBarMiniIcons ) { |
488 | if ( QApplication::desktop()->width() < 480 ) | 496 | if ( QApplication::desktop()->width() < 480 ) |
489 | pathString += "icons16/"; | 497 | pathString += "icons16/"; |
490 | } else | 498 | } else |
491 | pathString += "iconsmini/"; | 499 | pathString += "iconsmini/"; |
492 | configureAgendaMenu->setCheckable( true ); | 500 | configureAgendaMenu->setCheckable( true ); |
493 | configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 ); | 501 | configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 ); |
494 | configureAgendaMenu->insertSeparator(); | 502 | configureAgendaMenu->insertSeparator(); |
495 | configureAgendaMenu->insertItem(i18n("Tiny"), 4 ); | 503 | configureAgendaMenu->insertItem(i18n("Tiny"), 4 ); |
496 | configureAgendaMenu->insertItem(i18n("Small"), 6 ); | 504 | configureAgendaMenu->insertItem(i18n("Small"), 6 ); |
497 | configureAgendaMenu->insertItem(i18n("Medium"), 8 ); | 505 | configureAgendaMenu->insertItem(i18n("Medium"), 8 ); |
498 | configureAgendaMenu->insertItem(i18n("Normal"), 10 ); | 506 | configureAgendaMenu->insertItem(i18n("Normal"), 10 ); |
499 | configureAgendaMenu->insertItem(i18n("Large"), 12 ); | 507 | configureAgendaMenu->insertItem(i18n("Large"), 12 ); |
500 | configureAgendaMenu->insertItem(i18n("Big"), 14 ); | 508 | configureAgendaMenu->insertItem(i18n("Big"), 14 ); |
501 | configureAgendaMenu->insertItem(i18n("Bigger"), 16 ); | 509 | configureAgendaMenu->insertItem(i18n("Bigger"), 16 ); |
502 | configureAgendaMenu->insertItem(i18n("Biggest"), 18 ); | 510 | configureAgendaMenu->insertItem(i18n("Biggest"), 18 ); |
503 | //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); | 511 | //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); |
504 | 512 | ||
505 | icon = loadPixmap( pathString + "configure" ); | 513 | icon = loadPixmap( pathString + "configure" ); |
506 | action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); | 514 | action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); |
507 | action->addTo( actionMenu ); | 515 | action->addTo( actionMenu ); |
508 | connect( action, SIGNAL( activated() ), | 516 | connect( action, SIGNAL( activated() ), |
509 | mView, SLOT( edit_options() ) ); | 517 | mView, SLOT( edit_options() ) ); |
510 | actionMenu->insertSeparator(); | 518 | actionMenu->insertSeparator(); |
511 | icon = loadPixmap( pathString + "newevent" ); | 519 | icon = loadPixmap( pathString + "newevent" ); |
512 | configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); | 520 | configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); |
513 | configureToolBarMenu->insertSeparator(); | 521 | configureToolBarMenu->insertSeparator(); |
514 | configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); | 522 | configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); |
515 | QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); | 523 | QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); |
516 | ne_action->addTo( actionMenu ); | 524 | ne_action->addTo( actionMenu ); |
517 | connect( ne_action, SIGNAL( activated() ), | 525 | connect( ne_action, SIGNAL( activated() ), |
518 | mView, SLOT( newEvent() ) ); | 526 | mView, SLOT( newEvent() ) ); |
519 | icon = loadPixmap( pathString + "newtodo" ); | 527 | icon = loadPixmap( pathString + "newtodo" ); |
520 | configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); | 528 | configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); |
521 | QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); | 529 | QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); |
522 | nt_action->addTo( actionMenu ); | 530 | nt_action->addTo( actionMenu ); |
523 | connect( nt_action, SIGNAL( activated() ), | 531 | connect( nt_action, SIGNAL( activated() ), |
524 | mView, SLOT( newTodo() ) ); | 532 | mView, SLOT( newTodo() ) ); |
525 | icon = loadPixmap( pathString + "navi" ); | 533 | icon = loadPixmap( pathString + "navi" ); |
526 | action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); | 534 | action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); |
527 | action->addTo( viewMenu ); | 535 | action->addTo( viewMenu ); |
528 | connect( action, SIGNAL( activated() ), | 536 | connect( action, SIGNAL( activated() ), |
529 | mView, SLOT( toggleDateNavigatorWidget() ) ); | 537 | mView, SLOT( toggleDateNavigatorWidget() ) ); |
530 | icon = loadPixmap( pathString + "filter" ); | 538 | icon = loadPixmap( pathString + "filter" ); |
531 | action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); | 539 | action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); |
532 | action->addTo( viewMenu ); | 540 | action->addTo( viewMenu ); |
533 | connect( action, SIGNAL( activated() ), | 541 | connect( action, SIGNAL( activated() ), |
534 | mView, SLOT( toggleFilter() ) ); | 542 | mView, SLOT( toggleFilter() ) ); |
535 | 543 | ||
536 | 544 | ||
537 | viewMenu->insertSeparator(); | 545 | viewMenu->insertSeparator(); |
538 | icon = loadPixmap( pathString + "picker" ); | 546 | icon = loadPixmap( pathString + "picker" ); |
539 | action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); | 547 | action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); |
540 | action->addTo( viewMenu ); | 548 | action->addTo( viewMenu ); |
541 | connect( action, SIGNAL( activated() ), | 549 | connect( action, SIGNAL( activated() ), |
542 | mView, SLOT( showDatePicker() ) ); | 550 | mView, SLOT( showDatePicker() ) ); |
543 | action->addTo( iconToolBar ); | 551 | action->addTo( iconToolBar ); |
544 | viewMenu->insertSeparator(); | 552 | viewMenu->insertSeparator(); |
545 | icon = loadPixmap( pathString + "list" ); | 553 | icon = loadPixmap( pathString + "list" ); |
546 | configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); | 554 | configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); |
547 | QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); | 555 | QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); |
548 | showlist_action->addTo( viewMenu ); | 556 | showlist_action->addTo( viewMenu ); |
549 | connect( showlist_action, SIGNAL( activated() ), | 557 | connect( showlist_action, SIGNAL( activated() ), |
550 | mView->viewManager(), SLOT( showListView() ) ); | 558 | mView->viewManager(), SLOT( showListView() ) ); |
551 | 559 | ||
552 | 560 | ||
553 | icon = loadPixmap( pathString + "day" ); | 561 | icon = loadPixmap( pathString + "day" ); |
554 | configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); | 562 | configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); |
555 | QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); | 563 | QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); |
556 | day1_action->addTo( viewMenu ); | 564 | day1_action->addTo( viewMenu ); |
557 | // action->addTo( toolBar ); | 565 | // action->addTo( toolBar ); |
558 | connect( day1_action, SIGNAL( activated() ), | 566 | connect( day1_action, SIGNAL( activated() ), |
559 | mView->viewManager(), SLOT( showDayView() ) ); | 567 | mView->viewManager(), SLOT( showDayView() ) ); |
560 | 568 | ||
561 | icon = loadPixmap( pathString + "workweek" ); | 569 | icon = loadPixmap( pathString + "workweek" ); |
562 | configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); | 570 | configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); |
563 | QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); | 571 | QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); |
564 | day5_action->addTo( viewMenu ); | 572 | day5_action->addTo( viewMenu ); |
565 | connect( day5_action, SIGNAL( activated() ), | 573 | connect( day5_action, SIGNAL( activated() ), |
566 | mView->viewManager(), SLOT( showWorkWeekView() ) ); | 574 | mView->viewManager(), SLOT( showWorkWeekView() ) ); |
567 | 575 | ||
568 | icon = loadPixmap( pathString + "week" ); | 576 | icon = loadPixmap( pathString + "week" ); |
569 | configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); | 577 | configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); |
570 | QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); | 578 | QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); |
571 | day7_action->addTo( viewMenu ); | 579 | day7_action->addTo( viewMenu ); |
572 | connect( day7_action, SIGNAL( activated() ), | 580 | connect( day7_action, SIGNAL( activated() ), |
573 | mView->viewManager(), SLOT( showWeekView() ) ); | 581 | mView->viewManager(), SLOT( showWeekView() ) ); |
574 | 582 | ||
575 | icon = loadPixmap( pathString + "month" ); | 583 | icon = loadPixmap( pathString + "month" ); |
576 | configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); | 584 | configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); |
577 | QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); | 585 | QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); |
578 | month_action->addTo( viewMenu ); | 586 | month_action->addTo( viewMenu ); |
579 | connect( month_action, SIGNAL( activated() ), | 587 | connect( month_action, SIGNAL( activated() ), |
580 | mView->viewManager(), SLOT( showMonthView() ) ); | 588 | mView->viewManager(), SLOT( showMonthView() ) ); |
581 | 589 | ||
582 | icon = loadPixmap( pathString + "todo" ); | 590 | icon = loadPixmap( pathString + "todo" ); |
583 | configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); | 591 | configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); |
584 | QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); | 592 | QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); |
585 | todoview_action->addTo( viewMenu ); | 593 | todoview_action->addTo( viewMenu ); |
586 | connect( todoview_action, SIGNAL( activated() ), | 594 | connect( todoview_action, SIGNAL( activated() ), |
587 | mView->viewManager(), SLOT( showTodoView() ) ); | 595 | mView->viewManager(), SLOT( showTodoView() ) ); |
588 | 596 | ||
589 | icon = loadPixmap( pathString + "journal" ); | 597 | icon = loadPixmap( pathString + "journal" ); |
590 | configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); | 598 | configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); |
591 | QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); | 599 | QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); |
592 | viewjournal_action->addTo( viewMenu ); | 600 | viewjournal_action->addTo( viewMenu ); |
593 | connect( viewjournal_action, SIGNAL( activated() ), | 601 | connect( viewjournal_action, SIGNAL( activated() ), |
594 | mView->viewManager(), SLOT( showJournalView() ) ); | 602 | mView->viewManager(), SLOT( showJournalView() ) ); |
595 | 603 | ||
596 | icon = loadPixmap( pathString + "xdays" ); | 604 | icon = loadPixmap( pathString + "xdays" ); |
597 | configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 ); | 605 | configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 ); |
598 | QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); | 606 | QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); |
599 | xdays_action->addTo( viewMenu ); | 607 | xdays_action->addTo( viewMenu ); |
600 | connect( xdays_action, SIGNAL( activated() ), | 608 | connect( xdays_action, SIGNAL( activated() ), |
601 | mView->viewManager(), SLOT( showNextXView() ) ); | 609 | mView->viewManager(), SLOT( showNextXView() ) ); |
602 | 610 | ||
603 | icon = loadPixmap( pathString + "whatsnext" ); | 611 | icon = loadPixmap( pathString + "whatsnext" ); |
604 | configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 ); | 612 | configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 ); |
605 | QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); | 613 | QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); |
606 | whatsnext_action->addTo( viewMenu ); | 614 | whatsnext_action->addTo( viewMenu ); |
607 | connect( whatsnext_action, SIGNAL( activated() ), | 615 | connect( whatsnext_action, SIGNAL( activated() ), |
608 | mView->viewManager(), SLOT( showWhatsNextView() ) ); | 616 | mView->viewManager(), SLOT( showWhatsNextView() ) ); |
609 | 617 | ||
610 | #if 0 | 618 | #if 0 |
611 | action = new QAction( "view_timespan", "Time Span", 0, this ); | 619 | action = new QAction( "view_timespan", "Time Span", 0, this ); |
612 | action->addTo( viewMenu ); | 620 | action->addTo( viewMenu ); |
613 | connect( action, SIGNAL( activated() ), | 621 | connect( action, SIGNAL( activated() ), |
614 | mView->viewManager(), SLOT( showTimeSpanView() ) ); | 622 | mView->viewManager(), SLOT( showTimeSpanView() ) ); |
615 | #endif | 623 | #endif |
616 | 624 | ||
617 | mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, | 625 | mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, |
618 | this ); | 626 | this ); |
619 | mNewSubTodoAction->addTo( actionMenu ); | 627 | mNewSubTodoAction->addTo( actionMenu ); |
620 | connect( mNewSubTodoAction, SIGNAL( activated() ), | 628 | connect( mNewSubTodoAction, SIGNAL( activated() ), |
621 | mView, SLOT( newSubTodo() ) ); | 629 | mView, SLOT( newSubTodo() ) ); |
622 | 630 | ||
623 | actionMenu->insertSeparator(); | 631 | actionMenu->insertSeparator(); |
624 | 632 | ||
625 | mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); | 633 | mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); |
626 | mShowAction->addTo( actionMenu ); | 634 | mShowAction->addTo( actionMenu ); |
627 | connect( mShowAction, SIGNAL( activated() ), | 635 | connect( mShowAction, SIGNAL( activated() ), |
628 | mView, SLOT( showIncidence() ) ); | 636 | mView, SLOT( showIncidence() ) ); |
629 | 637 | ||
630 | mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); | 638 | mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); |
631 | mEditAction->addTo( actionMenu ); | 639 | mEditAction->addTo( actionMenu ); |
632 | connect( mEditAction, SIGNAL( activated() ), | 640 | connect( mEditAction, SIGNAL( activated() ), |
633 | mView, SLOT( editIncidence() ) ); | 641 | mView, SLOT( editIncidence() ) ); |
634 | 642 | ||
635 | mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); | 643 | mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); |
636 | mDeleteAction->addTo( actionMenu ); | 644 | mDeleteAction->addTo( actionMenu ); |
637 | connect( mDeleteAction, SIGNAL( activated() ), | 645 | connect( mDeleteAction, SIGNAL( activated() ), |
638 | mView, SLOT( deleteIncidence() ) ); | 646 | mView, SLOT( deleteIncidence() ) ); |
639 | 647 | ||
640 | 648 | ||
641 | mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); | 649 | mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); |
642 | mCloneAction->addTo( actionMenu ); | 650 | mCloneAction->addTo( actionMenu ); |
643 | connect( mCloneAction, SIGNAL( activated() ), | 651 | connect( mCloneAction, SIGNAL( activated() ), |
644 | mView, SLOT( cloneIncidence() ) ); | 652 | mView, SLOT( cloneIncidence() ) ); |
645 | mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); | 653 | mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); |
646 | mMoveAction->addTo( actionMenu ); | 654 | mMoveAction->addTo( actionMenu ); |
647 | connect( mMoveAction, SIGNAL( activated() ), | 655 | connect( mMoveAction, SIGNAL( activated() ), |
648 | mView, SLOT( moveIncidence() ) ); | 656 | mView, SLOT( moveIncidence() ) ); |
649 | mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); | 657 | mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); |
650 | mBeamAction->addTo( actionMenu ); | 658 | mBeamAction->addTo( actionMenu ); |
651 | connect( mBeamAction, SIGNAL( activated() ), | 659 | connect( mBeamAction, SIGNAL( activated() ), |
652 | mView, SLOT( beamIncidence() ) ); | 660 | mView, SLOT( beamIncidence() ) ); |
653 | mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); | 661 | mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); |
654 | mCancelAction->addTo( actionMenu ); | 662 | mCancelAction->addTo( actionMenu ); |
655 | connect( mCancelAction, SIGNAL( activated() ), | 663 | connect( mCancelAction, SIGNAL( activated() ), |
656 | mView, SLOT( toggleCancelIncidence() ) ); | 664 | mView, SLOT( toggleCancelIncidence() ) ); |
657 | 665 | ||
658 | actionMenu->insertSeparator(); | 666 | actionMenu->insertSeparator(); |
659 | 667 | ||
660 | action = new QAction( "purge_completed", i18n("Purge Completed"), 0, | 668 | action = new QAction( "purge_completed", i18n("Purge Completed"), 0, |
661 | this ); | 669 | this ); |
662 | action->addTo( actionMenu ); | 670 | action->addTo( actionMenu ); |
663 | connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); | 671 | connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); |
664 | 672 | ||
665 | icon = loadPixmap( pathString + "search" ); | 673 | icon = loadPixmap( pathString + "search" ); |
666 | QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); | 674 | QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); |
667 | configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4); | 675 | configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4); |
668 | search_action->addTo( actionMenu ); | 676 | search_action->addTo( actionMenu ); |
669 | connect( search_action, SIGNAL( activated() ), | 677 | connect( search_action, SIGNAL( activated() ), |
670 | mView->dialogManager(), SLOT( showSearchDialog() ) ); | 678 | mView->dialogManager(), SLOT( showSearchDialog() ) ); |
671 | 679 | ||
672 | icon = loadPixmap( pathString + "today" ); | 680 | icon = loadPixmap( pathString + "today" ); |
673 | configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); | 681 | configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); |
674 | QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); | 682 | QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); |
675 | today_action->addTo( actionMenu ); | 683 | today_action->addTo( actionMenu ); |
676 | connect( today_action, SIGNAL( activated() ), | 684 | connect( today_action, SIGNAL( activated() ), |
677 | mView, SLOT( goToday() ) ); | 685 | mView, SLOT( goToday() ) ); |
678 | 686 | ||
679 | if ( KOPrefs::instance()->mShowFullMenu ) { | 687 | if ( KOPrefs::instance()->mShowFullMenu ) { |
680 | actionMenu->insertSeparator(); | 688 | actionMenu->insertSeparator(); |
681 | actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); | 689 | actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); |
682 | 690 | ||
683 | } | 691 | } |
684 | // actionMenu->insertSeparator(); | 692 | // actionMenu->insertSeparator(); |
685 | action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, | 693 | action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, |
686 | this ); | 694 | this ); |
687 | action->addTo( importMenu ); | 695 | action->addTo( importMenu ); |
688 | connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); | 696 | connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); |
689 | action = new QAction( "import_quick", i18n("Import last file"), 0, | 697 | action = new QAction( "import_quick", i18n("Import last file"), 0, |
690 | this ); | 698 | this ); |
691 | action->addTo( importMenu ); | 699 | action->addTo( importMenu ); |
692 | connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); | 700 | connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); |
693 | importMenu->insertSeparator(); | 701 | importMenu->insertSeparator(); |
694 | action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, | 702 | action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, |
695 | this ); | 703 | this ); |
696 | action->addTo( importMenu ); | 704 | action->addTo( importMenu ); |
697 | connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); | 705 | connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); |
698 | #ifndef DESKTOP_VERSION | 706 | #ifndef DESKTOP_VERSION |
699 | importMenu->insertSeparator(); | 707 | importMenu->insertSeparator(); |
700 | action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, | 708 | action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, |
701 | this ); | 709 | this ); |
702 | action->addTo( importMenu ); | 710 | action->addTo( importMenu ); |
703 | connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); | 711 | connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); |
704 | #else | 712 | #else |
705 | #ifdef _WIN32_ | 713 | #ifdef _WIN32_ |
706 | importMenu->insertSeparator(); | 714 | importMenu->insertSeparator(); |
707 | action = new QAction( "import_ol", i18n("Import from OL"), 0, | 715 | action = new QAction( "import_ol", i18n("Import from OL"), 0, |
708 | this ); | 716 | this ); |
709 | action->addTo( importMenu ); | 717 | action->addTo( importMenu ); |
710 | connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); | 718 | connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); |
711 | #endif | 719 | #endif |
712 | #endif | 720 | #endif |
713 | 721 | ||
714 | importMenu->insertSeparator(); | 722 | importMenu->insertSeparator(); |
715 | action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, | 723 | action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, |
716 | this ); | 724 | this ); |
717 | action->addTo( importMenu ); | 725 | action->addTo( importMenu ); |
718 | connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); | 726 | connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); |
719 | 727 | ||
720 | action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, | 728 | action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, |
721 | this ); | 729 | this ); |
722 | action->addTo( importMenu ); | 730 | action->addTo( importMenu ); |
723 | connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); | 731 | connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); |
724 | 732 | ||
725 | importMenu->insertSeparator(); | 733 | importMenu->insertSeparator(); |
726 | action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, | 734 | action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, |
727 | this ); | 735 | this ); |
728 | action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); | 736 | action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); |
729 | 737 | ||
730 | 738 | ||
731 | //LR | 739 | //LR |
732 | QPopupMenu *ex2phone = new QPopupMenu( this ); | 740 | QPopupMenu *ex2phone = new QPopupMenu( this ); |
733 | ex2phone->insertItem(i18n("Complete calendar..."), 1 ); | 741 | ex2phone->insertItem(i18n("Complete calendar..."), 1 ); |
734 | ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); | 742 | ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); |
735 | connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); | 743 | connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); |
736 | importMenu->insertItem( i18n("Export to phone"), ex2phone ); | 744 | importMenu->insertItem( i18n("Export to phone"), ex2phone ); |
737 | 745 | ||
738 | importMenu->insertSeparator(); | 746 | importMenu->insertSeparator(); |
739 | action = new QAction( "manage cat", i18n("Manage new categories..."), 0, | 747 | action = new QAction( "manage cat", i18n("Manage new categories..."), 0, |
740 | this ); | 748 | this ); |
741 | action->addTo( importMenu ); | 749 | action->addTo( importMenu ); |
742 | connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); | 750 | connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); |
743 | #ifndef DESKTOP_VERSION | 751 | #ifndef DESKTOP_VERSION |
744 | importMenu->insertSeparator(); | 752 | importMenu->insertSeparator(); |
745 | action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, | 753 | action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, |
746 | this ); | 754 | this ); |
747 | action->addTo( importMenu ); | 755 | action->addTo( importMenu ); |
748 | connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); | 756 | connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); |
749 | 757 | ||
750 | action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, | 758 | action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, |
751 | this ); | 759 | this ); |
752 | action->addTo( importMenu ); | 760 | action->addTo( importMenu ); |
753 | connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); | 761 | connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); |
754 | #else | 762 | #else |
755 | importMenu->insertSeparator(); | 763 | importMenu->insertSeparator(); |
756 | icon = loadPixmap( pathString + "print" ); | 764 | icon = loadPixmap( pathString + "print" ); |
757 | action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); | 765 | action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); |
758 | action->addTo( importMenu ); | 766 | action->addTo( importMenu ); |
759 | connect( action, SIGNAL( activated() ), | 767 | connect( action, SIGNAL( activated() ), |
760 | this, SLOT( printCal() ) ); | 768 | this, SLOT( printCal() ) ); |
761 | 769 | ||
762 | icon = loadPixmap( pathString + "print" ); | 770 | icon = loadPixmap( pathString + "print" ); |
763 | action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); | 771 | action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); |
764 | action->addTo( importMenu ); | 772 | action->addTo( importMenu ); |
765 | connect( action, SIGNAL( activated() ), | 773 | connect( action, SIGNAL( activated() ), |
766 | this, SLOT( printSel() ) ); | 774 | this, SLOT( printSel() ) ); |
767 | #endif | 775 | #endif |
768 | importMenu->insertSeparator(); | 776 | importMenu->insertSeparator(); |
769 | action = new QAction( "beam all", i18n("Save"), 0, | 777 | action = new QAction( "beam all", i18n("Save"), 0, |
770 | this ); | 778 | this ); |
771 | action->addTo( importMenu ); | 779 | action->addTo( importMenu ); |
772 | connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); | 780 | connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); |
773 | action = new QAction( "beam all", i18n("Exit (+save)"), 0, | 781 | action = new QAction( "beam all", i18n("Exit (+save)"), 0, |
774 | this ); | 782 | this ); |
775 | action->addTo( importMenu ); | 783 | action->addTo( importMenu ); |
776 | connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); | 784 | connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); |
777 | 785 | ||
778 | //menuBar->insertItem( "Configure",configureMenu ); | 786 | //menuBar->insertItem( "Configure",configureMenu ); |
779 | //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); | 787 | //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); |
780 | icon = loadPixmap( "korganizer/korganizer" ); | 788 | icon = loadPixmap( "korganizer/korganizer" ); |
781 | action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); | 789 | action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); |
782 | action->addTo( helpMenu ); | 790 | action->addTo( helpMenu ); |
783 | connect( action, SIGNAL( activated() ), | 791 | connect( action, SIGNAL( activated() ), |
784 | SLOT( keyBindings() ) ); | 792 | SLOT( keyBindings() ) ); |
785 | action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); | 793 | action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); |
786 | action->addTo( helpMenu ); | 794 | action->addTo( helpMenu ); |
787 | connect( action, SIGNAL( activated() ), | 795 | connect( action, SIGNAL( activated() ), |
788 | SLOT( features() ) ); | 796 | SLOT( features() ) ); |
789 | action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); | 797 | action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); |
790 | action->addTo( helpMenu ); | 798 | action->addTo( helpMenu ); |
791 | connect( action, SIGNAL( activated() ), | 799 | connect( action, SIGNAL( activated() ), |
792 | SLOT( aboutAutoSaving() ) ); | 800 | SLOT( aboutAutoSaving() ) ); |
793 | action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); | 801 | action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); |
794 | action->addTo( helpMenu ); | 802 | action->addTo( helpMenu ); |
795 | connect( action, SIGNAL( activated() ), | 803 | connect( action, SIGNAL( activated() ), |
796 | SLOT( aboutKnownBugs() ) ); | 804 | SLOT( aboutKnownBugs() ) ); |
797 | action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); | 805 | action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); |
798 | action->addTo( helpMenu ); | 806 | action->addTo( helpMenu ); |
799 | connect( action, SIGNAL( activated() ), | 807 | connect( action, SIGNAL( activated() ), |
800 | SLOT( usertrans() ) ); | 808 | SLOT( usertrans() ) ); |
801 | action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); | 809 | action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); |
802 | action->addTo( helpMenu ); | 810 | action->addTo( helpMenu ); |
803 | connect( action, SIGNAL( activated() ), | 811 | connect( action, SIGNAL( activated() ), |
804 | SLOT( synchowto() ) ); | 812 | SLOT( synchowto() ) ); |
805 | action = new QAction( "Whats New", i18n("What's new?"), 0,this ); | 813 | action = new QAction( "Whats New", i18n("What's new?"), 0,this ); |
806 | action->addTo( helpMenu ); | 814 | action->addTo( helpMenu ); |
807 | connect( action, SIGNAL( activated() ), | 815 | connect( action, SIGNAL( activated() ), |
808 | SLOT( whatsNew() ) ); | 816 | SLOT( whatsNew() ) ); |
809 | action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); | 817 | action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); |
810 | action->addTo( helpMenu ); | 818 | action->addTo( helpMenu ); |
811 | connect( action, SIGNAL( activated() ), | 819 | connect( action, SIGNAL( activated() ), |
812 | SLOT( faq() ) ); | 820 | SLOT( faq() ) ); |
813 | 821 | ||
814 | 822 | ||
815 | action = new QAction( "about", i18n("About..."), 0, this ); | 823 | action = new QAction( "about", i18n("About..."), 0, this ); |
816 | action->addTo( helpMenu ); | 824 | action->addTo( helpMenu ); |
817 | connect( action, SIGNAL( activated() ), | 825 | connect( action, SIGNAL( activated() ), |
818 | SLOT( about() ) ); | 826 | SLOT( about() ) ); |
819 | action = new QAction( "licence", i18n("Licence..."), 0, this ); | 827 | action = new QAction( "licence", i18n("Licence..."), 0, this ); |
820 | action->addTo( helpMenu ); | 828 | action->addTo( helpMenu ); |
821 | connect( action, SIGNAL( activated() ), | 829 | connect( action, SIGNAL( activated() ), |
822 | SLOT( licence() ) ); | 830 | SLOT( licence() ) ); |
823 | //menuBar->insertSeparator(); | 831 | //menuBar->insertSeparator(); |
824 | 832 | ||
825 | // ****************************************************** | 833 | // ****************************************************** |
826 | // menubar icons | 834 | // menubar icons |
827 | 835 | ||
828 | 836 | ||
829 | iconToolBar->setHorizontalStretchable (true ); | 837 | iconToolBar->setHorizontalStretchable (true ); |
830 | //menuBar->insertItem( iconToolBar ); | 838 | //menuBar->insertItem( iconToolBar ); |
831 | //xdays_action | 839 | //xdays_action |
832 | if (p-> mShowIconNewEvent) | 840 | if (p-> mShowIconNewEvent) |
833 | ne_action->addTo( iconToolBar ); | 841 | ne_action->addTo( iconToolBar ); |
834 | if (p->mShowIconNewTodo ) | 842 | if (p->mShowIconNewTodo ) |
835 | nt_action->addTo( iconToolBar ); | 843 | nt_action->addTo( iconToolBar ); |
836 | if (p-> mShowIconSearch) | 844 | if (p-> mShowIconSearch) |
837 | search_action->addTo( iconToolBar ); | 845 | search_action->addTo( iconToolBar ); |
838 | if (p-> mShowIconNext) | 846 | if (p-> mShowIconNext) |
839 | whatsnext_action->addTo( iconToolBar ); | 847 | whatsnext_action->addTo( iconToolBar ); |
840 | if (p-> mShowIconNextDays) | 848 | if (p-> mShowIconNextDays) |
841 | xdays_action->addTo( iconToolBar ); | 849 | xdays_action->addTo( iconToolBar ); |
842 | if (p-> mShowIconList) | 850 | if (p-> mShowIconList) |
843 | showlist_action->addTo( iconToolBar ); | 851 | showlist_action->addTo( iconToolBar ); |
844 | if (p-> mShowIconDay1) | 852 | if (p-> mShowIconDay1) |
845 | day1_action->addTo( iconToolBar ); | 853 | day1_action->addTo( iconToolBar ); |
846 | if (p-> mShowIconDay5) | 854 | if (p-> mShowIconDay5) |
847 | day5_action->addTo( iconToolBar ); | 855 | day5_action->addTo( iconToolBar ); |
848 | if (p-> mShowIconDay7) | 856 | if (p-> mShowIconDay7) |
849 | day7_action->addTo( iconToolBar ); | 857 | day7_action->addTo( iconToolBar ); |
850 | if (p-> mShowIconMonth) | 858 | if (p-> mShowIconMonth) |
851 | month_action->addTo( iconToolBar ); | 859 | month_action->addTo( iconToolBar ); |
852 | if (p-> mShowIconTodoview) | 860 | if (p-> mShowIconTodoview) |
853 | todoview_action->addTo( iconToolBar ); | 861 | todoview_action->addTo( iconToolBar ); |
854 | if (p-> mShowIconJournal) | 862 | if (p-> mShowIconJournal) |
855 | viewjournal_action->addTo( iconToolBar ); | 863 | viewjournal_action->addTo( iconToolBar ); |
856 | icon = loadPixmap( pathString + "2leftarrowB" ); | 864 | icon = loadPixmap( pathString + "2leftarrowB" ); |
857 | configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); | 865 | configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); |
858 | if (p-> mShowIconBackFast) { | 866 | if (p-> mShowIconBackFast) { |
859 | action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); | 867 | action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); |
860 | connect( action, SIGNAL( activated() ), | 868 | connect( action, SIGNAL( activated() ), |
861 | mView, SLOT( goPreviousMonth() ) ); | 869 | mView, SLOT( goPreviousMonth() ) ); |
862 | action->addTo( iconToolBar ); | 870 | action->addTo( iconToolBar ); |
863 | } | 871 | } |
864 | icon = loadPixmap( pathString + "1leftarrowB" ); | 872 | icon = loadPixmap( pathString + "1leftarrowB" ); |
865 | configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); | 873 | configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); |
866 | if (p-> mShowIconBack) { | 874 | if (p-> mShowIconBack) { |
867 | action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); | 875 | action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); |
868 | connect( action, SIGNAL( activated() ), | 876 | connect( action, SIGNAL( activated() ), |
869 | mView, SLOT( goPrevious() ) ); | 877 | mView, SLOT( goPrevious() ) ); |
870 | action->addTo( iconToolBar ); | 878 | action->addTo( iconToolBar ); |
871 | } | 879 | } |
872 | if (p-> mShowIconToday) | 880 | if (p-> mShowIconToday) |
873 | today_action->addTo( iconToolBar ); | 881 | today_action->addTo( iconToolBar ); |
874 | icon = loadPixmap( pathString + "1rightarrowB" ); | 882 | icon = loadPixmap( pathString + "1rightarrowB" ); |
875 | configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); | 883 | configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); |
876 | if (p-> mShowIconForward) { | 884 | if (p-> mShowIconForward) { |
877 | action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); | 885 | action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); |
878 | connect( action, SIGNAL( activated() ), | 886 | connect( action, SIGNAL( activated() ), |
879 | mView, SLOT( goNext() ) ); | 887 | mView, SLOT( goNext() ) ); |
880 | action->addTo( iconToolBar ); | 888 | action->addTo( iconToolBar ); |
881 | } | 889 | } |
882 | icon = loadPixmap( pathString + "2rightarrowB" ); | 890 | icon = loadPixmap( pathString + "2rightarrowB" ); |
883 | configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); | 891 | configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); |
884 | if (p-> mShowIconForwardFast) { | 892 | if (p-> mShowIconForwardFast) { |
885 | action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); | 893 | action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); |
886 | connect( action, SIGNAL( activated() ), | 894 | connect( action, SIGNAL( activated() ), |
887 | mView, SLOT( goNextMonth() ) ); | 895 | mView, SLOT( goNextMonth() ) ); |
888 | action->addTo( iconToolBar ); | 896 | action->addTo( iconToolBar ); |
889 | } | 897 | } |
890 | 898 | ||
891 | 899 | ||
892 | configureToolBarMenu->insertItem(i18n("What's This?"), 300); | 900 | configureToolBarMenu->insertItem(i18n("What's This?"), 300); |
893 | 901 | ||
894 | if (p-> mShowIconNewEvent) | 902 | if (p-> mShowIconNewEvent) |
895 | configureToolBarMenu->setItemChecked( 10, true ); | 903 | configureToolBarMenu->setItemChecked( 10, true ); |
896 | if (p->mShowIconNewTodo ) | 904 | if (p->mShowIconNewTodo ) |
897 | configureToolBarMenu->setItemChecked( 20, true ); | 905 | configureToolBarMenu->setItemChecked( 20, true ); |
898 | if (p-> mShowIconSearch) | 906 | if (p-> mShowIconSearch) |
899 | configureToolBarMenu->setItemChecked( 120, true ); | 907 | configureToolBarMenu->setItemChecked( 120, true ); |
900 | if (p-> mShowIconList) | 908 | if (p-> mShowIconList) |
901 | configureToolBarMenu->setItemChecked( 30, true ); | 909 | configureToolBarMenu->setItemChecked( 30, true ); |
902 | if (p-> mShowIconDay1) | 910 | if (p-> mShowIconDay1) |
903 | configureToolBarMenu->setItemChecked( 40, true ); | 911 | configureToolBarMenu->setItemChecked( 40, true ); |
904 | if (p-> mShowIconDay5) | 912 | if (p-> mShowIconDay5) |
905 | configureToolBarMenu->setItemChecked( 50, true ); | 913 | configureToolBarMenu->setItemChecked( 50, true ); |
906 | if (p-> mShowIconDay7) | 914 | if (p-> mShowIconDay7) |
907 | configureToolBarMenu->setItemChecked( 60, true ); | 915 | configureToolBarMenu->setItemChecked( 60, true ); |
908 | if (p-> mShowIconMonth) | 916 | if (p-> mShowIconMonth) |
909 | configureToolBarMenu->setItemChecked( 70, true ); | 917 | configureToolBarMenu->setItemChecked( 70, true ); |
910 | if (p-> mShowIconTodoview) | 918 | if (p-> mShowIconTodoview) |
911 | configureToolBarMenu->setItemChecked( 80, true ); | 919 | configureToolBarMenu->setItemChecked( 80, true ); |
912 | if (p-> mShowIconBackFast) | 920 | if (p-> mShowIconBackFast) |
913 | configureToolBarMenu->setItemChecked( 200, true ); | 921 | configureToolBarMenu->setItemChecked( 200, true ); |
914 | if (p-> mShowIconBack) | 922 | if (p-> mShowIconBack) |
915 | configureToolBarMenu->setItemChecked( 210, true ); | 923 | configureToolBarMenu->setItemChecked( 210, true ); |
916 | if (p-> mShowIconToday) | 924 | if (p-> mShowIconToday) |
917 | configureToolBarMenu->setItemChecked( 130, true ); | 925 | configureToolBarMenu->setItemChecked( 130, true ); |
918 | if (p-> mShowIconForward) | 926 | if (p-> mShowIconForward) |
919 | configureToolBarMenu->setItemChecked( 220, true ); | 927 | configureToolBarMenu->setItemChecked( 220, true ); |
920 | if (p-> mShowIconForwardFast) | 928 | if (p-> mShowIconForwardFast) |
921 | configureToolBarMenu->setItemChecked( 230, true ); | 929 | configureToolBarMenu->setItemChecked( 230, true ); |
922 | if (p-> mShowIconNextDays) | 930 | if (p-> mShowIconNextDays) |
923 | configureToolBarMenu->setItemChecked( 100, true ); | 931 | configureToolBarMenu->setItemChecked( 100, true ); |
924 | if (p-> mShowIconNext) | 932 | if (p-> mShowIconNext) |
925 | configureToolBarMenu->setItemChecked( 110, true ); | 933 | configureToolBarMenu->setItemChecked( 110, true ); |
926 | if (p-> mShowIconJournal) | 934 | if (p-> mShowIconJournal) |
927 | configureToolBarMenu->setItemChecked( 90, true ); | 935 | configureToolBarMenu->setItemChecked( 90, true ); |
928 | if (p-> mShowIconWhatsThis) | 936 | if (p-> mShowIconWhatsThis) |
929 | configureToolBarMenu->setItemChecked( 300, true ); | 937 | configureToolBarMenu->setItemChecked( 300, true ); |
930 | 938 | ||
931 | QLabel* dummy = new QLabel( iconToolBar ); | 939 | QLabel* dummy = new QLabel( iconToolBar ); |
932 | dummy->setBackgroundColor( iconToolBar->backgroundColor() ); | 940 | dummy->setBackgroundColor( iconToolBar->backgroundColor() ); |
933 | if (!p-> mShowIconStretch) | 941 | if (!p-> mShowIconStretch) |
934 | iconToolBar->setStretchableWidget ( dummy ) ; | 942 | iconToolBar->setStretchableWidget ( dummy ) ; |
935 | else | 943 | else |
936 | configureToolBarMenu->setItemChecked( 5, true ); | 944 | configureToolBarMenu->setItemChecked( 5, true ); |
937 | if (p-> mShowIconWhatsThis) | 945 | if (p-> mShowIconWhatsThis) |
938 | QWhatsThis::whatsThisButton ( iconToolBar ); | 946 | QWhatsThis::whatsThisButton ( iconToolBar ); |
939 | connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); | 947 | connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); |
940 | configureAgenda( p->mHourSize ); | 948 | configureAgenda( p->mHourSize ); |
941 | connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); | 949 | connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); |
942 | } | 950 | } |
943 | void MainWindow::fillSyncMenu() | ||
944 | { | ||
945 | if ( syncMenu->count() ) | ||
946 | syncMenu->clear(); | ||
947 | syncMenu->insertItem( i18n("Configure..."), 0 ); | ||
948 | syncMenu->insertSeparator(); | ||
949 | if ( mServerSocket == 0 ) { | ||
950 | syncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); | ||
951 | } else { | ||
952 | syncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); | ||
953 | } | ||
954 | syncMenu->insertSeparator(); | ||
955 | syncMenu->insertItem( i18n("Multiple sync"), 1 ); | ||
956 | syncMenu->insertSeparator(); | ||
957 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | ||
958 | config.setGroup("General"); | ||
959 | QStringList prof = config.readListEntry("SyncProfileNames"); | ||
960 | KOPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); | ||
961 | if ( prof.count() < 3 ) { | ||
962 | prof.clear(); | ||
963 | prof << i18n("Sharp_DTM"); | ||
964 | prof << i18n("Local_file"); | ||
965 | prof << i18n("Last_file"); | ||
966 | KSyncProfile* temp = new KSyncProfile (); | ||
967 | temp->setName( prof[0] ); | ||
968 | temp->writeConfig(&config); | ||
969 | temp->setName( prof[1] ); | ||
970 | temp->writeConfig(&config); | ||
971 | temp->setName( prof[2] ); | ||
972 | temp->writeConfig(&config); | ||
973 | config.setGroup("General"); | ||
974 | config.writeEntry("SyncProfileNames",prof); | ||
975 | config.writeEntry("ExternSyncProfiles","Sharp_DTM"); | ||
976 | config.sync(); | ||
977 | delete temp; | ||
978 | } | ||
979 | KOPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); | ||
980 | KOPrefs::instance()->mSyncProfileNames = prof; | ||
981 | int i; | ||
982 | for ( i = 0; i < prof.count(); ++i ) { | ||
983 | |||
984 | syncMenu->insertItem( prof[i], 1000+i ); | ||
985 | if ( i == 2 ) | ||
986 | syncMenu->insertSeparator(); | ||
987 | } | ||
988 | QDir app_dir; | ||
989 | if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { | ||
990 | syncMenu->setItemEnabled( false , 1000 ); | ||
991 | } | ||
992 | } | ||
993 | |||
994 | int MainWindow::ringSync() | ||
995 | { | ||
996 | int syncedProfiles = 0; | ||
997 | int i; | ||
998 | QTime timer; | ||
999 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | ||
1000 | QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames; | ||
1001 | KSyncProfile* temp = new KSyncProfile (); | ||
1002 | KOPrefs::instance()->mAskForPreferences = false; | ||
1003 | for ( i = 0; i < syncProfileNames.count(); ++i ) { | ||
1004 | mCurrentSyncProfile = i; | ||
1005 | temp->setName(syncProfileNames[mCurrentSyncProfile]); | ||
1006 | temp->readConfig(&config); | ||
1007 | if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) { | ||
1008 | setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); | ||
1009 | ++syncedProfiles; | ||
1010 | // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); | ||
1011 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); | ||
1012 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); | ||
1013 | KOPrefs::instance()->mWriteBackInFuture = 0; | ||
1014 | if ( temp->getWriteBackFuture() ) | ||
1015 | KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | ||
1016 | KOPrefs::instance()->mShowSyncSummary = false; | ||
1017 | mView->setSyncDevice(syncProfileNames[i] ); | ||
1018 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); | ||
1019 | if ( i == 0 ) { | ||
1020 | syncSharp(); | ||
1021 | } else { | ||
1022 | if ( temp->getIsLocalFileSync() ) { | ||
1023 | if ( syncWithFile( temp->getRemoteFileName( ), true ) ) | ||
1024 | KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); | ||
1025 | } else { | ||
1026 | if ( temp->getIsPhoneSync() ) { | ||
1027 | KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; | ||
1028 | KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); | ||
1029 | KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); | ||
1030 | syncPhone(); | ||
1031 | } else if ( temp->getIsPiSync() ) { | ||
1032 | mPassWordPiSync = temp->getRemotePw(); | ||
1033 | KOPrefs::instance()->mActiveSyncPort = temp->getRemotePort(); | ||
1034 | KOPrefs::instance()->mActiveSyncIP = temp->getRemoteIP(); | ||
1035 | syncPi(); | ||
1036 | } else | ||
1037 | syncRemote( temp, false ); | ||
1038 | |||
1039 | } | ||
1040 | } | ||
1041 | timer.start(); | ||
1042 | setCaption(i18n("Multiple sync in progress ... please wait!") ); | ||
1043 | while ( timer.elapsed () < 2000 ) { | ||
1044 | qApp->processEvents(); | ||
1045 | #ifndef _WIN32_ | ||
1046 | sleep (1); | ||
1047 | #endif | ||
1048 | } | ||
1049 | |||
1050 | } | ||
1051 | |||
1052 | } | ||
1053 | delete temp; | ||
1054 | return syncedProfiles; | ||
1055 | } | ||
1056 | |||
1057 | void MainWindow::multiSync( bool askforPrefs ) | ||
1058 | { | ||
1059 | if (mBlockSaveFlag) | ||
1060 | return; | ||
1061 | mBlockSaveFlag = true; | ||
1062 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); | ||
1063 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), | ||
1064 | question, | ||
1065 | i18n("Yes"), i18n("No"), | ||
1066 | 0, 0 ) != 0 ) { | ||
1067 | mBlockSaveFlag = false; | ||
1068 | setCaption(i18n("Aborted! Nothing synced!")); | ||
1069 | return; | ||
1070 | } | ||
1071 | mView->setSyncDevice(i18n("Multiple profiles") ); | ||
1072 | KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs; | ||
1073 | if ( askforPrefs ) { | ||
1074 | mView->edit_sync_options(); | ||
1075 | KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs; | ||
1076 | } | ||
1077 | setCaption(i18n("Multiple sync started.") ); | ||
1078 | qApp->processEvents(); | ||
1079 | int num = ringSync() ; | ||
1080 | if ( num > 1 ) | ||
1081 | ringSync(); | ||
1082 | mBlockSaveFlag = false; | ||
1083 | if ( num ) | ||
1084 | save(); | ||
1085 | if ( num ) | ||
1086 | setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); | ||
1087 | else | ||
1088 | setCaption(i18n("Nothing synced! No profiles defined for multisync!")); | ||
1089 | return; | ||
1090 | } | ||
1091 | void MainWindow::slotSyncMenu( int action ) | ||
1092 | { | ||
1093 | qDebug("syncaction %d ", action); | ||
1094 | if ( action == 0 ) { | ||
1095 | |||
1096 | // seems to be a Qt2 event handling bug | ||
1097 | // syncmenu.clear causes a segfault at first time | ||
1098 | // when we call it after the main event loop, it is ok | ||
1099 | // same behaviour when calling OM/Pi via QCOP for the first time | ||
1100 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); | ||
1101 | //confSync(); | ||
1102 | 951 | ||
1103 | return; | ||
1104 | } | ||
1105 | if ( action == 1 ) { | ||
1106 | multiSync( true ); | ||
1107 | return; | ||
1108 | } | ||
1109 | if ( action == 2 ) { | ||
1110 | enableQuick(); | ||
1111 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | ||
1112 | return; | ||
1113 | } | ||
1114 | if ( action == 3 ) { | ||
1115 | delete mServerSocket; | ||
1116 | mServerSocket = 0; | ||
1117 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | ||
1118 | return; | ||
1119 | } | ||
1120 | |||
1121 | if (mBlockSaveFlag) | ||
1122 | return; | ||
1123 | mBlockSaveFlag = true; | ||
1124 | mCurrentSyncProfile = action - 1000 ; | ||
1125 | mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); | ||
1126 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); | ||
1127 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | ||
1128 | KSyncProfile* temp = new KSyncProfile (); | ||
1129 | temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); | ||
1130 | temp->readConfig(&config); | ||
1131 | KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); | ||
1132 | KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); | ||
1133 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); | ||
1134 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); | ||
1135 | KOPrefs::instance()->mWriteBackInFuture = 0; | ||
1136 | if ( temp->getWriteBackFuture() ) | ||
1137 | KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | ||
1138 | KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); | ||
1139 | if ( action == 1000 ) { | ||
1140 | syncSharp(); | ||
1141 | |||
1142 | } else if ( action == 1001 ) { | ||
1143 | syncLocalFile(); | ||
1144 | |||
1145 | } else if ( action == 1002 ) { | ||
1146 | quickSyncLocalFile(); | ||
1147 | |||
1148 | } else if ( action >= 1003 ) { | ||
1149 | if ( temp->getIsLocalFileSync() ) { | ||
1150 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | ||
1151 | KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); | ||
1152 | } else { | ||
1153 | if ( temp->getIsPhoneSync() ) { | ||
1154 | KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; | ||
1155 | KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); | ||
1156 | KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); | ||
1157 | syncPhone(); | ||
1158 | } else if ( temp->getIsPiSync() ) { | ||
1159 | mPassWordPiSync = temp->getRemotePw(); | ||
1160 | KOPrefs::instance()->mActiveSyncPort = temp->getRemotePort(); | ||
1161 | KOPrefs::instance()->mActiveSyncIP = temp->getRemoteIP(); | ||
1162 | syncPi(); | ||
1163 | } else | ||
1164 | syncRemote( temp ); | ||
1165 | |||
1166 | } | ||
1167 | } | ||
1168 | delete temp; | ||
1169 | mBlockSaveFlag = false; | ||
1170 | } | ||
1171 | void MainWindow::exportToPhone( int mode ) | 952 | void MainWindow::exportToPhone( int mode ) |
1172 | { | 953 | { |
1173 | 954 | ||
1174 | //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); | 955 | //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); |
1175 | //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); | 956 | //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); |
1176 | KOex2phonePrefs ex2phone; | 957 | KOex2phonePrefs ex2phone; |
1177 | 958 | ||
1178 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); | 959 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); |
1179 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); | 960 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); |
1180 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 961 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
1181 | if ( mode == 1 ) | 962 | if ( mode == 1 ) |
1182 | ex2phone.setCaption(i18n("Export complete calendar")); | 963 | ex2phone.setCaption(i18n("Export complete calendar")); |
1183 | if ( mode == 2 ) | 964 | if ( mode == 2 ) |
1184 | ex2phone.setCaption(i18n("Export filtered calendar")); | 965 | ex2phone.setCaption(i18n("Export filtered calendar")); |
1185 | 966 | ||
1186 | if ( !ex2phone.exec() ) { | 967 | if ( !ex2phone.exec() ) { |
1187 | return; | 968 | return; |
1188 | } | 969 | } |
1189 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); | 970 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); |
1190 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); | 971 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); |
1191 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); | 972 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); |
1192 | 973 | ||
1193 | int inFuture = 0; | 974 | int inFuture = 0; |
1194 | if ( ex2phone.mWriteBackFuture->isChecked() ) | 975 | if ( ex2phone.mWriteBackFuture->isChecked() ) |
1195 | inFuture = ex2phone.mWriteBackFutureWeeks->value(); | 976 | inFuture = ex2phone.mWriteBackFutureWeeks->value(); |
1196 | QPtrList<Incidence> delSel; | 977 | QPtrList<Incidence> delSel; |
1197 | if ( mode == 1 ) | 978 | if ( mode == 1 ) |
1198 | delSel = mCalendar->rawIncidences(); | 979 | delSel = mCalendar->rawIncidences(); |
1199 | if ( mode == 2 ) | 980 | if ( mode == 2 ) |
1200 | delSel = mCalendar->incidences(); | 981 | delSel = mCalendar->incidences(); |
1201 | CalendarLocal* cal = new CalendarLocal(); | 982 | CalendarLocal* cal = new CalendarLocal(); |
1202 | cal->setLocalTime(); | 983 | cal->setLocalTime(); |
1203 | Incidence *incidence = delSel.first(); | 984 | Incidence *incidence = delSel.first(); |
1204 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); | 985 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); |
1205 | QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); | 986 | QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); |
1206 | while ( incidence ) { | 987 | while ( incidence ) { |
1207 | if ( incidence->type() != "Journal" ) { | 988 | if ( incidence->type() != "Journal" ) { |
1208 | bool add = true; | 989 | bool add = true; |
1209 | if ( inFuture ) { | 990 | if ( inFuture ) { |
1210 | QDateTime dt; | 991 | QDateTime dt; |
1211 | if ( incidence->type() == "Todo" ) { | 992 | if ( incidence->type() == "Todo" ) { |
1212 | Todo * t = (Todo*)incidence; | 993 | Todo * t = (Todo*)incidence; |
1213 | if ( t->hasDueDate() ) | 994 | if ( t->hasDueDate() ) |
1214 | dt = t->dtDue(); | 995 | dt = t->dtDue(); |
1215 | else | 996 | else |
1216 | dt = cur.addSecs( 62 ); | 997 | dt = cur.addSecs( 62 ); |
1217 | } | 998 | } |
1218 | else { | 999 | else { |
1219 | bool ok; | 1000 | bool ok; |
1220 | dt = incidence->getNextOccurence( cur, &ok ); | 1001 | dt = incidence->getNextOccurence( cur, &ok ); |
1221 | if ( !ok ) | 1002 | if ( !ok ) |
1222 | dt = cur.addSecs( -62 ); | 1003 | dt = cur.addSecs( -62 ); |
1223 | } | 1004 | } |
1224 | if ( dt < cur || dt > end ) { | 1005 | if ( dt < cur || dt > end ) { |
1225 | add = false; | 1006 | add = false; |
1226 | } | 1007 | } |
1227 | } | 1008 | } |
1228 | if ( add ) { | 1009 | if ( add ) { |
1229 | Incidence *in = incidence->clone(); | 1010 | Incidence *in = incidence->clone(); |
1230 | cal->addIncidence( in ); | 1011 | cal->addIncidence( in ); |
1231 | } | 1012 | } |
1232 | } | 1013 | } |
1233 | incidence = delSel.next(); | 1014 | incidence = delSel.next(); |
1234 | } | 1015 | } |
1235 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, | 1016 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, |
1236 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, | 1017 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, |
1237 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 1018 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
1238 | 1019 | ||
1239 | setCaption( i18n("Writing to phone...")); | 1020 | setCaption( i18n("Writing to phone...")); |
1240 | if ( PhoneFormat::writeToPhone( cal ) ) | 1021 | if ( PhoneFormat::writeToPhone( cal ) ) |
1241 | setCaption( i18n("Export to phone successful!")); | 1022 | setCaption( i18n("Export to phone successful!")); |
1242 | else | 1023 | else |
1243 | setCaption( i18n("Error exporting to phone!")); | 1024 | setCaption( i18n("Error exporting to phone!")); |
1244 | delete cal; | 1025 | delete cal; |
1245 | } | 1026 | } |
1246 | 1027 | ||
1247 | 1028 | ||
1248 | void MainWindow::setDefaultPreferences() | 1029 | void MainWindow::setDefaultPreferences() |
1249 | { | 1030 | { |
1250 | KOPrefs *p = KOPrefs::instance(); | 1031 | KOPrefs *p = KOPrefs::instance(); |
1251 | 1032 | ||
1252 | p->mCompactDialogs = true; | 1033 | p->mCompactDialogs = true; |
1253 | p->mConfirm = true; | 1034 | p->mConfirm = true; |
1254 | // p->mEnableQuickTodo = false; | 1035 | // p->mEnableQuickTodo = false; |
1255 | 1036 | ||
1256 | } | 1037 | } |
1257 | 1038 | ||
1258 | QString MainWindow::resourcePath() | 1039 | QString MainWindow::resourcePath() |
1259 | { | 1040 | { |
1260 | return KGlobal::iconLoader()->iconPath(); | 1041 | return KGlobal::iconLoader()->iconPath(); |
1261 | } | 1042 | } |
1262 | 1043 | ||
1263 | void MainWindow::displayText( QString text ,QString cap ) | 1044 | void MainWindow::displayText( QString text ,QString cap ) |
1264 | { | 1045 | { |
1265 | QDialog dia( this, "name", true ); ; | 1046 | QDialog dia( this, "name", true ); ; |
1266 | dia.setCaption( cap ); | 1047 | dia.setCaption( cap ); |
1267 | QVBoxLayout* lay = new QVBoxLayout( &dia ); | 1048 | QVBoxLayout* lay = new QVBoxLayout( &dia ); |
1268 | lay->setSpacing( 3 ); | 1049 | lay->setSpacing( 3 ); |
1269 | lay->setMargin( 3 ); | 1050 | lay->setMargin( 3 ); |
1270 | QTextBrowser tb ( &dia ); | 1051 | QTextBrowser tb ( &dia ); |
1271 | lay->addWidget( &tb ); | 1052 | lay->addWidget( &tb ); |
1272 | tb.setText( text ); | 1053 | tb.setText( text ); |
1273 | #ifdef DESKTOP_VERSION | 1054 | #ifdef DESKTOP_VERSION |
1274 | dia.resize( 640, 480); | 1055 | dia.resize( 640, 480); |
1275 | #else | 1056 | #else |
1276 | dia.showMaximized(); | 1057 | dia.showMaximized(); |
1277 | #endif | 1058 | #endif |
1278 | dia.exec(); | 1059 | dia.exec(); |
1279 | } | 1060 | } |
1280 | void MainWindow::displayFile( QString fn, QString cap ) | 1061 | void MainWindow::displayFile( QString fn, QString cap ) |
1281 | { | 1062 | { |
1282 | QString fileName = resourcePath() + fn; | 1063 | QString fileName = resourcePath() + fn; |
1283 | QString text; | 1064 | QString text; |
1284 | QFile file( fileName ); | 1065 | QFile file( fileName ); |
1285 | if (!file.open( IO_ReadOnly ) ) { | 1066 | if (!file.open( IO_ReadOnly ) ) { |
1286 | return ; | 1067 | return ; |
1287 | 1068 | ||
1288 | } | 1069 | } |
1289 | QTextStream ts( &file ); | 1070 | QTextStream ts( &file ); |
1290 | text = ts.read(); | 1071 | text = ts.read(); |
1291 | file.close(); | 1072 | file.close(); |
1292 | displayText( text, cap); | 1073 | displayText( text, cap); |
1293 | } | 1074 | } |
1294 | void MainWindow::features() | 1075 | void MainWindow::features() |
1295 | { | 1076 | { |
1296 | 1077 | ||
1297 | displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); | 1078 | displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); |
1298 | } | 1079 | } |
1299 | 1080 | ||
1300 | void MainWindow::usertrans() | 1081 | void MainWindow::usertrans() |
1301 | { | 1082 | { |
1302 | 1083 | ||
1303 | displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); | 1084 | displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); |
1304 | } | 1085 | } |
1305 | 1086 | ||
1306 | void MainWindow::synchowto() | 1087 | void MainWindow::synchowto() |
1307 | { | 1088 | { |
1308 | #if 0 | 1089 | #if 0 |
1309 | QPtrList<Incidence> er = mCalendar->rawIncidences(); | 1090 | QPtrList<Incidence> er = mCalendar->rawIncidences(); |
1310 | Incidence* inR = er.first(); | 1091 | Incidence* inR = er.first(); |
1311 | VCalFormat vf; | 1092 | VCalFormat vf; |
1312 | QString strout; | 1093 | QString strout; |
1313 | while ( inR ) { | 1094 | while ( inR ) { |
1314 | if ( inR->type() == "Todo" ) | 1095 | if ( inR->type() == "Todo" ) |
1315 | strout = vf.todoToString( (Todo *) inR ); | 1096 | strout = vf.todoToString( (Todo *) inR ); |
1316 | if ( inR->type() == "Event" ) | 1097 | if ( inR->type() == "Event" ) |
1317 | strout = vf.eventToString( (Event *) inR ); | 1098 | strout = vf.eventToString( (Event *) inR ); |
1318 | qDebug("incidence: \n%s\n ente\n\n",strout.latin1() ); | 1099 | qDebug("incidence: \n%s\n ente\n\n",strout.latin1() ); |
1319 | inR = er.next(); | 1100 | inR = er.next(); |
1320 | } | 1101 | } |
1321 | #endif | 1102 | #endif |
1322 | displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") ); | 1103 | displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") ); |
1323 | } | 1104 | } |
1324 | void MainWindow::faq() | 1105 | void MainWindow::faq() |
1325 | { | 1106 | { |
1326 | displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); | 1107 | displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); |
1327 | 1108 | ||
1328 | } | 1109 | } |
1329 | void MainWindow::whatsNew() | 1110 | void MainWindow::whatsNew() |
1330 | { | 1111 | { |
1331 | displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") ); | 1112 | displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") ); |
1332 | 1113 | ||
1333 | } | 1114 | } |
1334 | void MainWindow::licence() | 1115 | void MainWindow::licence() |
1335 | { | 1116 | { |
1336 | KApplication::showLicence(); | 1117 | KApplication::showLicence(); |
1337 | 1118 | ||
1338 | } | 1119 | } |
1339 | void MainWindow::about() | 1120 | void MainWindow::about() |
1340 | { | 1121 | { |
1341 | QString version; | 1122 | QString version; |
1342 | #include <../version> | 1123 | #include <../version> |
1343 | QMessageBox::about( this, i18n("About KOrganizer/Pi"), | 1124 | QMessageBox::about( this, i18n("About KOrganizer/Pi"), |
1344 | i18n("KOrganizer/Platform-independent\n") + | 1125 | i18n("KOrganizer/Platform-independent\n") + |
1345 | "(KO/Pi) " + version + " - " + | 1126 | "(KO/Pi) " + version + " - " + |
1346 | 1127 | ||
1347 | #ifdef DESKTOP_VERSION | 1128 | #ifdef DESKTOP_VERSION |
1348 | i18n("Desktop Edition\n") + | 1129 | i18n("Desktop Edition\n") + |
1349 | #else | 1130 | #else |
1350 | i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + | 1131 | i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + |
1351 | #endif | 1132 | #endif |
1352 | i18n("(c) 2004 Lutz Rogowski\nEmail:lutz@pi-sync.net\nKO/Pi is based on KOrganizer\n(c) 2002,2003 Cornelius Schumacher\nEmail: schumacher@kde.org\nKOrganizer/Pi is licensed\nunder the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.korganizer.org\nwww.pi-sync.net\n") ); | 1133 | i18n("(c) 2004 Lutz Rogowski\nEmail:lutz@pi-sync.net\nKO/Pi is based on KOrganizer\n(c) 2002,2003 Cornelius Schumacher\nEmail: schumacher@kde.org\nKOrganizer/Pi is licensed\nunder the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.korganizer.org\nwww.pi-sync.net\n") ); |
1353 | } | 1134 | } |
1354 | void MainWindow::keyBindings() | 1135 | void MainWindow::keyBindings() |
1355 | { | 1136 | { |
1356 | QString cap = i18n("Key bindings KOrganizer/Pi"); | 1137 | QString cap = i18n("Key bindings KOrganizer/Pi"); |
1357 | QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + | 1138 | QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + |
1358 | i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ | 1139 | i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ |
1359 | i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + | 1140 | i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + |
1360 | i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ | 1141 | i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ |
1361 | i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ | 1142 | i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ |
1362 | i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ | 1143 | i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ |
1363 | i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ | 1144 | i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ |
1364 | i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ | 1145 | i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ |
1365 | i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ | 1146 | i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ |
1366 | i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ | 1147 | i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ |
1367 | i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ | 1148 | i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ |
1368 | i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ | 1149 | i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ |
1369 | i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ | 1150 | i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ |
1370 | i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ | 1151 | i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ |
1371 | i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ | 1152 | i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ |
1372 | i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ | 1153 | i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ |
1373 | i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ | 1154 | i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ |
1374 | i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ | 1155 | i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ |
1375 | i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ | 1156 | i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ |
1376 | i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ | 1157 | i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ |
1377 | i18n("<p><h3>In agenda view:</h3></p>\n") + | 1158 | i18n("<p><h3>In agenda view:</h3></p>\n") + |
1378 | i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ | 1159 | i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ |
1379 | i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ | 1160 | i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ |
1380 | i18n("<p><h3>In todo view:</h3></p>\n") + | 1161 | i18n("<p><h3>In todo view:</h3></p>\n") + |
1381 | i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ | 1162 | i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ |
1382 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ | 1163 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ |
1383 | i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ | 1164 | i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ |
1384 | i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ | 1165 | i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ |
1385 | i18n("<p><h3>In list view:</h3></p>\n") + | 1166 | i18n("<p><h3>In list view:</h3></p>\n") + |
1386 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ | 1167 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ |
1387 | i18n("<p><b>return</b>: Select item+one step down</p>\n")+ | 1168 | i18n("<p><b>return</b>: Select item+one step down</p>\n")+ |
1388 | i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ | 1169 | i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ |
1389 | i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ | 1170 | i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ |
1390 | i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ | 1171 | i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ |
1391 | i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ | 1172 | i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ |
1392 | i18n("<p><h3>In event/todo viewer:</h3></p>\n") + | 1173 | i18n("<p><h3>In event/todo viewer:</h3></p>\n") + |
1393 | i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ | 1174 | i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ |
1394 | i18n("<p><b>A</b>: Show agenda view.</p>\n")+ | 1175 | i18n("<p><b>A</b>: Show agenda view.</p>\n")+ |
1395 | i18n("<p><b>E</b>: Edit item</p>\n") + | 1176 | i18n("<p><b>E</b>: Edit item</p>\n") + |
1396 | i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + | 1177 | i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + |
1397 | i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + | 1178 | i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + |
1398 | i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ | 1179 | i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ |
1399 | i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ | 1180 | i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ |
1400 | i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ | 1181 | i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ |
1401 | i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ | 1182 | i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ |
1402 | i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ | 1183 | i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ |
1403 | i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + | 1184 | i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + |
1404 | i18n("<p><b>White</b>: Item readonly</p>\n"); | 1185 | i18n("<p><b>White</b>: Item readonly</p>\n"); |
1405 | displayText( text, cap); | 1186 | displayText( text, cap); |
1406 | 1187 | ||
1407 | } | 1188 | } |
1408 | void MainWindow::aboutAutoSaving() | 1189 | void MainWindow::aboutAutoSaving() |
1409 | { | 1190 | { |
1410 | QMessageBox* msg; | 1191 | QMessageBox* msg; |
1411 | msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"), | 1192 | msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"), |
1412 | i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configureable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"), QMessageBox::NoIcon, | 1193 | i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configureable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"), QMessageBox::NoIcon, |
1413 | QMessageBox::Ok, | 1194 | QMessageBox::Ok, |
1414 | QMessageBox::NoButton, | 1195 | QMessageBox::NoButton, |
1415 | QMessageBox::NoButton); | 1196 | QMessageBox::NoButton); |
1416 | msg->exec(); | 1197 | msg->exec(); |
1417 | delete msg; | 1198 | delete msg; |
1418 | 1199 | ||
1419 | 1200 | ||
1420 | } | 1201 | } |
1421 | void MainWindow::aboutKnownBugs() | 1202 | void MainWindow::aboutKnownBugs() |
1422 | { | 1203 | { |
1423 | QMessageBox* msg; | 1204 | QMessageBox* msg; |
1424 | msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), | 1205 | msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), |
1425 | i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ | 1206 | i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ |
1426 | i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ | 1207 | i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ |
1427 | i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + | 1208 | i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + |
1428 | i18n("\nor report them in the bugtracker on\n") + | 1209 | i18n("\nor report them in the bugtracker on\n") + |
1429 | i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), | 1210 | i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), |
1430 | QMessageBox::NoIcon, | 1211 | QMessageBox::NoIcon, |
1431 | QMessageBox::Ok, | 1212 | QMessageBox::Ok, |
1432 | QMessageBox::NoButton, | 1213 | QMessageBox::NoButton, |
1433 | QMessageBox::NoButton); | 1214 | QMessageBox::NoButton); |
1434 | msg->exec(); | 1215 | msg->exec(); |
1435 | delete msg; | 1216 | delete msg; |
1436 | 1217 | ||
1437 | } | 1218 | } |
1438 | 1219 | ||
1439 | QString MainWindow::defaultFileName() | 1220 | QString MainWindow::defaultFileName() |
1440 | { | 1221 | { |
1441 | return locateLocal( "data", "korganizer/mycalendar.ics" ); | 1222 | return locateLocal( "data", "korganizer/mycalendar.ics" ); |
1442 | } | 1223 | } |
1443 | QString MainWindow::syncFileName() | 1224 | QString MainWindow::syncFileName() |
1444 | { | 1225 | { |
1445 | #ifdef _WIN32_ | 1226 | #ifdef _WIN32_ |
1446 | return locateLocal( "tmp", "synccalendar.ics" ); | 1227 | return locateLocal( "tmp", "synccalendar.ics" ); |
1447 | #else | 1228 | #else |
1448 | return QString( "/tmp/kopitempfile.ics" ); | 1229 | return QString( "/tmp/kopitempfile.ics" ); |
1449 | #endif | 1230 | #endif |
1450 | } | 1231 | } |
1451 | 1232 | ||
1452 | void MainWindow::processIncidenceSelection( Incidence *incidence ) | 1233 | void MainWindow::processIncidenceSelection( Incidence *incidence ) |
1453 | { | 1234 | { |
1454 | if ( !incidence ) { | 1235 | if ( !incidence ) { |
1455 | enableIncidenceActions( false ); | 1236 | enableIncidenceActions( false ); |
1456 | 1237 | ||
1457 | mNewSubTodoAction->setEnabled( false ); | 1238 | mNewSubTodoAction->setEnabled( false ); |
1458 | setCaptionToDates(); | 1239 | setCaptionToDates(); |
1459 | return; | 1240 | return; |
1460 | 1241 | ||
1461 | } | 1242 | } |
1462 | 1243 | ||
1463 | //KGlobal::locale()->formatDateTime(nextA, true); | 1244 | //KGlobal::locale()->formatDateTime(nextA, true); |
1464 | QString startString = ""; | 1245 | QString startString = ""; |
1465 | if ( incidence->type() != "Todo" ) { | 1246 | if ( incidence->type() != "Todo" ) { |
1466 | if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { | 1247 | if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { |
1467 | if ( incidence->doesFloat() ) { | 1248 | if ( incidence->doesFloat() ) { |
1468 | startString += ": "+incidence->dtStartDateStr( true ); | 1249 | startString += ": "+incidence->dtStartDateStr( true ); |
1469 | startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); | 1250 | startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); |
1470 | 1251 | ||
1471 | } else { | 1252 | } else { |
1472 | startString = ": "+incidence->dtStartStr(true); | 1253 | startString = ": "+incidence->dtStartStr(true); |
1473 | startString += " --- "+((Event*)incidence)->dtEndStr(true); | 1254 | startString += " --- "+((Event*)incidence)->dtEndStr(true); |
1474 | 1255 | ||
1475 | } | 1256 | } |
1476 | 1257 | ||
1477 | } else { | 1258 | } else { |
1478 | if ( incidence->dtStart().time() != incidence->dtEnd().time() ) | 1259 | if ( incidence->dtStart().time() != incidence->dtEnd().time() ) |
1479 | startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ | 1260 | startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ |
1480 | "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); | 1261 | "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); |
1481 | startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); | 1262 | startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); |
1482 | } | 1263 | } |
1483 | 1264 | ||
1484 | } | 1265 | } |
1485 | else | 1266 | else |
1486 | startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); | 1267 | startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); |
1487 | if ( !incidence->location().isEmpty() ) | 1268 | if ( !incidence->location().isEmpty() ) |
1488 | startString += " (" +incidence->location()+")"; | 1269 | startString += " (" +incidence->location()+")"; |
1489 | setCaption( incidence->summary()+startString); | 1270 | setCaption( incidence->summary()+startString); |
1490 | 1271 | ||
1491 | enableIncidenceActions( true ); | 1272 | enableIncidenceActions( true ); |
1492 | 1273 | ||
1493 | if ( incidence->type() == "Event" ) { | 1274 | if ( incidence->type() == "Event" ) { |
1494 | mShowAction->setText( i18n("Show Event...") ); | 1275 | mShowAction->setText( i18n("Show Event...") ); |
1495 | mEditAction->setText( i18n("Edit Event...") ); | 1276 | mEditAction->setText( i18n("Edit Event...") ); |
1496 | mDeleteAction->setText( i18n("Delete Event...") ); | 1277 | mDeleteAction->setText( i18n("Delete Event...") ); |
1497 | 1278 | ||
1498 | mNewSubTodoAction->setEnabled( false ); | 1279 | mNewSubTodoAction->setEnabled( false ); |
1499 | } else if ( incidence->type() == "Todo" ) { | 1280 | } else if ( incidence->type() == "Todo" ) { |
1500 | mShowAction->setText( i18n("Show Todo...") ); | 1281 | mShowAction->setText( i18n("Show Todo...") ); |
1501 | mEditAction->setText( i18n("Edit Todo...") ); | 1282 | mEditAction->setText( i18n("Edit Todo...") ); |
1502 | mDeleteAction->setText( i18n("Delete Todo...") ); | 1283 | mDeleteAction->setText( i18n("Delete Todo...") ); |
1503 | 1284 | ||
1504 | mNewSubTodoAction->setEnabled( true ); | 1285 | mNewSubTodoAction->setEnabled( true ); |
1505 | } else { | 1286 | } else { |
1506 | mShowAction->setText( i18n("Show...") ); | 1287 | mShowAction->setText( i18n("Show...") ); |
1507 | mShowAction->setText( i18n("Edit...") ); | 1288 | mShowAction->setText( i18n("Edit...") ); |
1508 | mShowAction->setText( i18n("Delete...") ); | 1289 | mShowAction->setText( i18n("Delete...") ); |
1509 | 1290 | ||
1510 | mNewSubTodoAction->setEnabled( false ); | 1291 | mNewSubTodoAction->setEnabled( false ); |
1511 | } | 1292 | } |
1512 | } | 1293 | } |
1513 | 1294 | ||
1514 | void MainWindow::enableIncidenceActions( bool enabled ) | 1295 | void MainWindow::enableIncidenceActions( bool enabled ) |
1515 | { | 1296 | { |
1516 | mShowAction->setEnabled( enabled ); | 1297 | mShowAction->setEnabled( enabled ); |
1517 | mEditAction->setEnabled( enabled ); | 1298 | mEditAction->setEnabled( enabled ); |
1518 | mDeleteAction->setEnabled( enabled ); | 1299 | mDeleteAction->setEnabled( enabled ); |
1519 | 1300 | ||
1520 | mCloneAction->setEnabled( enabled ); | 1301 | mCloneAction->setEnabled( enabled ); |
1521 | mMoveAction->setEnabled( enabled ); | 1302 | mMoveAction->setEnabled( enabled ); |
1522 | mBeamAction->setEnabled( enabled ); | 1303 | mBeamAction->setEnabled( enabled ); |
1523 | mCancelAction->setEnabled( enabled ); | 1304 | mCancelAction->setEnabled( enabled ); |
1524 | } | 1305 | } |
1525 | 1306 | ||
1526 | void MainWindow::importOL() | 1307 | void MainWindow::importOL() |
1527 | { | 1308 | { |
1528 | #ifdef _WIN32_ | 1309 | #ifdef _WIN32_ |
1529 | KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); | 1310 | KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); |
1530 | id->exec(); | 1311 | id->exec(); |
1531 | delete id; | 1312 | delete id; |
1532 | mView->updateView(); | 1313 | mView->updateView(); |
1533 | #endif | 1314 | #endif |
1534 | } | 1315 | } |
1535 | void MainWindow::importBday() | 1316 | void MainWindow::importBday() |
1536 | { | 1317 | { |
1537 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1318 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1538 | i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), | 1319 | i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), |
1539 | i18n("Import!"), i18n("Cancel"), 0, | 1320 | i18n("Import!"), i18n("Cancel"), 0, |
1540 | 0, 1 ); | 1321 | 0, 1 ); |
1541 | if ( result == 0 ) { | 1322 | if ( result == 0 ) { |
1542 | mView->importBday(); | 1323 | mView->importBday(); |
1543 | 1324 | ||
1544 | } | 1325 | } |
1545 | 1326 | ||
1546 | 1327 | ||
1547 | } | 1328 | } |
1548 | void MainWindow::importQtopia() | 1329 | void MainWindow::importQtopia() |
1549 | { | 1330 | { |
1550 | #ifndef DESKTOP_VERSION | 1331 | #ifndef DESKTOP_VERSION |
1551 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1332 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1552 | i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"), | 1333 | i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"), |
1553 | i18n("Import!"), i18n("Cancel"), 0, | 1334 | i18n("Import!"), i18n("Cancel"), 0, |
1554 | 0, 1 ); | 1335 | 0, 1 ); |
1555 | if ( result == 0 ) { | 1336 | if ( result == 0 ) { |
1556 | QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); | 1337 | QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); |
1557 | QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); | 1338 | QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); |
1558 | QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; | 1339 | QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; |
1559 | mView->importQtopia( categories, datebook, todolist ); | 1340 | mView->importQtopia( categories, datebook, todolist ); |
1560 | } | 1341 | } |
1561 | #else | 1342 | #else |
1562 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1343 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1563 | i18n("Not supported \non desktop!\n"), | 1344 | i18n("Not supported \non desktop!\n"), |
1564 | i18n("Ok"), i18n("Cancel"), 0, | 1345 | i18n("Ok"), i18n("Cancel"), 0, |
1565 | 0, 1 ); | 1346 | 0, 1 ); |
1566 | 1347 | ||
1567 | #endif | 1348 | #endif |
1568 | } | 1349 | } |
1569 | 1350 | ||
1570 | void MainWindow::saveOnClose() | 1351 | void MainWindow::saveOnClose() |
1571 | { | 1352 | { |
1572 | KOPrefs *p = KOPrefs::instance(); | 1353 | KOPrefs *p = KOPrefs::instance(); |
1573 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); | 1354 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); |
1574 | p->mToolBarUp = iconToolBar->x() > width()/2 || | 1355 | p->mToolBarUp = iconToolBar->x() > width()/2 || |
1575 | iconToolBar->y() > height()/2; | 1356 | iconToolBar->y() > height()/2; |
1576 | mView->writeSettings(); | 1357 | mView->writeSettings(); |
1577 | if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) | 1358 | if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) |
1578 | save(); | 1359 | save(); |
1579 | } | 1360 | } |
1580 | void MainWindow::slotModifiedChanged( bool changed ) | 1361 | void MainWindow::slotModifiedChanged( bool changed ) |
1581 | { | 1362 | { |
1582 | if ( mBlockAtStartup ) | 1363 | if ( mBlockAtStartup ) |
1583 | return; | 1364 | return; |
1584 | int msec; | 1365 | int msec; |
1585 | // we store the changes after 1 minute, | 1366 | // we store the changes after 1 minute, |
1586 | // and for safety reasons after 10 minutes again | 1367 | // and for safety reasons after 10 minutes again |
1587 | if ( !mBlockSaveFlag ) | 1368 | if ( !mSyncManager->blockSave() ) |
1588 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; | 1369 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; |
1589 | else | 1370 | else |
1590 | msec = 1000 * 600; | 1371 | msec = 1000 * 600; |
1591 | mSaveTimer.start( msec, true ); // 1 minute | 1372 | mSaveTimer.start( msec, true ); // 1 minute |
1592 | qDebug("KO: Saving File in %d secs!", msec/1000); | 1373 | qDebug("KO: Saving File in %d secs!", msec/1000); |
1593 | mCalendarModifiedFlag = true; | 1374 | mCalendarModifiedFlag = true; |
1594 | } | 1375 | } |
1595 | void MainWindow::save() | 1376 | void MainWindow::save() |
1596 | { | 1377 | { |
1597 | if ( mBlockSaveFlag ) | 1378 | if ( mSyncManager->blockSave() ) |
1598 | return; | 1379 | return; |
1599 | bool store = mBlockSaveFlag; | 1380 | mSyncManager->setBlockSave(true); |
1600 | mBlockSaveFlag = true; | ||
1601 | if ( mView->checkFileVersion( defaultFileName()) ) { | 1381 | if ( mView->checkFileVersion( defaultFileName()) ) { |
1602 | 1382 | ||
1603 | QTime neededSaveTime = QDateTime::currentDateTime().time(); | 1383 | QTime neededSaveTime = QDateTime::currentDateTime().time(); |
1604 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); | 1384 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); |
1605 | qDebug("KO: Start saving data to file!"); | 1385 | qDebug("KO: Start saving data to file!"); |
1606 | mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); | 1386 | mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); |
1607 | mView->saveCalendar( defaultFileName() ); | 1387 | mView->saveCalendar( defaultFileName() ); |
1608 | 1388 | ||
1609 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | 1389 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); |
1610 | mView->watchSavedFile(); | 1390 | mView->watchSavedFile(); |
1611 | qDebug("KO: Needed %d ms for saving.",msNeeded ); | 1391 | qDebug("KO: Needed %d ms for saving.",msNeeded ); |
1612 | QString savemes; | 1392 | QString savemes; |
1613 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); | 1393 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); |
1614 | setCaption(savemes); | 1394 | setCaption(savemes); |
1615 | } else | 1395 | } else |
1616 | setCaption(i18n("Saving cancelled!")); | 1396 | setCaption(i18n("Saving cancelled!")); |
1617 | mCalendarModifiedFlag = false; | 1397 | mCalendarModifiedFlag = false; |
1618 | mBlockSaveFlag = store; | 1398 | mSyncManager->setBlockSave( false ); |
1619 | } | 1399 | } |
1620 | 1400 | ||
1621 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) | 1401 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) |
1622 | { | 1402 | { |
1623 | if ( !e->isAutoRepeat() ) { | 1403 | if ( !e->isAutoRepeat() ) { |
1624 | mFlagKeyPressed = false; | 1404 | mFlagKeyPressed = false; |
1625 | } | 1405 | } |
1626 | } | 1406 | } |
1627 | void MainWindow::keyPressEvent ( QKeyEvent * e ) | 1407 | void MainWindow::keyPressEvent ( QKeyEvent * e ) |
1628 | { | 1408 | { |
1629 | qApp->processEvents(); | 1409 | qApp->processEvents(); |
1630 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | 1410 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { |
1631 | e->ignore(); | 1411 | e->ignore(); |
1632 | // qDebug(" ignore %d",e->isAutoRepeat() ); | 1412 | // qDebug(" ignore %d",e->isAutoRepeat() ); |
1633 | return; | 1413 | return; |
1634 | } | 1414 | } |
1635 | if (! e->isAutoRepeat() ) | 1415 | if (! e->isAutoRepeat() ) |
1636 | mFlagKeyPressed = true; | 1416 | mFlagKeyPressed = true; |
1637 | KOPrefs *p = KOPrefs::instance(); | 1417 | KOPrefs *p = KOPrefs::instance(); |
1638 | bool showSelectedDates = false; | 1418 | bool showSelectedDates = false; |
1639 | int size; | 1419 | int size; |
1640 | int pro = 0; | 1420 | int pro = 0; |
1641 | //qDebug("MainWindow::keyPressEvent "); | 1421 | //qDebug("MainWindow::keyPressEvent "); |
1642 | switch ( e->key() ) { | 1422 | switch ( e->key() ) { |
1643 | case Qt::Key_Right: | 1423 | case Qt::Key_Right: |
1644 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 1424 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
1645 | mView->goNextMonth(); | 1425 | mView->goNextMonth(); |
1646 | else | 1426 | else |
1647 | mView->goNext(); | 1427 | mView->goNext(); |
1648 | showSelectedDates = true; | 1428 | showSelectedDates = true; |
1649 | break; | 1429 | break; |
1650 | case Qt::Key_Left: | 1430 | case Qt::Key_Left: |
1651 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1431 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1652 | mView->goPreviousMonth(); | 1432 | mView->goPreviousMonth(); |
1653 | else | 1433 | else |
1654 | mView->goPrevious(); | 1434 | mView->goPrevious(); |
1655 | showSelectedDates = true; | 1435 | showSelectedDates = true; |
1656 | break; | 1436 | break; |
1657 | case Qt::Key_Down: | 1437 | case Qt::Key_Down: |
1658 | mView->viewManager()->agendaView()->scrollOneHourDown(); | 1438 | mView->viewManager()->agendaView()->scrollOneHourDown(); |
1659 | break; | 1439 | break; |
1660 | case Qt::Key_Up: | 1440 | case Qt::Key_Up: |
1661 | mView->viewManager()->agendaView()->scrollOneHourUp(); | 1441 | mView->viewManager()->agendaView()->scrollOneHourUp(); |
1662 | break; | 1442 | break; |
1663 | case Qt::Key_I: | 1443 | case Qt::Key_I: |
1664 | mView->showIncidence(); | 1444 | mView->showIncidence(); |
1665 | break; | 1445 | break; |
1666 | case Qt::Key_Delete: | 1446 | case Qt::Key_Delete: |
1667 | case Qt::Key_Backspace: | 1447 | case Qt::Key_Backspace: |
1668 | mView->deleteIncidence(); | 1448 | mView->deleteIncidence(); |
1669 | break; | 1449 | break; |
1670 | case Qt::Key_D: | 1450 | case Qt::Key_D: |
1671 | mView->viewManager()->showDayView(); | 1451 | mView->viewManager()->showDayView(); |
1672 | showSelectedDates = true; | 1452 | showSelectedDates = true; |
1673 | break; | 1453 | break; |
1674 | case Qt::Key_O: | 1454 | case Qt::Key_O: |
1675 | mView->toggleFilerEnabled( ); | 1455 | mView->toggleFilerEnabled( ); |
1676 | break; | 1456 | break; |
1677 | case Qt::Key_0: | 1457 | case Qt::Key_0: |
1678 | case Qt::Key_1: | 1458 | case Qt::Key_1: |
1679 | case Qt::Key_2: | 1459 | case Qt::Key_2: |
1680 | case Qt::Key_3: | 1460 | case Qt::Key_3: |
1681 | case Qt::Key_4: | 1461 | case Qt::Key_4: |
1682 | case Qt::Key_5: | 1462 | case Qt::Key_5: |
1683 | case Qt::Key_6: | 1463 | case Qt::Key_6: |
1684 | case Qt::Key_7: | 1464 | case Qt::Key_7: |
1685 | case Qt::Key_8: | 1465 | case Qt::Key_8: |
1686 | case Qt::Key_9: | 1466 | case Qt::Key_9: |
1687 | pro = e->key()-48; | 1467 | pro = e->key()-48; |
1688 | if ( pro == 0 ) | 1468 | if ( pro == 0 ) |
1689 | pro = 10; | 1469 | pro = 10; |
1690 | if ( e->state() == Qt::ControlButton) | 1470 | if ( e->state() == Qt::ControlButton) |
1691 | pro += 10; | 1471 | pro += 10; |
1692 | break; | 1472 | break; |
1693 | case Qt::Key_M: | 1473 | case Qt::Key_M: |
1694 | mView->viewManager()->showMonthView(); | 1474 | mView->viewManager()->showMonthView(); |
1695 | showSelectedDates = true; | 1475 | showSelectedDates = true; |
1696 | break; | 1476 | break; |
1697 | case Qt::Key_Insert: | 1477 | case Qt::Key_Insert: |
1698 | mView->newEvent(); | 1478 | mView->newEvent(); |
1699 | break; | 1479 | break; |
1700 | case Qt::Key_S : | 1480 | case Qt::Key_S : |
1701 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 1481 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
1702 | mView->newSubTodo(); | 1482 | mView->newSubTodo(); |
1703 | else | 1483 | else |
1704 | mView->dialogManager()->showSearchDialog(); | 1484 | mView->dialogManager()->showSearchDialog(); |
1705 | break; | 1485 | break; |
1706 | case Qt::Key_Y : | 1486 | case Qt::Key_Y : |
1707 | case Qt::Key_Z : | 1487 | case Qt::Key_Z : |
1708 | mView->viewManager()->showWorkWeekView(); | 1488 | mView->viewManager()->showWorkWeekView(); |
1709 | showSelectedDates = true; | 1489 | showSelectedDates = true; |
1710 | break; | 1490 | break; |
1711 | case Qt::Key_U : | 1491 | case Qt::Key_U : |
1712 | mView->viewManager()->showWeekView(); | 1492 | mView->viewManager()->showWeekView(); |
1713 | showSelectedDates = true; | 1493 | showSelectedDates = true; |
1714 | break; | 1494 | break; |
1715 | case Qt::Key_H : | 1495 | case Qt::Key_H : |
1716 | keyBindings(); | 1496 | keyBindings(); |
1717 | break; | 1497 | break; |
1718 | case Qt::Key_W: | 1498 | case Qt::Key_W: |
1719 | mView->viewManager()->showWhatsNextView(); | 1499 | mView->viewManager()->showWhatsNextView(); |
1720 | break; | 1500 | break; |
1721 | case Qt::Key_L: | 1501 | case Qt::Key_L: |
1722 | mView->viewManager()->showListView(); | 1502 | mView->viewManager()->showListView(); |
1723 | break; | 1503 | break; |
1724 | case Qt::Key_N: | 1504 | case Qt::Key_N: |
1725 | mView->viewManager()->showNextXView(); | 1505 | mView->viewManager()->showNextXView(); |
1726 | showSelectedDates = true; | 1506 | showSelectedDates = true; |
1727 | break; | 1507 | break; |
1728 | case Qt::Key_V: | 1508 | case Qt::Key_V: |
1729 | mView->viewManager()->showTodoView(); | 1509 | mView->viewManager()->showTodoView(); |
1730 | break; | 1510 | break; |
1731 | case Qt::Key_C: | 1511 | case Qt::Key_C: |
1732 | mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); | 1512 | mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); |
1733 | break; | 1513 | break; |
1734 | case Qt::Key_P: | 1514 | case Qt::Key_P: |
1735 | mView->showDatePicker( ); | 1515 | mView->showDatePicker( ); |
1736 | break; | 1516 | break; |
1737 | case Qt::Key_F: | 1517 | case Qt::Key_F: |
1738 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1518 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1739 | mView->editFilters(); | 1519 | mView->editFilters(); |
1740 | else | 1520 | else |
1741 | mView->toggleFilter(); | 1521 | mView->toggleFilter(); |
1742 | break; | 1522 | break; |
1743 | case Qt::Key_X: | 1523 | case Qt::Key_X: |
1744 | mView->toggleDateNavigatorWidget(); | 1524 | mView->toggleDateNavigatorWidget(); |
1745 | break; | 1525 | break; |
1746 | case Qt::Key_Space: | 1526 | case Qt::Key_Space: |
1747 | mView->toggleExpand(); | 1527 | mView->toggleExpand(); |
1748 | break; | 1528 | break; |
1749 | case Qt::Key_A: | 1529 | case Qt::Key_A: |
1750 | mView->toggleAllDaySize(); | 1530 | mView->toggleAllDaySize(); |
1751 | break; | 1531 | break; |
1752 | case Qt::Key_T: | 1532 | case Qt::Key_T: |
1753 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1533 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1754 | mView->newTodo(); | 1534 | mView->newTodo(); |
1755 | else { | 1535 | else { |
1756 | mView->goToday(); | 1536 | mView->goToday(); |
1757 | showSelectedDates = true; | 1537 | showSelectedDates = true; |
1758 | } | 1538 | } |
1759 | break; | 1539 | break; |
1760 | case Qt::Key_J: | 1540 | case Qt::Key_J: |
1761 | mView->viewManager()->showJournalView(); | 1541 | mView->viewManager()->showJournalView(); |
1762 | break; | 1542 | break; |
1763 | case Qt::Key_B: | 1543 | case Qt::Key_B: |
1764 | mView->editIncidenceDescription();; | 1544 | mView->editIncidenceDescription();; |
1765 | break; | 1545 | break; |
1766 | // case Qt::Key_Return: | 1546 | // case Qt::Key_Return: |
1767 | case Qt::Key_E: | 1547 | case Qt::Key_E: |
1768 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1548 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1769 | mView->newEvent(); | 1549 | mView->newEvent(); |
1770 | else | 1550 | else |
1771 | mView->editIncidence(); | 1551 | mView->editIncidence(); |
1772 | break; | 1552 | break; |
1773 | case Qt::Key_Plus: | 1553 | case Qt::Key_Plus: |
1774 | size = p->mHourSize +2; | 1554 | size = p->mHourSize +2; |
1775 | if ( size <= 18 ) | 1555 | if ( size <= 18 ) |
1776 | configureAgenda( size ); | 1556 | configureAgenda( size ); |
1777 | break; | 1557 | break; |
1778 | case Qt::Key_Minus: | 1558 | case Qt::Key_Minus: |
1779 | size = p->mHourSize - 2; | 1559 | size = p->mHourSize - 2; |
1780 | if ( size >= 4 ) | 1560 | if ( size >= 4 ) |
1781 | configureAgenda( size ); | 1561 | configureAgenda( size ); |
1782 | break; | 1562 | break; |
1783 | 1563 | ||
1784 | 1564 | ||
1785 | default: | 1565 | default: |
1786 | e->ignore(); | 1566 | e->ignore(); |
1787 | } | 1567 | } |
1788 | if ( pro > 0 ) { | 1568 | if ( pro > 0 ) { |
1789 | mView->selectFilter( pro-1 ); | 1569 | mView->selectFilter( pro-1 ); |
1790 | } | 1570 | } |
1791 | if ( showSelectedDates ) { | 1571 | if ( showSelectedDates ) { |
1792 | ;// setCaptionToDates(); | 1572 | ;// setCaptionToDates(); |
1793 | } | 1573 | } |
1794 | 1574 | ||
1795 | } | 1575 | } |
1796 | 1576 | ||
1797 | void MainWindow::fillFilterMenu() | 1577 | void MainWindow::fillFilterMenu() |
1798 | { | 1578 | { |
1799 | selectFilterMenu->clear(); | 1579 | selectFilterMenu->clear(); |
1800 | bool disable = false; | 1580 | bool disable = false; |
1801 | if ( mView->filterView()->filtersEnabled() ) { | 1581 | if ( mView->filterView()->filtersEnabled() ) { |
1802 | selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 ); | 1582 | selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 ); |
1803 | } | 1583 | } |
1804 | else { | 1584 | else { |
1805 | selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 ); | 1585 | selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 ); |
1806 | disable = true; | 1586 | disable = true; |
1807 | } | 1587 | } |
1808 | selectFilterMenu->insertSeparator(); | 1588 | selectFilterMenu->insertSeparator(); |
1809 | QPtrList<CalFilter> fili = mView->filters(); | 1589 | QPtrList<CalFilter> fili = mView->filters(); |
1810 | CalFilter *curfilter = mView->filterView()->selectedFilter(); | 1590 | CalFilter *curfilter = mView->filterView()->selectedFilter(); |
1811 | CalFilter *filter = fili.first(); | 1591 | CalFilter *filter = fili.first(); |
1812 | int iii = 1; | 1592 | int iii = 1; |
1813 | while(filter) { | 1593 | while(filter) { |
1814 | selectFilterMenu->insertItem( filter->name(), iii ); | 1594 | selectFilterMenu->insertItem( filter->name(), iii ); |
1815 | if ( filter == curfilter) | 1595 | if ( filter == curfilter) |
1816 | selectFilterMenu->setItemChecked( iii, true ); | 1596 | selectFilterMenu->setItemChecked( iii, true ); |
1817 | if ( disable ) | 1597 | if ( disable ) |
1818 | selectFilterMenu->setItemEnabled( iii, false ); | 1598 | selectFilterMenu->setItemEnabled( iii, false ); |
1819 | filter = fili.next(); | 1599 | filter = fili.next(); |
1820 | ++iii; | 1600 | ++iii; |
1821 | } | 1601 | } |
1822 | } | 1602 | } |
1823 | void MainWindow::selectFilter( int fil ) | 1603 | void MainWindow::selectFilter( int fil ) |
1824 | { | 1604 | { |
1825 | if ( fil == 0 ) { | 1605 | if ( fil == 0 ) { |
1826 | mView->toggleFilerEnabled( ); | 1606 | mView->toggleFilerEnabled( ); |
1827 | } else { | 1607 | } else { |
1828 | mView->selectFilter( fil-1 ); | 1608 | mView->selectFilter( fil-1 ); |
1829 | } | 1609 | } |
1830 | } | 1610 | } |
1831 | void MainWindow::configureToolBar( int item ) | 1611 | void MainWindow::configureToolBar( int item ) |
1832 | { | 1612 | { |
1833 | 1613 | ||
1834 | configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); | 1614 | configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); |
1835 | KOPrefs *p = KOPrefs::instance(); | 1615 | KOPrefs *p = KOPrefs::instance(); |
1836 | p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); | 1616 | p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); |
1837 | p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); | 1617 | p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); |
1838 | p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); | 1618 | p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); |
1839 | p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); | 1619 | p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); |
1840 | p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); | 1620 | p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); |
1841 | p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); | 1621 | p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); |
1842 | p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); | 1622 | p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); |
1843 | p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); | 1623 | p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); |
1844 | p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); | 1624 | p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); |
1845 | p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); | 1625 | p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); |
1846 | p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); | 1626 | p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); |
1847 | p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); | 1627 | p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); |
1848 | p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); | 1628 | p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); |
1849 | p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); | 1629 | p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); |
1850 | p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); | 1630 | p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); |
1851 | p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); | 1631 | p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); |
1852 | p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); | 1632 | p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); |
1853 | p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); | 1633 | p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); |
1854 | p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); | 1634 | p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); |
1855 | // initActions(); | 1635 | // initActions(); |
1856 | } | 1636 | } |
1857 | 1637 | ||
1858 | void MainWindow::setCaptionToDates() | 1638 | void MainWindow::setCaptionToDates() |
1859 | { | 1639 | { |
1860 | QString selDates; | 1640 | QString selDates; |
1861 | selDates = KGlobal::locale()->formatDate(mView->startDate(), true); | 1641 | selDates = KGlobal::locale()->formatDate(mView->startDate(), true); |
1862 | if (mView->startDate() < mView->endDate() ) | 1642 | if (mView->startDate() < mView->endDate() ) |
1863 | selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); | 1643 | selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); |
1864 | setCaption( i18n("Dates: ") + selDates ); | 1644 | setCaption( i18n("Dates: ") + selDates ); |
1865 | 1645 | ||
1866 | } | 1646 | } |
1867 | // parameter item == 0: reinit | 1647 | // parameter item == 0: reinit |
1868 | void MainWindow::configureAgenda( int item ) | 1648 | void MainWindow::configureAgenda( int item ) |
1869 | { | 1649 | { |
1870 | 1650 | ||
1871 | KOPrefs *p = KOPrefs::instance(); | 1651 | KOPrefs *p = KOPrefs::instance(); |
1872 | 1652 | ||
1873 | int i; | 1653 | int i; |
1874 | if ( item == 1 ) { | 1654 | if ( item == 1 ) { |
1875 | mView->toggleAllDaySize(); | 1655 | mView->toggleAllDaySize(); |
1876 | return; | 1656 | return; |
1877 | } | 1657 | } |
1878 | // do not allow 4 for widgets higher than 480 | 1658 | // do not allow 4 for widgets higher than 480 |
1879 | // if ( QApplication::desktop()->height() > 480 ) { | 1659 | // if ( QApplication::desktop()->height() > 480 ) { |
1880 | // if ( item == 4 ) | 1660 | // if ( item == 4 ) |
1881 | // item = 6; | 1661 | // item = 6; |
1882 | // } | 1662 | // } |
1883 | for ( i = 4; i <= 18; i= i+2 ) | 1663 | for ( i = 4; i <= 18; i= i+2 ) |
1884 | configureAgendaMenu->setItemChecked( i, false ); | 1664 | configureAgendaMenu->setItemChecked( i, false ); |
1885 | configureAgendaMenu->setItemChecked( item, true ); | 1665 | configureAgendaMenu->setItemChecked( item, true ); |
1886 | if ( p->mHourSize == item ) | 1666 | if ( p->mHourSize == item ) |
1887 | return; | 1667 | return; |
1888 | p->mHourSize=item; | 1668 | p->mHourSize=item; |
1889 | mView->viewManager()->agendaView()->updateConfig(); | 1669 | mView->viewManager()->agendaView()->updateConfig(); |
1890 | } | 1670 | } |
1891 | 1671 | ||
1892 | void MainWindow::saveCalendar() | 1672 | void MainWindow::saveCalendar() |
1893 | { | 1673 | { |
1894 | QString fn = KOPrefs::instance()->mLastSaveFile; | 1674 | QString fn = KOPrefs::instance()->mLastSaveFile; |
1895 | fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); | 1675 | fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); |
1896 | 1676 | ||
1897 | if ( fn == "" ) | 1677 | if ( fn == "" ) |
1898 | return; | 1678 | return; |
1899 | QFileInfo info; | 1679 | QFileInfo info; |
1900 | info.setFile( fn ); | 1680 | info.setFile( fn ); |
1901 | QString mes; | 1681 | QString mes; |
1902 | bool createbup = true; | 1682 | bool createbup = true; |
1903 | if ( info. exists() ) { | 1683 | if ( info. exists() ) { |
1904 | mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; | 1684 | mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; |
1905 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 1685 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
1906 | i18n("Overwrite!"), i18n("Cancel"), 0, | 1686 | i18n("Overwrite!"), i18n("Cancel"), 0, |
1907 | 0, 1 ); | 1687 | 0, 1 ); |
1908 | if ( result != 0 ) { | 1688 | if ( result != 0 ) { |
1909 | createbup = false; | 1689 | createbup = false; |
1910 | } | 1690 | } |
1911 | } | 1691 | } |
1912 | if ( createbup ) { | 1692 | if ( createbup ) { |
1913 | mView->saveCalendar( fn ); | 1693 | mView->saveCalendar( fn ); |
1914 | mes = i18n("KO/Pi:Saved %1").arg(fn); | 1694 | mes = i18n("KO/Pi:Saved %1").arg(fn); |
1915 | KOPrefs::instance()->mLastSaveFile = fn; | 1695 | KOPrefs::instance()->mLastSaveFile = fn; |
1916 | setCaption(mes); | 1696 | setCaption(mes); |
1917 | } | 1697 | } |
1918 | } | 1698 | } |
1919 | void MainWindow::loadCalendar() | 1699 | void MainWindow::loadCalendar() |
1920 | { | 1700 | { |
1921 | 1701 | ||
1922 | QString fn = KOPrefs::instance()->mLastLoadFile; | 1702 | QString fn = KOPrefs::instance()->mLastLoadFile; |
1923 | fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); | 1703 | fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); |
1924 | 1704 | ||
1925 | if ( fn == "" ) | 1705 | if ( fn == "" ) |
1926 | return; | 1706 | return; |
1927 | QFileInfo info; | 1707 | QFileInfo info; |
1928 | info.setFile( fn ); | 1708 | info.setFile( fn ); |
1929 | QString mess; | 1709 | QString mess; |
1930 | bool loadbup = true; | 1710 | bool loadbup = true; |
1931 | if ( info. exists() ) { | 1711 | if ( info. exists() ) { |
1932 | mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 1712 | mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
1933 | int result = QMessageBox::warning( this, "KO/Pi: Warning!", | 1713 | int result = QMessageBox::warning( this, "KO/Pi: Warning!", |
1934 | mess, | 1714 | mess, |
1935 | i18n("Load!"), i18n("Cancel"), 0, | 1715 | i18n("Load!"), i18n("Cancel"), 0, |
1936 | 0, 1 ); | 1716 | 0, 1 ); |
1937 | if ( result != 0 ) { | 1717 | if ( result != 0 ) { |
1938 | loadbup = false; | 1718 | loadbup = false; |
1939 | } | 1719 | } |
1940 | } else { | 1720 | } else { |
1941 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1721 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1942 | i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, | 1722 | i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, |
1943 | 0, 1 ); | 1723 | 0, 1 ); |
1944 | 1724 | ||
1945 | return; | 1725 | return; |
1946 | } | 1726 | } |
1947 | if ( loadbup ) { | 1727 | if ( loadbup ) { |
1948 | mView->openCalendar( fn ); | 1728 | mView->openCalendar( fn ); |
1949 | KOPrefs::instance()->mLastLoadFile = fn; | 1729 | KOPrefs::instance()->mLastLoadFile = fn; |
1950 | mess = i18n("KO/Pi:Loaded %1").arg(fn) ; | 1730 | mess = i18n("KO/Pi:Loaded %1").arg(fn) ; |
1951 | setCaption(mess); | 1731 | setCaption(mess); |
1952 | } | 1732 | } |
1953 | 1733 | ||
1954 | } | 1734 | } |
1955 | void MainWindow::quickImportIcal() | 1735 | void MainWindow::quickImportIcal() |
1956 | { | 1736 | { |
1957 | importFile( KOPrefs::instance()->mLastImportFile, false ); | 1737 | importFile( KOPrefs::instance()->mLastImportFile, false ); |
1958 | } | 1738 | } |
1959 | void MainWindow::importFile( QString fn, bool quick ) | 1739 | void MainWindow::importFile( QString fn, bool quick ) |
1960 | { | 1740 | { |
1961 | QFileInfo info; | 1741 | QFileInfo info; |
1962 | info.setFile( fn ); | 1742 | info.setFile( fn ); |
1963 | QString mess; | 1743 | QString mess; |
1964 | bool loadbup = true; | 1744 | bool loadbup = true; |
1965 | if ( !info. exists() ) { | 1745 | if ( !info. exists() ) { |
1966 | mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); | 1746 | mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); |
1967 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1747 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1968 | mess ); | 1748 | mess ); |
1969 | return; | 1749 | return; |
1970 | } | 1750 | } |
1971 | int result = 0; | 1751 | int result = 0; |
1972 | if ( !quick ) { | 1752 | if ( !quick ) { |
1973 | mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 1753 | mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
1974 | result = QMessageBox::warning( this, "KO/Pi: Warning!", | 1754 | result = QMessageBox::warning( this, "KO/Pi: Warning!", |
1975 | mess, | 1755 | mess, |
1976 | "Import", "Cancel", 0, | 1756 | "Import", "Cancel", 0, |
1977 | 0, 1 ); | 1757 | 0, 1 ); |
1978 | } | 1758 | } |
1979 | if ( result == 0 ) { | 1759 | if ( result == 0 ) { |
1980 | if ( mView->openCalendar( fn, true )) { | 1760 | if ( mView->openCalendar( fn, true )) { |
1981 | KOPrefs::instance()->mLastImportFile = fn; | 1761 | KOPrefs::instance()->mLastImportFile = fn; |
1982 | setCaption(i18n("Imported file successfully")); | 1762 | setCaption(i18n("Imported file successfully")); |
1983 | } else { | 1763 | } else { |
1984 | setCaption(i18n("Error importing file")); | 1764 | setCaption(i18n("Error importing file")); |
1985 | } | 1765 | } |
1986 | } | 1766 | } |
1987 | } | 1767 | } |
1988 | 1768 | ||
1989 | void MainWindow::importIcal() | 1769 | void MainWindow::importIcal() |
1990 | { | 1770 | { |
1991 | 1771 | ||
1992 | QString fn =KOPrefs::instance()->mLastImportFile; | 1772 | QString fn =KOPrefs::instance()->mLastImportFile; |
1993 | 1773 | ||
1994 | fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); | 1774 | fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); |
1995 | if ( fn == "" ) | 1775 | if ( fn == "" ) |
1996 | return; | 1776 | return; |
1997 | importFile( fn, true ); | 1777 | importFile( fn, true ); |
1998 | 1778 | ||
1999 | } | 1779 | } |
2000 | 1780 | ||
2001 | void MainWindow::exportVCalendar() | 1781 | void MainWindow::exportVCalendar() |
2002 | { | 1782 | { |
2003 | QString fn = KOPrefs::instance()->mLastVcalFile; | 1783 | QString fn = KOPrefs::instance()->mLastVcalFile; |
2004 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); | 1784 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); |
2005 | if ( fn == "" ) | 1785 | if ( fn == "" ) |
2006 | return; | 1786 | return; |
2007 | QFileInfo info; | 1787 | QFileInfo info; |
2008 | info.setFile( fn ); | 1788 | info.setFile( fn ); |
2009 | QString mes; | 1789 | QString mes; |
2010 | bool createbup = true; | 1790 | bool createbup = true; |
2011 | if ( info. exists() ) { | 1791 | if ( info. exists() ) { |
2012 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | 1792 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); |
2013 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 1793 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
2014 | i18n("Overwrite!"), i18n("Cancel"), 0, | 1794 | i18n("Overwrite!"), i18n("Cancel"), 0, |
2015 | 0, 1 ); | 1795 | 0, 1 ); |
2016 | if ( result != 0 ) { | 1796 | if ( result != 0 ) { |
2017 | createbup = false; | 1797 | createbup = false; |
2018 | } | 1798 | } |
2019 | } | 1799 | } |
2020 | if ( createbup ) { | 1800 | if ( createbup ) { |
2021 | if ( mView->exportVCalendar( fn ) ) { | 1801 | if ( mView->exportVCalendar( fn ) ) { |
2022 | KOPrefs::instance()->mLastVcalFile = fn; | 1802 | KOPrefs::instance()->mLastVcalFile = fn; |
2023 | if ( fn.length() > 20 ) | 1803 | if ( fn.length() > 20 ) |
2024 | mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; | 1804 | mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; |
2025 | else | 1805 | else |
2026 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); | 1806 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); |
2027 | setCaption(mes); | 1807 | setCaption(mes); |
2028 | } | 1808 | } |
2029 | } | 1809 | } |
2030 | 1810 | ||
2031 | } | 1811 | } |
2032 | QString MainWindow::getPassword( ) | ||
2033 | { | ||
2034 | QString retfile = ""; | ||
2035 | QDialog dia ( this, "input-dialog", true ); | ||
2036 | QLineEdit lab ( &dia ); | ||
2037 | lab.setEchoMode( QLineEdit::Password ); | ||
2038 | QVBoxLayout lay( &dia ); | ||
2039 | lay.setMargin(7); | ||
2040 | lay.setSpacing(7); | ||
2041 | lay.addWidget( &lab); | ||
2042 | dia.setFixedSize( 230,50 ); | ||
2043 | dia.setCaption( i18n("Enter password") ); | ||
2044 | QPushButton pb ( "OK", &dia); | ||
2045 | lay.addWidget( &pb ); | ||
2046 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | ||
2047 | dia.show(); | ||
2048 | int res = dia.exec(); | ||
2049 | if ( res ) | ||
2050 | retfile = lab.text(); | ||
2051 | dia.hide(); | ||
2052 | qApp->processEvents(); | ||
2053 | return retfile; | ||
2054 | |||
2055 | } | ||
2056 | 1812 | ||
2057 | void MainWindow::enableQuick() | 1813 | void MainWindow::syncFileRequest() |
2058 | { | 1814 | { |
2059 | QDialog dia ( this, "input-dialog", true ); | 1815 | save(); |
2060 | QLineEdit lab ( &dia ); | ||
2061 | QVBoxLayout lay( &dia ); | ||
2062 | lab.setText( KOPrefs::instance()->mPassiveSyncPort ); | ||
2063 | lay.setMargin(7); | ||
2064 | lay.setSpacing(7); | ||
2065 | QLabel label ( i18n("Port number (Default: 9197)"), &dia ); | ||
2066 | lay.addWidget( &label); | ||
2067 | lay.addWidget( &lab); | ||
2068 | |||
2069 | QLineEdit lepw ( &dia ); | ||
2070 | lepw.setText( KOPrefs::instance()->mPassiveSyncPw ); | ||
2071 | QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); | ||
2072 | lay.addWidget( &label2); | ||
2073 | lay.addWidget( &lepw); | ||
2074 | dia.setFixedSize( 230,80 ); | ||
2075 | dia.setCaption( i18n("Enter port for Pi-Sync") ); | ||
2076 | QPushButton pb ( "OK", &dia); | ||
2077 | lay.addWidget( &pb ); | ||
2078 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | ||
2079 | dia.show(); | ||
2080 | if ( ! dia.exec() ) | ||
2081 | return; | ||
2082 | dia.hide(); | ||
2083 | qApp->processEvents(); | ||
2084 | KOPrefs::instance()->mPassiveSyncPw = lepw.text(); | ||
2085 | KOPrefs::instance()->mPassiveSyncPort = lab.text(); | ||
2086 | bool ok; | ||
2087 | Q_UINT16 port = KOPrefs::instance()->mPassiveSyncPort.toUInt(&ok); | ||
2088 | if ( ! ok ) { | ||
2089 | KMessageBox::information( this, i18n("No valid port")); | ||
2090 | return; | ||
2091 | } | ||
2092 | //qDebug("port %d ", port); | ||
2093 | mServerSocket = new KServerSocket ( KOPrefs::instance()->mPassiveSyncPw, port ,1 ); | ||
2094 | mServerSocket->setFileName( defaultFileName() ); | ||
2095 | //qDebug("connected "); | ||
2096 | if ( !mServerSocket->ok() ) { | ||
2097 | KMessageBox::information( this, i18n("Failed to bind or\nlisten to the port!")); | ||
2098 | delete mServerSocket; | ||
2099 | mServerSocket = 0; | ||
2100 | return; | ||
2101 | } | ||
2102 | connect( mServerSocket, SIGNAL ( saveFile() ), this, SLOT ( save() ) ); | ||
2103 | connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SLOT ( getFile( bool ) ) ); | ||
2104 | } | 1816 | } |
2105 | |||
2106 | void MainWindow::getFile( bool success ) | 1817 | void MainWindow::getFile( bool success ) |
2107 | { | 1818 | { |
2108 | if ( ! success ) { | 1819 | if ( ! success ) { |
2109 | setCaption( i18n("Error receiving file. Nothing changed!") ); | 1820 | setCaption( i18n("Error receiving file. Nothing changed!") ); |
2110 | return; | 1821 | return; |
2111 | } | 1822 | } |
2112 | mView->watchSavedFile(); | 1823 | mView->watchSavedFile(); |
2113 | mView->openCalendar( defaultFileName() ); | 1824 | mView->openCalendar( defaultFileName() ); |
2114 | setCaption( i18n("Pi-Sync successful!") ); | 1825 | setCaption( i18n("Pi-Sync successful!") ); |
2115 | 1826 | ||
2116 | } | 1827 | } |
2117 | 1828 | ||
2118 | |||
2119 | void MainWindow::syncPi() | ||
2120 | { | ||
2121 | qApp->processEvents(); | ||
2122 | bool ok; | ||
2123 | Q_UINT16 port = KOPrefs::instance()->mActiveSyncPort.toUInt(&ok); | ||
2124 | if ( ! ok ) { | ||
2125 | setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); | ||
2126 | return; | ||
2127 | } | ||
2128 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, KOPrefs::instance()->mActiveSyncIP, this ); | ||
2129 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); | ||
2130 | setCaption( i18n("Sending request for remote file ...") ); | ||
2131 | commandSocket->readFile( syncFileName() ); | ||
2132 | } | ||
2133 | |||
2134 | void MainWindow::deleteCommandSocket(KCommandSocket*s, int state) | ||
2135 | { | ||
2136 | qDebug("MainWindow::deleteCommandSocket %d", state); | ||
2137 | |||
2138 | //enum { success, errorW, errorR, quiet }; | ||
2139 | if ( state == KCommandSocket::errorR ) { | ||
2140 | setCaption( i18n("ERROR: Receiving remote file failed.") ); | ||
2141 | delete s; | ||
2142 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, KOPrefs::instance()->mActiveSyncPort.toUInt(), KOPrefs::instance()->mActiveSyncIP, this ); | ||
2143 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); | ||
2144 | commandSocket->sendStop(); | ||
2145 | return; | ||
2146 | |||
2147 | } else if ( state == KCommandSocket::errorW ) { | ||
2148 | setCaption( i18n("ERROR:Writing back file failed.") ); | ||
2149 | |||
2150 | } else if ( state == KCommandSocket::successR ) { | ||
2151 | QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); | ||
2152 | |||
2153 | } else if ( state == KCommandSocket::successW ) { | ||
2154 | setCaption( i18n("Pi-Sync succesful!") ); | ||
2155 | } | ||
2156 | |||
2157 | delete s; | ||
2158 | } | ||
2159 | |||
2160 | void MainWindow::readFileFromSocket() | ||
2161 | { | ||
2162 | QString fileName = syncFileName(); | ||
2163 | setCaption( i18n("Remote file saved to temp file.") ); | ||
2164 | if ( ! syncWithFile( fileName , true ) ) { | ||
2165 | setCaption( i18n("Syncing failed.") ); | ||
2166 | qDebug("Syncing failed "); | ||
2167 | return; | ||
2168 | } | ||
2169 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, KOPrefs::instance()->mActiveSyncPort.toUInt(), KOPrefs::instance()->mActiveSyncIP, this ); | ||
2170 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); | ||
2171 | if ( KOPrefs::instance()->mWriteBackFile ) | ||
2172 | commandSocket->writeFile( fileName ); | ||
2173 | else { | ||
2174 | commandSocket->sendStop(); | ||
2175 | setCaption( i18n("Pi-Sync succesful!") ); | ||
2176 | } | ||
2177 | } | ||
2178 | |||
2179 | void MainWindow::syncLocalFile() | ||
2180 | { | ||
2181 | |||
2182 | QString fn =KOPrefs::instance()->mLastSyncedLocalFile; | ||
2183 | |||
2184 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); | ||
2185 | if ( fn == "" ) | ||
2186 | return; | ||
2187 | //mView->setSyncDevice("local-file" ); | ||
2188 | if ( syncWithFile( fn, false ) ) { | ||
2189 | // Event* e = mView->getLastSyncEvent(); | ||
2190 | // e->setReadOnly( false ); | ||
2191 | // e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); | ||
2192 | // e->setReadOnly( true ); | ||
2193 | } | ||
2194 | |||
2195 | } | ||
2196 | |||
2197 | bool MainWindow::syncWithFile( QString fn , bool quick ) | ||
2198 | { | ||
2199 | bool ret = false; | ||
2200 | QFileInfo info; | ||
2201 | info.setFile( fn ); | ||
2202 | QString mess; | ||
2203 | bool loadbup = true; | ||
2204 | if ( !info. exists() ) { | ||
2205 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); | ||
2206 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | ||
2207 | mess ); | ||
2208 | return ret; | ||
2209 | } | ||
2210 | int result = 0; | ||
2211 | if ( !quick ) { | ||
2212 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | ||
2213 | result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | ||
2214 | mess, | ||
2215 | i18n("Sync"), i18n("Cancel"), 0, | ||
2216 | 0, 1 ); | ||
2217 | if ( result ) | ||
2218 | return false; | ||
2219 | } | ||
2220 | if ( KOPrefs::instance()->mAskForPreferences ) | ||
2221 | mView->edit_sync_options(); | ||
2222 | if ( result == 0 ) { | ||
2223 | //qDebug("Now sycing ... "); | ||
2224 | if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) ) | ||
2225 | setCaption( i18n("Synchronization successful") ); | ||
2226 | else | ||
2227 | setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); | ||
2228 | if ( ! quick ) | ||
2229 | KOPrefs::instance()->mLastSyncedLocalFile = fn; | ||
2230 | slotModifiedChanged( true ); | ||
2231 | } | ||
2232 | return ret; | ||
2233 | } | ||
2234 | void MainWindow::quickSyncLocalFile() | ||
2235 | { | ||
2236 | //mView->setSyncDevice("local-file" ); | ||
2237 | //qDebug("quickSyncLocalFile() "); | ||
2238 | if ( syncWithFile( KOPrefs::instance()->mLastSyncedLocalFile, false ) ) { | ||
2239 | // Event* e = mView->getLastSyncEvent(); | ||
2240 | // e->setReadOnly( false ); | ||
2241 | // e->setLocation( i18n("Quick with file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); | ||
2242 | // e->setReadOnly( true ); | ||
2243 | |||
2244 | } | ||
2245 | } | ||
2246 | |||
2247 | void MainWindow::confSync() | ||
2248 | { | ||
2249 | mView->confSync(); | ||
2250 | fillSyncMenu(); | ||
2251 | } | ||
2252 | void MainWindow::syncRemote( KSyncProfile* prof, bool ask) | ||
2253 | { | ||
2254 | QString question; | ||
2255 | if ( ask ) { | ||
2256 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; | ||
2257 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), | ||
2258 | question, | ||
2259 | i18n("Yes"), i18n("No"), | ||
2260 | 0, 0 ) != 0 ) | ||
2261 | return; | ||
2262 | } | ||
2263 | QString command = prof->getPreSyncCommand(); | ||
2264 | int fi; | ||
2265 | if ( (fi = command.find("$PWD$")) > 0 ) { | ||
2266 | QString pwd = getPassword(); | ||
2267 | command = command.left( fi )+ pwd + command.mid( fi+5 ); | ||
2268 | |||
2269 | } | ||
2270 | int maxlen = 30; | ||
2271 | if ( QApplication::desktop()->width() > 320 ) | ||
2272 | maxlen += 25; | ||
2273 | setCaption ( i18n( "Copy remote file to local machine..." ) ); | ||
2274 | int fileSize = 0; | ||
2275 | int result = system ( command ); | ||
2276 | // 0 : okay | ||
2277 | // 256: no such file or dir | ||
2278 | // | ||
2279 | qDebug("KO: Remote copy result(0 = okay): %d ",result ); | ||
2280 | if ( result != 0 ) { | ||
2281 | int len = maxlen; | ||
2282 | while ( len < command.length() ) { | ||
2283 | command.insert( len , "\n" ); | ||
2284 | len += maxlen +2; | ||
2285 | } | ||
2286 | question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; | ||
2287 | QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), | ||
2288 | question, | ||
2289 | i18n("Okay!")) ; | ||
2290 | setCaption ("KO/Pi"); | ||
2291 | return; | ||
2292 | } | ||
2293 | setCaption ( i18n( "Copying succeed." ) ); | ||
2294 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); | ||
2295 | if ( syncWithFile( prof->getLocalTempFile(), true ) ) { | ||
2296 | // Event* e = mView->getLastSyncEvent(); | ||
2297 | // e->setReadOnly( false ); | ||
2298 | // e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); | ||
2299 | // e->setReadOnly( true ); | ||
2300 | if ( KOPrefs::instance()->mWriteBackFile ) { | ||
2301 | command = prof->getPostSyncCommand(); | ||
2302 | int fi; | ||
2303 | if ( (fi = command.find("$PWD$")) > 0 ) { | ||
2304 | QString pwd = getPassword(); | ||
2305 | command = command.left( fi )+ pwd + command.mid( fi+5 ); | ||
2306 | |||
2307 | } | ||
2308 | setCaption ( i18n( "Writing back file ..." ) ); | ||
2309 | result = system ( command ); | ||
2310 | qDebug("KO: Writing back file result: %d ", result); | ||
2311 | if ( result != 0 ) { | ||
2312 | setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); | ||
2313 | return; | ||
2314 | } else { | ||
2315 | setCaption ( i18n( "Syncronization sucessfully completed" ) ); | ||
2316 | } | ||
2317 | } | ||
2318 | } | ||
2319 | return; | ||
2320 | } | ||
2321 | |||
2322 | void MainWindow::syncSharp() | ||
2323 | { | ||
2324 | if ( mCalendarModifiedFlag ) | ||
2325 | save(); | ||
2326 | mView->syncSharp(); | ||
2327 | slotModifiedChanged( true ); | ||
2328 | |||
2329 | } | ||
2330 | void MainWindow::syncPhone() | ||
2331 | { | ||
2332 | if ( mCalendarModifiedFlag ) | ||
2333 | save(); | ||
2334 | mView->syncPhone(); | ||
2335 | slotModifiedChanged( true ); | ||
2336 | |||
2337 | } | ||
2338 | |||
2339 | void MainWindow::printSel( ) | 1829 | void MainWindow::printSel( ) |
2340 | { | 1830 | { |
2341 | mView->viewManager()->agendaView()->agenda()->printSelection(); | 1831 | mView->viewManager()->agendaView()->agenda()->printSelection(); |
2342 | } | 1832 | } |
2343 | 1833 | ||
2344 | void MainWindow::printCal() | 1834 | void MainWindow::printCal() |
2345 | { | 1835 | { |
2346 | mView->print();//mCp->showDialog(); | 1836 | mView->print();//mCp->showDialog(); |
2347 | } | 1837 | } |
2348 | 1838 | ||
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h index 0da0be0..ee7bd87 100644 --- a/korganizer/mainwindow.h +++ b/korganizer/mainwindow.h | |||
@@ -1,148 +1,130 @@ | |||
1 | #ifndef KORGE_MAINWINDOW_H | 1 | #ifndef KORGE_MAINWINDOW_H |
2 | #define KORGE_MAINWINDOW_H | 2 | #define KORGE_MAINWINDOW_H |
3 | 3 | ||
4 | #include <qmainwindow.h> | 4 | #include <qmainwindow.h> |
5 | #include <qtimer.h> | 5 | #include <qtimer.h> |
6 | #include <qdict.h> | 6 | #include <qdict.h> |
7 | #include <qfile.h> | 7 | #include <qfile.h> |
8 | #include <qtextstream.h> | 8 | #include <qtextstream.h> |
9 | #include <qregexp.h> | 9 | #include <qregexp.h> |
10 | 10 | ||
11 | #include <libkcal/incidence.h> | 11 | #include <libkcal/incidence.h> |
12 | #include "simplealarmclient.h" | 12 | #include "simplealarmclient.h" |
13 | #include <ksyncmanager.h> | 13 | #include <ksyncmanager.h> |
14 | 14 | ||
15 | class QAction; | 15 | class QAction; |
16 | class CalendarView; | 16 | class CalendarView; |
17 | class KSyncProfile; | 17 | class KSyncProfile; |
18 | #ifdef DESKTOP_VERSION | 18 | #ifdef DESKTOP_VERSION |
19 | 19 | ||
20 | #define QPEToolBar QToolBar | 20 | #define QPEToolBar QToolBar |
21 | #define QPEMenuBar QMenuBar | 21 | #define QPEMenuBar QMenuBar |
22 | #endif | 22 | #endif |
23 | class QPEToolBar; | 23 | class QPEToolBar; |
24 | 24 | ||
25 | 25 | ||
26 | namespace KCal { | 26 | namespace KCal { |
27 | class CalendarLocal; | 27 | class CalendarLocal; |
28 | } | 28 | } |
29 | 29 | ||
30 | using namespace KCal; | 30 | using namespace KCal; |
31 | 31 | ||
32 | class MainWindow : public QMainWindow | 32 | class MainWindow : public QMainWindow |
33 | { | 33 | { |
34 | Q_OBJECT | 34 | Q_OBJECT |
35 | public: | 35 | public: |
36 | MainWindow( QWidget *parent = 0, const char *name = 0, QString command = ""); | 36 | MainWindow( QWidget *parent = 0, const char *name = 0, QString command = ""); |
37 | ~MainWindow(); | 37 | ~MainWindow(); |
38 | public slots: | 38 | public slots: |
39 | virtual void showMaximized (); | 39 | virtual void showMaximized (); |
40 | void configureAgenda( int ); | 40 | void configureAgenda( int ); |
41 | void recieve( const QCString& msg, const QByteArray& data ); | 41 | void recieve( const QCString& msg, const QByteArray& data ); |
42 | static QString defaultFileName(); | 42 | static QString defaultFileName(); |
43 | static QString syncFileName(); | 43 | static QString syncFileName(); |
44 | static QString resourcePath(); | 44 | static QString resourcePath(); |
45 | protected slots: | 45 | protected slots: |
46 | void setCaptionToDates(); | 46 | void setCaptionToDates(); |
47 | int ringSync(); | ||
48 | void multiSync( bool askforPrefs = false ); | ||
49 | void about(); | 47 | void about(); |
50 | void licence(); | 48 | void licence(); |
51 | void faq(); | 49 | void faq(); |
52 | void usertrans(); | 50 | void usertrans(); |
53 | void features(); | 51 | void features(); |
54 | void synchowto(); | 52 | void synchowto(); |
55 | void whatsNew(); | 53 | void whatsNew(); |
56 | void keyBindings(); | 54 | void keyBindings(); |
57 | void aboutAutoSaving();; | 55 | void aboutAutoSaving();; |
58 | void aboutKnownBugs(); | 56 | void aboutKnownBugs(); |
59 | 57 | ||
60 | void processIncidenceSelection( Incidence * ); | 58 | void processIncidenceSelection( Incidence * ); |
61 | 59 | ||
62 | void importQtopia(); | 60 | void importQtopia(); |
63 | void importBday(); | 61 | void importBday(); |
64 | void importOL(); | 62 | void importOL(); |
65 | void importIcal(); | 63 | void importIcal(); |
66 | void importFile( QString, bool ); | 64 | void importFile( QString, bool ); |
67 | void quickImportIcal(); | 65 | void quickImportIcal(); |
68 | 66 | ||
69 | void slotModifiedChanged( bool ); | 67 | void slotModifiedChanged( bool ); |
70 | 68 | ||
71 | void save(); | 69 | void save(); |
72 | void configureToolBar( int ); | 70 | void configureToolBar( int ); |
73 | void printSel(); | 71 | void printSel(); |
74 | void printCal(); | 72 | void printCal(); |
75 | void saveCalendar(); | 73 | void saveCalendar(); |
76 | void loadCalendar(); | 74 | void loadCalendar(); |
77 | void exportVCalendar(); | 75 | void exportVCalendar(); |
78 | void fillFilterMenu(); | 76 | void fillFilterMenu(); |
79 | void selectFilter( int ); | 77 | void selectFilter( int ); |
80 | void exportToPhone( int ); | 78 | void exportToPhone( int ); |
81 | 79 | ||
82 | void slotSyncMenu( int ); | ||
83 | void confSync(); | ||
84 | void syncSharp(); | ||
85 | void syncPhone(); | ||
86 | void syncPi(); | ||
87 | void syncLocalFile(); | ||
88 | bool syncWithFile( QString, bool ); | ||
89 | void quickSyncLocalFile(); | ||
90 | |||
91 | 80 | ||
92 | protected: | 81 | protected: |
93 | void displayText( QString, QString); | 82 | void displayText( QString, QString); |
94 | void displayFile( QString, QString); | 83 | void displayFile( QString, QString); |
95 | 84 | ||
96 | void enableIncidenceActions( bool ); | 85 | void enableIncidenceActions( bool ); |
97 | 86 | ||
98 | private slots: | 87 | private slots: |
99 | QSocket* piSocket; | 88 | QSocket* piSocket; |
100 | QString piFileString; | 89 | QString piFileString; |
101 | QTime piTime; | 90 | QTime piTime; |
102 | void deleteCommandSocket(KCommandSocket* s, int state ); | ||
103 | void fillSyncMenu(); | ||
104 | void getFile( bool ); | 91 | void getFile( bool ); |
105 | void readFileFromSocket(); | 92 | void syncFileRequest(); |
106 | private: | 93 | private: |
94 | KSyncManager* mSyncManager; | ||
107 | //QTimer* mTimerCommandSocket; | 95 | //QTimer* mTimerCommandSocket; |
108 | QString mPassWordPiSync; | ||
109 | KServerSocket * mServerSocket; | 96 | KServerSocket * mServerSocket; |
110 | bool mClosed; | 97 | bool mClosed; |
111 | void saveOnClose(); | 98 | void saveOnClose(); |
112 | int mCurrentSyncProfile; | ||
113 | void enableQuick(); | ||
114 | void syncRemote( KSyncProfile* , bool ask = true); | ||
115 | bool mFlagKeyPressed; | 99 | bool mFlagKeyPressed; |
116 | bool mBlockAtStartup; | 100 | bool mBlockAtStartup; |
117 | QPEToolBar *iconToolBar; | 101 | QPEToolBar *iconToolBar; |
118 | void initActions(); | 102 | void initActions(); |
119 | void setDefaultPreferences(); | 103 | void setDefaultPreferences(); |
120 | void keyPressEvent ( QKeyEvent * ) ; | 104 | void keyPressEvent ( QKeyEvent * ) ; |
121 | void keyReleaseEvent ( QKeyEvent * ) ; | 105 | void keyReleaseEvent ( QKeyEvent * ) ; |
122 | QPopupMenu *configureToolBarMenu; | 106 | QPopupMenu *configureToolBarMenu; |
123 | QPopupMenu *selectFilterMenu; | 107 | QPopupMenu *selectFilterMenu; |
124 | QPopupMenu *configureAgendaMenu, *syncMenu; | 108 | QPopupMenu *configureAgendaMenu, *syncMenu; |
125 | CalendarLocal *mCalendar; | 109 | CalendarLocal *mCalendar; |
126 | CalendarView *mView; | 110 | CalendarView *mView; |
127 | QString getPassword(); | ||
128 | QAction *mNewSubTodoAction; | 111 | QAction *mNewSubTodoAction; |
129 | 112 | ||
130 | QAction *mShowAction; | 113 | QAction *mShowAction; |
131 | QAction *mEditAction; | 114 | QAction *mEditAction; |
132 | QAction *mDeleteAction; | 115 | QAction *mDeleteAction; |
133 | QAction *mCloneAction; | 116 | QAction *mCloneAction; |
134 | QAction *mMoveAction; | 117 | QAction *mMoveAction; |
135 | QAction *mBeamAction; | 118 | QAction *mBeamAction; |
136 | QAction *mCancelAction; | 119 | QAction *mCancelAction; |
137 | 120 | ||
138 | |||
139 | void closeEvent( QCloseEvent* ce ); | 121 | void closeEvent( QCloseEvent* ce ); |
140 | SimpleAlarmClient mAlarmClient; | 122 | SimpleAlarmClient mAlarmClient; |
141 | QTimer mSaveTimer; | 123 | QTimer mSaveTimer; |
142 | bool mBlockSaveFlag; | 124 | //bool mBlockSaveFlag; |
143 | bool mCalendarModifiedFlag; | 125 | bool mCalendarModifiedFlag; |
144 | QPixmap loadPixmap( QString ); | 126 | QPixmap loadPixmap( QString ); |
145 | }; | 127 | }; |
146 | 128 | ||
147 | 129 | ||
148 | #endif | 130 | #endif |
diff --git a/libkdepim/kpimprefs.cpp b/libkdepim/kpimprefs.cpp index 0a2f5f1..c21ebaa 100644 --- a/libkdepim/kpimprefs.cpp +++ b/libkdepim/kpimprefs.cpp | |||
@@ -1,75 +1,82 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkdepim. | 2 | This file is part of libkdepim. |
3 | Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | /* | 24 | /* |
25 | Enhanced Version of the file for platform independent KDE tools. | 25 | Enhanced Version of the file for platform independent KDE tools. |
26 | Copyright (c) 2004 Ulf Schenk | 26 | Copyright (c) 2004 Ulf Schenk |
27 | 27 | ||
28 | $Id$ | 28 | $Id$ |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <kglobal.h> | 31 | #include <kglobal.h> |
32 | #include <kconfig.h> | 32 | #include <kconfig.h> |
33 | #include <klocale.h> | 33 | #include <klocale.h> |
34 | #include <kdebug.h> | 34 | #include <kdebug.h> |
35 | 35 | ||
36 | #include "kpimprefs.h" | 36 | #include "kpimprefs.h" |
37 | 37 | ||
38 | KPimPrefs::KPimPrefs( const QString &name ) : | 38 | KPimPrefs::KPimPrefs( const QString &name ) : |
39 | KPrefs( name ) | 39 | KPrefs( name ) |
40 | { | 40 | { |
41 | config()->setGroup("General"); | 41 | #ifdef _WIN32_ |
42 | QString hdp= locateLocal("data","korganizer")+"\\\\"; | ||
43 | #else | ||
44 | QString hdp= locateLocal("data","korganizer")+"/"; | ||
45 | #endif | ||
46 | config()->setGroup("SyncOptions"); | ||
42 | addItemString("PassiveSyncPort",&mPassiveSyncPort,"9197" ); | 47 | addItemString("PassiveSyncPort",&mPassiveSyncPort,"9197" ); |
43 | addItemString("PassiveSyncPw",&mPassiveSyncPw,"abc" ); | 48 | addItemString("PassiveSyncPw",&mPassiveSyncPw,"abc" ); |
49 | addItemString("LastSyncedLocalFile", &mLastSyncedLocalFile ,hdp +"lastsync.ics" ); | ||
50 | addItemInt("RingSyncAlgoPrefs",&mRingSyncAlgoPrefs,3); | ||
44 | } | 51 | } |
45 | 52 | ||
46 | KPimPrefs::~KPimPrefs() | 53 | KPimPrefs::~KPimPrefs() |
47 | { | 54 | { |
48 | } | 55 | } |
49 | 56 | ||
50 | void KPimPrefs::usrSetDefaults() | 57 | void KPimPrefs::usrSetDefaults() |
51 | { | 58 | { |
52 | setCategoryDefaults(); | 59 | setCategoryDefaults(); |
53 | } | 60 | } |
54 | 61 | ||
55 | void KPimPrefs::usrReadConfig() | 62 | void KPimPrefs::usrReadConfig() |
56 | { | 63 | { |
57 | kdDebug(5300) << "KPimPrefs::usrReadConfig()" << endl; | 64 | kdDebug(5300) << "KPimPrefs::usrReadConfig()" << endl; |
58 | 65 | ||
59 | config()->setGroup("General"); | 66 | config()->setGroup("General"); |
60 | mCustomCategories = config()->readListEntry("Custom Categories"); | 67 | mCustomCategories = config()->readListEntry("Custom Categories"); |
61 | if (mCustomCategories.isEmpty()) setCategoryDefaults(); | 68 | if (mCustomCategories.isEmpty()) setCategoryDefaults(); |
62 | } | 69 | } |
63 | 70 | ||
64 | 71 | ||
65 | void KPimPrefs::usrWriteConfig() | 72 | void KPimPrefs::usrWriteConfig() |
66 | { | 73 | { |
67 | config()->setGroup("General"); | 74 | config()->setGroup("General"); |
68 | config()->writeEntry("Custom Categories",mCustomCategories); | 75 | config()->writeEntry("Custom Categories",mCustomCategories); |
69 | } | 76 | } |
70 | 77 | ||
71 | void KPimPrefs::setCategoryDefaults() | 78 | void KPimPrefs::setCategoryDefaults() |
72 | { | 79 | { |
73 | // empty implementation | 80 | // empty implementation |
74 | } | 81 | } |
75 | 82 | ||
diff --git a/libkdepim/kpimprefs.h b/libkdepim/kpimprefs.h index fde8093..9346f7d 100644 --- a/libkdepim/kpimprefs.h +++ b/libkdepim/kpimprefs.h | |||
@@ -1,70 +1,71 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkdepim. | 2 | This file is part of libkdepim. |
3 | Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | /* | 24 | /* |
25 | Enhanced Version of the file for platform independent KDE tools. | 25 | Enhanced Version of the file for platform independent KDE tools. |
26 | Copyright (c) 2004 Ulf Schenk | 26 | Copyright (c) 2004 Ulf Schenk |
27 | 27 | ||
28 | $Id$ | 28 | $Id$ |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #ifndef KPIMPREFS_H | 31 | #ifndef KPIMPREFS_H |
32 | #define KPIMPREFS_H | 32 | #define KPIMPREFS_H |
33 | 33 | ||
34 | #include <qstringlist.h> | 34 | #include <qstringlist.h> |
35 | 35 | ||
36 | #include "kprefs.h" | 36 | #include "kprefs.h" |
37 | 37 | ||
38 | class KPimPrefs : public KPrefs | 38 | class KPimPrefs : public KPrefs |
39 | { | 39 | { |
40 | public: | 40 | public: |
41 | 41 | ||
42 | KPimPrefs( const QString &name = QString::null ); | 42 | KPimPrefs( const QString &name = QString::null ); |
43 | 43 | ||
44 | virtual ~KPimPrefs(); | 44 | virtual ~KPimPrefs(); |
45 | 45 | ||
46 | /** Set preferences to default values */ | 46 | /** Set preferences to default values */ |
47 | void usrSetDefaults(); | 47 | void usrSetDefaults(); |
48 | 48 | ||
49 | /** Read preferences from config file */ | 49 | /** Read preferences from config file */ |
50 | void usrReadConfig(); | 50 | void usrReadConfig(); |
51 | 51 | ||
52 | /** Write preferences to config file */ | 52 | /** Write preferences to config file */ |
53 | void usrWriteConfig(); | 53 | void usrWriteConfig(); |
54 | 54 | ||
55 | 55 | ||
56 | public: | 56 | public: |
57 | QStringList mCustomCategories; | 57 | QStringList mCustomCategories; |
58 | QString mPassiveSyncPort; | 58 | QString mPassiveSyncPort; |
59 | QString mPassiveSyncPw; | 59 | QString mPassiveSyncPw; |
60 | 60 | int mRingSyncAlgoPrefs; | |
61 | QString mLastSyncedLocalFile; | ||
61 | 62 | ||
62 | 63 | ||
63 | protected: | 64 | protected: |
64 | virtual void setCategoryDefaults(); | 65 | virtual void setCategoryDefaults(); |
65 | 66 | ||
66 | 67 | ||
67 | 68 | ||
68 | }; | 69 | }; |
69 | 70 | ||
70 | #endif | 71 | #endif |
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index fad9a76..568c2a9 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp | |||
@@ -1,1156 +1,1174 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KDE-Pim/Pi. | 2 | This file is part of KDE-Pim/Pi. |
3 | Copyright (c) 2004 Ulf Schenk | 3 | Copyright (c) 2004 Ulf Schenk |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | // $Id$ | 21 | // $Id$ |
22 | 22 | ||
23 | #include "ksyncmanager.h" | 23 | #include "ksyncmanager.h" |
24 | 24 | ||
25 | #include <stdlib.h> | 25 | #include <stdlib.h> |
26 | 26 | ||
27 | #ifndef _WIN32_ | 27 | #ifndef _WIN32_ |
28 | #include <unistd.h> | 28 | #include <unistd.h> |
29 | #endif | 29 | #endif |
30 | 30 | ||
31 | 31 | ||
32 | #include "ksyncprofile.h" | 32 | #include "ksyncprofile.h" |
33 | #include "ksyncprefsdialog.h" | 33 | #include "ksyncprefsdialog.h" |
34 | #include "kpimprefs.h" | 34 | #include "kpimprefs.h" |
35 | #include <kmessagebox.h> | 35 | #include <kmessagebox.h> |
36 | 36 | ||
37 | #include <qdir.h> | 37 | #include <qdir.h> |
38 | #include <qprogressbar.h> | 38 | #include <qprogressbar.h> |
39 | #include <qpopupmenu.h> | 39 | #include <qpopupmenu.h> |
40 | #include <qpushbutton.h> | 40 | #include <qpushbutton.h> |
41 | #include <qradiobutton.h> | 41 | #include <qradiobutton.h> |
42 | #include <qbuttongroup.h> | 42 | #include <qbuttongroup.h> |
43 | #include <qtimer.h> | 43 | #include <qtimer.h> |
44 | #include <qmessagebox.h> | 44 | #include <qmessagebox.h> |
45 | #include <qapplication.h> | 45 | #include <qapplication.h> |
46 | #include <qlineedit.h> | 46 | #include <qlineedit.h> |
47 | #include <qdialog.h> | 47 | #include <qdialog.h> |
48 | #include <qlayout.h> | 48 | #include <qlayout.h> |
49 | #include <qtextcodec.h> | 49 | #include <qtextcodec.h> |
50 | #include <qlabel.h> | 50 | #include <qlabel.h> |
51 | 51 | ||
52 | #include <klocale.h> | 52 | #include <klocale.h> |
53 | #include <kglobal.h> | 53 | #include <kglobal.h> |
54 | #include <kconfig.h> | 54 | #include <kconfig.h> |
55 | #include <kfiledialog.h> | 55 | #include <kfiledialog.h> |
56 | 56 | ||
57 | KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) | 57 | KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) |
58 | : QObject(), mParent(parent), mImplementation(implementation), mTargetApp(ta), mPrefs(prefs ),mSyncMenu(syncmenu) | 58 | : QObject(), mParent(parent), mImplementation(implementation), mTargetApp(ta), mPrefs(prefs ),mSyncMenu(syncmenu) |
59 | { | 59 | { |
60 | mServerSocket = 0; | 60 | mServerSocket = 0; |
61 | bar = new QProgressBar ( 1, 0 ); | 61 | bar = new QProgressBar ( 1, 0 ); |
62 | bar->setCaption (""); | 62 | bar->setCaption (""); |
63 | 63 | ||
64 | int w = 300; | 64 | int w = 300; |
65 | if ( QApplication::desktop()->width() < 320 ) | 65 | if ( QApplication::desktop()->width() < 320 ) |
66 | w = 220; | 66 | w = 220; |
67 | int h = bar->sizeHint().height() ; | 67 | int h = bar->sizeHint().height() ; |
68 | int dw = QApplication::desktop()->width(); | 68 | int dw = QApplication::desktop()->width(); |
69 | int dh = QApplication::desktop()->height(); | 69 | int dh = QApplication::desktop()->height(); |
70 | bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 70 | bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
71 | 71 | ||
72 | } | 72 | } |
73 | 73 | ||
74 | KSyncManager::~KSyncManager() | 74 | KSyncManager::~KSyncManager() |
75 | { | 75 | { |
76 | delete bar; | 76 | delete bar; |
77 | } | 77 | } |
78 | 78 | ||
79 | //LR ok | 79 | |
80 | void KSyncManager::fillSyncMenu() | 80 | void KSyncManager::fillSyncMenu() |
81 | { | 81 | { |
82 | if ( mSyncMenu->count() ) | 82 | if ( mSyncMenu->count() ) |
83 | mSyncMenu->clear(); | 83 | mSyncMenu->clear(); |
84 | 84 | ||
85 | mSyncMenu->insertItem( i18n("Configure..."), 0 ); | 85 | mSyncMenu->insertItem( i18n("Configure..."), 0 ); |
86 | mSyncMenu->insertSeparator(); | 86 | mSyncMenu->insertSeparator(); |
87 | if ( mServerSocket == 0 ) { | 87 | if ( mServerSocket == 0 ) { |
88 | mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); | 88 | mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); |
89 | } else { | 89 | } else { |
90 | mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); | 90 | mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); |
91 | } | 91 | } |
92 | mSyncMenu->insertSeparator(); | 92 | mSyncMenu->insertSeparator(); |
93 | mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); | 93 | mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); |
94 | mSyncMenu->insertSeparator(); | 94 | mSyncMenu->insertSeparator(); |
95 | 95 | ||
96 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 96 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
97 | config.setGroup("General"); | 97 | config.setGroup("General"); |
98 | QStringList prof = config.readListEntry("SyncProfileNames"); | 98 | QStringList prof = config.readListEntry("SyncProfileNames"); |
99 | mLocalMachineName = config.readEntry("LocalMachineName","undefined"); | 99 | mLocalMachineName = config.readEntry("LocalMachineName","undefined"); |
100 | if ( prof.count() < 2 ) { | 100 | if ( prof.count() < 2 ) { |
101 | prof.clear(); | 101 | prof.clear(); |
102 | prof << i18n("Sharp_DTM"); | 102 | prof << i18n("Sharp_DTM"); |
103 | prof << i18n("Local_file"); | 103 | prof << i18n("Local_file"); |
104 | prof << i18n("Last_file"); | ||
104 | KSyncProfile* temp = new KSyncProfile (); | 105 | KSyncProfile* temp = new KSyncProfile (); |
105 | temp->setName( prof[0] ); | 106 | temp->setName( prof[0] ); |
106 | temp->writeConfig(&config); | 107 | temp->writeConfig(&config); |
107 | temp->setName( prof[1] ); | 108 | temp->setName( prof[1] ); |
108 | temp->writeConfig(&config); | 109 | temp->writeConfig(&config); |
110 | temp->setName( prof[2] ); | ||
111 | temp->writeConfig(&config); | ||
109 | config.setGroup("General"); | 112 | config.setGroup("General"); |
110 | config.writeEntry("SyncProfileNames",prof); | 113 | config.writeEntry("SyncProfileNames",prof); |
111 | config.writeEntry("ExternSyncProfiles","Sharp_DTM"); | 114 | config.writeEntry("ExternSyncProfiles","Sharp_DTM"); |
112 | config.sync(); | 115 | config.sync(); |
113 | delete temp; | 116 | delete temp; |
114 | } | 117 | } |
115 | mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); | 118 | mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); |
116 | mSyncProfileNames = prof; | 119 | mSyncProfileNames = prof; |
117 | unsigned int i; | 120 | unsigned int i; |
118 | for ( i = 0; i < prof.count(); ++i ) { | 121 | for ( i = 0; i < prof.count(); ++i ) { |
119 | mSyncMenu->insertItem( prof[i], 1000+i ); | 122 | mSyncMenu->insertItem( prof[i], 1000+i ); |
120 | if ( i == 2 ) | 123 | if ( i == 2 ) |
121 | mSyncMenu->insertSeparator(); | 124 | mSyncMenu->insertSeparator(); |
122 | } | 125 | } |
123 | QDir app_dir; | 126 | QDir app_dir; |
124 | //US do not display SharpDTM if app is pwmpi, or no sharpfiles available | 127 | //US do not display SharpDTM if app is pwmpi, or no sharpfiles available |
125 | if ( mTargetApp == PWMPI) { | 128 | if ( mTargetApp == PWMPI) { |
126 | mSyncMenu->removeItem( 1000 ); | 129 | mSyncMenu->removeItem( 1000 ); |
127 | } | 130 | } |
128 | else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { | 131 | else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { |
129 | mSyncMenu->setItemEnabled( 1000, false ); | 132 | mSyncMenu->removeItem( 1000 ); |
130 | } | 133 | } |
134 | mSyncMenu->removeItem( 1002 ); | ||
131 | } | 135 | } |
132 | 136 | ||
133 | void KSyncManager::slotSyncMenu( int action ) | 137 | void KSyncManager::slotSyncMenu( int action ) |
134 | { | 138 | { |
135 | //qDebug("syncaction %d ", action); | 139 | //qDebug("syncaction %d ", action); |
136 | if ( action == 0 ) { | 140 | if ( action == 0 ) { |
137 | 141 | ||
138 | // seems to be a Qt2 event handling bug | 142 | // seems to be a Qt2 event handling bug |
139 | // syncmenu.clear causes a segfault at first time | 143 | // syncmenu.clear causes a segfault at first time |
140 | // when we call it after the main event loop, it is ok | 144 | // when we call it after the main event loop, it is ok |
141 | // same behaviour when calling OM/Pi via QCOP for the first time | 145 | // same behaviour when calling OM/Pi via QCOP for the first time |
142 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); | 146 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); |
143 | //confSync(); | 147 | //confSync(); |
144 | 148 | ||
145 | return; | 149 | return; |
146 | } | 150 | } |
147 | if ( action == 1 ) { | 151 | if ( action == 1 ) { |
148 | multiSync( true ); | 152 | multiSync( true ); |
149 | return; | 153 | return; |
150 | } | 154 | } |
151 | if ( action == 2 ) { | 155 | if ( action == 2 ) { |
152 | enableQuick(); | 156 | enableQuick(); |
153 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 157 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
154 | return; | 158 | return; |
155 | } | 159 | } |
156 | if ( action == 3 ) { | 160 | if ( action == 3 ) { |
157 | delete mServerSocket; | 161 | delete mServerSocket; |
158 | mServerSocket = 0; | 162 | mServerSocket = 0; |
159 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 163 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
160 | return; | 164 | return; |
161 | } | 165 | } |
162 | 166 | ||
163 | if (blockSave()) | 167 | if (blockSave()) |
164 | return; | 168 | return; |
165 | 169 | ||
166 | setBlockSave(true); | 170 | setBlockSave(true); |
167 | 171 | ||
168 | mCurrentSyncProfile = action - 1000 ; | 172 | mCurrentSyncProfile = action - 1000 ; |
169 | mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; | 173 | mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; |
170 | mCurrentSyncName = mLocalMachineName ; | 174 | mCurrentSyncName = mLocalMachineName ; |
171 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 175 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
172 | KSyncProfile* temp = new KSyncProfile (); | 176 | KSyncProfile* temp = new KSyncProfile (); |
173 | temp->setName(mSyncProfileNames[mCurrentSyncProfile]); | 177 | temp->setName(mSyncProfileNames[mCurrentSyncProfile]); |
174 | temp->readConfig(&config); | 178 | temp->readConfig(&config); |
175 | mAskForPreferences = temp->getAskForPreferences(); | 179 | mAskForPreferences = temp->getAskForPreferences(); |
176 | mSyncAlgoPrefs = temp->getSyncPrefs(); | 180 | mSyncAlgoPrefs = temp->getSyncPrefs(); |
177 | mWriteBackFile = temp->getWriteBackFile(); | 181 | mWriteBackFile = temp->getWriteBackFile(); |
178 | mWriteBackExistingOnly = temp->getWriteBackExisting(); | 182 | mWriteBackExistingOnly = temp->getWriteBackExisting(); |
179 | mWriteBackInFuture = 0; | 183 | mWriteBackInFuture = 0; |
180 | if ( temp->getWriteBackFuture() ) | 184 | if ( temp->getWriteBackFuture() ) |
181 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 185 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
182 | mShowSyncSummary = temp->getShowSummaryAfterSync(); | 186 | mShowSyncSummary = temp->getShowSummaryAfterSync(); |
183 | if ( action == 1000 ) { | 187 | if ( action == 1000 ) { |
184 | syncSharp(); | 188 | syncSharp(); |
185 | 189 | ||
186 | } else if ( action == 1001 ) { | 190 | } else if ( action == 1001 ) { |
187 | syncLocalFile(); | 191 | syncLocalFile(); |
188 | 192 | ||
189 | } else if ( action == 1002 ) { | 193 | } else if ( action == 1002 ) { |
190 | quickSyncLocalFile(); | 194 | quickSyncLocalFile(); |
191 | 195 | ||
192 | } else if ( action >= 1003 ) { | 196 | } else if ( action >= 1003 ) { |
193 | if ( temp->getIsLocalFileSync() ) { | 197 | if ( temp->getIsLocalFileSync() ) { |
194 | switch(mTargetApp) | 198 | switch(mTargetApp) |
195 | { | 199 | { |
196 | case (KAPI): | 200 | case (KAPI): |
197 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) | 201 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) |
198 | mLastSyncedLocalFile = temp->getRemoteFileNameAB(); | 202 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); |
199 | break; | 203 | break; |
200 | case (KOPI): | 204 | case (KOPI): |
201 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | 205 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) |
202 | mLastSyncedLocalFile = temp->getRemoteFileName(); | 206 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); |
203 | break; | 207 | break; |
204 | case (PWMPI): | 208 | case (PWMPI): |
205 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) | 209 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) |
206 | mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); | 210 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); |
207 | break; | 211 | break; |
208 | default: | 212 | default: |
209 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); | 213 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); |
210 | break; | 214 | break; |
211 | 215 | ||
212 | } | 216 | } |
213 | } else { | 217 | } else { |
214 | if ( temp->getIsPhoneSync() ) { | 218 | if ( temp->getIsPhoneSync() ) { |
215 | mPhoneDevice = temp->getPhoneDevice( ) ; | 219 | mPhoneDevice = temp->getPhoneDevice( ) ; |
216 | mPhoneConnection = temp->getPhoneConnection( ); | 220 | mPhoneConnection = temp->getPhoneConnection( ); |
217 | mPhoneModel = temp->getPhoneModel( ); | 221 | mPhoneModel = temp->getPhoneModel( ); |
218 | syncPhone(); | 222 | syncPhone(); |
219 | } else if ( temp->getIsPiSync() ) { | 223 | } else if ( temp->getIsPiSync() ) { |
220 | if ( mTargetApp == KAPI ) { | 224 | if ( mTargetApp == KAPI ) { |
221 | mPassWordPiSync = temp->getRemotePwAB(); | 225 | mPassWordPiSync = temp->getRemotePwAB(); |
222 | mActiveSyncPort = temp->getRemotePortAB(); | 226 | mActiveSyncPort = temp->getRemotePortAB(); |
223 | mActiveSyncIP = temp->getRemoteIPAB(); | 227 | mActiveSyncIP = temp->getRemoteIPAB(); |
224 | } else if ( mTargetApp == KOPI ) { | 228 | } else if ( mTargetApp == KOPI ) { |
225 | mPassWordPiSync = temp->getRemotePw(); | 229 | mPassWordPiSync = temp->getRemotePw(); |
226 | mActiveSyncPort = temp->getRemotePort(); | 230 | mActiveSyncPort = temp->getRemotePort(); |
227 | mActiveSyncIP = temp->getRemoteIP(); | 231 | mActiveSyncIP = temp->getRemoteIP(); |
228 | } else { | 232 | } else { |
229 | mPassWordPiSync = temp->getRemotePwPWM(); | 233 | mPassWordPiSync = temp->getRemotePwPWM(); |
230 | mActiveSyncPort = temp->getRemotePortPWM(); | 234 | mActiveSyncPort = temp->getRemotePortPWM(); |
231 | mActiveSyncIP = temp->getRemoteIPPWM(); | 235 | mActiveSyncIP = temp->getRemoteIPPWM(); |
232 | } | 236 | } |
233 | syncPi(); | 237 | syncPi(); |
234 | } else | 238 | } else |
235 | syncRemote( temp ); | 239 | syncRemote( temp ); |
236 | 240 | ||
237 | } | 241 | } |
238 | } | 242 | } |
239 | delete temp; | 243 | delete temp; |
240 | setBlockSave(false); | 244 | setBlockSave(false); |
241 | } | 245 | } |
246 | |||
242 | void KSyncManager::enableQuick() | 247 | void KSyncManager::enableQuick() |
243 | { | 248 | { |
244 | QDialog dia ( 0, "input-dialog", true ); | 249 | QDialog dia ( 0, "input-dialog", true ); |
245 | QLineEdit lab ( &dia ); | 250 | QLineEdit lab ( &dia ); |
246 | QVBoxLayout lay( &dia ); | 251 | QVBoxLayout lay( &dia ); |
247 | lab.setText( mPrefs->mPassiveSyncPort ); | 252 | lab.setText( mPrefs->mPassiveSyncPort ); |
248 | lay.setMargin(7); | 253 | lay.setMargin(7); |
249 | lay.setSpacing(7); | 254 | lay.setSpacing(7); |
250 | int po = 9197+mTargetApp; | 255 | int po = 9197+mTargetApp; |
251 | QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia ); | 256 | QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia ); |
252 | lay.addWidget( &label); | 257 | lay.addWidget( &label); |
253 | lay.addWidget( &lab); | 258 | lay.addWidget( &lab); |
254 | 259 | ||
255 | QLineEdit lepw ( &dia ); | 260 | QLineEdit lepw ( &dia ); |
256 | lepw.setText( mPrefs->mPassiveSyncPw ); | 261 | lepw.setText( mPrefs->mPassiveSyncPw ); |
257 | QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); | 262 | QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); |
258 | lay.addWidget( &label2); | 263 | lay.addWidget( &label2); |
259 | lay.addWidget( &lepw); | 264 | lay.addWidget( &lepw); |
260 | dia.setFixedSize( 230,80 ); | 265 | dia.setFixedSize( 230,80 ); |
261 | dia.setCaption( i18n("Enter port for Pi-Sync") ); | 266 | dia.setCaption( i18n("Enter port for Pi-Sync") ); |
262 | QPushButton pb ( "OK", &dia); | 267 | QPushButton pb ( "OK", &dia); |
263 | lay.addWidget( &pb ); | 268 | lay.addWidget( &pb ); |
264 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 269 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
265 | dia.show(); | 270 | dia.show(); |
266 | if ( ! dia.exec() ) | 271 | if ( ! dia.exec() ) |
267 | return; | 272 | return; |
268 | dia.hide(); | 273 | dia.hide(); |
269 | qApp->processEvents(); | 274 | qApp->processEvents(); |
270 | mPrefs->mPassiveSyncPw = lepw.text(); | 275 | mPrefs->mPassiveSyncPw = lepw.text(); |
271 | mPrefs->mPassiveSyncPort = lab.text(); | 276 | mPrefs->mPassiveSyncPort = lab.text(); |
272 | bool ok; | 277 | bool ok; |
273 | Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok); | 278 | Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok); |
274 | if ( ! ok ) { | 279 | if ( ! ok ) { |
275 | KMessageBox::information( 0, i18n("No valid port")); | 280 | KMessageBox::information( 0, i18n("No valid port")); |
276 | return; | 281 | return; |
277 | } | 282 | } |
278 | //qDebug("port %d ", port); | 283 | //qDebug("port %d ", port); |
279 | mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); | 284 | mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); |
280 | mServerSocket->setFileName( defaultFileName() ); | 285 | mServerSocket->setFileName( defaultFileName() ); |
281 | //qDebug("connected "); | 286 | //qDebug("connected "); |
282 | if ( !mServerSocket->ok() ) { | 287 | if ( !mServerSocket->ok() ) { |
283 | KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!")); | 288 | KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!")); |
284 | delete mServerSocket; | 289 | delete mServerSocket; |
285 | mServerSocket = 0; | 290 | mServerSocket = 0; |
286 | return; | 291 | return; |
287 | } | 292 | } |
288 | //connect( mServerSocket, SIGNAL ( saveFile() ),this, SIGNAL ( save() ) ); | ||
289 | connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); | 293 | connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); |
290 | connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); | 294 | connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); |
291 | } | 295 | } |
292 | 296 | ||
293 | void KSyncManager::syncLocalFile() | 297 | void KSyncManager::syncLocalFile() |
294 | { | 298 | { |
295 | 299 | ||
296 | QString fn =mLastSyncedLocalFile; | 300 | QString fn =mPrefs->mLastSyncedLocalFile; |
297 | QString ext; | 301 | QString ext; |
298 | 302 | ||
299 | switch(mTargetApp) | 303 | switch(mTargetApp) |
300 | { | 304 | { |
301 | case (KAPI): | 305 | case (KAPI): |
302 | ext = "(*.vcf)"; | 306 | ext = "(*.vcf)"; |
303 | break; | 307 | break; |
304 | case (KOPI): | 308 | case (KOPI): |
305 | ext = "(*.ics/*.vcs)"; | 309 | ext = "(*.ics/*.vcs)"; |
306 | break; | 310 | break; |
307 | case (PWMPI): | 311 | case (PWMPI): |
308 | ext = "(*.pwm)"; | 312 | ext = "(*.pwm)"; |
309 | break; | 313 | break; |
310 | default: | 314 | default: |
311 | qDebug("KSyncManager::syncLocalFile: invalid apptype selected"); | 315 | qDebug("KSyncManager::syncLocalFile: invalid apptype selected"); |
312 | break; | 316 | break; |
313 | 317 | ||
314 | } | 318 | } |
315 | 319 | ||
316 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); | 320 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); |
317 | if ( fn == "" ) | 321 | if ( fn == "" ) |
318 | return; | 322 | return; |
319 | if ( syncWithFile( fn, false ) ) { | 323 | if ( syncWithFile( fn, false ) ) { |
320 | qDebug("syncLocalFile() successful "); | 324 | qDebug("syncLocalFile() successful "); |
321 | } | 325 | } |
322 | 326 | ||
323 | } | 327 | } |
328 | |||
324 | bool KSyncManager::syncWithFile( QString fn , bool quick ) | 329 | bool KSyncManager::syncWithFile( QString fn , bool quick ) |
325 | { | 330 | { |
326 | bool ret = false; | 331 | bool ret = false; |
327 | QFileInfo info; | 332 | QFileInfo info; |
328 | info.setFile( fn ); | 333 | info.setFile( fn ); |
329 | QString mess; | 334 | QString mess; |
330 | bool loadbup = true; | 335 | bool loadbup = true; |
331 | if ( !info. exists() ) { | 336 | if ( !info. exists() ) { |
332 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); | 337 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); |
333 | int result = QMessageBox::warning( mParent, i18n("Warning!"), | 338 | int result = QMessageBox::warning( mParent, i18n("Warning!"), |
334 | mess ); | 339 | mess ); |
335 | return ret; | 340 | return ret; |
336 | } | 341 | } |
337 | int result = 0; | 342 | int result = 0; |
338 | if ( !quick ) { | 343 | if ( !quick ) { |
339 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 344 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
340 | result = QMessageBox::warning( mParent, i18n("Warning!"), | 345 | result = QMessageBox::warning( mParent, i18n("Warning!"), |
341 | mess, | 346 | mess, |
342 | i18n("Sync"), i18n("Cancel"), 0, | 347 | i18n("Sync"), i18n("Cancel"), 0, |
343 | 0, 1 ); | 348 | 0, 1 ); |
344 | if ( result ) | 349 | if ( result ) |
345 | return false; | 350 | return false; |
346 | } | 351 | } |
347 | if ( mAskForPreferences ) | 352 | if ( mAskForPreferences ) |
348 | edit_sync_options(); | 353 | edit_sync_options(); |
349 | if ( result == 0 ) { | 354 | if ( result == 0 ) { |
350 | //qDebug("Now sycing ... "); | 355 | //qDebug("Now sycing ... "); |
351 | if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) | 356 | if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) |
352 | mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); | 357 | mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); |
353 | else | 358 | else |
354 | mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); | 359 | mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); |
355 | if ( ! quick ) | 360 | if ( ! quick ) |
356 | mLastSyncedLocalFile = fn; | 361 | mPrefs->mLastSyncedLocalFile = fn; |
357 | } | 362 | } |
358 | return ret; | 363 | return ret; |
359 | } | 364 | } |
365 | |||
360 | void KSyncManager::quickSyncLocalFile() | 366 | void KSyncManager::quickSyncLocalFile() |
361 | { | 367 | { |
362 | 368 | ||
363 | if ( syncWithFile( mLastSyncedLocalFile, false ) ) { | 369 | if ( syncWithFile( mPrefs->mLastSyncedLocalFile, false ) ) { |
364 | qDebug("quick syncLocalFile() successful "); | 370 | qDebug("quick syncLocalFile() successful "); |
365 | 371 | ||
366 | } | 372 | } |
367 | } | 373 | } |
374 | |||
368 | void KSyncManager::multiSync( bool askforPrefs ) | 375 | void KSyncManager::multiSync( bool askforPrefs ) |
369 | { | 376 | { |
370 | if (blockSave()) | 377 | if (blockSave()) |
371 | return; | 378 | return; |
372 | setBlockSave(true); | 379 | setBlockSave(true); |
373 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); | 380 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); |
374 | if ( QMessageBox::information( mParent, i18n("Sync"), | 381 | if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), |
375 | question, | 382 | question, |
376 | i18n("Yes"), i18n("No"), | 383 | i18n("Yes"), i18n("No"), |
377 | 0, 0 ) != 0 ) { | 384 | 0, 0 ) != 0 ) { |
378 | setBlockSave(false); | 385 | setBlockSave(false); |
379 | mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); | 386 | mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); |
380 | return; | 387 | return; |
381 | } | 388 | } |
382 | mCurrentSyncDevice = i18n("Multiple profiles") ; | 389 | mCurrentSyncDevice = i18n("Multiple profiles") ; |
383 | mSyncAlgoPrefs = mRingSyncAlgoPrefs; | 390 | mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; |
384 | if ( askforPrefs ) { | 391 | if ( askforPrefs ) { |
385 | edit_sync_options(); | 392 | edit_sync_options(); |
386 | mRingSyncAlgoPrefs = mSyncAlgoPrefs; | 393 | mRingSyncAlgoPrefs = mSyncAlgoPrefs; |
387 | } | 394 | } |
388 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); | 395 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); |
389 | qApp->processEvents(); | 396 | qApp->processEvents(); |
390 | int num = ringSync() ; | 397 | int num = ringSync() ; |
391 | if ( num > 1 ) | 398 | if ( num > 1 ) |
392 | ringSync(); | 399 | ringSync(); |
393 | setBlockSave(false); | 400 | setBlockSave(false); |
394 | if ( num ) | 401 | if ( num ) |
395 | emit save(); | 402 | emit save(); |
396 | if ( num ) | 403 | if ( num ) |
397 | mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); | 404 | mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); |
398 | else | 405 | else |
399 | mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); | 406 | mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); |
400 | return; | 407 | return; |
401 | } | 408 | } |
409 | |||
402 | int KSyncManager::ringSync() | 410 | int KSyncManager::ringSync() |
403 | { | 411 | { |
404 | int syncedProfiles = 0; | 412 | int syncedProfiles = 0; |
405 | unsigned int i; | 413 | unsigned int i; |
406 | QTime timer; | 414 | QTime timer; |
407 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 415 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
408 | QStringList syncProfileNames = mSyncProfileNames; | 416 | QStringList syncProfileNames = mSyncProfileNames; |
409 | KSyncProfile* temp = new KSyncProfile (); | 417 | KSyncProfile* temp = new KSyncProfile (); |
410 | mAskForPreferences = false; | 418 | mAskForPreferences = false; |
411 | for ( i = 0; i < syncProfileNames.count(); ++i ) { | 419 | for ( i = 0; i < syncProfileNames.count(); ++i ) { |
412 | mCurrentSyncProfile = i; | 420 | mCurrentSyncProfile = i; |
413 | temp->setName(syncProfileNames[mCurrentSyncProfile]); | 421 | temp->setName(syncProfileNames[mCurrentSyncProfile]); |
414 | temp->readConfig(&config); | 422 | temp->readConfig(&config); |
415 | 423 | ||
416 | QString includeInRingSync; | 424 | QString includeInRingSync; |
417 | switch(mTargetApp) | 425 | switch(mTargetApp) |
418 | { | 426 | { |
419 | case (KAPI): | 427 | case (KAPI): |
420 | includeInRingSync = temp->getIncludeInRingSyncAB(); | 428 | includeInRingSync = temp->getIncludeInRingSyncAB(); |
421 | break; | 429 | break; |
422 | case (KOPI): | 430 | case (KOPI): |
423 | includeInRingSync = temp->getIncludeInRingSync(); | 431 | includeInRingSync = temp->getIncludeInRingSync(); |
424 | break; | 432 | break; |
425 | case (PWMPI): | 433 | case (PWMPI): |
426 | includeInRingSync = temp->getIncludeInRingSyncPWM(); | 434 | includeInRingSync = temp->getIncludeInRingSyncPWM(); |
427 | break; | 435 | break; |
428 | default: | 436 | default: |
429 | qDebug("KSyncManager::ringSync: invalid apptype selected"); | 437 | qDebug("KSyncManager::ringSync: invalid apptype selected"); |
430 | break; | 438 | break; |
431 | 439 | ||
432 | } | 440 | } |
433 | 441 | ||
434 | 442 | ||
435 | if ( includeInRingSync && ( i < 1 || i > 2 )) { | 443 | if ( includeInRingSync && ( i < 1 || i > 2 )) { |
436 | mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); | 444 | mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); |
437 | ++syncedProfiles; | 445 | ++syncedProfiles; |
438 | // mAskForPreferences = temp->getAskForPreferences(); | 446 | // mAskForPreferences = temp->getAskForPreferences(); |
439 | mWriteBackFile = temp->getWriteBackFile(); | 447 | mWriteBackFile = temp->getWriteBackFile(); |
440 | mWriteBackExistingOnly = temp->getWriteBackExisting(); | 448 | mWriteBackExistingOnly = temp->getWriteBackExisting(); |
441 | mWriteBackInFuture = 0; | 449 | mWriteBackInFuture = 0; |
442 | if ( temp->getWriteBackFuture() ) | 450 | if ( temp->getWriteBackFuture() ) |
443 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 451 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
444 | mShowSyncSummary = false; | 452 | mShowSyncSummary = false; |
445 | mCurrentSyncDevice = syncProfileNames[i] ; | 453 | mCurrentSyncDevice = syncProfileNames[i] ; |
446 | mCurrentSyncName = mLocalMachineName; | 454 | mCurrentSyncName = mLocalMachineName; |
447 | if ( i == 0 ) { | 455 | if ( i == 0 ) { |
448 | syncSharp(); | 456 | syncSharp(); |
449 | } else { | 457 | } else { |
450 | if ( temp->getIsLocalFileSync() ) { | 458 | if ( temp->getIsLocalFileSync() ) { |
451 | switch(mTargetApp) | 459 | switch(mTargetApp) |
452 | { | 460 | { |
453 | case (KAPI): | 461 | case (KAPI): |
454 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) | 462 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) |
455 | mLastSyncedLocalFile = temp->getRemoteFileNameAB(); | 463 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); |
456 | break; | 464 | break; |
457 | case (KOPI): | 465 | case (KOPI): |
458 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | 466 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) |
459 | mLastSyncedLocalFile = temp->getRemoteFileName(); | 467 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); |
460 | break; | 468 | break; |
461 | case (PWMPI): | 469 | case (PWMPI): |
462 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) | 470 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) |
463 | mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); | 471 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); |
464 | break; | 472 | break; |
465 | default: | 473 | default: |
466 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); | 474 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); |
467 | break; | 475 | break; |
468 | } | 476 | } |
469 | } else { | 477 | } else { |
470 | if ( temp->getIsPhoneSync() ) { | 478 | if ( temp->getIsPhoneSync() ) { |
471 | mPhoneDevice = temp->getPhoneDevice( ) ; | 479 | mPhoneDevice = temp->getPhoneDevice( ) ; |
472 | mPhoneConnection = temp->getPhoneConnection( ); | 480 | mPhoneConnection = temp->getPhoneConnection( ); |
473 | mPhoneModel = temp->getPhoneModel( ); | 481 | mPhoneModel = temp->getPhoneModel( ); |
474 | syncPhone(); | 482 | syncPhone(); |
483 | } else if ( temp->getIsPiSync() ) { | ||
484 | if ( mTargetApp == KAPI ) { | ||
485 | mPassWordPiSync = temp->getRemotePwAB(); | ||
486 | mActiveSyncPort = temp->getRemotePortAB(); | ||
487 | mActiveSyncIP = temp->getRemoteIPAB(); | ||
488 | } else if ( mTargetApp == KOPI ) { | ||
489 | mPassWordPiSync = temp->getRemotePw(); | ||
490 | mActiveSyncPort = temp->getRemotePort(); | ||
491 | mActiveSyncIP = temp->getRemoteIP(); | ||
492 | } else { | ||
493 | mPassWordPiSync = temp->getRemotePwPWM(); | ||
494 | mActiveSyncPort = temp->getRemotePortPWM(); | ||
495 | mActiveSyncIP = temp->getRemoteIPPWM(); | ||
496 | } | ||
497 | syncPi(); | ||
475 | } else | 498 | } else |
476 | syncRemote( temp, false ); | 499 | syncRemote( temp, false ); |
477 | 500 | ||
478 | } | 501 | } |
479 | } | 502 | } |
480 | timer.start(); | 503 | timer.start(); |
481 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") ); | 504 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") ); |
482 | while ( timer.elapsed () < 2000 ) { | 505 | while ( timer.elapsed () < 2000 ) { |
483 | qApp->processEvents(); | 506 | qApp->processEvents(); |
484 | #ifndef _WIN32_ | 507 | #ifndef _WIN32_ |
485 | sleep (1); | 508 | sleep (1); |
486 | #endif | 509 | #endif |
487 | } | 510 | } |
488 | 511 | ||
489 | } | 512 | } |
490 | 513 | ||
491 | } | 514 | } |
492 | delete temp; | 515 | delete temp; |
493 | return syncedProfiles; | 516 | return syncedProfiles; |
494 | } | 517 | } |
495 | 518 | ||
496 | void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) | 519 | void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) |
497 | { | 520 | { |
498 | QString question; | 521 | QString question; |
499 | if ( ask ) { | 522 | if ( ask ) { |
500 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; | 523 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; |
501 | if ( QMessageBox::information( mParent, i18n("Sync"), | 524 | if ( QMessageBox::information( mParent, i18n("Sync"), |
502 | question, | 525 | question, |
503 | i18n("Yes"), i18n("No"), | 526 | i18n("Yes"), i18n("No"), |
504 | 0, 0 ) != 0 ) | 527 | 0, 0 ) != 0 ) |
505 | return; | 528 | return; |
506 | } | 529 | } |
507 | 530 | ||
508 | QString preCommand; | 531 | QString preCommand; |
509 | QString localTempFile; | 532 | QString localTempFile; |
510 | QString postCommand; | 533 | QString postCommand; |
511 | 534 | ||
512 | switch(mTargetApp) | 535 | switch(mTargetApp) |
513 | { | 536 | { |
514 | case (KAPI): | 537 | case (KAPI): |
515 | preCommand = prof->getPreSyncCommandAB(); | 538 | preCommand = prof->getPreSyncCommandAB(); |
516 | postCommand = prof->getPostSyncCommandAB(); | 539 | postCommand = prof->getPostSyncCommandAB(); |
517 | localTempFile = prof->getLocalTempFileAB(); | 540 | localTempFile = prof->getLocalTempFileAB(); |
518 | break; | 541 | break; |
519 | case (KOPI): | 542 | case (KOPI): |
520 | preCommand = prof->getPreSyncCommand(); | 543 | preCommand = prof->getPreSyncCommand(); |
521 | postCommand = prof->getPostSyncCommand(); | 544 | postCommand = prof->getPostSyncCommand(); |
522 | localTempFile = prof->getLocalTempFile(); | 545 | localTempFile = prof->getLocalTempFile(); |
523 | break; | 546 | break; |
524 | case (PWMPI): | 547 | case (PWMPI): |
525 | preCommand = prof->getPreSyncCommandPWM(); | 548 | preCommand = prof->getPreSyncCommandPWM(); |
526 | postCommand = prof->getPostSyncCommandPWM(); | 549 | postCommand = prof->getPostSyncCommandPWM(); |
527 | localTempFile = prof->getLocalTempFilePWM(); | 550 | localTempFile = prof->getLocalTempFilePWM(); |
528 | break; | 551 | break; |
529 | default: | 552 | default: |
530 | qDebug("KSyncManager::syncRemote: invalid apptype selected"); | 553 | qDebug("KSyncManager::syncRemote: invalid apptype selected"); |
531 | break; | 554 | break; |
532 | } | 555 | } |
533 | 556 | ||
534 | 557 | ||
535 | int fi; | 558 | int fi; |
536 | if ( (fi = preCommand.find("$PWD$")) > 0 ) { | 559 | if ( (fi = preCommand.find("$PWD$")) > 0 ) { |
537 | QString pwd = getPassword(); | 560 | QString pwd = getPassword(); |
538 | preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); | 561 | preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); |
539 | 562 | ||
540 | } | 563 | } |
541 | int maxlen = 30; | 564 | int maxlen = 30; |
542 | if ( QApplication::desktop()->width() > 320 ) | 565 | if ( QApplication::desktop()->width() > 320 ) |
543 | maxlen += 25; | 566 | maxlen += 25; |
544 | mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) ); | 567 | mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) ); |
545 | int fileSize = 0; | 568 | int fileSize = 0; |
546 | int result = system ( preCommand ); | 569 | int result = system ( preCommand ); |
547 | // 0 : okay | 570 | // 0 : okay |
548 | // 256: no such file or dir | 571 | // 256: no such file or dir |
549 | // | 572 | // |
550 | qDebug("KO: Remote copy result(0 = okay): %d ",result ); | 573 | qDebug("KO: Remote copy result(0 = okay): %d ",result ); |
551 | if ( result != 0 ) { | 574 | if ( result != 0 ) { |
552 | unsigned int len = maxlen; | 575 | unsigned int len = maxlen; |
553 | while ( len < preCommand.length() ) { | 576 | while ( len < preCommand.length() ) { |
554 | preCommand.insert( len , "\n" ); | 577 | preCommand.insert( len , "\n" ); |
555 | len += maxlen +2; | 578 | len += maxlen +2; |
556 | } | 579 | } |
557 | question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (preCommand) ; | 580 | question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (preCommand) ; |
558 | QMessageBox::information( mParent, i18n("Sync - ERROR"), | 581 | QMessageBox::information( mParent, i18n("Sync - ERROR"), |
559 | question, | 582 | question, |
560 | i18n("Okay!")) ; | 583 | i18n("Okay!")) ; |
561 | mParent->topLevelWidget()->setCaption (""); | 584 | mParent->topLevelWidget()->setCaption ("KDE-Pim"); |
562 | return; | 585 | return; |
563 | } | 586 | } |
564 | mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) ); | 587 | mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) ); |
565 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); | 588 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); |
566 | 589 | ||
567 | |||
568 | |||
569 | if ( syncWithFile( localTempFile, true ) ) { | 590 | if ( syncWithFile( localTempFile, true ) ) { |
570 | // Event* e = mView->getLastSyncEvent(); | 591 | |
571 | // e->setReadOnly( false ); | ||
572 | // e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); | ||
573 | // e->setReadOnly( true ); | ||
574 | if ( mWriteBackFile ) { | 592 | if ( mWriteBackFile ) { |
575 | int fi; | 593 | int fi; |
576 | if ( (fi = postCommand.find("$PWD$")) > 0 ) { | 594 | if ( (fi = postCommand.find("$PWD$")) > 0 ) { |
577 | QString pwd = getPassword(); | 595 | QString pwd = getPassword(); |
578 | postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); | 596 | postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); |
579 | 597 | ||
580 | } | 598 | } |
581 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) ); | 599 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) ); |
582 | result = system ( postCommand ); | 600 | result = system ( postCommand ); |
583 | qDebug("Writing back file result: %d ", result); | 601 | qDebug("Writing back file result: %d ", result); |
584 | if ( result != 0 ) { | 602 | if ( result != 0 ) { |
585 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); | 603 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); |
586 | return; | 604 | return; |
587 | } else { | 605 | } else { |
588 | mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) ); | 606 | mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) ); |
589 | } | 607 | } |
590 | } | 608 | } |
591 | } | 609 | } |
592 | return; | 610 | return; |
593 | } | 611 | } |
594 | 612 | ||
595 | void KSyncManager::edit_sync_options() | 613 | void KSyncManager::edit_sync_options() |
596 | { | 614 | { |
597 | //mDialogManager->showSyncOptions(); | 615 | //mDialogManager->showSyncOptions(); |
598 | //mSyncAlgoPrefs | 616 | //mSyncAlgoPrefs |
599 | QDialog dia( mParent, "dia", true ); | 617 | QDialog dia( mParent, "dia", true ); |
600 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); | 618 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); |
601 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); | 619 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); |
602 | QVBoxLayout lay ( &dia ); | 620 | QVBoxLayout lay ( &dia ); |
603 | lay.setSpacing( 2 ); | 621 | lay.setSpacing( 2 ); |
604 | lay.setMargin( 3 ); | 622 | lay.setMargin( 3 ); |
605 | lay.addWidget(&gr); | 623 | lay.addWidget(&gr); |
606 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); | 624 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); |
607 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); | 625 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); |
608 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); | 626 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); |
609 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); | 627 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); |
610 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); | 628 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); |
611 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); | 629 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); |
612 | //QRadioButton both( i18n("Take both on conflict"), &gr ); | 630 | //QRadioButton both( i18n("Take both on conflict"), &gr ); |
613 | QPushButton pb ( "OK", &dia); | 631 | QPushButton pb ( "OK", &dia); |
614 | lay.addWidget( &pb ); | 632 | lay.addWidget( &pb ); |
615 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 633 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
616 | switch ( mSyncAlgoPrefs ) { | 634 | switch ( mSyncAlgoPrefs ) { |
617 | case 0: | 635 | case 0: |
618 | loc.setChecked( true); | 636 | loc.setChecked( true); |
619 | break; | 637 | break; |
620 | case 1: | 638 | case 1: |
621 | rem.setChecked( true ); | 639 | rem.setChecked( true ); |
622 | break; | 640 | break; |
623 | case 2: | 641 | case 2: |
624 | newest.setChecked( true); | 642 | newest.setChecked( true); |
625 | break; | 643 | break; |
626 | case 3: | 644 | case 3: |
627 | ask.setChecked( true); | 645 | ask.setChecked( true); |
628 | break; | 646 | break; |
629 | case 4: | 647 | case 4: |
630 | f_loc.setChecked( true); | 648 | f_loc.setChecked( true); |
631 | break; | 649 | break; |
632 | case 5: | 650 | case 5: |
633 | f_rem.setChecked( true); | 651 | f_rem.setChecked( true); |
634 | break; | 652 | break; |
635 | case 6: | 653 | case 6: |
636 | // both.setChecked( true); | 654 | // both.setChecked( true); |
637 | break; | 655 | break; |
638 | default: | 656 | default: |
639 | break; | 657 | break; |
640 | } | 658 | } |
641 | if ( dia.exec() ) { | 659 | if ( dia.exec() ) { |
642 | mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; | 660 | mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; |
643 | } | 661 | } |
644 | 662 | ||
645 | 663 | ||
646 | } | 664 | } |
665 | |||
647 | QString KSyncManager::getPassword( ) | 666 | QString KSyncManager::getPassword( ) |
648 | { | 667 | { |
649 | QString retfile = ""; | 668 | QString retfile = ""; |
650 | QDialog dia ( mParent, "input-dialog", true ); | 669 | QDialog dia ( mParent, "input-dialog", true ); |
651 | QLineEdit lab ( &dia ); | 670 | QLineEdit lab ( &dia ); |
652 | lab.setEchoMode( QLineEdit::Password ); | 671 | lab.setEchoMode( QLineEdit::Password ); |
653 | QVBoxLayout lay( &dia ); | 672 | QVBoxLayout lay( &dia ); |
654 | lay.setMargin(7); | 673 | lay.setMargin(7); |
655 | lay.setSpacing(7); | 674 | lay.setSpacing(7); |
656 | lay.addWidget( &lab); | 675 | lay.addWidget( &lab); |
657 | dia.setFixedSize( 230,50 ); | 676 | dia.setFixedSize( 230,50 ); |
658 | dia.setCaption( i18n("Enter password") ); | 677 | dia.setCaption( i18n("Enter password") ); |
659 | QPushButton pb ( "OK", &dia); | 678 | QPushButton pb ( "OK", &dia); |
660 | lay.addWidget( &pb ); | 679 | lay.addWidget( &pb ); |
661 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 680 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
662 | dia.show(); | 681 | dia.show(); |
663 | int res = dia.exec(); | 682 | int res = dia.exec(); |
664 | if ( res ) | 683 | if ( res ) |
665 | retfile = lab.text(); | 684 | retfile = lab.text(); |
666 | dia.hide(); | 685 | dia.hide(); |
667 | qApp->processEvents(); | 686 | qApp->processEvents(); |
668 | return retfile; | 687 | return retfile; |
669 | 688 | ||
670 | } | 689 | } |
671 | 690 | ||
672 | 691 | ||
673 | void KSyncManager::confSync() | 692 | void KSyncManager::confSync() |
674 | { | 693 | { |
675 | static KSyncPrefsDialog* sp = 0; | 694 | static KSyncPrefsDialog* sp = 0; |
676 | if ( ! sp ) { | 695 | if ( ! sp ) { |
677 | sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); | 696 | sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); |
678 | } | 697 | } |
679 | sp->usrReadConfig(); | 698 | sp->usrReadConfig(); |
680 | #ifndef DESKTOP_VERSION | 699 | #ifndef DESKTOP_VERSION |
681 | sp->showMaximized(); | 700 | sp->showMaximized(); |
682 | #else | 701 | #else |
683 | sp->show(); | 702 | sp->show(); |
684 | #endif | 703 | #endif |
685 | sp->exec(); | 704 | sp->exec(); |
686 | mSyncProfileNames = sp->getSyncProfileNames(); | 705 | mSyncProfileNames = sp->getSyncProfileNames(); |
687 | mLocalMachineName = sp->getLocalMachineName (); | 706 | mLocalMachineName = sp->getLocalMachineName (); |
688 | fillSyncMenu(); | 707 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
689 | } | 708 | } |
690 | 709 | ||
691 | void KSyncManager::syncSharp() | 710 | void KSyncManager::syncSharp() |
692 | { | 711 | { |
712 | |||
693 | if ( ! syncExternalApplication("sharp") ) | 713 | if ( ! syncExternalApplication("sharp") ) |
694 | qDebug("ERROR sync sharp ");; | 714 | qDebug("ERROR sync sharp ");; |
695 | } | 715 | } |
696 | 716 | ||
697 | bool KSyncManager::syncExternalApplication(QString resource) | 717 | bool KSyncManager::syncExternalApplication(QString resource) |
698 | { | 718 | { |
699 | 719 | ||
700 | emit save(); | 720 | emit save(); |
701 | 721 | ||
702 | if ( mAskForPreferences ) | 722 | if ( mAskForPreferences ) |
703 | edit_sync_options(); | 723 | edit_sync_options(); |
704 | 724 | ||
705 | qDebug("sync %s", resource.latin1()); | 725 | qDebug("sync %s", resource.latin1()); |
706 | 726 | ||
707 | bool syncOK = mImplementation->syncExternal(this, resource); | 727 | bool syncOK = mImplementation->syncExternal(this, resource); |
708 | 728 | ||
709 | return syncOK; | 729 | return syncOK; |
710 | 730 | ||
711 | } | 731 | } |
712 | 732 | ||
713 | void KSyncManager::syncPhone() | 733 | void KSyncManager::syncPhone() |
714 | { | 734 | { |
715 | emit save(); | ||
716 | 735 | ||
717 | qDebug("pending syncPhone(); "); | 736 | syncExternalApplication("phone"); |
718 | //mView->syncPhone(); | ||
719 | 737 | ||
720 | } | 738 | } |
721 | 739 | ||
722 | void KSyncManager::showProgressBar(int percentage, QString caption, int total) | 740 | void KSyncManager::showProgressBar(int percentage, QString caption, int total) |
723 | { | 741 | { |
724 | if (!bar->isVisible()) | 742 | if (!bar->isVisible()) |
725 | { | 743 | { |
726 | bar->setCaption (caption); | 744 | bar->setCaption (caption); |
727 | bar->setTotalSteps ( total ) ; | 745 | bar->setTotalSteps ( total ) ; |
728 | 746 | ||
729 | bar->show(); | 747 | bar->show(); |
730 | } | 748 | } |
731 | 749 | ||
732 | bar->setProgress( percentage ); | 750 | bar->setProgress( percentage ); |
733 | } | 751 | } |
734 | 752 | ||
735 | void KSyncManager::hideProgressBar() | 753 | void KSyncManager::hideProgressBar() |
736 | { | 754 | { |
737 | bar->hide(); | 755 | bar->hide(); |
738 | } | 756 | } |
739 | 757 | ||
740 | bool KSyncManager::isProgressBarCanceled() | 758 | bool KSyncManager::isProgressBarCanceled() |
741 | { | 759 | { |
742 | return !bar->isVisible(); | 760 | return !bar->isVisible(); |
743 | } | 761 | } |
744 | 762 | ||
745 | QString KSyncManager::syncFileName() | 763 | QString KSyncManager::syncFileName() |
746 | { | 764 | { |
747 | 765 | ||
748 | QString fn = "tempfile"; | 766 | QString fn = "tempfile"; |
749 | switch(mTargetApp) | 767 | switch(mTargetApp) |
750 | { | 768 | { |
751 | case (KAPI): | 769 | case (KAPI): |
752 | fn = "tempsyncab.vcf"; | 770 | fn = "tempsyncab.vcf"; |
753 | break; | 771 | break; |
754 | case (KOPI): | 772 | case (KOPI): |
755 | fn = "tempsynccal.ics"; | 773 | fn = "tempsynccal.ics"; |
756 | break; | 774 | break; |
757 | case (PWMPI): | 775 | case (PWMPI): |
758 | fn = "tempsyncpw.pwm"; | 776 | fn = "tempsyncpw.pwm"; |
759 | break; | 777 | break; |
760 | default: | 778 | default: |
761 | break; | 779 | break; |
762 | } | 780 | } |
763 | #ifdef _WIN32_ | 781 | #ifdef _WIN32_ |
764 | return locateLocal( "tmp", fn ); | 782 | return locateLocal( "tmp", fn ); |
765 | #else | 783 | #else |
766 | return (QString( "/tmp/" )+ fn ); | 784 | return (QString( "/tmp/" )+ fn ); |
767 | #endif | 785 | #endif |
768 | } | 786 | } |
769 | 787 | ||
788 | |||
770 | void KSyncManager::syncPi() | 789 | void KSyncManager::syncPi() |
771 | { | 790 | { |
772 | qApp->processEvents(); | 791 | qApp->processEvents(); |
773 | bool ok; | 792 | bool ok; |
774 | Q_UINT16 port = mActiveSyncPort.toUInt(&ok); | 793 | Q_UINT16 port = mActiveSyncPort.toUInt(&ok); |
775 | if ( ! ok ) { | 794 | if ( ! ok ) { |
776 | mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); | 795 | mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); |
777 | return; | 796 | return; |
778 | } | 797 | } |
779 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this ); | 798 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this ); |
780 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); | 799 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); |
781 | mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") ); | 800 | mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") ); |
782 | commandSocket->readFile( syncFileName() ); | 801 | commandSocket->readFile( syncFileName() ); |
783 | } | 802 | } |
784 | 803 | ||
785 | void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) | 804 | void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) |
786 | { | 805 | { |
787 | qDebug("MainWindow::deleteCommandSocket %d", state); | 806 | qDebug("MainWindow::deleteCommandSocket %d", state); |
788 | 807 | ||
789 | //enum { success, errorW, errorR, quiet }; | 808 | //enum { success, errorW, errorR, quiet }; |
790 | if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) { | 809 | if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) { |
791 | mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); | 810 | mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); |
792 | delete s; | 811 | delete s; |
793 | if ( state == KCommandSocket::errorR ) { | 812 | if ( state == KCommandSocket::errorR ) { |
794 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); | 813 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); |
795 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); | 814 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); |
796 | commandSocket->sendStop(); | 815 | commandSocket->sendStop(); |
797 | } | 816 | } |
798 | return; | 817 | return; |
799 | 818 | ||
800 | } else if ( state == KCommandSocket::errorW ) { | 819 | } else if ( state == KCommandSocket::errorW ) { |
801 | mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); | 820 | mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); |
802 | 821 | ||
803 | } else if ( state == KCommandSocket::successR ) { | 822 | } else if ( state == KCommandSocket::successR ) { |
804 | QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); | 823 | QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); |
805 | 824 | ||
806 | } else if ( state == KCommandSocket::successW ) { | 825 | } else if ( state == KCommandSocket::successW ) { |
807 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); | 826 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); |
808 | } | 827 | } |
809 | 828 | ||
810 | delete s; | 829 | delete s; |
811 | } | 830 | } |
812 | 831 | ||
813 | void KSyncManager::readFileFromSocket() | 832 | void KSyncManager::readFileFromSocket() |
814 | { | 833 | { |
815 | QString fileName = syncFileName(); | 834 | QString fileName = syncFileName(); |
816 | mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); | 835 | mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); |
817 | if ( ! syncWithFile( fileName , true ) ) { | 836 | if ( ! syncWithFile( fileName , true ) ) { |
818 | mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); | 837 | mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); |
819 | qDebug("Syncing failed "); | 838 | qDebug("Syncing failed "); |
820 | return; | 839 | return; |
821 | } | 840 | } |
822 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); | 841 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); |
823 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); | 842 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); |
824 | if ( mWriteBackFile ) | 843 | if ( mWriteBackFile ) |
825 | commandSocket->writeFile( fileName ); | 844 | commandSocket->writeFile( fileName ); |
826 | else { | 845 | else { |
827 | commandSocket->sendStop(); | 846 | commandSocket->sendStop(); |
828 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); | 847 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); |
829 | } | 848 | } |
830 | } | 849 | } |
831 | 850 | ||
832 | KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) | 851 | KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) |
833 | { | 852 | { |
834 | mPassWord = pw; | 853 | mPassWord = pw; |
835 | mSocket = 0; | 854 | mSocket = 0; |
836 | mSyncActionDialog = 0; | 855 | mSyncActionDialog = 0; |
837 | blockRC = false; | 856 | blockRC = false; |
838 | }; | 857 | }; |
839 | 858 | ||
840 | void KServerSocket::newConnection ( int socket ) | 859 | void KServerSocket::newConnection ( int socket ) |
841 | { | 860 | { |
842 | // qDebug("KServerSocket:New connection %d ", socket); | 861 | // qDebug("KServerSocket:New connection %d ", socket); |
843 | if ( mSocket ) { | 862 | if ( mSocket ) { |
844 | qDebug("KServerSocket::newConnection Socket deleted! "); | 863 | qDebug("KServerSocket::newConnection Socket deleted! "); |
845 | delete mSocket; | 864 | delete mSocket; |
846 | mSocket = 0; | 865 | mSocket = 0; |
847 | } | 866 | } |
848 | mSocket = new QSocket( this ); | 867 | mSocket = new QSocket( this ); |
849 | connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); | 868 | connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); |
850 | connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); | 869 | connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); |
851 | mSocket->setSocket( socket ); | 870 | mSocket->setSocket( socket ); |
852 | } | 871 | } |
853 | 872 | ||
854 | void KServerSocket::discardClient() | 873 | void KServerSocket::discardClient() |
855 | { | 874 | { |
856 | //qDebug(" KServerSocket::discardClient()"); | 875 | //qDebug(" KServerSocket::discardClient()"); |
857 | if ( mSocket ) { | 876 | if ( mSocket ) { |
858 | delete mSocket; | 877 | delete mSocket; |
859 | mSocket = 0; | 878 | mSocket = 0; |
860 | } | 879 | } |
861 | //emit endConnect(); | 880 | //emit endConnect(); |
862 | } | 881 | } |
863 | void KServerSocket::readClient() | 882 | void KServerSocket::readClient() |
864 | { | 883 | { |
865 | if ( blockRC ) | 884 | if ( blockRC ) |
866 | return; | 885 | return; |
867 | if ( mSocket == 0 ) { | 886 | if ( mSocket == 0 ) { |
868 | qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 "); | 887 | qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 "); |
869 | return; | 888 | return; |
870 | } | 889 | } |
871 | qDebug("KServerSocket readClient()"); | 890 | qDebug("KServerSocket readClient()"); |
872 | if ( mSocket->canReadLine() ) { | 891 | if ( mSocket->canReadLine() ) { |
873 | QString line = mSocket->readLine(); | 892 | QString line = mSocket->readLine(); |
874 | qDebug("KServerSocket readline: %s ", line.latin1()); | 893 | qDebug("KServerSocket readline: %s ", line.latin1()); |
875 | QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); | 894 | QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); |
876 | if ( tokens[0] == "GET" ) { | 895 | if ( tokens[0] == "GET" ) { |
877 | if ( tokens[1] == mPassWord ) | 896 | if ( tokens[1] == mPassWord ) |
878 | //emit sendFile( mSocket ); | 897 | //emit sendFile( mSocket ); |
879 | send_file(); | 898 | send_file(); |
880 | else { | 899 | else { |
881 | KMessageBox::information( 0, i18n("ERROR:\nGot send file request\nwith invalid password")); | 900 | KMessageBox::information( 0, i18n("ERROR:\nGot send file request\nwith invalid password")); |
882 | qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); | 901 | qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); |
883 | } | 902 | } |
884 | } | 903 | } |
885 | if ( tokens[0] == "PUT" ) { | 904 | if ( tokens[0] == "PUT" ) { |
886 | if ( tokens[1] == mPassWord ) { | 905 | if ( tokens[1] == mPassWord ) { |
887 | //emit getFile( mSocket ); | 906 | //emit getFile( mSocket ); |
888 | blockRC = true; | 907 | blockRC = true; |
889 | get_file(); | 908 | get_file(); |
890 | } | 909 | } |
891 | else { | 910 | else { |
892 | KMessageBox::information( 0, i18n("ERROR:\nGot receive file request\nwith invalid password")); | 911 | KMessageBox::information( 0, i18n("ERROR:\nGot receive file request\nwith invalid password")); |
893 | qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); | 912 | qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); |
894 | } | 913 | } |
895 | } | 914 | } |
896 | if ( tokens[0] == "STOP" ) { | 915 | if ( tokens[0] == "STOP" ) { |
897 | //emit endConnect(); | 916 | //emit endConnect(); |
898 | end_connect(); | 917 | end_connect(); |
899 | } | 918 | } |
900 | } | 919 | } |
901 | } | 920 | } |
902 | void KServerSocket::end_connect() | 921 | void KServerSocket::end_connect() |
903 | { | 922 | { |
904 | delete mSyncActionDialog; | 923 | delete mSyncActionDialog; |
905 | mSyncActionDialog = 0; | 924 | mSyncActionDialog = 0; |
906 | } | 925 | } |
907 | void KServerSocket::send_file() | 926 | void KServerSocket::send_file() |
908 | { | 927 | { |
909 | //qDebug("MainWindow::sendFile(QSocket* s) "); | 928 | //qDebug("MainWindow::sendFile(QSocket* s) "); |
910 | if ( mSyncActionDialog ) | 929 | if ( mSyncActionDialog ) |
911 | delete mSyncActionDialog; | 930 | delete mSyncActionDialog; |
912 | mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); | 931 | mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); |
913 | mSyncActionDialog->setCaption(i18n("Received sync request")); | 932 | mSyncActionDialog->setCaption(i18n("Received sync request")); |
914 | QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); | 933 | QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); |
915 | QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); | 934 | QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); |
916 | lay->addWidget( label); | 935 | lay->addWidget( label); |
917 | lay->setMargin(7); | 936 | lay->setMargin(7); |
918 | lay->setSpacing(7); | 937 | lay->setSpacing(7); |
919 | mSyncActionDialog->setFixedSize( 230, 120); | 938 | mSyncActionDialog->setFixedSize( 230, 120); |
920 | mSyncActionDialog->show(); | 939 | mSyncActionDialog->show(); |
921 | mSyncActionDialog->raise(); | 940 | mSyncActionDialog->raise(); |
922 | qDebug("KSS::saving ... "); | 941 | qDebug("KSS::saving ... "); |
923 | emit request_file(); | 942 | emit request_file(); |
924 | qApp->processEvents(); | 943 | qApp->processEvents(); |
925 | QString fileName = mFileName; | 944 | QString fileName = mFileName; |
926 | QFile file( fileName ); | 945 | QFile file( fileName ); |
927 | if (!file.open( IO_ReadOnly ) ) { | 946 | if (!file.open( IO_ReadOnly ) ) { |
928 | delete mSyncActionDialog; | 947 | delete mSyncActionDialog; |
929 | mSyncActionDialog = 0; | 948 | mSyncActionDialog = 0; |
930 | qDebug("KSS::error open file "); | 949 | qDebug("KSS::error open file "); |
931 | mSocket->close(); | 950 | mSocket->close(); |
932 | if ( mSocket->state() == QSocket::Idle ) | 951 | if ( mSocket->state() == QSocket::Idle ) |
933 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | 952 | QTimer::singleShot( 10, this , SLOT ( discardClient())); |
934 | return ; | 953 | return ; |
935 | 954 | ||
936 | } | 955 | } |
937 | mSyncActionDialog->setCaption( i18n("Sending file...") ); | 956 | mSyncActionDialog->setCaption( i18n("Sending file...") ); |
938 | QTextStream ts( &file ); | 957 | QTextStream ts( &file ); |
939 | ts.setEncoding( QTextStream::Latin1 ); | 958 | ts.setEncoding( QTextStream::Latin1 ); |
940 | 959 | ||
941 | QTextStream os( mSocket ); | 960 | QTextStream os( mSocket ); |
942 | os.setEncoding( QTextStream::Latin1 ); | 961 | os.setEncoding( QTextStream::Latin1 ); |
943 | while ( ! ts.atEnd() ) { | 962 | while ( ! ts.atEnd() ) { |
944 | os << ts.readLine() << "\n"; | 963 | os << ts.readLine() << "\n"; |
945 | } | 964 | } |
946 | //os << ts.read(); | 965 | //os << ts.read(); |
947 | file.close(); | 966 | file.close(); |
948 | mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); | 967 | mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); |
949 | mSocket->close(); | 968 | mSocket->close(); |
950 | if ( mSocket->state() == QSocket::Idle ) | 969 | if ( mSocket->state() == QSocket::Idle ) |
951 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | 970 | QTimer::singleShot( 10, this , SLOT ( discardClient())); |
952 | } | 971 | } |
953 | void KServerSocket::get_file() | 972 | void KServerSocket::get_file() |
954 | { | 973 | { |
955 | mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); | 974 | mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); |
956 | 975 | ||
957 | piTime.start(); | 976 | piTime.start(); |
958 | piFileString = ""; | 977 | piFileString = ""; |
959 | QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); | 978 | QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); |
960 | } | 979 | } |
961 | 980 | ||
962 | 981 | ||
963 | void KServerSocket::readBackFileFromSocket() | 982 | void KServerSocket::readBackFileFromSocket() |
964 | { | 983 | { |
965 | //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); | 984 | //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); |
966 | while ( mSocket->canReadLine () ) { | 985 | while ( mSocket->canReadLine () ) { |
967 | piTime.restart(); | 986 | piTime.restart(); |
968 | QString line = mSocket->readLine (); | 987 | QString line = mSocket->readLine (); |
969 | piFileString += line; | 988 | piFileString += line; |
970 | //qDebug("readline: %s ", line.latin1()); | 989 | //qDebug("readline: %s ", line.latin1()); |
971 | mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); | 990 | mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); |
972 | 991 | ||
973 | } | 992 | } |
974 | if ( piTime.elapsed () < 3000 ) { | 993 | if ( piTime.elapsed () < 3000 ) { |
975 | // wait for more | 994 | // wait for more |
976 | //qDebug("waitformore "); | 995 | //qDebug("waitformore "); |
977 | QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); | 996 | QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); |
978 | return; | 997 | return; |
979 | } | 998 | } |
980 | QString fileName = mFileName; | 999 | QString fileName = mFileName; |
981 | QFile file ( fileName ); | 1000 | QFile file ( fileName ); |
982 | if (!file.open( IO_WriteOnly ) ) { | 1001 | if (!file.open( IO_WriteOnly ) ) { |
983 | delete mSyncActionDialog; | 1002 | delete mSyncActionDialog; |
984 | mSyncActionDialog = 0; | 1003 | mSyncActionDialog = 0; |
985 | qDebug("error open cal file "); | 1004 | qDebug("error open cal file "); |
986 | piFileString = ""; | 1005 | piFileString = ""; |
987 | emit file_received( false ); | 1006 | emit file_received( false ); |
988 | blockRC = false; | 1007 | blockRC = false; |
989 | return ; | 1008 | return ; |
990 | 1009 | ||
991 | } | 1010 | } |
992 | 1011 | ||
993 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); | 1012 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); |
994 | QTextStream ts ( &file ); | 1013 | QTextStream ts ( &file ); |
995 | ts.setEncoding( QTextStream::Latin1 ); | 1014 | ts.setEncoding( QTextStream::Latin1 ); |
996 | mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); | 1015 | mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); |
997 | ts << piFileString; | 1016 | ts << piFileString; |
998 | mSocket->close(); | 1017 | mSocket->close(); |
999 | if ( mSocket->state() == QSocket::Idle ) | 1018 | if ( mSocket->state() == QSocket::Idle ) |
1000 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | 1019 | QTimer::singleShot( 10, this , SLOT ( discardClient())); |
1001 | file.close(); | 1020 | file.close(); |
1002 | delete mSyncActionDialog; | 1021 | delete mSyncActionDialog; |
1003 | mSyncActionDialog = 0; | 1022 | mSyncActionDialog = 0; |
1004 | piFileString = ""; | 1023 | piFileString = ""; |
1005 | blockRC = false; | 1024 | blockRC = false; |
1006 | emit file_received( true ); | 1025 | emit file_received( true ); |
1007 | 1026 | ||
1008 | } | 1027 | } |
1009 | 1028 | ||
1010 | KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name ) | 1029 | KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name ) |
1011 | { | 1030 | { |
1012 | mPassWord = password; | 1031 | mPassWord = password; |
1013 | mSocket = 0; | 1032 | mSocket = 0; |
1014 | mPort = port; | 1033 | mPort = port; |
1015 | mHost = host; | 1034 | mHost = host; |
1016 | 1035 | ||
1017 | mRetVal = quiet; | 1036 | mRetVal = quiet; |
1018 | mTimerSocket = new QTimer ( this ); | 1037 | mTimerSocket = new QTimer ( this ); |
1019 | connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) ); | 1038 | connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) ); |
1020 | } | 1039 | } |
1021 | void KCommandSocket::readFile( QString fn ) | 1040 | void KCommandSocket::readFile( QString fn ) |
1022 | { | 1041 | { |
1023 | if ( !mSocket ) { | 1042 | if ( !mSocket ) { |
1024 | mSocket = new QSocket( this ); | 1043 | mSocket = new QSocket( this ); |
1025 | connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); | 1044 | connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); |
1026 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 1045 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
1027 | } | 1046 | } |
1028 | mFileString = ""; | 1047 | mFileString = ""; |
1029 | mFileName = fn; | 1048 | mFileName = fn; |
1030 | mFirst = true; | 1049 | mFirst = true; |
1031 | mSocket->connectToHost( mHost, mPort ); | 1050 | mSocket->connectToHost( mHost, mPort ); |
1032 | QTextStream os( mSocket ); | 1051 | QTextStream os( mSocket ); |
1033 | os.setEncoding( QTextStream::Latin1 ); | 1052 | os.setEncoding( QTextStream::Latin1 ); |
1034 | os << "GET " << mPassWord << "\r\n"; | 1053 | os << "GET " << mPassWord << "\r\n"; |
1035 | mTimerSocket->start( 10000 ); | 1054 | mTimerSocket->start( 10000 ); |
1036 | } | 1055 | } |
1037 | 1056 | ||
1038 | void KCommandSocket::writeFile( QString fileName ) | 1057 | void KCommandSocket::writeFile( QString fileName ) |
1039 | { | 1058 | { |
1040 | if ( !mSocket ) { | 1059 | if ( !mSocket ) { |
1041 | mSocket = new QSocket( this ); | 1060 | mSocket = new QSocket( this ); |
1042 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 1061 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
1043 | connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); | 1062 | connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); |
1044 | } | 1063 | } |
1045 | mFileName = fileName ; | 1064 | mFileName = fileName ; |
1046 | mSocket->connectToHost( mHost, mPort ); | 1065 | mSocket->connectToHost( mHost, mPort ); |
1047 | } | 1066 | } |
1048 | void KCommandSocket::writeFileToSocket() | 1067 | void KCommandSocket::writeFileToSocket() |
1049 | { | 1068 | { |
1050 | QFile file2( mFileName ); | 1069 | QFile file2( mFileName ); |
1051 | if (!file2.open( IO_ReadOnly ) ) { | 1070 | if (!file2.open( IO_ReadOnly ) ) { |
1052 | mRetVal= errorW; | 1071 | mRetVal= errorW; |
1053 | mSocket->close(); | 1072 | mSocket->close(); |
1054 | if ( mSocket->state() == QSocket::Idle ) | 1073 | if ( mSocket->state() == QSocket::Idle ) |
1055 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 1074 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
1056 | return ; | 1075 | return ; |
1057 | } | 1076 | } |
1058 | QTextStream ts2( &file2 ); | 1077 | QTextStream ts2( &file2 ); |
1059 | ts2.setEncoding( QTextStream::Latin1 ); | 1078 | ts2.setEncoding( QTextStream::Latin1 ); |
1060 | QTextStream os2( mSocket ); | 1079 | QTextStream os2( mSocket ); |
1061 | os2.setEncoding( QTextStream::Latin1 ); | 1080 | os2.setEncoding( QTextStream::Latin1 ); |
1062 | os2 << "PUT " << mPassWord << "\r\n";; | 1081 | os2 << "PUT " << mPassWord << "\r\n";; |
1063 | while ( ! ts2.atEnd() ) { | 1082 | while ( ! ts2.atEnd() ) { |
1064 | os2 << ts2.readLine() << "\n"; | 1083 | os2 << ts2.readLine() << "\n"; |
1065 | } | 1084 | } |
1066 | mRetVal= successW; | 1085 | mRetVal= successW; |
1067 | file2.close(); | 1086 | file2.close(); |
1068 | mSocket->close(); | 1087 | mSocket->close(); |
1069 | if ( mSocket->state() == QSocket::Idle ) | 1088 | if ( mSocket->state() == QSocket::Idle ) |
1070 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 1089 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
1071 | } | 1090 | } |
1072 | void KCommandSocket::sendStop() | 1091 | void KCommandSocket::sendStop() |
1073 | { | 1092 | { |
1074 | if ( !mSocket ) { | 1093 | if ( !mSocket ) { |
1075 | mSocket = new QSocket( this ); | 1094 | mSocket = new QSocket( this ); |
1076 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 1095 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
1077 | } | 1096 | } |
1078 | mSocket->connectToHost( mHost, mPort ); | 1097 | mSocket->connectToHost( mHost, mPort ); |
1079 | QTextStream os2( mSocket ); | 1098 | QTextStream os2( mSocket ); |
1080 | os2.setEncoding( QTextStream::Latin1 ); | 1099 | os2.setEncoding( QTextStream::Latin1 ); |
1081 | os2 << "STOP\r\n"; | 1100 | os2 << "STOP\r\n"; |
1082 | mSocket->close(); | 1101 | mSocket->close(); |
1083 | if ( mSocket->state() == QSocket::Idle ) | 1102 | if ( mSocket->state() == QSocket::Idle ) |
1084 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 1103 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
1085 | } | 1104 | } |
1086 | 1105 | ||
1087 | void KCommandSocket::startReadFileFromSocket() | 1106 | void KCommandSocket::startReadFileFromSocket() |
1088 | { | 1107 | { |
1089 | if ( ! mFirst ) | 1108 | if ( ! mFirst ) |
1090 | return; | 1109 | return; |
1091 | mFirst = false; | 1110 | mFirst = false; |
1092 | mTimerSocket->stop(); | 1111 | mTimerSocket->stop(); |
1093 | mFileString = ""; | 1112 | mFileString = ""; |
1094 | mTime.start(); | 1113 | mTime.start(); |
1095 | QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); | 1114 | QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); |
1096 | 1115 | ||
1097 | } | 1116 | } |
1098 | void KCommandSocket::readFileFromSocket() | 1117 | void KCommandSocket::readFileFromSocket() |
1099 | { | 1118 | { |
1100 | //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); | 1119 | //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); |
1101 | while ( mSocket->canReadLine () ) { | 1120 | while ( mSocket->canReadLine () ) { |
1102 | mTime.restart(); | 1121 | mTime.restart(); |
1103 | QString line = mSocket->readLine (); | 1122 | QString line = mSocket->readLine (); |
1104 | mFileString += line; | 1123 | mFileString += line; |
1105 | //qDebug("readline: %s ", line.latin1()); | 1124 | //qDebug("readline: %s ", line.latin1()); |
1106 | } | 1125 | } |
1107 | if ( mTime.elapsed () < 3000 ) { | 1126 | if ( mTime.elapsed () < 3000 ) { |
1108 | // wait for more | 1127 | // wait for more |
1109 | //qDebug("waitformore "); | 1128 | //qDebug("waitformore "); |
1110 | QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); | 1129 | QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); |
1111 | return; | 1130 | return; |
1112 | } | 1131 | } |
1113 | QString fileName = mFileName; | 1132 | QString fileName = mFileName; |
1114 | QFile file ( fileName ); | 1133 | QFile file ( fileName ); |
1115 | if (!file.open( IO_WriteOnly ) ) { | 1134 | if (!file.open( IO_WriteOnly ) ) { |
1116 | mFileString = ""; | 1135 | mFileString = ""; |
1117 | mRetVal = errorR; | 1136 | mRetVal = errorR; |
1118 | qDebug("Error open temp calender file for writing: %s",fileName.latin1() ); | 1137 | qDebug("Error open temp calender file for writing: %s",fileName.latin1() ); |
1119 | deleteSocket(); | 1138 | deleteSocket(); |
1120 | return ; | 1139 | return ; |
1121 | 1140 | ||
1122 | } | 1141 | } |
1123 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); | 1142 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); |
1124 | QTextStream ts ( &file ); | 1143 | QTextStream ts ( &file ); |
1125 | ts.setEncoding( QTextStream::Latin1 ); | 1144 | ts.setEncoding( QTextStream::Latin1 ); |
1126 | ts << mFileString; | 1145 | ts << mFileString; |
1127 | file.close(); | 1146 | file.close(); |
1128 | mFileString = ""; | 1147 | mFileString = ""; |
1129 | mRetVal = successR; | 1148 | mRetVal = successR; |
1130 | mSocket->close(); | 1149 | mSocket->close(); |
1131 | // if state is not idle, deleteSocket(); is called via | 1150 | // if state is not idle, deleteSocket(); is called via |
1132 | // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 1151 | // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
1133 | if ( mSocket->state() == QSocket::Idle ) | 1152 | if ( mSocket->state() == QSocket::Idle ) |
1134 | deleteSocket(); | 1153 | deleteSocket(); |
1135 | } | 1154 | } |
1136 | 1155 | ||
1137 | void KCommandSocket::deleteSocket() | 1156 | void KCommandSocket::deleteSocket() |
1138 | { | 1157 | { |
1139 | if ( mTimerSocket->isActive () ) { | 1158 | if ( mTimerSocket->isActive () ) { |
1140 | mTimerSocket->stop(); | 1159 | mTimerSocket->stop(); |
1141 | KMessageBox::information( 0, i18n("ERROR:\nConnection to remote host timed out!\nDid you forgot to enable\nsyncing on remote host? ")); | 1160 | KMessageBox::information( 0, i18n("ERROR:\nConnection to remote host timed out!\nDid you forgot to enable\nsyncing on remote host? ")); |
1142 | mRetVal = errorTO; | 1161 | mRetVal = errorTO; |
1143 | if ( mSocket ) { | 1162 | if ( mSocket ) { |
1144 | mSocket->close(); | 1163 | mSocket->close(); |
1145 | if ( mSocket->state() == QSocket::Idle ) | 1164 | if ( mSocket->state() == QSocket::Idle ) |
1146 | deleteSocket(); | 1165 | deleteSocket(); |
1147 | return; | 1166 | return; |
1148 | } | 1167 | } |
1149 | } | 1168 | } |
1150 | //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); | 1169 | //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); |
1151 | if ( mSocket) | 1170 | if ( mSocket) |
1152 | delete mSocket; | 1171 | delete mSocket; |
1153 | mSocket = 0; | 1172 | mSocket = 0; |
1154 | emit commandFinished( this, mRetVal ); | 1173 | emit commandFinished( this, mRetVal ); |
1155 | } | 1174 | } |
1156 | |||
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h index 25892d8..7027894 100644 --- a/libkdepim/ksyncmanager.h +++ b/libkdepim/ksyncmanager.h | |||
@@ -1,227 +1,226 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KDE-Pim/Pi. | 2 | This file is part of KDE-Pim/Pi. |
3 | Copyright (c) 2004 Ulf Schenk | 3 | Copyright (c) 2004 Ulf Schenk |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | 19 | ||
20 | $Id$ | 20 | $Id$ |
21 | */ | 21 | */ |
22 | #ifndef _KSYNCMANAGER_H | 22 | #ifndef _KSYNCMANAGER_H |
23 | #define _KSYNCMANAGER_H | 23 | #define _KSYNCMANAGER_H |
24 | 24 | ||
25 | #include <qobject.h> | 25 | #include <qobject.h> |
26 | #include <qstring.h> | 26 | #include <qstring.h> |
27 | #include <qsocket.h> | 27 | #include <qsocket.h> |
28 | #include <qdatetime.h> | 28 | #include <qdatetime.h> |
29 | #include <qserversocket.h> | 29 | #include <qserversocket.h> |
30 | #include <qtextstream.h> | 30 | #include <qtextstream.h> |
31 | #include <qregexp.h> | 31 | #include <qregexp.h> |
32 | 32 | ||
33 | class QPopupMenu; | 33 | class QPopupMenu; |
34 | class KSyncProfile; | 34 | class KSyncProfile; |
35 | class KPimPrefs; | 35 | class KPimPrefs; |
36 | class QWidget; | 36 | class QWidget; |
37 | class KSyncManager; | 37 | class KSyncManager; |
38 | class KSyncInterface; | 38 | class KSyncInterface; |
39 | class QProgressBar; | 39 | class QProgressBar; |
40 | 40 | ||
41 | 41 | ||
42 | class KServerSocket : public QServerSocket | 42 | class KServerSocket : public QServerSocket |
43 | { | 43 | { |
44 | Q_OBJECT | 44 | Q_OBJECT |
45 | 45 | ||
46 | public: | 46 | public: |
47 | KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ); | 47 | KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ); |
48 | 48 | ||
49 | void newConnection ( int socket ) ; | 49 | void newConnection ( int socket ) ; |
50 | void setFileName( QString fn ) {mFileName = fn;}; | 50 | void setFileName( QString fn ) {mFileName = fn;}; |
51 | 51 | ||
52 | signals: | 52 | signals: |
53 | void file_received( bool ); | 53 | void file_received( bool ); |
54 | void request_file(); | 54 | void request_file(); |
55 | void saveFile(); | 55 | void saveFile(); |
56 | void endConnect(); | 56 | void endConnect(); |
57 | private slots: | 57 | private slots: |
58 | void discardClient(); | 58 | void discardClient(); |
59 | void readClient(); | 59 | void readClient(); |
60 | void readBackFileFromSocket(); | 60 | void readBackFileFromSocket(); |
61 | private : | 61 | private : |
62 | bool blockRC; | 62 | bool blockRC; |
63 | void send_file(); | 63 | void send_file(); |
64 | void get_file(); | 64 | void get_file(); |
65 | void end_connect(); | 65 | void end_connect(); |
66 | QDialog* mSyncActionDialog; | 66 | QDialog* mSyncActionDialog; |
67 | QSocket* mSocket; | 67 | QSocket* mSocket; |
68 | QString mPassWord; | 68 | QString mPassWord; |
69 | QString mFileName; | 69 | QString mFileName; |
70 | QTime piTime; | 70 | QTime piTime; |
71 | QString piFileString; | 71 | QString piFileString; |
72 | }; | 72 | }; |
73 | 73 | ||
74 | class KCommandSocket : public QObject | 74 | class KCommandSocket : public QObject |
75 | { | 75 | { |
76 | Q_OBJECT | 76 | Q_OBJECT |
77 | public: | 77 | public: |
78 | enum state { successR, errorR, successW, errorW, errorTO, quiet }; | 78 | enum state { successR, errorR, successW, errorW, errorTO, quiet }; |
79 | KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 ); | 79 | KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 ); |
80 | void readFile( QString ); | 80 | void readFile( QString ); |
81 | void writeFile( QString ); | 81 | void writeFile( QString ); |
82 | void sendStop(); | 82 | void sendStop(); |
83 | 83 | ||
84 | 84 | ||
85 | signals: | 85 | signals: |
86 | void commandFinished( KCommandSocket*, int ); | 86 | void commandFinished( KCommandSocket*, int ); |
87 | private slots: | 87 | private slots: |
88 | void startReadFileFromSocket(); | 88 | void startReadFileFromSocket(); |
89 | void readFileFromSocket(); | 89 | void readFileFromSocket(); |
90 | void deleteSocket(); | 90 | void deleteSocket(); |
91 | void writeFileToSocket(); | 91 | void writeFileToSocket(); |
92 | private : | 92 | private : |
93 | QSocket* mSocket; | 93 | QSocket* mSocket; |
94 | QString mPassWord; | 94 | QString mPassWord; |
95 | Q_UINT16 mPort; | 95 | Q_UINT16 mPort; |
96 | QString mHost; | 96 | QString mHost; |
97 | QString mFileName; | 97 | QString mFileName; |
98 | QTimer* mTimerSocket; | 98 | QTimer* mTimerSocket; |
99 | int mRetVal; | 99 | int mRetVal; |
100 | QTime mTime; | 100 | QTime mTime; |
101 | QString mFileString; | 101 | QString mFileString; |
102 | bool mFirst; | 102 | bool mFirst; |
103 | }; | 103 | }; |
104 | 104 | ||
105 | 105 | ||
106 | class KSyncManager : public QObject | 106 | class KSyncManager : public QObject |
107 | { | 107 | { |
108 | Q_OBJECT | 108 | Q_OBJECT |
109 | 109 | ||
110 | public: | 110 | public: |
111 | enum TargetApp { | 111 | enum TargetApp { |
112 | KOPI = 0, | 112 | KOPI = 0, |
113 | KAPI = 1, | 113 | KAPI = 1, |
114 | PWMPI = 2 }; | 114 | PWMPI = 2 }; |
115 | 115 | ||
116 | 116 | ||
117 | KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu); | 117 | KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu); |
118 | ~KSyncManager() ; | 118 | ~KSyncManager() ; |
119 | 119 | ||
120 | void multiSync( bool askforPrefs ); | ||
120 | bool blockSave() { return mBlockSaveFlag; } | 121 | bool blockSave() { return mBlockSaveFlag; } |
121 | void setBlockSave(bool sa) { mBlockSaveFlag = sa; } | 122 | void setBlockSave(bool sa) { mBlockSaveFlag = sa; } |
122 | void setDefaultFileName( QString s) { mDefFileName = s ;} | 123 | void setDefaultFileName( QString s) { mDefFileName = s ;} |
123 | QString defaultFileName() { return mDefFileName ;} | 124 | QString defaultFileName() { return mDefFileName ;} |
124 | QString syncFileName(); | 125 | QString syncFileName(); |
125 | void fillSyncMenu(); | 126 | void fillSyncMenu(); |
126 | 127 | ||
127 | QString getCurrentSyncDevice() { return mCurrentSyncDevice; } | 128 | QString getCurrentSyncDevice() { return mCurrentSyncDevice; } |
128 | QString getCurrentSyncName() { return mCurrentSyncName; } | 129 | QString getCurrentSyncName() { return mCurrentSyncName; } |
129 | 130 | ||
130 | void showProgressBar(int percentage, QString caption = QString::null, int total=100); | 131 | void showProgressBar(int percentage, QString caption = QString::null, int total=100); |
131 | void hideProgressBar(); | 132 | void hideProgressBar(); |
132 | bool isProgressBarCanceled(); | 133 | bool isProgressBarCanceled(); |
133 | 134 | ||
134 | // sync stuff | 135 | // sync stuff |
135 | QString mLocalMachineName; | 136 | QString mLocalMachineName; |
136 | QStringList mExternSyncProfiles; | 137 | QStringList mExternSyncProfiles; |
137 | QStringList mSyncProfileNames; | 138 | QStringList mSyncProfileNames; |
138 | bool mAskForPreferences; | 139 | bool mAskForPreferences; |
139 | bool mShowSyncSummary; | 140 | bool mShowSyncSummary; |
140 | bool mShowSyncEvents; | 141 | bool mShowSyncEvents; |
141 | bool mShowTodoInAgenda; | 142 | bool mShowTodoInAgenda; |
142 | bool mWriteBackExistingOnly; | 143 | bool mWriteBackExistingOnly; |
143 | int mSyncAlgoPrefs; | 144 | int mSyncAlgoPrefs; |
144 | int mRingSyncAlgoPrefs; | 145 | int mRingSyncAlgoPrefs; |
145 | bool mWriteBackFile; | 146 | bool mWriteBackFile; |
146 | int mWriteBackInFuture; | 147 | int mWriteBackInFuture; |
147 | QString mPhoneDevice; | 148 | QString mPhoneDevice; |
148 | QString mPhoneConnection; | 149 | QString mPhoneConnection; |
149 | QString mPhoneModel; | 150 | QString mPhoneModel; |
150 | QString mLastSyncedLocalFile; // save! | ||
151 | QString mPassWordPiSync; | 151 | QString mPassWordPiSync; |
152 | QString mActiveSyncPort; | 152 | QString mActiveSyncPort; |
153 | QString mActiveSyncIP ; | 153 | QString mActiveSyncIP ; |
154 | 154 | ||
155 | signals: | 155 | signals: |
156 | void save(); | 156 | void save(); |
157 | void request_file(); | 157 | void request_file(); |
158 | void getFile( bool ); | 158 | void getFile( bool ); |
159 | 159 | ||
160 | public slots: | 160 | public slots: |
161 | void slotSyncMenu( int ); | 161 | void slotSyncMenu( int ); |
162 | void deleteCommandSocket(KCommandSocket*s, int state); | 162 | void deleteCommandSocket(KCommandSocket*s, int state); |
163 | void readFileFromSocket(); | 163 | void readFileFromSocket(); |
164 | 164 | ||
165 | private: | 165 | private: |
166 | // LR ******************************* | 166 | // LR ******************************* |
167 | // sync stuff! | 167 | // sync stuff! |
168 | void syncPi(); | 168 | void syncPi(); |
169 | KServerSocket * mServerSocket; | 169 | KServerSocket * mServerSocket; |
170 | void enableQuick(); | 170 | void enableQuick(); |
171 | KPimPrefs* mPrefs; | 171 | KPimPrefs* mPrefs; |
172 | QString mDefFileName; | 172 | QString mDefFileName; |
173 | QString mCurrentSyncDevice; | 173 | QString mCurrentSyncDevice; |
174 | QString mCurrentSyncName; | 174 | QString mCurrentSyncName; |
175 | void quickSyncLocalFile(); | 175 | void quickSyncLocalFile(); |
176 | bool syncWithFile( QString fn , bool quick ); | 176 | bool syncWithFile( QString fn , bool quick ); |
177 | void syncLocalFile(); | 177 | void syncLocalFile(); |
178 | void syncPhone(); | 178 | void syncPhone(); |
179 | void syncSharp(); | 179 | void syncSharp(); |
180 | bool syncExternalApplication(QString); | 180 | bool syncExternalApplication(QString); |
181 | void multiSync( bool askforPrefs ); | ||
182 | int mCurrentSyncProfile ; | 181 | int mCurrentSyncProfile ; |
183 | void syncRemote( KSyncProfile* prof, bool ask = true); | 182 | void syncRemote( KSyncProfile* prof, bool ask = true); |
184 | void edit_sync_options(); | 183 | void edit_sync_options(); |
185 | int ringSync(); | 184 | int ringSync(); |
186 | QString getPassword( ); | 185 | QString getPassword( ); |
187 | 186 | ||
188 | private slots: | 187 | private slots: |
189 | void confSync(); | 188 | void confSync(); |
190 | // ********************* | 189 | // ********************* |
191 | 190 | ||
192 | private: | 191 | private: |
193 | bool mBlockSaveFlag; | 192 | bool mBlockSaveFlag; |
194 | 193 | ||
195 | 194 | ||
196 | QWidget* mParent; | 195 | QWidget* mParent; |
197 | KSyncInterface* mImplementation; | 196 | KSyncInterface* mImplementation; |
198 | TargetApp mTargetApp; | 197 | TargetApp mTargetApp; |
199 | QPopupMenu* mSyncMenu; | 198 | QPopupMenu* mSyncMenu; |
200 | 199 | ||
201 | QProgressBar* bar; | 200 | QProgressBar* bar; |
202 | 201 | ||
203 | 202 | ||
204 | 203 | ||
205 | 204 | ||
206 | 205 | ||
207 | }; | 206 | }; |
208 | 207 | ||
209 | 208 | ||
210 | class KSyncInterface | 209 | class KSyncInterface |
211 | { | 210 | { |
212 | 211 | ||
213 | 212 | ||
214 | public : | 213 | public : |
215 | virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0; | 214 | virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0; |
216 | 215 | ||
217 | virtual bool syncExternal(KSyncManager* manager, QString resource) | 216 | virtual bool syncExternal(KSyncManager* manager, QString resource) |
218 | { | 217 | { |
219 | // empty implementation, because some syncable applications do not have an external(sharpdtm) syncmode, like pwmanager. | 218 | // empty implementation, because some syncable applications do not have an external(sharpdtm) syncmode, like pwmanager. |
220 | return false; | 219 | return false; |
221 | } | 220 | } |
222 | 221 | ||
223 | 222 | ||
224 | }; | 223 | }; |
225 | 224 | ||
226 | 225 | ||
227 | #endif | 226 | #endif |