-rw-r--r-- | korganizer/koagenda.cpp | 2 | ||||
-rw-r--r-- | korganizer/koagendaitem.cpp | 6 |
2 files changed, 4 insertions, 4 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index eb3791e..7e0b216 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp | |||
@@ -1251,686 +1251,686 @@ void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// i | |||
1251 | mPixPainter.end() ; | 1251 | mPixPainter.end() ; |
1252 | } | 1252 | } |
1253 | 1253 | ||
1254 | /* | 1254 | /* |
1255 | Convert srcollview contents coordinates to agenda grid coordinates. | 1255 | Convert srcollview contents coordinates to agenda grid coordinates. |
1256 | */ | 1256 | */ |
1257 | void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy) | 1257 | void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy) |
1258 | { | 1258 | { |
1259 | gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX : | 1259 | gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX : |
1260 | x/mGridSpacingX; | 1260 | x/mGridSpacingX; |
1261 | gy = y/mGridSpacingY; | 1261 | gy = y/mGridSpacingY; |
1262 | } | 1262 | } |
1263 | 1263 | ||
1264 | /* | 1264 | /* |
1265 | Convert agenda grid coordinates to scrollview contents coordinates. | 1265 | Convert agenda grid coordinates to scrollview contents coordinates. |
1266 | */ | 1266 | */ |
1267 | void KOAgenda::gridToContents (int gx, int gy, int& x, int& y) | 1267 | void KOAgenda::gridToContents (int gx, int gy, int& x, int& y) |
1268 | { | 1268 | { |
1269 | x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX: | 1269 | x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX: |
1270 | gx*mGridSpacingX; | 1270 | gx*mGridSpacingX; |
1271 | y = gy*mGridSpacingY; | 1271 | y = gy*mGridSpacingY; |
1272 | } | 1272 | } |
1273 | 1273 | ||
1274 | 1274 | ||
1275 | /* | 1275 | /* |
1276 | Return Y coordinate corresponding to time. Coordinates are rounded to fit into | 1276 | Return Y coordinate corresponding to time. Coordinates are rounded to fit into |
1277 | the grid. | 1277 | the grid. |
1278 | */ | 1278 | */ |
1279 | int KOAgenda::timeToY(const QTime &time) | 1279 | int KOAgenda::timeToY(const QTime &time) |
1280 | { | 1280 | { |
1281 | int minutesPerCell = 24 * 60 / mRows; | 1281 | int minutesPerCell = 24 * 60 / mRows; |
1282 | int timeMinutes = time.hour() * 60 + time.minute(); | 1282 | int timeMinutes = time.hour() * 60 + time.minute(); |
1283 | int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell; | 1283 | int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell; |
1284 | return Y; | 1284 | return Y; |
1285 | } | 1285 | } |
1286 | 1286 | ||
1287 | 1287 | ||
1288 | /* | 1288 | /* |
1289 | Return time corresponding to cell y coordinate. Coordinates are rounded to | 1289 | Return time corresponding to cell y coordinate. Coordinates are rounded to |
1290 | fit into the grid. | 1290 | fit into the grid. |
1291 | */ | 1291 | */ |
1292 | QTime KOAgenda::gyToTime(int gy) | 1292 | QTime KOAgenda::gyToTime(int gy) |
1293 | { | 1293 | { |
1294 | 1294 | ||
1295 | int secondsPerCell = 24 * 60 * 60/ mRows; | 1295 | int secondsPerCell = 24 * 60 * 60/ mRows; |
1296 | 1296 | ||
1297 | int timeSeconds = secondsPerCell * gy; | 1297 | int timeSeconds = secondsPerCell * gy; |
1298 | 1298 | ||
1299 | QTime time( 0, 0, 0 ); | 1299 | QTime time( 0, 0, 0 ); |
1300 | if ( timeSeconds < 24 * 60 * 60 ) { | 1300 | if ( timeSeconds < 24 * 60 * 60 ) { |
1301 | time = time.addSecs(timeSeconds); | 1301 | time = time.addSecs(timeSeconds); |
1302 | } else { | 1302 | } else { |
1303 | time.setHMS( 23, 59, 59 ); | 1303 | time.setHMS( 23, 59, 59 ); |
1304 | } | 1304 | } |
1305 | 1305 | ||
1306 | return time; | 1306 | return time; |
1307 | } | 1307 | } |
1308 | 1308 | ||
1309 | void KOAgenda::setStartHour(int startHour) | 1309 | void KOAgenda::setStartHour(int startHour) |
1310 | { | 1310 | { |
1311 | int startCell = startHour * mRows / 24; | 1311 | int startCell = startHour * mRows / 24; |
1312 | setContentsPos(0,startCell * gridSpacingY()); | 1312 | setContentsPos(0,startCell * gridSpacingY()); |
1313 | } | 1313 | } |
1314 | void KOAgenda::hideUnused() | 1314 | void KOAgenda::hideUnused() |
1315 | { | 1315 | { |
1316 | // experimental only | 1316 | // experimental only |
1317 | // return; | 1317 | // return; |
1318 | KOAgendaItem *item; | 1318 | KOAgendaItem *item; |
1319 | for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) { | 1319 | for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) { |
1320 | item->hide(); | 1320 | item->hide(); |
1321 | } | 1321 | } |
1322 | } | 1322 | } |
1323 | 1323 | ||
1324 | 1324 | ||
1325 | KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view) | 1325 | KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view) |
1326 | { | 1326 | { |
1327 | 1327 | ||
1328 | KOAgendaItem *fi; | 1328 | KOAgendaItem *fi; |
1329 | for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) { | 1329 | for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) { |
1330 | if ( fi->incidence() == event ) { | 1330 | if ( fi->incidence() == event ) { |
1331 | mUnusedItems.remove(); | 1331 | mUnusedItems.remove(); |
1332 | fi->init( event, qd ); | 1332 | fi->init( event, qd ); |
1333 | return fi; | 1333 | return fi; |
1334 | } | 1334 | } |
1335 | } | 1335 | } |
1336 | fi=mUnusedItems.first(); | 1336 | fi=mUnusedItems.first(); |
1337 | if ( fi ) { | 1337 | if ( fi ) { |
1338 | mUnusedItems.remove(); | 1338 | mUnusedItems.remove(); |
1339 | fi->init( event, qd ); | 1339 | fi->init( event, qd ); |
1340 | return fi; | 1340 | return fi; |
1341 | } | 1341 | } |
1342 | // qDebug("new KOAgendaItem "); | 1342 | // qDebug("new KOAgendaItem "); |
1343 | 1343 | ||
1344 | KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode ); | 1344 | KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode ); |
1345 | agendaItem->installEventFilter(this); | 1345 | agendaItem->installEventFilter(this); |
1346 | addChild(agendaItem,0,0); | 1346 | addChild(agendaItem,0,0); |
1347 | return agendaItem; | 1347 | return agendaItem; |
1348 | } | 1348 | } |
1349 | KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) | 1349 | KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) |
1350 | { | 1350 | { |
1351 | KOAgendaItem *item; | 1351 | KOAgendaItem *item; |
1352 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1352 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1353 | if ( item->incidence() == todo ) { | 1353 | if ( item->incidence() == todo ) { |
1354 | mItems.remove(); | 1354 | mItems.remove(); |
1355 | return item; | 1355 | return item; |
1356 | } | 1356 | } |
1357 | } | 1357 | } |
1358 | return 0; | 1358 | return 0; |
1359 | } | 1359 | } |
1360 | 1360 | ||
1361 | 1361 | ||
1362 | void KOAgenda::updateTodo( Todo * todo, int days, bool remove) | 1362 | void KOAgenda::updateTodo( Todo * todo, int days, bool remove) |
1363 | { | 1363 | { |
1364 | 1364 | ||
1365 | KOAgendaItem *item; | 1365 | KOAgendaItem *item; |
1366 | item = getItemForTodo ( todo ); | 1366 | item = getItemForTodo ( todo ); |
1367 | //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove); | 1367 | //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove); |
1368 | if ( item ) { | 1368 | if ( item ) { |
1369 | blockSignals( true ); | 1369 | blockSignals( true ); |
1370 | //qDebug("item found "); | 1370 | //qDebug("item found "); |
1371 | item->hide(); | 1371 | item->hide(); |
1372 | item->setCellX(-2, -1 ); | 1372 | item->setCellX(-2, -1 ); |
1373 | item->select(false); | 1373 | item->select(false); |
1374 | mUnusedItems.append( item ); | 1374 | mUnusedItems.append( item ); |
1375 | mItems.remove( item ); | 1375 | mItems.remove( item ); |
1376 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); | 1376 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); |
1377 | KOAgendaItem *itemit; | 1377 | KOAgendaItem *itemit; |
1378 | //globalFlagBlockAgendaItemPaint = 1; | 1378 | //globalFlagBlockAgendaItemPaint = 1; |
1379 | for ( itemit=oldconflictItems.first(); itemit != 0; | 1379 | for ( itemit=oldconflictItems.first(); itemit != 0; |
1380 | itemit=oldconflictItems.next() ) { | 1380 | itemit=oldconflictItems.next() ) { |
1381 | if ( itemit != item ) | 1381 | if ( itemit != item ) |
1382 | placeSubCells(itemit); | 1382 | placeSubCells(itemit); |
1383 | } | 1383 | } |
1384 | qApp->processEvents(); | 1384 | qApp->processEvents(); |
1385 | //globalFlagBlockAgendaItemPaint = 0; | 1385 | //globalFlagBlockAgendaItemPaint = 0; |
1386 | for ( itemit=oldconflictItems.first(); itemit != 0; | 1386 | for ( itemit=oldconflictItems.first(); itemit != 0; |
1387 | itemit=oldconflictItems.next() ) { | 1387 | itemit=oldconflictItems.next() ) { |
1388 | globalFlagBlockAgendaItemUpdate = 0; | 1388 | globalFlagBlockAgendaItemUpdate = 0; |
1389 | if ( itemit != item ) | 1389 | if ( itemit != item ) |
1390 | itemit->repaintMe(); | 1390 | itemit->repaintMe(); |
1391 | globalFlagBlockAgendaItemUpdate = 1; | 1391 | globalFlagBlockAgendaItemUpdate = 1; |
1392 | itemit->repaint(); | 1392 | itemit->repaint(); |
1393 | } | 1393 | } |
1394 | blockSignals( false ); | 1394 | blockSignals( false ); |
1395 | } | 1395 | } |
1396 | if ( remove ) { | 1396 | if ( remove ) { |
1397 | //qDebug("remove****************************************** "); | 1397 | //qDebug("remove****************************************** "); |
1398 | return; | 1398 | return; |
1399 | } | 1399 | } |
1400 | //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ "); | 1400 | //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ "); |
1401 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < QDate::currentDate())&& ( KOPrefs::instance()->mShowTodoInAgenda ); | 1401 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < QDate::currentDate())&& ( KOPrefs::instance()->mShowTodoInAgenda ); |
1402 | QDate currentDate; | 1402 | QDate currentDate; |
1403 | if ( overdue ) { | 1403 | if ( overdue ) { |
1404 | currentDate = QDate::currentDate(); | 1404 | currentDate = QDate::currentDate(); |
1405 | days += todo->dtDue().date().daysTo( currentDate ); | 1405 | days += todo->dtDue().date().daysTo( currentDate ); |
1406 | } | 1406 | } |
1407 | else | 1407 | else |
1408 | currentDate = todo->dtDue().date(); | 1408 | currentDate = todo->dtDue().date(); |
1409 | 1409 | ||
1410 | if ( todo->doesFloat() || overdue ) { | 1410 | if ( todo->doesFloat() || overdue ) { |
1411 | if ( ! mAllDayMode ) return; | 1411 | if ( ! mAllDayMode ) return; |
1412 | // aldayagenda | 1412 | // aldayagenda |
1413 | globalFlagBlockAgendaItemPaint = 1; | 1413 | globalFlagBlockAgendaItemPaint = 1; |
1414 | item = insertAllDayItem(todo, currentDate,days, days); | 1414 | item = insertAllDayItem(todo, currentDate,days, days); |
1415 | item->show(); | 1415 | item->show(); |
1416 | 1416 | ||
1417 | } | 1417 | } |
1418 | else { | 1418 | else { |
1419 | if ( mAllDayMode ) return; | 1419 | if ( mAllDayMode ) return; |
1420 | // mAgenda | 1420 | // mAgenda |
1421 | globalFlagBlockAgendaItemPaint = 1; | 1421 | globalFlagBlockAgendaItemPaint = 1; |
1422 | int endY = timeToY(todo->dtDue().time()) - 1; | 1422 | int endY = timeToY(todo->dtDue().time()) - 1; |
1423 | int hi = 12/KOPrefs::instance()->mHourSize; | 1423 | int hi = 12/KOPrefs::instance()->mHourSize; |
1424 | int startY = endY - 1-hi; | 1424 | int startY = endY - 1-hi; |
1425 | item = insertItem(todo,currentDate,days,startY,endY); | 1425 | item = insertItem(todo,currentDate,days,startY,endY); |
1426 | item->show(); | 1426 | item->show(); |
1427 | } | 1427 | } |
1428 | qApp->processEvents(); | 1428 | qApp->processEvents(); |
1429 | globalFlagBlockAgendaItemPaint = 0; | 1429 | globalFlagBlockAgendaItemPaint = 0; |
1430 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); | 1430 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); |
1431 | KOAgendaItem *itemit; | 1431 | KOAgendaItem *itemit; |
1432 | for ( itemit=oldconflictItems.first(); itemit != 0; | 1432 | for ( itemit=oldconflictItems.first(); itemit != 0; |
1433 | itemit=oldconflictItems.next() ) { | 1433 | itemit=oldconflictItems.next() ) { |
1434 | globalFlagBlockAgendaItemUpdate = 0; | 1434 | globalFlagBlockAgendaItemUpdate = 0; |
1435 | itemit->repaintMe(); | 1435 | itemit->repaintMe(); |
1436 | globalFlagBlockAgendaItemUpdate = 1; | 1436 | globalFlagBlockAgendaItemUpdate = 1; |
1437 | itemit->repaint(); | 1437 | itemit->repaint(); |
1438 | } | 1438 | } |
1439 | globalFlagBlockAgendaItemUpdate = 0; | 1439 | globalFlagBlockAgendaItemUpdate = 0; |
1440 | item->repaintMe(); | 1440 | item->repaintMe(); |
1441 | globalFlagBlockAgendaItemUpdate = 1; | 1441 | globalFlagBlockAgendaItemUpdate = 1; |
1442 | item->repaint(); | 1442 | item->repaint(); |
1443 | } | 1443 | } |
1444 | /* | 1444 | /* |
1445 | Insert KOAgendaItem into agenda. | 1445 | Insert KOAgendaItem into agenda. |
1446 | */ | 1446 | */ |
1447 | KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom) | 1447 | KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom) |
1448 | { | 1448 | { |
1449 | //kdDebug() << "KOAgenda::insertItem:" << event->summary() << "-" << qd.toString() << " ;top, bottom:" << YTop << "," << YBottom << endl; | 1449 | //kdDebug() << "KOAgenda::insertItem:" << event->summary() << "-" << qd.toString() << " ;top, bottom:" << YTop << "," << YBottom << endl; |
1450 | 1450 | ||
1451 | if (mAllDayMode) { | 1451 | if (mAllDayMode) { |
1452 | kdDebug() << "KOAgenda: calling insertItem in all-day mode is illegal." << endl; | 1452 | kdDebug() << "KOAgenda: calling insertItem in all-day mode is illegal." << endl; |
1453 | return 0; | 1453 | return 0; |
1454 | } | 1454 | } |
1455 | 1455 | ||
1456 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); | 1456 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); |
1457 | //agendaItem->setFrameStyle(WinPanel|Raised); | 1457 | //agendaItem->setFrameStyle(WinPanel|Raised); |
1458 | 1458 | ||
1459 | int YSize = YBottom - YTop + 1; | 1459 | int YSize = YBottom - YTop + 1; |
1460 | if (YSize < 0) { | 1460 | if (YSize < 0) { |
1461 | kdDebug() << "KOAgenda::insertItem(): Text: " << agendaItem->text() << " YSize<0" << endl; | 1461 | kdDebug() << "KOAgenda::insertItem(): Text: " << agendaItem->text() << " YSize<0" << endl; |
1462 | YSize = 1; | 1462 | YSize = 1; |
1463 | } | 1463 | } |
1464 | int iheight = mGridSpacingY * YSize; | 1464 | int iheight = mGridSpacingY * YSize; |
1465 | 1465 | ||
1466 | agendaItem->resize(mGridSpacingX,iheight ); | 1466 | agendaItem->resize(mGridSpacingX,iheight ); |
1467 | agendaItem->setCellXY(X,YTop,YBottom); | 1467 | agendaItem->setCellXY(X,YTop,YBottom); |
1468 | agendaItem->setCellXWidth(X); | 1468 | agendaItem->setCellXWidth(X); |
1469 | 1469 | ||
1470 | //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY); | 1470 | //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY); |
1471 | mItems.append(agendaItem); | 1471 | mItems.append(agendaItem); |
1472 | 1472 | ||
1473 | placeSubCells(agendaItem); | 1473 | placeSubCells(agendaItem); |
1474 | 1474 | ||
1475 | //agendaItem->show(); | 1475 | //agendaItem->show(); |
1476 | 1476 | ||
1477 | marcus_bains(); | 1477 | marcus_bains(); |
1478 | 1478 | ||
1479 | return agendaItem; | 1479 | return agendaItem; |
1480 | } | 1480 | } |
1481 | 1481 | ||
1482 | 1482 | ||
1483 | /* | 1483 | /* |
1484 | Insert all-day KOAgendaItem into agenda. | 1484 | Insert all-day KOAgendaItem into agenda. |
1485 | */ | 1485 | */ |
1486 | KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd) | 1486 | KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd) |
1487 | { | 1487 | { |
1488 | if (!mAllDayMode) { | 1488 | if (!mAllDayMode) { |
1489 | return 0; | 1489 | return 0; |
1490 | } | 1490 | } |
1491 | 1491 | ||
1492 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); | 1492 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); |
1493 | 1493 | ||
1494 | agendaItem->setCellXY(XBegin,0,0); | 1494 | agendaItem->setCellXY(XBegin,0,0); |
1495 | agendaItem->setCellXWidth(XEnd); | 1495 | agendaItem->setCellXWidth(XEnd); |
1496 | agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY); | 1496 | agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY); |
1497 | 1497 | ||
1498 | //addChild(agendaItem,XBegin*mGridSpacingX,0); | 1498 | //addChild(agendaItem,XBegin*mGridSpacingX,0); |
1499 | mItems.append(agendaItem); | 1499 | mItems.append(agendaItem); |
1500 | 1500 | ||
1501 | placeSubCells(agendaItem); | 1501 | placeSubCells(agendaItem); |
1502 | 1502 | ||
1503 | //agendaItem->show(); | 1503 | //agendaItem->show(); |
1504 | 1504 | ||
1505 | return agendaItem; | 1505 | return agendaItem; |
1506 | } | 1506 | } |
1507 | 1507 | ||
1508 | 1508 | ||
1509 | void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, | 1509 | void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, |
1510 | int YTop,int YBottom) | 1510 | int YTop,int YBottom) |
1511 | { | 1511 | { |
1512 | if (mAllDayMode) { | 1512 | if (mAllDayMode) { |
1513 | ; | 1513 | ; |
1514 | return; | 1514 | return; |
1515 | } | 1515 | } |
1516 | 1516 | ||
1517 | int cellX,cellYTop,cellYBottom; | 1517 | int cellX,cellYTop,cellYBottom; |
1518 | QString newtext; | 1518 | QString newtext; |
1519 | int width = XEnd - XBegin + 1; | 1519 | int width = XEnd - XBegin + 1; |
1520 | int count = 0; | 1520 | int count = 0; |
1521 | KOAgendaItem *current = 0; | 1521 | KOAgendaItem *current = 0; |
1522 | QPtrList<KOAgendaItem> multiItems; | 1522 | QPtrList<KOAgendaItem> multiItems; |
1523 | for (cellX = XBegin;cellX <= XEnd;++cellX) { | 1523 | for (cellX = XBegin;cellX <= XEnd;++cellX) { |
1524 | if (cellX == XBegin) cellYTop = YTop; | 1524 | if (cellX == XBegin) cellYTop = YTop; |
1525 | else cellYTop = 0; | 1525 | else cellYTop = 0; |
1526 | if (cellX == XEnd) cellYBottom = YBottom; | 1526 | if (cellX == XEnd) cellYBottom = YBottom; |
1527 | else cellYBottom = rows() - 1; | 1527 | else cellYBottom = rows() - 1; |
1528 | newtext = QString("(%1/%2): ").arg(++count).arg(width); | 1528 | newtext = QString("(%1/%2): ").arg(++count).arg(width); |
1529 | newtext.append(event->summary()); | 1529 | newtext.append(event->summary()); |
1530 | current = insertItem(event,qd,cellX,cellYTop,cellYBottom); | 1530 | current = insertItem(event,qd,cellX,cellYTop,cellYBottom); |
1531 | current->setText(newtext); | 1531 | current->setText(newtext); |
1532 | multiItems.append(current); | 1532 | multiItems.append(current); |
1533 | } | 1533 | } |
1534 | 1534 | ||
1535 | KOAgendaItem *next = 0; | 1535 | KOAgendaItem *next = 0; |
1536 | KOAgendaItem *last = multiItems.last(); | 1536 | KOAgendaItem *last = multiItems.last(); |
1537 | KOAgendaItem *first = multiItems.first(); | 1537 | KOAgendaItem *first = multiItems.first(); |
1538 | KOAgendaItem *setFirst,*setLast; | 1538 | KOAgendaItem *setFirst,*setLast; |
1539 | current = first; | 1539 | current = first; |
1540 | while (current) { | 1540 | while (current) { |
1541 | next = multiItems.next(); | 1541 | next = multiItems.next(); |
1542 | if (current == first) setFirst = 0; | 1542 | if (current == first) setFirst = 0; |
1543 | else setFirst = first; | 1543 | else setFirst = first; |
1544 | if (current == last) setLast = 0; | 1544 | if (current == last) setLast = 0; |
1545 | else setLast = last; | 1545 | else setLast = last; |
1546 | 1546 | ||
1547 | current->setMultiItem(setFirst,next,setLast); | 1547 | current->setMultiItem(setFirst,next,setLast); |
1548 | current = next; | 1548 | current = next; |
1549 | } | 1549 | } |
1550 | 1550 | ||
1551 | marcus_bains(); | 1551 | marcus_bains(); |
1552 | } | 1552 | } |
1553 | 1553 | ||
1554 | 1554 | ||
1555 | //QSizePolicy KOAgenda::sizePolicy() const | 1555 | //QSizePolicy KOAgenda::sizePolicy() const |
1556 | //{ | 1556 | //{ |
1557 | // Thought this would make the all-day event agenda minimum size and the | 1557 | // Thought this would make the all-day event agenda minimum size and the |
1558 | // normal agenda take the remaining space. But it doesn´t work. The QSplitter | 1558 | // normal agenda take the remaining space. But it doesn´t work. The QSplitter |
1559 | // don´t seem to think that an Expanding widget needs more space than a | 1559 | // don´t seem to think that an Expanding widget needs more space than a |
1560 | // Preferred one. | 1560 | // Preferred one. |
1561 | // But it doesn´t hurt, so it stays. | 1561 | // But it doesn´t hurt, so it stays. |
1562 | // if (mAllDayMode) { | 1562 | // if (mAllDayMode) { |
1563 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); | 1563 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); |
1564 | // } else { | 1564 | // } else { |
1565 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); | 1565 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); |
1566 | // } | 1566 | // } |
1567 | //} | 1567 | //} |
1568 | void KOAgenda::finishResize ( ) | 1568 | void KOAgenda::finishResize ( ) |
1569 | { | 1569 | { |
1570 | //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) "); | 1570 | //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) "); |
1571 | if ( globalFlagBlockAgenda == 0 ) { | 1571 | if ( globalFlagBlockAgenda == 0 ) { |
1572 | finishUpdate(); | 1572 | finishUpdate(); |
1573 | //qDebug("finishUpdate() called "); | 1573 | //qDebug("finishUpdate() called "); |
1574 | } | 1574 | } |
1575 | } | 1575 | } |
1576 | /* | 1576 | /* |
1577 | Overridden from QScrollView to provide proper resizing of KOAgendaItems. | 1577 | Overridden from QScrollView to provide proper resizing of KOAgendaItems. |
1578 | */ | 1578 | */ |
1579 | void KOAgenda::resizeEvent ( QResizeEvent *ev ) | 1579 | void KOAgenda::resizeEvent ( QResizeEvent *ev ) |
1580 | { | 1580 | { |
1581 | 1581 | ||
1582 | mResizeTimer.start( 150 , true ); | 1582 | mResizeTimer.start( 150 , true ); |
1583 | computeSizes(); | 1583 | computeSizes(); |
1584 | return; | 1584 | return; |
1585 | 1585 | ||
1586 | } | 1586 | } |
1587 | void KOAgenda::computeSizes() | 1587 | void KOAgenda::computeSizes() |
1588 | { | 1588 | { |
1589 | if ( globalFlagBlockStartup ) | 1589 | if ( globalFlagBlockStartup ) |
1590 | return; | 1590 | return; |
1591 | 1591 | ||
1592 | if (mAllDayMode) { | 1592 | if (mAllDayMode) { |
1593 | mGridSpacingX = (width()-3) / mColumns; | 1593 | mGridSpacingX = (width()-3) / mColumns; |
1594 | mGridSpacingY = height() - 2 * frameWidth() - 1; | 1594 | mGridSpacingY = height() - 2 * frameWidth() - 1; |
1595 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1); | 1595 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1); |
1596 | // mGridSpacingY = height(); | 1596 | // mGridSpacingY = height(); |
1597 | // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 1597 | // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
1598 | 1598 | ||
1599 | KOAgendaItem *item; | 1599 | KOAgendaItem *item; |
1600 | int subCellWidth; | 1600 | int subCellWidth; |
1601 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1601 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1602 | subCellWidth = mGridSpacingY / item->subCells(); | 1602 | subCellWidth = mGridSpacingY / item->subCells(); |
1603 | item->resize(mGridSpacingX * item->cellWidth(),subCellWidth); | 1603 | item->resize(mGridSpacingX * item->cellWidth(),subCellWidth); |
1604 | moveChild(item,KOGlobals::self()->reverseLayout() ? | 1604 | moveChild(item,KOGlobals::self()->reverseLayout() ? |
1605 | (mColumns - 1 - item->cellX()) * mGridSpacingX : | 1605 | (mColumns - 1 - item->cellX()) * mGridSpacingX : |
1606 | item->cellX() * mGridSpacingX, | 1606 | item->cellX() * mGridSpacingX, |
1607 | item->subCell() * subCellWidth); | 1607 | item->subCell() * subCellWidth); |
1608 | } | 1608 | } |
1609 | KOPrefs::instance()->mAllDaySize = mGridSpacingY; | 1609 | KOPrefs::instance()->mAllDaySize = mGridSpacingY; |
1610 | } else { | 1610 | } else { |
1611 | mGridSpacingX = (width() - verticalScrollBar()->width()-3)/mColumns; | 1611 | mGridSpacingX = (width() - verticalScrollBar()->width()-3)/mColumns; |
1612 | if (height() > mGridSpacingY * mRows + 1 ) { | 1612 | if (height() > mGridSpacingY * mRows + 1 ) { |
1613 | KOPrefs::instance()->mHourSize = ((height())/mRows)+1; | 1613 | KOPrefs::instance()->mHourSize = ((height())/mRows)+1; |
1614 | mGridSpacingY = KOPrefs::instance()->mHourSize ; | 1614 | mGridSpacingY = KOPrefs::instance()->mHourSize ; |
1615 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 1615 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
1616 | emit resizedSignal(); | 1616 | emit resizedSignal(); |
1617 | } else | 1617 | } else |
1618 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 1618 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
1619 | KOAgendaItem *item; | 1619 | KOAgendaItem *item; |
1620 | int subCellWidth; | 1620 | int subCellWidth; |
1621 | 1621 | ||
1622 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1622 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1623 | subCellWidth = mGridSpacingX / item->subCells(); | 1623 | subCellWidth = mGridSpacingX / item->subCells(); |
1624 | item->resize(subCellWidth,item->height()); | 1624 | item->resize(subCellWidth,item->height()); |
1625 | moveChild(item,(KOGlobals::self()->reverseLayout() ? | 1625 | moveChild(item,(KOGlobals::self()->reverseLayout() ? |
1626 | (mColumns - 1 - item->cellX()) * mGridSpacingX : | 1626 | (mColumns - 1 - item->cellX()) * mGridSpacingX : |
1627 | item->cellX() * mGridSpacingX) + | 1627 | item->cellX() * mGridSpacingX) + |
1628 | item->subCell() * subCellWidth,childY(item)); | 1628 | item->subCell() * subCellWidth,childY(item)); |
1629 | } | 1629 | } |
1630 | } | 1630 | } |
1631 | int cw = contentsWidth(); | 1631 | int cw = contentsWidth(); |
1632 | int ch = contentsHeight(); | 1632 | int ch = contentsHeight(); |
1633 | if ( mAllDayMode ) { | 1633 | if ( mAllDayMode ) { |
1634 | QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); | 1634 | QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); |
1635 | if ( paintPixAll->width() < cw || paintPixAll->height() < ch ) | 1635 | if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) |
1636 | paintPixAll->resize( cw, ch ); | 1636 | paintPixAll->resize( cw, ch ); |
1637 | } else { | 1637 | } else { |
1638 | QPixmap* paintPix = KOAgendaItem::paintPix(); | 1638 | QPixmap* paintPix = KOAgendaItem::paintPix(); |
1639 | if ( paintPix->width() < cw || paintPix->height() < ch ) | 1639 | if ( paintPix->width() < cw || paintPix->height() < ch ) |
1640 | KOAgendaItem::resizePixmap( cw , ch ); | 1640 | KOAgendaItem::resizePixmap( cw , ch ); |
1641 | } | 1641 | } |
1642 | 1642 | ||
1643 | checkScrollBoundaries(); | 1643 | checkScrollBoundaries(); |
1644 | marcus_bains(); | 1644 | marcus_bains(); |
1645 | drawContentsToPainter(); | 1645 | drawContentsToPainter(); |
1646 | viewport()->repaint(false); | 1646 | viewport()->repaint(false); |
1647 | } | 1647 | } |
1648 | 1648 | ||
1649 | void KOAgenda::scrollUp() | 1649 | void KOAgenda::scrollUp() |
1650 | { | 1650 | { |
1651 | scrollBy(0,-mScrollOffset); | 1651 | scrollBy(0,-mScrollOffset); |
1652 | } | 1652 | } |
1653 | 1653 | ||
1654 | 1654 | ||
1655 | void KOAgenda::scrollDown() | 1655 | void KOAgenda::scrollDown() |
1656 | { | 1656 | { |
1657 | scrollBy(0,mScrollOffset); | 1657 | scrollBy(0,mScrollOffset); |
1658 | } | 1658 | } |
1659 | 1659 | ||
1660 | void KOAgenda::popupAlarm() | 1660 | void KOAgenda::popupAlarm() |
1661 | { | 1661 | { |
1662 | if (!mClickedItem) { | 1662 | if (!mClickedItem) { |
1663 | kdDebug() << "KOAgenda::popupAlarm() called without having a clicked item" << endl; | 1663 | kdDebug() << "KOAgenda::popupAlarm() called without having a clicked item" << endl; |
1664 | return; | 1664 | return; |
1665 | } | 1665 | } |
1666 | // TODO: deal correctly with multiple alarms | 1666 | // TODO: deal correctly with multiple alarms |
1667 | Alarm* alarm; | 1667 | Alarm* alarm; |
1668 | QPtrList<Alarm> list(mClickedItem->incidence()->alarms()); | 1668 | QPtrList<Alarm> list(mClickedItem->incidence()->alarms()); |
1669 | for(alarm=list.first();alarm;alarm=list.next()) { | 1669 | for(alarm=list.first();alarm;alarm=list.next()) { |
1670 | alarm->toggleAlarm(); | 1670 | alarm->toggleAlarm(); |
1671 | } | 1671 | } |
1672 | emit itemModified( mClickedItem , KOGlobals::EVENTEDITED ); | 1672 | emit itemModified( mClickedItem , KOGlobals::EVENTEDITED ); |
1673 | mClickedItem->paintMe( true ); | 1673 | mClickedItem->paintMe( true ); |
1674 | mClickedItem->repaint( false ); | 1674 | mClickedItem->repaint( false ); |
1675 | } | 1675 | } |
1676 | 1676 | ||
1677 | /* | 1677 | /* |
1678 | Calculates the minimum width | 1678 | Calculates the minimum width |
1679 | */ | 1679 | */ |
1680 | int KOAgenda::minimumWidth() const | 1680 | int KOAgenda::minimumWidth() const |
1681 | { | 1681 | { |
1682 | // TODO:: develop a way to dynamically determine the minimum width | 1682 | // TODO:: develop a way to dynamically determine the minimum width |
1683 | int min = 100; | 1683 | int min = 100; |
1684 | 1684 | ||
1685 | return min; | 1685 | return min; |
1686 | } | 1686 | } |
1687 | 1687 | ||
1688 | void KOAgenda::updateConfig() | 1688 | void KOAgenda::updateConfig() |
1689 | { | 1689 | { |
1690 | if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor) | 1690 | if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor) |
1691 | viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor); | 1691 | viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor); |
1692 | if ( mAllDayMode ) { | 1692 | if ( mAllDayMode ) { |
1693 | mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize; | 1693 | mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize; |
1694 | //mGridSpacingY = KOPrefs::instance()->mAllDaySize; | 1694 | //mGridSpacingY = KOPrefs::instance()->mAllDaySize; |
1695 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 ); | 1695 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 ); |
1696 | // setMaximumHeight( mGridSpacingY+1 ); | 1696 | // setMaximumHeight( mGridSpacingY+1 ); |
1697 | viewport()->repaint( false ); | 1697 | viewport()->repaint( false ); |
1698 | //setFixedHeight( mGridSpacingY+1 ); | 1698 | //setFixedHeight( mGridSpacingY+1 ); |
1699 | //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize); | 1699 | //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize); |
1700 | } | 1700 | } |
1701 | else { | 1701 | else { |
1702 | mGridSpacingY = KOPrefs::instance()->mHourSize; | 1702 | mGridSpacingY = KOPrefs::instance()->mHourSize; |
1703 | calculateWorkingHours(); | 1703 | calculateWorkingHours(); |
1704 | marcus_bains(); | 1704 | marcus_bains(); |
1705 | } | 1705 | } |
1706 | } | 1706 | } |
1707 | 1707 | ||
1708 | void KOAgenda::checkScrollBoundaries() | 1708 | void KOAgenda::checkScrollBoundaries() |
1709 | { | 1709 | { |
1710 | // Invalidate old values to force update | 1710 | // Invalidate old values to force update |
1711 | mOldLowerScrollValue = -1; | 1711 | mOldLowerScrollValue = -1; |
1712 | mOldUpperScrollValue = -1; | 1712 | mOldUpperScrollValue = -1; |
1713 | 1713 | ||
1714 | checkScrollBoundaries(verticalScrollBar()->value()); | 1714 | checkScrollBoundaries(verticalScrollBar()->value()); |
1715 | } | 1715 | } |
1716 | 1716 | ||
1717 | void KOAgenda::checkScrollBoundaries(int v) | 1717 | void KOAgenda::checkScrollBoundaries(int v) |
1718 | { | 1718 | { |
1719 | if ( mGridSpacingY == 0 ) | 1719 | if ( mGridSpacingY == 0 ) |
1720 | return; | 1720 | return; |
1721 | int yMin = v/mGridSpacingY; | 1721 | int yMin = v/mGridSpacingY; |
1722 | int yMax = (v+visibleHeight())/mGridSpacingY; | 1722 | int yMax = (v+visibleHeight())/mGridSpacingY; |
1723 | 1723 | ||
1724 | // kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl; | 1724 | // kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl; |
1725 | 1725 | ||
1726 | if (yMin != mOldLowerScrollValue) { | 1726 | if (yMin != mOldLowerScrollValue) { |
1727 | mOldLowerScrollValue = yMin; | 1727 | mOldLowerScrollValue = yMin; |
1728 | emit lowerYChanged(yMin); | 1728 | emit lowerYChanged(yMin); |
1729 | } | 1729 | } |
1730 | if (yMax != mOldUpperScrollValue) { | 1730 | if (yMax != mOldUpperScrollValue) { |
1731 | mOldUpperScrollValue = yMax; | 1731 | mOldUpperScrollValue = yMax; |
1732 | emit upperYChanged(yMax); | 1732 | emit upperYChanged(yMax); |
1733 | } | 1733 | } |
1734 | } | 1734 | } |
1735 | 1735 | ||
1736 | void KOAgenda::deselectItem() | 1736 | void KOAgenda::deselectItem() |
1737 | { | 1737 | { |
1738 | if (mSelectedItem.isNull()) return; | 1738 | if (mSelectedItem.isNull()) return; |
1739 | mSelectedItem->select(false); | 1739 | mSelectedItem->select(false); |
1740 | mSelectedItem = 0; | 1740 | mSelectedItem = 0; |
1741 | } | 1741 | } |
1742 | 1742 | ||
1743 | void KOAgenda::selectItem(KOAgendaItem *item) | 1743 | void KOAgenda::selectItem(KOAgendaItem *item) |
1744 | { | 1744 | { |
1745 | if ((KOAgendaItem *)mSelectedItem == item) return; | 1745 | if ((KOAgendaItem *)mSelectedItem == item) return; |
1746 | deselectItem(); | 1746 | deselectItem(); |
1747 | if (item == 0) { | 1747 | if (item == 0) { |
1748 | emit incidenceSelected( 0 ); | 1748 | emit incidenceSelected( 0 ); |
1749 | return; | 1749 | return; |
1750 | } | 1750 | } |
1751 | mSelectedItem = item; | 1751 | mSelectedItem = item; |
1752 | mSelectedItem->select(); | 1752 | mSelectedItem->select(); |
1753 | emit incidenceSelected( mSelectedItem->incidence() ); | 1753 | emit incidenceSelected( mSelectedItem->incidence() ); |
1754 | } | 1754 | } |
1755 | 1755 | ||
1756 | // This function seems never be called. | 1756 | // This function seems never be called. |
1757 | void KOAgenda::keyPressEvent( QKeyEvent *kev ) | 1757 | void KOAgenda::keyPressEvent( QKeyEvent *kev ) |
1758 | { | 1758 | { |
1759 | switch(kev->key()) { | 1759 | switch(kev->key()) { |
1760 | case Key_PageDown: | 1760 | case Key_PageDown: |
1761 | verticalScrollBar()->addPage(); | 1761 | verticalScrollBar()->addPage(); |
1762 | break; | 1762 | break; |
1763 | case Key_PageUp: | 1763 | case Key_PageUp: |
1764 | verticalScrollBar()->subtractPage(); | 1764 | verticalScrollBar()->subtractPage(); |
1765 | break; | 1765 | break; |
1766 | case Key_Down: | 1766 | case Key_Down: |
1767 | verticalScrollBar()->addLine(); | 1767 | verticalScrollBar()->addLine(); |
1768 | break; | 1768 | break; |
1769 | case Key_Up: | 1769 | case Key_Up: |
1770 | verticalScrollBar()->subtractLine(); | 1770 | verticalScrollBar()->subtractLine(); |
1771 | break; | 1771 | break; |
1772 | default: | 1772 | default: |
1773 | ; | 1773 | ; |
1774 | } | 1774 | } |
1775 | } | 1775 | } |
1776 | 1776 | ||
1777 | void KOAgenda::calculateWorkingHours() | 1777 | void KOAgenda::calculateWorkingHours() |
1778 | { | 1778 | { |
1779 | // mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours; | 1779 | // mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours; |
1780 | mWorkingHoursEnable = !mAllDayMode; | 1780 | mWorkingHoursEnable = !mAllDayMode; |
1781 | 1781 | ||
1782 | mWorkingHoursYTop = mGridSpacingY * | 1782 | mWorkingHoursYTop = mGridSpacingY * |
1783 | KOPrefs::instance()->mWorkingHoursStart * 4; | 1783 | KOPrefs::instance()->mWorkingHoursStart * 4; |
1784 | mWorkingHoursYBottom = mGridSpacingY * | 1784 | mWorkingHoursYBottom = mGridSpacingY * |
1785 | KOPrefs::instance()->mWorkingHoursEnd * 4 - 1; | 1785 | KOPrefs::instance()->mWorkingHoursEnd * 4 - 1; |
1786 | } | 1786 | } |
1787 | 1787 | ||
1788 | 1788 | ||
1789 | DateList KOAgenda::dateList() const | 1789 | DateList KOAgenda::dateList() const |
1790 | { | 1790 | { |
1791 | return mSelectedDates; | 1791 | return mSelectedDates; |
1792 | } | 1792 | } |
1793 | 1793 | ||
1794 | void KOAgenda::setDateList(const DateList &selectedDates) | 1794 | void KOAgenda::setDateList(const DateList &selectedDates) |
1795 | { | 1795 | { |
1796 | mSelectedDates = selectedDates; | 1796 | mSelectedDates = selectedDates; |
1797 | marcus_bains(); | 1797 | marcus_bains(); |
1798 | } | 1798 | } |
1799 | 1799 | ||
1800 | void KOAgenda::setHolidayMask(QMemArray<bool> *mask) | 1800 | void KOAgenda::setHolidayMask(QMemArray<bool> *mask) |
1801 | { | 1801 | { |
1802 | mHolidayMask = mask; | 1802 | mHolidayMask = mask; |
1803 | 1803 | ||
1804 | /* | 1804 | /* |
1805 | kdDebug() << "HolidayMask: "; | 1805 | kdDebug() << "HolidayMask: "; |
1806 | for(uint i=0;i<mask->count();++i) { | 1806 | for(uint i=0;i<mask->count();++i) { |
1807 | kdDebug() << (mask->at(i) ? "*" : "o"); | 1807 | kdDebug() << (mask->at(i) ? "*" : "o"); |
1808 | } | 1808 | } |
1809 | kdDebug() << endl; | 1809 | kdDebug() << endl; |
1810 | */ | 1810 | */ |
1811 | } | 1811 | } |
1812 | 1812 | ||
1813 | void KOAgenda::contentsMousePressEvent ( QMouseEvent *event ) | 1813 | void KOAgenda::contentsMousePressEvent ( QMouseEvent *event ) |
1814 | { | 1814 | { |
1815 | 1815 | ||
1816 | QScrollView::contentsMousePressEvent(event); | 1816 | QScrollView::contentsMousePressEvent(event); |
1817 | } | 1817 | } |
1818 | 1818 | ||
1819 | void KOAgenda::storePosition() | 1819 | void KOAgenda::storePosition() |
1820 | { | 1820 | { |
1821 | //mContentPosition | 1821 | //mContentPosition |
1822 | int max = mGridSpacingY*4*24; | 1822 | int max = mGridSpacingY*4*24; |
1823 | if ( contentsY() < 5 && max > viewport()->height()*3/2 ) | 1823 | if ( contentsY() < 5 && max > viewport()->height()*3/2 ) |
1824 | mContentPosition = 0; | 1824 | mContentPosition = 0; |
1825 | else if ( contentsY() + viewport()->height() > max - 5 && max > viewport()->height()*3/2) | 1825 | else if ( contentsY() + viewport()->height() > max - 5 && max > viewport()->height()*3/2) |
1826 | mContentPosition = -1.0; | 1826 | mContentPosition = -1.0; |
1827 | else | 1827 | else |
1828 | mContentPosition = ((float) max)/ ((float)(contentsY()+ ( viewport()->height()/2))); | 1828 | mContentPosition = ((float) max)/ ((float)(contentsY()+ ( viewport()->height()/2))); |
1829 | //qDebug("mContentPosition %f %d %d %d",mContentPosition , max, contentsY() ,viewport()->height()); | 1829 | //qDebug("mContentPosition %f %d %d %d",mContentPosition , max, contentsY() ,viewport()->height()); |
1830 | 1830 | ||
1831 | } | 1831 | } |
1832 | void KOAgenda::restorePosition() | 1832 | void KOAgenda::restorePosition() |
1833 | { | 1833 | { |
1834 | int posY; | 1834 | int posY; |
1835 | int max = mGridSpacingY*4*24; | 1835 | int max = mGridSpacingY*4*24; |
1836 | if ( mContentPosition < 0 ) | 1836 | if ( mContentPosition < 0 ) |
1837 | posY = max-viewport()->height(); | 1837 | posY = max-viewport()->height(); |
1838 | else | 1838 | else |
1839 | if ( mContentPosition == 0 ) | 1839 | if ( mContentPosition == 0 ) |
1840 | posY = 0; | 1840 | posY = 0; |
1841 | else | 1841 | else |
1842 | posY = (max/mContentPosition)-(viewport()->height()/2); | 1842 | posY = (max/mContentPosition)-(viewport()->height()/2); |
1843 | setContentsPos (0, posY ); | 1843 | setContentsPos (0, posY ); |
1844 | //qDebug("posY %d hei %d", posY, max); | 1844 | //qDebug("posY %d hei %d", posY, max); |
1845 | 1845 | ||
1846 | } | 1846 | } |
1847 | void KOAgenda::moveChild( QWidget *w, int x , int y ) | 1847 | void KOAgenda::moveChild( QWidget *w, int x , int y ) |
1848 | { | 1848 | { |
1849 | ++x; | 1849 | ++x; |
1850 | QScrollView::moveChild( w, x , y ); | 1850 | QScrollView::moveChild( w, x , y ); |
1851 | } | 1851 | } |
1852 | #include <qmessagebox.h> | 1852 | #include <qmessagebox.h> |
1853 | #ifdef DESKTOP_VERSION | 1853 | #ifdef DESKTOP_VERSION |
1854 | #include <qprinter.h> | 1854 | #include <qprinter.h> |
1855 | #include <qpainter.h> | 1855 | #include <qpainter.h> |
1856 | #include <qpaintdevicemetrics.h> | 1856 | #include <qpaintdevicemetrics.h> |
1857 | 1857 | ||
1858 | #endif | 1858 | #endif |
1859 | void KOAgenda::printSelection() | 1859 | void KOAgenda::printSelection() |
1860 | { | 1860 | { |
1861 | #ifdef DESKTOP_VERSION | 1861 | #ifdef DESKTOP_VERSION |
1862 | if ( mStartCellY == mCurrentCellY ) { | 1862 | if ( mStartCellY == mCurrentCellY ) { |
1863 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1863 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1864 | i18n("Nothing selected!\n\nThis prints the full width of the Agenda view as you see it!\n\nTo determine the vertical range of the printing, please select\na vertical range (with the left mouse button down) in one column. "), | 1864 | i18n("Nothing selected!\n\nThis prints the full width of the Agenda view as you see it!\n\nTo determine the vertical range of the printing, please select\na vertical range (with the left mouse button down) in one column. "), |
1865 | i18n("OK"), 0, 0, | 1865 | i18n("OK"), 0, 0, |
1866 | 0, 1 ); | 1866 | 0, 1 ); |
1867 | return; | 1867 | return; |
1868 | } | 1868 | } |
1869 | 1869 | ||
1870 | float dx, dy; | 1870 | float dx, dy; |
1871 | int x,y,w,h; | 1871 | int x,y,w,h; |
1872 | x= 0; | 1872 | x= 0; |
1873 | w= contentsWidth()+2; | 1873 | w= contentsWidth()+2; |
1874 | // h= contentsHeight(); | 1874 | // h= contentsHeight(); |
1875 | y = mGridSpacingY*mStartCellY; | 1875 | y = mGridSpacingY*mStartCellY; |
1876 | h = mGridSpacingY*(mCurrentCellY+1)-y+2; | 1876 | h = mGridSpacingY*(mCurrentCellY+1)-y+2; |
1877 | 1877 | ||
1878 | //return; | 1878 | //return; |
1879 | QPrinter* printer = new QPrinter(); | 1879 | QPrinter* printer = new QPrinter(); |
1880 | if ( !printer->setup()) { | 1880 | if ( !printer->setup()) { |
1881 | delete printer; | 1881 | delete printer; |
1882 | return; | 1882 | return; |
1883 | } | 1883 | } |
1884 | QPainter p( printer ); | 1884 | QPainter p( printer ); |
1885 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( printer ); | 1885 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( printer ); |
1886 | QString date = i18n("Date range: ")+KGlobal::locale()->formatDate( mSelectedDates.first() )+" - "+KGlobal::locale()->formatDate( mSelectedDates.last() ); | 1886 | QString date = i18n("Date range: ")+KGlobal::locale()->formatDate( mSelectedDates.first() )+" - "+KGlobal::locale()->formatDate( mSelectedDates.last() ); |
1887 | date += " --- printing time: " + KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), true ); | 1887 | date += " --- printing time: " + KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), true ); |
1888 | int hei = p.boundingRect(0,0, 5, 5, Qt::AlignLeft, date ).height(); | 1888 | int hei = p.boundingRect(0,0, 5, 5, Qt::AlignLeft, date ).height(); |
1889 | // p.drawText( 0, 0, date ); | 1889 | // p.drawText( 0, 0, date ); |
1890 | int offset = m.width()/8; | 1890 | int offset = m.width()/8; |
1891 | // compute the scale | 1891 | // compute the scale |
1892 | dx = ((float) m.width()-offset) / (float)w; | 1892 | dx = ((float) m.width()-offset) / (float)w; |
1893 | dy = (float)(m.height() - ( 2 * hei )-offset ) / (float)h; | 1893 | dy = (float)(m.height() - ( 2 * hei )-offset ) / (float)h; |
1894 | float scale; | 1894 | float scale; |
1895 | // scale to fit the width or height of the paper | 1895 | // scale to fit the width or height of the paper |
1896 | if ( dx < dy ) | 1896 | if ( dx < dy ) |
1897 | scale = dx; | 1897 | scale = dx; |
1898 | else | 1898 | else |
1899 | scale = dy; | 1899 | scale = dy; |
1900 | // set the scale | 1900 | // set the scale |
1901 | p.drawText( offset* scale, offset* scale*3/4, date ); | 1901 | p.drawText( offset* scale, offset* scale*3/4, date ); |
1902 | 1902 | ||
1903 | int selDay; | 1903 | int selDay; |
1904 | float widOffset = ((float) m.width()-offset) / ((float)(mSelectedDates.count())); | 1904 | float widOffset = ((float) m.width()-offset) / ((float)(mSelectedDates.count())); |
1905 | float startX = 1; | 1905 | float startX = 1; |
1906 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) | 1906 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) |
1907 | { | 1907 | { |
1908 | QString text = KGlobal::locale()->formatDate( mSelectedDates[selDay],true ); | 1908 | QString text = KGlobal::locale()->formatDate( mSelectedDates[selDay],true ); |
1909 | p.setClipRect(offset* scale+startX , 0, widOffset-4, offset* scale+(2*hei* scale) ); | 1909 | p.setClipRect(offset* scale+startX , 0, widOffset-4, offset* scale+(2*hei* scale) ); |
1910 | p.drawText( offset* scale+startX, (offset+hei)* scale, text ); | 1910 | p.drawText( offset* scale+startX, (offset+hei)* scale, text ); |
1911 | startX += widOffset; | 1911 | startX += widOffset; |
1912 | 1912 | ||
1913 | } | 1913 | } |
1914 | p.translate( offset* scale,offset* scale+ (-y * scale)+(2*hei* scale)); | 1914 | p.translate( offset* scale,offset* scale+ (-y * scale)+(2*hei* scale)); |
1915 | p.scale( scale, scale ); | 1915 | p.scale( scale, scale ); |
1916 | p.setClipRect( offset* scale, offset* scale+(2*hei* scale), w*scale, h*scale ); | 1916 | p.setClipRect( offset* scale, offset* scale+(2*hei* scale), w*scale, h*scale ); |
1917 | // now printing with y offset: 2 hei | 1917 | // now printing with y offset: 2 hei |
1918 | // p.translate( 0, -y*scale); | 1918 | // p.translate( 0, -y*scale); |
1919 | 1919 | ||
1920 | drawContentsToPainter(&p, true ); | 1920 | drawContentsToPainter(&p, true ); |
1921 | globalFlagBlockAgendaItemUpdate = false; | 1921 | globalFlagBlockAgendaItemUpdate = false; |
1922 | KOAgendaItem *item; | 1922 | KOAgendaItem *item; |
1923 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1923 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1924 | item->select(false); | 1924 | item->select(false); |
1925 | item->paintMe( false, &p ); | 1925 | item->paintMe( false, &p ); |
1926 | } | 1926 | } |
1927 | globalFlagBlockAgendaItemUpdate = true; | 1927 | globalFlagBlockAgendaItemUpdate = true; |
1928 | p.end(); | 1928 | p.end(); |
1929 | delete printer; | 1929 | delete printer; |
1930 | #else | 1930 | #else |
1931 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1931 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1932 | i18n("Not supported \non PDA!\n"), | 1932 | i18n("Not supported \non PDA!\n"), |
1933 | i18n("OK"), 0, 0, | 1933 | i18n("OK"), 0, 0, |
1934 | 0, 1 ); | 1934 | 0, 1 ); |
1935 | #endif | 1935 | #endif |
1936 | } | 1936 | } |
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp index 6965ba7..62281d4 100644 --- a/korganizer/koagendaitem.cpp +++ b/korganizer/koagendaitem.cpp | |||
@@ -46,677 +46,677 @@ extern int globalFlagBlockAgendaItemUpdate; | |||
46 | 46 | ||
47 | #include "koprefs.h" | 47 | #include "koprefs.h" |
48 | 48 | ||
49 | #include "koagendaitem.h" | 49 | #include "koagendaitem.h" |
50 | //#include "koagendaitem.moc" | 50 | //#include "koagendaitem.moc" |
51 | 51 | ||
52 | 52 | ||
53 | //-------------------------------------------------------------------------- | 53 | //-------------------------------------------------------------------------- |
54 | 54 | ||
55 | QToolTipGroup *KOAgendaItem::mToolTipGroup = 0; | 55 | QToolTipGroup *KOAgendaItem::mToolTipGroup = 0; |
56 | 56 | ||
57 | //-------------------------------------------------------------------------- | 57 | //-------------------------------------------------------------------------- |
58 | 58 | ||
59 | KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday, | 59 | KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday, |
60 | const char *name,WFlags) : | 60 | const char *name,WFlags) : |
61 | QWidget(parent, name), mIncidence(incidence), mDate(qd) | 61 | QWidget(parent, name), mIncidence(incidence), mDate(qd) |
62 | { | 62 | { |
63 | #ifndef DESKTOP_VERSION | 63 | #ifndef DESKTOP_VERSION |
64 | QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); | 64 | QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); |
65 | #endif | 65 | #endif |
66 | int wflags = getWFlags() |WRepaintNoErase;// WResizeNoErase | 66 | int wflags = getWFlags() |WRepaintNoErase;// WResizeNoErase |
67 | setWFlags ( wflags); | 67 | setWFlags ( wflags); |
68 | mAllDay = allday; | 68 | mAllDay = allday; |
69 | init ( incidence, qd ); | 69 | init ( incidence, qd ); |
70 | setMouseTracking(true); | 70 | setMouseTracking(true); |
71 | //setAcceptDrops(true); | 71 | //setAcceptDrops(true); |
72 | xPaintCoord = -1; | 72 | xPaintCoord = -1; |
73 | yPaintCoord = -1; | 73 | yPaintCoord = -1; |
74 | } | 74 | } |
75 | 75 | ||
76 | void KOAgendaItem::init ( Incidence *incidence, QDate qd ) | 76 | void KOAgendaItem::init ( Incidence *incidence, QDate qd ) |
77 | { | 77 | { |
78 | mIncidence = incidence; | 78 | mIncidence = incidence; |
79 | mDate = qd; | 79 | mDate = qd; |
80 | mFirstMultiItem = 0; | 80 | mFirstMultiItem = 0; |
81 | mNextMultiItem = 0; | 81 | mNextMultiItem = 0; |
82 | mLastMultiItem = 0; | 82 | mLastMultiItem = 0; |
83 | computeText(); | 83 | computeText(); |
84 | 84 | ||
85 | if ( (incidence->type() == "Todo") && | 85 | if ( (incidence->type() == "Todo") && |
86 | ( !((static_cast<Todo*>(incidence))->isCompleted()) && | 86 | ( !((static_cast<Todo*>(incidence))->isCompleted()) && |
87 | ((static_cast<Todo*>(incidence))->dtDue().date() <= QDate::currentDate()) ) ) { | 87 | ((static_cast<Todo*>(incidence))->dtDue().date() <= QDate::currentDate()) ) ) { |
88 | if ( (static_cast<Todo*>(incidence))->dtDue() < QDateTime::currentDateTime().date()) | 88 | if ( (static_cast<Todo*>(incidence))->dtDue() < QDateTime::currentDateTime().date()) |
89 | mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ; | 89 | mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ; |
90 | else | 90 | else |
91 | mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor; | 91 | mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor; |
92 | } | 92 | } |
93 | else { | 93 | else { |
94 | QStringList categories = mIncidence->categories(); | 94 | QStringList categories = mIncidence->categories(); |
95 | QString cat = categories.first(); | 95 | QString cat = categories.first(); |
96 | if (cat.isEmpty()) { | 96 | if (cat.isEmpty()) { |
97 | mBackgroundColor =KOPrefs::instance()->mEventColor; | 97 | mBackgroundColor =KOPrefs::instance()->mEventColor; |
98 | } else { | 98 | } else { |
99 | mBackgroundColor = *KOPrefs::instance()->categoryColor(cat); | 99 | mBackgroundColor = *KOPrefs::instance()->categoryColor(cat); |
100 | } | 100 | } |
101 | } | 101 | } |
102 | mColorGroup = QColorGroup( mBackgroundColor.light(), | 102 | mColorGroup = QColorGroup( mBackgroundColor.light(), |
103 | mBackgroundColor.dark(),mBackgroundColor.light(), | 103 | mBackgroundColor.dark(),mBackgroundColor.light(), |
104 | mBackgroundColor.dark(),mBackgroundColor, black, mBackgroundColor) ; | 104 | mBackgroundColor.dark(),mBackgroundColor, black, mBackgroundColor) ; |
105 | setBackgroundColor( mBackgroundColor ); | 105 | setBackgroundColor( mBackgroundColor ); |
106 | 106 | ||
107 | setCellXY(0,0,1); | 107 | setCellXY(0,0,1); |
108 | setCellXWidth(0); | 108 | setCellXWidth(0); |
109 | setSubCell(0); | 109 | setSubCell(0); |
110 | setSubCells(1); | 110 | setSubCells(1); |
111 | setMultiItem(0,0,0); | 111 | setMultiItem(0,0,0); |
112 | startMove(); | 112 | startMove(); |
113 | mSelected = true; | 113 | mSelected = true; |
114 | select(false); | 114 | select(false); |
115 | QString tipText = mIncidence->summary(); | 115 | QString tipText = mIncidence->summary(); |
116 | // QToolTip::add(this,tipText); | 116 | // QToolTip::add(this,tipText); |
117 | QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence )); | 117 | QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence )); |
118 | if ( !mIncidence->doesFloat() ) | 118 | if ( !mIncidence->doesFloat() ) |
119 | if ( mIncidence->type() == "Event" ) { | 119 | if ( mIncidence->type() == "Event" ) { |
120 | if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { | 120 | if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { |
121 | tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); | 121 | tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); |
122 | tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); | 122 | tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); |
123 | } | 123 | } |
124 | else { | 124 | else { |
125 | tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); | 125 | tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); |
126 | tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); | 126 | tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); |
127 | } | 127 | } |
128 | } | 128 | } |
129 | else if ( mIncidence->type() == "Todo" ) { | 129 | else if ( mIncidence->type() == "Todo" ) { |
130 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueTimeStr(); | 130 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueTimeStr(); |
131 | } | 131 | } |
132 | 132 | ||
133 | if (!mIncidence->location().isEmpty()) { | 133 | if (!mIncidence->location().isEmpty()) { |
134 | tipText += "\n"+i18n("Location: ")+mIncidence->location(); | 134 | tipText += "\n"+i18n("Location: ")+mIncidence->location(); |
135 | } | 135 | } |
136 | QToolTip::add(this,tipText,toolTipGroup(),""); | 136 | QToolTip::add(this,tipText,toolTipGroup(),""); |
137 | QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont); | 137 | QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont); |
138 | mFontPixelSize = fontinf.height();; | 138 | mFontPixelSize = fontinf.height();; |
139 | hide(); | 139 | hide(); |
140 | xPaintCoord = -1; | 140 | xPaintCoord = -1; |
141 | yPaintCoord = -1; | 141 | yPaintCoord = -1; |
142 | } | 142 | } |
143 | 143 | ||
144 | 144 | ||
145 | KOAgendaItem::~KOAgendaItem() | 145 | KOAgendaItem::~KOAgendaItem() |
146 | { | 146 | { |
147 | // qDebug("deleteKOAgendaItem::~KOAgendaItem( "); | 147 | // qDebug("deleteKOAgendaItem::~KOAgendaItem( "); |
148 | 148 | ||
149 | } | 149 | } |
150 | 150 | ||
151 | void KOAgendaItem::recreateIncidence() | 151 | void KOAgendaItem::recreateIncidence() |
152 | { | 152 | { |
153 | #if 0 | 153 | #if 0 |
154 | Incidence* newInc = mIncidence->clone(); | 154 | Incidence* newInc = mIncidence->clone(); |
155 | newInc->recreate(); | 155 | newInc->recreate(); |
156 | if ( mIncidence->doesRecur() ) { | 156 | if ( mIncidence->doesRecur() ) { |
157 | mIncidence->addExDate( mDate ); | 157 | mIncidence->addExDate( mDate ); |
158 | newInc->recurrence()->unsetRecurs(); | 158 | newInc->recurrence()->unsetRecurs(); |
159 | int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd()); | 159 | int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd()); |
160 | QTime tim = mIncidence->dtStart().time(); | 160 | QTime tim = mIncidence->dtStart().time(); |
161 | newInc->setDtStart( QDateTime(mDate, tim) ); | 161 | newInc->setDtStart( QDateTime(mDate, tim) ); |
162 | ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); | 162 | ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); |
163 | } | 163 | } |
164 | #endif | 164 | #endif |
165 | mIncidence = mIncidence->recreateCloneException( mDate ); | 165 | mIncidence = mIncidence->recreateCloneException( mDate ); |
166 | } | 166 | } |
167 | bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout) | 167 | bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout) |
168 | { | 168 | { |
169 | int size = AGENDA_ICON_SIZE; | 169 | int size = AGENDA_ICON_SIZE; |
170 | 170 | ||
171 | int yOff = 0; | 171 | int yOff = 0; |
172 | int xOff = 0; | 172 | int xOff = 0; |
173 | int x = pos().x() +3; | 173 | int x = pos().x() +3; |
174 | int y; | 174 | int y; |
175 | if ( mAllDay ) | 175 | if ( mAllDay ) |
176 | y = pos().y()+3; | 176 | y = pos().y()+3; |
177 | else | 177 | else |
178 | y = mCellYTop * ( height() / cellHeight() ) +3; | 178 | y = mCellYTop * ( height() / cellHeight() ) +3; |
179 | if (mIncidence->cancelled()) { | 179 | if (mIncidence->cancelled()) { |
180 | int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x; | 180 | int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x; |
181 | int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y; | 181 | int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y; |
182 | p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 ); | 182 | p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 ); |
183 | p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos ); | 183 | p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos ); |
184 | if ( horLayout ) | 184 | if ( horLayout ) |
185 | ++xOff; | 185 | ++xOff; |
186 | else | 186 | else |
187 | ++yOff; | 187 | ++yOff; |
188 | } | 188 | } |
189 | if (mIncidence->isAlarmEnabled()) { | 189 | if (mIncidence->isAlarmEnabled()) { |
190 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red ); | 190 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red ); |
191 | if ( horLayout ) | 191 | if ( horLayout ) |
192 | ++xOff; | 192 | ++xOff; |
193 | else | 193 | else |
194 | ++yOff; | 194 | ++yOff; |
195 | } | 195 | } |
196 | if (mIncidence->recurrence()->doesRecur()) { | 196 | if (mIncidence->recurrence()->doesRecur()) { |
197 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue ); | 197 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue ); |
198 | if ( horLayout ) | 198 | if ( horLayout ) |
199 | ++xOff; | 199 | ++xOff; |
200 | else | 200 | else |
201 | ++yOff; | 201 | ++yOff; |
202 | } | 202 | } |
203 | if (mIncidence->description().length() > 0) { | 203 | if (mIncidence->description().length() > 0) { |
204 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen ); | 204 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen ); |
205 | if ( horLayout ) | 205 | if ( horLayout ) |
206 | ++xOff; | 206 | ++xOff; |
207 | else | 207 | else |
208 | ++yOff; | 208 | ++yOff; |
209 | } | 209 | } |
210 | if (mIncidence->isReadOnly()) { | 210 | if (mIncidence->isReadOnly()) { |
211 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white ); | 211 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white ); |
212 | if ( horLayout ) | 212 | if ( horLayout ) |
213 | ++xOff; | 213 | ++xOff; |
214 | else | 214 | else |
215 | ++yOff; | 215 | ++yOff; |
216 | } | 216 | } |
217 | 217 | ||
218 | if (mIncidence->attendeeCount()>0) { | 218 | if (mIncidence->attendeeCount()>0) { |
219 | 219 | ||
220 | if (mIncidence->organizer() == KOPrefs::instance()->email()) { | 220 | if (mIncidence->organizer() == KOPrefs::instance()->email()) { |
221 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black ); | 221 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black ); |
222 | if ( horLayout ) | 222 | if ( horLayout ) |
223 | ++xOff; | 223 | ++xOff; |
224 | else | 224 | else |
225 | ++yOff; | 225 | ++yOff; |
226 | } else { | 226 | } else { |
227 | Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 227 | Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
228 | if (me!=0) { | 228 | if (me!=0) { |
229 | 229 | ||
230 | 230 | ||
231 | } else { | 231 | } else { |
232 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow ); | 232 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow ); |
233 | if ( horLayout ) | 233 | if ( horLayout ) |
234 | ++xOff; | 234 | ++xOff; |
235 | else | 235 | else |
236 | ++yOff; | 236 | ++yOff; |
237 | 237 | ||
238 | } | 238 | } |
239 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow ); | 239 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow ); |
240 | if ( horLayout ) | 240 | if ( horLayout ) |
241 | ++xOff; | 241 | ++xOff; |
242 | else | 242 | else |
243 | ++yOff; | 243 | ++yOff; |
244 | 244 | ||
245 | } | 245 | } |
246 | 246 | ||
247 | } | 247 | } |
248 | return ( yOff || xOff ); | 248 | return ( yOff || xOff ); |
249 | } | 249 | } |
250 | 250 | ||
251 | 251 | ||
252 | void KOAgendaItem::select(bool selected) | 252 | void KOAgendaItem::select(bool selected) |
253 | { | 253 | { |
254 | //qDebug("select %d %d",firstMultiItem(), nextMultiItem() ); | 254 | //qDebug("select %d %d",firstMultiItem(), nextMultiItem() ); |
255 | if (mSelected == selected) return; | 255 | if (mSelected == selected) return; |
256 | mSelected = selected; | 256 | mSelected = selected; |
257 | if ( ! isVisible() ) | 257 | if ( ! isVisible() ) |
258 | return; | 258 | return; |
259 | if ( firstMultiItem() ) | 259 | if ( firstMultiItem() ) |
260 | firstMultiItem()->select( selected ); | 260 | firstMultiItem()->select( selected ); |
261 | if ( !firstMultiItem() && nextMultiItem() ) { | 261 | if ( !firstMultiItem() && nextMultiItem() ) { |
262 | KOAgendaItem * placeItem = nextMultiItem(); | 262 | KOAgendaItem * placeItem = nextMultiItem(); |
263 | while ( placeItem ) { | 263 | while ( placeItem ) { |
264 | placeItem->select( selected ); | 264 | placeItem->select( selected ); |
265 | placeItem = placeItem->nextMultiItem(); | 265 | placeItem = placeItem->nextMultiItem(); |
266 | } | 266 | } |
267 | } | 267 | } |
268 | globalFlagBlockAgendaItemUpdate = 0; | 268 | globalFlagBlockAgendaItemUpdate = 0; |
269 | paintMe( selected ); | 269 | paintMe( selected ); |
270 | globalFlagBlockAgendaItemUpdate = 1; | 270 | globalFlagBlockAgendaItemUpdate = 1; |
271 | repaint( false ); | 271 | repaint( false ); |
272 | } | 272 | } |
273 | 273 | ||
274 | 274 | ||
275 | /* | 275 | /* |
276 | The eventFilter has to filter the mouse events of the agenda item childs. The | 276 | The eventFilter has to filter the mouse events of the agenda item childs. The |
277 | events are fed into the event handling method of KOAgendaItem. This allows the | 277 | events are fed into the event handling method of KOAgendaItem. This allows the |
278 | KOAgenda to handle the KOAgendaItems by using an eventFilter. | 278 | KOAgenda to handle the KOAgendaItems by using an eventFilter. |
279 | */ | 279 | */ |
280 | bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e ) | 280 | bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e ) |
281 | { | 281 | { |
282 | if (e->type() == QEvent::MouseButtonPress || | 282 | if (e->type() == QEvent::MouseButtonPress || |
283 | e->type() == QEvent::MouseButtonDblClick || | 283 | e->type() == QEvent::MouseButtonDblClick || |
284 | e->type() == QEvent::MouseButtonRelease || | 284 | e->type() == QEvent::MouseButtonRelease || |
285 | e->type() == QEvent::MouseMove) { | 285 | e->type() == QEvent::MouseMove) { |
286 | QMouseEvent *me = (QMouseEvent *)e; | 286 | QMouseEvent *me = (QMouseEvent *)e; |
287 | QPoint itemPos = this->mapFromGlobal(((QWidget *)object)-> | 287 | QPoint itemPos = this->mapFromGlobal(((QWidget *)object)-> |
288 | mapToGlobal(me->pos())); | 288 | mapToGlobal(me->pos())); |
289 | QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state()); | 289 | QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state()); |
290 | return event(&returnEvent); | 290 | return event(&returnEvent); |
291 | } else { | 291 | } else { |
292 | return false; | 292 | return false; |
293 | } | 293 | } |
294 | } | 294 | } |
295 | void KOAgendaItem::repaintMe( ) | 295 | void KOAgendaItem::repaintMe( ) |
296 | { | 296 | { |
297 | paintMe ( mSelected ); | 297 | paintMe ( mSelected ); |
298 | } | 298 | } |
299 | void KOAgendaItem::paintMe( bool selected, QPainter* paint ) | 299 | void KOAgendaItem::paintMe( bool selected, QPainter* paint ) |
300 | { | 300 | { |
301 | if ( globalFlagBlockAgendaItemUpdate && ! selected) | 301 | if ( globalFlagBlockAgendaItemUpdate && ! selected) |
302 | return; | 302 | return; |
303 | QPainter pa; | 303 | QPainter pa; |
304 | 304 | ||
305 | if ( mSelected ) { | 305 | if ( mSelected ) { |
306 | pa.begin( paintPixSel() ); | 306 | pa.begin( paintPixSel() ); |
307 | } else { | 307 | } else { |
308 | if ( mAllDay ) | 308 | if ( mAllDay ) |
309 | pa.begin( paintPixAllday() ); | 309 | pa.begin( paintPixAllday() ); |
310 | else | 310 | else |
311 | pa.begin( paintPix() ); | 311 | pa.begin( paintPix() ); |
312 | } | 312 | } |
313 | int x, yy, w, h; | 313 | int x, yy, w, h; |
314 | float nfh; | 314 | float nfh; |
315 | x = pos().x(); w = width(); h = height (); | 315 | x = pos().x(); w = width(); h = height (); |
316 | if ( mAllDay ) | 316 | if ( mAllDay ) |
317 | yy = y(); | 317 | yy = y(); |
318 | else | 318 | else |
319 | yy = mCellYTop * ( height() / cellHeight() ); | 319 | yy = mCellYTop * ( height() / cellHeight() ); |
320 | xPaintCoord= x; | 320 | xPaintCoord= x; |
321 | yPaintCoord = yy; | 321 | yPaintCoord = yy; |
322 | wPaintCoord = width(); | 322 | wPaintCoord = width(); |
323 | hPaintCoord = height(); | 323 | hPaintCoord = height(); |
324 | //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height()); | 324 | //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height()); |
325 | if ( paint == 0 ) | 325 | if ( paint == 0 ) |
326 | paint = &pa; | 326 | paint = &pa; |
327 | bool horLayout = ( w < h ); | 327 | bool horLayout = ( w < h ); |
328 | int maxhei = mFontPixelSize+4; | 328 | int maxhei = mFontPixelSize+4; |
329 | if ( horLayout ) | 329 | if ( horLayout ) |
330 | maxhei += AGENDA_ICON_SIZE -4; | 330 | maxhei += AGENDA_ICON_SIZE -4; |
331 | bool small = ( h < maxhei ); | 331 | bool small = ( h < maxhei ); |
332 | if ( ! small ) | 332 | if ( ! small ) |
333 | paint->setFont(KOPrefs::instance()->mAgendaViewFont); | 333 | paint->setFont(KOPrefs::instance()->mAgendaViewFont); |
334 | else { | 334 | else { |
335 | QFont f = KOPrefs::instance()->mAgendaViewFont; | 335 | QFont f = KOPrefs::instance()->mAgendaViewFont; |
336 | f.setBold( false ); | 336 | f.setBold( false ); |
337 | int fh = f.pointSize(); | 337 | int fh = f.pointSize(); |
338 | nfh = (((float)height())/(float)(mFontPixelSize+4))*fh; | 338 | nfh = (((float)height())/(float)(mFontPixelSize+4))*fh; |
339 | if ( nfh < 6 ) | 339 | if ( nfh < 6 ) |
340 | nfh = 6; | 340 | nfh = 6; |
341 | f.setPointSize( nfh ); | 341 | f.setPointSize( nfh ); |
342 | paint->setFont(f); | 342 | paint->setFont(f); |
343 | } | 343 | } |
344 | paint->fillRect ( x, yy, w, h, mBackgroundColor ); | 344 | paint->fillRect ( x, yy, w, h, mBackgroundColor ); |
345 | static const QPixmap completedPxmp = SmallIcon("greenhook16"); | 345 | static const QPixmap completedPxmp = SmallIcon("greenhook16"); |
346 | static const QPixmap overduePxmp = SmallIcon("redcross16"); | 346 | static const QPixmap overduePxmp = SmallIcon("redcross16"); |
347 | if ( mIncidence->type() == "Todo" ) { | 347 | if ( mIncidence->type() == "Todo" ) { |
348 | Todo* tempTodo = static_cast<Todo*>(mIncidence); | 348 | Todo* tempTodo = static_cast<Todo*>(mIncidence); |
349 | int xx = pos().x()+(width()-completedPxmp.width()-3 ); | 349 | int xx = pos().x()+(width()-completedPxmp.width()-3 ); |
350 | int yyy = yy+3; | 350 | int yyy = yy+3; |
351 | if ( tempTodo->isCompleted() ) | 351 | if ( tempTodo->isCompleted() ) |
352 | paint->drawPixmap ( xx, yyy, completedPxmp ); | 352 | paint->drawPixmap ( xx, yyy, completedPxmp ); |
353 | else { | 353 | else { |
354 | paint->drawPixmap ( xx, yyy, overduePxmp ); | 354 | paint->drawPixmap ( xx, yyy, overduePxmp ); |
355 | 355 | ||
356 | } | 356 | } |
357 | } | 357 | } |
358 | bool addIcon = false; | 358 | bool addIcon = false; |
359 | if ( ! small || w > 3 * h || h > 3* w ) | 359 | if ( ! small || w > 3 * h || h > 3* w ) |
360 | addIcon = updateIcons( paint, horLayout ); | 360 | addIcon = updateIcons( paint, horLayout ); |
361 | 361 | ||
362 | qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); | 362 | qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); |
363 | //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); | 363 | //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); |
364 | if ( ! small ) { | 364 | if ( ! small ) { |
365 | x += 3; yy += 3;w -= 6; h-= 5; | 365 | x += 3; yy += 3;w -= 6; h-= 5; |
366 | } else { | 366 | } else { |
367 | x += 2; yy += 1;w -= 4; h-= 4; | 367 | x += 2; yy += 1;w -= 4; h-= 4; |
368 | if ( nfh < 6.01 ) { | 368 | if ( nfh < 6.01 ) { |
369 | yy -= 2; | 369 | yy -= 2; |
370 | h += 4; | 370 | h += 4; |
371 | } | 371 | } |
372 | else | 372 | else |
373 | if ( nfh < h -2 ) | 373 | if ( nfh < h -2 ) |
374 | ++yy; | 374 | ++yy; |
375 | } | 375 | } |
376 | int align; | 376 | int align; |
377 | #ifndef DESKTOP_VERSION | 377 | #ifndef DESKTOP_VERSION |
378 | align = ( AlignLeft|WordBreak|AlignTop); | 378 | align = ( AlignLeft|WordBreak|AlignTop); |
379 | #else | 379 | #else |
380 | align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); | 380 | align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); |
381 | #endif | 381 | #endif |
382 | if ( addIcon ) { | 382 | if ( addIcon ) { |
383 | if ( ! horLayout ) { | 383 | if ( ! horLayout ) { |
384 | x += AGENDA_ICON_SIZE+3; | 384 | x += AGENDA_ICON_SIZE+3; |
385 | w -= (AGENDA_ICON_SIZE+3); | 385 | w -= (AGENDA_ICON_SIZE+3); |
386 | } | 386 | } |
387 | else { | 387 | else { |
388 | yy+= AGENDA_ICON_SIZE+2; | 388 | yy+= AGENDA_ICON_SIZE+2; |
389 | h -=(AGENDA_ICON_SIZE+3); | 389 | h -=(AGENDA_ICON_SIZE+3); |
390 | } | 390 | } |
391 | } | 391 | } |
392 | int colsum = mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue(); | 392 | int colsum = mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue(); |
393 | if ( colsum < 250 ) | 393 | if ( colsum < 250 ) |
394 | paint->setPen ( white); | 394 | paint->setPen ( white); |
395 | if ( x < 0 ) { | 395 | if ( x < 0 ) { |
396 | w = w+x-3; | 396 | w = w+x-3; |
397 | x = 3; | 397 | x = 3; |
398 | if ( w > parentWidget()->width() ){ | 398 | if ( w > parentWidget()->width() ){ |
399 | w = parentWidget()->width() - 6; | 399 | w = parentWidget()->width() - 6; |
400 | #ifndef DESKTOP_VERSION | 400 | #ifndef DESKTOP_VERSION |
401 | align = ( AlignCenter|WordBreak); | 401 | align = ( AlignCenter|WordBreak); |
402 | #else | 402 | #else |
403 | align = ( AlignCenter|BreakAnywhere|WordBreak); | 403 | align = ( AlignCenter|BreakAnywhere|WordBreak); |
404 | #endif | 404 | #endif |
405 | 405 | ||
406 | } | 406 | } |
407 | } | 407 | } |
408 | QRect dr; | 408 | QRect dr; |
409 | paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); | 409 | paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); |
410 | if ( mIncidence->cancelled() ){ | 410 | if ( mIncidence->cancelled() ){ |
411 | if ( ! small ) { | 411 | if ( ! small ) { |
412 | QFontMetrics fm ( paint->font() ); | 412 | QFontMetrics fm ( paint->font() ); |
413 | paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); | 413 | paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); |
414 | } | 414 | } |
415 | 415 | ||
416 | } | 416 | } |
417 | pa.end(); | 417 | pa.end(); |
418 | 418 | ||
419 | } | 419 | } |
420 | void KOAgendaItem::resizePixmap( int w , int h ) | 420 | void KOAgendaItem::resizePixmap( int w , int h ) |
421 | { | 421 | { |
422 | paintPix()->resize( w, h ); | 422 | paintPix()->resize( w, h ); |
423 | paintPixSel()->resize( w, h ); | 423 | paintPixSel()->resize( w, h ); |
424 | 424 | ||
425 | } | 425 | } |
426 | QPixmap * KOAgendaItem::paintPix() | 426 | QPixmap * KOAgendaItem::paintPix() |
427 | { | 427 | { |
428 | static QPixmap* mPaintPix = 0; | 428 | static QPixmap* mPaintPix = 0; |
429 | if ( ! mPaintPix ) | 429 | if ( ! mPaintPix ) |
430 | mPaintPix = new QPixmap(); | 430 | mPaintPix = new QPixmap(1,1); |
431 | return mPaintPix ; | 431 | return mPaintPix ; |
432 | } | 432 | } |
433 | QPixmap * KOAgendaItem::paintPixAllday() | 433 | QPixmap * KOAgendaItem::paintPixAllday() |
434 | { | 434 | { |
435 | static QPixmap* mPaintPixA = 0; | 435 | static QPixmap* mPaintPixA = 0; |
436 | if ( ! mPaintPixA ) | 436 | if ( ! mPaintPixA ) |
437 | mPaintPixA = new QPixmap(); | 437 | mPaintPixA = new QPixmap(1,1); |
438 | return mPaintPixA ; | 438 | return mPaintPixA ; |
439 | } | 439 | } |
440 | QPixmap * KOAgendaItem::paintPixSel() | 440 | QPixmap * KOAgendaItem::paintPixSel() |
441 | { | 441 | { |
442 | static QPixmap* mPaintPixSel = 0; | 442 | static QPixmap* mPaintPixSel = 0; |
443 | if ( ! mPaintPixSel ) | 443 | if ( ! mPaintPixSel ) |
444 | mPaintPixSel = new QPixmap(); | 444 | mPaintPixSel = new QPixmap(1,1); |
445 | return mPaintPixSel ; | 445 | return mPaintPixSel ; |
446 | } | 446 | } |
447 | void KOAgendaItem::paintEvent ( QPaintEvent *e ) | 447 | void KOAgendaItem::paintEvent ( QPaintEvent *e ) |
448 | { | 448 | { |
449 | 449 | ||
450 | if ( globalFlagBlockAgendaItemPaint ) | 450 | if ( globalFlagBlockAgendaItemPaint ) |
451 | return; | 451 | return; |
452 | if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) | 452 | if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) |
453 | return; | 453 | return; |
454 | int yy; | 454 | int yy; |
455 | if ( mAllDay ) | 455 | if ( mAllDay ) |
456 | yy = y(); | 456 | yy = y(); |
457 | else | 457 | else |
458 | yy = mCellYTop * ( height() / cellHeight() ); | 458 | yy = mCellYTop * ( height() / cellHeight() ); |
459 | int xx = x(); | 459 | int xx = x(); |
460 | if ( xPaintCoord != xx || yPaintCoord != yy || | 460 | if ( xPaintCoord != xx || yPaintCoord != yy || |
461 | wPaintCoord != width() || hPaintCoord != height()) { | 461 | wPaintCoord != width() || hPaintCoord != height()) { |
462 | xPaintCoord= xx; | 462 | xPaintCoord= xx; |
463 | yPaintCoord = yy; | 463 | yPaintCoord = yy; |
464 | wPaintCoord = width(); | 464 | wPaintCoord = width(); |
465 | hPaintCoord = height(); | 465 | hPaintCoord = height(); |
466 | globalFlagBlockAgendaItemUpdate = 0; | 466 | globalFlagBlockAgendaItemUpdate = 0; |
467 | paintMe( mSelected ); | 467 | paintMe( mSelected ); |
468 | //qDebug("calling paintMe "); | 468 | //qDebug("calling paintMe "); |
469 | globalFlagBlockAgendaItemUpdate = 1; | 469 | globalFlagBlockAgendaItemUpdate = 1; |
470 | } | 470 | } |
471 | int rx, ry, rw, rh; | 471 | int rx, ry, rw, rh; |
472 | rx = e->rect().x(); | 472 | rx = e->rect().x(); |
473 | ry = e->rect().y(); | 473 | ry = e->rect().y(); |
474 | rw = e->rect().width(); | 474 | rw = e->rect().width(); |
475 | rh = e->rect().height(); | 475 | rh = e->rect().height(); |
476 | //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); | 476 | //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); |
477 | 477 | ||
478 | QPixmap* paintFrom ; | 478 | QPixmap* paintFrom ; |
479 | if ( mSelected ) { | 479 | if ( mSelected ) { |
480 | paintFrom = paintPixSel(); | 480 | paintFrom = paintPixSel(); |
481 | } else { | 481 | } else { |
482 | if ( mAllDay ) | 482 | if ( mAllDay ) |
483 | paintFrom = paintPixAllday(); | 483 | paintFrom = paintPixAllday(); |
484 | else | 484 | else |
485 | paintFrom = paintPix(); | 485 | paintFrom = paintPix(); |
486 | } | 486 | } |
487 | bitBlt (this, rx, ry, paintFrom, x()+rx ,yPaintCoord+ry, rw, rh ,CopyROP); | 487 | bitBlt (this, rx, ry, paintFrom, x()+rx ,yPaintCoord+ry, rw, rh ,CopyROP); |
488 | } | 488 | } |
489 | void KOAgendaItem::computeText() | 489 | void KOAgendaItem::computeText() |
490 | { | 490 | { |
491 | mDisplayedText = mIncidence->summary(); | 491 | mDisplayedText = mIncidence->summary(); |
492 | if ( (mIncidence->type() == "Todo") ) { | 492 | if ( (mIncidence->type() == "Todo") ) { |
493 | if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) | 493 | if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) |
494 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; | 494 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; |
495 | else if ( !(mIncidence->doesFloat())) | 495 | else if ( !(mIncidence->doesFloat())) |
496 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; | 496 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; |
497 | 497 | ||
498 | 498 | ||
499 | 499 | ||
500 | } else { | 500 | } else { |
501 | if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) | 501 | if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) |
502 | mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + "-" + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; | 502 | mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + "-" + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; |
503 | 503 | ||
504 | if ( mAllDay ) { | 504 | if ( mAllDay ) { |
505 | if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { | 505 | if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { |
506 | mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ; | 506 | mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ; |
507 | } | 507 | } |
508 | } | 508 | } |
509 | 509 | ||
510 | } | 510 | } |
511 | 511 | ||
512 | if ( !mIncidence->location().isEmpty() ) { | 512 | if ( !mIncidence->location().isEmpty() ) { |
513 | if ( mAllDay ) | 513 | if ( mAllDay ) |
514 | mDisplayedText += " ("; | 514 | mDisplayedText += " ("; |
515 | else | 515 | else |
516 | mDisplayedText += "\n("; | 516 | mDisplayedText += "\n("; |
517 | mDisplayedText += mIncidence->location() +")"; | 517 | mDisplayedText += mIncidence->location() +")"; |
518 | } | 518 | } |
519 | } | 519 | } |
520 | void KOAgendaItem::updateItem() | 520 | void KOAgendaItem::updateItem() |
521 | { | 521 | { |
522 | computeText(); | 522 | computeText(); |
523 | 523 | ||
524 | //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y()); | 524 | //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y()); |
525 | paintMe( mSelected ); | 525 | paintMe( mSelected ); |
526 | repaint( false); | 526 | repaint( false); |
527 | } | 527 | } |
528 | 528 | ||
529 | void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) | 529 | void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) |
530 | { | 530 | { |
531 | //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); | 531 | //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); |
532 | paintMe( mSelected ); | 532 | paintMe( mSelected ); |
533 | repaint( false ); | 533 | repaint( false ); |
534 | } | 534 | } |
535 | 535 | ||
536 | /* | 536 | /* |
537 | Return height of item in units of agenda cells | 537 | Return height of item in units of agenda cells |
538 | */ | 538 | */ |
539 | int KOAgendaItem::cellHeight() | 539 | int KOAgendaItem::cellHeight() |
540 | { | 540 | { |
541 | int ret = mCellYBottom - mCellYTop + 1; | 541 | int ret = mCellYBottom - mCellYTop + 1; |
542 | if ( ret <= 0 ) { | 542 | if ( ret <= 0 ) { |
543 | ret = 1; | 543 | ret = 1; |
544 | mCellYBottom = 0; | 544 | mCellYBottom = 0; |
545 | mCellYTop = 0; | 545 | mCellYTop = 0; |
546 | } | 546 | } |
547 | return ret; | 547 | return ret; |
548 | } | 548 | } |
549 | 549 | ||
550 | /* | 550 | /* |
551 | Return height of item in units of agenda cells | 551 | Return height of item in units of agenda cells |
552 | */ | 552 | */ |
553 | int KOAgendaItem::cellWidth() | 553 | int KOAgendaItem::cellWidth() |
554 | { | 554 | { |
555 | return mCellXWidth - mCellX + 1; | 555 | return mCellXWidth - mCellX + 1; |
556 | } | 556 | } |
557 | 557 | ||
558 | void KOAgendaItem::setItemDate(QDate qd) | 558 | void KOAgendaItem::setItemDate(QDate qd) |
559 | { | 559 | { |
560 | mDate = qd; | 560 | mDate = qd; |
561 | } | 561 | } |
562 | 562 | ||
563 | void KOAgendaItem::setCellXY(int X, int YTop, int YBottom) | 563 | void KOAgendaItem::setCellXY(int X, int YTop, int YBottom) |
564 | { | 564 | { |
565 | mCellX = X; | 565 | mCellX = X; |
566 | mCellYTop = YTop; | 566 | mCellYTop = YTop; |
567 | mCellYBottom = YBottom; | 567 | mCellYBottom = YBottom; |
568 | } | 568 | } |
569 | 569 | ||
570 | void KOAgendaItem::setCellXWidth(int xwidth) | 570 | void KOAgendaItem::setCellXWidth(int xwidth) |
571 | { | 571 | { |
572 | mCellXWidth = xwidth; | 572 | mCellXWidth = xwidth; |
573 | } | 573 | } |
574 | 574 | ||
575 | void KOAgendaItem::setCellX(int XLeft, int XRight) | 575 | void KOAgendaItem::setCellX(int XLeft, int XRight) |
576 | { | 576 | { |
577 | mCellX = XLeft; | 577 | mCellX = XLeft; |
578 | mCellXWidth = XRight; | 578 | mCellXWidth = XRight; |
579 | } | 579 | } |
580 | 580 | ||
581 | void KOAgendaItem::setCellY(int YTop, int YBottom) | 581 | void KOAgendaItem::setCellY(int YTop, int YBottom) |
582 | { | 582 | { |
583 | mCellYTop = YTop; | 583 | mCellYTop = YTop; |
584 | mCellYBottom = YBottom; | 584 | mCellYBottom = YBottom; |
585 | } | 585 | } |
586 | 586 | ||
587 | void KOAgendaItem::setSubCell(int subCell) | 587 | void KOAgendaItem::setSubCell(int subCell) |
588 | { | 588 | { |
589 | mSubCell = subCell; | 589 | mSubCell = subCell; |
590 | } | 590 | } |
591 | 591 | ||
592 | void KOAgendaItem::setSubCells(int subCells) | 592 | void KOAgendaItem::setSubCells(int subCells) |
593 | { | 593 | { |
594 | mSubCells = subCells; | 594 | mSubCells = subCells; |
595 | } | 595 | } |
596 | 596 | ||
597 | void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next, | 597 | void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next, |
598 | KOAgendaItem *last) | 598 | KOAgendaItem *last) |
599 | { | 599 | { |
600 | mFirstMultiItem = first; | 600 | mFirstMultiItem = first; |
601 | mNextMultiItem = next; | 601 | mNextMultiItem = next; |
602 | mLastMultiItem = last; | 602 | mLastMultiItem = last; |
603 | } | 603 | } |
604 | 604 | ||
605 | void KOAgendaItem::startMove() | 605 | void KOAgendaItem::startMove() |
606 | { | 606 | { |
607 | mStartCellX = mCellX; | 607 | mStartCellX = mCellX; |
608 | mStartCellXWidth = mCellXWidth; | 608 | mStartCellXWidth = mCellXWidth; |
609 | mStartCellYTop = mCellYTop; | 609 | mStartCellYTop = mCellYTop; |
610 | mStartCellYBottom = mCellYBottom; | 610 | mStartCellYBottom = mCellYBottom; |
611 | } | 611 | } |
612 | 612 | ||
613 | void KOAgendaItem::resetMove() | 613 | void KOAgendaItem::resetMove() |
614 | { | 614 | { |
615 | mCellX = mStartCellX; | 615 | mCellX = mStartCellX; |
616 | mCellXWidth = mStartCellXWidth; | 616 | mCellXWidth = mStartCellXWidth; |
617 | mCellYTop = mStartCellYTop; | 617 | mCellYTop = mStartCellYTop; |
618 | mCellYBottom = mStartCellYBottom; | 618 | mCellYBottom = mStartCellYBottom; |
619 | } | 619 | } |
620 | 620 | ||
621 | void KOAgendaItem::moveRelative(int dx, int dy) | 621 | void KOAgendaItem::moveRelative(int dx, int dy) |
622 | { | 622 | { |
623 | int newX = cellX() + dx; | 623 | int newX = cellX() + dx; |
624 | int newXWidth = cellXWidth() + dx; | 624 | int newXWidth = cellXWidth() + dx; |
625 | int newYTop = cellYTop() + dy; | 625 | int newYTop = cellYTop() + dy; |
626 | int newYBottom = cellYBottom() + dy; | 626 | int newYBottom = cellYBottom() + dy; |
627 | setCellXY(newX,newYTop,newYBottom); | 627 | setCellXY(newX,newYTop,newYBottom); |
628 | setCellXWidth(newXWidth); | 628 | setCellXWidth(newXWidth); |
629 | } | 629 | } |
630 | 630 | ||
631 | void KOAgendaItem::expandTop(int dy) | 631 | void KOAgendaItem::expandTop(int dy) |
632 | { | 632 | { |
633 | int newYTop = cellYTop() + dy; | 633 | int newYTop = cellYTop() + dy; |
634 | int newYBottom = cellYBottom(); | 634 | int newYBottom = cellYBottom(); |
635 | if (newYTop > newYBottom) newYTop = newYBottom; | 635 | if (newYTop > newYBottom) newYTop = newYBottom; |
636 | setCellY(newYTop, newYBottom); | 636 | setCellY(newYTop, newYBottom); |
637 | } | 637 | } |
638 | 638 | ||
639 | void KOAgendaItem::expandBottom(int dy) | 639 | void KOAgendaItem::expandBottom(int dy) |
640 | { | 640 | { |
641 | int newYTop = cellYTop(); | 641 | int newYTop = cellYTop(); |
642 | int newYBottom = cellYBottom() + dy; | 642 | int newYBottom = cellYBottom() + dy; |
643 | if (newYBottom < newYTop) newYBottom = newYTop; | 643 | if (newYBottom < newYTop) newYBottom = newYTop; |
644 | setCellY(newYTop, newYBottom); | 644 | setCellY(newYTop, newYBottom); |
645 | } | 645 | } |
646 | 646 | ||
647 | void KOAgendaItem::expandLeft(int dx) | 647 | void KOAgendaItem::expandLeft(int dx) |
648 | { | 648 | { |
649 | int newX = cellX() + dx; | 649 | int newX = cellX() + dx; |
650 | int newXWidth = cellXWidth(); | 650 | int newXWidth = cellXWidth(); |
651 | if (newX > newXWidth) newX = newXWidth; | 651 | if (newX > newXWidth) newX = newXWidth; |
652 | setCellX(newX,newXWidth); | 652 | setCellX(newX,newXWidth); |
653 | } | 653 | } |
654 | 654 | ||
655 | void KOAgendaItem::expandRight(int dx) | 655 | void KOAgendaItem::expandRight(int dx) |
656 | { | 656 | { |
657 | int newX = cellX(); | 657 | int newX = cellX(); |
658 | int newXWidth = cellXWidth() + dx; | 658 | int newXWidth = cellXWidth() + dx; |
659 | if (newXWidth < newX) newXWidth = newX; | 659 | if (newXWidth < newX) newXWidth = newX; |
660 | setCellX(newX,newXWidth); | 660 | setCellX(newX,newXWidth); |
661 | } | 661 | } |
662 | 662 | ||
663 | QToolTipGroup *KOAgendaItem::toolTipGroup() | 663 | QToolTipGroup *KOAgendaItem::toolTipGroup() |
664 | { | 664 | { |
665 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); | 665 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); |
666 | return mToolTipGroup; | 666 | return mToolTipGroup; |
667 | } | 667 | } |
668 | 668 | ||
669 | void KOAgendaItem::dragEnterEvent( QDragEnterEvent *e ) | 669 | void KOAgendaItem::dragEnterEvent( QDragEnterEvent *e ) |
670 | { | 670 | { |
671 | #ifndef KORG_NODND | 671 | #ifndef KORG_NODND |
672 | if ( ICalDrag::canDecode( e ) || VCalDrag::canDecode( e ) || | 672 | if ( ICalDrag::canDecode( e ) || VCalDrag::canDecode( e ) || |
673 | !QTextDrag::canDecode( e ) ) { | 673 | !QTextDrag::canDecode( e ) ) { |
674 | e->ignore(); | 674 | e->ignore(); |
675 | return; | 675 | return; |
676 | } | 676 | } |
677 | e->accept(); | 677 | e->accept(); |
678 | #endif | 678 | #endif |
679 | } | 679 | } |
680 | 680 | ||
681 | void KOAgendaItem::dropEvent( QDropEvent *e ) | 681 | void KOAgendaItem::dropEvent( QDropEvent *e ) |
682 | { | 682 | { |
683 | #ifndef KORG_NODND | 683 | #ifndef KORG_NODND |
684 | QString text; | 684 | QString text; |
685 | if(QTextDrag::decode(e,text)) | 685 | if(QTextDrag::decode(e,text)) |
686 | { | 686 | { |
687 | kdDebug() << "Dropped : " << text << endl; | 687 | kdDebug() << "Dropped : " << text << endl; |
688 | QStringList emails = QStringList::split(",",text); | 688 | QStringList emails = QStringList::split(",",text); |
689 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { | 689 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { |
690 | kdDebug() << " Email: " << (*it) << endl; | 690 | kdDebug() << " Email: " << (*it) << endl; |
691 | int pos = (*it).find("<"); | 691 | int pos = (*it).find("<"); |
692 | QString name = (*it).left(pos); | 692 | QString name = (*it).left(pos); |
693 | QString email = (*it).mid(pos); | 693 | QString email = (*it).mid(pos); |
694 | if (!email.isEmpty()) { | 694 | if (!email.isEmpty()) { |
695 | mIncidence->addAttendee(new Attendee(name,email)); | 695 | mIncidence->addAttendee(new Attendee(name,email)); |
696 | } | 696 | } |
697 | } | 697 | } |
698 | } | 698 | } |
699 | #endif | 699 | #endif |
700 | } | 700 | } |
701 | 701 | ||
702 | 702 | ||
703 | QPtrList<KOAgendaItem> KOAgendaItem::conflictItems() | 703 | QPtrList<KOAgendaItem> KOAgendaItem::conflictItems() |
704 | { | 704 | { |
705 | return mConflictItems; | 705 | return mConflictItems; |
706 | } | 706 | } |
707 | 707 | ||
708 | void KOAgendaItem::setConflictItems(QPtrList<KOAgendaItem> ci) | 708 | void KOAgendaItem::setConflictItems(QPtrList<KOAgendaItem> ci) |
709 | { | 709 | { |
710 | mConflictItems = ci; | 710 | mConflictItems = ci; |
711 | KOAgendaItem *item; | 711 | KOAgendaItem *item; |
712 | for ( item=mConflictItems.first(); item != 0; | 712 | for ( item=mConflictItems.first(); item != 0; |
713 | item=mConflictItems.next() ) { | 713 | item=mConflictItems.next() ) { |
714 | item->addConflictItem(this); | 714 | item->addConflictItem(this); |
715 | } | 715 | } |
716 | } | 716 | } |
717 | 717 | ||
718 | void KOAgendaItem::addConflictItem(KOAgendaItem *ci) | 718 | void KOAgendaItem::addConflictItem(KOAgendaItem *ci) |
719 | { | 719 | { |
720 | if (mConflictItems.find(ci)<0) | 720 | if (mConflictItems.find(ci)<0) |
721 | mConflictItems.append(ci); | 721 | mConflictItems.append(ci); |
722 | } | 722 | } |