-rw-r--r-- | korganizer/komonthview.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index c125ce9..f983ff9 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -1250,415 +1250,421 @@ void KOMonthView::updateView() | |||
1250 | incidenceEnd = incidenceStart.addDays( eventlen ); | 1250 | incidenceEnd = incidenceStart.addDays( eventlen ); |
1251 | int st = incidenceStart.date().daysTo( endDate ); | 1251 | int st = incidenceStart.date().daysTo( endDate ); |
1252 | if ( st >= 0 ) { // start before timeend | 1252 | if ( st >= 0 ) { // start before timeend |
1253 | int end = mStartDate.daysTo( incidenceEnd.date() ); | 1253 | int end = mStartDate.daysTo( incidenceEnd.date() ); |
1254 | if ( end >= 0 ) { // end after timestart --- got one! | 1254 | if ( end >= 0 ) { // end after timestart --- got one! |
1255 | //normalize | 1255 | //normalize |
1256 | st = timeSpan - st; | 1256 | st = timeSpan - st; |
1257 | if ( st < 0 ) st = 0; | 1257 | if ( st < 0 ) st = 0; |
1258 | if ( end > timeSpan ) end = timeSpan; | 1258 | if ( end > timeSpan ) end = timeSpan; |
1259 | int iii; | 1259 | int iii; |
1260 | //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); | 1260 | //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); |
1261 | for ( iii = st;iii<= end;++iii) | 1261 | for ( iii = st;iii<= end;++iii) |
1262 | (*cells)[iii]->insertEvent( event ); | 1262 | (*cells)[iii]->insertEvent( event ); |
1263 | } | 1263 | } |
1264 | } | 1264 | } |
1265 | } else { | 1265 | } else { |
1266 | if ( invalid ) | 1266 | if ( invalid ) |
1267 | break; | 1267 | break; |
1268 | invalid = true; | 1268 | invalid = true; |
1269 | //qDebug("invalid %s", event->summary().latin1()); | 1269 | //qDebug("invalid %s", event->summary().latin1()); |
1270 | incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; | 1270 | incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; |
1271 | } | 1271 | } |
1272 | if ( last ) | 1272 | if ( last ) |
1273 | break; | 1273 | break; |
1274 | bool ok; | 1274 | bool ok; |
1275 | incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); | 1275 | incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); |
1276 | if ( ! ok ) | 1276 | if ( ! ok ) |
1277 | break; | 1277 | break; |
1278 | if ( incidenceStart.date() > endDate ) | 1278 | if ( incidenceStart.date() > endDate ) |
1279 | break; | 1279 | break; |
1280 | } | 1280 | } |
1281 | } else { // no recur | 1281 | } else { // no recur |
1282 | int st = event->dtStart().date().daysTo( endDate ); | 1282 | int st = event->dtStart().date().daysTo( endDate ); |
1283 | if ( st >= 0 ) { // start before timeend | 1283 | if ( st >= 0 ) { // start before timeend |
1284 | int end = mStartDate.daysTo( event->dtEnd().date() ); | 1284 | int end = mStartDate.daysTo( event->dtEnd().date() ); |
1285 | if ( end >= 0 ) { // end after timestart --- got one! | 1285 | if ( end >= 0 ) { // end after timestart --- got one! |
1286 | //normalize | 1286 | //normalize |
1287 | st = timeSpan - st; | 1287 | st = timeSpan - st; |
1288 | if ( st < 0 ) st = 0; | 1288 | if ( st < 0 ) st = 0; |
1289 | if ( end > timeSpan ) end = timeSpan; | 1289 | if ( end > timeSpan ) end = timeSpan; |
1290 | int iii; | 1290 | int iii; |
1291 | for ( iii = st;iii<= end;++iii) | 1291 | for ( iii = st;iii<= end;++iii) |
1292 | (*cells)[iii]->insertEvent( event ); | 1292 | (*cells)[iii]->insertEvent( event ); |
1293 | } | 1293 | } |
1294 | } | 1294 | } |
1295 | } | 1295 | } |
1296 | } | 1296 | } |
1297 | // insert due todos | 1297 | // insert due todos |
1298 | QPtrList<Todo> todos = calendar()->todos( ); | 1298 | QPtrList<Todo> todos = calendar()->todos( ); |
1299 | Todo *todo; | 1299 | Todo *todo; |
1300 | for(todo = todos.first(); todo; todo = todos.next()) { | 1300 | for(todo = todos.first(); todo; todo = todos.next()) { |
1301 | //insertTodo( todo ); | 1301 | //insertTodo( todo ); |
1302 | if ( todo->hasDueDate() ) { | 1302 | if ( todo->hasDueDate() ) { |
1303 | int day = mStartDate.daysTo( todo->dtDue().date() ); | 1303 | int day = mStartDate.daysTo( todo->dtDue().date() ); |
1304 | if ( day >= 0 && day < timeSpan + 1) { | 1304 | if ( day >= 0 && day < timeSpan + 1) { |
1305 | (*cells)[day]->insertTodo( todo ); | 1305 | (*cells)[day]->insertTodo( todo ); |
1306 | } | 1306 | } |
1307 | } | 1307 | } |
1308 | } | 1308 | } |
1309 | 1309 | ||
1310 | for( i = 0; i < timeSpan+1; ++i ) { | 1310 | for( i = 0; i < timeSpan+1; ++i ) { |
1311 | (*cells)[i]->finishUpdateCell(); | 1311 | (*cells)[i]->finishUpdateCell(); |
1312 | } | 1312 | } |
1313 | processSelectionChange(); | 1313 | processSelectionChange(); |
1314 | (*cells)[0]->setFocus(); | 1314 | (*cells)[0]->setFocus(); |
1315 | 1315 | ||
1316 | 1316 | ||
1317 | #else | 1317 | #else |
1318 | // old code | 1318 | // old code |
1319 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); | 1319 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); |
1320 | int i; | 1320 | int i; |
1321 | for( i = 0; i < (*cells).count(); ++i ) { | 1321 | for( i = 0; i < (*cells).count(); ++i ) { |
1322 | (*cells)[i]->updateCell(); | 1322 | (*cells)[i]->updateCell(); |
1323 | } | 1323 | } |
1324 | 1324 | ||
1325 | //qDebug("KOMonthView::updateView() "); | 1325 | //qDebug("KOMonthView::updateView() "); |
1326 | processSelectionChange(); | 1326 | processSelectionChange(); |
1327 | // qDebug("---------------------------------------------------------------------+ "); | 1327 | // qDebug("---------------------------------------------------------------------+ "); |
1328 | (*cells)[0]->setFocus(); | 1328 | (*cells)[0]->setFocus(); |
1329 | #endif | 1329 | #endif |
1330 | 1330 | ||
1331 | //qDebug("update time %d ", ti.elapsed()); | 1331 | //qDebug("update time %d ", ti.elapsed()); |
1332 | } | 1332 | } |
1333 | 1333 | ||
1334 | void KOMonthView::resizeEvent(QResizeEvent * e) | 1334 | void KOMonthView::resizeEvent(QResizeEvent * e) |
1335 | { | 1335 | { |
1336 | //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height()); | 1336 | //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height()); |
1337 | computeLayout(); | 1337 | computeLayout(); |
1338 | clPending = true; | 1338 | clPending = true; |
1339 | if ( mShowWeekView ) | 1339 | if ( mShowWeekView ) |
1340 | mCellsW[0]->setFocus(); | 1340 | mCellsW[0]->setFocus(); |
1341 | else | 1341 | else |
1342 | mCells[0]->setFocus(); | 1342 | mCells[0]->setFocus(); |
1343 | } | 1343 | } |
1344 | void KOMonthView::computeLayoutWeek() | 1344 | void KOMonthView::computeLayoutWeek() |
1345 | { | 1345 | { |
1346 | static int lastWid = 0; | 1346 | static int lastWid = 0; |
1347 | static int lastHei = 0; | 1347 | static int lastHei = 0; |
1348 | int daysToShow; | 1348 | int daysToShow; |
1349 | bool combinedSatSun = false; | 1349 | bool combinedSatSun = false; |
1350 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { | 1350 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { |
1351 | daysToShow = 6; | 1351 | daysToShow = 6; |
1352 | combinedSatSun = true; | 1352 | combinedSatSun = true; |
1353 | } | 1353 | } |
1354 | int tWid = topLevelWidget()->size().width(); | 1354 | int tWid = topLevelWidget()->size().width(); |
1355 | int tHei = topLevelWidget()->size().height(); | 1355 | int tHei = topLevelWidget()->size().height(); |
1356 | 1356 | ||
1357 | int wid = width();//e | 1357 | int wid = width();//e |
1358 | int hei = height()-1-mNavigatorBar->height(); | 1358 | int hei = height()-1-mNavigatorBar->height(); |
1359 | 1359 | ||
1360 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) | 1360 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) |
1361 | return; | 1361 | return; |
1362 | 1362 | ||
1363 | if ( lastWid == width() && lastHei == height() ) | 1363 | if ( lastWid == width() && lastHei == height() ) |
1364 | return; | 1364 | return; |
1365 | lastWid = width(); | 1365 | lastWid = width(); |
1366 | lastHei = height(); | 1366 | lastHei = height(); |
1367 | 1367 | ||
1368 | 1368 | ||
1369 | if ( wid < hei ) | 1369 | if ( wid < hei ) |
1370 | daysToShow = 2; | 1370 | daysToShow = 2; |
1371 | else | 1371 | else |
1372 | daysToShow = 3; | 1372 | daysToShow = 3; |
1373 | mShowSatSunComp = true; | 1373 | mShowSatSunComp = true; |
1374 | combinedSatSun = true; | 1374 | combinedSatSun = true; |
1375 | 1375 | ||
1376 | //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ "); | 1376 | //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ "); |
1377 | QFontMetrics fm ( mWeekLabels[0]->font() ); | 1377 | QFontMetrics fm ( mWeekLabels[0]->font() ); |
1378 | int weeklabelwid = fm.width( "888" ); | 1378 | int weeklabelwid = fm.width( "888" ); |
1379 | wid -= weeklabelwid; | 1379 | wid -= weeklabelwid; |
1380 | 1380 | ||
1381 | int colWid = wid / daysToShow; | 1381 | int colWid = wid / daysToShow; |
1382 | int lastCol = wid - ( colWid*6 ); | 1382 | int lastCol = wid - ( colWid*6 ); |
1383 | int dayLabelHei = mDayLabelsW[0]->sizeHint().height(); | 1383 | int dayLabelHei = mDayLabelsW[0]->sizeHint().height(); |
1384 | int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); | 1384 | int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); |
1385 | int colModulo = wid % daysToShow; | 1385 | int colModulo = wid % daysToShow; |
1386 | int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; | 1386 | int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; |
1387 | //qDebug("rowmod %d ", rowModulo); | 1387 | //qDebug("rowmod %d ", rowModulo); |
1388 | int i; | 1388 | int i; |
1389 | int x,y,w,h; | 1389 | int x,y,w,h; |
1390 | x= 0; | 1390 | x= 0; |
1391 | y= 0; | 1391 | y= 0; |
1392 | w = colWid; | 1392 | w = colWid; |
1393 | h = dayLabelHei ; | 1393 | h = dayLabelHei ; |
1394 | for ( i = 0; i < 7; i++) { | 1394 | for ( i = 0; i < 7; i++) { |
1395 | if ( i && !( i % daysToShow) && i < 6) { | 1395 | if ( i && !( i % daysToShow) && i < 6) { |
1396 | y += hei/(5-daysToShow); | 1396 | y += hei/(5-daysToShow); |
1397 | x = 0; | 1397 | x = 0; |
1398 | w = colWid; | 1398 | w = colWid; |
1399 | } | 1399 | } |
1400 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { | 1400 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { |
1401 | ++w; | 1401 | ++w; |
1402 | } | 1402 | } |
1403 | if ( i >= 5 ) { | 1403 | if ( i >= 5 ) { |
1404 | mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w/2+w%2,h); | 1404 | mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w/2+w%2,h); |
1405 | x -= (w/2 ); | 1405 | x -= (w/2 ); |
1406 | } | 1406 | } |
1407 | else | 1407 | else |
1408 | mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w,h); | 1408 | mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w,h); |
1409 | x += w; | 1409 | x += w; |
1410 | } | 1410 | } |
1411 | x= 0; | 1411 | x= 0; |
1412 | y= dayLabelHei; | 1412 | y= dayLabelHei; |
1413 | w = colWid; | 1413 | w = colWid; |
1414 | h = cellHei; | 1414 | h = cellHei; |
1415 | for ( i = 0; i < mCellsW.count(); ++i) { | 1415 | for ( i = 0; i < mCellsW.count(); ++i) { |
1416 | if ( i > 6 ) { | 1416 | if ( i > 6 ) { |
1417 | mCellsW[i]->hide(); | 1417 | mCellsW[i]->hide(); |
1418 | continue; | 1418 | continue; |
1419 | } | 1419 | } |
1420 | 1420 | ||
1421 | w = colWid; | 1421 | w = colWid; |
1422 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { | 1422 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { |
1423 | ++w; | 1423 | ++w; |
1424 | } | 1424 | } |
1425 | if ( i == (daysToShow-1-rowModulo)*7) | 1425 | if ( i == (daysToShow-1-rowModulo)*7) |
1426 | ++h; | 1426 | ++h; |
1427 | 1427 | ||
1428 | if ( i >= 5 ) { | 1428 | if ( i >= 5 ) { |
1429 | if ( i ==5 ) { | 1429 | if ( i ==5 ) { |
1430 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); | 1430 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); |
1431 | x -= w ;y += h/2; | 1431 | x -= w ;y += h/2; |
1432 | } else { | 1432 | } else { |
1433 | if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { | 1433 | if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { |
1434 | ++w; | 1434 | ++w; |
1435 | } | 1435 | } |
1436 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); | 1436 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); |
1437 | y -= h/2; | 1437 | y -= h/2; |
1438 | } | 1438 | } |
1439 | } else | 1439 | } else |
1440 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1440 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1441 | 1441 | ||
1442 | 1442 | ||
1443 | x += w; | 1443 | x += w; |
1444 | if ( x + w/2 > wid ) { | 1444 | if ( x + w/2 > wid ) { |
1445 | x = 0; | 1445 | x = 0; |
1446 | y += h+dayLabelHei ; | 1446 | y += h+dayLabelHei ; |
1447 | } | 1447 | } |
1448 | } | 1448 | } |
1449 | y= dayLabelHei; | 1449 | y= dayLabelHei; |
1450 | h = cellHei ; | 1450 | h = cellHei ; |
1451 | mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); | 1451 | mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); |
1452 | mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei); | 1452 | mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei); |
1453 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); | 1453 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); |
1454 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); | 1454 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); |
1455 | mShortDayLabelsW = mDayLabelsW[0]->width()-2 < mWidthLongDayLabel ; | 1455 | mShortDayLabelsW = mDayLabelsW[0]->width()-2 < mWidthLongDayLabel ; |
1456 | updateDayLabels(); | 1456 | updateDayLabels(); |
1457 | //bool forceUpdate = !updatePossible; | 1457 | //bool forceUpdate = !updatePossible; |
1458 | updatePossible = true; | 1458 | updatePossible = true; |
1459 | //mWeekLabels[mNumWeeks]->setText( i18n("M")); | 1459 | //mWeekLabels[mNumWeeks]->setText( i18n("M")); |
1460 | //if ( forceUpdate ) | 1460 | //if ( forceUpdate ) |
1461 | // updateView(); | 1461 | // updateView(); |
1462 | } | 1462 | } |
1463 | void KOMonthView::computeLayout() | 1463 | void KOMonthView::computeLayout() |
1464 | { | 1464 | { |
1465 | 1465 | ||
1466 | 1466 | ||
1467 | static int lastWid = 0; | 1467 | static int lastWid = 0; |
1468 | static int lastHei = 0; | 1468 | static int lastHei = 0; |
1469 | 1469 | ||
1470 | if ( mShowWeekView ){ | 1470 | if ( mShowWeekView ){ |
1471 | computeLayoutWeek(); | 1471 | computeLayoutWeek(); |
1472 | return; | 1472 | return; |
1473 | } | 1473 | } |
1474 | int daysToShow = 7; | 1474 | int daysToShow = 7; |
1475 | bool combinedSatSun = false; | 1475 | bool combinedSatSun = false; |
1476 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { | 1476 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { |
1477 | daysToShow = 6; | 1477 | daysToShow = 6; |
1478 | combinedSatSun = true; | 1478 | combinedSatSun = true; |
1479 | } | 1479 | } |
1480 | int tWid = topLevelWidget()->size().width(); | 1480 | int tWid = topLevelWidget()->size().width(); |
1481 | int tHei = topLevelWidget()->size().height(); | 1481 | int tHei = topLevelWidget()->size().height(); |
1482 | 1482 | ||
1483 | int wid = width();//e | 1483 | int wid = width();//e |
1484 | int hei = height()-1-mNavigatorBar->height(); | 1484 | int hei = height()-1-mNavigatorBar->height(); |
1485 | 1485 | ||
1486 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) { | 1486 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) { |
1487 | return; | 1487 | return; |
1488 | } | 1488 | } |
1489 | if ( lastWid == width() && lastHei == height() ){ | 1489 | if ( lastWid == width() && lastHei == height() ){ |
1490 | return; | 1490 | return; |
1491 | } | 1491 | } |
1492 | 1492 | ||
1493 | lastWid = width(); | 1493 | lastWid = width(); |
1494 | lastHei = height(); | 1494 | lastHei = height(); |
1495 | //qDebug("KOMonthView::computeLayout() MMM ------------------------------------ "); | 1495 | //qDebug("KOMonthView::computeLayout() MMM ------------------------------------ "); |
1496 | QFontMetrics fm ( mWeekLabels[0]->font() ); | 1496 | QFontMetrics fm ( mWeekLabels[0]->font() ); |
1497 | int weeklabelwid = fm.width( "888" ); | 1497 | int weeklabelwid = fm.width( "888" ); |
1498 | wid -= weeklabelwid; | 1498 | wid -= weeklabelwid; |
1499 | 1499 | ||
1500 | int colWid = wid / daysToShow; | 1500 | int colWid = wid / daysToShow; |
1501 | int lastCol = wid - ( colWid*6 ); | 1501 | int lastCol = wid - ( colWid*6 ); |
1502 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); | 1502 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); |
1503 | int cellHei = (hei - dayLabelHei) /6; | 1503 | int cellHei = (hei - dayLabelHei) /6; |
1504 | int colModulo = wid % daysToShow; | 1504 | int colModulo = wid % daysToShow; |
1505 | int rowModulo = (hei- dayLabelHei) % 6; | 1505 | int rowModulo = (hei- dayLabelHei) % 6; |
1506 | //qDebug("rowmod %d ", rowModulo); | 1506 | //qDebug("rowmod %d ", rowModulo); |
1507 | int i; | 1507 | int i; |
1508 | int x,y,w,h; | 1508 | int x,y,w,h; |
1509 | x= 0; | 1509 | x= 0; |
1510 | y= 0; | 1510 | y= 0; |
1511 | w = colWid; | 1511 | w = colWid; |
1512 | h = dayLabelHei ; | 1512 | h = dayLabelHei ; |
1513 | for ( i = 0; i < 7; i++) { | 1513 | for ( i = 0; i < 7; i++) { |
1514 | if ( i == daysToShow-colModulo ) | 1514 | if ( i == daysToShow-colModulo ) |
1515 | ++w; | 1515 | ++w; |
1516 | if ( combinedSatSun ) { | 1516 | if ( combinedSatSun ) { |
1517 | if ( i >= daysToShow-1 ) { | 1517 | if ( i >= daysToShow-1 ) { |
1518 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); | 1518 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); |
1519 | x -= w/2 ; | 1519 | x -= w/2 ; |
1520 | } | 1520 | } |
1521 | else | 1521 | else |
1522 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); | 1522 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); |
1523 | } else | 1523 | } else |
1524 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); | 1524 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); |
1525 | x += w; | 1525 | x += w; |
1526 | } | 1526 | } |
1527 | x= 0; | 1527 | x= 0; |
1528 | y= dayLabelHei; | 1528 | y= dayLabelHei; |
1529 | w = colWid; | 1529 | w = colWid; |
1530 | h = cellHei ; | 1530 | h = cellHei ; |
1531 | for ( i = 0; i < mCells.count(); ++i) { | 1531 | for ( i = 0; i < mCells.count(); ++i) { |
1532 | //qDebug("iii %d ", i); | 1532 | //qDebug("iii %d ", i); |
1533 | w = colWid; | 1533 | w = colWid; |
1534 | if ( ((i) % 7) >= 7-colModulo ) { | 1534 | if ( ((i) % 7) >= 7-colModulo ) { |
1535 | ++w; | 1535 | ++w; |
1536 | } | 1536 | } |
1537 | if ( i == (6-rowModulo)*7) | 1537 | if ( i == (6-rowModulo)*7) |
1538 | ++h; | 1538 | ++h; |
1539 | if ( combinedSatSun ) { | 1539 | if ( combinedSatSun ) { |
1540 | if ( (i)%7 >= daysToShow-1 ) { | 1540 | if ( (i)%7 >= daysToShow-1 ) { |
1541 | if ( (i)%7 == daysToShow-1 ) { | 1541 | if ( (i)%7 == daysToShow-1 ) { |
1542 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); | 1542 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); |
1543 | x -= w ;y += h/2; | 1543 | x -= w ;y += h/2; |
1544 | } else { | 1544 | } else { |
1545 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); | 1545 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); |
1546 | y -= h/2; | 1546 | y -= h/2; |
1547 | } | 1547 | } |
1548 | } else | 1548 | } else |
1549 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1549 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1550 | 1550 | ||
1551 | } | 1551 | } |
1552 | else | 1552 | else |
1553 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1553 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1554 | x += w; | 1554 | x += w; |
1555 | if ( x + w/2 > wid ) { | 1555 | if ( x + w/2 > wid ) { |
1556 | x = 0; | 1556 | x = 0; |
1557 | y += h; | 1557 | y += h; |
1558 | } | 1558 | } |
1559 | } | 1559 | } |
1560 | y= dayLabelHei; | 1560 | y= dayLabelHei; |
1561 | h = cellHei ; | 1561 | h = cellHei ; |
1562 | for ( i = 0; i < 6; i++) { | 1562 | for ( i = 0; i < 6; i++) { |
1563 | if ( i == (6-rowModulo)) | 1563 | if ( i == (6-rowModulo)) |
1564 | ++h; | 1564 | ++h; |
1565 | mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); | 1565 | mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); |
1566 | y += h; | 1566 | y += h; |
1567 | } | 1567 | } |
1568 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); | 1568 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); |
1569 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); | 1569 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); |
1570 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); | 1570 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); |
1571 | mShortDayLabelsM = mDayLabels[0]->width()-2 < mWidthLongDayLabel ; | 1571 | mShortDayLabelsM = mDayLabels[0]->width()-2 < mWidthLongDayLabel ; |
1572 | updateDayLabels(); | 1572 | updateDayLabels(); |
1573 | //bool forceUpdate = !updatePossible; | 1573 | //bool forceUpdate = !updatePossible; |
1574 | updatePossible = true; | 1574 | updatePossible = true; |
1575 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); | 1575 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); |
1576 | } | 1576 | } |
1577 | 1577 | ||
1578 | void KOMonthView::showContextMenu( Incidence *incidence ) | 1578 | void KOMonthView::showContextMenu( Incidence *incidence ) |
1579 | { | 1579 | { |
1580 | mContextMenu->showIncidencePopup(incidence); | 1580 | mContextMenu->showIncidencePopup(incidence); |
1581 | /* | 1581 | /* |
1582 | if( incidence && incidence->type() == "Event" ) { | 1582 | if( incidence && incidence->type() == "Event" ) { |
1583 | Event *event = static_cast<Event *>(incidence); | 1583 | Event *event = static_cast<Event *>(incidence); |
1584 | mContextMenu->showEventPopup(event); | 1584 | mContextMenu->showEventPopup(event); |
1585 | } else { | 1585 | } else { |
1586 | kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; | 1586 | kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; |
1587 | } | 1587 | } |
1588 | */ | 1588 | */ |
1589 | } | 1589 | } |
1590 | MonthViewCell * KOMonthView::selectedCell( ) | 1590 | MonthViewCell * KOMonthView::selectedCell( ) |
1591 | { | 1591 | { |
1592 | return mSelectedCell; | 1592 | return mSelectedCell; |
1593 | } | 1593 | } |
1594 | void KOMonthView::setSelectedCell( MonthViewCell *cell ) | 1594 | void KOMonthView::setSelectedCell( MonthViewCell *cell ) |
1595 | { | 1595 | { |
1596 | // qDebug("KOMonthView::setSelectedCell "); | 1596 | // qDebug("KOMonthView::setSelectedCell "); |
1597 | if ( mSelectedCell && mSelectedCell != cell ) { | 1597 | if ( mSelectedCell && mSelectedCell != cell ) { |
1598 | MonthViewCell * mvc = mSelectedCell; | 1598 | MonthViewCell * mvc = mSelectedCell; |
1599 | mSelectedCell = cell; | 1599 | mSelectedCell = cell; |
1600 | mvc->deselect(); | 1600 | mvc->deselect(); |
1601 | } else | 1601 | } else |
1602 | mSelectedCell = cell; | 1602 | mSelectedCell = cell; |
1603 | // if ( mSelectedCell ) | 1603 | // if ( mSelectedCell ) |
1604 | // mSelectedCell->select(); | 1604 | // mSelectedCell->select(); |
1605 | if ( !mSelectedCell ) | 1605 | if ( !mSelectedCell ) |
1606 | emit incidenceSelected( 0 ); | 1606 | emit incidenceSelected( 0 ); |
1607 | else | 1607 | else |
1608 | emit incidenceSelected( mSelectedCell->selectedIncidence() ); | 1608 | emit incidenceSelected( mSelectedCell->selectedIncidence() ); |
1609 | } | 1609 | } |
1610 | 1610 | ||
1611 | void KOMonthView::processSelectionChange() | 1611 | void KOMonthView::processSelectionChange() |
1612 | { | 1612 | { |
1613 | QPtrList<Incidence> incidences = selectedIncidences(); | 1613 | QPtrList<Incidence> incidences = selectedIncidences(); |
1614 | if (incidences.count() > 0) { | 1614 | if (incidences.count() > 0) { |
1615 | emit incidenceSelected( incidences.first() ); | 1615 | emit incidenceSelected( incidences.first() ); |
1616 | } else { | 1616 | } else { |
1617 | emit incidenceSelected( 0 ); | 1617 | emit incidenceSelected( 0 ); |
1618 | } | 1618 | } |
1619 | } | 1619 | } |
1620 | 1620 | ||
1621 | void KOMonthView::clearSelection() | 1621 | void KOMonthView::clearSelection() |
1622 | { | 1622 | { |
1623 | if ( mSelectedCell ) { | 1623 | if ( mSelectedCell ) { |
1624 | mSelectedCell->deselect(); | 1624 | mSelectedCell->deselect(); |
1625 | mSelectedCell = 0; | 1625 | mSelectedCell = 0; |
1626 | } | 1626 | } |
1627 | } | 1627 | } |
1628 | void KOMonthView::keyPressEvent ( QKeyEvent * e ) | 1628 | void KOMonthView::keyPressEvent ( QKeyEvent * e ) |
1629 | { | 1629 | { |
1630 | //qDebug("KOMonthView::keyPressEvent "); | 1630 | //qDebug("KOMonthView::keyPressEvent "); |
1631 | switch(e->key()) { | 1631 | switch(e->key()) { |
1632 | case Key_Up: | 1632 | case Key_Up: |
1633 | { | 1633 | { |
1634 | emit prevMonth(); | 1634 | if ( mShowWeekView ) { |
1635 | if ( mShowWeekView ) | ||
1636 | mCellsW[0]->setFocus(); | 1635 | mCellsW[0]->setFocus(); |
1637 | else | 1636 | emit selectWeekNum ( currentWeek() - 1 ); |
1637 | } | ||
1638 | else { | ||
1638 | mCells[0]->setFocus(); | 1639 | mCells[0]->setFocus(); |
1640 | emit prevMonth(); | ||
1641 | } | ||
1639 | } | 1642 | } |
1640 | e->accept(); | 1643 | e->accept(); |
1641 | break; | 1644 | break; |
1642 | case Key_Down: | 1645 | case Key_Down: |
1643 | { | 1646 | { |
1644 | emit nextMonth(); | 1647 | if ( mShowWeekView ) { |
1645 | if ( mShowWeekView ) | ||
1646 | mCellsW[0]->setFocus(); | 1648 | mCellsW[0]->setFocus(); |
1647 | else | 1649 | emit selectWeekNum ( currentWeek() +1); |
1650 | } | ||
1651 | else { | ||
1648 | mCells[0]->setFocus(); | 1652 | mCells[0]->setFocus(); |
1653 | emit nextMonth(); | ||
1654 | } | ||
1649 | 1655 | ||
1650 | } | 1656 | } |
1651 | e->accept(); | 1657 | e->accept(); |
1652 | break; | 1658 | break; |
1653 | case Key_Return: | 1659 | case Key_Return: |
1654 | case Key_Enter: | 1660 | case Key_Enter: |
1655 | { | 1661 | { |
1656 | selectInternalWeekNum ( currentWeek() ); | 1662 | selectInternalWeekNum ( currentWeek() ); |
1657 | } | 1663 | } |
1658 | e->accept(); | 1664 | e->accept(); |
1659 | break; | 1665 | break; |
1660 | default: | 1666 | default: |
1661 | e->ignore(); | 1667 | e->ignore(); |
1662 | break; | 1668 | break; |
1663 | } | 1669 | } |
1664 | } | 1670 | } |