summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagenda.cpp2
-rw-r--r--korganizer/koagendaview.cpp3
-rw-r--r--korganizer/koeditorgeneraltodo.h1
-rw-r--r--korganizer/kotodoeditor.cpp12
4 files changed, 13 insertions, 5 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index 7c41cab..0aef929 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -1344,257 +1344,257 @@ int KOAgenda::timeToY(const QTime &time)
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*/
1349QTime KOAgenda::gyToTime(int gy) 1349QTime 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
1366void KOAgenda::setStartHour(int startHour) 1366void 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}
1371void KOAgenda::hideUnused() 1371void 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
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 // ( todo->hasCompletedDate() && todo->completed().date() == currentDate )|| 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; 1460 QDateTime dt;
1461 if ( todo->hasCompletedDate() ) 1461 if ( todo->hasCompletedDate() )
1462 dt = todo->completed(); 1462 dt = todo->completed();
1463 else 1463 else
1464 dt = todo->dtDue(); 1464 dt = todo->dtDue();
1465 if ( overdue ) { 1465 if ( overdue ) {
1466 currentDate = QDate::currentDate(); 1466 currentDate = QDate::currentDate();
1467 days += todo->dtDue().date().daysTo( currentDate ); 1467 days += todo->dtDue().date().daysTo( currentDate );
1468 } 1468 }
1469 else 1469 else
1470 currentDate = dt.date(); 1470 currentDate = dt.date();
1471 1471
1472 if ( todo->doesFloat() || overdue ) { 1472 if (( todo->doesFloat() || overdue) && !todo->hasCompletedDate() ) {
1473 if ( ! mAllDayMode ) return; 1473 if ( ! mAllDayMode ) return;
1474 // aldayagenda 1474 // aldayagenda
1475 globalFlagBlockAgendaItemPaint = 1; 1475 globalFlagBlockAgendaItemPaint = 1;
1476 item = insertAllDayItem(todo, currentDate,days, days); 1476 item = insertAllDayItem(todo, currentDate,days, days);
1477 item->show(); 1477 item->show();
1478 1478
1479 } 1479 }
1480 else { 1480 else {
1481 if ( mAllDayMode ) return; 1481 if ( mAllDayMode ) return;
1482 // mAgenda 1482 // mAgenda
1483 globalFlagBlockAgendaItemPaint = 1; 1483 globalFlagBlockAgendaItemPaint = 1;
1484 int endY = timeToY(dt.time()) - 1; 1484 int endY = timeToY(dt.time()) - 1;
1485 int hi = 12/KOPrefs::instance()->mHourSize; 1485 int hi = 12/KOPrefs::instance()->mHourSize;
1486 int startY = endY - 1-hi; 1486 int startY = endY - 1-hi;
1487 item = insertItem(todo,currentDate,days,startY,endY); 1487 item = insertItem(todo,currentDate,days,startY,endY);
1488 item->show(); 1488 item->show();
1489 } 1489 }
1490 qApp->processEvents(); 1490 qApp->processEvents();
1491 globalFlagBlockAgendaItemPaint = 0; 1491 globalFlagBlockAgendaItemPaint = 0;
1492 QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); 1492 QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems();
1493 KOAgendaItem *itemit; 1493 KOAgendaItem *itemit;
1494 for ( itemit=oldconflictItems.first(); itemit != 0; 1494 for ( itemit=oldconflictItems.first(); itemit != 0;
1495 itemit=oldconflictItems.next() ) { 1495 itemit=oldconflictItems.next() ) {
1496 globalFlagBlockAgendaItemUpdate = 0; 1496 globalFlagBlockAgendaItemUpdate = 0;
1497 itemit->repaintMe(); 1497 itemit->repaintMe();
1498 globalFlagBlockAgendaItemUpdate = 1; 1498 globalFlagBlockAgendaItemUpdate = 1;
1499 itemit->repaint(); 1499 itemit->repaint();
1500 } 1500 }
1501 globalFlagBlockAgendaItemUpdate = 0; 1501 globalFlagBlockAgendaItemUpdate = 0;
1502 item->repaintMe(); 1502 item->repaintMe();
1503 globalFlagBlockAgendaItemUpdate = 1; 1503 globalFlagBlockAgendaItemUpdate = 1;
1504 item->repaint(); 1504 item->repaint();
1505} 1505}
1506/* 1506/*
1507 Insert KOAgendaItem into agenda. 1507 Insert KOAgendaItem into agenda.
1508*/ 1508*/
1509KOAgendaItem *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)
1510{ 1510{
1511 //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;
1512 1512
1513 if (mAllDayMode) { 1513 if (mAllDayMode) {
1514 kdDebug() << "KOAgenda: calling insertItem in all-day mode is illegal." << endl; 1514 kdDebug() << "KOAgenda: calling insertItem in all-day mode is illegal." << endl;
1515 return 0; 1515 return 0;
1516 } 1516 }
1517 1517
1518 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); 1518 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport());
1519 //agendaItem->setFrameStyle(WinPanel|Raised); 1519 //agendaItem->setFrameStyle(WinPanel|Raised);
1520 1520
1521 int YSize = YBottom - YTop + 1; 1521 int YSize = YBottom - YTop + 1;
1522 if (YSize < 0) { 1522 if (YSize < 0) {
1523 kdDebug() << "KOAgenda::insertItem(): Text: " << agendaItem->text() << " YSize<0" << endl; 1523 kdDebug() << "KOAgenda::insertItem(): Text: " << agendaItem->text() << " YSize<0" << endl;
1524 YSize = 1; 1524 YSize = 1;
1525 } 1525 }
1526 int iheight = mGridSpacingY * YSize; 1526 int iheight = mGridSpacingY * YSize;
1527 1527
1528 agendaItem->resize(mGridSpacingX,iheight ); 1528 agendaItem->resize(mGridSpacingX,iheight );
1529 agendaItem->setCellXY(X,YTop,YBottom); 1529 agendaItem->setCellXY(X,YTop,YBottom);
1530 agendaItem->setCellXWidth(X); 1530 agendaItem->setCellXWidth(X);
1531 1531
1532 //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY); 1532 //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY);
1533 mItems.append(agendaItem); 1533 mItems.append(agendaItem);
1534 1534
1535 placeSubCells(agendaItem); 1535 placeSubCells(agendaItem);
1536 1536
1537 //agendaItem->show(); 1537 //agendaItem->show();
1538 1538
1539 marcus_bains(); 1539 marcus_bains();
1540 1540
1541 return agendaItem; 1541 return agendaItem;
1542} 1542}
1543 1543
1544 1544
1545/* 1545/*
1546 Insert all-day KOAgendaItem into agenda. 1546 Insert all-day KOAgendaItem into agenda.
1547*/ 1547*/
1548KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd) 1548KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd)
1549{ 1549{
1550 if (!mAllDayMode) { 1550 if (!mAllDayMode) {
1551 return 0; 1551 return 0;
1552 } 1552 }
1553 1553
1554 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); 1554 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport());
1555 1555
1556 agendaItem->setCellXY(XBegin,0,0); 1556 agendaItem->setCellXY(XBegin,0,0);
1557 agendaItem->setCellXWidth(XEnd); 1557 agendaItem->setCellXWidth(XEnd);
1558 agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY); 1558 agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY);
1559 1559
1560 //addChild(agendaItem,XBegin*mGridSpacingX,0); 1560 //addChild(agendaItem,XBegin*mGridSpacingX,0);
1561 mItems.append(agendaItem); 1561 mItems.append(agendaItem);
1562 1562
1563 placeSubCells(agendaItem); 1563 placeSubCells(agendaItem);
1564 1564
1565 //agendaItem->show(); 1565 //agendaItem->show();
1566 1566
1567 return agendaItem; 1567 return agendaItem;
1568} 1568}
1569 1569
1570 1570
1571void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, 1571void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd,
1572 int YTop,int YBottom) 1572 int YTop,int YBottom)
1573{ 1573{
1574 if (mAllDayMode) { 1574 if (mAllDayMode) {
1575 ; 1575 ;
1576 return; 1576 return;
1577 } 1577 }
1578 1578
1579 int cellX,cellYTop,cellYBottom; 1579 int cellX,cellYTop,cellYBottom;
1580 QString newtext; 1580 QString newtext;
1581 int width = XEnd - XBegin + 1; 1581 int width = XEnd - XBegin + 1;
1582 int count = 0; 1582 int count = 0;
1583 KOAgendaItem *current = 0; 1583 KOAgendaItem *current = 0;
1584 QPtrList<KOAgendaItem> multiItems; 1584 QPtrList<KOAgendaItem> multiItems;
1585 for (cellX = XBegin;cellX <= XEnd;++cellX) { 1585 for (cellX = XBegin;cellX <= XEnd;++cellX) {
1586 if (cellX == XBegin) cellYTop = YTop; 1586 if (cellX == XBegin) cellYTop = YTop;
1587 else cellYTop = 0; 1587 else cellYTop = 0;
1588 if (cellX == XEnd) cellYBottom = YBottom; 1588 if (cellX == XEnd) cellYBottom = YBottom;
1589 else cellYBottom = rows() - 1; 1589 else cellYBottom = rows() - 1;
1590 newtext = QString("(%1/%2): ").arg(++count).arg(width); 1590 newtext = QString("(%1/%2): ").arg(++count).arg(width);
1591 newtext.append(event->summary()); 1591 newtext.append(event->summary());
1592 current = insertItem(event,qd,cellX,cellYTop,cellYBottom); 1592 current = insertItem(event,qd,cellX,cellYTop,cellYBottom);
1593 current->setText(newtext); 1593 current->setText(newtext);
1594 multiItems.append(current); 1594 multiItems.append(current);
1595 } 1595 }
1596 1596
1597 KOAgendaItem *next = 0; 1597 KOAgendaItem *next = 0;
1598 KOAgendaItem *last = multiItems.last(); 1598 KOAgendaItem *last = multiItems.last();
1599 KOAgendaItem *first = multiItems.first(); 1599 KOAgendaItem *first = multiItems.first();
1600 KOAgendaItem *setFirst,*setLast; 1600 KOAgendaItem *setFirst,*setLast;
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index 42a6f7c..8b79788 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -1382,168 +1382,167 @@ void KOAgendaView::writeSettings(KConfig *config)
1382 config->setGroup("Views"); 1382 config->setGroup("Views");
1383 1383
1384 //#ifndef KORG_NOSPLITTER 1384 //#ifndef KORG_NOSPLITTER
1385 QValueList<int> list = mSplitterAgenda->sizes(); 1385 QValueList<int> list = mSplitterAgenda->sizes();
1386 config->writeEntry("Separator AgendaView",list); 1386 config->writeEntry("Separator AgendaView",list);
1387 //qDebug("write %d %d ", list[0],list[1] ); 1387 //qDebug("write %d %d ", list[0],list[1] );
1388 //#endif 1388 //#endif
1389} 1389}
1390 1390
1391void KOAgendaView::setHolidayMasks() 1391void KOAgendaView::setHolidayMasks()
1392{ 1392{
1393 mHolidayMask.resize(mSelectedDates.count()); 1393 mHolidayMask.resize(mSelectedDates.count());
1394 1394
1395 uint i; 1395 uint i;
1396 for(i=0;i<mSelectedDates.count();++i) { 1396 for(i=0;i<mSelectedDates.count();++i) {
1397 QDate date = mSelectedDates[i]; 1397 QDate date = mSelectedDates[i];
1398 bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6); 1398 bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6);
1399 bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7); 1399 bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7);
1400 bool showHoliday = false; 1400 bool showHoliday = false;
1401 if ( KOPrefs::instance()->mExcludeHolidays ) { 1401 if ( KOPrefs::instance()->mExcludeHolidays ) {
1402 QPtrList<Event> events = calendar()->events( date, true ); 1402 QPtrList<Event> events = calendar()->events( date, true );
1403 Event *event; 1403 Event *event;
1404 for( event = events.first(); event; event = events.next() ) { 1404 for( event = events.first(); event; event = events.next() ) {
1405 if ( event->categories().contains("Holiday") || 1405 if ( event->categories().contains("Holiday") ||
1406 event->categories().contains(i18n("Holiday"))) { 1406 event->categories().contains(i18n("Holiday"))) {
1407 showHoliday = true; 1407 showHoliday = true;
1408 break; 1408 break;
1409 } 1409 }
1410 } 1410 }
1411 1411
1412 } 1412 }
1413 1413
1414#ifndef KORG_NOPLUGINS 1414#ifndef KORG_NOPLUGINS
1415 bool showHoliday = KOPrefs::instance()->mExcludeHolidays && 1415 bool showHoliday = KOPrefs::instance()->mExcludeHolidays &&
1416 !KOCore::self()->holiday(date).isEmpty(); 1416 !KOCore::self()->holiday(date).isEmpty();
1417#endif 1417#endif
1418 bool showDay = showSaturday || showSunday || showHoliday; 1418 bool showDay = showSaturday || showSunday || showHoliday;
1419 1419
1420 if (showDay) { 1420 if (showDay) {
1421 mHolidayMask.at(i) = true; 1421 mHolidayMask.at(i) = true;
1422 } else { 1422 } else {
1423 mHolidayMask.at(i) = false; 1423 mHolidayMask.at(i) = false;
1424 } 1424 }
1425 } 1425 }
1426 1426
1427 mAgenda->setHolidayMask(&mHolidayMask); 1427 mAgenda->setHolidayMask(&mHolidayMask);
1428 mAllDayAgenda->setHolidayMask(&mHolidayMask); 1428 mAllDayAgenda->setHolidayMask(&mHolidayMask);
1429} 1429}
1430 1430
1431void KOAgendaView::setContentsPos(int y) 1431void KOAgendaView::setContentsPos(int y)
1432{ 1432{
1433 mAgenda->setContentsPos(0,y); 1433 mAgenda->setContentsPos(0,y);
1434} 1434}
1435 1435
1436void KOAgendaView::setExpandedButton( bool expanded ) 1436void KOAgendaView::setExpandedButton( bool expanded )
1437{ 1437{
1438 if ( expanded ) { 1438 if ( expanded ) {
1439 mExpandButton->setPixmap( mExpandedPixmap ); 1439 mExpandButton->setPixmap( mExpandedPixmap );
1440 } else { 1440 } else {
1441 mExpandButton->setPixmap( mNotExpandedPixmap ); 1441 mExpandButton->setPixmap( mNotExpandedPixmap );
1442 } 1442 }
1443} 1443}
1444 1444
1445void KOAgendaView::clearSelection() 1445void KOAgendaView::clearSelection()
1446{ 1446{
1447 mAgenda->deselectItem(); 1447 mAgenda->deselectItem();
1448 mAllDayAgenda->deselectItem(); 1448 mAllDayAgenda->deselectItem();
1449} 1449}
1450 1450
1451void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart, 1451void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart,
1452 int gxEnd, int gyEnd) 1452 int gxEnd, int gyEnd)
1453{ 1453{
1454 mTimeSpanInAllDay = true; 1454 mTimeSpanInAllDay = true;
1455 newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd); 1455 newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd);
1456} 1456}
1457 1457
1458 1458
1459 1459
1460 1460
1461void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart, 1461void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart,
1462 int gxEnd, int gyEnd) 1462 int gxEnd, int gyEnd)
1463{ 1463{
1464 if (!mSelectedDates.count()) return; 1464 if (!mSelectedDates.count()) return;
1465 1465
1466 QDate dayStart = mSelectedDates[gxStart]; 1466 QDate dayStart = mSelectedDates[gxStart];
1467 QDate dayEnd = mSelectedDates[gxEnd]; 1467 QDate dayEnd = mSelectedDates[gxEnd];
1468 1468
1469 QTime timeStart = mAgenda->gyToTime(gyStart); 1469 QTime timeStart = mAgenda->gyToTime(gyStart);
1470 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); 1470 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 );
1471 1471
1472 QDateTime dtStart(dayStart,timeStart); 1472 QDateTime dtStart(dayStart,timeStart);
1473 QDateTime dtEnd(dayEnd,timeEnd); 1473 QDateTime dtEnd(dayEnd,timeEnd);
1474 1474
1475 mTimeSpanBegin = dtStart; 1475 mTimeSpanBegin = dtStart;
1476 mTimeSpanEnd = dtEnd; 1476 mTimeSpanEnd = dtEnd;
1477 1477
1478} 1478}
1479 1479
1480void KOAgendaView::deleteSelectedDateTime() 1480void KOAgendaView::deleteSelectedDateTime()
1481{ 1481{
1482 mTimeSpanBegin.setDate(QDate()); 1482 mTimeSpanBegin.setDate(QDate());
1483 mTimeSpanEnd.setDate(QDate()); 1483 mTimeSpanEnd.setDate(QDate());
1484 mTimeSpanInAllDay = false; 1484 mTimeSpanInAllDay = false;
1485} 1485}
1486 1486
1487void KOAgendaView::keyPressEvent ( QKeyEvent * e ) 1487void KOAgendaView::keyPressEvent ( QKeyEvent * e )
1488{ 1488{
1489 e->ignore(); 1489 e->ignore();
1490} 1490}
1491 1491
1492void KOAgendaView::scrollOneHourUp() 1492void KOAgendaView::scrollOneHourUp()
1493{ 1493{
1494 1494
1495 mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 ); 1495 mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 );
1496} 1496}
1497void KOAgendaView::scrollOneHourDown() 1497void KOAgendaView::scrollOneHourDown()
1498{ 1498{
1499 mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 ); 1499 mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 );
1500} 1500}
1501 1501
1502void KOAgendaView::setStartHour( int h ) 1502void KOAgendaView::setStartHour( int h )
1503{ 1503{
1504 mAgenda->setStartHour( h ); 1504 mAgenda->setStartHour( h );
1505 1505
1506} 1506}
1507 1507
1508void KOAgendaView::updateTodo( Todo * t, int ) 1508void KOAgendaView::updateTodo( Todo * t, int )
1509{ 1509{
1510
1511 bool remove = false; 1510 bool remove = false;
1512 bool removeAD = false; 1511 bool removeAD = false;
1513 QDate da; 1512 QDate da;
1514 if ( t->hasCompletedDate() ) 1513 if ( t->hasCompletedDate() )
1515 da = t->completed().date(); 1514 da = t->completed().date();
1516 else 1515 else
1517 da = t->dtDue().date(); 1516 da = t->dtDue().date();
1518 if ( ! t->hasDueDate() && !t->hasCompletedDate() ) { 1517 if ( ! t->hasDueDate() && !t->hasCompletedDate() ) {
1519 remove = true; 1518 remove = true;
1520 removeAD = true; 1519 removeAD = true;
1521 } 1520 }
1522 else { 1521 else {
1523 bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ; 1522 bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ;
1524 if ( overdue && 1523 if ( overdue &&
1525 QDate::currentDate() >= mSelectedDates.first() && 1524 QDate::currentDate() >= mSelectedDates.first() &&
1526 QDate::currentDate() <= mSelectedDates.last()) { 1525 QDate::currentDate() <= mSelectedDates.last()) {
1527 removeAD = false; 1526 removeAD = false;
1528 remove = true; 1527 remove = true;
1529 } 1528 }
1530 else { 1529 else {
1531 1530
1532 if ( da < mSelectedDates.first() || 1531 if ( da < mSelectedDates.first() ||
1533 da > mSelectedDates.last() ) { 1532 da > mSelectedDates.last() ) {
1534 remove = true; 1533 remove = true;
1535 removeAD = true; 1534 removeAD = true;
1536 } else { 1535 } else {
1537 remove = t->doesFloat() && !t->hasCompletedDate(); 1536 remove = t->doesFloat() && !t->hasCompletedDate();
1538 removeAD = !remove; 1537 removeAD = !remove;
1539 } 1538 }
1540 } 1539 }
1541 } 1540 }
1542 int days = mSelectedDates.first().daysTo( da ); 1541 int days = mSelectedDates.first().daysTo( da );
1543 // qDebug("daysto %d ", days ); 1542 //qDebug("daysto %d %d %d", days, remove,removeAD );
1544 mAgenda->updateTodo( t , days, remove); 1543 mAgenda->updateTodo( t , days, remove);
1545 if ( KOPrefs::instance()->mShowTodoInAgenda ) 1544 if ( KOPrefs::instance()->mShowTodoInAgenda )
1546 mAllDayAgenda->updateTodo( t , days, removeAD); 1545 mAllDayAgenda->updateTodo( t , days, removeAD);
1547 //qDebug("KOAgendaView::updateTodo( Todo *, int ) "); 1546 //qDebug("KOAgendaView::updateTodo( Todo *, int ) ");
1548 1547
1549} 1548}
diff --git a/korganizer/koeditorgeneraltodo.h b/korganizer/koeditorgeneraltodo.h
index f6c30f8..5f1c3cc 100644
--- a/korganizer/koeditorgeneraltodo.h
+++ b/korganizer/koeditorgeneraltodo.h
@@ -1,105 +1,106 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23#ifndef _KOEDITORGENERALTODO_H 23#ifndef _KOEDITORGENERALTODO_H
24#define _KOEDITORGENERALTODO_H 24#define _KOEDITORGENERALTODO_H
25 25
26#include <qframe.h> 26#include <qframe.h>
27#include <qlabel.h> 27#include <qlabel.h>
28#include <qcheckbox.h> 28#include <qcheckbox.h>
29#include <qpushbutton.h> 29#include <qpushbutton.h>
30#include <qgroupbox.h> 30#include <qgroupbox.h>
31#include <qlineedit.h> 31#include <qlineedit.h>
32#include <qcombobox.h> 32#include <qcombobox.h>
33#include <qmultilineedit.h> 33#include <qmultilineedit.h>
34#include <qlistview.h> 34#include <qlistview.h>
35#include <qradiobutton.h> 35#include <qradiobutton.h>
36 36
37#include "koeditorgeneral.h" 37#include "koeditorgeneral.h"
38#include "koglobals.h" 38#include "koglobals.h"
39 39
40class KRestrictedLine; 40class KRestrictedLine;
41 41
42class KDateEdit; 42class KDateEdit;
43 43
44using namespace KCal; 44using namespace KCal;
45 45
46class KOEditorGeneralTodo : public KOEditorGeneral 46class KOEditorGeneralTodo : public KOEditorGeneral
47{ 47{
48 Q_OBJECT 48 Q_OBJECT
49 public: 49 public:
50 KOEditorGeneralTodo (QObject* parent=0,const char* name=0); 50 KOEditorGeneralTodo (QObject* parent=0,const char* name=0);
51 virtual ~KOEditorGeneralTodo(); 51 virtual ~KOEditorGeneralTodo();
52 52
53 void initTime(QWidget *, QBoxLayout *); 53 void initTime(QWidget *, QBoxLayout *);
54 void initStatus(QWidget *, QBoxLayout *); 54 void initStatus(QWidget *, QBoxLayout *);
55 void initCompletion(QWidget *, QBoxLayout *); 55 void initCompletion(QWidget *, QBoxLayout *);
56 void initPriority(QWidget *, QBoxLayout *); 56 void initPriority(QWidget *, QBoxLayout *);
57 57
58 void finishSetup(); 58 void finishSetup();
59 59
60 /** Set widgets to default values */ 60 /** Set widgets to default values */
61 void setDefaults(QDateTime due,bool allDay); 61 void setDefaults(QDateTime due,bool allDay);
62 /** Read todo object and setup widgets accordingly */ 62 /** Read todo object and setup widgets accordingly */
63 void readTodo(Todo *); 63 void readTodo(Todo *);
64 /** Write todo settings to event object */ 64 /** Write todo settings to event object */
65 void writeTodo(Todo *); 65 void writeTodo(Todo *);
66 66
67 /** Check if the input is valid. */ 67 /** Check if the input is valid. */
68 bool validateInput(); 68 bool validateInput();
69 69
70 /** The todo has been modified externally */ 70 /** The todo has been modified externally */
71 void modified (Todo*, int); 71 void modified (Todo*, int);
72 72
73 signals: 73 signals:
74 void openCategoryDialog(); 74 void openCategoryDialog();
75 75
76 protected slots: 76 protected slots:
77 void completedChanged(int); 77 void completedChanged(int);
78 78
79 void enableDueEdit( bool enable ); 79 void enableDueEdit( bool enable );
80 void enableStartEdit( bool enable ); 80 void enableStartEdit( bool enable );
81 void enableTimeEdits( bool enable ); 81 void enableTimeEdits( bool enable );
82 void showAlarm(); 82 void showAlarm();
83 83
84 protected: 84 protected:
85 void setCompletedDate(); 85 void setCompletedDate();
86 86
87 private: 87 private:
88 friend class KOTodoEditor;
88 KDateEdit *mStartDateEdit; 89 KDateEdit *mStartDateEdit;
89 KOTimeEdit *mStartTimeEdit; 90 KOTimeEdit *mStartTimeEdit;
90 QCheckBox *mTimeButton; 91 QCheckBox *mTimeButton;
91 QCheckBox *mDueCheck; 92 QCheckBox *mDueCheck;
92 KDateEdit *mDueDateEdit; 93 KDateEdit *mDueDateEdit;
93 KOTimeEdit *mDueTimeEdit; 94 KOTimeEdit *mDueTimeEdit;
94 QComboBox *mCompletedCombo; 95 QComboBox *mCompletedCombo;
95 QLabel *mCompletedLabel; 96 QLabel *mCompletedLabel;
96 QLabel *mPriorityLabel; 97 QLabel *mPriorityLabel;
97 QComboBox *mPriorityCombo; 98 QComboBox *mPriorityCombo;
98 99
99 QCheckBox *mStartCheck; 100 QCheckBox *mStartCheck;
100 101
101 QDateTime mCompleted; 102 QDateTime mCompleted;
102}; 103};
103 104
104 105
105#endif 106#endif
diff --git a/korganizer/kotodoeditor.cpp b/korganizer/kotodoeditor.cpp
index 16c19a4..ec5c2d1 100644
--- a/korganizer/kotodoeditor.cpp
+++ b/korganizer/kotodoeditor.cpp
@@ -1,375 +1,383 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 1997, 1998 Preston Brown 3 Copyright (c) 1997, 1998 Preston Brown
4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution. 22 without including the source code for Qt in the source distribution.
23*/ 23*/
24 24
25#include <qtooltip.h> 25#include <qtooltip.h>
26#include <qframe.h> 26#include <qframe.h>
27#include <qpixmap.h> 27#include <qpixmap.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#include <qhbox.h> 29#include <qhbox.h>
30#include <qdir.h> 30#include <qdir.h>
31#include <qdatetime.h> 31#include <qdatetime.h>
32#include <qapplication.h> 32#include <qapplication.h>
33 33
34#include <kiconloader.h> 34#include <kiconloader.h>
35#include <klocale.h> 35#include <klocale.h>
36#include <kfiledialog.h> 36#include <kfiledialog.h>
37#include <kstandarddirs.h> 37#include <kstandarddirs.h>
38#include <kmessagebox.h> 38#include <kmessagebox.h>
39 39
40#include <libkdepim/categoryselectdialog.h> 40#include <libkdepim/categoryselectdialog.h>
41#include <libkcal/calendarlocal.h> 41#include <libkcal/calendarlocal.h>
42#include <libkcal/calendarresources.h> 42#include <libkcal/calendarresources.h>
43#include <libkcal/resourcecalendar.h> 43#include <libkcal/resourcecalendar.h>
44#include <libkcal/icalformat.h> 44#include <libkcal/icalformat.h>
45#include <kresources/resourceselectdialog.h> 45#include <kresources/resourceselectdialog.h>
46 46
47#include "koprefs.h" 47#include "koprefs.h"
48#include "kolocationbox.h"
48 49
49#include "kotodoeditor.h" 50#include "kotodoeditor.h"
50extern int globalFlagBlockAgenda; 51extern int globalFlagBlockAgenda;
51 52
52KOTodoEditor::KOTodoEditor( Calendar *calendar, QWidget *parent ) : 53KOTodoEditor::KOTodoEditor( Calendar *calendar, QWidget *parent ) :
53 KOIncidenceEditor( i18n("Edit To-Do"), calendar, parent ) 54 KOIncidenceEditor( i18n("Edit To-Do"), calendar, parent )
54{ 55{
55 mTodo = 0; 56 mTodo = 0;
56 mRelatedTodo = 0; 57 mRelatedTodo = 0;
57 findButton(User1)->hide(); 58 findButton(User1)->hide();
58 init(); 59 init();
59} 60}
60 61
61KOTodoEditor::~KOTodoEditor() 62KOTodoEditor::~KOTodoEditor()
62{ 63{
63 emit dialogClose( mTodo ); 64 emit dialogClose( mTodo );
64} 65}
65 66
66void KOTodoEditor::init() 67void KOTodoEditor::init()
67{ 68{
68 setupGeneral(); 69 setupGeneral();
69 setupAttendeesTab(); 70 setupAttendeesTab();
70} 71}
71void KOTodoEditor::setCategories( QString s ) 72void KOTodoEditor::setCategories( QString s )
72{ 73{
73 mGeneral->setCategories(s); 74 mGeneral->setCategories(s);
74} 75}
75void KOTodoEditor::setSecrecy( int sec ) 76void KOTodoEditor::setSecrecy( int sec )
76{ 77{
77 mGeneral->setSecrecy( sec ); 78 mGeneral->setSecrecy( sec );
78} 79}
79void KOTodoEditor::reload() 80void KOTodoEditor::reload()
80{ 81{
81 if ( mTodo ) readTodo( mTodo ); 82 if ( mTodo ) readTodo( mTodo );
82} 83}
83 84
84void KOTodoEditor::setupGeneral() 85void KOTodoEditor::setupGeneral()
85{ 86{
86 mGeneral = new KOEditorGeneralTodo(this); 87 mGeneral = new KOEditorGeneralTodo(this);
87 connect ( mGeneral, SIGNAL ( allAccepted() ), this, SLOT ( slotOk () ) ); 88 connect ( mGeneral, SIGNAL ( allAccepted() ), this, SLOT ( slotOk () ) );
88 89
89 // connect(mGeneral,SIGNAL(openCategoryDialog()),mCategoryDialog,SLOT(show())); 90 // connect(mGeneral,SIGNAL(openCategoryDialog()),mCategoryDialog,SLOT(show()));
90 //connect(mCategoryDialog, SIGNAL(categoriesSelected(const QString &)), 91 //connect(mCategoryDialog, SIGNAL(categoriesSelected(const QString &)),
91 // mGeneral,SLOT(setCategories(const QString &))); 92 // mGeneral,SLOT(setCategories(const QString &)));
92 93
93 if (KOPrefs::instance()->mCompactDialogs) { 94 if (KOPrefs::instance()->mCompactDialogs) {
94 QFrame *topFrame = addPage(i18n("General")); 95 QFrame *topFrame = addPage(i18n("General"));
95 96
96 QBoxLayout *topLayout = new QVBoxLayout(topFrame); 97 QBoxLayout *topLayout = new QVBoxLayout(topFrame);
97 if ( QApplication::desktop()->width() < 480 ) { 98 if ( QApplication::desktop()->width() < 480 ) {
98 topLayout->setMargin(1); 99 topLayout->setMargin(1);
99 topLayout->setSpacing(1); 100 topLayout->setSpacing(1);
100 } else { 101 } else {
101 topLayout->setMargin(marginHint()-1); 102 topLayout->setMargin(marginHint()-1);
102 topLayout->setSpacing(spacingHint()-1); 103 topLayout->setSpacing(spacingHint()-1);
103 } 104 }
104 mGeneral->initHeader(topFrame,topLayout); 105 mGeneral->initHeader(topFrame,topLayout);
105 mGeneral->initTime(topFrame,topLayout); 106 mGeneral->initTime(topFrame,topLayout);
106 mGeneral->initAlarm(topFrame,topLayout); 107 mGeneral->initAlarm(topFrame,topLayout);
107 mGeneral->enableAlarm( false ); 108 mGeneral->enableAlarm( false );
108 109
109 110
110 QBoxLayout *priorityLayout; 111 QBoxLayout *priorityLayout;
111 if ( QApplication::desktop()->width() < 500 ) 112 if ( QApplication::desktop()->width() < 500 )
112 priorityLayout = new QVBoxLayout( topLayout ); 113 priorityLayout = new QVBoxLayout( topLayout );
113 else 114 else
114 priorityLayout = new QHBoxLayout( topLayout ); 115 priorityLayout = new QHBoxLayout( topLayout );
115 QWidget* prioWidget = new QWidget (topFrame); 116 QWidget* prioWidget = new QWidget (topFrame);
116 priorityLayout->addWidget( prioWidget ); 117 priorityLayout->addWidget( prioWidget );
117 QHBoxLayout* priorityLayout2 = new QHBoxLayout( prioWidget); 118 QHBoxLayout* priorityLayout2 = new QHBoxLayout( prioWidget);
118 119
119 120
120 QIconSet icon; 121 QIconSet icon;
121 if ( QApplication::desktop()->width() < 321 ) 122 if ( QApplication::desktop()->width() < 321 )
122 icon = SmallIcon("fileexport16"); 123 icon = SmallIcon("fileexport16");
123 else 124 else
124 icon = SmallIcon("fileexport"); 125 icon = SmallIcon("fileexport");
125 QPushButton * saveTemplate = new QPushButton( prioWidget); 126 QPushButton * saveTemplate = new QPushButton( prioWidget);
126 saveTemplate->setIconSet (icon ) ; 127 saveTemplate->setIconSet (icon ) ;
127 int size = saveTemplate->sizeHint().height(); 128 int size = saveTemplate->sizeHint().height();
128 saveTemplate->setFixedSize( size, size ); 129 saveTemplate->setFixedSize( size, size );
129 if ( QApplication::desktop()->width() < 321 ) 130 if ( QApplication::desktop()->width() < 321 )
130 icon = SmallIcon("fileimport16"); 131 icon = SmallIcon("fileimport16");
131 else 132 else
132 icon = SmallIcon("fileimport"); 133 icon = SmallIcon("fileimport");
133 QPushButton * loadTemplate = new QPushButton( prioWidget); 134 QPushButton * loadTemplate = new QPushButton( prioWidget);
134 loadTemplate->setIconSet (icon ) ; 135 loadTemplate->setIconSet (icon ) ;
135 loadTemplate->setFixedSize( size, size ); 136 loadTemplate->setFixedSize( size, size );
136 137
137 priorityLayout2->addWidget(loadTemplate); 138 priorityLayout2->addWidget(loadTemplate);
138 priorityLayout2->addWidget(saveTemplate); 139 priorityLayout2->addWidget(saveTemplate);
139 mGeneral->initPriority(prioWidget,priorityLayout2); 140 mGeneral->initPriority(prioWidget,priorityLayout2);
140 mGeneral->initCategories( topFrame, priorityLayout ); 141 mGeneral->initCategories( topFrame, priorityLayout );
141 topLayout->addStretch(1); 142 topLayout->addStretch(1);
142 143
143 QFrame *topFrame2 = addPage(i18n("Details")); 144 QFrame *topFrame2 = addPage(i18n("Details"));
144 145
145 QBoxLayout *topLayout2 = new QVBoxLayout(topFrame2); 146 QBoxLayout *topLayout2 = new QVBoxLayout(topFrame2);
146 topLayout2->setMargin(marginHint()); 147 topLayout2->setMargin(marginHint());
147 topLayout2->setSpacing(spacingHint()); 148 topLayout2->setSpacing(spacingHint());
148 149
149 QHBoxLayout *completionLayout = new QHBoxLayout( topLayout2 ); 150 QHBoxLayout *completionLayout = new QHBoxLayout( topLayout2 );
150 mGeneral->initCompletion(topFrame2,completionLayout); 151 mGeneral->initCompletion(topFrame2,completionLayout);
151 152
152 153
153 mGeneral->initSecrecy( topFrame2, topLayout2 ); 154 mGeneral->initSecrecy( topFrame2, topLayout2 );
154 mGeneral->initDescription(topFrame2,topLayout2); 155 mGeneral->initDescription(topFrame2,topLayout2);
155 156
156 // QHBox * hb = new QHBox ( topFrame2 ); 157 // QHBox * hb = new QHBox ( topFrame2 );
157 // topLayout2->addWidget(hb); 158 // topLayout2->addWidget(hb);
158 // hb->setSpacing( 3 ); 159 // hb->setSpacing( 3 );
159 160
160 connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); 161 connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) );
161 connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); 162 connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) );
162 163
163 } else { 164 } else {
164 QFrame *topFrame = addPage(i18n("General")); 165 QFrame *topFrame = addPage(i18n("General"));
165 166
166 QBoxLayout *topLayout = new QVBoxLayout(topFrame); 167 QBoxLayout *topLayout = new QVBoxLayout(topFrame);
167 topLayout->setSpacing(spacingHint()); 168 topLayout->setSpacing(spacingHint());
168 169
169 mGeneral->initHeader(topFrame,topLayout); 170 mGeneral->initHeader(topFrame,topLayout);
170 mGeneral->initTime(topFrame,topLayout); 171 mGeneral->initTime(topFrame,topLayout);
171 mGeneral->initStatus(topFrame,topLayout); 172 mGeneral->initStatus(topFrame,topLayout);
172 QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout); 173 QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout);
173 mGeneral->initAlarm(topFrame,alarmLineLayout); 174 mGeneral->initAlarm(topFrame,alarmLineLayout);
174 mGeneral->initDescription(topFrame,topLayout); 175 mGeneral->initDescription(topFrame,topLayout);
175 QBoxLayout *detailsLayout = new QHBoxLayout(topLayout); 176 QBoxLayout *detailsLayout = new QHBoxLayout(topLayout);
176 mGeneral->initCategories( topFrame, detailsLayout ); 177 mGeneral->initCategories( topFrame, detailsLayout );
177 mGeneral->initSecrecy( topFrame, detailsLayout ); 178 mGeneral->initSecrecy( topFrame, detailsLayout );
178 } 179 }
179 mGeneral->finishSetup(); 180 mGeneral->finishSetup();
180 181
181} 182}
182 183
183void KOTodoEditor::editTodo(Todo *todo, bool editDescription) 184void KOTodoEditor::editTodo(Todo *todo, bool editDescription)
184{ 185{
185 //init(); 186 //init();
186 187
187 mTodo = todo; 188 mTodo = todo;
188 readTodo(mTodo); 189 readTodo(mTodo);
189 if ( editDescription ) { 190 if ( editDescription ) {
190 showPage( 1 ); 191 showPage( 1 );
191 mGeneral->setFocusOn( 1 ); 192 mGeneral->setFocusOn( 1 );
192 } else { 193 } else {
193 showPage( 0 ); 194 showPage( 0 );
194 mGeneral->setFocusOn( 2 ); 195 mGeneral->setFocusOn( 2 );
195 } 196 }
196} 197}
197 198
198void KOTodoEditor::newTodo(QDateTime due,Todo *relatedTodo,bool allDay) 199void KOTodoEditor::newTodo(QDateTime due,Todo *relatedTodo,bool allDay)
199{ 200{
200 //init(); 201 //init();
201 202
202 mTodo = 0; 203 mTodo = 0;
203 setDefaults(due,relatedTodo,allDay); 204 setDefaults(due,relatedTodo,allDay);
204} 205}
205 206
206void KOTodoEditor::loadDefaults() 207void KOTodoEditor::loadDefaults()
207{ 208{
208 setDefaults(QDateTime::currentDateTime().addDays(7),0,false); 209 setDefaults(QDateTime::currentDateTime().addDays(7),0,false);
209} 210}
210 211
211bool KOTodoEditor::processInput( bool emitTime ) 212bool KOTodoEditor::processInput( bool emitTime )
212{ 213{
213 if (!validateInput()) return false; 214 if (!validateInput()) return false;
214 215
215 Todo *todo = 0; 216 Todo *todo = 0;
216 217
217 if (mTodo) todo = mTodo; 218 if (mTodo) todo = mTodo;
218 else { 219 else {
219 todo = new Todo; 220 todo = new Todo;
220 todo->setOrganizer(KOPrefs::instance()->email()); 221 todo->setOrganizer(KOPrefs::instance()->email());
221 } 222 }
222 223
223 writeTodo(todo); 224 writeTodo(todo);
224 if ( emitTime ) { 225 if ( emitTime ) {
225 globalFlagBlockAgenda = 1; 226 globalFlagBlockAgenda = 1;
226 emit showAgendaView( false ); 227 emit showAgendaView( false );
227 if ( todo->hasDueDate() ) 228 if ( todo->hasDueDate() )
228 emit jumpToTime( todo->dtDue().date() ); 229 emit jumpToTime( todo->dtDue().date() );
229 globalFlagBlockAgenda = 2; 230 globalFlagBlockAgenda = 2;
230 } 231 }
231 if (mTodo) { 232 if (mTodo) {
232 todo->setRevision(todo->revision()+1); 233 todo->setRevision(todo->revision()+1);
233 emit todoChanged(todo); 234 emit todoChanged(todo);
234 } else { 235 } else {
235 mCalendar->addTodo(todo); 236 mCalendar->addTodo(todo);
236 mTodo = todo; 237 mTodo = todo;
237 emit todoAdded(todo); 238 emit todoAdded(todo);
238 } 239 }
239 240
240 return true; 241 return true;
241} 242}
242 243
243void KOTodoEditor::deleteTodo() 244void KOTodoEditor::deleteTodo()
244{ 245{
245 if (mTodo) { 246 if (mTodo) {
246 if (KOPrefs::instance()->mConfirm) { 247 if (KOPrefs::instance()->mConfirm) {
247 switch (msgItemDelete()) { 248 switch (msgItemDelete()) {
248 case KMessageBox::Continue: // OK 249 case KMessageBox::Continue: // OK
249 emit todoToBeDeleted(mTodo); 250 emit todoToBeDeleted(mTodo);
250 emit dialogClose(mTodo); 251 emit dialogClose(mTodo);
251 mCalendar->deleteTodo(mTodo); 252 mCalendar->deleteTodo(mTodo);
252 emit todoDeleted(); 253 emit todoDeleted();
253 reject(); 254 reject();
254 break; 255 break;
255 } 256 }
256 } 257 }
257 else { 258 else {
258 emit todoToBeDeleted(mTodo); 259 emit todoToBeDeleted(mTodo);
259 emit dialogClose(mTodo); 260 emit dialogClose(mTodo);
260 mCalendar->deleteTodo(mTodo); 261 mCalendar->deleteTodo(mTodo);
261 emit todoDeleted(); 262 emit todoDeleted();
262 reject(); 263 reject();
263 } 264 }
264 } else { 265 } else {
265 reject(); 266 reject();
266 } 267 }
267} 268}
268 269
269void KOTodoEditor::setDefaults(QDateTime due,Todo *relatedEvent,bool allDay) 270void KOTodoEditor::setDefaults(QDateTime due,Todo *relatedEvent,bool allDay)
270{ 271{
271 mRelatedTodo = relatedEvent; 272 mRelatedTodo = relatedEvent;
272 273
273 mGeneral->setDefaults(due,allDay); 274 mGeneral->setDefaults(due,allDay);
274 mDetails->setDefaults(); 275 mDetails->setDefaults();
275 showPage( 0 ); 276 showPage( 0 );
276 if ( mRelatedTodo ) { 277 if ( mRelatedTodo ) {
277 mGeneral->setCategories (mRelatedTodo->categoriesStr ()); 278 mGeneral->setCategories (mRelatedTodo->categoriesStr ());
278 mGeneral->setSecrecy (mRelatedTodo->secrecy ()); 279 mGeneral->setSecrecy (mRelatedTodo->secrecy ());
280 if ( mRelatedTodo->priority() < 3 )
281 mGeneral->mPriorityCombo->setCurrentItem(mRelatedTodo->priority()-1);
282 mGeneral->mSummaryEdit->lineEdit()->setText(mRelatedTodo->summary()+": ");
283 int len = mRelatedTodo->summary().length();
284 mGeneral->mSummaryEdit->lineEdit()->setSelection ( 0, len+2 );
285 mGeneral->mSummaryEdit->lineEdit()->setCursorPosition ( len+2 );
286 mGeneral->mSummaryEdit->lineEdit()->setFocus();
279 287
280 } 288 } else
281 mGeneral->setFocusOn( 2 ); 289 mGeneral->setFocusOn( 2 );
282} 290}
283 291
284void KOTodoEditor::readTodo(Todo *todo) 292void KOTodoEditor::readTodo(Todo *todo)
285{ 293{
286 mGeneral->readTodo(todo); 294 mGeneral->readTodo(todo);
287 mDetails->readEvent(todo); 295 mDetails->readEvent(todo);
288 mRelatedTodo = 0;//todo->relatedTo(); 296 mRelatedTodo = 0;//todo->relatedTo();
289 // categories 297 // categories
290 // mCategoryDialog->setSelected(todo->categories()); 298 // mCategoryDialog->setSelected(todo->categories());
291 299
292 // We should handle read-only events here. 300 // We should handle read-only events here.
293} 301}
294 302
295void KOTodoEditor::writeTodo(Todo *event) 303void KOTodoEditor::writeTodo(Todo *event)
296{ 304{
297 mGeneral->writeTodo(event); 305 mGeneral->writeTodo(event);
298 mDetails->writeEvent(event); 306 mDetails->writeEvent(event);
299 307
300 // set related event, i.e. parent to-do in this case. 308 // set related event, i.e. parent to-do in this case.
301 if (mRelatedTodo) { 309 if (mRelatedTodo) {
302 event->setRelatedTo(mRelatedTodo); 310 event->setRelatedTo(mRelatedTodo);
303 } 311 }
304} 312}
305 313
306bool KOTodoEditor::validateInput() 314bool KOTodoEditor::validateInput()
307{ 315{
308 if (!mGeneral->validateInput()) return false; 316 if (!mGeneral->validateInput()) return false;
309 if (!mDetails->validateInput()) return false; 317 if (!mDetails->validateInput()) return false;
310 return true; 318 return true;
311} 319}
312 320
313int KOTodoEditor::msgItemDelete() 321int KOTodoEditor::msgItemDelete()
314{ 322{
315 return KMessageBox::warningContinueCancel(this, 323 return KMessageBox::warningContinueCancel(this,
316 i18n("This item will be permanently deleted."), 324 i18n("This item will be permanently deleted."),
317 i18n("KOrganizer Confirmation"),i18n("Delete")); 325 i18n("KOrganizer Confirmation"),i18n("Delete"));
318} 326}
319 327
320void KOTodoEditor::modified (int modification) 328void KOTodoEditor::modified (int modification)
321{ 329{
322 if (modification == KOGlobals::CATEGORY_MODIFIED || 330 if (modification == KOGlobals::CATEGORY_MODIFIED ||
323 KOGlobals::UNKNOWN_MODIFIED == modification ) 331 KOGlobals::UNKNOWN_MODIFIED == modification )
324 // mCategoryDialog->setSelected (mTodo->categories ()); 332 // mCategoryDialog->setSelected (mTodo->categories ());
325 mGeneral->modified (mTodo, modification); 333 mGeneral->modified (mTodo, modification);
326 334
327} 335}
328 336
329void KOTodoEditor::slotLoadTemplate() 337void KOTodoEditor::slotLoadTemplate()
330{ 338{
331 339
332 QString fileName =locateLocal( "templates", "todos" ); 340 QString fileName =locateLocal( "templates", "todos" );
333 QDir t_dir; 341 QDir t_dir;
334 if ( !t_dir.exists(fileName) ) 342 if ( !t_dir.exists(fileName) )
335 t_dir.mkdir ( fileName ); 343 t_dir.mkdir ( fileName );
336 fileName += "/todo"; 344 fileName += "/todo";
337 fileName = KFileDialog::getSaveFileName( fileName , "Load Todo template", this ); 345 fileName = KFileDialog::getSaveFileName( fileName , "Load Todo template", this );
338 if ( fileName.length() == 0 ) 346 if ( fileName.length() == 0 )
339 return; 347 return;
340 CalendarLocal cal; 348 CalendarLocal cal;
341 ICalFormat format; 349 ICalFormat format;
342 if ( !format.load( &cal, fileName ) ) { 350 if ( !format.load( &cal, fileName ) ) {
343 KMessageBox::error( this, i18n("Error loading template file\n '%1'.") 351 KMessageBox::error( this, i18n("Error loading template file\n '%1'.")
344 .arg( fileName ) ); 352 .arg( fileName ) );
345 return ; 353 return ;
346 } 354 }
347 QPtrList<Todo> todos = cal.todos(); 355 QPtrList<Todo> todos = cal.todos();
348 Todo * todo = todos.first(); 356 Todo * todo = todos.first();
349 if ( !todo ) { 357 if ( !todo ) {
350 KMessageBox::error( this, 358 KMessageBox::error( this,
351 i18n("Template does not\ncontain a valid Todo.")); 359 i18n("Template does not\ncontain a valid Todo."));
352 } else { 360 } else {
353 readTodo( todo ); 361 readTodo( todo );
354 } 362 }
355 363
356} 364}
357 365
358void KOTodoEditor::slotSaveTemplate() 366void KOTodoEditor::slotSaveTemplate()
359{ 367{
360 QString fileName =locateLocal( "templates", "todos" ); 368 QString fileName =locateLocal( "templates", "todos" );
361 QDir t_dir; 369 QDir t_dir;
362 if ( !t_dir.exists(fileName) ) 370 if ( !t_dir.exists(fileName) )
363 t_dir.mkdir ( fileName ); 371 t_dir.mkdir ( fileName );
364 fileName += "/todo"; 372 fileName += "/todo";
365 fileName = KFileDialog::getSaveFileName( fileName , "Save as Todo template", this ); 373 fileName = KFileDialog::getSaveFileName( fileName , "Save as Todo template", this );
366 if ( fileName.length() > 0 ) 374 if ( fileName.length() > 0 )
367 saveTemplate( fileName ); 375 saveTemplate( fileName );
368} 376}
369 377
370void KOTodoEditor::saveTemplate( const QString &templateName ) 378void KOTodoEditor::saveTemplate( const QString &templateName )
371{ 379{
372 Todo *todo = new Todo; 380 Todo *todo = new Todo;
373 writeTodo( todo ); 381 writeTodo( todo );
374 saveAsTemplate( todo, templateName ); 382 saveAsTemplate( todo, templateName );
375} 383}