-rw-r--r-- | korganizer/calendarview.cpp | 20 | ||||
-rw-r--r-- | korganizer/calendarview.h | 1 | ||||
-rw-r--r-- | korganizer/journalentry.cpp | 22 | ||||
-rw-r--r-- | korganizer/journalentry.h | 3 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 2 | ||||
-rw-r--r-- | libkcal/calendar.cpp | 1 | ||||
-rw-r--r-- | libkcal/calendar.h | 1 | ||||
-rw-r--r-- | libkcal/calendarlocal.cpp | 75 | ||||
-rw-r--r-- | libkcal/calendarlocal.h | 3 |
9 files changed, 126 insertions, 2 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 940ea91..ccacc52 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1358,314 +1358,323 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int | |||
1358 | QDateTime modifiedCalendar = mLastCalendarSync; | 1358 | QDateTime modifiedCalendar = mLastCalendarSync; |
1359 | eventLSync = getLastSyncEvent(); | 1359 | eventLSync = getLastSyncEvent(); |
1360 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 1360 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
1361 | if ( eventR ) { | 1361 | if ( eventR ) { |
1362 | eventRSync = (Event*) eventR->clone(); | 1362 | eventRSync = (Event*) eventR->clone(); |
1363 | remote->deleteEvent(eventR ); | 1363 | remote->deleteEvent(eventR ); |
1364 | 1364 | ||
1365 | } else { | 1365 | } else { |
1366 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { | 1366 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { |
1367 | eventRSync = (Event*)eventLSync->clone(); | 1367 | eventRSync = (Event*)eventLSync->clone(); |
1368 | } else { | 1368 | } else { |
1369 | fullDateRange = true; | 1369 | fullDateRange = true; |
1370 | eventRSync = new Event(); | 1370 | eventRSync = new Event(); |
1371 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 1371 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
1372 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 1372 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
1373 | eventRSync->setDtStart( mLastCalendarSync ); | 1373 | eventRSync->setDtStart( mLastCalendarSync ); |
1374 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1374 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1375 | eventRSync->setCategories( i18n("SyncEvent") ); | 1375 | eventRSync->setCategories( i18n("SyncEvent") ); |
1376 | } | 1376 | } |
1377 | } | 1377 | } |
1378 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 1378 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
1379 | fullDateRange = true; | 1379 | fullDateRange = true; |
1380 | 1380 | ||
1381 | if ( ! fullDateRange ) { | 1381 | if ( ! fullDateRange ) { |
1382 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 1382 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
1383 | 1383 | ||
1384 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 1384 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
1385 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 1385 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
1386 | fullDateRange = true; | 1386 | fullDateRange = true; |
1387 | } | 1387 | } |
1388 | } | 1388 | } |
1389 | if ( mSyncManager->syncWithDesktop() ) { | 1389 | if ( mSyncManager->syncWithDesktop() ) { |
1390 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); | 1390 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); |
1391 | } | 1391 | } |
1392 | if ( fullDateRange ) | 1392 | if ( fullDateRange ) |
1393 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 1393 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
1394 | else | 1394 | else |
1395 | mLastCalendarSync = eventLSync->dtStart(); | 1395 | mLastCalendarSync = eventLSync->dtStart(); |
1396 | // for resyncing if own file has changed | 1396 | // for resyncing if own file has changed |
1397 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 1397 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
1398 | mLastCalendarSync = loadedFileVersion; | 1398 | mLastCalendarSync = loadedFileVersion; |
1399 | //qDebug("setting mLastCalendarSync "); | 1399 | //qDebug("setting mLastCalendarSync "); |
1400 | } | 1400 | } |
1401 | //qDebug("*************************** "); | 1401 | //qDebug("*************************** "); |
1402 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); | 1402 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); |
1403 | QPtrList<Incidence> er = remote->rawIncidences(); | 1403 | QPtrList<Incidence> er = remote->rawIncidences(); |
1404 | Incidence* inR = er.first(); | 1404 | Incidence* inR = er.first(); |
1405 | Incidence* inL; | 1405 | Incidence* inL; |
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 ); |
1624 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1633 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1625 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1634 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1626 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1635 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1627 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1636 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1628 | eventLSync->setReadOnly( true ); | 1637 | eventLSync->setReadOnly( true ); |
1629 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); | 1638 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); |
1630 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... | 1639 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... |
1631 | remote->addEvent( eventRSync ); | 1640 | remote->addEvent( eventRSync ); |
1632 | else | 1641 | else |
1633 | delete eventRSync; | 1642 | delete eventRSync; |
1634 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); | 1643 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); |
1635 | QString mes; | 1644 | QString mes; |
1636 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); | 1645 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); |
1637 | QString delmess; | 1646 | QString delmess; |
1638 | if ( delFut ) { | 1647 | if ( delFut ) { |
1639 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); | 1648 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); |
1640 | mes += delmess; | 1649 | mes += delmess; |
1641 | } | 1650 | } |
1642 | mes = i18n("Local calendar changed!\n") +mes; | 1651 | mes = i18n("Local calendar changed!\n") +mes; |
1643 | mCalendar->checkAlarmForIncidence( 0, true ); | 1652 | mCalendar->checkAlarmForIncidence( 0, true ); |
1644 | qDebug( mes ); | 1653 | qDebug( mes ); |
1645 | if ( mSyncManager->mShowSyncSummary ) { | 1654 | if ( mSyncManager->mShowSyncSummary ) { |
1646 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 1655 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
1647 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { | 1656 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { |
1648 | qDebug("KO: WB cancelled "); | 1657 | qDebug("KO: WB cancelled "); |
1649 | mSyncManager->mWriteBackFile = false; | 1658 | mSyncManager->mWriteBackFile = false; |
1650 | return syncOK; | 1659 | return syncOK; |
1651 | } | 1660 | } |
1652 | } | 1661 | } |
1653 | return syncOK; | 1662 | return syncOK; |
1654 | } | 1663 | } |
1655 | 1664 | ||
1656 | void CalendarView::setSyncDevice( QString s ) | 1665 | void CalendarView::setSyncDevice( QString s ) |
1657 | { | 1666 | { |
1658 | mCurrentSyncDevice= s; | 1667 | mCurrentSyncDevice= s; |
1659 | } | 1668 | } |
1660 | void CalendarView::setSyncName( QString s ) | 1669 | void CalendarView::setSyncName( QString s ) |
1661 | { | 1670 | { |
1662 | mCurrentSyncName= s; | 1671 | mCurrentSyncName= s; |
1663 | } | 1672 | } |
1664 | bool CalendarView::syncCalendar(QString filename, int mode) | 1673 | bool CalendarView::syncCalendar(QString filename, int mode) |
1665 | { | 1674 | { |
1666 | //qDebug("syncCalendar %s ", filename.latin1()); | 1675 | //qDebug("syncCalendar %s ", filename.latin1()); |
1667 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1676 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1668 | CalendarLocal* calendar = new CalendarLocal(); | 1677 | CalendarLocal* calendar = new CalendarLocal(); |
1669 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1678 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1670 | FileStorage* storage = new FileStorage( calendar ); | 1679 | FileStorage* storage = new FileStorage( calendar ); |
1671 | bool syncOK = false; | 1680 | bool syncOK = false; |
@@ -2050,192 +2059,201 @@ bool CalendarView::restoreCalendarSettings() | |||
2050 | while ( cal ) { | 2059 | while ( cal ) { |
2051 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); | 2060 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); |
2052 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); | 2061 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); |
2053 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); | 2062 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); |
2054 | if ( cal->isStandard ) | 2063 | if ( cal->isStandard ) |
2055 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2064 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2056 | cal = calendars.next(); | 2065 | cal = calendars.next(); |
2057 | } | 2066 | } |
2058 | setSyncEventsReadOnly(); | 2067 | setSyncEventsReadOnly(); |
2059 | mCalendar->reInitAlarmSettings(); | 2068 | mCalendar->reInitAlarmSettings(); |
2060 | updateUnmanagedViews(); | 2069 | updateUnmanagedViews(); |
2061 | updateView(); | 2070 | updateView(); |
2062 | return true; | 2071 | return true; |
2063 | } | 2072 | } |
2064 | void CalendarView::addCalendarId( int id ) | 2073 | void CalendarView::addCalendarId( int id ) |
2065 | { | 2074 | { |
2066 | KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); | 2075 | KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); |
2067 | if ( cal ) | 2076 | if ( cal ) |
2068 | addCalendar( cal ); | 2077 | addCalendar( cal ); |
2069 | } | 2078 | } |
2070 | bool CalendarView::addCalendar( KopiCalendarFile * cal ) | 2079 | bool CalendarView::addCalendar( KopiCalendarFile * cal ) |
2071 | { | 2080 | { |
2072 | cal->mErrorOnLoad = false; | 2081 | cal->mErrorOnLoad = false; |
2073 | if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { | 2082 | if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { |
2074 | cal->mLoadDt = QDateTime::currentDateTime(); | 2083 | cal->mLoadDt = QDateTime::currentDateTime(); |
2075 | return true; | 2084 | return true; |
2076 | } | 2085 | } |
2077 | qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() ); | 2086 | qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() ); |
2078 | cal->mErrorOnLoad = true; | 2087 | cal->mErrorOnLoad = true; |
2079 | return false; | 2088 | return false; |
2080 | } | 2089 | } |
2081 | bool CalendarView::openCalendar(QString filename, bool merge) | 2090 | bool CalendarView::openCalendar(QString filename, bool merge) |
2082 | { | 2091 | { |
2083 | 2092 | ||
2084 | if (filename.isEmpty()) { | 2093 | if (filename.isEmpty()) { |
2085 | return false; | 2094 | return false; |
2086 | } | 2095 | } |
2087 | 2096 | ||
2088 | if (!QFile::exists(filename)) { | 2097 | if (!QFile::exists(filename)) { |
2089 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 2098 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
2090 | return false; | 2099 | return false; |
2091 | } | 2100 | } |
2092 | 2101 | ||
2093 | globalFlagBlockAgenda = 1; | 2102 | globalFlagBlockAgenda = 1; |
2094 | clearAllViews(); | 2103 | clearAllViews(); |
2095 | if (!merge) { | 2104 | if (!merge) { |
2096 | mViewManager->setDocumentId( filename ); | 2105 | mViewManager->setDocumentId( filename ); |
2097 | mCalendar->close(); | 2106 | mCalendar->close(); |
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 ) { |
2194 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2212 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2195 | mCalendar->setDefaultCalendarEnabledOnly(); | 2213 | mCalendar->setDefaultCalendarEnabledOnly(); |
2196 | loadedFileVersion = cal->mLoadDt.addSecs( 15 ); | 2214 | loadedFileVersion = cal->mLoadDt.addSecs( 15 ); |
2197 | if ( !checkFileVersion(cal->mFileName )) { | 2215 | if ( !checkFileVersion(cal->mFileName )) { |
2198 | loadedFileVersion = storeTemp; | 2216 | loadedFileVersion = storeTemp; |
2199 | restoreCalendarSettings(); | 2217 | restoreCalendarSettings(); |
2200 | return false; | 2218 | return false; |
2201 | } | 2219 | } |
2202 | } | 2220 | } |
2203 | cal = calendars.next(); | 2221 | cal = calendars.next(); |
2204 | } | 2222 | } |
2205 | loadedFileVersion = storeTemp; | 2223 | loadedFileVersion = storeTemp; |
2206 | return true; | 2224 | return true; |
2207 | } | 2225 | } |
2208 | bool CalendarView::checkFileVersion(QString fn) | 2226 | bool CalendarView::checkFileVersion(QString fn) |
2209 | { | 2227 | { |
2210 | QFileInfo finf ( fn ); | 2228 | QFileInfo finf ( fn ); |
2211 | if ( !finf.exists() ) | 2229 | if ( !finf.exists() ) |
2212 | return true; | 2230 | return true; |
2213 | QDateTime dt = finf.lastModified (); | 2231 | QDateTime dt = finf.lastModified (); |
2214 | qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); | 2232 | qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); |
2215 | qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); | 2233 | qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); |
2216 | if ( dt <= loadedFileVersion ) | 2234 | if ( dt <= loadedFileVersion ) |
2217 | return true; | 2235 | return true; |
2218 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\non disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(KGlobal::formatMessage(fn,0)).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , | 2236 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\non disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(KGlobal::formatMessage(fn,0)).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , |
2219 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 2237 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
2220 | i18n("Sync+save")); | 2238 | i18n("Sync+save")); |
2221 | 2239 | ||
2222 | if ( km == KMessageBox::Cancel ) | 2240 | if ( km == KMessageBox::Cancel ) |
2223 | return false; | 2241 | return false; |
2224 | if ( km == KMessageBox::Yes ) | 2242 | if ( km == KMessageBox::Yes ) |
2225 | return true; | 2243 | return true; |
2226 | 2244 | ||
2227 | setSyncDevice("deleteaftersync" ); | 2245 | setSyncDevice("deleteaftersync" ); |
2228 | mSyncManager->mAskForPreferences = true; | 2246 | mSyncManager->mAskForPreferences = true; |
2229 | mSyncManager->mSyncAlgoPrefs = 3; | 2247 | mSyncManager->mSyncAlgoPrefs = 3; |
2230 | mSyncManager->mWriteBackFile = false; | 2248 | mSyncManager->mWriteBackFile = false; |
2231 | mSyncManager->mWriteBackExistingOnly = false; | 2249 | mSyncManager->mWriteBackExistingOnly = false; |
2232 | mSyncManager->mShowSyncSummary = false; | 2250 | mSyncManager->mShowSyncSummary = false; |
2233 | syncCalendar( fn, 3 ); | 2251 | syncCalendar( fn, 3 ); |
2234 | Event * e = getLastSyncEvent(); | 2252 | Event * e = getLastSyncEvent(); |
2235 | if ( e ) | 2253 | if ( e ) |
2236 | mCalendar->deleteEvent( e ); | 2254 | mCalendar->deleteEvent( e ); |
2237 | return true; | 2255 | return true; |
2238 | } | 2256 | } |
2239 | bool CalendarView::saveCalendars() | 2257 | bool CalendarView::saveCalendars() |
2240 | { | 2258 | { |
2241 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2259 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
@@ -3265,198 +3283,200 @@ void CalendarView::moveIncidence() | |||
3265 | } | 3283 | } |
3266 | } | 3284 | } |
3267 | void CalendarView::beamIncidence() | 3285 | void CalendarView::beamIncidence() |
3268 | { | 3286 | { |
3269 | Incidence *incidence = currentSelection(); | 3287 | Incidence *incidence = currentSelection(); |
3270 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3288 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3271 | if ( incidence ) { | 3289 | if ( incidence ) { |
3272 | beamIncidence(incidence); | 3290 | beamIncidence(incidence); |
3273 | } | 3291 | } |
3274 | } | 3292 | } |
3275 | void CalendarView::toggleCancelIncidence() | 3293 | void CalendarView::toggleCancelIncidence() |
3276 | { | 3294 | { |
3277 | Incidence *incidence = currentSelection(); | 3295 | Incidence *incidence = currentSelection(); |
3278 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3296 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3279 | if ( incidence ) { | 3297 | if ( incidence ) { |
3280 | cancelIncidence(incidence); | 3298 | cancelIncidence(incidence); |
3281 | } | 3299 | } |
3282 | } | 3300 | } |
3283 | 3301 | ||
3284 | 3302 | ||
3285 | void CalendarView::cancelIncidence(Incidence * inc ) | 3303 | void CalendarView::cancelIncidence(Incidence * inc ) |
3286 | { | 3304 | { |
3287 | inc->setCancelled( ! inc->cancelled() ); | 3305 | inc->setCancelled( ! inc->cancelled() ); |
3288 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 3306 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
3289 | updateView(); | 3307 | updateView(); |
3290 | } | 3308 | } |
3291 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 3309 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
3292 | { | 3310 | { |
3293 | Incidence * newInc = orgInc->clone(); | 3311 | Incidence * newInc = orgInc->clone(); |
3294 | newInc->recreate(); | 3312 | newInc->recreate(); |
3295 | 3313 | ||
3296 | if ( newInc->typeID() == todoID ) { | 3314 | if ( newInc->typeID() == todoID ) { |
3297 | Todo* t = (Todo*) newInc; | 3315 | Todo* t = (Todo*) newInc; |
3298 | bool cloneSub = false; | 3316 | bool cloneSub = false; |
3299 | if ( orgInc->relations().count() ) { | 3317 | if ( orgInc->relations().count() ) { |
3300 | int result = KMessageBox::warningYesNoCancel(this, | 3318 | int result = KMessageBox::warningYesNoCancel(this, |
3301 | i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( KGlobal::formatMessage ( newInc->summary(),0 ) ), | 3319 | i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( KGlobal::formatMessage ( newInc->summary(),0 ) ), |
3302 | i18n("Todo has subtodos"), | 3320 | i18n("Todo has subtodos"), |
3303 | i18n("Yes"), | 3321 | i18n("Yes"), |
3304 | i18n("No")); | 3322 | i18n("No")); |
3305 | 3323 | ||
3306 | if ( result == KMessageBox::Cancel ) { | 3324 | if ( result == KMessageBox::Cancel ) { |
3307 | delete t; | 3325 | delete t; |
3308 | return; | 3326 | return; |
3309 | } | 3327 | } |
3310 | if (result == KMessageBox::Yes) cloneSub = true; | 3328 | if (result == KMessageBox::Yes) cloneSub = true; |
3311 | } | 3329 | } |
3312 | showTodoEditor(); | 3330 | showTodoEditor(); |
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 *) |
3415 | { | 3435 | { |
3416 | //qDebug("todoToBeDeleted(Todo *) "); | 3436 | //qDebug("todoToBeDeleted(Todo *) "); |
3417 | updateTodoViews(); | 3437 | updateTodoViews(); |
3418 | } | 3438 | } |
3419 | void CalendarView::todoDeleted() | 3439 | void CalendarView::todoDeleted() |
3420 | { | 3440 | { |
3421 | //qDebug(" todoDeleted()"); | 3441 | //qDebug(" todoDeleted()"); |
3422 | updateTodoViews(); | 3442 | updateTodoViews(); |
3423 | } | 3443 | } |
3424 | 3444 | ||
3425 | 3445 | ||
3426 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) | 3446 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) |
3427 | { | 3447 | { |
3428 | showTodoEditor(); | 3448 | showTodoEditor(); |
3429 | mTodoEditor->newTodo(dt,0,allday); | 3449 | mTodoEditor->newTodo(dt,0,allday); |
3430 | if ( mFilterView->filtersEnabled() ) { | 3450 | if ( mFilterView->filtersEnabled() ) { |
3431 | CalFilter *filter = mFilterView->selectedFilter(); | 3451 | CalFilter *filter = mFilterView->selectedFilter(); |
3432 | if (filter && filter->showCategories()) { | 3452 | if (filter && filter->showCategories()) { |
3433 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 3453 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
3434 | } | 3454 | } |
3435 | if ( filter ) | 3455 | if ( filter ) |
3436 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 3456 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
3437 | } | 3457 | } |
3438 | mTodoEditor->exec(); | 3458 | mTodoEditor->exec(); |
3439 | setActiveWindow(); | 3459 | setActiveWindow(); |
3440 | } | 3460 | } |
3441 | 3461 | ||
3442 | void CalendarView::newTodo() | 3462 | void CalendarView::newTodo() |
3443 | { | 3463 | { |
3444 | newTodoDateTime( QDateTime(),true ); | 3464 | newTodoDateTime( QDateTime(),true ); |
3445 | } | 3465 | } |
3446 | 3466 | ||
3447 | void CalendarView::newSubTodo() | 3467 | void CalendarView::newSubTodo() |
3448 | { | 3468 | { |
3449 | Todo *todo = selectedTodo(); | 3469 | Todo *todo = selectedTodo(); |
3450 | if ( todo ) newSubTodo( todo ); | 3470 | if ( todo ) newSubTodo( todo ); |
3451 | } | 3471 | } |
3452 | 3472 | ||
3453 | void CalendarView::newSubTodo(Todo *parentEvent) | 3473 | void CalendarView::newSubTodo(Todo *parentEvent) |
3454 | { | 3474 | { |
3455 | 3475 | ||
3456 | showTodoEditor(); | 3476 | showTodoEditor(); |
3457 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); | 3477 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); |
3458 | mTodoEditor->exec(); | 3478 | mTodoEditor->exec(); |
3459 | setActiveWindow(); | 3479 | setActiveWindow(); |
3460 | } | 3480 | } |
3461 | 3481 | ||
3462 | void CalendarView::newFloatingEvent() | 3482 | void CalendarView::newFloatingEvent() |
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h index 706d05d..799c297 100644 --- a/korganizer/calendarview.h +++ b/korganizer/calendarview.h | |||
@@ -45,192 +45,193 @@ | |||
45 | #include <korganizer/calendarviewbase.h> | 45 | #include <korganizer/calendarviewbase.h> |
46 | 46 | ||
47 | #include <ksyncmanager.h> | 47 | #include <ksyncmanager.h> |
48 | //#include <koprefs.h> | 48 | //#include <koprefs.h> |
49 | 49 | ||
50 | class QWidgetStack; | 50 | class QWidgetStack; |
51 | class QSplitter; | 51 | class QSplitter; |
52 | class KopiCalendarFile; | 52 | class KopiCalendarFile; |
53 | class CalPrinter; | 53 | class CalPrinter; |
54 | class KOFilterView; | 54 | class KOFilterView; |
55 | class KOCalEditView; | 55 | class KOCalEditView; |
56 | class KOViewManager; | 56 | class KOViewManager; |
57 | class KODialogManager; | 57 | class KODialogManager; |
58 | class KOTodoView; | 58 | class KOTodoView; |
59 | class KDateNavigator; | 59 | class KDateNavigator; |
60 | class DateNavigatorContainer; | 60 | class DateNavigatorContainer; |
61 | class DateNavigator; | 61 | class DateNavigator; |
62 | class KOIncidenceEditor; | 62 | class KOIncidenceEditor; |
63 | class KDatePicker; | 63 | class KDatePicker; |
64 | class ResourceView; | 64 | class ResourceView; |
65 | class KOEventEditor; | 65 | class KOEventEditor; |
66 | class KOTodoEditor ; | 66 | class KOTodoEditor ; |
67 | class KOEventViewerDialog; | 67 | class KOEventViewerDialog; |
68 | class KOBeamPrefs; | 68 | class KOBeamPrefs; |
69 | class KSyncProfile; | 69 | class KSyncProfile; |
70 | class AlarmDialog; | 70 | class AlarmDialog; |
71 | class KCal::Attendee; | 71 | class KCal::Attendee; |
72 | 72 | ||
73 | namespace KCal { class FileStorage; } | 73 | namespace KCal { class FileStorage; } |
74 | 74 | ||
75 | using namespace KCal; | 75 | using namespace KCal; |
76 | 76 | ||
77 | /** | 77 | /** |
78 | This is the main calendar widget. It provides the different vies on t he | 78 | This is the main calendar widget. It provides the different vies on t he |
79 | calendar data as well as the date navigator. It also handles synchronisation | 79 | calendar data as well as the date navigator. It also handles synchronisation |
80 | of the different views and controls the different dialogs like preferences, | 80 | of the different views and controls the different dialogs like preferences, |
81 | event editor, search dialog etc. | 81 | event editor, search dialog etc. |
82 | 82 | ||
83 | @short main calendar view widget | 83 | @short main calendar view widget |
84 | @author Cornelius Schumacher | 84 | @author Cornelius Schumacher |
85 | */ | 85 | */ |
86 | 86 | ||
87 | #include <qtextbrowser.h> | 87 | #include <qtextbrowser.h> |
88 | #include <qtextcodec.h> | 88 | #include <qtextcodec.h> |
89 | 89 | ||
90 | class MissedAlarmTextBrowser : public QTextBrowser { | 90 | class MissedAlarmTextBrowser : public QTextBrowser { |
91 | Q_OBJECT | 91 | Q_OBJECT |
92 | public: | 92 | public: |
93 | MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms ,QDateTime start); | 93 | MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms ,QDateTime start); |
94 | ~MissedAlarmTextBrowser(); | 94 | ~MissedAlarmTextBrowser(); |
95 | void setSource(const QString & n); | 95 | void setSource(const QString & n); |
96 | 96 | ||
97 | private: | 97 | private: |
98 | Incidence * getNextInc(QDateTime start ); | 98 | Incidence * getNextInc(QDateTime start ); |
99 | QPtrList<Incidence> mAlarms; | 99 | QPtrList<Incidence> mAlarms; |
100 | signals: | 100 | signals: |
101 | void showIncidence( QString uid); | 101 | void showIncidence( QString uid); |
102 | }; | 102 | }; |
103 | 103 | ||
104 | 104 | ||
105 | class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface | 105 | class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface |
106 | { | 106 | { |
107 | Q_OBJECT | 107 | Q_OBJECT |
108 | public: | 108 | public: |
109 | /** | 109 | /** |
110 | Constructs a new calendar view widget. | 110 | Constructs a new calendar view widget. |
111 | 111 | ||
112 | @param calendar calendar document | 112 | @param calendar calendar document |
113 | @param parent parent window | 113 | @param parent parent window |
114 | @param name Qt internal widget object name | 114 | @param name Qt internal widget object name |
115 | */ | 115 | */ |
116 | CalendarView( CalendarResources *calendar, QWidget *parent = 0, | 116 | CalendarView( CalendarResources *calendar, QWidget *parent = 0, |
117 | const char *name = 0 ); | 117 | const char *name = 0 ); |
118 | CalendarView( Calendar *calendar, QWidget *parent = 0, | 118 | CalendarView( Calendar *calendar, QWidget *parent = 0, |
119 | const char *name = 0 ); | 119 | const char *name = 0 ); |
120 | virtual ~CalendarView(); | 120 | virtual ~CalendarView(); |
121 | 121 | ||
122 | Calendar *calendar() { return mCalendar; } | 122 | Calendar *calendar() { return mCalendar; } |
123 | 123 | ||
124 | KOViewManager *viewManager(); | 124 | KOViewManager *viewManager(); |
125 | KODialogManager *dialogManager(); | 125 | KODialogManager *dialogManager(); |
126 | 126 | ||
127 | QDate startDate(); | 127 | QDate startDate(); |
128 | QDate endDate(); | 128 | QDate endDate(); |
129 | 129 | ||
130 | QWidgetStack *viewStack(); | 130 | QWidgetStack *viewStack(); |
131 | QWidget *leftFrame(); | 131 | QWidget *leftFrame(); |
132 | 132 | ||
133 | DateNavigator *dateNavigator(); | 133 | DateNavigator *dateNavigator(); |
134 | KDateNavigator *dateNavigatorWidget(); | 134 | KDateNavigator *dateNavigatorWidget(); |
135 | 135 | ||
136 | void addView(KOrg::BaseView *); | 136 | void addView(KOrg::BaseView *); |
137 | void showView(KOrg::BaseView *); | 137 | void showView(KOrg::BaseView *); |
138 | KOEventViewerDialog* getEventViewerDialog(); | 138 | KOEventViewerDialog* getEventViewerDialog(); |
139 | Incidence *currentSelection(); | 139 | Incidence *currentSelection(); |
140 | void checkSuspendAlarm(); | 140 | void checkSuspendAlarm(); |
141 | void mergeFile( QString fn ); | ||
141 | 142 | ||
142 | signals: | 143 | signals: |
143 | void save (); | 144 | void save (); |
144 | void saveStopTimer (); | 145 | void saveStopTimer (); |
145 | void tempDisableBR(bool); | 146 | void tempDisableBR(bool); |
146 | /** This todo has been modified */ | 147 | /** This todo has been modified */ |
147 | void todoModified(Todo *, int); | 148 | void todoModified(Todo *, int); |
148 | 149 | ||
149 | /** when change is made to options dialog, the topwidget will catch this | 150 | /** when change is made to options dialog, the topwidget will catch this |
150 | * and emit this signal which notifies all widgets which have registered | 151 | * and emit this signal which notifies all widgets which have registered |
151 | * for notification to update their settings. */ | 152 | * for notification to update their settings. */ |
152 | void configChanged(); | 153 | void configChanged(); |
153 | /** emitted when the topwidget is closing down, so that any attached | 154 | /** emitted when the topwidget is closing down, so that any attached |
154 | child windows can also close. */ | 155 | child windows can also close. */ |
155 | void closingDown(); | 156 | void closingDown(); |
156 | /** emitted right before we die */ | 157 | /** emitted right before we die */ |
157 | void closed(QWidget *); | 158 | void closed(QWidget *); |
158 | 159 | ||
159 | /** Emitted when state of modified flag changes */ | 160 | /** Emitted when state of modified flag changes */ |
160 | void modifiedChanged(bool); | 161 | void modifiedChanged(bool); |
161 | void signalmodified(); | 162 | void signalmodified(); |
162 | 163 | ||
163 | /** Emitted when state of read-only flag changes */ | 164 | /** Emitted when state of read-only flag changes */ |
164 | void readOnlyChanged(bool); | 165 | void readOnlyChanged(bool); |
165 | 166 | ||
166 | /** Emitted when the unit of navigation changes */ | 167 | /** Emitted when the unit of navigation changes */ |
167 | void changeNavStringPrev(const QString &); | 168 | void changeNavStringPrev(const QString &); |
168 | void changeNavStringNext(const QString &); | 169 | void changeNavStringNext(const QString &); |
169 | 170 | ||
170 | /** Emitted when state of events selection has changed and user is organizer*/ | 171 | /** Emitted when state of events selection has changed and user is organizer*/ |
171 | void organizerEventsSelected(bool); | 172 | void organizerEventsSelected(bool); |
172 | /** Emitted when state of events selection has changed and user is attendee*/ | 173 | /** Emitted when state of events selection has changed and user is attendee*/ |
173 | void groupEventsSelected(bool); | 174 | void groupEventsSelected(bool); |
174 | /** | 175 | /** |
175 | Emitted when an incidence gets selected. If the selection is cleared the | 176 | Emitted when an incidence gets selected. If the selection is cleared the |
176 | signal is emitted with 0 as argument. | 177 | signal is emitted with 0 as argument. |
177 | */ | 178 | */ |
178 | void incidenceSelected( Incidence * ); | 179 | void incidenceSelected( Incidence * ); |
179 | /** Emitted, when a todoitem is selected or deselected. */ | 180 | /** Emitted, when a todoitem is selected or deselected. */ |
180 | void todoSelected( bool ); | 181 | void todoSelected( bool ); |
181 | 182 | ||
182 | /** | 183 | /** |
183 | Emitted, when clipboard content changes. Parameter indicates if paste | 184 | Emitted, when clipboard content changes. Parameter indicates if paste |
184 | is possible or not. | 185 | is possible or not. |
185 | */ | 186 | */ |
186 | void pasteEnabled(bool); | 187 | void pasteEnabled(bool); |
187 | 188 | ||
188 | /** Emitted, when the number of incoming messages has changed. */ | 189 | /** Emitted, when the number of incoming messages has changed. */ |
189 | void numIncomingChanged(int); | 190 | void numIncomingChanged(int); |
190 | 191 | ||
191 | /** Emitted, when the number of outgoing messages has changed. */ | 192 | /** Emitted, when the number of outgoing messages has changed. */ |
192 | void numOutgoingChanged(int); | 193 | void numOutgoingChanged(int); |
193 | 194 | ||
194 | /** Send status message, which can e.g. be displayed in the status bar. */ | 195 | /** Send status message, which can e.g. be displayed in the status bar. */ |
195 | void statusMessage(const QString &); | 196 | void statusMessage(const QString &); |
196 | 197 | ||
197 | void calendarViewExpanded( bool ); | 198 | void calendarViewExpanded( bool ); |
198 | void updateSearchDialog(); | 199 | void updateSearchDialog(); |
199 | void filtersUpdated(); | 200 | void filtersUpdated(); |
200 | 201 | ||
201 | 202 | ||
202 | public slots: | 203 | public slots: |
203 | void nextConflict( bool all, bool allday ); | 204 | void nextConflict( bool all, bool allday ); |
204 | void conflictAll(); | 205 | void conflictAll(); |
205 | void conflictAllday(); | 206 | void conflictAllday(); |
206 | void conflictNotAll(); | 207 | void conflictNotAll(); |
207 | void setCalReadOnly( int id, bool readO ); | 208 | void setCalReadOnly( int id, bool readO ); |
208 | void checkAlarms(); | 209 | void checkAlarms(); |
209 | void checkFiles(); | 210 | void checkFiles(); |
210 | void slotprintSelInc(); | 211 | void slotprintSelInc(); |
211 | void showNextAlarms(); | 212 | void showNextAlarms(); |
212 | void showOpenError(); | 213 | void showOpenError(); |
213 | void watchSavedFile(); | 214 | void watchSavedFile(); |
214 | void recheckTimerAlarm(); | 215 | void recheckTimerAlarm(); |
215 | void checkNextTimerAlarm(); | 216 | void checkNextTimerAlarm(); |
216 | void addAlarm(const QDateTime &qdt, const QString ¬i ); | 217 | void addAlarm(const QDateTime &qdt, const QString ¬i ); |
217 | void addSuspendAlarm(const QDateTime &qdt, const QString ¬i ); | 218 | void addSuspendAlarm(const QDateTime &qdt, const QString ¬i ); |
218 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); | 219 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); |
219 | 220 | ||
220 | /** options dialog made a changed to the configuration. we catch this | 221 | /** options dialog made a changed to the configuration. we catch this |
221 | * and notify all widgets which need to update their configuration. */ | 222 | * and notify all widgets which need to update their configuration. */ |
222 | void updateConfig(); | 223 | void updateConfig(); |
223 | 224 | ||
224 | void insertBirthdays(const QString& uid, const QStringList& birthdayList, | 225 | void insertBirthdays(const QString& uid, const QStringList& birthdayList, |
225 | const QStringList& anniversaryList, const QStringList& realNameList, | 226 | const QStringList& anniversaryList, const QStringList& realNameList, |
226 | const QStringList& emailList, const QStringList& assembledNameList, | 227 | const QStringList& emailList, const QStringList& assembledNameList, |
227 | const QStringList& uidList); | 228 | const QStringList& uidList); |
228 | 229 | ||
229 | /** | 230 | /** |
230 | Load calendar from file \a filename. If \a merge is true, load | 231 | Load calendar from file \a filename. If \a merge is true, load |
231 | calendar into existing one, if it is false, clear calendar, before | 232 | calendar into existing one, if it is false, clear calendar, before |
232 | loading. Return true, if calendar could be successfully loaded. | 233 | loading. Return true, if calendar could be successfully loaded. |
233 | */ | 234 | */ |
234 | bool openCalendar(QString filename, bool merge=false); | 235 | bool openCalendar(QString filename, bool merge=false); |
235 | bool loadCalendars(); | 236 | bool loadCalendars(); |
236 | bool saveCalendars(); | 237 | bool saveCalendars(); |
diff --git a/korganizer/journalentry.cpp b/korganizer/journalentry.cpp index b8a4cf2..f0e0f86 100644 --- a/korganizer/journalentry.cpp +++ b/korganizer/journalentry.cpp | |||
@@ -1,226 +1,246 @@ | |||
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 | // | 24 | // |
25 | // Journal Entry | 25 | // Journal Entry |
26 | 26 | ||
27 | #include <qlabel.h> | 27 | #include <qlabel.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include <qvbox.h> | 29 | #include <qvbox.h> |
30 | #include <qfile.h> | 30 | #include <qfile.h> |
31 | #include <qdir.h> | 31 | #include <qdir.h> |
32 | #include <qtextstream.h> | 32 | #include <qtextstream.h> |
33 | #include <qtextcodec.h> | 33 | #include <qtextcodec.h> |
34 | #include <qpixmap.h> | 34 | #include <qpixmap.h> |
35 | #include <qpushbutton.h> | 35 | #include <qpushbutton.h> |
36 | #include <qapplication.h> | 36 | #include <qapplication.h> |
37 | 37 | ||
38 | #include <kdebug.h> | 38 | #include <kdebug.h> |
39 | #include <kglobal.h> | 39 | #include <kglobal.h> |
40 | #include <klocale.h> | 40 | #include <klocale.h> |
41 | #include <ktextedit.h> | 41 | #include <ktextedit.h> |
42 | #include <kfiledialog.h> | 42 | #include <kfiledialog.h> |
43 | #include <kmessagebox.h> | 43 | #include <kmessagebox.h> |
44 | #include "koprefs.h" | 44 | #include "koprefs.h" |
45 | #include <klineedit.h> | 45 | #include <klineedit.h> |
46 | #include <kdialog.h> | 46 | #include <kdialog.h> |
47 | #include "kolocationbox.h" | 47 | #include "kolocationbox.h" |
48 | 48 | ||
49 | #include <libkcal/journal.h> | 49 | #include <libkcal/journal.h> |
50 | #include <libkcal/calendarresources.h> | 50 | #include <libkcal/calendarresources.h> |
51 | #include <libkcal/resourcecalendar.h> | 51 | #include <libkcal/resourcecalendar.h> |
52 | #include <kresources/resourceselectdialog.h> | 52 | #include <kresources/resourceselectdialog.h> |
53 | 53 | ||
54 | #include "journalentry.h" | 54 | #include "journalentry.h" |
55 | //#include "journalentry.moc" | 55 | //#include "journalentry.moc" |
56 | #ifndef DESKTOP_VERSION | 56 | #ifndef DESKTOP_VERSION |
57 | #include <qpe/qpeapplication.h> | 57 | #include <qpe/qpeapplication.h> |
58 | #endif | 58 | #endif |
59 | JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) : | 59 | JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) : |
60 | QFrame(parent) | 60 | QFrame(parent) |
61 | { | 61 | { |
62 | 62 | ||
63 | int fac = 5; | 63 | int fac = 5; |
64 | heiHint = QApplication::desktop()->height(); | 64 | heiHint = QApplication::desktop()->height(); |
65 | if ( heiHint > 800 ) | 65 | if ( heiHint > 800 ) |
66 | fac += 2; | 66 | fac += 2; |
67 | heiHint = heiHint / fac; | 67 | heiHint = heiHint / fac; |
68 | 68 | ||
69 | showOnlyMode = false; | 69 | showOnlyMode = false; |
70 | mCalendar = calendar; | 70 | mCalendar = calendar; |
71 | mJournal = 0; | 71 | mJournal = 0; |
72 | visibleMode = true; | 72 | visibleMode = true; |
73 | QHBox * vb = new QHBox ( this ); | 73 | QHBox * vb = new QHBox ( this ); |
74 | QPixmap iconp; | 74 | QPixmap iconp; |
75 | vb->setMargin ( KDialog::marginHint()-1 ); | 75 | vb->setMargin ( KDialog::marginHint()-1 ); |
76 | QPushButton * toggleJournal = new QPushButton( vb ); | 76 | QPushButton * toggleJournal = new QPushButton( vb ); |
77 | iconp = SmallIcon("1updownarrow"); | 77 | iconp = SmallIcon("1updownarrow"); |
78 | toggleJournal->setPixmap (iconp ) ; | 78 | toggleJournal->setPixmap (iconp ) ; |
79 | vb->setStretchFactor (new QLabel(" "+i18n("Title: "),vb),1); | 79 | QLabel* textLabel = new QLabel(" "+i18n("Title: "),vb); |
80 | vb->setStretchFactor (textLabel,1); | ||
80 | vb->setStretchFactor( toggleJournal, 1 ); | 81 | vb->setStretchFactor( toggleJournal, 1 ); |
81 | mTitle = new KOLocationBox(TRUE, vb, 30); | 82 | mTitle = new KOLocationBox(TRUE, vb, 30); |
82 | mTitle->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding ,QSizePolicy::Fixed ,FALSE) ); | 83 | mTitle->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding ,QSizePolicy::Fixed ,FALSE) ); |
83 | mCalendarBox = new QComboBox(vb); | 84 | mCalendarBox = new QComboBox(vb); |
84 | mCalendarBox->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding ,QSizePolicy::Fixed ,FALSE) ); | 85 | mCalendarBox->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding ,QSizePolicy::Fixed ,FALSE) ); |
85 | #ifndef DESKTOP_VERSION | 86 | #ifndef DESKTOP_VERSION |
86 | mTitle->setSizeLimit( 8 ); | 87 | mTitle->setSizeLimit( 8 ); |
87 | mCalendarBox->setSizeLimit( 8 ); | 88 | mCalendarBox->setSizeLimit( 8 ); |
88 | #endif | 89 | #endif |
89 | vb->setStretchFactor ( mTitle, 8 ); | 90 | vb->setStretchFactor ( mTitle, 8 ); |
90 | vb->setStretchFactor ( mCalendarBox, 3 ); | 91 | vb->setStretchFactor ( mCalendarBox, 3 ); |
91 | //mTitleLabel->setMargin(0); | 92 | //mTitleLabel->setMargin(0); |
92 | //mTitleLabel->setAlignment(AlignCenter); | 93 | //mTitleLabel->setAlignment(AlignCenter); |
93 | QPushButton * loadTemplate = new QPushButton( vb ); | 94 | QPushButton * loadTemplate = new QPushButton( vb ); |
94 | QPushButton * saveTemplate = new QPushButton( vb ); | 95 | QPushButton * saveTemplate = new QPushButton( vb ); |
95 | if ( QApplication::desktop()->width() < 321 ) | 96 | if ( QApplication::desktop()->width() < 321 ) |
96 | iconp = SmallIcon("fileexport16"); | 97 | iconp = SmallIcon("fileexport16"); |
97 | else | 98 | else |
98 | iconp = SmallIcon("fileexport"); | 99 | iconp = SmallIcon("fileexport"); |
99 | saveTemplate->setPixmap (iconp ) ; | 100 | saveTemplate->setPixmap (iconp ) ; |
100 | int size = saveTemplate->sizeHint().height(); | 101 | int size = saveTemplate->sizeHint().height(); |
101 | if ( QApplication::desktop()->width() < 321 ) | 102 | if ( QApplication::desktop()->width() < 321 ) |
102 | iconp = SmallIcon("fileimport16"); | 103 | iconp = SmallIcon("fileimport16"); |
103 | else | 104 | else |
104 | iconp = SmallIcon("fileimport"); | 105 | iconp = SmallIcon("fileimport"); |
105 | loadTemplate->setPixmap (iconp ) ; | 106 | loadTemplate->setPixmap (iconp ) ; |
106 | loadTemplate->setFixedSize( size, size ); | 107 | loadTemplate->setFixedSize( size, size ); |
107 | saveTemplate->setFixedSize( size, size ); | 108 | saveTemplate->setFixedSize( size, size ); |
108 | toggleJournal->setFixedSize( size , size ); | 109 | toggleJournal->setFixedSize( size , size ); |
109 | mTitle->setFixedHeight( size+4); | 110 | mTitle->setFixedHeight( size+4); |
110 | mCalendarBox->setFixedHeight( size+4); | 111 | mCalendarBox->setFixedHeight( size+4); |
111 | mEditor = new KTextEdit(this); | 112 | mEditor = new KTextEdit(this); |
112 | #ifndef DESKTOP_VERSION | 113 | #ifndef DESKTOP_VERSION |
113 | QPEApplication::setStylusOperation( mEditor, QPEApplication::RightOnHold ); | 114 | QPEApplication::setStylusOperation( mEditor, QPEApplication::RightOnHold ); |
114 | #endif | 115 | #endif |
116 | mMaxWidDiff = 3*size - 2*frameWidth() - textLabel->sizeHint().width(); | ||
117 | mDeskWid = QApplication::desktop()->width(); | ||
118 | int maxwid = mDeskWid - mMaxWidDiff; | ||
119 | mTitle->setMaximumWidth( maxwid/2 +20 ); | ||
120 | mCalendarBox->setMaximumWidth( maxwid/2 -20 ); | ||
115 | mEditor->setWordWrap( KTextEdit::WidgetWidth ); | 121 | mEditor->setWordWrap( KTextEdit::WidgetWidth ); |
116 | QBoxLayout *topLayout = new QVBoxLayout(this); | 122 | QBoxLayout *topLayout = new QVBoxLayout(this); |
117 | topLayout->addWidget(vb); | 123 | topLayout->addWidget(vb); |
118 | topLayout->addWidget(mEditor); | 124 | topLayout->addWidget(mEditor); |
119 | mEditor->installEventFilter(this); | 125 | mEditor->installEventFilter(this); |
120 | connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); | 126 | connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); |
121 | connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); | 127 | connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); |
122 | connect( toggleJournal, SIGNAL( clicked() ), this , SLOT( toggleShowJournal() ) ); | 128 | connect( toggleJournal, SIGNAL( clicked() ), this , SLOT( toggleShowJournal() ) ); |
123 | mTitle->load( KOLocationBox::SUMMARYJOURNAL ); | 129 | mTitle->load( KOLocationBox::SUMMARYJOURNAL ); |
124 | mTitle->lineEdit ()->setText(""); | 130 | mTitle->lineEdit ()->setText(""); |
125 | } | 131 | } |
126 | 132 | ||
127 | JournalEntry::~JournalEntry() | 133 | JournalEntry::~JournalEntry() |
128 | { | 134 | { |
129 | //qDebug("JournalEntry::~JournalEntry() "); | 135 | //qDebug("JournalEntry::~JournalEntry() "); |
130 | } | 136 | } |
137 | void JournalEntry::resizeEvent(QResizeEvent* e ) | ||
138 | { | ||
139 | #ifndef DESKTOP_VERSION | ||
140 | if ( mDeskWid != QApplication::desktop()->width() ) { | ||
141 | mDeskWid == QApplication::desktop()->width(); | ||
142 | int maxwid = mDeskWid - mMaxWidDiff; | ||
143 | mTitle->setMaximumWidth( maxwid/2 +20 ); | ||
144 | mCalendarBox->setMaximumWidth( maxwid/2 -20 ); | ||
145 | } | ||
146 | setMaximumWidth( QApplication::desktop()->width() ); | ||
147 | qDebug("MAXXX %d ", QApplication::desktop()->width()); | ||
148 | #endif | ||
149 | QFrame::resizeEvent( e ); | ||
150 | } | ||
131 | QSize JournalEntry::sizeHint() const | 151 | QSize JournalEntry::sizeHint() const |
132 | { | 152 | { |
133 | return QSize ( 240, heiHint ); | 153 | return QSize ( 240, heiHint ); |
134 | } | 154 | } |
135 | void JournalEntry::slotSaveTemplate() | 155 | void JournalEntry::slotSaveTemplate() |
136 | { | 156 | { |
137 | QString fileName =locateLocal( "templates", "journals" ); | 157 | QString fileName =locateLocal( "templates", "journals" ); |
138 | QDir t_dir; | 158 | QDir t_dir; |
139 | if ( !t_dir.exists(fileName) ) | 159 | if ( !t_dir.exists(fileName) ) |
140 | t_dir.mkdir ( fileName ); | 160 | t_dir.mkdir ( fileName ); |
141 | fileName += "/journal"; | 161 | fileName += "/journal"; |
142 | fileName = KFileDialog::getSaveFileName( fileName , i18n("Save as Journal template"), this ); | 162 | fileName = KFileDialog::getSaveFileName( fileName , i18n("Save as Journal template"), this ); |
143 | if ( fileName.length() == 0 ) | 163 | if ( fileName.length() == 0 ) |
144 | return; | 164 | return; |
145 | 165 | ||
146 | QFile fileIn( fileName ); | 166 | QFile fileIn( fileName ); |
147 | if (!fileIn.open( IO_WriteOnly ) ) { | 167 | if (!fileIn.open( IO_WriteOnly ) ) { |
148 | KMessageBox::error( this, i18n("Error saving template file\n '%1'.") | 168 | KMessageBox::error( this, i18n("Error saving template file\n '%1'.") |
149 | .arg( fileName ) ); | 169 | .arg( fileName ) ); |
150 | return; | 170 | return; |
151 | } | 171 | } |
152 | // QString text; | 172 | // QString text; |
153 | QTextStream tsIn( &fileIn ); | 173 | QTextStream tsIn( &fileIn ); |
154 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); | 174 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); |
155 | tsIn << mEditor->text(); | 175 | tsIn << mEditor->text(); |
156 | fileIn.close(); | 176 | fileIn.close(); |
157 | } | 177 | } |
158 | void JournalEntry::slotLoadTemplate() | 178 | void JournalEntry::slotLoadTemplate() |
159 | { | 179 | { |
160 | QString fileName =locateLocal( "templates", "journals" ); | 180 | QString fileName =locateLocal( "templates", "journals" ); |
161 | QDir t_dir; | 181 | QDir t_dir; |
162 | if ( !t_dir.exists(fileName) ) | 182 | if ( !t_dir.exists(fileName) ) |
163 | t_dir.mkdir ( fileName ); | 183 | t_dir.mkdir ( fileName ); |
164 | fileName += "/journal"; | 184 | fileName += "/journal"; |
165 | fileName = KFileDialog::getOpenFileName( fileName , i18n("Insert Journal template"), this ); | 185 | fileName = KFileDialog::getOpenFileName( fileName , i18n("Insert Journal template"), this ); |
166 | if ( fileName.length() == 0 ) | 186 | if ( fileName.length() == 0 ) |
167 | return; | 187 | return; |
168 | QFile fileIn( fileName ); | 188 | QFile fileIn( fileName ); |
169 | if (!fileIn.open( IO_ReadOnly ) ) { | 189 | if (!fileIn.open( IO_ReadOnly ) ) { |
170 | KMessageBox::error( this, i18n("Error loading template file\n '%1'.") | 190 | KMessageBox::error( this, i18n("Error loading template file\n '%1'.") |
171 | .arg( fileName ) ); | 191 | .arg( fileName ) ); |
172 | return; | 192 | return; |
173 | } | 193 | } |
174 | QTextStream tsIn( &fileIn ); | 194 | QTextStream tsIn( &fileIn ); |
175 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); | 195 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); |
176 | QString text = tsIn.read(); | 196 | QString text = tsIn.read(); |
177 | fileIn.close(); | 197 | fileIn.close(); |
178 | int line, col; | 198 | int line, col; |
179 | mEditor->getCursorPosition (& line, & col ); | 199 | mEditor->getCursorPosition (& line, & col ); |
180 | mEditor-> insertAt ( text, line, col, true ); | 200 | mEditor-> insertAt ( text, line, col, true ); |
181 | //mEditor->setIgnoreMark( true ); | 201 | //mEditor->setIgnoreMark( true ); |
182 | } | 202 | } |
183 | void JournalEntry::setDate(const QDate &date) | 203 | void JournalEntry::setDate(const QDate &date) |
184 | { | 204 | { |
185 | showOnlyMode = false; | 205 | showOnlyMode = false; |
186 | writeJournal(); | 206 | writeJournal(); |
187 | mDate = date; | 207 | mDate = date; |
188 | fillCalendar( mCalendar->defaultCalendar() ); | 208 | fillCalendar( mCalendar->defaultCalendar() ); |
189 | } | 209 | } |
190 | void JournalEntry::fillCalendar( int setToID ) | 210 | void JournalEntry::fillCalendar( int setToID ) |
191 | { | 211 | { |
192 | mCalendarBox->clear(); | 212 | mCalendarBox->clear(); |
193 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); | 213 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); |
194 | int std = 0; | 214 | int std = 0; |
195 | int count = 0; | 215 | int count = 0; |
196 | while ( kkf ) { | 216 | while ( kkf ) { |
197 | if ( (!kkf->mErrorOnLoad &&! kkf->isReadOnly) || setToID == kkf->mCalNumber ) { | 217 | if ( (!kkf->mErrorOnLoad &&! kkf->isReadOnly) || setToID == kkf->mCalNumber ) { |
198 | if ( setToID ) { | 218 | if ( setToID ) { |
199 | if ( kkf->mCalNumber == setToID ) | 219 | if ( kkf->mCalNumber == setToID ) |
200 | std = count; | 220 | std = count; |
201 | } else { | 221 | } else { |
202 | if ( kkf->isStandard ) { | 222 | if ( kkf->isStandard ) { |
203 | std = count; | 223 | std = count; |
204 | } | 224 | } |
205 | } | 225 | } |
206 | ++count; | 226 | ++count; |
207 | mCalendarBox->insertItem( kkf->mName ); | 227 | mCalendarBox->insertItem( kkf->mName ); |
208 | } | 228 | } |
209 | kkf = KOPrefs::instance()->mCalendars.next(); | 229 | kkf = KOPrefs::instance()->mCalendars.next(); |
210 | } | 230 | } |
211 | mCalendarBox->setCurrentItem( std ); | 231 | mCalendarBox->setCurrentItem( std ); |
212 | } | 232 | } |
213 | 233 | ||
214 | void JournalEntry::toggleShowJournal() | 234 | void JournalEntry::toggleShowJournal() |
215 | { | 235 | { |
216 | if (!mEditor->text().isEmpty() || !mTitle->currentText ().isEmpty()) | 236 | if (!mEditor->text().isEmpty() || !mTitle->currentText ().isEmpty()) |
217 | flushEntry(); | 237 | flushEntry(); |
218 | if ( showOnlyMode ) | 238 | if ( showOnlyMode ) |
219 | emit showJournalOnly( 0 ); | 239 | emit showJournalOnly( 0 ); |
220 | else { | 240 | else { |
221 | // we have to protect mJournal from deleting if mJournal has empty text | 241 | // we have to protect mJournal from deleting if mJournal has empty text |
222 | visibleMode = false; // set to true via :setShowOnly() | 242 | visibleMode = false; // set to true via :setShowOnly() |
223 | emit showJournalOnly( mJournal ); | 243 | emit showJournalOnly( mJournal ); |
224 | //QTimer::singleShot( 0, this, SLOT( setVisibleOn() ) ); | 244 | //QTimer::singleShot( 0, this, SLOT( setVisibleOn() ) ); |
225 | } | 245 | } |
226 | } | 246 | } |
diff --git a/korganizer/journalentry.h b/korganizer/journalentry.h index ed04b7c..a69846c 100644 --- a/korganizer/journalentry.h +++ b/korganizer/journalentry.h | |||
@@ -1,86 +1,89 @@ | |||
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 | #ifndef JOURNALENTRY_H | 23 | #ifndef JOURNALENTRY_H |
24 | #define JOURNALENTRY_H | 24 | #define JOURNALENTRY_H |
25 | // | 25 | // |
26 | // Widget showing one Journal entry | 26 | // Widget showing one Journal entry |
27 | 27 | ||
28 | #include <qframe.h> | 28 | #include <qframe.h> |
29 | 29 | ||
30 | #include <libkcal/calendar.h> | 30 | #include <libkcal/calendar.h> |
31 | 31 | ||
32 | class QLabel; | 32 | class QLabel; |
33 | class KTextEdit; | 33 | class KTextEdit; |
34 | class QComboBox; | 34 | class QComboBox; |
35 | class KLineEdit; | 35 | class KLineEdit; |
36 | class KOLocationBox; | 36 | class KOLocationBox; |
37 | 37 | ||
38 | using namespace KCal; | 38 | using namespace KCal; |
39 | 39 | ||
40 | class JournalEntry : public QFrame { | 40 | class JournalEntry : public QFrame { |
41 | Q_OBJECT | 41 | Q_OBJECT |
42 | public: | 42 | public: |
43 | JournalEntry(Calendar *,QWidget *parent); | 43 | JournalEntry(Calendar *,QWidget *parent); |
44 | virtual ~JournalEntry(); | 44 | virtual ~JournalEntry(); |
45 | 45 | ||
46 | void setJournal(Journal *, bool saveJournal = true ); | 46 | void setJournal(Journal *, bool saveJournal = true ); |
47 | Journal *journal() const; | 47 | Journal *journal() const; |
48 | 48 | ||
49 | void setDate(const QDate &); | 49 | void setDate(const QDate &); |
50 | 50 | ||
51 | void clear(); | 51 | void clear(); |
52 | 52 | ||
53 | void flushEntry(); | 53 | void flushEntry(); |
54 | void setShowOnly(); | 54 | void setShowOnly(); |
55 | QSize sizeHint() const; | 55 | QSize sizeHint() const; |
56 | void setVisibleMode( bool b ) { visibleMode = b;} | 56 | void setVisibleMode( bool b ) { visibleMode = b;} |
57 | void fillCalendar( int id = 0 ); | 57 | void fillCalendar( int id = 0 ); |
58 | void resizeEvent(QResizeEvent* e ) ; | ||
58 | protected slots: | 59 | protected slots: |
59 | void slotSaveTemplate(); | 60 | void slotSaveTemplate(); |
60 | void slotLoadTemplate(); | 61 | void slotLoadTemplate(); |
61 | void toggleShowJournal(); | 62 | void toggleShowJournal(); |
62 | void setVisibleOn(); | 63 | void setVisibleOn(); |
63 | signals: | 64 | signals: |
64 | void deleteJournal(Journal *); | 65 | void deleteJournal(Journal *); |
65 | void newJournal(); | 66 | void newJournal(); |
66 | void showJournalOnly( Journal * ); | 67 | void showJournalOnly( Journal * ); |
67 | 68 | ||
68 | protected: | 69 | protected: |
69 | bool eventFilter( QObject *o, QEvent *e ); | 70 | bool eventFilter( QObject *o, QEvent *e ); |
70 | 71 | ||
71 | void writeJournal(); | 72 | void writeJournal(); |
72 | 73 | ||
73 | private: | 74 | private: |
75 | int mMaxWidDiff; | ||
76 | int mDeskWid; | ||
74 | bool visibleMode; | 77 | bool visibleMode; |
75 | bool showOnlyMode; | 78 | bool showOnlyMode; |
76 | Calendar *mCalendar; | 79 | Calendar *mCalendar; |
77 | Journal *mJournal; | 80 | Journal *mJournal; |
78 | QDate mDate; | 81 | QDate mDate; |
79 | void keyPressEvent ( QKeyEvent * ) ; | 82 | void keyPressEvent ( QKeyEvent * ) ; |
80 | QComboBox *mCalendarBox; | 83 | QComboBox *mCalendarBox; |
81 | KOLocationBox * mTitle; | 84 | KOLocationBox * mTitle; |
82 | KTextEdit *mEditor; | 85 | KTextEdit *mEditor; |
83 | int heiHint; | 86 | int heiHint; |
84 | }; | 87 | }; |
85 | 88 | ||
86 | #endif | 89 | #endif |
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 5249300..4bedb61 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp | |||
@@ -2451,186 +2451,186 @@ void MainWindow::importFile( QString fn, bool quick ) | |||
2451 | QFileInfo info; | 2451 | QFileInfo info; |
2452 | info.setFile( fn ); | 2452 | info.setFile( fn ); |
2453 | QString mess; | 2453 | QString mess; |
2454 | if ( !info. exists() ) { | 2454 | if ( !info. exists() ) { |
2455 | mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); | 2455 | mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); |
2456 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2456 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2457 | mess ); | 2457 | mess ); |
2458 | return; | 2458 | return; |
2459 | } | 2459 | } |
2460 | int result = 0; | 2460 | int result = 0; |
2461 | if ( !quick ) { | 2461 | if ( !quick ) { |
2462 | 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 )); | 2462 | 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 )); |
2463 | result = QMessageBox::warning( this, "KO/Pi: Warning!", | 2463 | result = QMessageBox::warning( this, "KO/Pi: Warning!", |
2464 | mess, | 2464 | mess, |
2465 | "Import", "Cancel", 0, | 2465 | "Import", "Cancel", 0, |
2466 | 0, 1 ); | 2466 | 0, 1 ); |
2467 | } | 2467 | } |
2468 | if ( result == 0 ) { | 2468 | if ( result == 0 ) { |
2469 | if ( mView->openCalendar( fn, true )) { | 2469 | if ( mView->openCalendar( fn, true )) { |
2470 | KOPrefs::instance()->mLastImportFile = fn; | 2470 | KOPrefs::instance()->mLastImportFile = fn; |
2471 | setCaption(i18n("Imported file successfully")); | 2471 | setCaption(i18n("Imported file successfully")); |
2472 | } else { | 2472 | } else { |
2473 | setCaption(i18n("Error importing file")); | 2473 | setCaption(i18n("Error importing file")); |
2474 | } | 2474 | } |
2475 | } | 2475 | } |
2476 | } | 2476 | } |
2477 | 2477 | ||
2478 | void MainWindow::importIcal() | 2478 | void MainWindow::importIcal() |
2479 | { | 2479 | { |
2480 | 2480 | ||
2481 | QString fn =KOPrefs::instance()->mLastImportFile; | 2481 | QString fn =KOPrefs::instance()->mLastImportFile; |
2482 | 2482 | ||
2483 | fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); | 2483 | fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); |
2484 | if ( fn == "" ) | 2484 | if ( fn == "" ) |
2485 | return; | 2485 | return; |
2486 | importFile( fn, true ); | 2486 | importFile( fn, true ); |
2487 | 2487 | ||
2488 | } | 2488 | } |
2489 | 2489 | ||
2490 | void MainWindow::exportVCalendar() | 2490 | void MainWindow::exportVCalendar() |
2491 | { | 2491 | { |
2492 | QString fn = KOPrefs::instance()->mLastVcalFile; | 2492 | QString fn = KOPrefs::instance()->mLastVcalFile; |
2493 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); | 2493 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); |
2494 | if ( fn == "" ) | 2494 | if ( fn == "" ) |
2495 | return; | 2495 | return; |
2496 | QFileInfo info; | 2496 | QFileInfo info; |
2497 | info.setFile( fn ); | 2497 | info.setFile( fn ); |
2498 | QString mes; | 2498 | QString mes; |
2499 | bool createbup = true; | 2499 | bool createbup = true; |
2500 | if ( info. exists() ) { | 2500 | if ( info. exists() ) { |
2501 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | 2501 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); |
2502 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 2502 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
2503 | i18n("Overwrite!"), i18n("Cancel"), 0, | 2503 | i18n("Overwrite!"), i18n("Cancel"), 0, |
2504 | 0, 1 ); | 2504 | 0, 1 ); |
2505 | if ( result != 0 ) { | 2505 | if ( result != 0 ) { |
2506 | createbup = false; | 2506 | createbup = false; |
2507 | } | 2507 | } |
2508 | } | 2508 | } |
2509 | if ( createbup ) { | 2509 | if ( createbup ) { |
2510 | if ( mView->exportVCalendar( fn ) ) { | 2510 | if ( mView->exportVCalendar( fn ) ) { |
2511 | KOPrefs::instance()->mLastVcalFile = fn; | 2511 | KOPrefs::instance()->mLastVcalFile = fn; |
2512 | if ( fn.length() > 20 ) | 2512 | if ( fn.length() > 20 ) |
2513 | mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; | 2513 | mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; |
2514 | else | 2514 | else |
2515 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); | 2515 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); |
2516 | setCaption(mes); | 2516 | setCaption(mes); |
2517 | } | 2517 | } |
2518 | } | 2518 | } |
2519 | 2519 | ||
2520 | } | 2520 | } |
2521 | QString MainWindow::sentSyncFile() | 2521 | QString MainWindow::sentSyncFile() |
2522 | { | 2522 | { |
2523 | #ifdef DESKTOP_VERSION | 2523 | #ifdef DESKTOP_VERSION |
2524 | return locateLocal( "tmp", "copysynccal.ics" ); | 2524 | return locateLocal( "tmp", "copysynccal.ics" ); |
2525 | #else | 2525 | #else |
2526 | return QString( "/tmp/copysynccal.ics" ); | 2526 | return QString( "/tmp/copysynccal.ics" ); |
2527 | #endif | 2527 | #endif |
2528 | } | 2528 | } |
2529 | 2529 | ||
2530 | void MainWindow::syncFileRequest() | 2530 | void MainWindow::syncFileRequest() |
2531 | { | 2531 | { |
2532 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { | 2532 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { |
2533 | mSyncManager->slotSyncMenu( 999 ); | 2533 | mSyncManager->slotSyncMenu( 999 ); |
2534 | } | 2534 | } |
2535 | 2535 | ||
2536 | setCaption(i18n("Saving Data to temp file ..." )); | 2536 | setCaption(i18n("Saving Data to temp file ..." )); |
2537 | mView->saveCalendar( sentSyncFile() ); | 2537 | mView->saveCalendar( sentSyncFile() ); |
2538 | setCaption(i18n("Data saved to temp file!" )); | 2538 | setCaption(i18n("Data saved to temp file!" )); |
2539 | 2539 | ||
2540 | } | 2540 | } |
2541 | void MainWindow::getFile( bool success ) | 2541 | void MainWindow::getFile( bool success ) |
2542 | { | 2542 | { |
2543 | if ( ! success ) { | 2543 | if ( ! success ) { |
2544 | setCaption( i18n("Error receiving file. Nothing changed!") ); | 2544 | setCaption( i18n("Error receiving file. Nothing changed!") ); |
2545 | return; | 2545 | return; |
2546 | } | 2546 | } |
2547 | mView->openCalendar( sentSyncFile() ); | 2547 | mView->mergeFile( sentSyncFile() ); |
2548 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { | 2548 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { |
2549 | mSyncManager->slotSyncMenu( 999 ); | 2549 | mSyncManager->slotSyncMenu( 999 ); |
2550 | } | 2550 | } |
2551 | setCaption( i18n("Pi-Sync successful!") ); | 2551 | setCaption( i18n("Pi-Sync successful!") ); |
2552 | } | 2552 | } |
2553 | void MainWindow::printListView() | 2553 | void MainWindow::printListView() |
2554 | { | 2554 | { |
2555 | 2555 | ||
2556 | QString message = i18n("You can make a printout of the <b>List View</b> and the list view in the <b>Search Dialog</b>! To do this, please go to the <b>List View/Search Dialog</b>. Right click on the list. Select in the popup menu the entry <b>Print complete list</b>. That prints the list as you see it. You can remove items from the list before printing without deleting the corresponding event/todo! Simply select all items you do not want to print out. Then right click on one of the items and choose <b>Hide selected items</b>. After that you can print the list without these items."); | 2556 | QString message = i18n("You can make a printout of the <b>List View</b> and the list view in the <b>Search Dialog</b>! To do this, please go to the <b>List View/Search Dialog</b>. Right click on the list. Select in the popup menu the entry <b>Print complete list</b>. That prints the list as you see it. You can remove items from the list before printing without deleting the corresponding event/todo! Simply select all items you do not want to print out. Then right click on one of the items and choose <b>Hide selected items</b>. After that you can print the list without these items."); |
2557 | 2557 | ||
2558 | KMessageBox::information( this, message); | 2558 | KMessageBox::information( this, message); |
2559 | } | 2559 | } |
2560 | void MainWindow::printSel( ) | 2560 | void MainWindow::printSel( ) |
2561 | { | 2561 | { |
2562 | mView->viewManager()->agendaView()->agenda()->printSelection(); | 2562 | mView->viewManager()->agendaView()->agenda()->printSelection(); |
2563 | } | 2563 | } |
2564 | 2564 | ||
2565 | void MainWindow::printCal() | 2565 | void MainWindow::printCal() |
2566 | { | 2566 | { |
2567 | mView->print();//mCp->showDialog(); | 2567 | mView->print();//mCp->showDialog(); |
2568 | } | 2568 | } |
2569 | 2569 | ||
2570 | 2570 | ||
2571 | #include "libkdepim/kdatepicker.h" | 2571 | #include "libkdepim/kdatepicker.h" |
2572 | #include <kdatetbl.h> | 2572 | #include <kdatetbl.h> |
2573 | 2573 | ||
2574 | void MainWindow::weekAction() | 2574 | void MainWindow::weekAction() |
2575 | { | 2575 | { |
2576 | int month; | 2576 | int month; |
2577 | KPopupFrame* popup = new KPopupFrame(this); | 2577 | KPopupFrame* popup = new KPopupFrame(this); |
2578 | KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(popup); | 2578 | KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(popup); |
2579 | // ----- | 2579 | // ----- |
2580 | picker->resize(picker->sizeHint()); | 2580 | picker->resize(picker->sizeHint()); |
2581 | popup->setMainWidget(picker); | 2581 | popup->setMainWidget(picker); |
2582 | picker->setFocus(); | 2582 | picker->setFocus(); |
2583 | connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); | 2583 | connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); |
2584 | int x = 0; | 2584 | int x = 0; |
2585 | int y = iconToolBar->height(); | 2585 | int y = iconToolBar->height(); |
2586 | int dX = 0; | 2586 | int dX = 0; |
2587 | int dY = 0; | 2587 | int dY = 0; |
2588 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { | 2588 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { |
2589 | if ( iconToolBar->y() > height()/2 ) { | 2589 | if ( iconToolBar->y() > height()/2 ) { |
2590 | dY = picker->sizeHint().height()+8; | 2590 | dY = picker->sizeHint().height()+8; |
2591 | y = 0; | 2591 | y = 0; |
2592 | } | 2592 | } |
2593 | } else { | 2593 | } else { |
2594 | if ( iconToolBar->x() > width()/2 ) { // right side | 2594 | if ( iconToolBar->x() > width()/2 ) { // right side |
2595 | x=0; | 2595 | x=0; |
2596 | dX= picker->sizeHint().width()+8; | 2596 | dX= picker->sizeHint().width()+8; |
2597 | y = 0; | 2597 | y = 0; |
2598 | } else { | 2598 | } else { |
2599 | x= iconToolBar->width(); | 2599 | x= iconToolBar->width(); |
2600 | y = 0; | 2600 | y = 0; |
2601 | } | 2601 | } |
2602 | } | 2602 | } |
2603 | //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); | 2603 | //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); |
2604 | if(popup->exec(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY)))) | 2604 | if(popup->exec(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY)))) |
2605 | { | 2605 | { |
2606 | month = picker->getResult(); | 2606 | month = picker->getResult(); |
2607 | emit selectWeek ( month ); | 2607 | emit selectWeek ( month ); |
2608 | //qDebug("weekSelected %d ", month); | 2608 | //qDebug("weekSelected %d ", month); |
2609 | } | 2609 | } |
2610 | delete popup; | 2610 | delete popup; |
2611 | } | 2611 | } |
2612 | 2612 | ||
2613 | void MainWindow::hideEvent ( QHideEvent * ) | 2613 | void MainWindow::hideEvent ( QHideEvent * ) |
2614 | { | 2614 | { |
2615 | QString message; | 2615 | QString message; |
2616 | QDateTime nextA = mCalendar->nextAlarmEventDateTime(); | 2616 | QDateTime nextA = mCalendar->nextAlarmEventDateTime(); |
2617 | if ( nextA.isValid() ) { | 2617 | if ( nextA.isValid() ) { |
2618 | QString sum = mCalendar->nextSummary(); | 2618 | QString sum = mCalendar->nextSummary(); |
2619 | 2619 | ||
2620 | message = i18n("%1 %2 - %3 (next event/todo with alarm)").arg( KGlobal::locale()->formatTime(nextA.time() , false)).arg(sum ).arg( KGlobal::locale()->formatDate(nextA.date() , false)); | 2620 | message = i18n("%1 %2 - %3 (next event/todo with alarm)").arg( KGlobal::locale()->formatTime(nextA.time() , false)).arg(sum ).arg( KGlobal::locale()->formatDate(nextA.date() , false)); |
2621 | setCaption( message ); | 2621 | setCaption( message ); |
2622 | } | 2622 | } |
2623 | } | 2623 | } |
2624 | 2624 | ||
2625 | void MainWindow::resizeEvent( QResizeEvent* e) | 2625 | void MainWindow::resizeEvent( QResizeEvent* e) |
2626 | { | 2626 | { |
2627 | #ifndef DESKTOP_VERSION | 2627 | #ifndef DESKTOP_VERSION |
2628 | if ( !KOPrefs::instance()->mShowIconFilter && !KOPrefs::instance()->mShowIconOnetoolbar && QApplication::desktop()->width() > 320) { | 2628 | if ( !KOPrefs::instance()->mShowIconFilter && !KOPrefs::instance()->mShowIconOnetoolbar && QApplication::desktop()->width() > 320) { |
2629 | if (QApplication::desktop()->width() > QApplication::desktop()->height() ) | 2629 | if (QApplication::desktop()->width() > QApplication::desktop()->height() ) |
2630 | filterToolBar->hide(); | 2630 | filterToolBar->hide(); |
2631 | else | 2631 | else |
2632 | filterToolBar->show(); | 2632 | filterToolBar->show(); |
2633 | } | 2633 | } |
2634 | #endif | 2634 | #endif |
2635 | QMainWindow::resizeEvent( e); | 2635 | QMainWindow::resizeEvent( e); |
2636 | } | 2636 | } |
diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp index a662eeb..b7990d4 100644 --- a/libkcal/calendar.cpp +++ b/libkcal/calendar.cpp | |||
@@ -267,192 +267,193 @@ QPtrList<Incidence> Calendar::incidences() | |||
267 | 267 | ||
268 | QPtrList<Journal> j = journals(); | 268 | QPtrList<Journal> j = journals(); |
269 | for( i = j.first(); i; i = j.next() ) incidences.append( i ); | 269 | for( i = j.first(); i; i = j.next() ) incidences.append( i ); |
270 | 270 | ||
271 | return incidences; | 271 | return incidences; |
272 | } | 272 | } |
273 | 273 | ||
274 | void Calendar::resetPilotStat(int id ) | 274 | void Calendar::resetPilotStat(int id ) |
275 | { | 275 | { |
276 | QPtrList<Incidence> incidences; | 276 | QPtrList<Incidence> incidences; |
277 | 277 | ||
278 | Incidence *i; | 278 | Incidence *i; |
279 | 279 | ||
280 | QPtrList<Event> e = rawEvents(); | 280 | QPtrList<Event> e = rawEvents(); |
281 | for( i = e.first(); i; i = e.next() ) i->setPilotId( id ); | 281 | for( i = e.first(); i; i = e.next() ) i->setPilotId( id ); |
282 | 282 | ||
283 | QPtrList<Todo> t = rawTodos(); | 283 | QPtrList<Todo> t = rawTodos(); |
284 | for( i = t.first(); i; i = t.next() ) i->setPilotId( id ); | 284 | for( i = t.first(); i; i = t.next() ) i->setPilotId( id ); |
285 | 285 | ||
286 | QPtrList<Journal> j = journals(); | 286 | QPtrList<Journal> j = journals(); |
287 | for( i = j.first(); i; i = j.next() ) i->setPilotId( id ); | 287 | for( i = j.first(); i; i = j.next() ) i->setPilotId( id ); |
288 | } | 288 | } |
289 | void Calendar::resetTempSyncStat() | 289 | void Calendar::resetTempSyncStat() |
290 | { | 290 | { |
291 | QPtrList<Incidence> incidences; | 291 | QPtrList<Incidence> incidences; |
292 | 292 | ||
293 | Incidence *i; | 293 | Incidence *i; |
294 | 294 | ||
295 | QPtrList<Event> e = rawEvents(); | 295 | QPtrList<Event> e = rawEvents(); |
296 | for( i = e.first(); i; i = e.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 296 | for( i = e.first(); i; i = e.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
297 | 297 | ||
298 | QPtrList<Todo> t = rawTodos(); | 298 | QPtrList<Todo> t = rawTodos(); |
299 | for( i = t.first(); i; i = t.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 299 | for( i = t.first(); i; i = t.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
300 | 300 | ||
301 | QPtrList<Journal> j = journals(); | 301 | QPtrList<Journal> j = journals(); |
302 | for( i = j.first(); i; i = j.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 302 | for( i = j.first(); i; i = j.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
303 | } | 303 | } |
304 | QPtrList<Incidence> Calendar::rawIncidences() | 304 | QPtrList<Incidence> Calendar::rawIncidences() |
305 | { | 305 | { |
306 | QPtrList<Incidence> incidences; | 306 | QPtrList<Incidence> incidences; |
307 | 307 | ||
308 | Incidence *i; | 308 | Incidence *i; |
309 | 309 | ||
310 | QPtrList<Event> e = rawEvents(); | 310 | QPtrList<Event> e = rawEvents(); |
311 | for( i = e.first(); i; i = e.next() ) incidences.append( i ); | 311 | for( i = e.first(); i; i = e.next() ) incidences.append( i ); |
312 | 312 | ||
313 | QPtrList<Todo> t = rawTodos(); | 313 | QPtrList<Todo> t = rawTodos(); |
314 | for( i = t.first(); i; i = t.next() ) incidences.append( i ); | 314 | for( i = t.first(); i; i = t.next() ) incidences.append( i ); |
315 | 315 | ||
316 | QPtrList<Journal> j = journals(); | 316 | QPtrList<Journal> j = journals(); |
317 | for( i = j.first(); i; i = j.next() ) incidences.append( i ); | 317 | for( i = j.first(); i; i = j.next() ) incidences.append( i ); |
318 | 318 | ||
319 | return incidences; | 319 | return incidences; |
320 | } | 320 | } |
321 | 321 | ||
322 | QPtrList<Event> Calendar::events( const QDate &date, bool sorted ) | 322 | QPtrList<Event> Calendar::events( const QDate &date, bool sorted ) |
323 | { | 323 | { |
324 | QPtrList<Event> el = rawEventsForDate(date,sorted); | 324 | QPtrList<Event> el = rawEventsForDate(date,sorted); |
325 | mFilter->apply(&el); | 325 | mFilter->apply(&el); |
326 | return el; | 326 | return el; |
327 | } | 327 | } |
328 | 328 | ||
329 | QPtrList<Event> Calendar::events( const QDateTime &qdt ) | 329 | QPtrList<Event> Calendar::events( const QDateTime &qdt ) |
330 | { | 330 | { |
331 | QPtrList<Event> el = rawEventsForDate(qdt); | 331 | QPtrList<Event> el = rawEventsForDate(qdt); |
332 | mFilter->apply(&el); | 332 | mFilter->apply(&el); |
333 | return el; | 333 | return el; |
334 | } | 334 | } |
335 | 335 | ||
336 | QPtrList<Event> Calendar::events( const QDate &start, const QDate &end, | 336 | QPtrList<Event> Calendar::events( const QDate &start, const QDate &end, |
337 | bool inclusive) | 337 | bool inclusive) |
338 | { | 338 | { |
339 | QPtrList<Event> el = rawEvents(start,end,inclusive); | 339 | QPtrList<Event> el = rawEvents(start,end,inclusive); |
340 | mFilter->apply(&el); | 340 | mFilter->apply(&el); |
341 | return el; | 341 | return el; |
342 | } | 342 | } |
343 | 343 | ||
344 | QPtrList<Event> Calendar::events() | 344 | QPtrList<Event> Calendar::events() |
345 | { | 345 | { |
346 | QPtrList<Event> el = rawEvents(); | 346 | QPtrList<Event> el = rawEvents(); |
347 | mFilter->apply(&el); | 347 | mFilter->apply(&el); |
348 | return el; | 348 | return el; |
349 | } | 349 | } |
350 | void Calendar::addIncidenceBranch(Incidence *i) | 350 | void Calendar::addIncidenceBranch(Incidence *i) |
351 | { | 351 | { |
352 | addIncidence( i ); | 352 | addIncidence( i ); |
353 | Incidence * inc; | 353 | Incidence * inc; |
354 | QPtrList<Incidence> Relations = i->relations(); | 354 | QPtrList<Incidence> Relations = i->relations(); |
355 | for (inc=Relations.first();inc;inc=Relations.next()) { | 355 | for (inc=Relations.first();inc;inc=Relations.next()) { |
356 | addIncidenceBranch( inc ); | 356 | addIncidenceBranch( inc ); |
357 | } | 357 | } |
358 | } | 358 | } |
359 | 359 | ||
360 | bool Calendar::addIncidence(Incidence *i) | 360 | bool Calendar::addIncidence(Incidence *i) |
361 | { | 361 | { |
362 | Incidence::AddVisitor<Calendar> v(this); | 362 | Incidence::AddVisitor<Calendar> v(this); |
363 | if ( i->calID() == 0 ) | ||
363 | i->setCalID( mDefaultCalendar ); | 364 | i->setCalID( mDefaultCalendar ); |
364 | i->setCalEnabled( true ); | 365 | i->setCalEnabled( true ); |
365 | return i->accept(v); | 366 | return i->accept(v); |
366 | } | 367 | } |
367 | void Calendar::deleteIncidence(Incidence *in) | 368 | void Calendar::deleteIncidence(Incidence *in) |
368 | { | 369 | { |
369 | if ( in->typeID() == eventID ) | 370 | if ( in->typeID() == eventID ) |
370 | deleteEvent( (Event*) in ); | 371 | deleteEvent( (Event*) in ); |
371 | else if ( in->typeID() == todoID ) | 372 | else if ( in->typeID() == todoID ) |
372 | deleteTodo( (Todo*) in); | 373 | deleteTodo( (Todo*) in); |
373 | else if ( in->typeID() == journalID ) | 374 | else if ( in->typeID() == journalID ) |
374 | deleteJournal( (Journal*) in ); | 375 | deleteJournal( (Journal*) in ); |
375 | } | 376 | } |
376 | 377 | ||
377 | Incidence* Calendar::incidence( const QString& uid ) | 378 | Incidence* Calendar::incidence( const QString& uid ) |
378 | { | 379 | { |
379 | Incidence* i; | 380 | Incidence* i; |
380 | 381 | ||
381 | if( (i = todo( uid )) != 0 ) | 382 | if( (i = todo( uid )) != 0 ) |
382 | return i; | 383 | return i; |
383 | if( (i = event( uid )) != 0 ) | 384 | if( (i = event( uid )) != 0 ) |
384 | return i; | 385 | return i; |
385 | if( (i = journal( uid )) != 0 ) | 386 | if( (i = journal( uid )) != 0 ) |
386 | return i; | 387 | return i; |
387 | 388 | ||
388 | return 0; | 389 | return 0; |
389 | } | 390 | } |
390 | 391 | ||
391 | QPtrList<Todo> Calendar::todos() | 392 | QPtrList<Todo> Calendar::todos() |
392 | { | 393 | { |
393 | QPtrList<Todo> tl = rawTodos(); | 394 | QPtrList<Todo> tl = rawTodos(); |
394 | mFilter->apply( &tl ); | 395 | mFilter->apply( &tl ); |
395 | return tl; | 396 | return tl; |
396 | } | 397 | } |
397 | 398 | ||
398 | // When this is called, the todo have already been added to the calendar. | 399 | // When this is called, the todo have already been added to the calendar. |
399 | // This method is only about linking related todos | 400 | // This method is only about linking related todos |
400 | void Calendar::setupRelations( Incidence *incidence ) | 401 | void Calendar::setupRelations( Incidence *incidence ) |
401 | { | 402 | { |
402 | QString uid = incidence->uid(); | 403 | QString uid = incidence->uid(); |
403 | //qDebug("Calendar::setupRelations "); | 404 | //qDebug("Calendar::setupRelations "); |
404 | // First, go over the list of orphans and see if this is their parent | 405 | // First, go over the list of orphans and see if this is their parent |
405 | while( Incidence* i = mOrphans[ uid ] ) { | 406 | while( Incidence* i = mOrphans[ uid ] ) { |
406 | mOrphans.remove( uid ); | 407 | mOrphans.remove( uid ); |
407 | i->setRelatedTo( incidence ); | 408 | i->setRelatedTo( incidence ); |
408 | incidence->addRelation( i ); | 409 | incidence->addRelation( i ); |
409 | mOrphanUids.remove( i->uid() ); | 410 | mOrphanUids.remove( i->uid() ); |
410 | } | 411 | } |
411 | 412 | ||
412 | // Now see about this incidences parent | 413 | // Now see about this incidences parent |
413 | if( !incidence->relatedTo() && !incidence->relatedToUid().isEmpty() ) { | 414 | if( !incidence->relatedTo() && !incidence->relatedToUid().isEmpty() ) { |
414 | // This incidence has a uid it is related to, but is not registered to it yet | 415 | // This incidence has a uid it is related to, but is not registered to it yet |
415 | // Try to find it | 416 | // Try to find it |
416 | Incidence* parent = this->incidence( incidence->relatedToUid() ); | 417 | Incidence* parent = this->incidence( incidence->relatedToUid() ); |
417 | if( parent ) { | 418 | if( parent ) { |
418 | // Found it | 419 | // Found it |
419 | incidence->setRelatedTo( parent ); | 420 | incidence->setRelatedTo( parent ); |
420 | parent->addRelation( incidence ); | 421 | parent->addRelation( incidence ); |
421 | } else { | 422 | } else { |
422 | // Not found, put this in the mOrphans list | 423 | // Not found, put this in the mOrphans list |
423 | mOrphans.insert( incidence->relatedToUid(), incidence ); | 424 | mOrphans.insert( incidence->relatedToUid(), incidence ); |
424 | mOrphanUids.insert( incidence->uid(), incidence ); | 425 | mOrphanUids.insert( incidence->uid(), incidence ); |
425 | } | 426 | } |
426 | } | 427 | } |
427 | } | 428 | } |
428 | 429 | ||
429 | // If a task with subtasks is deleted, move it's subtasks to the orphans list | 430 | // If a task with subtasks is deleted, move it's subtasks to the orphans list |
430 | void Calendar::removeRelations( Incidence *incidence ) | 431 | void Calendar::removeRelations( Incidence *incidence ) |
431 | { | 432 | { |
432 | // qDebug("Calendar::removeRelations "); | 433 | // qDebug("Calendar::removeRelations "); |
433 | QString uid = incidence->uid(); | 434 | QString uid = incidence->uid(); |
434 | 435 | ||
435 | QPtrList<Incidence> relations = incidence->relations(); | 436 | QPtrList<Incidence> relations = incidence->relations(); |
436 | for( Incidence* i = relations.first(); i; i = relations.next() ) | 437 | for( Incidence* i = relations.first(); i; i = relations.next() ) |
437 | if( !mOrphanUids.find( i->uid() ) ) { | 438 | if( !mOrphanUids.find( i->uid() ) ) { |
438 | mOrphans.insert( uid, i ); | 439 | mOrphans.insert( uid, i ); |
439 | mOrphanUids.insert( i->uid(), i ); | 440 | mOrphanUids.insert( i->uid(), i ); |
440 | i->setRelatedTo( 0 ); | 441 | i->setRelatedTo( 0 ); |
441 | i->setRelatedToUid( uid ); | 442 | i->setRelatedToUid( uid ); |
442 | } | 443 | } |
443 | 444 | ||
444 | // If this incidence is related to something else, tell that about it | 445 | // If this incidence is related to something else, tell that about it |
445 | if( incidence->relatedTo() ) | 446 | if( incidence->relatedTo() ) |
446 | incidence->relatedTo()->removeRelation( incidence ); | 447 | incidence->relatedTo()->removeRelation( incidence ); |
447 | 448 | ||
448 | // Remove this one from the orphans list | 449 | // Remove this one from the orphans list |
449 | if( mOrphanUids.remove( uid ) ) | 450 | if( mOrphanUids.remove( uid ) ) |
450 | // This incidence is located in the orphans list - it should be removed | 451 | // This incidence is located in the orphans list - it should be removed |
451 | if( !( incidence->relatedTo() != 0 && mOrphans.remove( incidence->relatedTo()->uid() ) ) ) { | 452 | if( !( incidence->relatedTo() != 0 && mOrphans.remove( incidence->relatedTo()->uid() ) ) ) { |
452 | // Removing wasn't that easy | 453 | // Removing wasn't that easy |
453 | for( QDictIterator<Incidence> it( mOrphans ); it.current(); ++it ) { | 454 | for( QDictIterator<Incidence> it( mOrphans ); it.current(); ++it ) { |
454 | if( it.current()->uid() == uid ) { | 455 | if( it.current()->uid() == uid ) { |
455 | mOrphans.remove( it.currentKey() ); | 456 | mOrphans.remove( it.currentKey() ); |
456 | break; | 457 | break; |
457 | } | 458 | } |
458 | } | 459 | } |
diff --git a/libkcal/calendar.h b/libkcal/calendar.h index 4652fe5..14a1a45 100644 --- a/libkcal/calendar.h +++ b/libkcal/calendar.h | |||
@@ -1,174 +1,175 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 1998 Preston Brown | 3 | Copyright (c) 1998 Preston Brown |
4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library 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 GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #ifndef CALENDAR_H | 22 | #ifndef CALENDAR_H |
23 | #define CALENDAR_H | 23 | #define CALENDAR_H |
24 | 24 | ||
25 | #include <qobject.h> | 25 | #include <qobject.h> |
26 | #include <qstring.h> | 26 | #include <qstring.h> |
27 | #include <qdatetime.h> | 27 | #include <qdatetime.h> |
28 | #include <qptrlist.h> | 28 | #include <qptrlist.h> |
29 | #include <qdict.h> | 29 | #include <qdict.h> |
30 | 30 | ||
31 | #include "customproperties.h" | 31 | #include "customproperties.h" |
32 | #include "event.h" | 32 | #include "event.h" |
33 | #include "todo.h" | 33 | #include "todo.h" |
34 | #include "journal.h" | 34 | #include "journal.h" |
35 | #include "calfilter.h" | 35 | #include "calfilter.h" |
36 | 36 | ||
37 | //#define _TIME_ZONE "-0500" /* hardcoded, overridden in config file. */ | 37 | //#define _TIME_ZONE "-0500" /* hardcoded, overridden in config file. */ |
38 | 38 | ||
39 | class KConfig; | 39 | class KConfig; |
40 | 40 | ||
41 | namespace KCal { | 41 | namespace KCal { |
42 | 42 | ||
43 | 43 | ||
44 | /** | 44 | /** |
45 | This is the main "calendar" object class for KOrganizer. It holds | 45 | This is the main "calendar" object class for KOrganizer. It holds |
46 | information like all appointments/events, user information, etc. etc. | 46 | information like all appointments/events, user information, etc. etc. |
47 | one calendar is associated with each CalendarView (@see calendarview.h). | 47 | one calendar is associated with each CalendarView (@see calendarview.h). |
48 | This is an abstract base class defining the interface to a calendar. It is | 48 | This is an abstract base class defining the interface to a calendar. It is |
49 | implemented by subclasses like @see CalendarLocal, which use different | 49 | implemented by subclasses like @see CalendarLocal, which use different |
50 | methods to store and access the data. | 50 | methods to store and access the data. |
51 | 51 | ||
52 | Ownership of events etc. is handled by the following policy: As soon as an | 52 | Ownership of events etc. is handled by the following policy: As soon as an |
53 | event (or any other subclass of IncidenceBase) object is added to the | 53 | event (or any other subclass of IncidenceBase) object is added to the |
54 | Calendar by addEvent() it is owned by the Calendar object. The Calendar takes | 54 | Calendar by addEvent() it is owned by the Calendar object. The Calendar takes |
55 | care of deleting it. All Events returned by the query functions are returned | 55 | care of deleting it. All Events returned by the query functions are returned |
56 | as pointers, that means all changes to the returned events are immediately | 56 | as pointers, that means all changes to the returned events are immediately |
57 | visible in the Calendar. You shouldn't delete any Event object you get from | 57 | visible in the Calendar. You shouldn't delete any Event object you get from |
58 | Calendar. | 58 | Calendar. |
59 | */ | 59 | */ |
60 | class Calendar : public QObject, public CustomProperties, | 60 | class Calendar : public QObject, public CustomProperties, |
61 | public IncidenceBase::Observer | 61 | public IncidenceBase::Observer |
62 | { | 62 | { |
63 | Q_OBJECT | 63 | Q_OBJECT |
64 | public: | 64 | public: |
65 | Calendar(); | 65 | Calendar(); |
66 | Calendar(const QString &timeZoneId); | 66 | Calendar(const QString &timeZoneId); |
67 | virtual ~Calendar(); | 67 | virtual ~Calendar(); |
68 | Incidence * undoIncidence() { return mUndoIncidence; }; | 68 | Incidence * undoIncidence() { return mUndoIncidence; }; |
69 | bool undoDeleteIncidence(); | 69 | bool undoDeleteIncidence(); |
70 | void deleteIncidence(Incidence *in); | 70 | void deleteIncidence(Incidence *in); |
71 | void resetTempSyncStat(); | 71 | void resetTempSyncStat(); |
72 | void resetPilotStat(int id); | 72 | void resetPilotStat(int id); |
73 | /** | 73 | /** |
74 | Clears out the current calendar, freeing all used memory etc. | 74 | Clears out the current calendar, freeing all used memory etc. |
75 | */ | 75 | */ |
76 | virtual void close() = 0; | 76 | virtual void close() = 0; |
77 | virtual void addCalendar( Calendar* ) = 0; | 77 | virtual void addCalendar( Calendar* ) = 0; |
78 | virtual bool addCalendarFile( QString name, int id ) = 0; | 78 | virtual bool addCalendarFile( QString name, int id ) = 0; |
79 | virtual bool mergeCalendarFile( QString name ) = 0; | ||
79 | virtual void setSyncEventsReadOnly() = 0; | 80 | virtual void setSyncEventsReadOnly() = 0; |
80 | virtual void stopAllTodos() = 0; | 81 | virtual void stopAllTodos() = 0; |
81 | 82 | ||
82 | /** | 83 | /** |
83 | Sync changes in memory to persistant storage. | 84 | Sync changes in memory to persistant storage. |
84 | */ | 85 | */ |
85 | virtual void save() = 0; | 86 | virtual void save() = 0; |
86 | virtual QPtrList<Event> getExternLastSyncEvents() = 0; | 87 | virtual QPtrList<Event> getExternLastSyncEvents() = 0; |
87 | virtual void removeSyncInfo( QString syncProfile) = 0; | 88 | virtual void removeSyncInfo( QString syncProfile) = 0; |
88 | virtual bool isSaving() { return false; } | 89 | virtual bool isSaving() { return false; } |
89 | 90 | ||
90 | /** | 91 | /** |
91 | Return the owner of the calendar's full name. | 92 | Return the owner of the calendar's full name. |
92 | */ | 93 | */ |
93 | const QString &getOwner() const; | 94 | const QString &getOwner() const; |
94 | /** | 95 | /** |
95 | Set the owner of the calendar. Should be owner's full name. | 96 | Set the owner of the calendar. Should be owner's full name. |
96 | */ | 97 | */ |
97 | void setOwner( const QString &os ); | 98 | void setOwner( const QString &os ); |
98 | /** | 99 | /** |
99 | Return the email address of the calendar owner. | 100 | Return the email address of the calendar owner. |
100 | */ | 101 | */ |
101 | const QString &getEmail(); | 102 | const QString &getEmail(); |
102 | /** | 103 | /** |
103 | Set the email address of the calendar owner. | 104 | Set the email address of the calendar owner. |
104 | */ | 105 | */ |
105 | void setEmail( const QString & ); | 106 | void setEmail( const QString & ); |
106 | 107 | ||
107 | /** | 108 | /** |
108 | Set time zone from a timezone string (e.g. -2:00) | 109 | Set time zone from a timezone string (e.g. -2:00) |
109 | */ | 110 | */ |
110 | void setTimeZone( const QString &tz ); | 111 | void setTimeZone( const QString &tz ); |
111 | /** | 112 | /** |
112 | Set time zone from a minutes value (e.g. -60) | 113 | Set time zone from a minutes value (e.g. -60) |
113 | */ | 114 | */ |
114 | void setTimeZone( int tz ); | 115 | void setTimeZone( int tz ); |
115 | /** | 116 | /** |
116 | Return time zone as offest in minutes. | 117 | Return time zone as offest in minutes. |
117 | */ | 118 | */ |
118 | int getTimeZone() const; | 119 | int getTimeZone() const; |
119 | /** | 120 | /** |
120 | Compute an ISO 8601 format string from the time zone. | 121 | Compute an ISO 8601 format string from the time zone. |
121 | */ | 122 | */ |
122 | QString getTimeZoneStr() const; | 123 | QString getTimeZoneStr() const; |
123 | /** | 124 | /** |
124 | Set time zone id (see /usr/share/zoneinfo/zone.tab for list of legal | 125 | Set time zone id (see /usr/share/zoneinfo/zone.tab for list of legal |
125 | values). | 126 | values). |
126 | */ | 127 | */ |
127 | void setTimeZoneId( const QString & ); | 128 | void setTimeZoneId( const QString & ); |
128 | /** | 129 | /** |
129 | Return time zone id. | 130 | Return time zone id. |
130 | */ | 131 | */ |
131 | QString timeZoneId() const; | 132 | QString timeZoneId() const; |
132 | /** | 133 | /** |
133 | Use local time, not UTC or a time zone. | 134 | Use local time, not UTC or a time zone. |
134 | */ | 135 | */ |
135 | void setLocalTime(); | 136 | void setLocalTime(); |
136 | /** | 137 | /** |
137 | Return whether local time is being used. | 138 | Return whether local time is being used. |
138 | */ | 139 | */ |
139 | bool isLocalTime() const; | 140 | bool isLocalTime() const; |
140 | 141 | ||
141 | /** | 142 | /** |
142 | Add an incidence to calendar. | 143 | Add an incidence to calendar. |
143 | 144 | ||
144 | @return true on success, false on error. | 145 | @return true on success, false on error. |
145 | */ | 146 | */ |
146 | virtual bool addIncidence( Incidence * ); | 147 | virtual bool addIncidence( Incidence * ); |
147 | 148 | ||
148 | // Adds an incidence and all relatedto incidences to the cal | 149 | // Adds an incidence and all relatedto incidences to the cal |
149 | void addIncidenceBranch( Incidence * ); | 150 | void addIncidenceBranch( Incidence * ); |
150 | /** | 151 | /** |
151 | Return filtered list of all incidences of this calendar. | 152 | Return filtered list of all incidences of this calendar. |
152 | */ | 153 | */ |
153 | virtual QPtrList<Incidence> incidences(); | 154 | virtual QPtrList<Incidence> incidences(); |
154 | 155 | ||
155 | /** | 156 | /** |
156 | Return unfiltered list of all incidences of this calendar. | 157 | Return unfiltered list of all incidences of this calendar. |
157 | */ | 158 | */ |
158 | virtual QPtrList<Incidence> rawIncidences(); | 159 | virtual QPtrList<Incidence> rawIncidences(); |
159 | 160 | ||
160 | /** | 161 | /** |
161 | Adds a Event to this calendar object. | 162 | Adds a Event to this calendar object. |
162 | @param anEvent a pointer to the event to add | 163 | @param anEvent a pointer to the event to add |
163 | 164 | ||
164 | @return true on success, false on error. | 165 | @return true on success, false on error. |
165 | */ | 166 | */ |
166 | virtual bool addEventNoDup( Event *event ) = 0; | 167 | virtual bool addEventNoDup( Event *event ) = 0; |
167 | virtual bool addAnniversaryNoDup( Event *event ) = 0; | 168 | virtual bool addAnniversaryNoDup( Event *event ) = 0; |
168 | virtual bool addEvent( Event *anEvent ) = 0; | 169 | virtual bool addEvent( Event *anEvent ) = 0; |
169 | /** | 170 | /** |
170 | Delete event from calendar. | 171 | Delete event from calendar. |
171 | */ | 172 | */ |
172 | virtual void deleteEvent( Event * ) = 0; | 173 | virtual void deleteEvent( Event * ) = 0; |
173 | /** | 174 | /** |
174 | Retrieves an event on the basis of the unique string ID. | 175 | Retrieves an event on the basis of the unique string ID. |
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index cce798f..3e42ec0 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp | |||
@@ -1,166 +1,241 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | 3 | ||
4 | Copyright (c) 1998 Preston Brown | 4 | Copyright (c) 1998 Preston Brown |
5 | Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org> | 5 | Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org> |
6 | 6 | ||
7 | This library is free software; you can redistribute it and/or | 7 | This library is free software; you can redistribute it and/or |
8 | modify it under the terms of the GNU Library General Public | 8 | modify it under the terms of the GNU Library General Public |
9 | License as published by the Free Software Foundation; either | 9 | License as published by the Free Software Foundation; either |
10 | version 2 of the License, or (at your option) any later version. | 10 | version 2 of the License, or (at your option) any later version. |
11 | 11 | ||
12 | This library is distributed in the hope that it will be useful, | 12 | This library is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 | Library General Public License for more details. | 15 | Library General Public License for more details. |
16 | 16 | ||
17 | You should have received a copy of the GNU Library General Public License | 17 | You should have received a copy of the GNU Library General Public License |
18 | along with this library; see the file COPYING.LIB. If not, write to | 18 | along with this library; see the file COPYING.LIB. If not, write to |
19 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 19 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
20 | Boston, MA 02111-1307, USA. | 20 | Boston, MA 02111-1307, USA. |
21 | */ | 21 | */ |
22 | 22 | ||
23 | #include <qdatetime.h> | 23 | #include <qdatetime.h> |
24 | #include <qstring.h> | 24 | #include <qstring.h> |
25 | #include <qptrlist.h> | 25 | #include <qptrlist.h> |
26 | 26 | ||
27 | #include <kdebug.h> | 27 | #include <kdebug.h> |
28 | #include <kconfig.h> | 28 | #include <kconfig.h> |
29 | #include <kglobal.h> | 29 | #include <kglobal.h> |
30 | #include <klocale.h> | 30 | #include <klocale.h> |
31 | 31 | ||
32 | #include "vcaldrag.h" | 32 | #include "vcaldrag.h" |
33 | #include "vcalformat.h" | 33 | #include "vcalformat.h" |
34 | #include "icalformat.h" | 34 | #include "icalformat.h" |
35 | #include "exceptions.h" | 35 | #include "exceptions.h" |
36 | #include "incidence.h" | 36 | #include "incidence.h" |
37 | #include "journal.h" | 37 | #include "journal.h" |
38 | #include "filestorage.h" | 38 | #include "filestorage.h" |
39 | #include "calfilter.h" | 39 | #include "calfilter.h" |
40 | 40 | ||
41 | #include "calendarlocal.h" | 41 | #include "calendarlocal.h" |
42 | 42 | ||
43 | // #ifndef DESKTOP_VERSION | 43 | // #ifndef DESKTOP_VERSION |
44 | // #include <qtopia/alarmserver.h> | 44 | // #include <qtopia/alarmserver.h> |
45 | // #endif | 45 | // #endif |
46 | using namespace KCal; | 46 | using namespace KCal; |
47 | 47 | ||
48 | CalendarLocal::CalendarLocal() | 48 | CalendarLocal::CalendarLocal() |
49 | : Calendar() | 49 | : Calendar() |
50 | { | 50 | { |
51 | init(); | 51 | init(); |
52 | } | 52 | } |
53 | 53 | ||
54 | CalendarLocal::CalendarLocal(const QString &timeZoneId) | 54 | CalendarLocal::CalendarLocal(const QString &timeZoneId) |
55 | : Calendar(timeZoneId) | 55 | : Calendar(timeZoneId) |
56 | { | 56 | { |
57 | init(); | 57 | init(); |
58 | } | 58 | } |
59 | 59 | ||
60 | void CalendarLocal::init() | 60 | void CalendarLocal::init() |
61 | { | 61 | { |
62 | mNextAlarmIncidence = 0; | 62 | mNextAlarmIncidence = 0; |
63 | } | 63 | } |
64 | 64 | ||
65 | 65 | ||
66 | CalendarLocal::~CalendarLocal() | 66 | CalendarLocal::~CalendarLocal() |
67 | { | 67 | { |
68 | if ( mDeleteIncidencesOnClose ) | 68 | if ( mDeleteIncidencesOnClose ) |
69 | close(); | 69 | close(); |
70 | } | 70 | } |
71 | bool CalendarLocal::mergeCalendarFile( QString name ) | ||
72 | { | ||
73 | CalendarLocal calendar( timeZoneId() ); | ||
74 | calendar.setDefaultCalendar( 1 ); | ||
75 | if ( calendar.load( name ) ) { | ||
76 | mergeCalendar( &calendar ); | ||
77 | return true; | ||
78 | } | ||
79 | return false; | ||
80 | } | ||
81 | |||
82 | Incidence* CalendarLocal::incidenceForUid( const QString& uid ) | ||
83 | { | ||
84 | Todo *todo;; | ||
85 | Incidence *retVal = 0; | ||
86 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { | ||
87 | if ( todo->uid() == uid ) { | ||
88 | if ( retVal ) { | ||
89 | if ( retVal->calID() > todo->calID() ) { | ||
90 | retVal = todo; | ||
91 | } | ||
92 | } else { | ||
93 | retVal = todo; | ||
94 | } | ||
95 | } | ||
96 | } | ||
97 | if ( retVal ) return retVal; | ||
98 | Event *event; | ||
99 | for ( event = mEventList.first(); event; event = mEventList.next() ) { | ||
100 | if ( event->uid() == uid ) { | ||
101 | if ( retVal ) { | ||
102 | if ( retVal->calID() > event->calID() ) { | ||
103 | retVal = event; | ||
104 | } | ||
105 | } else { | ||
106 | retVal = event; | ||
107 | } | ||
108 | } | ||
109 | } | ||
110 | if ( retVal ) return retVal; | ||
111 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | ||
112 | if ( it->uid() == uid ) { | ||
113 | if ( retVal ) { | ||
114 | if ( retVal->calID() > it->calID() ) { | ||
115 | retVal = it; | ||
116 | } | ||
117 | } else { | ||
118 | retVal = it; | ||
119 | } | ||
120 | } | ||
121 | return retVal; | ||
122 | } | ||
123 | |||
124 | bool CalendarLocal::mergeCalendar( Calendar* remote ) | ||
125 | { | ||
126 | QPtrList<Incidence> er = remote->rawIncidences(); | ||
127 | Incidence* inR = er.first(); | ||
128 | Incidence* inL; | ||
129 | while ( inR ) { | ||
130 | inL = incidenceForUid( inR->uid() ); | ||
131 | if ( inL ) { | ||
132 | int calID = inL->calID(); | ||
133 | deleteIncidence( inL ); | ||
134 | inL = inR->clone(); | ||
135 | inL->setCalID( calID ); | ||
136 | addIncidence( inL ); | ||
137 | } else { | ||
138 | inL = inR->clone(); | ||
139 | inL->setCalID( 0 );// add to default cal | ||
140 | addIncidence( inL ); | ||
141 | } | ||
142 | inR = er.next(); | ||
143 | } | ||
144 | return true; | ||
145 | } | ||
71 | bool CalendarLocal::addCalendarFile( QString name, int id ) | 146 | bool CalendarLocal::addCalendarFile( QString name, int id ) |
72 | { | 147 | { |
73 | CalendarLocal calendar( timeZoneId() ); | 148 | CalendarLocal calendar( timeZoneId() ); |
74 | calendar.setDefaultCalendar( id ); | 149 | calendar.setDefaultCalendar( id ); |
75 | if ( calendar.load( name ) ) { | 150 | if ( calendar.load( name ) ) { |
76 | addCalendar( &calendar ); | 151 | addCalendar( &calendar ); |
77 | return true; | 152 | return true; |
78 | } | 153 | } |
79 | return false; | 154 | return false; |
80 | } | 155 | } |
81 | void CalendarLocal::setSyncEventsReadOnly() | 156 | void CalendarLocal::setSyncEventsReadOnly() |
82 | { | 157 | { |
83 | Event * ev; | 158 | Event * ev; |
84 | ev = mEventList.first(); | 159 | ev = mEventList.first(); |
85 | while ( ev ) { | 160 | while ( ev ) { |
86 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) | 161 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) |
87 | ev->setReadOnly( true ); | 162 | ev->setReadOnly( true ); |
88 | ev = mEventList.next(); | 163 | ev = mEventList.next(); |
89 | } | 164 | } |
90 | } | 165 | } |
91 | void CalendarLocal::addCalendar( Calendar* cal ) | 166 | void CalendarLocal::addCalendar( Calendar* cal ) |
92 | { | 167 | { |
93 | cal->setDontDeleteIncidencesOnClose(); | 168 | cal->setDontDeleteIncidencesOnClose(); |
94 | { | 169 | { |
95 | QPtrList<Event> EventList = cal->rawEvents(); | 170 | QPtrList<Event> EventList = cal->rawEvents(); |
96 | Event * ev = EventList.first(); | 171 | Event * ev = EventList.first(); |
97 | while ( ev ) { | 172 | while ( ev ) { |
98 | ev->unRegisterObserver( cal ); | 173 | ev->unRegisterObserver( cal ); |
99 | ev->registerObserver( this ); | 174 | ev->registerObserver( this ); |
100 | mEventList.append( ev ); | 175 | mEventList.append( ev ); |
101 | ev = EventList.next(); | 176 | ev = EventList.next(); |
102 | } | 177 | } |
103 | } | 178 | } |
104 | { | 179 | { |
105 | 180 | ||
106 | QPtrList<Todo> TodoList = cal->rawTodos(); | 181 | QPtrList<Todo> TodoList = cal->rawTodos(); |
107 | Todo * ev = TodoList.first(); | 182 | Todo * ev = TodoList.first(); |
108 | while ( ev ) { | 183 | while ( ev ) { |
109 | QString rel = ev->relatedToUid(); | 184 | QString rel = ev->relatedToUid(); |
110 | if ( !rel.isEmpty() ){ | 185 | if ( !rel.isEmpty() ){ |
111 | ev->setRelatedTo ( 0 ); | 186 | ev->setRelatedTo ( 0 ); |
112 | ev->setRelatedToUid( rel ); | 187 | ev->setRelatedToUid( rel ); |
113 | } | 188 | } |
114 | ev = TodoList.next(); | 189 | ev = TodoList.next(); |
115 | } | 190 | } |
116 | //TodoList = cal->rawTodos(); | 191 | //TodoList = cal->rawTodos(); |
117 | ev = TodoList.first(); | 192 | ev = TodoList.first(); |
118 | while ( ev ) { | 193 | while ( ev ) { |
119 | ev->unRegisterObserver( cal ); | 194 | ev->unRegisterObserver( cal ); |
120 | ev->registerObserver( this ); | 195 | ev->registerObserver( this ); |
121 | mTodoList.append( ev ); | 196 | mTodoList.append( ev ); |
122 | setupRelations( ev ); | 197 | setupRelations( ev ); |
123 | ev = TodoList.next(); | 198 | ev = TodoList.next(); |
124 | } | 199 | } |
125 | } | 200 | } |
126 | { | 201 | { |
127 | QPtrList<Journal> JournalList = cal->journals(); | 202 | QPtrList<Journal> JournalList = cal->journals(); |
128 | Journal * ev = JournalList.first(); | 203 | Journal * ev = JournalList.first(); |
129 | while ( ev ) { | 204 | while ( ev ) { |
130 | ev->unRegisterObserver( cal ); | 205 | ev->unRegisterObserver( cal ); |
131 | ev->registerObserver( this ); | 206 | ev->registerObserver( this ); |
132 | mJournalList.append( ev ); | 207 | mJournalList.append( ev ); |
133 | ev = JournalList.next(); | 208 | ev = JournalList.next(); |
134 | } | 209 | } |
135 | } | 210 | } |
136 | setModified( true ); | 211 | setModified( true ); |
137 | } | 212 | } |
138 | bool CalendarLocal::load( const QString &fileName ) | 213 | bool CalendarLocal::load( const QString &fileName ) |
139 | { | 214 | { |
140 | FileStorage storage( this, fileName ); | 215 | FileStorage storage( this, fileName ); |
141 | return storage.load(); | 216 | return storage.load(); |
142 | } | 217 | } |
143 | 218 | ||
144 | bool CalendarLocal::save( const QString &fileName, CalFormat *format ) | 219 | bool CalendarLocal::save( const QString &fileName, CalFormat *format ) |
145 | { | 220 | { |
146 | FileStorage storage( this, fileName, format ); | 221 | FileStorage storage( this, fileName, format ); |
147 | return storage.save(); | 222 | return storage.save(); |
148 | } | 223 | } |
149 | 224 | ||
150 | void CalendarLocal::stopAllTodos() | 225 | void CalendarLocal::stopAllTodos() |
151 | { | 226 | { |
152 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) | 227 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) |
153 | it->setRunning( false ); | 228 | it->setRunning( false ); |
154 | 229 | ||
155 | } | 230 | } |
156 | void CalendarLocal::close() | 231 | void CalendarLocal::close() |
157 | { | 232 | { |
158 | 233 | ||
159 | Todo * i; | 234 | Todo * i; |
160 | for( i = mTodoList.first(); i; i = mTodoList.next() ) i->setRunning(false); | 235 | for( i = mTodoList.first(); i; i = mTodoList.next() ) i->setRunning(false); |
161 | 236 | ||
162 | mEventList.setAutoDelete( true ); | 237 | mEventList.setAutoDelete( true ); |
163 | mTodoList.setAutoDelete( true ); | 238 | mTodoList.setAutoDelete( true ); |
164 | mJournalList.setAutoDelete( false ); | 239 | mJournalList.setAutoDelete( false ); |
165 | 240 | ||
166 | mEventList.clear(); | 241 | mEventList.clear(); |
diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h index 98d16a3..23b0542 100644 --- a/libkcal/calendarlocal.h +++ b/libkcal/calendarlocal.h | |||
@@ -1,143 +1,146 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | 3 | ||
4 | Copyright (c) 1998 Preston Brown | 4 | Copyright (c) 1998 Preston Brown |
5 | Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org> | 5 | Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org> |
6 | 6 | ||
7 | This library is free software; you can redistribute it and/or | 7 | This library is free software; you can redistribute it and/or |
8 | modify it under the terms of the GNU Library General Public | 8 | modify it under the terms of the GNU Library General Public |
9 | License as published by the Free Software Foundation; either | 9 | License as published by the Free Software Foundation; either |
10 | version 2 of the License, or (at your option) any later version. | 10 | version 2 of the License, or (at your option) any later version. |
11 | 11 | ||
12 | This library is distributed in the hope that it will be useful, | 12 | This library is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 | Library General Public License for more details. | 15 | Library General Public License for more details. |
16 | 16 | ||
17 | You should have received a copy of the GNU Library General Public License | 17 | You should have received a copy of the GNU Library General Public License |
18 | along with this library; see the file COPYING.LIB. If not, write to | 18 | along with this library; see the file COPYING.LIB. If not, write to |
19 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 19 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
20 | Boston, MA 02111-1307, USA. | 20 | Boston, MA 02111-1307, USA. |
21 | */ | 21 | */ |
22 | #ifndef KCAL_CALENDARLOCAL_H | 22 | #ifndef KCAL_CALENDARLOCAL_H |
23 | #define KCAL_CALENDARLOCAL_H | 23 | #define KCAL_CALENDARLOCAL_H |
24 | 24 | ||
25 | #include "calendar.h" | 25 | #include "calendar.h" |
26 | 26 | ||
27 | namespace KCal { | 27 | namespace KCal { |
28 | 28 | ||
29 | class CalFormat; | 29 | class CalFormat; |
30 | 30 | ||
31 | /** | 31 | /** |
32 | This class provides a calendar stored as a local file. | 32 | This class provides a calendar stored as a local file. |
33 | */ | 33 | */ |
34 | class CalendarLocal : public Calendar | 34 | class CalendarLocal : public Calendar |
35 | { | 35 | { |
36 | public: | 36 | public: |
37 | /** | 37 | /** |
38 | Constructs a new calendar, with variables initialized to sane values. | 38 | Constructs a new calendar, with variables initialized to sane values. |
39 | */ | 39 | */ |
40 | CalendarLocal(); | 40 | CalendarLocal(); |
41 | /** | 41 | /** |
42 | Constructs a new calendar, with variables initialized to sane values. | 42 | Constructs a new calendar, with variables initialized to sane values. |
43 | */ | 43 | */ |
44 | CalendarLocal( const QString &timeZoneId ); | 44 | CalendarLocal( const QString &timeZoneId ); |
45 | ~CalendarLocal(); | 45 | ~CalendarLocal(); |
46 | void addCalendar( Calendar* ); | 46 | void addCalendar( Calendar* ); |
47 | bool addCalendarFile( QString name, int id ); | 47 | bool addCalendarFile( QString name, int id ); |
48 | bool mergeCalendarFile( QString name ); | ||
49 | bool mergeCalendar( Calendar* cal ); | ||
50 | Incidence* incidenceForUid( const QString& uid ); | ||
48 | void setSyncEventsReadOnly(); | 51 | void setSyncEventsReadOnly(); |
49 | void stopAllTodos(); | 52 | void stopAllTodos(); |
50 | /** | 53 | /** |
51 | Loads a calendar on disk in vCalendar or iCalendar format into the current | 54 | Loads a calendar on disk in vCalendar or iCalendar format into the current |
52 | calendar. Any information already present is lost. | 55 | calendar. Any information already present is lost. |
53 | @return true, if successfull, false on error. | 56 | @return true, if successfull, false on error. |
54 | @param fileName the name of the calendar on disk. | 57 | @param fileName the name of the calendar on disk. |
55 | */ | 58 | */ |
56 | bool load( const QString &fileName ); | 59 | bool load( const QString &fileName ); |
57 | /** | 60 | /** |
58 | Writes out the calendar to disk in the specified \a format. | 61 | Writes out the calendar to disk in the specified \a format. |
59 | CalendarLocal takes ownership of the CalFormat object. | 62 | CalendarLocal takes ownership of the CalFormat object. |
60 | @return true, if successfull, false on error. | 63 | @return true, if successfull, false on error. |
61 | @param fileName the name of the file | 64 | @param fileName the name of the file |
62 | */ | 65 | */ |
63 | bool save( const QString &fileName, CalFormat *format = 0 ); | 66 | bool save( const QString &fileName, CalFormat *format = 0 ); |
64 | 67 | ||
65 | /** | 68 | /** |
66 | Clears out the current calendar, freeing all used memory etc. etc. | 69 | Clears out the current calendar, freeing all used memory etc. etc. |
67 | */ | 70 | */ |
68 | void close(); | 71 | void close(); |
69 | 72 | ||
70 | void save() {} | 73 | void save() {} |
71 | 74 | ||
72 | /** | 75 | /** |
73 | Add Event to calendar. | 76 | Add Event to calendar. |
74 | */ | 77 | */ |
75 | void removeSyncInfo( QString syncProfile); | 78 | void removeSyncInfo( QString syncProfile); |
76 | bool addAnniversaryNoDup( Event *event ); | 79 | bool addAnniversaryNoDup( Event *event ); |
77 | bool addEventNoDup( Event *event ); | 80 | bool addEventNoDup( Event *event ); |
78 | bool addEvent( Event *event ); | 81 | bool addEvent( Event *event ); |
79 | /** | 82 | /** |
80 | Deletes an event from this calendar. | 83 | Deletes an event from this calendar. |
81 | */ | 84 | */ |
82 | void deleteEvent( Event *event ); | 85 | void deleteEvent( Event *event ); |
83 | 86 | ||
84 | /** | 87 | /** |
85 | Retrieves an event on the basis of the unique string ID. | 88 | Retrieves an event on the basis of the unique string ID. |
86 | */ | 89 | */ |
87 | Event *event( const QString &uid ); | 90 | Event *event( const QString &uid ); |
88 | /** | 91 | /** |
89 | Return unfiltered list of all events in calendar. | 92 | Return unfiltered list of all events in calendar. |
90 | */ | 93 | */ |
91 | QPtrList<Event> rawEvents(); | 94 | QPtrList<Event> rawEvents(); |
92 | QPtrList<Event> getExternLastSyncEvents(); | 95 | QPtrList<Event> getExternLastSyncEvents(); |
93 | /** | 96 | /** |
94 | Add a todo to the todolist. | 97 | Add a todo to the todolist. |
95 | */ | 98 | */ |
96 | bool addTodo( Todo *todo ); | 99 | bool addTodo( Todo *todo ); |
97 | bool addTodoNoDup( Todo *todo ); | 100 | bool addTodoNoDup( Todo *todo ); |
98 | /** | 101 | /** |
99 | Remove a todo from the todolist. | 102 | Remove a todo from the todolist. |
100 | */ | 103 | */ |
101 | void deleteTodo( Todo * ); | 104 | void deleteTodo( Todo * ); |
102 | /** | 105 | /** |
103 | Searches todolist for an event with this unique string identifier, | 106 | Searches todolist for an event with this unique string identifier, |
104 | returns a pointer or null. | 107 | returns a pointer or null. |
105 | */ | 108 | */ |
106 | Todo *todo( const QString &uid ); | 109 | Todo *todo( const QString &uid ); |
107 | /** | 110 | /** |
108 | Return list of all todos. | 111 | Return list of all todos. |
109 | */ | 112 | */ |
110 | QPtrList<Todo> rawTodos(); | 113 | QPtrList<Todo> rawTodos(); |
111 | /** | 114 | /** |
112 | Returns list of todos due on the specified date. | 115 | Returns list of todos due on the specified date. |
113 | */ | 116 | */ |
114 | QPtrList<Todo> todos( const QDate &date ); | 117 | QPtrList<Todo> todos( const QDate &date ); |
115 | /** | 118 | /** |
116 | Return list of all todos. | 119 | Return list of all todos. |
117 | 120 | ||
118 | Workaround because compiler does not recognize function of base class. | 121 | Workaround because compiler does not recognize function of base class. |
119 | */ | 122 | */ |
120 | QPtrList<Todo> todos() { return Calendar::todos(); } | 123 | QPtrList<Todo> todos() { return Calendar::todos(); } |
121 | 124 | ||
122 | /** | 125 | /** |
123 | Add a Journal entry to calendar. | 126 | Add a Journal entry to calendar. |
124 | */ | 127 | */ |
125 | bool addJournal( Journal * ); | 128 | bool addJournal( Journal * ); |
126 | /** | 129 | /** |
127 | Remove a Journal from the calendar. | 130 | Remove a Journal from the calendar. |
128 | */ | 131 | */ |
129 | void deleteJournal( Journal * ); | 132 | void deleteJournal( Journal * ); |
130 | /** | 133 | /** |
131 | Return Journal for given date. | 134 | Return Journal for given date. |
132 | */ | 135 | */ |
133 | Journal *journal( const QDate & ); | 136 | Journal *journal( const QDate & ); |
134 | QPtrList<Journal> journals4Date( const QDate & ); | 137 | QPtrList<Journal> journals4Date( const QDate & ); |
135 | /** | 138 | /** |
136 | Return Journal with given UID. | 139 | Return Journal with given UID. |
137 | */ | 140 | */ |
138 | Journal *journal( const QString &uid ); | 141 | Journal *journal( const QString &uid ); |
139 | /** | 142 | /** |
140 | Return list of all Journals stored in calendar. | 143 | Return list of all Journals stored in calendar. |
141 | */ | 144 | */ |
142 | QPtrList<Journal> journals(); | 145 | QPtrList<Journal> journals(); |
143 | 146 | ||