-rw-r--r-- | korganizer/calendarview.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 940ea91..ccacc52 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1406,218 +1406,227 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int | |||
1406 | QProgressBar bar( er.count(),0 ); | 1406 | QProgressBar bar( er.count(),0 ); |
1407 | bar.setCaption (i18n("Syncing - close to abort!") ); | 1407 | bar.setCaption (i18n("Syncing - close to abort!") ); |
1408 | 1408 | ||
1409 | // ************** setting up filter ************* | 1409 | // ************** setting up filter ************* |
1410 | CalFilter *filterIN = 0; | 1410 | CalFilter *filterIN = 0; |
1411 | CalFilter *filterOUT = 0; | 1411 | CalFilter *filterOUT = 0; |
1412 | CalFilter *filter = mFilters.first(); | 1412 | CalFilter *filter = mFilters.first(); |
1413 | while(filter) { | 1413 | while(filter) { |
1414 | if ( filter->name() == mSyncManager->mFilterInCal ) | 1414 | if ( filter->name() == mSyncManager->mFilterInCal ) |
1415 | filterIN = filter; | 1415 | filterIN = filter; |
1416 | if ( filter->name() == mSyncManager->mFilterOutCal ) | 1416 | if ( filter->name() == mSyncManager->mFilterOutCal ) |
1417 | filterOUT = filter; | 1417 | filterOUT = filter; |
1418 | filter = mFilters.next(); | 1418 | filter = mFilters.next(); |
1419 | } | 1419 | } |
1420 | int w = 300; | 1420 | int w = 300; |
1421 | if ( QApplication::desktop()->width() < 320 ) | 1421 | if ( QApplication::desktop()->width() < 320 ) |
1422 | w = 220; | 1422 | w = 220; |
1423 | int h = bar.sizeHint().height() ; | 1423 | int h = bar.sizeHint().height() ; |
1424 | int dw = QApplication::desktop()->width(); | 1424 | int dw = QApplication::desktop()->width(); |
1425 | int dh = QApplication::desktop()->height(); | 1425 | int dh = QApplication::desktop()->height(); |
1426 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1426 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1427 | bar.show(); | 1427 | bar.show(); |
1428 | int modulo = (er.count()/10)+1; | 1428 | int modulo = (er.count()/10)+1; |
1429 | int incCounter = 0; | 1429 | int incCounter = 0; |
1430 | while ( inR ) { | 1430 | while ( inR ) { |
1431 | if ( ! bar.isVisible() ) | 1431 | if ( ! bar.isVisible() ) |
1432 | return false; | 1432 | return false; |
1433 | if ( incCounter % modulo == 0 ) | 1433 | if ( incCounter % modulo == 0 ) |
1434 | bar.setProgress( incCounter ); | 1434 | bar.setProgress( incCounter ); |
1435 | ++incCounter; | 1435 | ++incCounter; |
1436 | uid = inR->uid(); | 1436 | uid = inR->uid(); |
1437 | bool skipIncidence = false; | 1437 | bool skipIncidence = false; |
1438 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1438 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1439 | skipIncidence = true; | 1439 | skipIncidence = true; |
1440 | QString idS; | 1440 | QString idS; |
1441 | qApp->processEvents(); | 1441 | qApp->processEvents(); |
1442 | if ( !skipIncidence ) { | 1442 | if ( !skipIncidence ) { |
1443 | inL = local->incidence( uid ); | 1443 | inL = local->incidence( uid ); |
1444 | if ( inL ) { // maybe conflict - same uid in both calendars | 1444 | if ( inL ) { // maybe conflict - same uid in both calendars |
1445 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1445 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1446 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1446 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1447 | if ( take == 3 ) | 1447 | if ( take == 3 ) |
1448 | return false; | 1448 | return false; |
1449 | if ( take == 1 ) {// take local ********************** | 1449 | if ( take == 1 ) {// take local ********************** |
1450 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1450 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1451 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1451 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1452 | else | 1452 | else |
1453 | idS = inR->IDStr(); | 1453 | idS = inR->IDStr(); |
1454 | int calID = inR->calID(); | ||
1454 | remote->deleteIncidence( inR ); | 1455 | remote->deleteIncidence( inR ); |
1455 | inR = inL->clone(); | 1456 | inR = inL->clone(); |
1457 | inR->setCalID( calID ); | ||
1456 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1458 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1457 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1459 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1458 | inR->setIDStr( idS ); | 1460 | inR->setIDStr( idS ); |
1459 | remote->addIncidence( inR ); | 1461 | remote->addIncidence( inR ); |
1460 | if ( mSyncManager->syncWithDesktop() ) | 1462 | if ( mSyncManager->syncWithDesktop() ) |
1461 | inR->setPilotId( 2 ); | 1463 | inR->setPilotId( 2 ); |
1462 | ++changedRemote; | 1464 | ++changedRemote; |
1463 | } else {// take remote ********************** | 1465 | } else {// take remote ********************** |
1464 | idS = inL->IDStr(); | 1466 | idS = inL->IDStr(); |
1465 | int pid = inL->pilotId(); | 1467 | int pid = inL->pilotId(); |
1468 | int calID = inL->calID(); | ||
1466 | local->deleteIncidence( inL ); | 1469 | local->deleteIncidence( inL ); |
1467 | inL = inR->clone(); | 1470 | inL = inR->clone(); |
1471 | inL->setCalID( calID ); | ||
1468 | if ( mSyncManager->syncWithDesktop() ) | 1472 | if ( mSyncManager->syncWithDesktop() ) |
1469 | inL->setPilotId( pid ); | 1473 | inL->setPilotId( pid ); |
1470 | inL->setIDStr( idS ); | 1474 | inL->setIDStr( idS ); |
1471 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1475 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1472 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1476 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1473 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1477 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1474 | } | 1478 | } |
1475 | local->addIncidence( inL ); | 1479 | local->addIncidence( inL ); |
1476 | ++changedLocal; | 1480 | ++changedLocal; |
1477 | } | 1481 | } |
1478 | } | 1482 | } |
1479 | } else { // no conflict ********** add or delete remote | 1483 | } else { // no conflict ********** add or delete remote |
1480 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ | 1484 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ |
1481 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1485 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1482 | QString des = eventLSync->description(); | 1486 | QString des = eventLSync->description(); |
1483 | QString pref = "e"; | 1487 | QString pref = "e"; |
1484 | if ( inR->typeID() == todoID ) | 1488 | if ( inR->typeID() == todoID ) |
1485 | pref = "t"; | 1489 | pref = "t"; |
1486 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1490 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1487 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1491 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1488 | //remote->deleteIncidence( inR ); | 1492 | //remote->deleteIncidence( inR ); |
1489 | ++deletedEventR; | 1493 | ++deletedEventR; |
1490 | } else { | 1494 | } else { |
1491 | inR->setLastModified( modifiedCalendar ); | 1495 | inR->setLastModified( modifiedCalendar ); |
1492 | inL = inR->clone(); | 1496 | inL = inR->clone(); |
1493 | inL->setIDStr( ":" ); | 1497 | inL->setIDStr( ":" ); |
1494 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1498 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1495 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1499 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1500 | |||
1501 | inL->setCalID( 0 );// add to default cal | ||
1496 | local->addIncidence( inL ); | 1502 | local->addIncidence( inL ); |
1497 | ++addedEvent; | 1503 | ++addedEvent; |
1498 | 1504 | ||
1499 | } | 1505 | } |
1500 | } else { | 1506 | } else { |
1501 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1507 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1502 | inR->setLastModified( modifiedCalendar ); | 1508 | inR->setLastModified( modifiedCalendar ); |
1503 | inL = inR->clone(); | 1509 | inL = inR->clone(); |
1504 | inL->setIDStr( ":" ); | 1510 | inL->setIDStr( ":" ); |
1511 | inL->setCalID( 0 );// add to default cal | ||
1505 | local->addIncidence( inL ); | 1512 | local->addIncidence( inL ); |
1506 | ++addedEvent; | 1513 | ++addedEvent; |
1507 | 1514 | ||
1508 | } else { | 1515 | } else { |
1509 | checkExternSyncEvent(eventRSyncSharp, inR); | 1516 | checkExternSyncEvent(eventRSyncSharp, inR); |
1510 | remote->deleteIncidence( inR ); | 1517 | remote->deleteIncidence( inR ); |
1511 | ++deletedEventR; | 1518 | ++deletedEventR; |
1512 | } | 1519 | } |
1513 | } | 1520 | } |
1514 | } else { | 1521 | } else { |
1515 | ++filteredIN; | 1522 | ++filteredIN; |
1516 | } | 1523 | } |
1517 | } | 1524 | } |
1518 | } | 1525 | } |
1519 | inR = er.next(); | 1526 | inR = er.next(); |
1520 | } | 1527 | } |
1521 | QPtrList<Incidence> el = local->rawIncidences(); | 1528 | QPtrList<Incidence> el = local->rawIncidences(); |
1522 | inL = el.first(); | 1529 | inL = el.first(); |
1523 | modulo = (el.count()/10)+1; | 1530 | modulo = (el.count()/10)+1; |
1524 | bar.setCaption (i18n("Add / remove events") ); | 1531 | bar.setCaption (i18n("Add / remove events") ); |
1525 | bar.setTotalSteps ( el.count() ) ; | 1532 | bar.setTotalSteps ( el.count() ) ; |
1526 | bar.show(); | 1533 | bar.show(); |
1527 | incCounter = 0; | 1534 | incCounter = 0; |
1528 | 1535 | ||
1529 | while ( inL ) { | 1536 | while ( inL ) { |
1530 | 1537 | ||
1531 | qApp->processEvents(); | 1538 | qApp->processEvents(); |
1532 | if ( ! bar.isVisible() ) | 1539 | if ( ! bar.isVisible() ) |
1533 | return false; | 1540 | return false; |
1534 | if ( incCounter % modulo == 0 ) | 1541 | if ( incCounter % modulo == 0 ) |
1535 | bar.setProgress( incCounter ); | 1542 | bar.setProgress( incCounter ); |
1536 | ++incCounter; | 1543 | ++incCounter; |
1537 | uid = inL->uid(); | 1544 | uid = inL->uid(); |
1538 | bool skipIncidence = false; | 1545 | bool skipIncidence = false; |
1539 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1546 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1540 | skipIncidence = true; | 1547 | skipIncidence = true; |
1541 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) | 1548 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) |
1542 | skipIncidence = true; | 1549 | skipIncidence = true; |
1543 | if ( !skipIncidence ) { | 1550 | if ( !skipIncidence ) { |
1544 | inR = remote->incidence( uid ); | 1551 | inR = remote->incidence( uid ); |
1545 | if ( ! inR ) { | 1552 | if ( ! inR ) { |
1546 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ | 1553 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ |
1547 | // no conflict ********** add or delete local | 1554 | // no conflict ********** add or delete local |
1548 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1555 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1549 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1556 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1550 | checkExternSyncEvent(eventLSyncSharp, inL); | 1557 | checkExternSyncEvent(eventLSyncSharp, inL); |
1551 | local->deleteIncidence( inL ); | 1558 | local->deleteIncidence( inL ); |
1552 | ++deletedEventL; | 1559 | ++deletedEventL; |
1553 | } else { | 1560 | } else { |
1554 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1561 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1555 | inL->removeID(mCurrentSyncDevice ); | 1562 | inL->removeID(mCurrentSyncDevice ); |
1556 | ++addedEventR; | 1563 | ++addedEventR; |
1557 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1564 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1558 | inL->setLastModified( modifiedCalendar ); | 1565 | inL->setLastModified( modifiedCalendar ); |
1559 | inR = inL->clone(); | 1566 | inR = inL->clone(); |
1560 | inR->setIDStr( ":" ); | 1567 | inR->setIDStr( ":" ); |
1561 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1568 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1569 | inR->setCalID( 0 );// add to default cal | ||
1562 | remote->addIncidence( inR ); | 1570 | remote->addIncidence( inR ); |
1563 | } | 1571 | } |
1564 | } | 1572 | } |
1565 | } else { | 1573 | } else { |
1566 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1574 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1567 | checkExternSyncEvent(eventLSyncSharp, inL); | 1575 | checkExternSyncEvent(eventLSyncSharp, inL); |
1568 | local->deleteIncidence( inL ); | 1576 | local->deleteIncidence( inL ); |
1569 | ++deletedEventL; | 1577 | ++deletedEventL; |
1570 | } else { | 1578 | } else { |
1571 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1579 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1572 | ++addedEventR; | 1580 | ++addedEventR; |
1573 | inL->setLastModified( modifiedCalendar ); | 1581 | inL->setLastModified( modifiedCalendar ); |
1574 | inR = inL->clone(); | 1582 | inR = inL->clone(); |
1575 | inR->setIDStr( ":" ); | 1583 | inR->setIDStr( ":" ); |
1584 | inR->setCalID( 0 );// add to default cal | ||
1576 | remote->addIncidence( inR ); | 1585 | remote->addIncidence( inR ); |
1577 | } | 1586 | } |
1578 | } | 1587 | } |
1579 | } | 1588 | } |
1580 | } else { | 1589 | } else { |
1581 | ++filteredOUT; | 1590 | ++filteredOUT; |
1582 | } | 1591 | } |
1583 | } | 1592 | } |
1584 | } | 1593 | } |
1585 | inL = el.next(); | 1594 | inL = el.next(); |
1586 | } | 1595 | } |
1587 | int delFut = 0; | 1596 | int delFut = 0; |
1588 | int remRem = 0; | 1597 | int remRem = 0; |
1589 | if ( mSyncManager->mWriteBackInFuture ) { | 1598 | if ( mSyncManager->mWriteBackInFuture ) { |
1590 | er = remote->rawIncidences(); | 1599 | er = remote->rawIncidences(); |
1591 | remRem = er.count(); | 1600 | remRem = er.count(); |
1592 | inR = er.first(); | 1601 | inR = er.first(); |
1593 | QDateTime dt; | 1602 | QDateTime dt; |
1594 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); | 1603 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); |
1595 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); | 1604 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); |
1596 | while ( inR ) { | 1605 | while ( inR ) { |
1597 | if ( inR->typeID() == todoID ) { | 1606 | if ( inR->typeID() == todoID ) { |
1598 | Todo * t = (Todo*)inR; | 1607 | Todo * t = (Todo*)inR; |
1599 | if ( t->hasDueDate() ) | 1608 | if ( t->hasDueDate() ) |
1600 | dt = t->dtDue(); | 1609 | dt = t->dtDue(); |
1601 | else | 1610 | else |
1602 | dt = cur.addSecs( 62 ); | 1611 | dt = cur.addSecs( 62 ); |
1603 | } | 1612 | } |
1604 | else if (inR->typeID() == eventID ) { | 1613 | else if (inR->typeID() == eventID ) { |
1605 | bool ok; | 1614 | bool ok; |
1606 | dt = inR->getNextOccurence( cur, &ok ); | 1615 | dt = inR->getNextOccurence( cur, &ok ); |
1607 | if ( !ok ) | 1616 | if ( !ok ) |
1608 | dt = cur.addSecs( -62 ); | 1617 | dt = cur.addSecs( -62 ); |
1609 | } | 1618 | } |
1610 | else | 1619 | else |
1611 | dt = inR->dtStart(); | 1620 | dt = inR->dtStart(); |
1612 | if ( dt < cur || dt > end ) { | 1621 | if ( dt < cur || dt > end ) { |
1613 | remote->deleteIncidence( inR ); | 1622 | remote->deleteIncidence( inR ); |
1614 | ++delFut; | 1623 | ++delFut; |
1615 | } | 1624 | } |
1616 | inR = er.next(); | 1625 | inR = er.next(); |
1617 | } | 1626 | } |
1618 | } | 1627 | } |
1619 | bar.hide(); | 1628 | bar.hide(); |
1620 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1629 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1621 | eventLSync->setReadOnly( false ); | 1630 | eventLSync->setReadOnly( false ); |
1622 | eventLSync->setDtStart( mLastCalendarSync ); | 1631 | eventLSync->setDtStart( mLastCalendarSync ); |
1623 | eventRSync->setDtStart( mLastCalendarSync ); | 1632 | eventRSync->setDtStart( mLastCalendarSync ); |
@@ -2098,96 +2107,105 @@ bool CalendarView::openCalendar(QString filename, bool merge) | |||
2098 | } | 2107 | } |
2099 | mStorage->setFileName( filename ); | 2108 | mStorage->setFileName( filename ); |
2100 | 2109 | ||
2101 | if ( mStorage->load() ) { | 2110 | if ( mStorage->load() ) { |
2102 | if ( merge ) ;//setModified( true ); | 2111 | if ( merge ) ;//setModified( true ); |
2103 | else { | 2112 | else { |
2104 | //setModified( true ); | 2113 | //setModified( true ); |
2105 | mViewManager->setDocumentId( filename ); | 2114 | mViewManager->setDocumentId( filename ); |
2106 | mDialogManager->setDocumentId( filename ); | 2115 | mDialogManager->setDocumentId( filename ); |
2107 | mTodoList->setDocumentId( filename ); | 2116 | mTodoList->setDocumentId( filename ); |
2108 | } | 2117 | } |
2109 | globalFlagBlockAgenda = 2; | 2118 | globalFlagBlockAgenda = 2; |
2110 | // if ( getLastSyncEvent() ) | 2119 | // if ( getLastSyncEvent() ) |
2111 | // getLastSyncEvent()->setReadOnly( true ); | 2120 | // getLastSyncEvent()->setReadOnly( true ); |
2112 | mCalendar->reInitAlarmSettings(); | 2121 | mCalendar->reInitAlarmSettings(); |
2113 | setSyncEventsReadOnly(); | 2122 | setSyncEventsReadOnly(); |
2114 | updateUnmanagedViews(); | 2123 | updateUnmanagedViews(); |
2115 | updateView(); | 2124 | updateView(); |
2116 | if ( filename != MainWindow::defaultFileName() ) { | 2125 | if ( filename != MainWindow::defaultFileName() ) { |
2117 | saveCalendar( MainWindow::defaultFileName() ); | 2126 | saveCalendar( MainWindow::defaultFileName() ); |
2118 | } else { | 2127 | } else { |
2119 | QFileInfo finf ( MainWindow::defaultFileName()); | 2128 | QFileInfo finf ( MainWindow::defaultFileName()); |
2120 | if ( finf.exists() ) { | 2129 | if ( finf.exists() ) { |
2121 | setLoadedFileVersion( finf.lastModified () ); | 2130 | setLoadedFileVersion( finf.lastModified () ); |
2122 | } | 2131 | } |
2123 | } | 2132 | } |
2124 | return true; | 2133 | return true; |
2125 | } else { | 2134 | } else { |
2126 | // while failing to load, the calendar object could | 2135 | // while failing to load, the calendar object could |
2127 | // have become partially populated. Clear it out. | 2136 | // have become partially populated. Clear it out. |
2128 | if ( !merge ) { | 2137 | if ( !merge ) { |
2129 | mCalendar->close(); | 2138 | mCalendar->close(); |
2130 | mViewManager->setDocumentId( filename ); | 2139 | mViewManager->setDocumentId( filename ); |
2131 | mDialogManager->setDocumentId( filename ); | 2140 | mDialogManager->setDocumentId( filename ); |
2132 | mTodoList->setDocumentId( filename ); | 2141 | mTodoList->setDocumentId( filename ); |
2133 | } | 2142 | } |
2134 | 2143 | ||
2135 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 2144 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
2136 | 2145 | ||
2137 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 2146 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
2138 | globalFlagBlockAgenda = 2; | 2147 | globalFlagBlockAgenda = 2; |
2139 | mCalendar->reInitAlarmSettings(); | 2148 | mCalendar->reInitAlarmSettings(); |
2140 | setSyncEventsReadOnly(); | 2149 | setSyncEventsReadOnly(); |
2141 | updateUnmanagedViews(); | 2150 | updateUnmanagedViews(); |
2142 | updateView(); | 2151 | updateView(); |
2143 | } | 2152 | } |
2144 | return false; | 2153 | return false; |
2145 | } | 2154 | } |
2155 | void CalendarView::mergeFile( QString fn ) | ||
2156 | { | ||
2157 | clearAllViews(); | ||
2158 | mCalendar->mergeCalendarFile( fn ); | ||
2159 | mCalendar->reInitAlarmSettings(); | ||
2160 | setSyncEventsReadOnly(); | ||
2161 | updateUnmanagedViews(); | ||
2162 | updateView(); | ||
2163 | } | ||
2146 | void CalendarView::showOpenError() | 2164 | void CalendarView::showOpenError() |
2147 | { | 2165 | { |
2148 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 2166 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
2149 | } | 2167 | } |
2150 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 2168 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
2151 | { | 2169 | { |
2152 | loadedFileVersion = dt; | 2170 | loadedFileVersion = dt; |
2153 | } | 2171 | } |
2154 | bool CalendarView::checkFileChanged(QString fn) | 2172 | bool CalendarView::checkFileChanged(QString fn) |
2155 | { | 2173 | { |
2156 | QFileInfo finf ( fn ); | 2174 | QFileInfo finf ( fn ); |
2157 | if ( !finf.exists() ) | 2175 | if ( !finf.exists() ) |
2158 | return true; | 2176 | return true; |
2159 | QDateTime dt = finf.lastModified (); | 2177 | QDateTime dt = finf.lastModified (); |
2160 | if ( dt <= loadedFileVersion ) | 2178 | if ( dt <= loadedFileVersion ) |
2161 | return false; | 2179 | return false; |
2162 | return true; | 2180 | return true; |
2163 | 2181 | ||
2164 | } | 2182 | } |
2165 | void CalendarView::watchSavedFile() | 2183 | void CalendarView::watchSavedFile() |
2166 | { | 2184 | { |
2167 | QFileInfo finf ( MainWindow::defaultFileName()); | 2185 | QFileInfo finf ( MainWindow::defaultFileName()); |
2168 | if ( !finf.exists() ) | 2186 | if ( !finf.exists() ) |
2169 | return; | 2187 | return; |
2170 | QDateTime dt = finf.lastModified (); | 2188 | QDateTime dt = finf.lastModified (); |
2171 | if ( dt < loadedFileVersion ) { | 2189 | if ( dt < loadedFileVersion ) { |
2172 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 2190 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
2173 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 2191 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
2174 | return; | 2192 | return; |
2175 | } | 2193 | } |
2176 | loadedFileVersion = dt; | 2194 | loadedFileVersion = dt; |
2177 | } | 2195 | } |
2178 | bool CalendarView::checkAllFileVersions() | 2196 | bool CalendarView::checkAllFileVersions() |
2179 | { | 2197 | { |
2180 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2198 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2181 | KopiCalendarFile * cal = calendars.first(); | 2199 | KopiCalendarFile * cal = calendars.first(); |
2182 | mCalendar->setDefaultCalendar( 1 ); | 2200 | mCalendar->setDefaultCalendar( 1 ); |
2183 | mCalendar->setDefaultCalendarEnabledOnly(); | 2201 | mCalendar->setDefaultCalendarEnabledOnly(); |
2184 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2202 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2185 | if ( !checkFileVersion(MainWindow::defaultFileName())) { | 2203 | if ( !checkFileVersion(MainWindow::defaultFileName())) { |
2186 | restoreCalendarSettings(); | 2204 | restoreCalendarSettings(); |
2187 | return false; | 2205 | return false; |
2188 | } | 2206 | } |
2189 | } | 2207 | } |
2190 | cal = calendars.next(); | 2208 | cal = calendars.next(); |
2191 | QDateTime storeTemp = loadedFileVersion; | 2209 | QDateTime storeTemp = loadedFileVersion; |
2192 | while ( cal ) { | 2210 | while ( cal ) { |
2193 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2211 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
@@ -3313,102 +3331,104 @@ void CalendarView::cloneIncidence(Incidence * orgInc ) | |||
3313 | mTodoEditor->editTodo( t ); | 3331 | mTodoEditor->editTodo( t ); |
3314 | if ( mTodoEditor->exec() ) { | 3332 | if ( mTodoEditor->exec() ) { |
3315 | if ( cloneSub ) { | 3333 | if ( cloneSub ) { |
3316 | orgInc->cloneRelations( t ); | 3334 | orgInc->cloneRelations( t ); |
3317 | mCalendar->addIncidenceBranch( t ); | 3335 | mCalendar->addIncidenceBranch( t ); |
3318 | updateView(); | 3336 | updateView(); |
3319 | 3337 | ||
3320 | } else { | 3338 | } else { |
3321 | mCalendar->addTodo( t ); | 3339 | mCalendar->addTodo( t ); |
3322 | updateView(); | 3340 | updateView(); |
3323 | } | 3341 | } |
3324 | } else { | 3342 | } else { |
3325 | delete t; | 3343 | delete t; |
3326 | } | 3344 | } |
3327 | } | 3345 | } |
3328 | else if ( newInc->typeID() == eventID ) { | 3346 | else if ( newInc->typeID() == eventID ) { |
3329 | Event* e = (Event*) newInc; | 3347 | Event* e = (Event*) newInc; |
3330 | showEventEditor(); | 3348 | showEventEditor(); |
3331 | mEventEditor->editEvent( e ); | 3349 | mEventEditor->editEvent( e ); |
3332 | if ( mEventEditor->exec() ) { | 3350 | if ( mEventEditor->exec() ) { |
3333 | mCalendar->addEvent( e ); | 3351 | mCalendar->addEvent( e ); |
3334 | updateView(); | 3352 | updateView(); |
3335 | } else { | 3353 | } else { |
3336 | delete e; | 3354 | delete e; |
3337 | } | 3355 | } |
3338 | } if ( newInc->typeID() == journalID ) { | 3356 | } if ( newInc->typeID() == journalID ) { |
3339 | mCalendar->addJournal( (Journal*) newInc ); | 3357 | mCalendar->addJournal( (Journal*) newInc ); |
3340 | editJournal( (Journal*) newInc ); | 3358 | editJournal( (Journal*) newInc ); |
3341 | } | 3359 | } |
3342 | setActiveWindow(); | 3360 | setActiveWindow(); |
3343 | } | 3361 | } |
3344 | 3362 | ||
3345 | void CalendarView::newEvent() | 3363 | void CalendarView::newEvent() |
3346 | { | 3364 | { |
3347 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 3365 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
3348 | KOAgendaView *aView = mViewManager->agendaView(); | 3366 | KOAgendaView *aView = mViewManager->agendaView(); |
3349 | if (aView) { | 3367 | if (aView) { |
3350 | if (aView->selectionStart().isValid()) { | 3368 | if (aView->selectionStart().isValid()) { |
3351 | if (aView->selectedIsAllDay()) { | 3369 | if (aView->selectedIsAllDay()) { |
3352 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 3370 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
3353 | } else { | 3371 | } else { |
3354 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 3372 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
3355 | } | 3373 | } |
3356 | return; | 3374 | return; |
3357 | } | 3375 | } |
3358 | } | 3376 | } |
3359 | 3377 | ||
3360 | QDate date = mNavigator->selectedDates().first(); | 3378 | QDate date = mNavigator->selectedDates().first(); |
3379 | #if 0 | ||
3361 | QDateTime current = QDateTime::currentDateTime(); | 3380 | QDateTime current = QDateTime::currentDateTime(); |
3362 | if ( date <= current.date() ) { | 3381 | if ( date <= current.date() ) { |
3363 | int hour = current.time().hour() +1; | 3382 | int hour = current.time().hour() +1; |
3364 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 3383 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
3365 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 3384 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
3366 | } else | 3385 | } else |
3386 | #endif | ||
3367 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 3387 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
3368 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 3388 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
3369 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 3389 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
3370 | } | 3390 | } |
3371 | 3391 | ||
3372 | void CalendarView::newEvent(QDateTime fh) | 3392 | void CalendarView::newEvent(QDateTime fh) |
3373 | { | 3393 | { |
3374 | newEvent(fh, | 3394 | newEvent(fh, |
3375 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 3395 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
3376 | } | 3396 | } |
3377 | 3397 | ||
3378 | void CalendarView::newEvent(QDate dt) | 3398 | void CalendarView::newEvent(QDate dt) |
3379 | { | 3399 | { |
3380 | newEvent(QDateTime(dt, QTime(0,0,0)), | 3400 | newEvent(QDateTime(dt, QTime(0,0,0)), |
3381 | QDateTime(dt, QTime(0,0,0)), true); | 3401 | QDateTime(dt, QTime(0,0,0)), true); |
3382 | } | 3402 | } |
3383 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) | 3403 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) |
3384 | { | 3404 | { |
3385 | newEvent(fromHint, toHint, false); | 3405 | newEvent(fromHint, toHint, false); |
3386 | } | 3406 | } |
3387 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 3407 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
3388 | { | 3408 | { |
3389 | 3409 | ||
3390 | showEventEditor(); | 3410 | showEventEditor(); |
3391 | mEventEditor->newEvent(fromHint,toHint,allDay); | 3411 | mEventEditor->newEvent(fromHint,toHint,allDay); |
3392 | if ( mFilterView->filtersEnabled() ) { | 3412 | if ( mFilterView->filtersEnabled() ) { |
3393 | CalFilter *filter = mFilterView->selectedFilter(); | 3413 | CalFilter *filter = mFilterView->selectedFilter(); |
3394 | if (filter && filter->showCategories()) { | 3414 | if (filter && filter->showCategories()) { |
3395 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 3415 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
3396 | } | 3416 | } |
3397 | if ( filter ) | 3417 | if ( filter ) |
3398 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 3418 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
3399 | } | 3419 | } |
3400 | mEventEditor->exec(); | 3420 | mEventEditor->exec(); |
3401 | setActiveWindow(); | 3421 | setActiveWindow(); |
3402 | } | 3422 | } |
3403 | void CalendarView::todoAdded(Todo * t) | 3423 | void CalendarView::todoAdded(Todo * t) |
3404 | { | 3424 | { |
3405 | 3425 | ||
3406 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 3426 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
3407 | updateTodoViews(); | 3427 | updateTodoViews(); |
3408 | } | 3428 | } |
3409 | void CalendarView::todoChanged(Todo * t) | 3429 | void CalendarView::todoChanged(Todo * t) |
3410 | { | 3430 | { |
3411 | emit todoModified( t, 4 ); | 3431 | emit todoModified( t, 4 ); |
3412 | // updateTodoViews(); | 3432 | // updateTodoViews(); |
3413 | } | 3433 | } |
3414 | void CalendarView::todoToBeDeleted(Todo *) | 3434 | void CalendarView::todoToBeDeleted(Todo *) |