-rw-r--r-- | korganizer/koagenda.cpp | 11 | ||||
-rw-r--r-- | korganizer/koagendaview.cpp | 33 | ||||
-rw-r--r-- | korganizer/koeventviewer.cpp | 18 | ||||
-rw-r--r-- | korganizer/kotodoview.cpp | 13 | ||||
-rw-r--r-- | korganizer/kotodoviewitem.cpp | 7 | ||||
-rw-r--r-- | libkcal/kincidenceformatter.cpp | 18 | ||||
-rw-r--r-- | libkcal/todo.cpp | 5 | ||||
-rw-r--r-- | libkcal/todo.h | 2 |
8 files changed, 67 insertions, 40 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index 002234d..7c41cab 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp | |||
@@ -1325,251 +1325,256 @@ void KOAgenda::gridToContents (int gx, int gy, int& x, int& y) | |||
1325 | { | 1325 | { |
1326 | x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX: | 1326 | x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX: |
1327 | gx*mGridSpacingX; | 1327 | gx*mGridSpacingX; |
1328 | y = gy*mGridSpacingY; | 1328 | y = gy*mGridSpacingY; |
1329 | } | 1329 | } |
1330 | 1330 | ||
1331 | 1331 | ||
1332 | /* | 1332 | /* |
1333 | Return Y coordinate corresponding to time. Coordinates are rounded to fit into | 1333 | Return Y coordinate corresponding to time. Coordinates are rounded to fit into |
1334 | the grid. | 1334 | the grid. |
1335 | */ | 1335 | */ |
1336 | int KOAgenda::timeToY(const QTime &time) | 1336 | int KOAgenda::timeToY(const QTime &time) |
1337 | { | 1337 | { |
1338 | int minutesPerCell = 24 * 60 / mRows; | 1338 | int minutesPerCell = 24 * 60 / mRows; |
1339 | int timeMinutes = time.hour() * 60 + time.minute(); | 1339 | int timeMinutes = time.hour() * 60 + time.minute(); |
1340 | int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell; | 1340 | int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell; |
1341 | return Y; | 1341 | return Y; |
1342 | } | 1342 | } |
1343 | 1343 | ||
1344 | 1344 | ||
1345 | /* | 1345 | /* |
1346 | Return time corresponding to cell y coordinate. Coordinates are rounded to | 1346 | Return time corresponding to cell y coordinate. Coordinates are rounded to |
1347 | fit into the grid. | 1347 | fit into the grid. |
1348 | */ | 1348 | */ |
1349 | QTime KOAgenda::gyToTime(int gy) | 1349 | QTime KOAgenda::gyToTime(int gy) |
1350 | { | 1350 | { |
1351 | 1351 | ||
1352 | int secondsPerCell = 24 * 60 * 60/ mRows; | 1352 | int secondsPerCell = 24 * 60 * 60/ mRows; |
1353 | 1353 | ||
1354 | int timeSeconds = secondsPerCell * gy; | 1354 | int timeSeconds = secondsPerCell * gy; |
1355 | 1355 | ||
1356 | QTime time( 0, 0, 0 ); | 1356 | QTime time( 0, 0, 0 ); |
1357 | if ( timeSeconds < 24 * 60 * 60 ) { | 1357 | if ( timeSeconds < 24 * 60 * 60 ) { |
1358 | time = time.addSecs(timeSeconds); | 1358 | time = time.addSecs(timeSeconds); |
1359 | } else { | 1359 | } else { |
1360 | time.setHMS( 23, 59, 59 ); | 1360 | time.setHMS( 23, 59, 59 ); |
1361 | } | 1361 | } |
1362 | 1362 | ||
1363 | return time; | 1363 | return time; |
1364 | } | 1364 | } |
1365 | 1365 | ||
1366 | void KOAgenda::setStartHour(int startHour) | 1366 | void KOAgenda::setStartHour(int startHour) |
1367 | { | 1367 | { |
1368 | int startCell = startHour * mRows / 24; | 1368 | int startCell = startHour * mRows / 24; |
1369 | setContentsPos(0,startCell * gridSpacingY()); | 1369 | setContentsPos(0,startCell * gridSpacingY()); |
1370 | } | 1370 | } |
1371 | void KOAgenda::hideUnused() | 1371 | void KOAgenda::hideUnused() |
1372 | { | 1372 | { |
1373 | // experimental only | 1373 | // experimental only |
1374 | // return; | 1374 | // return; |
1375 | KOAgendaItem *item; | 1375 | KOAgendaItem *item; |
1376 | for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) { | 1376 | for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) { |
1377 | item->hide(); | 1377 | item->hide(); |
1378 | } | 1378 | } |
1379 | } | 1379 | } |
1380 | 1380 | ||
1381 | 1381 | ||
1382 | KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view) | 1382 | KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view) |
1383 | { | 1383 | { |
1384 | 1384 | ||
1385 | KOAgendaItem *fi; | 1385 | KOAgendaItem *fi; |
1386 | for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) { | 1386 | for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) { |
1387 | if ( fi->incidence() == event ) { | 1387 | if ( fi->incidence() == event ) { |
1388 | mUnusedItems.remove(); | 1388 | mUnusedItems.remove(); |
1389 | fi->init( event, qd ); | 1389 | fi->init( event, qd ); |
1390 | return fi; | 1390 | return fi; |
1391 | } | 1391 | } |
1392 | } | 1392 | } |
1393 | fi=mUnusedItems.first(); | 1393 | fi=mUnusedItems.first(); |
1394 | if ( fi ) { | 1394 | if ( fi ) { |
1395 | mUnusedItems.remove(); | 1395 | mUnusedItems.remove(); |
1396 | fi->init( event, qd ); | 1396 | fi->init( event, qd ); |
1397 | return fi; | 1397 | return fi; |
1398 | } | 1398 | } |
1399 | // qDebug("new KOAgendaItem "); | 1399 | // qDebug("new KOAgendaItem "); |
1400 | 1400 | ||
1401 | KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode ); | 1401 | KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode ); |
1402 | agendaItem->installEventFilter(this); | 1402 | agendaItem->installEventFilter(this); |
1403 | addChild(agendaItem,0,0); | 1403 | addChild(agendaItem,0,0); |
1404 | return agendaItem; | 1404 | return agendaItem; |
1405 | } | 1405 | } |
1406 | KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) | 1406 | KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) |
1407 | { | 1407 | { |
1408 | KOAgendaItem *item; | 1408 | KOAgendaItem *item; |
1409 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1409 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1410 | if ( item->incidence() == todo ) { | 1410 | if ( item->incidence() == todo ) { |
1411 | mItems.remove(); | 1411 | mItems.remove(); |
1412 | return item; | 1412 | return item; |
1413 | } | 1413 | } |
1414 | } | 1414 | } |
1415 | return 0; | 1415 | return 0; |
1416 | } | 1416 | } |
1417 | 1417 | ||
1418 | 1418 | ||
1419 | void KOAgenda::updateTodo( Todo * todo, int days, bool remove) | 1419 | void KOAgenda::updateTodo( Todo * todo, int days, bool remove) |
1420 | { | 1420 | { |
1421 | 1421 | // ( todo->hasCompletedDate() && todo->completed().date() == currentDate )|| | |
1422 | KOAgendaItem *item; | 1422 | KOAgendaItem *item; |
1423 | item = getItemForTodo ( todo ); | 1423 | item = getItemForTodo ( todo ); |
1424 | //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove); | 1424 | //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove); |
1425 | if ( item ) { | 1425 | if ( item ) { |
1426 | blockSignals( true ); | 1426 | blockSignals( true ); |
1427 | //qDebug("item found "); | 1427 | //qDebug("item found "); |
1428 | item->hide(); | 1428 | item->hide(); |
1429 | item->setCellX(-2, -1 ); | 1429 | item->setCellX(-2, -1 ); |
1430 | item->select(false); | 1430 | item->select(false); |
1431 | mUnusedItems.append( item ); | 1431 | mUnusedItems.append( item ); |
1432 | mItems.remove( item ); | 1432 | mItems.remove( item ); |
1433 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); | 1433 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); |
1434 | KOAgendaItem *itemit; | 1434 | KOAgendaItem *itemit; |
1435 | //globalFlagBlockAgendaItemPaint = 1; | 1435 | //globalFlagBlockAgendaItemPaint = 1; |
1436 | for ( itemit=oldconflictItems.first(); itemit != 0; | 1436 | for ( itemit=oldconflictItems.first(); itemit != 0; |
1437 | itemit=oldconflictItems.next() ) { | 1437 | itemit=oldconflictItems.next() ) { |
1438 | if ( itemit != item ) | 1438 | if ( itemit != item ) |
1439 | placeSubCells(itemit); | 1439 | placeSubCells(itemit); |
1440 | } | 1440 | } |
1441 | qApp->processEvents(); | 1441 | qApp->processEvents(); |
1442 | //globalFlagBlockAgendaItemPaint = 0; | 1442 | //globalFlagBlockAgendaItemPaint = 0; |
1443 | for ( itemit=oldconflictItems.first(); itemit != 0; | 1443 | for ( itemit=oldconflictItems.first(); itemit != 0; |
1444 | itemit=oldconflictItems.next() ) { | 1444 | itemit=oldconflictItems.next() ) { |
1445 | globalFlagBlockAgendaItemUpdate = 0; | 1445 | globalFlagBlockAgendaItemUpdate = 0; |
1446 | if ( itemit != item ) | 1446 | if ( itemit != item ) |
1447 | itemit->repaintMe(); | 1447 | itemit->repaintMe(); |
1448 | globalFlagBlockAgendaItemUpdate = 1; | 1448 | globalFlagBlockAgendaItemUpdate = 1; |
1449 | itemit->repaint(); | 1449 | itemit->repaint(); |
1450 | } | 1450 | } |
1451 | blockSignals( false ); | 1451 | blockSignals( false ); |
1452 | } | 1452 | } |
1453 | if ( remove ) { | 1453 | if ( remove ) { |
1454 | //qDebug("remove****************************************** "); | 1454 | //qDebug("remove****************************************** "); |
1455 | return; | 1455 | return; |
1456 | } | 1456 | } |
1457 | //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ "); | 1457 | //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ "); |
1458 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < QDate::currentDate())&& ( KOPrefs::instance()->mShowTodoInAgenda ); | 1458 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < QDate::currentDate())&& ( KOPrefs::instance()->mShowTodoInAgenda ); |
1459 | QDate currentDate; | 1459 | QDate currentDate; |
1460 | QDateTime dt; | ||
1461 | if ( todo->hasCompletedDate() ) | ||
1462 | dt = todo->completed(); | ||
1463 | else | ||
1464 | dt = todo->dtDue(); | ||
1460 | if ( overdue ) { | 1465 | if ( overdue ) { |
1461 | currentDate = QDate::currentDate(); | 1466 | currentDate = QDate::currentDate(); |
1462 | days += todo->dtDue().date().daysTo( currentDate ); | 1467 | days += todo->dtDue().date().daysTo( currentDate ); |
1463 | } | 1468 | } |
1464 | else | 1469 | else |
1465 | currentDate = todo->dtDue().date(); | 1470 | currentDate = dt.date(); |
1466 | 1471 | ||
1467 | if ( todo->doesFloat() || overdue ) { | 1472 | if ( todo->doesFloat() || overdue ) { |
1468 | if ( ! mAllDayMode ) return; | 1473 | if ( ! mAllDayMode ) return; |
1469 | // aldayagenda | 1474 | // aldayagenda |
1470 | globalFlagBlockAgendaItemPaint = 1; | 1475 | globalFlagBlockAgendaItemPaint = 1; |
1471 | item = insertAllDayItem(todo, currentDate,days, days); | 1476 | item = insertAllDayItem(todo, currentDate,days, days); |
1472 | item->show(); | 1477 | item->show(); |
1473 | 1478 | ||
1474 | } | 1479 | } |
1475 | else { | 1480 | else { |
1476 | if ( mAllDayMode ) return; | 1481 | if ( mAllDayMode ) return; |
1477 | // mAgenda | 1482 | // mAgenda |
1478 | globalFlagBlockAgendaItemPaint = 1; | 1483 | globalFlagBlockAgendaItemPaint = 1; |
1479 | int endY = timeToY(todo->dtDue().time()) - 1; | 1484 | int endY = timeToY(dt.time()) - 1; |
1480 | int hi = 12/KOPrefs::instance()->mHourSize; | 1485 | int hi = 12/KOPrefs::instance()->mHourSize; |
1481 | int startY = endY - 1-hi; | 1486 | int startY = endY - 1-hi; |
1482 | item = insertItem(todo,currentDate,days,startY,endY); | 1487 | item = insertItem(todo,currentDate,days,startY,endY); |
1483 | item->show(); | 1488 | item->show(); |
1484 | } | 1489 | } |
1485 | qApp->processEvents(); | 1490 | qApp->processEvents(); |
1486 | globalFlagBlockAgendaItemPaint = 0; | 1491 | globalFlagBlockAgendaItemPaint = 0; |
1487 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); | 1492 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); |
1488 | KOAgendaItem *itemit; | 1493 | KOAgendaItem *itemit; |
1489 | for ( itemit=oldconflictItems.first(); itemit != 0; | 1494 | for ( itemit=oldconflictItems.first(); itemit != 0; |
1490 | itemit=oldconflictItems.next() ) { | 1495 | itemit=oldconflictItems.next() ) { |
1491 | globalFlagBlockAgendaItemUpdate = 0; | 1496 | globalFlagBlockAgendaItemUpdate = 0; |
1492 | itemit->repaintMe(); | 1497 | itemit->repaintMe(); |
1493 | globalFlagBlockAgendaItemUpdate = 1; | 1498 | globalFlagBlockAgendaItemUpdate = 1; |
1494 | itemit->repaint(); | 1499 | itemit->repaint(); |
1495 | } | 1500 | } |
1496 | globalFlagBlockAgendaItemUpdate = 0; | 1501 | globalFlagBlockAgendaItemUpdate = 0; |
1497 | item->repaintMe(); | 1502 | item->repaintMe(); |
1498 | globalFlagBlockAgendaItemUpdate = 1; | 1503 | globalFlagBlockAgendaItemUpdate = 1; |
1499 | item->repaint(); | 1504 | item->repaint(); |
1500 | } | 1505 | } |
1501 | /* | 1506 | /* |
1502 | Insert KOAgendaItem into agenda. | 1507 | Insert KOAgendaItem into agenda. |
1503 | */ | 1508 | */ |
1504 | KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom) | 1509 | KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom) |
1505 | { | 1510 | { |
1506 | //kdDebug() << "KOAgenda::insertItem:" << event->summary() << "-" << qd.toString() << " ;top, bottom:" << YTop << "," << YBottom << endl; | 1511 | //kdDebug() << "KOAgenda::insertItem:" << event->summary() << "-" << qd.toString() << " ;top, bottom:" << YTop << "," << YBottom << endl; |
1507 | 1512 | ||
1508 | if (mAllDayMode) { | 1513 | if (mAllDayMode) { |
1509 | kdDebug() << "KOAgenda: calling insertItem in all-day mode is illegal." << endl; | 1514 | kdDebug() << "KOAgenda: calling insertItem in all-day mode is illegal." << endl; |
1510 | return 0; | 1515 | return 0; |
1511 | } | 1516 | } |
1512 | 1517 | ||
1513 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); | 1518 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); |
1514 | //agendaItem->setFrameStyle(WinPanel|Raised); | 1519 | //agendaItem->setFrameStyle(WinPanel|Raised); |
1515 | 1520 | ||
1516 | int YSize = YBottom - YTop + 1; | 1521 | int YSize = YBottom - YTop + 1; |
1517 | if (YSize < 0) { | 1522 | if (YSize < 0) { |
1518 | kdDebug() << "KOAgenda::insertItem(): Text: " << agendaItem->text() << " YSize<0" << endl; | 1523 | kdDebug() << "KOAgenda::insertItem(): Text: " << agendaItem->text() << " YSize<0" << endl; |
1519 | YSize = 1; | 1524 | YSize = 1; |
1520 | } | 1525 | } |
1521 | int iheight = mGridSpacingY * YSize; | 1526 | int iheight = mGridSpacingY * YSize; |
1522 | 1527 | ||
1523 | agendaItem->resize(mGridSpacingX,iheight ); | 1528 | agendaItem->resize(mGridSpacingX,iheight ); |
1524 | agendaItem->setCellXY(X,YTop,YBottom); | 1529 | agendaItem->setCellXY(X,YTop,YBottom); |
1525 | agendaItem->setCellXWidth(X); | 1530 | agendaItem->setCellXWidth(X); |
1526 | 1531 | ||
1527 | //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY); | 1532 | //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY); |
1528 | mItems.append(agendaItem); | 1533 | mItems.append(agendaItem); |
1529 | 1534 | ||
1530 | placeSubCells(agendaItem); | 1535 | placeSubCells(agendaItem); |
1531 | 1536 | ||
1532 | //agendaItem->show(); | 1537 | //agendaItem->show(); |
1533 | 1538 | ||
1534 | marcus_bains(); | 1539 | marcus_bains(); |
1535 | 1540 | ||
1536 | return agendaItem; | 1541 | return agendaItem; |
1537 | } | 1542 | } |
1538 | 1543 | ||
1539 | 1544 | ||
1540 | /* | 1545 | /* |
1541 | Insert all-day KOAgendaItem into agenda. | 1546 | Insert all-day KOAgendaItem into agenda. |
1542 | */ | 1547 | */ |
1543 | KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd) | 1548 | KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd) |
1544 | { | 1549 | { |
1545 | if (!mAllDayMode) { | 1550 | if (!mAllDayMode) { |
1546 | return 0; | 1551 | return 0; |
1547 | } | 1552 | } |
1548 | 1553 | ||
1549 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); | 1554 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); |
1550 | 1555 | ||
1551 | agendaItem->setCellXY(XBegin,0,0); | 1556 | agendaItem->setCellXY(XBegin,0,0); |
1552 | agendaItem->setCellXWidth(XEnd); | 1557 | agendaItem->setCellXWidth(XEnd); |
1553 | agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY); | 1558 | agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY); |
1554 | 1559 | ||
1555 | //addChild(agendaItem,XBegin*mGridSpacingX,0); | 1560 | //addChild(agendaItem,XBegin*mGridSpacingX,0); |
1556 | mItems.append(agendaItem); | 1561 | mItems.append(agendaItem); |
1557 | 1562 | ||
1558 | placeSubCells(agendaItem); | 1563 | placeSubCells(agendaItem); |
1559 | 1564 | ||
1560 | //agendaItem->show(); | 1565 | //agendaItem->show(); |
1561 | 1566 | ||
1562 | return agendaItem; | 1567 | return agendaItem; |
1563 | } | 1568 | } |
1564 | 1569 | ||
1565 | 1570 | ||
1566 | void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, | 1571 | void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, |
1567 | int YTop,int YBottom) | 1572 | int YTop,int YBottom) |
1568 | { | 1573 | { |
1569 | if (mAllDayMode) { | 1574 | if (mAllDayMode) { |
1570 | ; | 1575 | ; |
1571 | return; | 1576 | return; |
1572 | } | 1577 | } |
1573 | 1578 | ||
1574 | int cellX,cellYTop,cellYBottom; | 1579 | int cellX,cellYTop,cellYBottom; |
1575 | QString newtext; | 1580 | QString newtext; |
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index 1864e22..bbc43e4 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp | |||
@@ -857,400 +857,405 @@ void KOAgendaView::updateView() | |||
857 | // kdDebug() << "KOAgendaView::updateView()" << endl; | 857 | // kdDebug() << "KOAgendaView::updateView()" << endl; |
858 | fillAgenda(); | 858 | fillAgenda(); |
859 | 859 | ||
860 | } | 860 | } |
861 | 861 | ||
862 | 862 | ||
863 | /* | 863 | /* |
864 | Update configuration settings for the agenda view. This method is not | 864 | Update configuration settings for the agenda view. This method is not |
865 | complete. | 865 | complete. |
866 | */ | 866 | */ |
867 | void KOAgendaView::updateConfig() | 867 | void KOAgendaView::updateConfig() |
868 | { | 868 | { |
869 | if ( mBlockUpdating ) | 869 | if ( mBlockUpdating ) |
870 | return; | 870 | return; |
871 | // kdDebug() << "KOAgendaView::updateConfig()" << endl; | 871 | // kdDebug() << "KOAgendaView::updateConfig()" << endl; |
872 | 872 | ||
873 | // update config for children | 873 | // update config for children |
874 | mTimeLabels->updateConfig(); | 874 | mTimeLabels->updateConfig(); |
875 | mAgenda->storePosition(); | 875 | mAgenda->storePosition(); |
876 | mAgenda->updateConfig(); | 876 | mAgenda->updateConfig(); |
877 | mAllDayAgenda->updateConfig(); | 877 | mAllDayAgenda->updateConfig(); |
878 | // widget synchronization | 878 | // widget synchronization |
879 | //TODO: find a better way, maybe signal/slot | 879 | //TODO: find a better way, maybe signal/slot |
880 | mTimeLabels->positionChanged(); | 880 | mTimeLabels->positionChanged(); |
881 | 881 | ||
882 | // for some reason, this needs to be called explicitly | 882 | // for some reason, this needs to be called explicitly |
883 | mTimeLabels->repaint(); | 883 | mTimeLabels->repaint(); |
884 | 884 | ||
885 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); | 885 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); |
886 | 886 | ||
887 | // ToolTips displaying summary of events | 887 | // ToolTips displaying summary of events |
888 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() | 888 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() |
889 | ->mEnableToolTips); | 889 | ->mEnableToolTips); |
890 | 890 | ||
891 | //setHolidayMasks(); | 891 | //setHolidayMasks(); |
892 | 892 | ||
893 | //createDayLabels(); called by via updateView(); | 893 | //createDayLabels(); called by via updateView(); |
894 | mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); | 894 | mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); |
895 | updateView(); | 895 | updateView(); |
896 | mAgenda->restorePosition(); | 896 | mAgenda->restorePosition(); |
897 | } | 897 | } |
898 | 898 | ||
899 | 899 | ||
900 | void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) | 900 | void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) |
901 | { | 901 | { |
902 | // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl; | 902 | // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl; |
903 | //qDebug("KOAgendaView::updateEventDates "); | 903 | //qDebug("KOAgendaView::updateEventDates "); |
904 | QDateTime startDt,endDt; | 904 | QDateTime startDt,endDt; |
905 | QDate startDate; | 905 | QDate startDate; |
906 | int lenInSecs; | 906 | int lenInSecs; |
907 | // if ( type == KOAgenda::RESIZETOP ) | 907 | // if ( type == KOAgenda::RESIZETOP ) |
908 | // qDebug("RESIZETOP "); | 908 | // qDebug("RESIZETOP "); |
909 | // if ( type == KOAgenda::RESIZEBOTTOM ) | 909 | // if ( type == KOAgenda::RESIZEBOTTOM ) |
910 | // qDebug("RESIZEBOTTOM "); | 910 | // qDebug("RESIZEBOTTOM "); |
911 | // if ( type == KOAgenda::MOVE ) | 911 | // if ( type == KOAgenda::MOVE ) |
912 | // qDebug("MOVE "); | 912 | // qDebug("MOVE "); |
913 | if ( item->incidence()->type() == "Event" ) { | 913 | if ( item->incidence()->type() == "Event" ) { |
914 | startDt =item->incidence()->dtStart(); | 914 | startDt =item->incidence()->dtStart(); |
915 | endDt = item->incidence()->dtEnd(); | 915 | endDt = item->incidence()->dtEnd(); |
916 | lenInSecs = startDt.secsTo( endDt ); | 916 | lenInSecs = startDt.secsTo( endDt ); |
917 | } | 917 | } |
918 | 918 | ||
919 | // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); | 919 | // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); |
920 | 920 | ||
921 | if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { | 921 | if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { |
922 | startDate = mSelectedDates[item->mLastMoveXPos]; | 922 | startDate = mSelectedDates[item->mLastMoveXPos]; |
923 | } else { | 923 | } else { |
924 | if (item->cellX() < 0) { | 924 | if (item->cellX() < 0) { |
925 | startDate = (mSelectedDates.first()).addDays(item->cellX()); | 925 | startDate = (mSelectedDates.first()).addDays(item->cellX()); |
926 | } else { | 926 | } else { |
927 | startDate = mSelectedDates[item->cellX()]; | 927 | startDate = mSelectedDates[item->cellX()]; |
928 | } | 928 | } |
929 | } | 929 | } |
930 | startDt.setDate(startDate); | 930 | startDt.setDate(startDate); |
931 | 931 | ||
932 | if (item->incidence()->doesFloat()) { | 932 | if (item->incidence()->doesFloat()) { |
933 | endDt.setDate(startDate.addDays(item->cellWidth() - 1)); | 933 | endDt.setDate(startDate.addDays(item->cellWidth() - 1)); |
934 | } else { | 934 | } else { |
935 | if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) | 935 | if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) |
936 | startDt.setTime(mAgenda->gyToTime(item->cellYTop())); | 936 | startDt.setTime(mAgenda->gyToTime(item->cellYTop())); |
937 | if ( item->incidence()->type() == "Event" ) { | 937 | if ( item->incidence()->type() == "Event" ) { |
938 | if ( type == KOAgenda::MOVE ) { | 938 | if ( type == KOAgenda::MOVE ) { |
939 | endDt = startDt.addSecs(lenInSecs); | 939 | endDt = startDt.addSecs(lenInSecs); |
940 | 940 | ||
941 | } else if ( type == KOAgenda::RESIZEBOTTOM ) { | 941 | } else if ( type == KOAgenda::RESIZEBOTTOM ) { |
942 | if (item->lastMultiItem()) { | 942 | if (item->lastMultiItem()) { |
943 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); | 943 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); |
944 | endDt.setDate(startDate. | 944 | endDt.setDate(startDate. |
945 | addDays(item->lastMultiItem()->cellX() - item->cellX())); | 945 | addDays(item->lastMultiItem()->cellX() - item->cellX())); |
946 | } else { | 946 | } else { |
947 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); | 947 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); |
948 | endDt.setDate(startDate); | 948 | endDt.setDate(startDate); |
949 | } | 949 | } |
950 | } | 950 | } |
951 | } else { | 951 | } else { |
952 | // todo | 952 | // todo |
953 | qDebug("tooooodoooooo "); | ||
953 | if (item->lastMultiItem()) { | 954 | if (item->lastMultiItem()) { |
954 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); | 955 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); |
955 | endDt.setDate(startDate. | 956 | endDt.setDate(startDate. |
956 | addDays(item->lastMultiItem()->cellX() - item->cellX())); | 957 | addDays(item->lastMultiItem()->cellX() - item->cellX())); |
957 | } else { | 958 | } else { |
958 | //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); | 959 | //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); |
959 | if ( item->cellYBottom() > 0 ) | 960 | if ( item->cellYBottom() > 0 ) |
960 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); | 961 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); |
961 | else | 962 | else |
962 | endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); | 963 | endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); |
963 | endDt.setDate(startDate); | 964 | endDt.setDate(startDate); |
964 | } | 965 | } |
965 | } | 966 | } |
966 | } | 967 | } |
967 | 968 | ||
968 | 969 | qDebug("to888"); | |
969 | if ( item->incidence()->type() == "Event" ) { | 970 | if ( item->incidence()->type() == "Event" ) { |
970 | item->incidence()->setDtStart(startDt); | 971 | item->incidence()->setDtStart(startDt); |
971 | (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); | 972 | (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); |
972 | } else if ( item->incidence()->type() == "Todo" ) { | 973 | } else if ( item->incidence()->type() == "Todo" ) { |
973 | (static_cast<Todo*>(item->incidence()))->setDtDue(endDt); | 974 | (static_cast<Todo*>(item->incidence()))->setDtDue(endDt); |
974 | } | 975 | } |
975 | //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); | 976 | //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); |
976 | item->incidence()->setRevision(item->incidence()->revision()+1); | 977 | item->incidence()->setRevision(item->incidence()->revision()+1); |
977 | item->setItemDate(startDt.date()); | 978 | item->setItemDate(startDt.date()); |
978 | //item->updateItem(); | 979 | //item->updateItem(); |
979 | if ( item->incidence()->type() == "Todo" ) { | 980 | if ( item->incidence()->type() == "Todo" ) { |
980 | emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); | 981 | emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); |
981 | 982 | ||
982 | } | 983 | } |
983 | else | 984 | else |
984 | emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); | 985 | emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); |
985 | item->updateItem(); | 986 | item->updateItem(); |
986 | } | 987 | } |
987 | 988 | ||
988 | void KOAgendaView::showDates( const QDate &start, const QDate &end ) | 989 | void KOAgendaView::showDates( const QDate &start, const QDate &end ) |
989 | { | 990 | { |
990 | // kdDebug() << "KOAgendaView::selectDates" << endl; | 991 | // kdDebug() << "KOAgendaView::selectDates" << endl; |
991 | 992 | ||
992 | mSelectedDates.clear(); | 993 | mSelectedDates.clear(); |
993 | // qDebug("KOAgendaView::showDates "); | 994 | // qDebug("KOAgendaView::showDates "); |
994 | QDate d = start; | 995 | QDate d = start; |
995 | while (d <= end) { | 996 | while (d <= end) { |
996 | mSelectedDates.append(d); | 997 | mSelectedDates.append(d); |
997 | d = d.addDays( 1 ); | 998 | d = d.addDays( 1 ); |
998 | } | 999 | } |
999 | 1000 | ||
1000 | // and update the view | 1001 | // and update the view |
1001 | fillAgenda(); | 1002 | fillAgenda(); |
1002 | } | 1003 | } |
1003 | 1004 | ||
1004 | 1005 | ||
1005 | void KOAgendaView::showEvents(QPtrList<Event>) | 1006 | void KOAgendaView::showEvents(QPtrList<Event>) |
1006 | { | 1007 | { |
1007 | kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; | 1008 | kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; |
1008 | } | 1009 | } |
1009 | 1010 | ||
1010 | void KOAgendaView::changeEventDisplay(Event *, int) | 1011 | void KOAgendaView::changeEventDisplay(Event *, int) |
1011 | { | 1012 | { |
1012 | // qDebug("KOAgendaView::changeEventDisplay "); | 1013 | // qDebug("KOAgendaView::changeEventDisplay "); |
1013 | // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; | 1014 | // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; |
1014 | // this should be re-written to be MUCH smarter. Right now we | 1015 | // this should be re-written to be MUCH smarter. Right now we |
1015 | // are just playing dumb. | 1016 | // are just playing dumb. |
1016 | fillAgenda(); | 1017 | fillAgenda(); |
1017 | } | 1018 | } |
1018 | 1019 | ||
1019 | void KOAgendaView::fillAgenda(const QDate &) | 1020 | void KOAgendaView::fillAgenda(const QDate &) |
1020 | { | 1021 | { |
1021 | // qDebug("KOAgendaView::fillAgenda "); | 1022 | // qDebug("KOAgendaView::fillAgenda "); |
1022 | fillAgenda(); | 1023 | fillAgenda(); |
1023 | } | 1024 | } |
1024 | 1025 | ||
1025 | void KOAgendaView::fillAgenda() | 1026 | void KOAgendaView::fillAgenda() |
1026 | { | 1027 | { |
1027 | if ( globalFlagBlockStartup ) | 1028 | if ( globalFlagBlockStartup ) |
1028 | return; | 1029 | return; |
1029 | if ( globalFlagBlockAgenda == 1 ) | 1030 | if ( globalFlagBlockAgenda == 1 ) |
1030 | return; | 1031 | return; |
1031 | //if ( globalFlagBlockAgenda == 2 ) | 1032 | //if ( globalFlagBlockAgenda == 2 ) |
1032 | //globalFlagBlockAgenda = 0; | 1033 | //globalFlagBlockAgenda = 0; |
1033 | // globalFlagBlockPainting = false; | 1034 | // globalFlagBlockPainting = false; |
1034 | if ( globalFlagBlockAgenda == 0 ) | 1035 | if ( globalFlagBlockAgenda == 0 ) |
1035 | globalFlagBlockAgenda = 1; | 1036 | globalFlagBlockAgenda = 1; |
1036 | // clearView(); | 1037 | // clearView(); |
1037 | //qDebug("fillAgenda()++++ "); | 1038 | //qDebug("fillAgenda()++++ "); |
1038 | globalFlagBlockAgendaItemPaint = 1; | 1039 | globalFlagBlockAgendaItemPaint = 1; |
1039 | mAllDayAgenda->changeColumns(mSelectedDates.count()); | 1040 | mAllDayAgenda->changeColumns(mSelectedDates.count()); |
1040 | mAgenda->changeColumns(mSelectedDates.count()); | 1041 | mAgenda->changeColumns(mSelectedDates.count()); |
1041 | qApp->processEvents(); | 1042 | qApp->processEvents(); |
1042 | mEventIndicatorTop->changeColumns(mSelectedDates.count()); | 1043 | mEventIndicatorTop->changeColumns(mSelectedDates.count()); |
1043 | mEventIndicatorBottom->changeColumns(mSelectedDates.count()); | 1044 | mEventIndicatorBottom->changeColumns(mSelectedDates.count()); |
1044 | setHolidayMasks(); | 1045 | setHolidayMasks(); |
1045 | 1046 | ||
1046 | //mAgenda->hideUnused(); | 1047 | //mAgenda->hideUnused(); |
1047 | //mAllDayAgenda->hideUnused(); | 1048 | //mAllDayAgenda->hideUnused(); |
1048 | 1049 | ||
1049 | // mAgenda->blockNextRepaint( false ); | 1050 | // mAgenda->blockNextRepaint( false ); |
1050 | // mAgenda->viewport()->repaint(); | 1051 | // mAgenda->viewport()->repaint(); |
1051 | // mAgenda->blockNextRepaint( true ); | 1052 | // mAgenda->blockNextRepaint( true ); |
1052 | mMinY.resize(mSelectedDates.count()); | 1053 | mMinY.resize(mSelectedDates.count()); |
1053 | mMaxY.resize(mSelectedDates.count()); | 1054 | mMaxY.resize(mSelectedDates.count()); |
1054 | 1055 | ||
1055 | QPtrList<Event> dayEvents; | 1056 | QPtrList<Event> dayEvents; |
1056 | 1057 | ||
1057 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. | 1058 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. |
1058 | // Therefore, get all of them. | 1059 | // Therefore, gtodoset all of them. |
1059 | QPtrList<Todo> todos = calendar()->todos(); | 1060 | QPtrList<Todo> todos = calendar()->todos(); |
1060 | 1061 | ||
1061 | mAgenda->setDateList(mSelectedDates); | 1062 | mAgenda->setDateList(mSelectedDates); |
1062 | 1063 | ||
1063 | QDate today = QDate::currentDate(); | 1064 | QDate today = QDate::currentDate(); |
1064 | 1065 | ||
1065 | DateList::ConstIterator dit; | 1066 | DateList::ConstIterator dit; |
1066 | int curCol = 0; | 1067 | int curCol = 0; |
1067 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { | 1068 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { |
1068 | QDate currentDate = *dit; | 1069 | QDate currentDate = *dit; |
1069 | // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() | 1070 | // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() |
1070 | // << endl; | 1071 | // << endl; |
1071 | 1072 | ||
1072 | dayEvents = calendar()->events(currentDate,true); | 1073 | dayEvents = calendar()->events(currentDate,true); |
1073 | 1074 | ||
1074 | // Default values, which can never be reached | 1075 | // Default values, which can never be reached |
1075 | mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; | 1076 | mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; |
1076 | mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; | 1077 | mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; |
1077 | 1078 | ||
1078 | unsigned int numEvent; | 1079 | unsigned int numEvent; |
1079 | for(numEvent=0;numEvent<dayEvents.count();++numEvent) { | 1080 | for(numEvent=0;numEvent<dayEvents.count();++numEvent) { |
1080 | Event *event = dayEvents.at(numEvent); | 1081 | Event *event = dayEvents.at(numEvent); |
1081 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) | 1082 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) |
1082 | if ( event->uid().left(15) == QString("last-syncEvent-") ) | 1083 | if ( event->uid().left(15) == QString("last-syncEvent-") ) |
1083 | continue; | 1084 | continue; |
1084 | // kdDebug() << " Event: " << event->summary() << endl; | 1085 | // kdDebug() << " Event: " << event->summary() << endl; |
1085 | 1086 | ||
1086 | int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; | 1087 | int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; |
1087 | int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; | 1088 | int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; |
1088 | 1089 | ||
1089 | // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; | 1090 | // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; |
1090 | 1091 | ||
1091 | if (event->doesFloat()) { | 1092 | if (event->doesFloat()) { |
1092 | if (event->recurrence()->doesRecur()) { | 1093 | if (event->recurrence()->doesRecur()) { |
1093 | mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); | 1094 | mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); |
1094 | } else { | 1095 | } else { |
1095 | if (beginX <= 0 && curCol == 0) { | 1096 | if (beginX <= 0 && curCol == 0) { |
1096 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); | 1097 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); |
1097 | } else if (beginX == curCol) { | 1098 | } else if (beginX == curCol) { |
1098 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); | 1099 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); |
1099 | } | 1100 | } |
1100 | } | 1101 | } |
1101 | } else if (event->isMultiDay()) { | 1102 | } else if (event->isMultiDay()) { |
1102 | if ( event->doesRecur () ) { | 1103 | if ( event->doesRecur () ) { |
1103 | QDate dateit = currentDate; | 1104 | QDate dateit = currentDate; |
1104 | int count = 0; | 1105 | int count = 0; |
1105 | int max = event->dtStart().daysTo( event->dtEnd() ) +2; | 1106 | int max = event->dtStart().daysTo( event->dtEnd() ) +2; |
1106 | while (! event->recursOn( dateit ) && count <= max ) { | 1107 | while (! event->recursOn( dateit ) && count <= max ) { |
1107 | ++count; | 1108 | ++count; |
1108 | dateit = dateit.addDays( -1 ); | 1109 | dateit = dateit.addDays( -1 ); |
1109 | } | 1110 | } |
1110 | bool ok; | 1111 | bool ok; |
1111 | QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); | 1112 | QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); |
1112 | if ( ok ) | 1113 | if ( ok ) |
1113 | { | 1114 | { |
1114 | int secs = event->dtStart().secsTo( event->dtEnd() ); | 1115 | int secs = event->dtStart().secsTo( event->dtEnd() ); |
1115 | QDateTime nextOcend =nextOcstart.addSecs( secs ); ; | 1116 | QDateTime nextOcend =nextOcstart.addSecs( secs ); ; |
1116 | beginX = currentDate.daysTo(nextOcstart.date()) + curCol; | 1117 | beginX = currentDate.daysTo(nextOcstart.date()) + curCol; |
1117 | endX = currentDate.daysTo(nextOcend.date()) + curCol; | 1118 | endX = currentDate.daysTo(nextOcend.date()) + curCol; |
1118 | 1119 | ||
1119 | } | 1120 | } |
1120 | } | 1121 | } |
1121 | int startY = mAgenda->timeToY(event->dtStart().time()); | 1122 | int startY = mAgenda->timeToY(event->dtStart().time()); |
1122 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; | 1123 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; |
1123 | //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); | 1124 | //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); |
1124 | if ((beginX <= 0 && curCol == 0) || beginX == curCol) { | 1125 | if ((beginX <= 0 && curCol == 0) || beginX == curCol) { |
1125 | //qDebug("insert!!! "); | 1126 | //qDebug("insert!!! "); |
1126 | mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); | 1127 | mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); |
1127 | } | 1128 | } |
1128 | if (beginX == curCol) { | 1129 | if (beginX == curCol) { |
1129 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); | 1130 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); |
1130 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1131 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1131 | } else if (endX == curCol) { | 1132 | } else if (endX == curCol) { |
1132 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); | 1133 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); |
1133 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1134 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1134 | } else { | 1135 | } else { |
1135 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); | 1136 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); |
1136 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); | 1137 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); |
1137 | } | 1138 | } |
1138 | } else { | 1139 | } else { |
1139 | int startY = mAgenda->timeToY(event->dtStart().time()); | 1140 | int startY = mAgenda->timeToY(event->dtStart().time()); |
1140 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; | 1141 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; |
1141 | if (endY < startY) endY = startY; | 1142 | if (endY < startY) endY = startY; |
1142 | mAgenda->insertItem(event,currentDate,curCol,startY,endY); | 1143 | mAgenda->insertItem(event,currentDate,curCol,startY,endY); |
1143 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1144 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1144 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1145 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1145 | } | 1146 | } |
1146 | } | 1147 | } |
1147 | // ---------- [display Todos -------------- | 1148 | // ---------- [display Todos -------------- |
1148 | unsigned int numTodo; | 1149 | unsigned int numTodo; |
1149 | for (numTodo = 0; numTodo < todos.count(); ++numTodo) { | 1150 | for (numTodo = 0; numTodo < todos.count(); ++numTodo) { |
1150 | Todo *todo = todos.at(numTodo); | 1151 | Todo *todo = todos.at(numTodo); |
1151 | 1152 | ||
1152 | if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date | 1153 | if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date |
1153 | 1154 | ||
1154 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. | 1155 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. |
1155 | // Already completed items can be displayed on their original due date | 1156 | // Already completed items can be displayed on their original due date |
1156 | //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda | 1157 | //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda |
1157 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; | 1158 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; |
1158 | 1159 | bool fillIn = false; | |
1159 | if ( ((todo->dtDue().date() == currentDate) && !overdue) || ( todo->hasCompletedDate() && todo->completed().date() == currentDate )|| | 1160 | if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) |
1160 | ((currentDate == today) && overdue) ) { | 1161 | fillIn = true; |
1162 | if ( ! fillIn && !todo->hasCompletedDate() ) | ||
1163 | fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); | ||
1164 | qDebug("refill todo "); | ||
1165 | if ( fillIn ) { | ||
1161 | if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue | 1166 | if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue |
1162 | if ( KOPrefs::instance()->mShowTodoInAgenda ) | 1167 | if ( KOPrefs::instance()->mShowTodoInAgenda ) |
1163 | mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); | 1168 | mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); |
1164 | } | 1169 | } |
1165 | else { | 1170 | else { |
1166 | QDateTime dt; | 1171 | QDateTime dt; |
1167 | if ( todo->hasCompletedDate() ) | 1172 | if ( todo->hasCompletedDate() ) |
1168 | dt = todo->completed(); | 1173 | dt = todo->completed(); |
1169 | else | 1174 | else |
1170 | dt = todo->dtDue();; | 1175 | dt = todo->dtDue();; |
1171 | 1176 | ||
1172 | 1177 | ||
1173 | int endY = mAgenda->timeToY(dt.time()) - 1; | 1178 | int endY = mAgenda->timeToY(dt.time()) - 1; |
1174 | int hi = (18/KOPrefs::instance()->mHourSize); | 1179 | int hi = (18/KOPrefs::instance()->mHourSize); |
1175 | //qDebug("hei %d ",KOPrefs::instance()->mHourSize); | 1180 | //qDebug("hei %d ",KOPrefs::instance()->mHourSize); |
1176 | int startY = endY -hi; | 1181 | int startY = endY -hi; |
1177 | 1182 | ||
1178 | mAgenda->insertItem(todo,currentDate,curCol,startY,endY); | 1183 | mAgenda->insertItem(todo,currentDate,curCol,startY,endY); |
1179 | 1184 | ||
1180 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1185 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1181 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1186 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1182 | } | 1187 | } |
1183 | } | 1188 | } |
1184 | } | 1189 | } |
1185 | // ---------- display Todos] -------------- | 1190 | // ---------- display Todos] -------------- |
1186 | 1191 | ||
1187 | ++curCol; | 1192 | ++curCol; |
1188 | } | 1193 | } |
1189 | mAgenda->hideUnused(); | 1194 | mAgenda->hideUnused(); |
1190 | mAllDayAgenda->hideUnused(); | 1195 | mAllDayAgenda->hideUnused(); |
1191 | mAgenda->checkScrollBoundaries(); | 1196 | mAgenda->checkScrollBoundaries(); |
1192 | 1197 | ||
1193 | deleteSelectedDateTime(); | 1198 | deleteSelectedDateTime(); |
1194 | 1199 | ||
1195 | createDayLabels(); | 1200 | createDayLabels(); |
1196 | emit incidenceSelected( 0 ); | 1201 | emit incidenceSelected( 0 ); |
1197 | 1202 | ||
1198 | if ( globalFlagBlockAgenda == 2 ) { | 1203 | if ( globalFlagBlockAgenda == 2 ) { |
1199 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) | 1204 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) |
1200 | setStartHour( KOPrefs::instance()->mDayBegins ); | 1205 | setStartHour( KOPrefs::instance()->mDayBegins ); |
1201 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) | 1206 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) |
1202 | setStartHour( QTime::currentTime ().hour() ); | 1207 | setStartHour( QTime::currentTime ().hour() ); |
1203 | // qApp->processEvents(); | 1208 | // qApp->processEvents(); |
1204 | } | 1209 | } |
1205 | qApp->processEvents(); | 1210 | qApp->processEvents(); |
1206 | //qDebug("qApp->processEvents(); END "); | 1211 | //qDebug("qApp->processEvents(); END "); |
1207 | globalFlagBlockAgenda = 0; | 1212 | globalFlagBlockAgenda = 0; |
1208 | 1213 | ||
1209 | // mAgenda->hideUnused(); | 1214 | // mAgenda->hideUnused(); |
1210 | //mAllDayAgenda->hideUnused(); | 1215 | //mAllDayAgenda->hideUnused(); |
1211 | mAllDayAgenda->drawContentsToPainter(); | 1216 | mAllDayAgenda->drawContentsToPainter(); |
1212 | mAgenda->drawContentsToPainter(); | 1217 | mAgenda->drawContentsToPainter(); |
1213 | repaintAgenda(); | 1218 | repaintAgenda(); |
1214 | // mAgenda->finishUpdate(); | 1219 | // mAgenda->finishUpdate(); |
1215 | //mAllDayAgenda->finishUpdate(); | 1220 | //mAllDayAgenda->finishUpdate(); |
1216 | 1221 | ||
1217 | // repaintAgenda(); | 1222 | // repaintAgenda(); |
1218 | //qApp->processEvents(); | 1223 | //qApp->processEvents(); |
1219 | // globalFlagBlockAgenda = 0; | 1224 | // globalFlagBlockAgenda = 0; |
1220 | } | 1225 | } |
1221 | void KOAgendaView::repaintAgenda() | 1226 | void KOAgendaView::repaintAgenda() |
1222 | { | 1227 | { |
1223 | // mAllDayAgenda->drawContentsToPainter(); | 1228 | // mAllDayAgenda->drawContentsToPainter(); |
1224 | // mAllDayAgenda->viewport()->repaint( false ); | 1229 | // mAllDayAgenda->viewport()->repaint( false ); |
1225 | // mAgenda->drawContentsToPainter(); | 1230 | // mAgenda->drawContentsToPainter(); |
1226 | // mAgenda->viewport()->repaint( false ); | 1231 | // mAgenda->viewport()->repaint( false ); |
1227 | // qApp->processEvents(); | 1232 | // qApp->processEvents(); |
1228 | 1233 | ||
1229 | //qDebug("KOAgendaView::repaintAgenda() "); | 1234 | //qDebug("KOAgendaView::repaintAgenda() "); |
1230 | //qApp->processEvents(); | 1235 | //qApp->processEvents(); |
1231 | mAgenda->viewport()->repaint( false ); | 1236 | mAgenda->viewport()->repaint( false ); |
1232 | mAllDayAgenda->viewport()->repaint( false ); | 1237 | mAllDayAgenda->viewport()->repaint( false ); |
1233 | mAgenda->finishUpdate(); | 1238 | mAgenda->finishUpdate(); |
1234 | mAllDayAgenda->finishUpdate(); | 1239 | mAllDayAgenda->finishUpdate(); |
1235 | } | 1240 | } |
1236 | 1241 | ||
1237 | 1242 | ||
1238 | void KOAgendaView::clearView() | 1243 | void KOAgendaView::clearView() |
1239 | { | 1244 | { |
1240 | // kdDebug() << "ClearView" << endl; | 1245 | // kdDebug() << "ClearView" << endl; |
1241 | mAllDayAgenda->clear(); | 1246 | mAllDayAgenda->clear(); |
1242 | mAgenda->clear(); | 1247 | mAgenda->clear(); |
1243 | } | 1248 | } |
1244 | 1249 | ||
1245 | void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 1250 | void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
1246 | const QDate &td) | 1251 | const QDate &td) |
1247 | { | 1252 | { |
1248 | #ifndef KORG_NOPRINTER | 1253 | #ifndef KORG_NOPRINTER |
1249 | if (fd == td) | 1254 | if (fd == td) |
1250 | calPrinter->preview(CalPrinter::Day, fd, td); | 1255 | calPrinter->preview(CalPrinter::Day, fd, td); |
1251 | else | 1256 | else |
1252 | calPrinter->preview(CalPrinter::Week, fd, td); | 1257 | calPrinter->preview(CalPrinter::Week, fd, td); |
1253 | #endif | 1258 | #endif |
1254 | } | 1259 | } |
1255 | 1260 | ||
1256 | // void KOAgendaView::updateMovedTodo() | 1261 | // void KOAgendaView::updateMovedTodo() |
@@ -1410,130 +1415,136 @@ void KOAgendaView::setHolidayMasks() | |||
1410 | #ifndef KORG_NOPLUGINS | 1415 | #ifndef KORG_NOPLUGINS |
1411 | bool showHoliday = KOPrefs::instance()->mExcludeHolidays && | 1416 | bool showHoliday = KOPrefs::instance()->mExcludeHolidays && |
1412 | !KOCore::self()->holiday(date).isEmpty(); | 1417 | !KOCore::self()->holiday(date).isEmpty(); |
1413 | #endif | 1418 | #endif |
1414 | bool showDay = showSaturday || showSunday || showHoliday; | 1419 | bool showDay = showSaturday || showSunday || showHoliday; |
1415 | 1420 | ||
1416 | if (showDay) { | 1421 | if (showDay) { |
1417 | mHolidayMask.at(i) = true; | 1422 | mHolidayMask.at(i) = true; |
1418 | } else { | 1423 | } else { |
1419 | mHolidayMask.at(i) = false; | 1424 | mHolidayMask.at(i) = false; |
1420 | } | 1425 | } |
1421 | } | 1426 | } |
1422 | 1427 | ||
1423 | mAgenda->setHolidayMask(&mHolidayMask); | 1428 | mAgenda->setHolidayMask(&mHolidayMask); |
1424 | mAllDayAgenda->setHolidayMask(&mHolidayMask); | 1429 | mAllDayAgenda->setHolidayMask(&mHolidayMask); |
1425 | } | 1430 | } |
1426 | 1431 | ||
1427 | void KOAgendaView::setContentsPos(int y) | 1432 | void KOAgendaView::setContentsPos(int y) |
1428 | { | 1433 | { |
1429 | mAgenda->setContentsPos(0,y); | 1434 | mAgenda->setContentsPos(0,y); |
1430 | } | 1435 | } |
1431 | 1436 | ||
1432 | void KOAgendaView::setExpandedButton( bool expanded ) | 1437 | void KOAgendaView::setExpandedButton( bool expanded ) |
1433 | { | 1438 | { |
1434 | if ( expanded ) { | 1439 | if ( expanded ) { |
1435 | mExpandButton->setPixmap( mExpandedPixmap ); | 1440 | mExpandButton->setPixmap( mExpandedPixmap ); |
1436 | } else { | 1441 | } else { |
1437 | mExpandButton->setPixmap( mNotExpandedPixmap ); | 1442 | mExpandButton->setPixmap( mNotExpandedPixmap ); |
1438 | } | 1443 | } |
1439 | } | 1444 | } |
1440 | 1445 | ||
1441 | void KOAgendaView::clearSelection() | 1446 | void KOAgendaView::clearSelection() |
1442 | { | 1447 | { |
1443 | mAgenda->deselectItem(); | 1448 | mAgenda->deselectItem(); |
1444 | mAllDayAgenda->deselectItem(); | 1449 | mAllDayAgenda->deselectItem(); |
1445 | } | 1450 | } |
1446 | 1451 | ||
1447 | void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart, | 1452 | void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart, |
1448 | int gxEnd, int gyEnd) | 1453 | int gxEnd, int gyEnd) |
1449 | { | 1454 | { |
1450 | mTimeSpanInAllDay = true; | 1455 | mTimeSpanInAllDay = true; |
1451 | newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd); | 1456 | newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd); |
1452 | } | 1457 | } |
1453 | 1458 | ||
1454 | 1459 | ||
1455 | 1460 | ||
1456 | 1461 | ||
1457 | void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart, | 1462 | void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart, |
1458 | int gxEnd, int gyEnd) | 1463 | int gxEnd, int gyEnd) |
1459 | { | 1464 | { |
1460 | if (!mSelectedDates.count()) return; | 1465 | if (!mSelectedDates.count()) return; |
1461 | 1466 | ||
1462 | QDate dayStart = mSelectedDates[gxStart]; | 1467 | QDate dayStart = mSelectedDates[gxStart]; |
1463 | QDate dayEnd = mSelectedDates[gxEnd]; | 1468 | QDate dayEnd = mSelectedDates[gxEnd]; |
1464 | 1469 | ||
1465 | QTime timeStart = mAgenda->gyToTime(gyStart); | 1470 | QTime timeStart = mAgenda->gyToTime(gyStart); |
1466 | QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); | 1471 | QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); |
1467 | 1472 | ||
1468 | QDateTime dtStart(dayStart,timeStart); | 1473 | QDateTime dtStart(dayStart,timeStart); |
1469 | QDateTime dtEnd(dayEnd,timeEnd); | 1474 | QDateTime dtEnd(dayEnd,timeEnd); |
1470 | 1475 | ||
1471 | mTimeSpanBegin = dtStart; | 1476 | mTimeSpanBegin = dtStart; |
1472 | mTimeSpanEnd = dtEnd; | 1477 | mTimeSpanEnd = dtEnd; |
1473 | 1478 | ||
1474 | } | 1479 | } |
1475 | 1480 | ||
1476 | void KOAgendaView::deleteSelectedDateTime() | 1481 | void KOAgendaView::deleteSelectedDateTime() |
1477 | { | 1482 | { |
1478 | mTimeSpanBegin.setDate(QDate()); | 1483 | mTimeSpanBegin.setDate(QDate()); |
1479 | mTimeSpanEnd.setDate(QDate()); | 1484 | mTimeSpanEnd.setDate(QDate()); |
1480 | mTimeSpanInAllDay = false; | 1485 | mTimeSpanInAllDay = false; |
1481 | } | 1486 | } |
1482 | 1487 | ||
1483 | void KOAgendaView::keyPressEvent ( QKeyEvent * e ) | 1488 | void KOAgendaView::keyPressEvent ( QKeyEvent * e ) |
1484 | { | 1489 | { |
1485 | e->ignore(); | 1490 | e->ignore(); |
1486 | } | 1491 | } |
1487 | 1492 | ||
1488 | void KOAgendaView::scrollOneHourUp() | 1493 | void KOAgendaView::scrollOneHourUp() |
1489 | { | 1494 | { |
1490 | 1495 | ||
1491 | mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 ); | 1496 | mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 ); |
1492 | } | 1497 | } |
1493 | void KOAgendaView::scrollOneHourDown() | 1498 | void KOAgendaView::scrollOneHourDown() |
1494 | { | 1499 | { |
1495 | mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 ); | 1500 | mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 ); |
1496 | } | 1501 | } |
1497 | 1502 | ||
1498 | void KOAgendaView::setStartHour( int h ) | 1503 | void KOAgendaView::setStartHour( int h ) |
1499 | { | 1504 | { |
1500 | mAgenda->setStartHour( h ); | 1505 | mAgenda->setStartHour( h ); |
1501 | 1506 | ||
1502 | } | 1507 | } |
1503 | 1508 | ||
1504 | void KOAgendaView::updateTodo( Todo * t, int ) | 1509 | void KOAgendaView::updateTodo( Todo * t, int ) |
1505 | { | 1510 | { |
1506 | 1511 | ||
1507 | bool remove = false; | 1512 | bool remove = false; |
1508 | bool removeAD = false; | 1513 | bool removeAD = false; |
1509 | if ( ! t->hasDueDate() ) { | 1514 | QDate da; |
1515 | if ( t->hasCompletedDate() ) | ||
1516 | da = t->completed().date(); | ||
1517 | else | ||
1518 | da = t->dtDue().date(); | ||
1519 | if ( ! t->hasDueDate() && !t->hasCompletedDate() ) { | ||
1510 | remove = true; | 1520 | remove = true; |
1511 | removeAD = true; | 1521 | removeAD = true; |
1512 | } | 1522 | } |
1513 | else { | 1523 | else { |
1514 | bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ; | 1524 | bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ; |
1515 | if ( overdue && | 1525 | if ( overdue && |
1516 | QDate::currentDate() >= mSelectedDates.first() && | 1526 | QDate::currentDate() >= mSelectedDates.first() && |
1517 | QDate::currentDate() <= mSelectedDates.last()) { | 1527 | QDate::currentDate() <= mSelectedDates.last()) { |
1518 | removeAD = false; | 1528 | removeAD = false; |
1519 | remove = true; | 1529 | remove = true; |
1520 | } | 1530 | } |
1521 | else { | 1531 | else { |
1522 | if ( t->dtDue().date() < mSelectedDates.first() || | 1532 | |
1523 | t->dtDue().date() > mSelectedDates.last() ) { | 1533 | if ( da < mSelectedDates.first() || |
1534 | da > mSelectedDates.last() ) { | ||
1524 | remove = true; | 1535 | remove = true; |
1525 | removeAD = true; | 1536 | removeAD = true; |
1526 | } else { | 1537 | } else { |
1527 | remove = t->doesFloat(); | 1538 | remove = t->doesFloat() && !t->hasCompletedDate(); |
1528 | removeAD = !remove; | 1539 | removeAD = !remove; |
1529 | } | 1540 | } |
1530 | } | 1541 | } |
1531 | } | 1542 | } |
1532 | int days = mSelectedDates.first().daysTo( t->dtDue().date() ); | 1543 | int days = mSelectedDates.first().daysTo( da ); |
1533 | // qDebug("daysto %d ", days ); | 1544 | // qDebug("daysto %d ", days ); |
1534 | mAgenda->updateTodo( t , days, remove); | 1545 | mAgenda->updateTodo( t , days, remove); |
1535 | if ( KOPrefs::instance()->mShowTodoInAgenda ) | 1546 | if ( KOPrefs::instance()->mShowTodoInAgenda ) |
1536 | mAllDayAgenda->updateTodo( t , days, removeAD); | 1547 | mAllDayAgenda->updateTodo( t , days, removeAD); |
1537 | //qDebug("KOAgendaView::updateTodo( Todo *, int ) "); | 1548 | //qDebug("KOAgendaView::updateTodo( Todo *, int ) "); |
1538 | 1549 | ||
1539 | } | 1550 | } |
diff --git a/korganizer/koeventviewer.cpp b/korganizer/koeventviewer.cpp index 36a2947..7dc1880 100644 --- a/korganizer/koeventviewer.cpp +++ b/korganizer/koeventviewer.cpp | |||
@@ -254,232 +254,234 @@ void KOEventViewer::appendEvent(Event *event, int mode ) | |||
254 | .arg(event->dtEndDateStr(shortDate))); | 254 | .arg(event->dtEndDateStr(shortDate))); |
255 | } else { | 255 | } else { |
256 | mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate ))); | 256 | mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate ))); |
257 | } | 257 | } |
258 | } else { | 258 | } else { |
259 | if (event->isMultiDay()) { | 259 | if (event->isMultiDay()) { |
260 | mText.append(i18n("<p><b>From:</b> %1</p> ") | 260 | mText.append(i18n("<p><b>From:</b> %1</p> ") |
261 | .arg(event->dtStartStr( shortDate))); | 261 | .arg(event->dtStartStr( shortDate))); |
262 | mText.append(i18n("<p><b>To:</b> %1</p>") | 262 | mText.append(i18n("<p><b>To:</b> %1</p>") |
263 | .arg(event->dtEndStr(shortDate))); | 263 | .arg(event->dtEndStr(shortDate))); |
264 | } else { | 264 | } else { |
265 | mText.append(i18n("<p><b>On:</b> %1</p> ") | 265 | mText.append(i18n("<p><b>On:</b> %1</p> ") |
266 | .arg(event->dtStartDateStr( shortDate ))); | 266 | .arg(event->dtStartDateStr( shortDate ))); |
267 | mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") | 267 | mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") |
268 | .arg(event->dtStartTimeStr()) | 268 | .arg(event->dtStartTimeStr()) |
269 | .arg(event->dtEndTimeStr())); | 269 | .arg(event->dtEndTimeStr())); |
270 | } | 270 | } |
271 | } | 271 | } |
272 | 272 | ||
273 | if (event->recurrence()->doesRecur()) { | 273 | if (event->recurrence()->doesRecur()) { |
274 | 274 | ||
275 | QString recurText = event->recurrence()->recurrenceText(); | 275 | QString recurText = event->recurrence()->recurrenceText(); |
276 | addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); | 276 | addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); |
277 | bool last; | 277 | bool last; |
278 | QDate start = QDate::currentDate(); | 278 | QDate start = QDate::currentDate(); |
279 | QDate next; | 279 | QDate next; |
280 | next = event->recurrence()->getPreviousDate( start , &last ); | 280 | next = event->recurrence()->getPreviousDate( start , &last ); |
281 | if ( !last ) { | 281 | if ( !last ) { |
282 | next = event->recurrence()->getNextDate( start.addDays( - 1 ) ); | 282 | next = event->recurrence()->getNextDate( start.addDays( - 1 ) ); |
283 | addTag("p",i18n("<b>Next recurrence is on:</b>") ); | 283 | addTag("p",i18n("<b>Next recurrence is on:</b>") ); |
284 | addTag("p", KGlobal::locale()->formatDate( next, shortDate )); | 284 | addTag("p", KGlobal::locale()->formatDate( next, shortDate )); |
285 | QDateTime nextdt = QDateTime( next, event->dtStart().time()); | 285 | QDateTime nextdt = QDateTime( next, event->dtStart().time()); |
286 | mMailSubject += i18n(" - " )+ KGlobal::locale()->formatDateTime( nextdt, true ); | 286 | mMailSubject += i18n(" - " )+ KGlobal::locale()->formatDateTime( nextdt, true ); |
287 | 287 | ||
288 | } else { | 288 | } else { |
289 | addTag("p",i18n("<b>Last recurrence was on:</b>") ); | 289 | addTag("p",i18n("<b>Last recurrence was on:</b>") ); |
290 | addTag("p", KGlobal::locale()->formatDate( next, shortDate )); | 290 | addTag("p", KGlobal::locale()->formatDate( next, shortDate )); |
291 | } | 291 | } |
292 | } else { | 292 | } else { |
293 | mMailSubject += i18n(" - " )+event->dtStartStr( true ); | 293 | mMailSubject += i18n(" - " )+event->dtStartStr( true ); |
294 | 294 | ||
295 | } | 295 | } |
296 | 296 | ||
297 | 297 | ||
298 | if (event->isAlarmEnabled()) { | 298 | if (event->isAlarmEnabled()) { |
299 | Alarm *alarm =event->alarms().first() ; | 299 | Alarm *alarm =event->alarms().first() ; |
300 | QDateTime t = alarm->time(); | 300 | QDateTime t = alarm->time(); |
301 | int min = t.secsTo( event->dtStart() )/60; | 301 | int min = t.secsTo( event->dtStart() )/60; |
302 | QString s =i18n("( %1 min before )").arg( min ); | 302 | QString s =i18n("( %1 min before )").arg( min ); |
303 | addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); | 303 | addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); |
304 | addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); | 304 | addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); |
305 | //addTag("p",s); | 305 | //addTag("p",s); |
306 | } | 306 | } |
307 | 307 | ||
308 | addTag("b",i18n("Access: ")); | 308 | addTag("b",i18n("Access: ")); |
309 | mText.append(event->secrecyStr()+"<br>"); | 309 | mText.append(event->secrecyStr()+"<br>"); |
310 | if (!event->description().isEmpty()) { | 310 | if (!event->description().isEmpty()) { |
311 | addTag("p",i18n("<b>Details: </b>")); | 311 | addTag("p",i18n("<b>Details: </b>")); |
312 | addTag("p",event->description()); | 312 | addTag("p",event->description()); |
313 | } | 313 | } |
314 | 314 | ||
315 | formatCategories(event); | 315 | formatCategories(event); |
316 | 316 | ||
317 | formatReadOnly(event); | 317 | formatReadOnly(event); |
318 | formatAttendees(event); | 318 | formatAttendees(event); |
319 | 319 | ||
320 | setText(mText); | 320 | setText(mText); |
321 | //QWhatsThis::add(this,mText); | 321 | //QWhatsThis::add(this,mText); |
322 | 322 | ||
323 | } | 323 | } |
324 | 324 | ||
325 | void KOEventViewer::appendTodo(Todo *event, int mode ) | 325 | void KOEventViewer::appendTodo(Todo *event, int mode ) |
326 | { | 326 | { |
327 | mMailSubject = ""; | 327 | mMailSubject = ""; |
328 | mCurrentIncidence = event; | 328 | mCurrentIncidence = event; |
329 | topLevelWidget()->setCaption(i18n("Todo Viewer")); | 329 | topLevelWidget()->setCaption(i18n("Todo Viewer")); |
330 | bool shortDate = KOPrefs::instance()->mShortDateInViewer; | 330 | bool shortDate = KOPrefs::instance()->mShortDateInViewer; |
331 | if (mode == 0 ) | 331 | if (mode == 0 ) |
332 | addTag("h2",event->summary()); | 332 | addTag("h2",event->summary()); |
333 | else { | 333 | else { |
334 | if ( mColorMode == 1 ) { | 334 | if ( mColorMode == 1 ) { |
335 | mText +="<font color=\"#00A000\">"; | 335 | mText +="<font color=\"#00A000\">"; |
336 | } | 336 | } |
337 | if ( mColorMode == 2 ) { | 337 | if ( mColorMode == 2 ) { |
338 | mText +="<font color=\"#B00000\">"; | 338 | mText +="<font color=\"#B00000\">"; |
339 | } | 339 | } |
340 | if ( mode == 1 ) { | 340 | if ( mode == 1 ) { |
341 | addTag("h2",i18n( "Local: " ) +event->summary()); | 341 | addTag("h2",i18n( "Local: " ) +event->summary()); |
342 | } else { | 342 | } else { |
343 | addTag("h2",i18n( "Remote: " ) +event->summary()); | 343 | addTag("h2",i18n( "Remote: " ) +event->summary()); |
344 | } | 344 | } |
345 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); | 345 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); |
346 | if ( mColorMode ) | 346 | if ( mColorMode ) |
347 | mText += "</font>"; | 347 | mText += "</font>"; |
348 | } | 348 | } |
349 | mMailSubject += i18n( "Todo " )+ event->summary(); | 349 | mMailSubject += i18n( "Todo " )+ event->summary(); |
350 | |||
351 | if ( event->percentComplete() == 100 && event->hasCompletedDate() ) { | ||
352 | mText +="<font color=\"#B00000\">"; | ||
353 | addTag("i", i18n("<p><i>Completed on %1</i></p>").arg( event->completedStr(KOPrefs::instance()->mShortDateInViewer) ) ); | ||
354 | mText += "</font>"; | ||
355 | } else { | ||
356 | mText.append(i18n("<p><i>%1 % completed</i></p>") | ||
357 | .arg(event->percentComplete())); | ||
358 | } | ||
359 | |||
350 | if (event->cancelled ()) { | 360 | if (event->cancelled ()) { |
351 | mText +="<font color=\"#B00000\">"; | 361 | mText +="<font color=\"#B00000\">"; |
352 | addTag("i",i18n("This todo has been cancelled!")); | 362 | addTag("i",i18n("This todo has been cancelled!")); |
353 | mText.append("<br>"); | 363 | mText.append("<br>"); |
354 | mText += "</font>"; | 364 | mText += "</font>"; |
355 | mMailSubject += i18n("(cancelled)"); | 365 | mMailSubject += i18n("(cancelled)"); |
356 | } | 366 | } |
357 | 367 | ||
358 | if (!event->location().isEmpty()) { | 368 | if (!event->location().isEmpty()) { |
359 | addTag("b",i18n("Location: ")); | 369 | addTag("b",i18n("Location: ")); |
360 | mText.append(event->location()+"<br>"); | 370 | mText.append(event->location()+"<br>"); |
361 | mMailSubject += i18n(" at ") + event->location(); | 371 | mMailSubject += i18n(" at ") + event->location(); |
362 | } | 372 | } |
363 | if (event->hasStartDate()) { | 373 | if (event->hasStartDate()) { |
364 | mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(KOPrefs::instance()->mShortDateInViewer))); | 374 | mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(KOPrefs::instance()->mShortDateInViewer))); |
365 | } | 375 | } |
366 | if (event->hasDueDate()) { | 376 | if (event->hasDueDate()) { |
367 | mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer))); | 377 | mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer))); |
368 | mMailSubject += i18n(" - " )+event->dtDueStr( true ); | 378 | mMailSubject += i18n(" - " )+event->dtDueStr( true ); |
369 | } | 379 | } |
370 | addTag("b",i18n("Access: ")); | 380 | addTag("b",i18n("Access: ")); |
371 | mText.append(event->secrecyStr()+"<br>"); | 381 | mText.append(event->secrecyStr()+"<br>"); |
372 | if (!event->description().isEmpty()) { | 382 | if (!event->description().isEmpty()) { |
373 | addTag("p",i18n("<b>Details: </b>")); | 383 | addTag("p",i18n("<b>Details: </b>")); |
374 | addTag("p",event->description()); | 384 | addTag("p",event->description()); |
375 | } | 385 | } |
376 | 386 | ||
377 | formatCategories(event); | 387 | formatCategories(event); |
378 | 388 | ||
379 | mText.append(i18n("<p><b>Priority:</b> %2</p>") | 389 | mText.append(i18n("<p><b>Priority:</b> %2</p>") |
380 | .arg(QString::number(event->priority()))); | 390 | .arg(QString::number(event->priority()))); |
381 | 391 | ||
382 | if ( event->percentComplete() == 100 && event->hasCompletedDate() ) { | ||
383 | mText.append(i18n("<p><i>Completed on %1</i></p>") | ||
384 | .arg( event->completedStr() )); | ||
385 | } else { | ||
386 | mText.append(i18n("<p><i>%1 % completed</i></p>") | ||
387 | .arg(event->percentComplete())); | ||
388 | } | ||
389 | |||
390 | formatReadOnly(event); | 392 | formatReadOnly(event); |
391 | formatAttendees(event); | 393 | formatAttendees(event); |
392 | if ( event->relatedTo() ) { | 394 | if ( event->relatedTo() ) { |
393 | addTag("b",i18n("Parent todo: ")); | 395 | addTag("b",i18n("Parent todo: ")); |
394 | mText.append(event->relatedTo()->summary()+" [" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] <br>"); | 396 | mText.append(event->relatedTo()->summary()+" [" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] <br>"); |
395 | } | 397 | } |
396 | QPtrList<Incidence> Relations = event->relations(); | 398 | QPtrList<Incidence> Relations = event->relations(); |
397 | Incidence *to; | 399 | Incidence *to; |
398 | if ( Relations.first() ) | 400 | if ( Relations.first() ) |
399 | addTag("b",i18n("Sub todos:<br>")); | 401 | addTag("b",i18n("Sub todos:<br>")); |
400 | for (to=Relations.first();to;to=Relations.next()) { | 402 | for (to=Relations.first();to;to=Relations.next()) { |
401 | mText.append( to->summary()+" [" +QString::number(to->priority()) + "/" + QString::number(((Todo*)to)->percentComplete())+"%]<br>"); | 403 | mText.append( to->summary()+" [" +QString::number(to->priority()) + "/" + QString::number(((Todo*)to)->percentComplete())+"%]<br>"); |
402 | 404 | ||
403 | } | 405 | } |
404 | setText(mText); | 406 | setText(mText); |
405 | } | 407 | } |
406 | 408 | ||
407 | void KOEventViewer::formatCategories(Incidence *event) | 409 | void KOEventViewer::formatCategories(Incidence *event) |
408 | { | 410 | { |
409 | if (!event->categoriesStr().isEmpty()) { | 411 | if (!event->categoriesStr().isEmpty()) { |
410 | if (event->categories().count() == 1) { | 412 | if (event->categories().count() == 1) { |
411 | addTag("h3",i18n("Category")); | 413 | addTag("h3",i18n("Category")); |
412 | } else { | 414 | } else { |
413 | addTag("h3",i18n("Categories")); | 415 | addTag("h3",i18n("Categories")); |
414 | } | 416 | } |
415 | addTag("p",event->categoriesStr()); | 417 | addTag("p",event->categoriesStr()); |
416 | } | 418 | } |
417 | } | 419 | } |
418 | void KOEventViewer::formatAttendees(Incidence *event) | 420 | void KOEventViewer::formatAttendees(Incidence *event) |
419 | { | 421 | { |
420 | QPtrList<Attendee> attendees = event->attendees(); | 422 | QPtrList<Attendee> attendees = event->attendees(); |
421 | if (attendees.count()) { | 423 | if (attendees.count()) { |
422 | 424 | ||
423 | 425 | ||
424 | QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); | 426 | QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); |
425 | QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small); | 427 | QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small); |
426 | addTag("h3",i18n("Organizer")); | 428 | addTag("h3",i18n("Organizer")); |
427 | mText.append("<ul><li>"); | 429 | mText.append("<ul><li>"); |
428 | #ifndef KORG_NOKABC | 430 | #ifndef KORG_NOKABC |
429 | 431 | ||
430 | #ifdef DESKTOP_VERSION | 432 | #ifdef DESKTOP_VERSION |
431 | KABC::AddressBook *add_book = KABC::StdAddressBook::self(); | 433 | KABC::AddressBook *add_book = KABC::StdAddressBook::self(); |
432 | KABC::Addressee::List addressList; | 434 | KABC::Addressee::List addressList; |
433 | addressList = add_book->findByEmail(event->organizer()); | 435 | addressList = add_book->findByEmail(event->organizer()); |
434 | KABC::Addressee o = addressList.first(); | 436 | KABC::Addressee o = addressList.first(); |
435 | if (!o.isEmpty() && addressList.size()<2) { | 437 | if (!o.isEmpty() && addressList.size()<2) { |
436 | mText += "<a href=\"uid:" + o.uid() + "\">"; | 438 | mText += "<a href=\"uid:" + o.uid() + "\">"; |
437 | mText += o.formattedName(); | 439 | mText += o.formattedName(); |
438 | mText += "</a>\n"; | 440 | mText += "</a>\n"; |
439 | } else { | 441 | } else { |
440 | mText.append(event->organizer()); | 442 | mText.append(event->organizer()); |
441 | } | 443 | } |
442 | #else //DESKTOP_VERSION | 444 | #else //DESKTOP_VERSION |
443 | mText += "<a href=\"uid:organizer\">"; | 445 | mText += "<a href=\"uid:organizer\">"; |
444 | mText += event->organizer(); | 446 | mText += event->organizer(); |
445 | mText += "</a>\n"; | 447 | mText += "</a>\n"; |
446 | #endif //DESKTOP_VERSION | 448 | #endif //DESKTOP_VERSION |
447 | 449 | ||
448 | 450 | ||
449 | #else | 451 | #else |
450 | mText.append(event->organizer()); | 452 | mText.append(event->organizer()); |
451 | #endif | 453 | #endif |
452 | 454 | ||
453 | if (iconPath) { | 455 | if (iconPath) { |
454 | mText += " <a href=\"mailto:" + event->organizer() + "\">"; | 456 | mText += " <a href=\"mailto:" + event->organizer() + "\">"; |
455 | mText += "<IMG src=\"" + iconPath + "\">"; | 457 | mText += "<IMG src=\"" + iconPath + "\">"; |
456 | mText += "</a>\n"; | 458 | mText += "</a>\n"; |
457 | } | 459 | } |
458 | mText.append("</li></ul>"); | 460 | mText.append("</li></ul>"); |
459 | 461 | ||
460 | addTag("h3",i18n("Attendees")); | 462 | addTag("h3",i18n("Attendees")); |
461 | Attendee *a; | 463 | Attendee *a; |
462 | mText.append("<ul>"); | 464 | mText.append("<ul>"); |
463 | for(a=attendees.first();a;a=attendees.next()) { | 465 | for(a=attendees.first();a;a=attendees.next()) { |
464 | #ifndef KORG_NOKABC | 466 | #ifndef KORG_NOKABC |
465 | #ifdef DESKTOP_VERSION | 467 | #ifdef DESKTOP_VERSION |
466 | if (a->name().isEmpty()) { | 468 | if (a->name().isEmpty()) { |
467 | addressList = add_book->findByEmail(a->email()); | 469 | addressList = add_book->findByEmail(a->email()); |
468 | KABC::Addressee o = addressList.first(); | 470 | KABC::Addressee o = addressList.first(); |
469 | if (!o.isEmpty() && addressList.size()<2) { | 471 | if (!o.isEmpty() && addressList.size()<2) { |
470 | mText += "<a href=\"uid:" + o.uid() + "\">"; | 472 | mText += "<a href=\"uid:" + o.uid() + "\">"; |
471 | mText += o.formattedName(); | 473 | mText += o.formattedName(); |
472 | mText += "</a>\n"; | 474 | mText += "</a>\n"; |
473 | } else { | 475 | } else { |
474 | mText += "<li>"; | 476 | mText += "<li>"; |
475 | mText.append(a->email()); | 477 | mText.append(a->email()); |
476 | mText += "\n"; | 478 | mText += "\n"; |
477 | } | 479 | } |
478 | } else { | 480 | } else { |
479 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; | 481 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; |
480 | if (!a->name().isEmpty()) mText += a->name(); | 482 | if (!a->name().isEmpty()) mText += a->name(); |
481 | else mText += a->email(); | 483 | else mText += a->email(); |
482 | mText += "</a>\n"; | 484 | mText += "</a>\n"; |
483 | } | 485 | } |
484 | #else //DESKTOP_VERSION | 486 | #else //DESKTOP_VERSION |
485 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; | 487 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; |
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index 8c1953d..14e8b5c 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp | |||
@@ -241,192 +241,193 @@ void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) | |||
241 | } | 241 | } |
242 | } | 242 | } |
243 | #endif | 243 | #endif |
244 | } | 244 | } |
245 | void KOTodoListView::keyPressEvent ( QKeyEvent * e ) | 245 | void KOTodoListView::keyPressEvent ( QKeyEvent * e ) |
246 | { | 246 | { |
247 | 247 | ||
248 | QListViewItem* cn; | 248 | QListViewItem* cn; |
249 | if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { | 249 | if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { |
250 | cn = currentItem(); | 250 | cn = currentItem(); |
251 | if ( cn ) { | 251 | if ( cn ) { |
252 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); | 252 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); |
253 | if ( ci ){ | 253 | if ( ci ){ |
254 | if ( e->state() == ShiftButton ) | 254 | if ( e->state() == ShiftButton ) |
255 | ci->setOn( false ); | 255 | ci->setOn( false ); |
256 | else | 256 | else |
257 | ci->setOn( true ); | 257 | ci->setOn( true ); |
258 | cn = cn->nextSibling(); | 258 | cn = cn->nextSibling(); |
259 | if ( cn ) { | 259 | if ( cn ) { |
260 | setCurrentItem ( cn ); | 260 | setCurrentItem ( cn ); |
261 | ensureItemVisible ( cn ); | 261 | ensureItemVisible ( cn ); |
262 | } | 262 | } |
263 | 263 | ||
264 | } | 264 | } |
265 | } | 265 | } |
266 | 266 | ||
267 | return; | 267 | return; |
268 | } | 268 | } |
269 | 269 | ||
270 | // qDebug("KOTodoListView::keyPressEvent "); | 270 | // qDebug("KOTodoListView::keyPressEvent "); |
271 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { | 271 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { |
272 | switch ( e->key() ) { | 272 | switch ( e->key() ) { |
273 | case Qt::Key_Down: | 273 | case Qt::Key_Down: |
274 | case Qt::Key_Up: | 274 | case Qt::Key_Up: |
275 | QListView::keyPressEvent ( e ); | 275 | QListView::keyPressEvent ( e ); |
276 | break; | 276 | break; |
277 | case Qt::Key_Left: | 277 | case Qt::Key_Left: |
278 | case Qt::Key_Right: | 278 | case Qt::Key_Right: |
279 | QListView::keyPressEvent ( e ); | 279 | QListView::keyPressEvent ( e ); |
280 | e->accept(); | 280 | e->accept(); |
281 | return; | 281 | return; |
282 | break; | 282 | break; |
283 | default: | 283 | default: |
284 | e->ignore(); | 284 | e->ignore(); |
285 | break; | 285 | break; |
286 | } | 286 | } |
287 | return; | 287 | return; |
288 | } | 288 | } |
289 | e->ignore(); | 289 | e->ignore(); |
290 | } | 290 | } |
291 | void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) | 291 | void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) |
292 | { | 292 | { |
293 | QListView::contentsMouseReleaseEvent(e); | 293 | QListView::contentsMouseReleaseEvent(e); |
294 | mMousePressed = false; | 294 | mMousePressed = false; |
295 | } | 295 | } |
296 | 296 | ||
297 | void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) | 297 | void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) |
298 | { | 298 | { |
299 | if (!e) return; | 299 | if (!e) return; |
300 | 300 | ||
301 | QPoint vp = contentsToViewport(e->pos()); | 301 | QPoint vp = contentsToViewport(e->pos()); |
302 | 302 | ||
303 | QListViewItem *item = itemAt(vp); | 303 | QListViewItem *item = itemAt(vp); |
304 | 304 | ||
305 | emit double_Clicked(item); | 305 | emit double_Clicked(item); |
306 | if (!item) return; | 306 | if (!item) return; |
307 | 307 | ||
308 | emit doubleClicked(item,vp,0); | 308 | emit doubleClicked(item,vp,0); |
309 | } | 309 | } |
310 | 310 | ||
311 | ///////////////////////////////////////////////////////////////////////////// | 311 | ///////////////////////////////////////////////////////////////////////////// |
312 | 312 | ||
313 | KOQuickTodo::KOQuickTodo(QWidget *parent) : | 313 | KOQuickTodo::KOQuickTodo(QWidget *parent) : |
314 | QLineEdit(parent) | 314 | QLineEdit(parent) |
315 | { | 315 | { |
316 | setText(i18n("Click to add a new Todo")); | 316 | setText(i18n("Click to add a new Todo")); |
317 | } | 317 | } |
318 | 318 | ||
319 | void KOQuickTodo::focusInEvent(QFocusEvent *ev) | 319 | void KOQuickTodo::focusInEvent(QFocusEvent *ev) |
320 | { | 320 | { |
321 | if ( text()==i18n("Click to add a new Todo") ) | 321 | if ( text()==i18n("Click to add a new Todo") ) |
322 | setText(""); | 322 | setText(""); |
323 | QLineEdit::focusInEvent(ev); | 323 | QLineEdit::focusInEvent(ev); |
324 | } | 324 | } |
325 | 325 | ||
326 | void KOQuickTodo::focusOutEvent(QFocusEvent *ev) | 326 | void KOQuickTodo::focusOutEvent(QFocusEvent *ev) |
327 | { | 327 | { |
328 | setText(i18n("Click to add a new Todo")); | 328 | setText(i18n("Click to add a new Todo")); |
329 | QLineEdit::focusOutEvent(ev); | 329 | QLineEdit::focusOutEvent(ev); |
330 | } | 330 | } |
331 | 331 | ||
332 | ///////////////////////////////////////////////////////////////////////////// | 332 | ///////////////////////////////////////////////////////////////////////////// |
333 | 333 | ||
334 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : | 334 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : |
335 | KOrg::BaseView(calendar,parent,name) | 335 | KOrg::BaseView(calendar,parent,name) |
336 | { | 336 | { |
337 | isFlatDisplay = false; | ||
337 | mNavigator = 0; | 338 | mNavigator = 0; |
338 | QBoxLayout *topLayout = new QVBoxLayout(this); | 339 | QBoxLayout *topLayout = new QVBoxLayout(this); |
339 | mName = QString ( name ); | 340 | mName = QString ( name ); |
340 | mBlockUpdate = false; | 341 | mBlockUpdate = false; |
341 | mQuickAdd = new KOQuickTodo(this); | 342 | mQuickAdd = new KOQuickTodo(this); |
342 | topLayout->addWidget(mQuickAdd); | 343 | topLayout->addWidget(mQuickAdd); |
343 | 344 | ||
344 | if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); | 345 | if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); |
345 | 346 | ||
346 | mTodoListView = new KOTodoListView(calendar,this, name ); | 347 | mTodoListView = new KOTodoListView(calendar,this, name ); |
347 | topLayout->addWidget(mTodoListView); | 348 | topLayout->addWidget(mTodoListView); |
348 | //mTodoListView->header()->setMaximumHeight(30); | 349 | //mTodoListView->header()->setMaximumHeight(30); |
349 | mTodoListView->setRootIsDecorated(true); | 350 | mTodoListView->setRootIsDecorated(true); |
350 | mTodoListView->setAllColumnsShowFocus(true); | 351 | mTodoListView->setAllColumnsShowFocus(true); |
351 | 352 | ||
352 | mTodoListView->setShowSortIndicator(true); | 353 | mTodoListView->setShowSortIndicator(true); |
353 | 354 | ||
354 | mTodoListView->addColumn(i18n("Todo")); | 355 | mTodoListView->addColumn(i18n("Todo")); |
355 | mTodoListView->addColumn(i18n("Prio")); | 356 | mTodoListView->addColumn(i18n("Prio")); |
356 | mTodoListView->setColumnAlignment(1,AlignHCenter); | 357 | mTodoListView->setColumnAlignment(1,AlignHCenter); |
357 | mTodoListView->addColumn(i18n("Complete")); | 358 | mTodoListView->addColumn(i18n("Complete")); |
358 | mTodoListView->setColumnAlignment(2,AlignCenter); | 359 | mTodoListView->setColumnAlignment(2,AlignCenter); |
359 | 360 | ||
360 | mTodoListView->addColumn(i18n("Due Date")); | 361 | mTodoListView->addColumn(i18n("Due Date")); |
361 | mTodoListView->setColumnAlignment(3,AlignLeft); | 362 | mTodoListView->setColumnAlignment(3,AlignLeft); |
362 | mTodoListView->addColumn(i18n("Due Time")); | 363 | mTodoListView->addColumn(i18n("Due Time")); |
363 | mTodoListView->setColumnAlignment(4,AlignHCenter); | 364 | mTodoListView->setColumnAlignment(4,AlignHCenter); |
364 | 365 | ||
365 | mTodoListView->addColumn(i18n("Start Date")); | 366 | mTodoListView->addColumn(i18n("Start Date")); |
366 | mTodoListView->setColumnAlignment(5,AlignLeft); | 367 | mTodoListView->setColumnAlignment(5,AlignLeft); |
367 | mTodoListView->addColumn(i18n("Start Time")); | 368 | mTodoListView->addColumn(i18n("Start Time")); |
368 | mTodoListView->setColumnAlignment(6,AlignHCenter); | 369 | mTodoListView->setColumnAlignment(6,AlignHCenter); |
369 | 370 | ||
370 | mTodoListView->addColumn(i18n("Cancelled")); | 371 | mTodoListView->addColumn(i18n("Cancelled")); |
371 | mTodoListView->addColumn(i18n("Categories")); | 372 | mTodoListView->addColumn(i18n("Categories")); |
372 | #if 0 | 373 | #if 0 |
373 | mTodoListView->addColumn(i18n("Sort Id")); | 374 | mTodoListView->addColumn(i18n("Sort Id")); |
374 | mTodoListView->setColumnAlignment(4,AlignHCenter); | 375 | mTodoListView->setColumnAlignment(4,AlignHCenter); |
375 | #endif | 376 | #endif |
376 | 377 | ||
377 | mTodoListView->setMinimumHeight( 60 ); | 378 | mTodoListView->setMinimumHeight( 60 ); |
378 | mTodoListView->setItemsRenameable( true ); | 379 | mTodoListView->setItemsRenameable( true ); |
379 | mTodoListView->setRenameable( 0 ); | 380 | mTodoListView->setRenameable( 0 ); |
380 | mTodoListView->setColumnWidth( 0, 120 ); | 381 | mTodoListView->setColumnWidth( 0, 120 ); |
381 | mTodoListView->setColumnWidthMode(0, QListView::Manual); | 382 | mTodoListView->setColumnWidthMode(0, QListView::Manual); |
382 | mTodoListView->setColumnWidthMode(1, QListView::Manual); | 383 | mTodoListView->setColumnWidthMode(1, QListView::Manual); |
383 | mTodoListView->setColumnWidthMode(2, QListView::Manual); | 384 | mTodoListView->setColumnWidthMode(2, QListView::Manual); |
384 | mTodoListView->setColumnWidthMode(3, QListView::Manual); | 385 | mTodoListView->setColumnWidthMode(3, QListView::Manual); |
385 | mTodoListView->setColumnWidthMode(4, QListView::Manual); | 386 | mTodoListView->setColumnWidthMode(4, QListView::Manual); |
386 | mTodoListView->setColumnWidthMode(5, QListView::Manual); | 387 | mTodoListView->setColumnWidthMode(5, QListView::Manual); |
387 | mTodoListView->setColumnWidthMode(6, QListView::Manual); | 388 | mTodoListView->setColumnWidthMode(6, QListView::Manual); |
388 | mTodoListView->setColumnWidthMode(7, QListView::Manual); | 389 | mTodoListView->setColumnWidthMode(7, QListView::Manual); |
389 | mTodoListView->setColumnWidthMode(8, QListView::Manual); | 390 | mTodoListView->setColumnWidthMode(8, QListView::Manual); |
390 | 391 | ||
391 | 392 | ||
392 | mPriorityPopupMenu = new QPopupMenu(this); | 393 | mPriorityPopupMenu = new QPopupMenu(this); |
393 | for (int i = 1; i <= 5; i++) { | 394 | for (int i = 1; i <= 5; i++) { |
394 | QString label = QString ("%1").arg (i); | 395 | QString label = QString ("%1").arg (i); |
395 | mPriority[mPriorityPopupMenu->insertItem (label)] = i; | 396 | mPriority[mPriorityPopupMenu->insertItem (label)] = i; |
396 | } | 397 | } |
397 | connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); | 398 | connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); |
398 | 399 | ||
399 | mPercentageCompletedPopupMenu = new QPopupMenu(this); | 400 | mPercentageCompletedPopupMenu = new QPopupMenu(this); |
400 | for (int i = 0; i <= 100; i+=20) { | 401 | for (int i = 0; i <= 100; i+=20) { |
401 | QString label = QString ("%1 %").arg (i); | 402 | QString label = QString ("%1 %").arg (i); |
402 | mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; | 403 | mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; |
403 | } | 404 | } |
404 | connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); | 405 | connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); |
405 | 406 | ||
406 | 407 | ||
407 | 408 | ||
408 | mItemPopupMenu = new QPopupMenu(this); | 409 | mItemPopupMenu = new QPopupMenu(this); |
409 | mItemPopupMenu->insertItem(i18n("Show..."), this, | 410 | mItemPopupMenu->insertItem(i18n("Show..."), this, |
410 | SLOT (showTodo())); | 411 | SLOT (showTodo())); |
411 | mItemPopupMenu->insertItem(i18n("Edit..."), this, | 412 | mItemPopupMenu->insertItem(i18n("Edit..."), this, |
412 | SLOT (editTodo())); | 413 | SLOT (editTodo())); |
413 | mItemPopupMenu->insertItem( i18n("Delete"), this, | 414 | mItemPopupMenu->insertItem( i18n("Delete"), this, |
414 | SLOT (deleteTodo())); | 415 | SLOT (deleteTodo())); |
415 | mItemPopupMenu->insertItem( i18n("Clone..."), this, | 416 | mItemPopupMenu->insertItem( i18n("Clone..."), this, |
416 | SLOT (cloneTodo())); | 417 | SLOT (cloneTodo())); |
417 | mItemPopupMenu->insertItem( i18n("Move..."), this, | 418 | mItemPopupMenu->insertItem( i18n("Move..."), this, |
418 | SLOT (moveTodo())); | 419 | SLOT (moveTodo())); |
419 | mItemPopupMenu->insertItem( i18n("Beam..."), this, | 420 | mItemPopupMenu->insertItem( i18n("Beam..."), this, |
420 | SLOT (beamTodo())); | 421 | SLOT (beamTodo())); |
421 | mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, | 422 | mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, |
422 | SLOT (cancelTodo())); | 423 | SLOT (cancelTodo())); |
423 | mItemPopupMenu->insertSeparator(); | 424 | mItemPopupMenu->insertSeparator(); |
424 | 425 | ||
425 | mItemPopupMenu->insertItem( i18n("New Todo..."), this, | 426 | mItemPopupMenu->insertItem( i18n("New Todo..."), this, |
426 | SLOT (newTodo())); | 427 | SLOT (newTodo())); |
427 | mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, | 428 | mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, |
428 | SLOT (newSubTodo())); | 429 | SLOT (newSubTodo())); |
429 | mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, | 430 | mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, |
430 | SLOT (unparentTodo()),0,21); | 431 | SLOT (unparentTodo()),0,21); |
431 | mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, | 432 | mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, |
432 | SLOT (reparentTodo()),0,22); | 433 | SLOT (reparentTodo()),0,22); |
@@ -859,203 +860,211 @@ void KOTodoView::setNewPercentage(int index) | |||
859 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 860 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
860 | if (mPercentage[index] == 100) { | 861 | if (mPercentage[index] == 100) { |
861 | mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); | 862 | mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); |
862 | } else { | 863 | } else { |
863 | mActiveItem->todo()->setCompleted(false); | 864 | mActiveItem->todo()->setCompleted(false); |
864 | } | 865 | } |
865 | mActiveItem->todo()->setPercentComplete(mPercentage[index]); | 866 | mActiveItem->todo()->setPercentComplete(mPercentage[index]); |
866 | mActiveItem->construct(); | 867 | mActiveItem->construct(); |
867 | todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); | 868 | todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); |
868 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 869 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
869 | } | 870 | } |
870 | } | 871 | } |
871 | 872 | ||
872 | 873 | ||
873 | QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) | 874 | QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) |
874 | { | 875 | { |
875 | QPopupMenu* tempMenu = new QPopupMenu (this); | 876 | QPopupMenu* tempMenu = new QPopupMenu (this); |
876 | QStringList checkedCategories = todoItem->todo()->categories (); | 877 | QStringList checkedCategories = todoItem->todo()->categories (); |
877 | 878 | ||
878 | tempMenu->setCheckable (true); | 879 | tempMenu->setCheckable (true); |
879 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); | 880 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); |
880 | it != KOPrefs::instance()->mCustomCategories.end (); | 881 | it != KOPrefs::instance()->mCustomCategories.end (); |
881 | ++it) { | 882 | ++it) { |
882 | int index = tempMenu->insertItem (*it); | 883 | int index = tempMenu->insertItem (*it); |
883 | mCategory[index] = *it; | 884 | mCategory[index] = *it; |
884 | if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true); | 885 | if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true); |
885 | } | 886 | } |
886 | 887 | ||
887 | connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); | 888 | connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); |
888 | return tempMenu; | 889 | return tempMenu; |
889 | 890 | ||
890 | 891 | ||
891 | } | 892 | } |
892 | void KOTodoView::changedCategories(int index) | 893 | void KOTodoView::changedCategories(int index) |
893 | { | 894 | { |
894 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 895 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
895 | QStringList categories = mActiveItem->todo()->categories (); | 896 | QStringList categories = mActiveItem->todo()->categories (); |
896 | if (categories.find (mCategory[index]) != categories.end ()) | 897 | if (categories.find (mCategory[index]) != categories.end ()) |
897 | categories.remove (mCategory[index]); | 898 | categories.remove (mCategory[index]); |
898 | else | 899 | else |
899 | categories.insert (categories.end(), mCategory[index]); | 900 | categories.insert (categories.end(), mCategory[index]); |
900 | categories.sort (); | 901 | categories.sort (); |
901 | mActiveItem->todo()->setCategories (categories); | 902 | mActiveItem->todo()->setCategories (categories); |
902 | mActiveItem->construct(); | 903 | mActiveItem->construct(); |
903 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 904 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
904 | todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); | 905 | todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); |
905 | } | 906 | } |
906 | } | 907 | } |
907 | void KOTodoView::itemDoubleClicked(QListViewItem *item) | 908 | void KOTodoView::itemDoubleClicked(QListViewItem *item) |
908 | { | 909 | { |
909 | if ( pendingSubtodo != 0 ) { | 910 | if ( pendingSubtodo != 0 ) { |
910 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); | 911 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); |
911 | } | 912 | } |
912 | pendingSubtodo = 0; | 913 | pendingSubtodo = 0; |
913 | if (!item) { | 914 | if (!item) { |
914 | newTodo(); | 915 | newTodo(); |
915 | return; | 916 | return; |
916 | } | 917 | } |
917 | if ( KOPrefs::instance()->mEditOnDoubleClick ) | 918 | if ( KOPrefs::instance()->mEditOnDoubleClick ) |
918 | editItem( item ); | 919 | editItem( item ); |
919 | else | 920 | else |
920 | showItem( item , QPoint(), 0 ); | 921 | showItem( item , QPoint(), 0 ); |
921 | } | 922 | } |
922 | void KOTodoView::itemClicked(QListViewItem *item) | 923 | void KOTodoView::itemClicked(QListViewItem *item) |
923 | { | 924 | { |
924 | 925 | ||
925 | if (!item) { | 926 | if (!item) { |
926 | if ( pendingSubtodo != 0 ) { | 927 | if ( pendingSubtodo != 0 ) { |
927 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); | 928 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); |
928 | } | 929 | } |
929 | pendingSubtodo = 0; | 930 | pendingSubtodo = 0; |
930 | return; | 931 | return; |
931 | } | 932 | } |
932 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 933 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
933 | if ( pendingSubtodo != 0 ) { | 934 | if ( pendingSubtodo != 0 ) { |
934 | bool allowReparent = true; | 935 | bool allowReparent = true; |
935 | QListViewItem *par = item; | 936 | QListViewItem *par = item; |
936 | while ( par ) { | 937 | while ( par ) { |
937 | if ( par == pendingSubtodo ) { | 938 | if ( par == pendingSubtodo ) { |
938 | allowReparent = false; | 939 | allowReparent = false; |
939 | break; | 940 | break; |
940 | } | 941 | } |
941 | par = par->parent(); | 942 | par = par->parent(); |
942 | } | 943 | } |
943 | if ( !allowReparent ) { | 944 | if ( !allowReparent ) { |
944 | topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); | 945 | topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); |
945 | qDebug("Recursive reparenting not possible "); | 946 | qDebug("Recursive reparenting not possible "); |
946 | pendingSubtodo = 0; | 947 | pendingSubtodo = 0; |
947 | } else { | 948 | } else { |
948 | Todo* newParent = todoItem->todo(); | 949 | Todo* newParent = todoItem->todo(); |
949 | Todo* newSub = pendingSubtodo->todo(); | 950 | Todo* newSub = pendingSubtodo->todo(); |
950 | pendingSubtodo = 0; | 951 | pendingSubtodo = 0; |
951 | emit reparentTodoSignal( newParent,newSub ); | 952 | emit reparentTodoSignal( newParent,newSub ); |
952 | return; | 953 | return; |
953 | } | 954 | } |
954 | } | 955 | } |
955 | int completed = todoItem->todo()->isCompleted(); // Completed or not? | 956 | #if 0 |
956 | 957 | // handled by the item itself | |
958 | bool completed = todoItem->todo()->isCompleted(); // Completed or not? | ||
959 | qDebug("com %d ",completed ); | ||
960 | qDebug("itemclicked "); | ||
957 | if (todoItem->isOn()) { | 961 | if (todoItem->isOn()) { |
962 | qDebug("on "); | ||
958 | if (!completed) { | 963 | if (!completed) { |
964 | qDebug("set true "); | ||
959 | todoItem->todo()->setCompleted(QDateTime::currentDateTime()); | 965 | todoItem->todo()->setCompleted(QDateTime::currentDateTime()); |
960 | } | 966 | } |
961 | } else { | 967 | } else { |
968 | qDebug("not on "); | ||
962 | if (completed) { | 969 | if (completed) { |
970 | qDebug("set false "); | ||
963 | todoItem->todo()->setCompleted(false); | 971 | todoItem->todo()->setCompleted(false); |
964 | } | 972 | } |
965 | } | 973 | } |
974 | #endif | ||
966 | } | 975 | } |
967 | 976 | ||
968 | void KOTodoView::setDocumentId( const QString &id ) | 977 | void KOTodoView::setDocumentId( const QString &id ) |
969 | { | 978 | { |
970 | kdDebug() << "KOTodoView::setDocumentId()" << endl; | 979 | kdDebug() << "KOTodoView::setDocumentId()" << endl; |
971 | 980 | ||
972 | mDocPrefs->setDoc( id ); | 981 | mDocPrefs->setDoc( id ); |
973 | } | 982 | } |
974 | 983 | ||
975 | void KOTodoView::itemStateChanged( QListViewItem *item ) | 984 | void KOTodoView::itemStateChanged( QListViewItem *item ) |
976 | { | 985 | { |
977 | if (!item) return; | 986 | if (!item) return; |
978 | 987 | ||
979 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 988 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
980 | 989 | ||
981 | // kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; | 990 | // kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; |
982 | 991 | ||
983 | if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); | 992 | if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); |
984 | } | 993 | } |
985 | 994 | ||
986 | void KOTodoView::saveLayout(KConfig *config, const QString &group) const | 995 | void KOTodoView::saveLayout(KConfig *config, const QString &group) const |
987 | { | 996 | { |
988 | mTodoListView->saveLayout(config,group); | 997 | mTodoListView->saveLayout(config,group); |
989 | } | 998 | } |
990 | 999 | ||
991 | void KOTodoView::restoreLayout(KConfig *config, const QString &group) | 1000 | void KOTodoView::restoreLayout(KConfig *config, const QString &group) |
992 | { | 1001 | { |
993 | mTodoListView->restoreLayout(config,group); | 1002 | mTodoListView->restoreLayout(config,group); |
994 | } | 1003 | } |
995 | 1004 | ||
996 | void KOTodoView::processSelectionChange() | 1005 | void KOTodoView::processSelectionChange() |
997 | { | 1006 | { |
998 | // kdDebug() << "KOTodoView::processSelectionChange()" << endl; | 1007 | // kdDebug() << "KOTodoView::processSelectionChange()" << endl; |
999 | 1008 | ||
1000 | KOTodoViewItem *item = | 1009 | KOTodoViewItem *item = |
1001 | static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); | 1010 | static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); |
1002 | 1011 | ||
1003 | if ( !item ) { | 1012 | if ( !item ) { |
1004 | emit incidenceSelected( 0 ); | 1013 | emit incidenceSelected( 0 ); |
1005 | } else { | 1014 | } else { |
1006 | emit incidenceSelected( item->todo() ); | 1015 | emit incidenceSelected( item->todo() ); |
1007 | } | 1016 | } |
1008 | } | 1017 | } |
1009 | 1018 | ||
1010 | void KOTodoView::modified(bool b) | 1019 | void KOTodoView::modified(bool b) |
1011 | { | 1020 | { |
1012 | emit isModified(b); | 1021 | emit isModified(b); |
1013 | } | 1022 | } |
1014 | void KOTodoView::setTodoModified( Todo* todo ) | 1023 | void KOTodoView::setTodoModified( Todo* todo ) |
1015 | { | 1024 | { |
1016 | todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); | 1025 | todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); |
1017 | } | 1026 | } |
1018 | void KOTodoView::clearSelection() | 1027 | void KOTodoView::clearSelection() |
1019 | { | 1028 | { |
1020 | mTodoListView->selectAll( false ); | 1029 | mTodoListView->selectAll( false ); |
1021 | } | 1030 | } |
1022 | void KOTodoView::setAllOpen() | 1031 | void KOTodoView::setAllOpen() |
1023 | { | 1032 | { |
1024 | if ( isFlatDisplay ) { | 1033 | if ( isFlatDisplay ) { |
1025 | isFlatDisplay = false; | 1034 | isFlatDisplay = false; |
1026 | mPopupMenu->setItemChecked( 8,false ); | 1035 | mPopupMenu->setItemChecked( 8,false ); |
1027 | updateView(); | 1036 | updateView(); |
1028 | } | 1037 | } |
1029 | setOpen(mTodoListView->firstChild(), true); | 1038 | setOpen(mTodoListView->firstChild(), true); |
1030 | } | 1039 | } |
1031 | void KOTodoView::setAllClose() | 1040 | void KOTodoView::setAllClose() |
1032 | { | 1041 | { |
1033 | if ( isFlatDisplay ) { | 1042 | if ( isFlatDisplay ) { |
1034 | isFlatDisplay = false; | 1043 | isFlatDisplay = false; |
1035 | mPopupMenu->setItemChecked( 8,false ); | 1044 | mPopupMenu->setItemChecked( 8,false ); |
1036 | updateView(); | 1045 | updateView(); |
1037 | } | 1046 | } |
1038 | setOpen(mTodoListView->firstChild(), false); | 1047 | setOpen(mTodoListView->firstChild(), false); |
1039 | } | 1048 | } |
1040 | void KOTodoView::setOpen( QListViewItem* item, bool setOpenI) | 1049 | void KOTodoView::setOpen( QListViewItem* item, bool setOpenI) |
1041 | { | 1050 | { |
1042 | 1051 | ||
1043 | while ( item ) { | 1052 | while ( item ) { |
1044 | setOpen( item->firstChild(), setOpenI ); | 1053 | setOpen( item->firstChild(), setOpenI ); |
1045 | item->setOpen( setOpenI ); | 1054 | item->setOpen( setOpenI ); |
1046 | item = item->nextSibling(); | 1055 | item = item->nextSibling(); |
1047 | } | 1056 | } |
1048 | } | 1057 | } |
1049 | 1058 | ||
1050 | void KOTodoView::setAllFlat() | 1059 | void KOTodoView::setAllFlat() |
1051 | { | 1060 | { |
1052 | if ( isFlatDisplay ) { | 1061 | if ( isFlatDisplay ) { |
1053 | isFlatDisplay = false; | 1062 | isFlatDisplay = false; |
1054 | mPopupMenu->setItemChecked( 8,false ); | 1063 | mPopupMenu->setItemChecked( 8,false ); |
1055 | updateView(); | 1064 | updateView(); |
1056 | return; | 1065 | return; |
1057 | } | 1066 | } |
1058 | pendingSubtodo = 0; | 1067 | pendingSubtodo = 0; |
1059 | if ( mBlockUpdate ) { | 1068 | if ( mBlockUpdate ) { |
1060 | return; | 1069 | return; |
1061 | } | 1070 | } |
diff --git a/korganizer/kotodoviewitem.cpp b/korganizer/kotodoviewitem.cpp index 21ecb73..2822237 100644 --- a/korganizer/kotodoviewitem.cpp +++ b/korganizer/kotodoviewitem.cpp | |||
@@ -110,199 +110,198 @@ void KOTodoViewItem::construct() | |||
110 | } | 110 | } |
111 | } else { | 111 | } else { |
112 | setText(3,""); | 112 | setText(3,""); |
113 | setText(4,""); | 113 | setText(4,""); |
114 | } | 114 | } |
115 | setSortKey(3,keyd); | 115 | setSortKey(3,keyd); |
116 | setSortKey(4,keyt); | 116 | setSortKey(4,keyt); |
117 | 117 | ||
118 | if (mTodo->isCompleted()) setSortKey(1,"6" + QString::number(mTodo->priority())+keyd+keyt); | 118 | if (mTodo->isCompleted()) setSortKey(1,"6" + QString::number(mTodo->priority())+keyd+keyt); |
119 | else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); | 119 | else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); |
120 | 120 | ||
121 | 121 | ||
122 | 122 | ||
123 | if (mTodo->hasStartDate()) { | 123 | if (mTodo->hasStartDate()) { |
124 | setText(5, mTodo->dtStartDateStr()); | 124 | setText(5, mTodo->dtStartDateStr()); |
125 | QDate d = mTodo->dtStart().date(); | 125 | QDate d = mTodo->dtStart().date(); |
126 | skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); | 126 | skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); |
127 | 127 | ||
128 | if (mTodo->doesFloat()) { | 128 | if (mTodo->doesFloat()) { |
129 | setText(6,""); | 129 | setText(6,""); |
130 | } | 130 | } |
131 | else { | 131 | else { |
132 | setText(6,mTodo->dtStartTimeStr()); | 132 | setText(6,mTodo->dtStartTimeStr()); |
133 | QTime t = mTodo->dtStart().time(); | 133 | QTime t = mTodo->dtStart().time(); |
134 | skeyt.sprintf("%02d%02d",t.hour(),t.minute()); | 134 | skeyt.sprintf("%02d%02d",t.hour(),t.minute()); |
135 | 135 | ||
136 | } | 136 | } |
137 | } else { | 137 | } else { |
138 | setText(5,""); | 138 | setText(5,""); |
139 | setText(6,""); | 139 | setText(6,""); |
140 | } | 140 | } |
141 | setSortKey(5,skeyd); | 141 | setSortKey(5,skeyd); |
142 | setSortKey(6,skeyt); | 142 | setSortKey(6,skeyt); |
143 | 143 | ||
144 | setText(7,mTodo->cancelled() ? i18n("Yes") : i18n("No")); | 144 | setText(7,mTodo->cancelled() ? i18n("Yes") : i18n("No")); |
145 | setText(8,mTodo->categoriesStr()); | 145 | setText(8,mTodo->categoriesStr()); |
146 | 146 | ||
147 | #if 0 | 147 | #if 0 |
148 | // Find sort id in description. It's the text behind the last '#' character | 148 | // Find sort id in description. It's the text behind the last '#' character |
149 | // found in the description. White spaces are removed from beginning and end | 149 | // found in the description. White spaces are removed from beginning and end |
150 | // of sort id. | 150 | // of sort id. |
151 | int pos = mTodo->description().findRev('#'); | 151 | int pos = mTodo->description().findRev('#'); |
152 | if (pos < 0) { | 152 | if (pos < 0) { |
153 | setText(6,""); | 153 | setText(6,""); |
154 | } else { | 154 | } else { |
155 | QString str = mTodo->description().mid(pos+1); | 155 | QString str = mTodo->description().mid(pos+1); |
156 | str.stripWhiteSpace(); | 156 | str.stripWhiteSpace(); |
157 | setText(6,str); | 157 | setText(6,str); |
158 | } | 158 | } |
159 | #endif | 159 | #endif |
160 | 160 | ||
161 | m_known = false; | 161 | m_known = false; |
162 | m_init = false; | 162 | m_init = false; |
163 | 163 | ||
164 | setMyPixmap(); | 164 | setMyPixmap(); |
165 | 165 | ||
166 | } | 166 | } |
167 | void KOTodoViewItem::setMyPixmap() | 167 | void KOTodoViewItem::setMyPixmap() |
168 | { | 168 | { |
169 | int size = 5; | 169 | int size = 5; |
170 | QPixmap pixi = QPixmap( 1, 1 ); | 170 | QPixmap pixi = QPixmap( 1, 1 ); |
171 | // if ( !mTodo->isCompleted() && mTodo->hasDueDate() && mTodo->dtDue() < QDateTime::currentDateTime() ) { | 171 | // if ( !mTodo->isCompleted() && mTodo->hasDueDate() && mTodo->dtDue() < QDateTime::currentDateTime() ) { |
172 | // pixi = SmallIcon("redcross16"); | 172 | // pixi = SmallIcon("redcross16"); |
173 | // } else { | 173 | // } else { |
174 | QPainter p; | 174 | QPainter p; |
175 | 175 | ||
176 | int pixSize = 0; | 176 | int pixSize = 0; |
177 | QPixmap pPix = QPixmap( size, size ); | 177 | QPixmap pPix = QPixmap( size, size ); |
178 | if ( mTodo->description().length() > 0 ) { | 178 | if ( mTodo->description().length() > 0 ) { |
179 | pixi.resize(size, pixSize+size); | 179 | pixi.resize(size, pixSize+size); |
180 | pPix.fill( Qt::darkGreen ); | 180 | pPix.fill( Qt::darkGreen ); |
181 | p.begin( &pixi ); | 181 | p.begin( &pixi ); |
182 | p. drawPixmap ( 0, pixSize, pPix); | 182 | p. drawPixmap ( 0, pixSize, pPix); |
183 | p.end(); | 183 | p.end(); |
184 | pixSize += size; | 184 | pixSize += size; |
185 | } | 185 | } |
186 | if ( mTodo->isAlarmEnabled() ) { | 186 | if ( mTodo->isAlarmEnabled() ) { |
187 | pixi.resize(size, pixSize+size); | 187 | pixi.resize(size, pixSize+size); |
188 | pPix.fill( Qt::red ); | 188 | pPix.fill( Qt::red ); |
189 | p.begin( &pixi ); | 189 | p.begin( &pixi ); |
190 | p. drawPixmap ( 0, pixSize, pPix); | 190 | p. drawPixmap ( 0, pixSize, pPix); |
191 | p.end(); | 191 | p.end(); |
192 | pixSize += size; | 192 | pixSize += size; |
193 | } | 193 | } |
194 | // } | 194 | // } |
195 | if ( pixi.width() > 1 ) { | 195 | if ( pixi.width() > 1 ) { |
196 | setPixmap ( 0,pixi ) ; | 196 | setPixmap ( 0,pixi ) ; |
197 | } else { | 197 | } else { |
198 | setPixmap ( 0,QPixmap() ) ; | 198 | setPixmap ( 0,QPixmap() ) ; |
199 | } | 199 | } |
200 | } | 200 | } |
201 | void KOTodoViewItem::stateChange(bool state) | 201 | void KOTodoViewItem::stateChange(bool state) |
202 | { | 202 | { |
203 | // qDebug("KOTodoViewItem::stateChange "); | 203 | // qDebug("KOTodoViewItem::stateChange "); |
204 | // do not change setting on startup | 204 | // do not change setting on startup |
205 | if ( m_init ) return; | 205 | if ( m_init ) return; |
206 | 206 | qDebug("KOTodoViewItem::stateChange "); | |
207 | kdDebug() << "State changed, modified " << state << endl; | ||
208 | QString keyd = "=="; | 207 | QString keyd = "=="; |
209 | QString keyt = "=="; | 208 | QString keyt = "=="; |
210 | 209 | ||
211 | if (state) mTodo->setCompleted(state); | 210 | mTodo->setCompleted(state); |
212 | else mTodo->setPercentComplete(0); | 211 | if (state) mTodo->setCompleted(QDateTime::currentDateTime()); |
213 | if (isOn()!=state) { | 212 | if (isOn()!=state) { |
214 | setOn(state); | 213 | setOn(state); |
215 | } | 214 | } |
216 | 215 | ||
217 | if (mTodo->hasDueDate()) { | 216 | if (mTodo->hasDueDate()) { |
218 | setText(3, mTodo->dtDueDateStr()); | 217 | setText(3, mTodo->dtDueDateStr()); |
219 | QDate d = mTodo->dtDue().date(); | 218 | QDate d = mTodo->dtDue().date(); |
220 | keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); | 219 | keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); |
221 | setSortKey(3,keyd); | 220 | setSortKey(3,keyd); |
222 | if (mTodo->doesFloat()) { | 221 | if (mTodo->doesFloat()) { |
223 | setText(4,""); | 222 | setText(4,""); |
224 | } | 223 | } |
225 | else { | 224 | else { |
226 | setText(4,mTodo->dtDueTimeStr()); | 225 | setText(4,mTodo->dtDueTimeStr()); |
227 | QTime t = mTodo->dtDue().time(); | 226 | QTime t = mTodo->dtDue().time(); |
228 | keyt.sprintf("%02d%02d",t.hour(),t.minute()); | 227 | keyt.sprintf("%02d%02d",t.hour(),t.minute()); |
229 | setSortKey(4,keyt); | 228 | setSortKey(4,keyt); |
230 | } | 229 | } |
231 | } | 230 | } |
232 | if (mTodo->isCompleted()) setSortKey(1,QString::number(9)+keyd+keyt); | 231 | if (mTodo->isCompleted()) setSortKey(1,QString::number(9)+keyd+keyt); |
233 | else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); | 232 | else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); |
234 | 233 | ||
235 | setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); | 234 | setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); |
236 | if (mTodo->percentComplete()<100) { | 235 | if (mTodo->percentComplete()<100) { |
237 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); | 236 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); |
238 | else setSortKey(2,QString::number(mTodo->percentComplete())); | 237 | else setSortKey(2,QString::number(mTodo->percentComplete())); |
239 | } | 238 | } |
240 | else { | 239 | else { |
241 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); | 240 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); |
242 | else setSortKey(2,QString::number(99)); | 241 | else setSortKey(2,QString::number(99)); |
243 | } | 242 | } |
244 | QListViewItem * myChild = firstChild(); | 243 | QListViewItem * myChild = firstChild(); |
245 | KOTodoViewItem *item; | 244 | KOTodoViewItem *item; |
246 | while( myChild ) { | 245 | while( myChild ) { |
247 | item = static_cast<KOTodoViewItem*>(myChild); | 246 | item = static_cast<KOTodoViewItem*>(myChild); |
248 | item->stateChange(state); | 247 | item->stateChange(state); |
249 | myChild = myChild->nextSibling(); | 248 | myChild = myChild->nextSibling(); |
250 | } | 249 | } |
251 | mTodoView->modified(true); | 250 | mTodoView->modified(true); |
252 | setMyPixmap(); | 251 | setMyPixmap(); |
253 | mTodoView->setTodoModified( mTodo ); | 252 | mTodoView->setTodoModified( mTodo ); |
254 | } | 253 | } |
255 | 254 | ||
256 | bool KOTodoViewItem::isAlternate() | 255 | bool KOTodoViewItem::isAlternate() |
257 | { | 256 | { |
258 | #ifndef KORG_NOLVALTERNATION | 257 | #ifndef KORG_NOLVALTERNATION |
259 | KOTodoListView *lv = static_cast<KOTodoListView *>(listView()); | 258 | KOTodoListView *lv = static_cast<KOTodoListView *>(listView()); |
260 | if (lv && lv->alternateBackground().isValid()) | 259 | if (lv && lv->alternateBackground().isValid()) |
261 | { | 260 | { |
262 | KOTodoViewItem *above = 0; | 261 | KOTodoViewItem *above = 0; |
263 | above = dynamic_cast<KOTodoViewItem *>(itemAbove()); | 262 | above = dynamic_cast<KOTodoViewItem *>(itemAbove()); |
264 | m_known = above ? above->m_known : true; | 263 | m_known = above ? above->m_known : true; |
265 | if (m_known) | 264 | if (m_known) |
266 | { | 265 | { |
267 | m_odd = above ? !above->m_odd : false; | 266 | m_odd = above ? !above->m_odd : false; |
268 | } | 267 | } |
269 | else | 268 | else |
270 | { | 269 | { |
271 | KOTodoViewItem *item; | 270 | KOTodoViewItem *item; |
272 | bool previous = true; | 271 | bool previous = true; |
273 | if (QListViewItem::parent()) | 272 | if (QListViewItem::parent()) |
274 | { | 273 | { |
275 | item = dynamic_cast<KOTodoViewItem *>(QListViewItem::parent()); | 274 | item = dynamic_cast<KOTodoViewItem *>(QListViewItem::parent()); |
276 | if (item) | 275 | if (item) |
277 | previous = item->m_odd; | 276 | previous = item->m_odd; |
278 | item = dynamic_cast<KOTodoViewItem *>(QListViewItem::parent()->firstChild()); | 277 | item = dynamic_cast<KOTodoViewItem *>(QListViewItem::parent()->firstChild()); |
279 | } | 278 | } |
280 | else | 279 | else |
281 | { | 280 | { |
282 | item = dynamic_cast<KOTodoViewItem *>(lv->firstChild()); | 281 | item = dynamic_cast<KOTodoViewItem *>(lv->firstChild()); |
283 | } | 282 | } |
284 | 283 | ||
285 | while(item) | 284 | while(item) |
286 | { | 285 | { |
287 | item->m_odd = previous = !previous; | 286 | item->m_odd = previous = !previous; |
288 | item->m_known = true; | 287 | item->m_known = true; |
289 | item = dynamic_cast<KOTodoViewItem *>(item->nextSibling()); | 288 | item = dynamic_cast<KOTodoViewItem *>(item->nextSibling()); |
290 | } | 289 | } |
291 | } | 290 | } |
292 | return m_odd; | 291 | return m_odd; |
293 | } | 292 | } |
294 | return false; | 293 | return false; |
295 | #else | 294 | #else |
296 | return false; | 295 | return false; |
297 | #endif | 296 | #endif |
298 | } | 297 | } |
299 | 298 | ||
300 | void KOTodoViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) | 299 | void KOTodoViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) |
301 | { | 300 | { |
302 | QColorGroup _cg = cg; | 301 | QColorGroup _cg = cg; |
303 | QColorGroup::ColorRole role; | 302 | QColorGroup::ColorRole role; |
304 | if ( KOPrefs::instance()->mTodoViewUsesForegroundColor ) | 303 | if ( KOPrefs::instance()->mTodoViewUsesForegroundColor ) |
305 | role = QColorGroup::Text; | 304 | role = QColorGroup::Text; |
306 | else | 305 | else |
307 | role = QColorGroup::Base; | 306 | role = QColorGroup::Base; |
308 | //#ifndef KORG_NOLVALTERNATION | 307 | //#ifndef KORG_NOLVALTERNATION |
diff --git a/libkcal/kincidenceformatter.cpp b/libkcal/kincidenceformatter.cpp index c52f2b3..6d07d4c 100644 --- a/libkcal/kincidenceformatter.cpp +++ b/libkcal/kincidenceformatter.cpp | |||
@@ -74,218 +74,218 @@ void KIncidenceFormatter::setEvent(Event *event) | |||
74 | mText += "</font>"; | 74 | mText += "</font>"; |
75 | } | 75 | } |
76 | if (!event->location().isEmpty()) { | 76 | if (!event->location().isEmpty()) { |
77 | addTag("b",i18n("Location: ")); | 77 | addTag("b",i18n("Location: ")); |
78 | mText.append(event->location()+"<br>"); | 78 | mText.append(event->location()+"<br>"); |
79 | } | 79 | } |
80 | if (event->doesFloat()) { | 80 | if (event->doesFloat()) { |
81 | if (event->isMultiDay()) { | 81 | if (event->isMultiDay()) { |
82 | mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>") | 82 | mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>") |
83 | .arg(event->dtStartDateStr(shortDate)) | 83 | .arg(event->dtStartDateStr(shortDate)) |
84 | .arg(event->dtEndDateStr(shortDate))); | 84 | .arg(event->dtEndDateStr(shortDate))); |
85 | } else { | 85 | } else { |
86 | mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate ))); | 86 | mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate ))); |
87 | } | 87 | } |
88 | } else { | 88 | } else { |
89 | if (event->isMultiDay()) { | 89 | if (event->isMultiDay()) { |
90 | mText.append(i18n("<p><b>From:</b> %1</p> ") | 90 | mText.append(i18n("<p><b>From:</b> %1</p> ") |
91 | .arg(event->dtStartStr( shortDate))); | 91 | .arg(event->dtStartStr( shortDate))); |
92 | mText.append(i18n("<p><b>To:</b> %1</p>") | 92 | mText.append(i18n("<p><b>To:</b> %1</p>") |
93 | .arg(event->dtEndStr(shortDate))); | 93 | .arg(event->dtEndStr(shortDate))); |
94 | } else { | 94 | } else { |
95 | mText.append(i18n("<p><b>On:</b> %1</p> ") | 95 | mText.append(i18n("<p><b>On:</b> %1</p> ") |
96 | .arg(event->dtStartDateStr( shortDate ))); | 96 | .arg(event->dtStartDateStr( shortDate ))); |
97 | mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") | 97 | mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") |
98 | .arg(event->dtStartTimeStr()) | 98 | .arg(event->dtStartTimeStr()) |
99 | .arg(event->dtEndTimeStr())); | 99 | .arg(event->dtEndTimeStr())); |
100 | } | 100 | } |
101 | } | 101 | } |
102 | 102 | ||
103 | if (event->recurrence()->doesRecur()) { | 103 | if (event->recurrence()->doesRecur()) { |
104 | 104 | ||
105 | QString recurText = event->recurrence()->recurrenceText(); | 105 | QString recurText = event->recurrence()->recurrenceText(); |
106 | addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); | 106 | addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); |
107 | bool last; | 107 | bool last; |
108 | QDate start = QDate::currentDate(); | 108 | QDate start = QDate::currentDate(); |
109 | QDate next; | 109 | QDate next; |
110 | next = event->recurrence()->getPreviousDate( start , &last ); | 110 | next = event->recurrence()->getPreviousDate( start , &last ); |
111 | if ( !last ) { | 111 | if ( !last ) { |
112 | next = event->recurrence()->getNextDate( start.addDays( - 1 ) ); | 112 | next = event->recurrence()->getNextDate( start.addDays( - 1 ) ); |
113 | addTag("p",i18n("Next recurrence is on: ")+ KGlobal::locale()->formatDate( next, shortDate ) ); | 113 | addTag("p",i18n("Next recurrence is on: ")+ KGlobal::locale()->formatDate( next, shortDate ) ); |
114 | //addTag("p", KGlobal::locale()->formatDate( next, shortDate )); | 114 | //addTag("p", KGlobal::locale()->formatDate( next, shortDate )); |
115 | } else { | 115 | } else { |
116 | addTag("p",i18n("<b>Last recurrence was on:</b>") ); | 116 | addTag("p",i18n("<b>Last recurrence was on:</b>") ); |
117 | addTag("p", KGlobal::locale()->formatDate( next, shortDate )); | 117 | addTag("p", KGlobal::locale()->formatDate( next, shortDate )); |
118 | } | 118 | } |
119 | } | 119 | } |
120 | 120 | ||
121 | 121 | ||
122 | if (event->isAlarmEnabled()) { | 122 | if (event->isAlarmEnabled()) { |
123 | Alarm *alarm =event->alarms().first() ; | 123 | Alarm *alarm =event->alarms().first() ; |
124 | QDateTime t = alarm->time(); | 124 | QDateTime t = alarm->time(); |
125 | int min = t.secsTo( event->dtStart() )/60; | 125 | int min = t.secsTo( event->dtStart() )/60; |
126 | QString s =i18n("(%1 min before)").arg( min ); | 126 | QString s =i18n("(%1 min before)").arg( min ); |
127 | addTag("p",i18n("<b>Alarm on: </b>") + s + ": "+KGlobal::locale()->formatDateTime( t, shortDate )); | 127 | addTag("p",i18n("<b>Alarm on: </b>") + s + ": "+KGlobal::locale()->formatDateTime( t, shortDate )); |
128 | //addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); | 128 | //addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); |
129 | //addTag("p",s); | 129 | //addTag("p",s); |
130 | } | 130 | } |
131 | 131 | ||
132 | addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); | 132 | addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); |
133 | // mText.append(event->secrecyStr()+"<br>"); | 133 | // mText.append(event->secrecyStr()+"<br>"); |
134 | formatCategories(event); | 134 | formatCategories(event); |
135 | if (!event->description().isEmpty()) { | 135 | if (!event->description().isEmpty()) { |
136 | addTag("p",i18n("<b>Details: </b>")); | 136 | addTag("p",i18n("<b>Details: </b>")); |
137 | addTag("p",event->description()); | 137 | addTag("p",event->description()); |
138 | } | 138 | } |
139 | 139 | ||
140 | 140 | ||
141 | formatReadOnly(event); | 141 | formatReadOnly(event); |
142 | formatAttendees(event); | 142 | formatAttendees(event); |
143 | 143 | ||
144 | 144 | ||
145 | } | 145 | } |
146 | 146 | ||
147 | void KIncidenceFormatter::setTodo(Todo *event ) | 147 | void KIncidenceFormatter::setTodo(Todo *event ) |
148 | { | 148 | { |
149 | int mode = 0; | 149 | int mode = 0; |
150 | mCurrentIncidence = event; | 150 | mCurrentIncidence = event; |
151 | bool shortDate = true; | 151 | bool shortDate = true; |
152 | if (mode == 0 ) | 152 | if (mode == 0 ) |
153 | addTag("h3",event->summary()); | 153 | addTag("h3",event->summary()); |
154 | else { | 154 | else { |
155 | if ( mColorMode == 1 ) { | 155 | if ( mColorMode == 1 ) { |
156 | mText +="<font color=\"#00A000\">"; | 156 | mText +="<font color=\"#00A000\">"; |
157 | } | 157 | } |
158 | if ( mColorMode == 2 ) { | 158 | if ( mColorMode == 2 ) { |
159 | mText +="<font color=\"#B00000\">"; | 159 | mText +="<font color=\"#B00000\">"; |
160 | } | 160 | } |
161 | if ( mode == 1 ) { | 161 | if ( mode == 1 ) { |
162 | addTag("h2",i18n( "Local: " ) +event->summary()); | 162 | addTag("h2",i18n( "Local: " ) +event->summary()); |
163 | } else { | 163 | } else { |
164 | addTag("h2",i18n( "Remote: " ) +event->summary()); | 164 | addTag("h2",i18n( "Remote: " ) +event->summary()); |
165 | } | 165 | } |
166 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); | 166 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); |
167 | if ( mColorMode ) | 167 | if ( mColorMode ) |
168 | mText += "</font>"; | 168 | mText += "</font>"; |
169 | } | 169 | } |
170 | if ( event->percentComplete() == 100 && event->hasCompletedDate() ) { | ||
171 | mText +="<font color=\"#B00000\">"; | ||
172 | addTag("i", i18n("<p><i>Completed on %1</i></p>").arg( event->completedStr(shortDate) ) ); | ||
173 | mText += "</font>"; | ||
174 | } else { | ||
175 | mText.append(i18n("<p><i>%1 % completed</i></p>") | ||
176 | .arg(event->percentComplete())); | ||
177 | } | ||
170 | if (event->cancelled ()) { | 178 | if (event->cancelled ()) { |
171 | mText +="<font color=\"#B00000\">"; | 179 | mText +="<font color=\"#B00000\">"; |
172 | addTag("i",i18n("This todo has been cancelled!")); | 180 | addTag("i",i18n("This todo has been cancelled!")); |
173 | mText.append("<br>"); | 181 | mText.append("<br>"); |
174 | mText += "</font>"; | 182 | mText += "</font>"; |
175 | } | 183 | } |
176 | 184 | ||
177 | if (!event->location().isEmpty()) { | 185 | if (!event->location().isEmpty()) { |
178 | addTag("b",i18n("Location: ")); | 186 | addTag("b",i18n("Location: ")); |
179 | mText.append(event->location()+"<br>"); | 187 | mText.append(event->location()+"<br>"); |
180 | } | 188 | } |
181 | if (event->hasDueDate()) { | 189 | if (event->hasDueDate()) { |
182 | mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(shortDate))); | 190 | mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(shortDate))); |
183 | } | 191 | } |
184 | mText.append(i18n("<p><b>Priority:</b> %2</p>") | 192 | mText.append(i18n("<p><b>Priority:</b> %2</p>") |
185 | .arg(QString::number(event->priority()))); | 193 | .arg(QString::number(event->priority()))); |
186 | 194 | ||
187 | if ( event->percentComplete() == 100 && event->hasCompletedDate() ) { | 195 | addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); |
188 | mText.append(i18n("<p><i>Completed on %1</i></p>") | ||
189 | .arg( event->completedStr() )); | ||
190 | } else { | ||
191 | mText.append(i18n("<p><i>%1 % completed</i></p>") | ||
192 | .arg(event->percentComplete())); | ||
193 | } | ||
194 | |||
195 | addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); | ||
196 | formatCategories(event); | 196 | formatCategories(event); |
197 | if (!event->description().isEmpty()) { | 197 | if (!event->description().isEmpty()) { |
198 | addTag("p",i18n("<b>Details: </b>")); | 198 | addTag("p",i18n("<b>Details: </b>")); |
199 | addTag("p",event->description()); | 199 | addTag("p",event->description()); |
200 | } | 200 | } |
201 | 201 | ||
202 | 202 | ||
203 | 203 | ||
204 | formatReadOnly(event); | 204 | formatReadOnly(event); |
205 | formatAttendees(event); | 205 | formatAttendees(event); |
206 | 206 | ||
207 | } | 207 | } |
208 | 208 | ||
209 | void KIncidenceFormatter::setJournal(Journal* ) | 209 | void KIncidenceFormatter::setJournal(Journal* ) |
210 | { | 210 | { |
211 | 211 | ||
212 | } | 212 | } |
213 | 213 | ||
214 | void KIncidenceFormatter::formatCategories(Incidence *event) | 214 | void KIncidenceFormatter::formatCategories(Incidence *event) |
215 | { | 215 | { |
216 | if (!event->categoriesStr().isEmpty()) { | 216 | if (!event->categoriesStr().isEmpty()) { |
217 | addTag("p",i18n("<b>Categories: </b>")+event->categoriesStr() ); | 217 | addTag("p",i18n("<b>Categories: </b>")+event->categoriesStr() ); |
218 | //mText.append(event->categoriesStr()); | 218 | //mText.append(event->categoriesStr()); |
219 | } | 219 | } |
220 | } | 220 | } |
221 | void KIncidenceFormatter::addTag(const QString & tag,const QString & text) | 221 | void KIncidenceFormatter::addTag(const QString & tag,const QString & text) |
222 | { | 222 | { |
223 | int number=text.contains("\n"); | 223 | int number=text.contains("\n"); |
224 | QString str = "<" + tag + ">"; | 224 | QString str = "<" + tag + ">"; |
225 | QString tmpText=text; | 225 | QString tmpText=text; |
226 | QString tmpStr=str; | 226 | QString tmpStr=str; |
227 | if(number !=-1) | 227 | if(number !=-1) |
228 | { | 228 | { |
229 | if (number > 0) { | 229 | if (number > 0) { |
230 | int pos=0; | 230 | int pos=0; |
231 | QString tmp; | 231 | QString tmp; |
232 | for(int i=0;i<=number;i++) { | 232 | for(int i=0;i<=number;i++) { |
233 | pos=tmpText.find("\n"); | 233 | pos=tmpText.find("\n"); |
234 | tmp=tmpText.left(pos); | 234 | tmp=tmpText.left(pos); |
235 | tmpText=tmpText.right(tmpText.length()-pos-1); | 235 | tmpText=tmpText.right(tmpText.length()-pos-1); |
236 | tmpStr+=tmp+"<br>"; | 236 | tmpStr+=tmp+"<br>"; |
237 | } | 237 | } |
238 | } | 238 | } |
239 | else tmpStr += tmpText; | 239 | else tmpStr += tmpText; |
240 | tmpStr+="</" + tag + ">"; | 240 | tmpStr+="</" + tag + ">"; |
241 | mText.append(tmpStr); | 241 | mText.append(tmpStr); |
242 | } | 242 | } |
243 | else | 243 | else |
244 | { | 244 | { |
245 | str += text + "</" + tag + ">"; | 245 | str += text + "</" + tag + ">"; |
246 | mText.append(str); | 246 | mText.append(str); |
247 | } | 247 | } |
248 | } | 248 | } |
249 | 249 | ||
250 | void KIncidenceFormatter::formatAttendees(Incidence *event) | 250 | void KIncidenceFormatter::formatAttendees(Incidence *event) |
251 | { | 251 | { |
252 | QPtrList<Attendee> attendees = event->attendees(); | 252 | QPtrList<Attendee> attendees = event->attendees(); |
253 | if (attendees.count()) { | 253 | if (attendees.count()) { |
254 | QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); | 254 | QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); |
255 | QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small); | 255 | QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small); |
256 | addTag("h3",i18n("Organizer")); | 256 | addTag("h3",i18n("Organizer")); |
257 | mText.append("<ul><li>"); | 257 | mText.append("<ul><li>"); |
258 | #if 0 | 258 | #if 0 |
259 | //ndef KORG_NOKABC | 259 | //ndef KORG_NOKABC |
260 | 260 | ||
261 | KABC::AddressBook *add_book = KABC::StdAddressBook::self(); | 261 | KABC::AddressBook *add_book = KABC::StdAddressBook::self(); |
262 | KABC::Addressee::List addressList; | 262 | KABC::Addressee::List addressList; |
263 | addressList = add_book->findByEmail(event->organizer()); | 263 | addressList = add_book->findByEmail(event->organizer()); |
264 | KABC::Addressee o = addressList.first(); | 264 | KABC::Addressee o = addressList.first(); |
265 | if (!o.isEmpty() && addressList.size()<2) { | 265 | if (!o.isEmpty() && addressList.size()<2) { |
266 | mText += "<a href=\"uid:" + o.uid() + "\">"; | 266 | mText += "<a href=\"uid:" + o.uid() + "\">"; |
267 | mText += o.formattedName(); | 267 | mText += o.formattedName(); |
268 | mText += "</a>\n"; | 268 | mText += "</a>\n"; |
269 | } else { | 269 | } else { |
270 | mText.append(event->organizer()); | 270 | mText.append(event->organizer()); |
271 | } | 271 | } |
272 | #else | 272 | #else |
273 | mText.append(event->organizer()); | 273 | mText.append(event->organizer()); |
274 | #endif | 274 | #endif |
275 | if (iconPath) { | 275 | if (iconPath) { |
276 | mText += " <a href=\"mailto:" + event->organizer() + "\">"; | 276 | mText += " <a href=\"mailto:" + event->organizer() + "\">"; |
277 | mText += "<IMG src=\"" + iconPath + "\">"; | 277 | mText += "<IMG src=\"" + iconPath + "\">"; |
278 | mText += "</a>\n"; | 278 | mText += "</a>\n"; |
279 | } | 279 | } |
280 | mText.append("</li></ul>"); | 280 | mText.append("</li></ul>"); |
281 | 281 | ||
282 | addTag("h3",i18n("Attendees")); | 282 | addTag("h3",i18n("Attendees")); |
283 | Attendee *a; | 283 | Attendee *a; |
284 | mText.append("<ul>"); | 284 | mText.append("<ul>"); |
285 | for(a=attendees.first();a;a=attendees.next()) { | 285 | for(a=attendees.first();a;a=attendees.next()) { |
286 | #if 0 | 286 | #if 0 |
287 | //ndef KORG_NOKABC | 287 | //ndef KORG_NOKABC |
288 | if (a->name().isEmpty()) { | 288 | if (a->name().isEmpty()) { |
289 | addressList = add_book->findByEmail(a->email()); | 289 | addressList = add_book->findByEmail(a->email()); |
290 | KABC::Addressee o = addressList.first(); | 290 | KABC::Addressee o = addressList.first(); |
291 | if (!o.isEmpty() && addressList.size()<2) { | 291 | if (!o.isEmpty() && addressList.size()<2) { |
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp index 7362bdf..7d04793 100644 --- a/libkcal/todo.cpp +++ b/libkcal/todo.cpp | |||
@@ -207,173 +207,174 @@ void Todo::setHasDueDate(bool f) | |||
207 | } | 207 | } |
208 | 208 | ||
209 | 209 | ||
210 | #if 0 | 210 | #if 0 |
211 | void Todo::setStatus(const QString &statStr) | 211 | void Todo::setStatus(const QString &statStr) |
212 | { | 212 | { |
213 | if (mReadOnly) return; | 213 | if (mReadOnly) return; |
214 | QString ss(statStr.upper()); | 214 | QString ss(statStr.upper()); |
215 | 215 | ||
216 | if (ss == "X-ACTION") | 216 | if (ss == "X-ACTION") |
217 | mStatus = NEEDS_ACTION; | 217 | mStatus = NEEDS_ACTION; |
218 | else if (ss == "NEEDS ACTION") | 218 | else if (ss == "NEEDS ACTION") |
219 | mStatus = NEEDS_ACTION; | 219 | mStatus = NEEDS_ACTION; |
220 | else if (ss == "ACCEPTED") | 220 | else if (ss == "ACCEPTED") |
221 | mStatus = ACCEPTED; | 221 | mStatus = ACCEPTED; |
222 | else if (ss == "SENT") | 222 | else if (ss == "SENT") |
223 | mStatus = SENT; | 223 | mStatus = SENT; |
224 | else if (ss == "TENTATIVE") | 224 | else if (ss == "TENTATIVE") |
225 | mStatus = TENTATIVE; | 225 | mStatus = TENTATIVE; |
226 | else if (ss == "CONFIRMED") | 226 | else if (ss == "CONFIRMED") |
227 | mStatus = CONFIRMED; | 227 | mStatus = CONFIRMED; |
228 | else if (ss == "DECLINED") | 228 | else if (ss == "DECLINED") |
229 | mStatus = DECLINED; | 229 | mStatus = DECLINED; |
230 | else if (ss == "COMPLETED") | 230 | else if (ss == "COMPLETED") |
231 | mStatus = COMPLETED; | 231 | mStatus = COMPLETED; |
232 | else if (ss == "DELEGATED") | 232 | else if (ss == "DELEGATED") |
233 | mStatus = DELEGATED; | 233 | mStatus = DELEGATED; |
234 | 234 | ||
235 | updated(); | 235 | updated(); |
236 | } | 236 | } |
237 | 237 | ||
238 | void Todo::setStatus(int status) | 238 | void Todo::setStatus(int status) |
239 | { | 239 | { |
240 | if (mReadOnly) return; | 240 | if (mReadOnly) return; |
241 | mStatus = status; | 241 | mStatus = status; |
242 | updated(); | 242 | updated(); |
243 | } | 243 | } |
244 | 244 | ||
245 | int Todo::status() const | 245 | int Todo::status() const |
246 | { | 246 | { |
247 | return mStatus; | 247 | return mStatus; |
248 | } | 248 | } |
249 | 249 | ||
250 | QString Todo::statusStr() const | 250 | QString Todo::statusStr() const |
251 | { | 251 | { |
252 | switch(mStatus) { | 252 | switch(mStatus) { |
253 | case NEEDS_ACTION: | 253 | case NEEDS_ACTION: |
254 | return QString("NEEDS ACTION"); | 254 | return QString("NEEDS ACTION"); |
255 | break; | 255 | break; |
256 | case ACCEPTED: | 256 | case ACCEPTED: |
257 | return QString("ACCEPTED"); | 257 | return QString("ACCEPTED"); |
258 | break; | 258 | break; |
259 | case SENT: | 259 | case SENT: |
260 | return QString("SENT"); | 260 | return QString("SENT"); |
261 | break; | 261 | break; |
262 | case TENTATIVE: | 262 | case TENTATIVE: |
263 | return QString("TENTATIVE"); | 263 | return QString("TENTATIVE"); |
264 | break; | 264 | break; |
265 | case CONFIRMED: | 265 | case CONFIRMED: |
266 | return QString("CONFIRMED"); | 266 | return QString("CONFIRMED"); |
267 | break; | 267 | break; |
268 | case DECLINED: | 268 | case DECLINED: |
269 | return QString("DECLINED"); | 269 | return QString("DECLINED"); |
270 | break; | 270 | break; |
271 | case COMPLETED: | 271 | case COMPLETED: |
272 | return QString("COMPLETED"); | 272 | return QString("COMPLETED"); |
273 | break; | 273 | break; |
274 | case DELEGATED: | 274 | case DELEGATED: |
275 | return QString("DELEGATED"); | 275 | return QString("DELEGATED"); |
276 | break; | 276 | break; |
277 | } | 277 | } |
278 | return QString(""); | 278 | return QString(""); |
279 | } | 279 | } |
280 | #endif | 280 | #endif |
281 | 281 | ||
282 | bool Todo::isCompleted() const | 282 | bool Todo::isCompleted() const |
283 | { | 283 | { |
284 | if (mPercentComplete == 100) return true; | 284 | if (mPercentComplete == 100) return true; |
285 | else return false; | 285 | else return false; |
286 | } | 286 | } |
287 | 287 | ||
288 | void Todo::setCompleted(bool completed) | 288 | void Todo::setCompleted(bool completed) |
289 | { | 289 | { |
290 | if (completed) mPercentComplete = 100; | 290 | if (completed) mPercentComplete = 100; |
291 | else { | 291 | else { |
292 | mPercentComplete = 0; | 292 | mPercentComplete = 0; |
293 | mHasCompletedDate = false; | 293 | mHasCompletedDate = false; |
294 | } | 294 | } |
295 | updated(); | 295 | updated(); |
296 | } | 296 | } |
297 | 297 | ||
298 | QDateTime Todo::completed() const | 298 | QDateTime Todo::completed() const |
299 | { | 299 | { |
300 | return mCompleted; | 300 | return mCompleted; |
301 | } | 301 | } |
302 | 302 | ||
303 | QString Todo::completedStr() const | 303 | QString Todo::completedStr( bool shortF ) const |
304 | { | 304 | { |
305 | return KGlobal::locale()->formatDateTime(mCompleted); | 305 | return KGlobal::locale()->formatDateTime(mCompleted, shortF); |
306 | } | 306 | } |
307 | 307 | ||
308 | void Todo::setCompleted(const QDateTime &completed) | 308 | void Todo::setCompleted(const QDateTime &completed) |
309 | { | 309 | { |
310 | qDebug("Todo::setCompleted "); | ||
310 | mHasCompletedDate = true; | 311 | mHasCompletedDate = true; |
311 | mPercentComplete = 100; | 312 | mPercentComplete = 100; |
312 | mCompleted = getEvenTime(completed); | 313 | mCompleted = getEvenTime(completed); |
313 | updated(); | 314 | updated(); |
314 | } | 315 | } |
315 | 316 | ||
316 | bool Todo::hasCompletedDate() const | 317 | bool Todo::hasCompletedDate() const |
317 | { | 318 | { |
318 | return mHasCompletedDate; | 319 | return mHasCompletedDate; |
319 | } | 320 | } |
320 | 321 | ||
321 | int Todo::percentComplete() const | 322 | int Todo::percentComplete() const |
322 | { | 323 | { |
323 | return mPercentComplete; | 324 | return mPercentComplete; |
324 | } | 325 | } |
325 | 326 | ||
326 | void Todo::setPercentComplete(int v) | 327 | void Todo::setPercentComplete(int v) |
327 | { | 328 | { |
328 | mPercentComplete = v; | 329 | mPercentComplete = v; |
329 | if ( v != 100 ) | 330 | if ( v != 100 ) |
330 | mHasCompletedDate = false; | 331 | mHasCompletedDate = false; |
331 | updated(); | 332 | updated(); |
332 | } | 333 | } |
333 | QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset ) const | 334 | QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset ) const |
334 | { | 335 | { |
335 | if ( isCompleted() || ! hasDueDate() || cancelled() ) { | 336 | if ( isCompleted() || ! hasDueDate() || cancelled() ) { |
336 | *ok = false; | 337 | *ok = false; |
337 | return QDateTime (); | 338 | return QDateTime (); |
338 | } | 339 | } |
339 | QDateTime incidenceStart; | 340 | QDateTime incidenceStart; |
340 | incidenceStart = dtDue(); | 341 | incidenceStart = dtDue(); |
341 | bool enabled = false; | 342 | bool enabled = false; |
342 | Alarm* alarm; | 343 | Alarm* alarm; |
343 | int off; | 344 | int off; |
344 | QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; | 345 | QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; |
345 | // if ( QDateTime::currentDateTime() > incidenceStart ){ | 346 | // if ( QDateTime::currentDateTime() > incidenceStart ){ |
346 | // *ok = false; | 347 | // *ok = false; |
347 | // return incidenceStart; | 348 | // return incidenceStart; |
348 | // } | 349 | // } |
349 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { | 350 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { |
350 | if (alarm->enabled()) { | 351 | if (alarm->enabled()) { |
351 | if ( alarm->hasTime () ) { | 352 | if ( alarm->hasTime () ) { |
352 | if ( alarm->time() < alarmStart ) { | 353 | if ( alarm->time() < alarmStart ) { |
353 | alarmStart = alarm->time(); | 354 | alarmStart = alarm->time(); |
354 | enabled = true; | 355 | enabled = true; |
355 | off = alarmStart.secsTo( incidenceStart ); | 356 | off = alarmStart.secsTo( incidenceStart ); |
356 | } | 357 | } |
357 | 358 | ||
358 | } else { | 359 | } else { |
359 | int secs = alarm->startOffset().asSeconds(); | 360 | int secs = alarm->startOffset().asSeconds(); |
360 | if ( incidenceStart.addSecs( secs ) < alarmStart ) { | 361 | if ( incidenceStart.addSecs( secs ) < alarmStart ) { |
361 | alarmStart = incidenceStart.addSecs( secs ); | 362 | alarmStart = incidenceStart.addSecs( secs ); |
362 | enabled = true; | 363 | enabled = true; |
363 | off = -secs; | 364 | off = -secs; |
364 | } | 365 | } |
365 | } | 366 | } |
366 | } | 367 | } |
367 | } | 368 | } |
368 | if ( enabled ) { | 369 | if ( enabled ) { |
369 | if ( alarmStart > QDateTime::currentDateTime() ) { | 370 | if ( alarmStart > QDateTime::currentDateTime() ) { |
370 | *ok = true; | 371 | *ok = true; |
371 | * offset = off; | 372 | * offset = off; |
372 | return alarmStart; | 373 | return alarmStart; |
373 | } | 374 | } |
374 | } | 375 | } |
375 | *ok = false; | 376 | *ok = false; |
376 | return QDateTime (); | 377 | return QDateTime (); |
377 | 378 | ||
378 | } | 379 | } |
379 | 380 | ||
diff --git a/libkcal/todo.h b/libkcal/todo.h index 0f22c59..41f5841 100644 --- a/libkcal/todo.h +++ b/libkcal/todo.h | |||
@@ -1,122 +1,122 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | #ifndef TODO_H | 20 | #ifndef TODO_H |
21 | #define TODO_H | 21 | #define TODO_H |
22 | // | 22 | // |
23 | // Todo component, representing a VTODO object | 23 | // Todo component, representing a VTODO object |
24 | // | 24 | // |
25 | 25 | ||
26 | #include "incidence.h" | 26 | #include "incidence.h" |
27 | 27 | ||
28 | namespace KCal { | 28 | namespace KCal { |
29 | 29 | ||
30 | /** | 30 | /** |
31 | This class provides a Todo in the sense of RFC2445. | 31 | This class provides a Todo in the sense of RFC2445. |
32 | */ | 32 | */ |
33 | class Todo : public Incidence | 33 | class Todo : public Incidence |
34 | { | 34 | { |
35 | public: | 35 | public: |
36 | Todo(); | 36 | Todo(); |
37 | Todo(const Todo &); | 37 | Todo(const Todo &); |
38 | ~Todo(); | 38 | ~Todo(); |
39 | typedef ListBase<Todo> List; | 39 | typedef ListBase<Todo> List; |
40 | QCString type() const { return "Todo"; } | 40 | QCString type() const { return "Todo"; } |
41 | 41 | ||
42 | /** Return an exact copy of this todo. */ | 42 | /** Return an exact copy of this todo. */ |
43 | Incidence *clone(); | 43 | Incidence *clone(); |
44 | QDateTime getNextAlarmDateTime( bool * ok, int * offset ) const; | 44 | QDateTime getNextAlarmDateTime( bool * ok, int * offset ) const; |
45 | 45 | ||
46 | /** for setting the todo's due date/time with a QDateTime. */ | 46 | /** for setting the todo's due date/time with a QDateTime. */ |
47 | void setDtDue(const QDateTime &dtDue); | 47 | void setDtDue(const QDateTime &dtDue); |
48 | /** returns an event's Due date/time as a QDateTime. */ | 48 | /** returns an event's Due date/time as a QDateTime. */ |
49 | QDateTime dtDue() const; | 49 | QDateTime dtDue() const; |
50 | /** returns an event's due time as a string formatted according to the | 50 | /** returns an event's due time as a string formatted according to the |
51 | users locale settings */ | 51 | users locale settings */ |
52 | QString dtDueTimeStr() const; | 52 | QString dtDueTimeStr() const; |
53 | /** returns an event's due date as a string formatted according to the | 53 | /** returns an event's due date as a string formatted according to the |
54 | users locale settings */ | 54 | users locale settings */ |
55 | QString dtDueDateStr(bool shortfmt=true) const; | 55 | QString dtDueDateStr(bool shortfmt=true) const; |
56 | /** returns an event's due date and time as a string formatted according | 56 | /** returns an event's due date and time as a string formatted according |
57 | to the users locale settings */ | 57 | to the users locale settings */ |
58 | QString dtDueStr(bool shortfmt=true) const; | 58 | QString dtDueStr(bool shortfmt=true) const; |
59 | 59 | ||
60 | /** returns TRUE or FALSE depending on whether the todo has a due date */ | 60 | /** returns TRUE or FALSE depending on whether the todo has a due date */ |
61 | bool hasDueDate() const; | 61 | bool hasDueDate() const; |
62 | /** sets the event's hasDueDate value. */ | 62 | /** sets the event's hasDueDate value. */ |
63 | void setHasDueDate(bool f); | 63 | void setHasDueDate(bool f); |
64 | 64 | ||
65 | 65 | ||
66 | /** sets the event's status to the string specified. The string | 66 | /** sets the event's status to the string specified. The string |
67 | * must be a recognized value for the status field, i.e. a string | 67 | * must be a recognized value for the status field, i.e. a string |
68 | * equivalent of the possible status enumerations previously described. */ | 68 | * equivalent of the possible status enumerations previously described. */ |
69 | // void setStatus(const QString &statStr); | 69 | // void setStatus(const QString &statStr); |
70 | /** sets the event's status to the value specified. See the enumeration | 70 | /** sets the event's status to the value specified. See the enumeration |
71 | * above for possible values. */ | 71 | * above for possible values. */ |
72 | // void setStatus(int); | 72 | // void setStatus(int); |
73 | /** return the event's status. */ | 73 | /** return the event's status. */ |
74 | // int status() const; | 74 | // int status() const; |
75 | /** return the event's status in string format. */ | 75 | /** return the event's status in string format. */ |
76 | // QString statusStr() const; | 76 | // QString statusStr() const; |
77 | 77 | ||
78 | /** return, if this todo is completed */ | 78 | /** return, if this todo is completed */ |
79 | bool isCompleted() const; | 79 | bool isCompleted() const; |
80 | /** set completed state of this todo */ | 80 | /** set completed state of this todo */ |
81 | void setCompleted(bool); | 81 | void setCompleted(bool); |
82 | 82 | ||
83 | /** | 83 | /** |
84 | Return how many percent of the task are completed. Returns a value | 84 | Return how many percent of the task are completed. Returns a value |
85 | between 0 and 100. | 85 | between 0 and 100. |
86 | */ | 86 | */ |
87 | int percentComplete() const; | 87 | int percentComplete() const; |
88 | /** | 88 | /** |
89 | Set how many percent of the task are completed. Valid values are in the | 89 | Set how many percent of the task are completed. Valid values are in the |
90 | range from 0 to 100. | 90 | range from 0 to 100. |
91 | */ | 91 | */ |
92 | void setPercentComplete(int); | 92 | void setPercentComplete(int); |
93 | 93 | ||
94 | /** return date and time when todo was completed */ | 94 | /** return date and time when todo was completed */ |
95 | QDateTime completed() const; | 95 | QDateTime completed() const; |
96 | QString completedStr() const; | 96 | QString completedStr(bool shortF = true) const; |
97 | /** set date and time of completion */ | 97 | /** set date and time of completion */ |
98 | void setCompleted(const QDateTime &completed); | 98 | void setCompleted(const QDateTime &completed); |
99 | 99 | ||
100 | /** Return true, if todo has a date associated with completion */ | 100 | /** Return true, if todo has a date associated with completion */ |
101 | bool hasCompletedDate() const; | 101 | bool hasCompletedDate() const; |
102 | bool contains ( Todo*); | 102 | bool contains ( Todo*); |
103 | 103 | ||
104 | private: | 104 | private: |
105 | bool accept(Visitor &v) { return v.visit(this); } | 105 | bool accept(Visitor &v) { return v.visit(this); } |
106 | 106 | ||
107 | QDateTime mDtDue; // due date of todo | 107 | QDateTime mDtDue; // due date of todo |
108 | 108 | ||
109 | bool mHasDueDate; // if todo has associated due date | 109 | bool mHasDueDate; // if todo has associated due date |
110 | 110 | ||
111 | // int mStatus; // confirmed/delegated/tentative/etc | 111 | // int mStatus; // confirmed/delegated/tentative/etc |
112 | 112 | ||
113 | QDateTime mCompleted; | 113 | QDateTime mCompleted; |
114 | bool mHasCompletedDate; | 114 | bool mHasCompletedDate; |
115 | 115 | ||
116 | int mPercentComplete; | 116 | int mPercentComplete; |
117 | }; | 117 | }; |
118 | 118 | ||
119 | bool operator==( const Todo&, const Todo& ); | 119 | bool operator==( const Todo&, const Todo& ); |
120 | } | 120 | } |
121 | 121 | ||
122 | #endif | 122 | #endif |