summaryrefslogtreecommitdiffabout
path: root/korganizer/koagenda.cpp
Unidiff
Diffstat (limited to 'korganizer/koagenda.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagenda.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index 002234d..7c41cab 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -1373,155 +1373,160 @@ void KOAgenda::hideUnused()
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
1382KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view) 1382KOAgendaItem *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}
1406KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) 1406KOAgendaItem * 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
1419void KOAgenda::updateTodo( Todo * todo, int days, bool remove) 1419void 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*/
1504KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom) 1509KOAgendaItem *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);