author | zautrix <zautrix> | 2005-04-05 14:03:26 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-04-05 14:03:26 (UTC) |
commit | 637415693af8fe9974b45c355ecfdd0745617ac3 (patch) (unidiff) | |
tree | f7d83828754e82b0eeb001a2837f7c3f6865d647 | |
parent | e1fd021493c30106d2a31449d620ab6eaf96f18f (diff) | |
download | kdepimpi-637415693af8fe9974b45c355ecfdd0745617ac3.zip kdepimpi-637415693af8fe9974b45c355ecfdd0745617ac3.tar.gz kdepimpi-637415693af8fe9974b45c355ecfdd0745617ac3.tar.bz2 |
minor pixel fixes
-rw-r--r-- | korganizer/komonthview.cpp | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 6d6ae8a..e66ddce 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -1273,688 +1273,704 @@ DateList KOMonthView::selectedDates() | |||
1273 | if ( mSelectedCell ) { | 1273 | if ( mSelectedCell ) { |
1274 | QDate qd = mSelectedCell->selectedIncidenceDate(); | 1274 | QDate qd = mSelectedCell->selectedIncidenceDate(); |
1275 | if ( qd.isValid() ) selected.append( qd ); | 1275 | if ( qd.isValid() ) selected.append( qd ); |
1276 | } | 1276 | } |
1277 | 1277 | ||
1278 | return selected; | 1278 | return selected; |
1279 | } | 1279 | } |
1280 | 1280 | ||
1281 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 1281 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
1282 | const QDate &td) | 1282 | const QDate &td) |
1283 | { | 1283 | { |
1284 | #ifndef KORG_NOPRINTER | 1284 | #ifndef KORG_NOPRINTER |
1285 | calPrinter->preview(CalPrinter::Month, fd, td); | 1285 | calPrinter->preview(CalPrinter::Month, fd, td); |
1286 | #endif | 1286 | #endif |
1287 | } | 1287 | } |
1288 | 1288 | ||
1289 | void KOMonthView::updateConfig() | 1289 | void KOMonthView::updateConfig() |
1290 | { | 1290 | { |
1291 | 1291 | ||
1292 | int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); | 1292 | int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); |
1293 | 1293 | ||
1294 | if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { | 1294 | if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { |
1295 | mWeekStartsMonday = true; | 1295 | mWeekStartsMonday = true; |
1296 | } | 1296 | } |
1297 | QFontMetrics fontmetric(mDayLabels[0]->font()); | 1297 | QFontMetrics fontmetric(mDayLabels[0]->font()); |
1298 | mWidthLongDayLabel = 0; | 1298 | mWidthLongDayLabel = 0; |
1299 | 1299 | ||
1300 | for (int i = 0; i < 7; i++) { | 1300 | for (int i = 0; i < 7; i++) { |
1301 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); | 1301 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); |
1302 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; | 1302 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; |
1303 | } | 1303 | } |
1304 | bool temp = mShowSatSunComp ; | 1304 | bool temp = mShowSatSunComp ; |
1305 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 1305 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
1306 | if ( ! mShowWeekView ) { | 1306 | if ( ! mShowWeekView ) { |
1307 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) | 1307 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) |
1308 | computeLayout(); | 1308 | computeLayout(); |
1309 | } | 1309 | } |
1310 | updateDayLabels(); | 1310 | updateDayLabels(); |
1311 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); | 1311 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); |
1312 | //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; | 1312 | //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; |
1313 | //resizeEvent( 0 ); | 1313 | //resizeEvent( 0 ); |
1314 | for (uint i = 0; i < mCells.count(); ++i) { | 1314 | for (uint i = 0; i < mCells.count(); ++i) { |
1315 | mCells[i]->updateConfig(); | 1315 | mCells[i]->updateConfig(); |
1316 | } | 1316 | } |
1317 | 1317 | ||
1318 | for (uint i = 0; i < mCellsW.count(); ++i) { | 1318 | for (uint i = 0; i < mCellsW.count(); ++i) { |
1319 | mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); | 1319 | mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); |
1320 | } | 1320 | } |
1321 | #ifdef DESKTOP_VERSION | 1321 | #ifdef DESKTOP_VERSION |
1322 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); | 1322 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); |
1323 | #endif | 1323 | #endif |
1324 | updateView(); | 1324 | updateView(); |
1325 | } | 1325 | } |
1326 | 1326 | ||
1327 | void KOMonthView::updateDayLabels() | 1327 | void KOMonthView::updateDayLabels() |
1328 | { | 1328 | { |
1329 | 1329 | ||
1330 | QPtrVector<QLabel> *mDayLabelsT; | 1330 | QPtrVector<QLabel> *mDayLabelsT; |
1331 | 1331 | ||
1332 | mDayLabelsT = &mDayLabelsW; | 1332 | mDayLabelsT = &mDayLabelsW; |
1333 | for (int i = 0; i < 7; i++) { | 1333 | for (int i = 0; i < 7; i++) { |
1334 | { | 1334 | { |
1335 | bool show = mShortDayLabelsW; | 1335 | bool show = mShortDayLabelsW; |
1336 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) | 1336 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) |
1337 | show = true; | 1337 | show = true; |
1338 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); | 1338 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); |
1339 | } | 1339 | } |
1340 | } | 1340 | } |
1341 | mDayLabelsT = &mDayLabels; | 1341 | mDayLabelsT = &mDayLabels; |
1342 | for (int i = 0; i < 7; i++) { | 1342 | for (int i = 0; i < 7; i++) { |
1343 | if (KGlobal::locale()->weekStartsMonday() || KOPrefs::instance()->mMonthViewSatSunTog ) { | 1343 | if (KGlobal::locale()->weekStartsMonday() || KOPrefs::instance()->mMonthViewSatSunTog ) { |
1344 | bool show = mShortDayLabelsM; | 1344 | bool show = mShortDayLabelsM; |
1345 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) | 1345 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) |
1346 | show = true; | 1346 | show = true; |
1347 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); | 1347 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); |
1348 | } else { | 1348 | } else { |
1349 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM)); | 1349 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM)); |
1350 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM)); | 1350 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM)); |
1351 | 1351 | ||
1352 | } | 1352 | } |
1353 | } | 1353 | } |
1354 | 1354 | ||
1355 | } | 1355 | } |
1356 | 1356 | ||
1357 | void KOMonthView::showDates(const QDate &start, const QDate &) | 1357 | void KOMonthView::showDates(const QDate &start, const QDate &) |
1358 | { | 1358 | { |
1359 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; | 1359 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; |
1360 | 1360 | ||
1361 | QPtrVector<MonthViewCell> *cells; | 1361 | QPtrVector<MonthViewCell> *cells; |
1362 | QPtrVector<QLabel> *dayLabels; | 1362 | QPtrVector<QLabel> *dayLabels; |
1363 | QPtrVector<KOWeekButton> *weekLabels; | 1363 | QPtrVector<KOWeekButton> *weekLabels; |
1364 | int weekNum = 6; | 1364 | int weekNum = 6; |
1365 | mStartDate = start; | 1365 | mStartDate = start; |
1366 | if ( mShowWeekView ) { | 1366 | if ( mShowWeekView ) { |
1367 | weekNum = 1; | 1367 | weekNum = 1; |
1368 | cells = &mCellsW; | 1368 | cells = &mCellsW; |
1369 | dayLabels = &mDayLabelsW; | 1369 | dayLabels = &mDayLabelsW; |
1370 | weekLabels = &mWeekLabelsW; | 1370 | weekLabels = &mWeekLabelsW; |
1371 | if ( !KGlobal::locale()->weekStartsMonday() ) { | 1371 | if ( !KGlobal::locale()->weekStartsMonday() ) { |
1372 | mStartDate = mStartDate.addDays( 1 ); | 1372 | mStartDate = mStartDate.addDays( 1 ); |
1373 | } | 1373 | } |
1374 | } else { | 1374 | } else { |
1375 | cells = &mCells; | 1375 | cells = &mCells; |
1376 | dayLabels = &mDayLabels; | 1376 | dayLabels = &mDayLabels; |
1377 | weekLabels = &mWeekLabels; | 1377 | weekLabels = &mWeekLabels; |
1378 | } | 1378 | } |
1379 | 1379 | ||
1380 | int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); | 1380 | int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); |
1381 | 1381 | ||
1382 | if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { | 1382 | if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { |
1383 | mWeekStartsMonday = true; | 1383 | mWeekStartsMonday = true; |
1384 | } | 1384 | } |
1385 | int startWeekDay = mWeekStartsMonday ? 1 : 7; | 1385 | int startWeekDay = mWeekStartsMonday ? 1 : 7; |
1386 | 1386 | ||
1387 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { | 1387 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { |
1388 | mStartDate = mStartDate.addDays( -1 ); | 1388 | mStartDate = mStartDate.addDays( -1 ); |
1389 | } | 1389 | } |
1390 | bool primary = false; | 1390 | bool primary = false; |
1391 | uint i; | 1391 | uint i; |
1392 | for( i = 0; i < (*cells).size(); ++i ) { | 1392 | for( i = 0; i < (*cells).size(); ++i ) { |
1393 | QDate date = mStartDate.addDays( i ); | 1393 | QDate date = mStartDate.addDays( i ); |
1394 | (*cells)[i]->setDate( date ); | 1394 | (*cells)[i]->setDate( date ); |
1395 | 1395 | ||
1396 | #ifndef KORG_NOPLUGINS | 1396 | #ifndef KORG_NOPLUGINS |
1397 | // add holiday, if present | 1397 | // add holiday, if present |
1398 | QString hstring(KOCore::self()->holiday(date)); | 1398 | QString hstring(KOCore::self()->holiday(date)); |
1399 | (*cells)[i]->setHoliday( hstring ); | 1399 | (*cells)[i]->setHoliday( hstring ); |
1400 | #endif | 1400 | #endif |
1401 | 1401 | ||
1402 | } | 1402 | } |
1403 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); | 1403 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); |
1404 | for( i = 0; i < weekNum; ++i ) { | 1404 | for( i = 0; i < weekNum; ++i ) { |
1405 | int wno; | 1405 | int wno; |
1406 | // remember, according to ISO 8601, the first week of the year is the | 1406 | // remember, according to ISO 8601, the first week of the year is the |
1407 | // first week that contains a thursday. Thus we must subtract off 4, | 1407 | // first week that contains a thursday. Thus we must subtract off 4, |
1408 | // not just 1. | 1408 | // not just 1. |
1409 | int dayOfYear = date.dayOfYear(); | 1409 | int dayOfYear = date.dayOfYear(); |
1410 | if (dayOfYear % 7 != 0) | 1410 | if (dayOfYear % 7 != 0) |
1411 | wno = dayOfYear / 7 + 1; | 1411 | wno = dayOfYear / 7 + 1; |
1412 | else | 1412 | else |
1413 | wno =dayOfYear / 7; | 1413 | wno =dayOfYear / 7; |
1414 | (*weekLabels)[i]->setWeekNum( wno ); | 1414 | (*weekLabels)[i]->setWeekNum( wno ); |
1415 | date = date.addDays( 7 ); | 1415 | date = date.addDays( 7 ); |
1416 | } | 1416 | } |
1417 | updateView(); | 1417 | updateView(); |
1418 | } | 1418 | } |
1419 | 1419 | ||
1420 | void KOMonthView::showEvents(QPtrList<Event>) | 1420 | void KOMonthView::showEvents(QPtrList<Event>) |
1421 | { | 1421 | { |
1422 | qDebug("KOMonthView::selectEvents is not implemented yet. "); | 1422 | qDebug("KOMonthView::selectEvents is not implemented yet. "); |
1423 | } | 1423 | } |
1424 | 1424 | ||
1425 | void KOMonthView::changeEventDisplay(Event *, int) | 1425 | void KOMonthView::changeEventDisplay(Event *, int) |
1426 | { | 1426 | { |
1427 | // this should be re-written to be much more efficient, but this | 1427 | // this should be re-written to be much more efficient, but this |
1428 | // quick-and-dirty-hack gets the job done for right now. | 1428 | // quick-and-dirty-hack gets the job done for right now. |
1429 | //qDebug("KOMonthView::changeEventDisplay "); | 1429 | //qDebug("KOMonthView::changeEventDisplay "); |
1430 | updateView(); | 1430 | updateView(); |
1431 | } | 1431 | } |
1432 | 1432 | ||
1433 | void KOMonthView::updateView() | 1433 | void KOMonthView::updateView() |
1434 | { | 1434 | { |
1435 | 1435 | ||
1436 | if ( !updatePossible ) | 1436 | if ( !updatePossible ) |
1437 | return; | 1437 | return; |
1438 | //qDebug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU "); | 1438 | //qDebug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU "); |
1439 | //QTime ti; | 1439 | //QTime ti; |
1440 | //ti.start(); | 1440 | //ti.start(); |
1441 | clearSelection(); | 1441 | clearSelection(); |
1442 | QPtrVector<MonthViewCell> *cells; | 1442 | QPtrVector<MonthViewCell> *cells; |
1443 | if ( mShowWeekView ) { | 1443 | if ( mShowWeekView ) { |
1444 | cells = &mCellsW; | 1444 | cells = &mCellsW; |
1445 | } else { | 1445 | } else { |
1446 | cells = &mCells; | 1446 | cells = &mCells; |
1447 | } | 1447 | } |
1448 | #if 1 | 1448 | #if 1 |
1449 | int i; | 1449 | int i; |
1450 | int timeSpan = (*cells).size()-1; | 1450 | int timeSpan = (*cells).size()-1; |
1451 | if ( KOPrefs::instance()->mMonthViewWeek ) | 1451 | if ( KOPrefs::instance()->mMonthViewWeek ) |
1452 | timeSpan = 6; | 1452 | timeSpan = 6; |
1453 | for( i = 0; i < timeSpan + 1; ++i ) { | 1453 | for( i = 0; i < timeSpan + 1; ++i ) { |
1454 | (*cells)[i]->startUpdateCell(); | 1454 | (*cells)[i]->startUpdateCell(); |
1455 | } | 1455 | } |
1456 | 1456 | ||
1457 | QPtrList<Event> events = calendar()->events(); | 1457 | QPtrList<Event> events = calendar()->events(); |
1458 | Event *event; | 1458 | Event *event; |
1459 | QDateTime dt; | 1459 | QDateTime dt; |
1460 | bool ok; | 1460 | bool ok; |
1461 | QDate endDate = mStartDate.addDays( timeSpan ); | 1461 | QDate endDate = mStartDate.addDays( timeSpan ); |
1462 | for( event = events.first(); event; event = events.next() ) { // for event | 1462 | for( event = events.first(); event; event = events.next() ) { // for event |
1463 | if ( event->doesRecur() ) { | 1463 | if ( event->doesRecur() ) { |
1464 | bool last; | 1464 | bool last; |
1465 | QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); | 1465 | QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); |
1466 | QDateTime incidenceEnd; | 1466 | QDateTime incidenceEnd; |
1467 | int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 1467 | int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
1468 | bool invalid = false; | 1468 | bool invalid = false; |
1469 | while( true ) { | 1469 | while( true ) { |
1470 | if ( incidenceStart.isValid() ) { | 1470 | if ( incidenceStart.isValid() ) { |
1471 | incidenceEnd = incidenceStart.addDays( eventlen ); | 1471 | incidenceEnd = incidenceStart.addDays( eventlen ); |
1472 | int st = incidenceStart.date().daysTo( endDate ); | 1472 | int st = incidenceStart.date().daysTo( endDate ); |
1473 | if ( st >= 0 ) { // start before timeend | 1473 | if ( st >= 0 ) { // start before timeend |
1474 | int end = mStartDate.daysTo( incidenceEnd.date() ); | 1474 | int end = mStartDate.daysTo( incidenceEnd.date() ); |
1475 | if ( end >= 0 ) { // end after timestart --- got one! | 1475 | if ( end >= 0 ) { // end after timestart --- got one! |
1476 | //normalize | 1476 | //normalize |
1477 | st = timeSpan - st; | 1477 | st = timeSpan - st; |
1478 | if ( st < 0 ) st = 0; | 1478 | if ( st < 0 ) st = 0; |
1479 | if ( end > timeSpan ) end = timeSpan; | 1479 | if ( end > timeSpan ) end = timeSpan; |
1480 | int iii; | 1480 | int iii; |
1481 | //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); | 1481 | //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); |
1482 | for ( iii = st;iii<= end;++iii) | 1482 | for ( iii = st;iii<= end;++iii) |
1483 | (*cells)[iii]->insertEvent( event ); | 1483 | (*cells)[iii]->insertEvent( event ); |
1484 | } | 1484 | } |
1485 | } | 1485 | } |
1486 | } else { | 1486 | } else { |
1487 | if ( invalid ) | 1487 | if ( invalid ) |
1488 | break; | 1488 | break; |
1489 | invalid = true; | 1489 | invalid = true; |
1490 | //qDebug("invalid %s", event->summary().latin1()); | 1490 | //qDebug("invalid %s", event->summary().latin1()); |
1491 | incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; | 1491 | incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; |
1492 | } | 1492 | } |
1493 | if ( last ) | 1493 | if ( last ) |
1494 | break; | 1494 | break; |
1495 | bool ok; | 1495 | bool ok; |
1496 | incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); | 1496 | incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); |
1497 | if ( ! ok ) | 1497 | if ( ! ok ) |
1498 | break; | 1498 | break; |
1499 | if ( incidenceStart.date() > endDate ) | 1499 | if ( incidenceStart.date() > endDate ) |
1500 | break; | 1500 | break; |
1501 | } | 1501 | } |
1502 | } else { // no recur | 1502 | } else { // no recur |
1503 | int st = event->dtStart().date().daysTo( endDate ); | 1503 | int st = event->dtStart().date().daysTo( endDate ); |
1504 | if ( st >= 0 ) { // start before timeend | 1504 | if ( st >= 0 ) { // start before timeend |
1505 | int end = mStartDate.daysTo( event->dtEnd().date() ); | 1505 | int end = mStartDate.daysTo( event->dtEnd().date() ); |
1506 | if ( end >= 0 ) { // end after timestart --- got one! | 1506 | if ( end >= 0 ) { // end after timestart --- got one! |
1507 | //normalize | 1507 | //normalize |
1508 | st = timeSpan - st; | 1508 | st = timeSpan - st; |
1509 | if ( st < 0 ) st = 0; | 1509 | if ( st < 0 ) st = 0; |
1510 | if ( end > timeSpan ) end = timeSpan; | 1510 | if ( end > timeSpan ) end = timeSpan; |
1511 | int iii; | 1511 | int iii; |
1512 | for ( iii = st;iii<= end;++iii) | 1512 | for ( iii = st;iii<= end;++iii) |
1513 | (*cells)[iii]->insertEvent( event ); | 1513 | (*cells)[iii]->insertEvent( event ); |
1514 | } | 1514 | } |
1515 | } | 1515 | } |
1516 | } | 1516 | } |
1517 | } | 1517 | } |
1518 | // insert due todos | 1518 | // insert due todos |
1519 | QPtrList<Todo> todos = calendar()->todos( ); | 1519 | QPtrList<Todo> todos = calendar()->todos( ); |
1520 | Todo *todo; | 1520 | Todo *todo; |
1521 | for(todo = todos.first(); todo; todo = todos.next()) { | 1521 | for(todo = todos.first(); todo; todo = todos.next()) { |
1522 | //insertTodo( todo ); | 1522 | //insertTodo( todo ); |
1523 | if ( todo->hasDueDate() ) { | 1523 | if ( todo->hasDueDate() ) { |
1524 | int day = mStartDate.daysTo( todo->dtDue().date() ); | 1524 | int day = mStartDate.daysTo( todo->dtDue().date() ); |
1525 | if ( day >= 0 && day < timeSpan + 1) { | 1525 | if ( day >= 0 && day < timeSpan + 1) { |
1526 | (*cells)[day]->insertTodo( todo ); | 1526 | (*cells)[day]->insertTodo( todo ); |
1527 | } | 1527 | } |
1528 | } | 1528 | } |
1529 | } | 1529 | } |
1530 | 1530 | ||
1531 | for( i = 0; i < timeSpan+1; ++i ) { | 1531 | for( i = 0; i < timeSpan+1; ++i ) { |
1532 | (*cells)[i]->finishUpdateCell(); | 1532 | (*cells)[i]->finishUpdateCell(); |
1533 | } | 1533 | } |
1534 | processSelectionChange(); | 1534 | processSelectionChange(); |
1535 | //qApp->processEvents(); | 1535 | //qApp->processEvents(); |
1536 | for( i = 0; i < timeSpan+1; ++i ) { | 1536 | for( i = 0; i < timeSpan+1; ++i ) { |
1537 | (*cells)[i]->repaintfinishUpdateCell(); | 1537 | (*cells)[i]->repaintfinishUpdateCell(); |
1538 | } | 1538 | } |
1539 | setKeyBFocus(); | 1539 | setKeyBFocus(); |
1540 | #else | 1540 | #else |
1541 | // old code | 1541 | // old code |
1542 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); | 1542 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); |
1543 | int i; | 1543 | int i; |
1544 | for( i = 0; i < (*cells).count(); ++i ) { | 1544 | for( i = 0; i < (*cells).count(); ++i ) { |
1545 | (*cells)[i]->updateCell(); | 1545 | (*cells)[i]->updateCell(); |
1546 | } | 1546 | } |
1547 | 1547 | ||
1548 | //qDebug("KOMonthView::updateView() "); | 1548 | //qDebug("KOMonthView::updateView() "); |
1549 | processSelectionChange(); | 1549 | processSelectionChange(); |
1550 | // qDebug("---------------------------------------------------------------------+ "); | 1550 | // qDebug("---------------------------------------------------------------------+ "); |
1551 | (*cells)[0]->setFocus(); | 1551 | (*cells)[0]->setFocus(); |
1552 | #endif | 1552 | #endif |
1553 | 1553 | ||
1554 | //qDebug("update time %d ", ti.elapsed()); | 1554 | //qDebug("update time %d ", ti.elapsed()); |
1555 | } | 1555 | } |
1556 | 1556 | ||
1557 | void KOMonthView::setKeyBoardFocus() | 1557 | void KOMonthView::setKeyBoardFocus() |
1558 | { | 1558 | { |
1559 | //qDebug("KOMonthView::setKeyBoardFocus() "); | 1559 | //qDebug("KOMonthView::setKeyBoardFocus() "); |
1560 | bool shootAgain = false; | 1560 | bool shootAgain = false; |
1561 | if ( mShowWeekView ) { | 1561 | if ( mShowWeekView ) { |
1562 | shootAgain = !mWeekLabelsW[1]->hasFocus(); | 1562 | shootAgain = !mWeekLabelsW[1]->hasFocus(); |
1563 | mWeekLabelsW[1]->setFocus(); | 1563 | mWeekLabelsW[1]->setFocus(); |
1564 | } | 1564 | } |
1565 | else { | 1565 | else { |
1566 | shootAgain = !mWeekLabels[mNumWeeks]->hasFocus(); | 1566 | shootAgain = !mWeekLabels[mNumWeeks]->hasFocus(); |
1567 | mWeekLabels[mNumWeeks]->setFocus(); | 1567 | mWeekLabels[mNumWeeks]->setFocus(); |
1568 | } | 1568 | } |
1569 | if ( shootAgain ) { | 1569 | if ( shootAgain ) { |
1570 | QTimer::singleShot( 0, this, SLOT ( setKeyBFocus() ) ); | 1570 | QTimer::singleShot( 0, this, SLOT ( setKeyBFocus() ) ); |
1571 | } | 1571 | } |
1572 | } | 1572 | } |
1573 | void KOMonthView::setKeyBFocus() | 1573 | void KOMonthView::setKeyBFocus() |
1574 | { | 1574 | { |
1575 | //qDebug("KOMonthView::setKeyBFocus() "); | 1575 | //qDebug("KOMonthView::setKeyBFocus() "); |
1576 | QTimer::singleShot( 0, this, SLOT ( setKeyBoardFocus() ) ); | 1576 | QTimer::singleShot( 0, this, SLOT ( setKeyBoardFocus() ) ); |
1577 | } | 1577 | } |
1578 | void KOMonthView::resizeEvent(QResizeEvent * e) | 1578 | void KOMonthView::resizeEvent(QResizeEvent * e) |
1579 | { | 1579 | { |
1580 | //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height()); | 1580 | //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height()); |
1581 | if ( isVisible() ) { | 1581 | if ( isVisible() ) { |
1582 | //qDebug("KOMonthView::isVisible "); | 1582 | //qDebug("KOMonthView::isVisible "); |
1583 | slotComputeLayout(); | 1583 | slotComputeLayout(); |
1584 | } else | 1584 | } else |
1585 | mComputeLayoutTimer->start( 100 ); | 1585 | mComputeLayoutTimer->start( 100 ); |
1586 | } | 1586 | } |
1587 | 1587 | ||
1588 | void KOMonthView::slotComputeLayout() | 1588 | void KOMonthView::slotComputeLayout() |
1589 | { | 1589 | { |
1590 | mComputeLayoutTimer->stop(); | 1590 | mComputeLayoutTimer->stop(); |
1591 | //qDebug("KOMonthView::Post - resizeEvent %d %d ", width(), height() ); | 1591 | //qDebug("KOMonthView::Post - resizeEvent %d %d ", width(), height() ); |
1592 | computeLayout(); | 1592 | computeLayout(); |
1593 | clPending = true; | 1593 | clPending = true; |
1594 | setKeyBFocus(); | 1594 | setKeyBFocus(); |
1595 | } | 1595 | } |
1596 | void KOMonthView::computeLayoutWeek() | 1596 | void KOMonthView::computeLayoutWeek() |
1597 | { | 1597 | { |
1598 | static int lastWid = 0; | 1598 | static int lastWid = 0; |
1599 | static int lastHei = 0; | 1599 | static int lastHei = 0; |
1600 | int daysToShow; | 1600 | int daysToShow; |
1601 | bool combinedSatSun = false; | 1601 | bool combinedSatSun = false; |
1602 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { | 1602 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { |
1603 | daysToShow = 6; | 1603 | daysToShow = 6; |
1604 | combinedSatSun = true; | 1604 | combinedSatSun = true; |
1605 | } | 1605 | } |
1606 | int tWid = topLevelWidget()->size().width(); | 1606 | int tWid = topLevelWidget()->size().width(); |
1607 | int tHei = topLevelWidget()->size().height(); | 1607 | int tHei = topLevelWidget()->size().height(); |
1608 | 1608 | ||
1609 | int wid = width();//e | 1609 | int wid = width();//e |
1610 | int hei = height()-1-mNavigatorBar->height(); | 1610 | int hei = height()-1-mNavigatorBar->height(); |
1611 | 1611 | ||
1612 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) | 1612 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) |
1613 | return; | 1613 | return; |
1614 | 1614 | ||
1615 | if ( lastWid == width() && lastHei == height() ) { | 1615 | if ( lastWid == width() && lastHei == height() ) { |
1616 | //qDebug("KOListWeekView::No compute layout needed "); | 1616 | //qDebug("KOListWeekView::No compute layout needed "); |
1617 | return; | 1617 | return; |
1618 | } | 1618 | } |
1619 | lastWid = width(); | 1619 | lastWid = width(); |
1620 | lastHei = height(); | 1620 | lastHei = height(); |
1621 | 1621 | ||
1622 | 1622 | ||
1623 | if ( wid < hei ) | 1623 | if ( wid < hei ) |
1624 | daysToShow = 2; | 1624 | daysToShow = 2; |
1625 | else | 1625 | else |
1626 | daysToShow = 3; | 1626 | daysToShow = 3; |
1627 | mShowSatSunComp = true; | 1627 | mShowSatSunComp = true; |
1628 | combinedSatSun = true; | 1628 | combinedSatSun = true; |
1629 | 1629 | ||
1630 | //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ "); | 1630 | //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ "); |
1631 | QFontMetrics fm ( mWeekLabels[0]->font() ); | 1631 | QFontMetrics fm ( mWeekLabels[0]->font() ); |
1632 | int weeklabelwid = fm.width( "888" ); | 1632 | int weeklabelwid = fm.width( "888" ); |
1633 | wid -= weeklabelwid; | 1633 | wid -= weeklabelwid; |
1634 | 1634 | ||
1635 | int colWid = wid / daysToShow; | 1635 | int colWid = wid / daysToShow; |
1636 | int lastCol = wid - ( colWid*6 ); | 1636 | int lastCol = wid - ( colWid*6 ); |
1637 | int dayLabelHei = mDayLabelsW[0]->sizeHint().height(); | 1637 | int dayLabelHei = mDayLabelsW[0]->sizeHint().height(); |
1638 | int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); | 1638 | int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); |
1639 | int colModulo = wid % daysToShow; | 1639 | int colModulo = wid % daysToShow; |
1640 | int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; | 1640 | int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; |
1641 | //qDebug("rowmod %d ", rowModulo); | 1641 | //qDebug("rowmod %d ", rowModulo); |
1642 | int i; | 1642 | int i; |
1643 | int x,y,w,h; | 1643 | int x,y,w,h; |
1644 | x= 0; | 1644 | x= 0; |
1645 | y= 0; | 1645 | y= 0; |
1646 | w = colWid; | 1646 | w = colWid; |
1647 | h = dayLabelHei ; | 1647 | h = dayLabelHei ; |
1648 | for ( i = 0; i < 7; i++) { | 1648 | for ( i = 0; i < 7; i++) { |
1649 | if ( i && !( i % daysToShow) && i < 6) { | 1649 | if ( i && !( i % daysToShow) && i < 6) { |
1650 | y += hei/(5-daysToShow); | 1650 | y += hei/(5-daysToShow); |
1651 | x = 0; | 1651 | x = 0; |
1652 | w = colWid; | 1652 | w = colWid; |
1653 | } | 1653 | } |
1654 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { | 1654 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { |
1655 | ++w; | 1655 | ++w; |
1656 | } | 1656 | } |
1657 | if ( i >= 5 ) { | 1657 | if ( i >= 5 ) { |
1658 | mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w/2+w%2,h); | 1658 | int wi = width() - x - weeklabelwid; |
1659 | x -= (w/2 ); | 1659 | if ( i == 5 ) { |
1660 | mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi/2+wi%2,h); | ||
1661 | } else { | ||
1662 | mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi,h); | ||
1663 | } | ||
1664 | x = x - w + wi - (wi/2 ); | ||
1665 | } | ||
1666 | else { | ||
1667 | int wi = w; | ||
1668 | if ( !(( i+1) % daysToShow)) { | ||
1669 | wi = width() - x - weeklabelwid; | ||
1670 | } | ||
1671 | mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi,h); | ||
1660 | } | 1672 | } |
1661 | else | ||
1662 | mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w,h); | ||
1663 | x += w; | 1673 | x += w; |
1664 | } | 1674 | } |
1665 | x= 0; | 1675 | x= 0; |
1666 | y= dayLabelHei; | 1676 | y= dayLabelHei; |
1667 | w = colWid; | 1677 | w = colWid; |
1668 | h = cellHei; | 1678 | h = cellHei; |
1669 | int max = 0; | 1679 | int max = 0; |
1670 | for ( i = 0; i < mCellsW.count(); ++i) { | 1680 | for ( i = 0; i < mCellsW.count(); ++i) { |
1671 | if ( i > 6 ) { | 1681 | if ( i > 6 ) { |
1672 | mCellsW[i]->hide(); | 1682 | mCellsW[i]->hide(); |
1673 | continue; | 1683 | continue; |
1674 | } | 1684 | } |
1675 | 1685 | ||
1676 | w = colWid; | 1686 | w = colWid; |
1677 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { | 1687 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { |
1678 | ++w; | 1688 | ++w; |
1679 | } | 1689 | } |
1680 | if ( i == (daysToShow-1-rowModulo)*7) | 1690 | if ( i == (daysToShow-1-rowModulo)*7) |
1681 | ++h; | 1691 | ++h; |
1682 | 1692 | ||
1683 | if ( i >= 5 ) { | 1693 | if ( i >= 5 ) { |
1684 | if ( i ==5 ) { | 1694 | if ( i ==5 ) { |
1685 | max = h/2; | 1695 | max = h/2; |
1686 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,max ); | 1696 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,max ); |
1687 | x -= w ;y += h/2; | 1697 | x -= w ;y += h/2; |
1688 | } else { | 1698 | } else { |
1689 | if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { | 1699 | if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { |
1690 | ++w; | 1700 | ++w; |
1691 | } | 1701 | } |
1692 | max = h-h/2; | 1702 | max = h-h/2; |
1693 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,max ); | 1703 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,max ); |
1694 | y -= h/2; | 1704 | y -= h/2; |
1695 | } | 1705 | } |
1696 | } else { | 1706 | } else { |
1697 | max = h; | 1707 | max = h; |
1698 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1708 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1699 | } | 1709 | } |
1700 | 1710 | ||
1701 | 1711 | ||
1702 | x += w; | 1712 | x += w; |
1703 | if ( x + w/2 > wid ) { | 1713 | if ( x + w/2 > wid ) { |
1704 | x = 0; | 1714 | x = 0; |
1705 | y += h+dayLabelHei ; | 1715 | y += h+dayLabelHei ; |
1706 | } | 1716 | } |
1707 | //mCellsW[i]->dateLabel()->setMaximumHeight( max - mCellsW[i]->lineWidth()*2 ); | 1717 | //mCellsW[i]->dateLabel()->setMaximumHeight( max - mCellsW[i]->lineWidth()*2 ); |
1708 | } | 1718 | } |
1709 | y= dayLabelHei; | 1719 | y= dayLabelHei; |
1710 | h = cellHei ; | 1720 | h = cellHei ; |
1711 | mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); | 1721 | mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); |
1712 | mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei); | 1722 | mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei); |
1713 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); | 1723 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); |
1714 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); | 1724 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); |
1715 | mShortDayLabelsW = mDayLabelsW[0]->width()-2 < mWidthLongDayLabel ; | 1725 | mShortDayLabelsW = mDayLabelsW[0]->width()-2 < mWidthLongDayLabel ; |
1716 | updateDayLabels(); | 1726 | updateDayLabels(); |
1717 | //bool forceUpdate = !updatePossible; | 1727 | //bool forceUpdate = !updatePossible; |
1718 | updatePossible = true; | 1728 | updatePossible = true; |
1719 | //mWeekLabels[mNumWeeks]->setText( i18n("M")); | 1729 | //mWeekLabels[mNumWeeks]->setText( i18n("M")); |
1720 | //if ( forceUpdate ) | 1730 | //if ( forceUpdate ) |
1721 | // updateView(); | 1731 | // updateView(); |
1722 | } | 1732 | } |
1723 | void KOMonthView::computeLayout() | 1733 | void KOMonthView::computeLayout() |
1724 | { | 1734 | { |
1725 | 1735 | ||
1726 | 1736 | ||
1727 | static int lastWid = 0; | 1737 | static int lastWid = 0; |
1728 | static int lastHei = 0; | 1738 | static int lastHei = 0; |
1729 | 1739 | ||
1730 | if ( mShowWeekView ){ | 1740 | if ( mShowWeekView ){ |
1731 | computeLayoutWeek(); | 1741 | computeLayoutWeek(); |
1732 | return; | 1742 | return; |
1733 | } | 1743 | } |
1734 | int daysToShow = 7; | 1744 | int daysToShow = 7; |
1735 | bool combinedSatSun = false; | 1745 | bool combinedSatSun = false; |
1736 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { | 1746 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { |
1737 | daysToShow = 6; | 1747 | daysToShow = 6; |
1738 | combinedSatSun = true; | 1748 | combinedSatSun = true; |
1739 | } | 1749 | } |
1740 | int tWid = topLevelWidget()->size().width(); | 1750 | int tWid = topLevelWidget()->size().width(); |
1741 | int tHei = topLevelWidget()->size().height(); | 1751 | int tHei = topLevelWidget()->size().height(); |
1742 | 1752 | ||
1743 | int wid = width();//e | 1753 | int wid = width();//e |
1744 | int hei = height()-1-mNavigatorBar->height(); | 1754 | int hei = height()-1-mNavigatorBar->height(); |
1745 | 1755 | ||
1746 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) { | 1756 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) { |
1747 | return; | 1757 | return; |
1748 | } | 1758 | } |
1749 | if ( lastWid == width() && lastHei == height() ){ | 1759 | if ( lastWid == width() && lastHei == height() ){ |
1750 | //qDebug("KOMonthview::No compute layout needed "); | 1760 | //qDebug("KOMonthview::No compute layout needed "); |
1751 | return; | 1761 | return; |
1752 | } | 1762 | } |
1753 | 1763 | ||
1754 | lastWid = width(); | 1764 | lastWid = width(); |
1755 | lastHei = height(); | 1765 | lastHei = height(); |
1756 | //qDebug("KOMonthView::computeLayout() MMM ------------------- "); | 1766 | //qDebug("KOMonthView::computeLayout() MMM ------------------- "); |
1757 | QFontMetrics fm ( mWeekLabels[0]->font() ); | 1767 | QFontMetrics fm ( mWeekLabels[0]->font() ); |
1758 | int weeklabelwid = fm.width( "888" ); | 1768 | int weeklabelwid = fm.width( "888" ); |
1759 | wid -= weeklabelwid; | 1769 | wid -= weeklabelwid; |
1760 | 1770 | ||
1761 | int colWid = wid / daysToShow; | 1771 | int colWid = wid / daysToShow; |
1762 | int lastCol = wid - ( colWid*6 ); | 1772 | int lastCol = wid - ( colWid*6 ); |
1763 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); | 1773 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); |
1764 | int cellHei = (hei - dayLabelHei) /6; | 1774 | int cellHei = (hei - dayLabelHei) /6; |
1765 | int colModulo = wid % daysToShow; | 1775 | int colModulo = wid % daysToShow; |
1766 | int rowModulo = (hei- dayLabelHei) % 6; | 1776 | int rowModulo = (hei- dayLabelHei) % 6; |
1767 | //qDebug("rowmod %d ", rowModulo); | 1777 | //qDebug("rowmod %d ", rowModulo); |
1768 | int i; | 1778 | int i; |
1769 | int x,y,w,h; | 1779 | int x,y,w,h; |
1770 | x= 0; | 1780 | x= 0; |
1771 | y= 0; | 1781 | y= 0; |
1772 | w = colWid; | 1782 | w = colWid; |
1773 | h = dayLabelHei ; | 1783 | h = dayLabelHei ; |
1774 | for ( i = 0; i < 7; i++) { | 1784 | for ( i = 0; i < 7; i++) { |
1775 | if ( i == daysToShow-colModulo ) | 1785 | if ( i == daysToShow-colModulo ) |
1776 | ++w; | 1786 | ++w; |
1777 | if ( combinedSatSun ) { | 1787 | if ( combinedSatSun ) { |
1778 | if ( i >= daysToShow-1 ) { | 1788 | if ( i >= daysToShow-1 ) { |
1779 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); | 1789 | |
1790 | if ( i == 6 ) | ||
1791 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,width()-x-weeklabelwid,h); | ||
1792 | else | ||
1793 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); | ||
1780 | x -= w/2 ; | 1794 | x -= w/2 ; |
1781 | } | 1795 | } |
1782 | else | 1796 | else |
1783 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); | 1797 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); |
1784 | } else | 1798 | } else |
1785 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); | 1799 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); |
1786 | x += w; | 1800 | x += w; |
1787 | } | 1801 | } |
1788 | x= 0; | 1802 | x= 0; |
1789 | y= dayLabelHei; | 1803 | y= dayLabelHei; |
1790 | w = colWid; | 1804 | w = colWid; |
1791 | h = cellHei ; | 1805 | h = cellHei ; |
1792 | int max = 0; | 1806 | int max = 0; |
1793 | for ( i = 0; i < mCells.count(); ++i) { | 1807 | for ( i = 0; i < mCells.count(); ++i) { |
1794 | //qDebug("iii %d ", i); | 1808 | //qDebug("iii %d ", i); |
1795 | w = colWid; | 1809 | w = colWid; |
1796 | if ( ((i) % 7) >= 7-colModulo ) { | 1810 | if ( ((i) % 7) >= 7-colModulo ) { |
1797 | ++w; | 1811 | ++w; |
1798 | } | 1812 | } |
1799 | if ( i == (6-rowModulo)*7) | 1813 | if ( i == (6-rowModulo)*7) |
1800 | ++h; | 1814 | ++h; |
1801 | if ( combinedSatSun ) { | 1815 | if ( combinedSatSun ) { |
1802 | if ( (i)%7 >= daysToShow-1 ) { | 1816 | if ( (i)%7 >= daysToShow-1 ) { |
1803 | if ( (i)%7 == daysToShow-1 ) { | 1817 | if ( (i)%7 == daysToShow-1 ) { |
1818 | w = width()-x-weeklabelwid; | ||
1804 | max = h/2; | 1819 | max = h/2; |
1805 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,max ); | 1820 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,max ); |
1806 | x -= w ;y += h/2; | 1821 | x -= w ;y += h/2; |
1807 | } else { | 1822 | } else { |
1823 | w = width()-x-weeklabelwid; | ||
1808 | max = h-h/2; | 1824 | max = h-h/2; |
1809 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,max ); | 1825 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,max ); |
1810 | y -= h/2; | 1826 | y -= h/2; |
1811 | } | 1827 | } |
1812 | } else { | 1828 | } else { |
1813 | max = h; | 1829 | max = h; |
1814 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1830 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1815 | } | 1831 | } |
1816 | 1832 | ||
1817 | } | 1833 | } |
1818 | else { | 1834 | else { |
1819 | max = h; | 1835 | max = h; |
1820 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1836 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1821 | } | 1837 | } |
1822 | x += w; | 1838 | x += w; |
1823 | if ( x + w/2 > wid ) { | 1839 | if ( x + w/2 > wid ) { |
1824 | x = 0; | 1840 | x = 0; |
1825 | y += h; | 1841 | y += h; |
1826 | } | 1842 | } |
1827 | //mCells[i]->dateLabel()->setMaximumHeight( max- mCells[i]->lineWidth()*2 ); | 1843 | //mCells[i]->dateLabel()->setMaximumHeight( max- mCells[i]->lineWidth()*2 ); |
1828 | } | 1844 | } |
1829 | y= dayLabelHei; | 1845 | y= dayLabelHei; |
1830 | h = cellHei ; | 1846 | h = cellHei ; |
1831 | for ( i = 0; i < 6; i++) { | 1847 | for ( i = 0; i < 6; i++) { |
1832 | if ( i == (6-rowModulo)) | 1848 | if ( i == (6-rowModulo)) |
1833 | ++h; | 1849 | ++h; |
1834 | mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); | 1850 | mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); |
1835 | y += h; | 1851 | y += h; |
1836 | } | 1852 | } |
1837 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); | 1853 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); |
1838 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); | 1854 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); |
1839 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); | 1855 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); |
1840 | mShortDayLabelsM = mDayLabels[0]->width()-2 < mWidthLongDayLabel ; | 1856 | mShortDayLabelsM = mDayLabels[0]->width()-2 < mWidthLongDayLabel ; |
1841 | updateDayLabels(); | 1857 | updateDayLabels(); |
1842 | //bool forceUpdate = !updatePossible; | 1858 | //bool forceUpdate = !updatePossible; |
1843 | updatePossible = true; | 1859 | updatePossible = true; |
1844 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); | 1860 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); |
1845 | } | 1861 | } |
1846 | 1862 | ||
1847 | void KOMonthView::showContextMenu( Incidence *incidence ) | 1863 | void KOMonthView::showContextMenu( Incidence *incidence ) |
1848 | { | 1864 | { |
1849 | mContextMenu->showIncidencePopup(incidence); | 1865 | mContextMenu->showIncidencePopup(incidence); |
1850 | /* | 1866 | /* |
1851 | if( incidence && incidence->type() == "Event" ) { | 1867 | if( incidence && incidence->type() == "Event" ) { |
1852 | Event *event = static_cast<Event *>(incidence); | 1868 | Event *event = static_cast<Event *>(incidence); |
1853 | mContextMenu->showEventPopup(event); | 1869 | mContextMenu->showEventPopup(event); |
1854 | } else { | 1870 | } else { |
1855 | kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; | 1871 | kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; |
1856 | } | 1872 | } |
1857 | */ | 1873 | */ |
1858 | } | 1874 | } |
1859 | MonthViewCell * KOMonthView::selectedCell( ) | 1875 | MonthViewCell * KOMonthView::selectedCell( ) |
1860 | { | 1876 | { |
1861 | return mSelectedCell; | 1877 | return mSelectedCell; |
1862 | } | 1878 | } |
1863 | void KOMonthView::setSelectedCell( MonthViewCell *cell ) | 1879 | void KOMonthView::setSelectedCell( MonthViewCell *cell ) |
1864 | { | 1880 | { |
1865 | //qDebug("KOMonthView::setSelectedCell "); | 1881 | //qDebug("KOMonthView::setSelectedCell "); |
1866 | if ( mSelectedCell && mSelectedCell != cell ) { | 1882 | if ( mSelectedCell && mSelectedCell != cell ) { |
1867 | MonthViewCell * mvc = mSelectedCell; | 1883 | MonthViewCell * mvc = mSelectedCell; |
1868 | mSelectedCell = cell; | 1884 | mSelectedCell = cell; |
1869 | mvc->deselect(); | 1885 | mvc->deselect(); |
1870 | } else | 1886 | } else |
1871 | mSelectedCell = cell; | 1887 | mSelectedCell = cell; |
1872 | // if ( mSelectedCell ) | 1888 | // if ( mSelectedCell ) |
1873 | // mSelectedCell->select(); | 1889 | // mSelectedCell->select(); |
1874 | if ( !mSelectedCell ) | 1890 | if ( !mSelectedCell ) |
1875 | emit incidenceSelected( 0 ); | 1891 | emit incidenceSelected( 0 ); |
1876 | else | 1892 | else |
1877 | emit incidenceSelected( mSelectedCell->selectedIncidence() ); | 1893 | emit incidenceSelected( mSelectedCell->selectedIncidence() ); |
1878 | } | 1894 | } |
1879 | 1895 | ||
1880 | void KOMonthView::processSelectionChange() | 1896 | void KOMonthView::processSelectionChange() |
1881 | { | 1897 | { |
1882 | QPtrList<Incidence> incidences = selectedIncidences(); | 1898 | QPtrList<Incidence> incidences = selectedIncidences(); |
1883 | if (incidences.count() > 0) { | 1899 | if (incidences.count() > 0) { |
1884 | emit incidenceSelected( incidences.first() ); | 1900 | emit incidenceSelected( incidences.first() ); |
1885 | } else { | 1901 | } else { |
1886 | emit incidenceSelected( 0 ); | 1902 | emit incidenceSelected( 0 ); |
1887 | clearSelection(); | 1903 | clearSelection(); |
1888 | } | 1904 | } |
1889 | } | 1905 | } |
1890 | 1906 | ||
1891 | void KOMonthView::clearSelection() | 1907 | void KOMonthView::clearSelection() |
1892 | { | 1908 | { |
1893 | if ( mSelectedCell ) { | 1909 | if ( mSelectedCell ) { |
1894 | mSelectedCell->deselect(); | 1910 | mSelectedCell->deselect(); |
1895 | mSelectedCell = 0; | 1911 | mSelectedCell = 0; |
1896 | } | 1912 | } |
1897 | } | 1913 | } |
1898 | 1914 | ||
1899 | void KOMonthView::keyReleaseEvent ( QKeyEvent * e) | 1915 | void KOMonthView::keyReleaseEvent ( QKeyEvent * e) |
1900 | { | 1916 | { |
1901 | if ( !e->isAutoRepeat() ) { | 1917 | if ( !e->isAutoRepeat() ) { |
1902 | mFlagKeyPressed = false; | 1918 | mFlagKeyPressed = false; |
1903 | } | 1919 | } |
1904 | } | 1920 | } |
1905 | 1921 | ||
1906 | void KOMonthView::keyPressEvent ( QKeyEvent * e ) | 1922 | void KOMonthView::keyPressEvent ( QKeyEvent * e ) |
1907 | { | 1923 | { |
1908 | 1924 | ||
1909 | qApp->processEvents(); | 1925 | qApp->processEvents(); |
1910 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | 1926 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { |
1911 | //e->ignore(); | 1927 | //e->ignore(); |
1912 | e->accept(); | 1928 | e->accept(); |
1913 | return; | 1929 | return; |
1914 | } | 1930 | } |
1915 | if (! e->isAutoRepeat() ) | 1931 | if (! e->isAutoRepeat() ) |
1916 | mFlagKeyPressed = true; | 1932 | mFlagKeyPressed = true; |
1917 | switch(e->key()) { | 1933 | switch(e->key()) { |
1918 | case Key_Up: | 1934 | case Key_Up: |
1919 | { | 1935 | { |
1920 | if ( mShowWeekView ) { | 1936 | if ( mShowWeekView ) { |
1921 | emit selectWeekNum ( currentWeek() - 1 ); | 1937 | emit selectWeekNum ( currentWeek() - 1 ); |
1922 | } | 1938 | } |
1923 | else { | 1939 | else { |
1924 | emit prevMonth(); | 1940 | emit prevMonth(); |
1925 | } | 1941 | } |
1926 | } | 1942 | } |
1927 | e->accept(); | 1943 | e->accept(); |
1928 | break; | 1944 | break; |
1929 | case Key_Down: | 1945 | case Key_Down: |
1930 | { | 1946 | { |
1931 | if ( mShowWeekView ) { | 1947 | if ( mShowWeekView ) { |
1932 | emit selectWeekNum ( currentWeek() +1); | 1948 | emit selectWeekNum ( currentWeek() +1); |
1933 | } | 1949 | } |
1934 | else { | 1950 | else { |
1935 | emit nextMonth(); | 1951 | emit nextMonth(); |
1936 | } | 1952 | } |
1937 | 1953 | ||
1938 | } | 1954 | } |
1939 | e->accept(); | 1955 | e->accept(); |
1940 | break; | 1956 | break; |
1941 | case Key_Return: | 1957 | case Key_Return: |
1942 | case Key_Enter: | 1958 | case Key_Enter: |
1943 | { | 1959 | { |
1944 | selectInternalWeekNum ( currentWeek() ); | 1960 | selectInternalWeekNum ( currentWeek() ); |
1945 | } | 1961 | } |
1946 | e->accept(); | 1962 | e->accept(); |
1947 | break; | 1963 | break; |
1948 | case Key_D: | 1964 | case Key_D: |
1949 | if ( mSelectedCell ) { | 1965 | if ( mSelectedCell ) { |
1950 | mSelectedCell->showDay(); | 1966 | mSelectedCell->showDay(); |
1951 | e->accept(); | 1967 | e->accept(); |
1952 | } else { | 1968 | } else { |
1953 | e->ignore(); | 1969 | e->ignore(); |
1954 | } | 1970 | } |
1955 | break; | 1971 | break; |
1956 | default: | 1972 | default: |
1957 | e->ignore(); | 1973 | e->ignore(); |
1958 | break; | 1974 | break; |
1959 | } | 1975 | } |
1960 | } | 1976 | } |