-rw-r--r-- | korganizer/komonthview.cpp | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 9fd1f68..8ee5bc3 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -973,48 +973,53 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) | |||
973 | cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); | 973 | cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); |
974 | } | 974 | } |
975 | 975 | ||
976 | //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); | 976 | //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); |
977 | mContextMenu = eventPopup(); | 977 | mContextMenu = eventPopup(); |
978 | // updateConfig(); //useless here... | 978 | // updateConfig(); //useless here... |
979 | // ... but we need mWidthLongDayLabel computed | 979 | // ... but we need mWidthLongDayLabel computed |
980 | QFontMetrics fontmetric(mDayLabels[0]->font()); | 980 | QFontMetrics fontmetric(mDayLabels[0]->font()); |
981 | mWidthLongDayLabel = 0; | 981 | mWidthLongDayLabel = 0; |
982 | for (int i = 0; i < 7; i++) { | 982 | for (int i = 0; i < 7; i++) { |
983 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); | 983 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); |
984 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; | 984 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; |
985 | } | 985 | } |
986 | 986 | ||
987 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); | 987 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); |
988 | 988 | ||
989 | #if 0 | 989 | #if 0 |
990 | if ( mShowWeekView ) | 990 | if ( mShowWeekView ) |
991 | mWidStack->raiseWidget( mWeekView ); | 991 | mWidStack->raiseWidget( mWeekView ); |
992 | else | 992 | else |
993 | mWidStack->raiseWidget( mMonthView ); | 993 | mWidStack->raiseWidget( mMonthView ); |
994 | #endif | 994 | #endif |
995 | 995 | ||
996 | emit incidenceSelected( 0 ); | 996 | emit incidenceSelected( 0 ); |
997 | |||
998 | mComputeLayoutTimer = new QTimer( this ); | ||
999 | connect (mComputeLayoutTimer ,SIGNAL(timeout()), this, SLOT ( slotComputeLayout())); | ||
1000 | |||
1001 | |||
997 | #ifndef DESKTOP_VERSION | 1002 | #ifndef DESKTOP_VERSION |
998 | resize( QApplication::desktop()->size() ); | 1003 | resize( QApplication::desktop()->size() ); |
999 | #else | 1004 | #else |
1000 | resize(640, 480 ); | 1005 | resize(640, 480 ); |
1001 | updatePossible = true; | 1006 | updatePossible = true; |
1002 | #endif | 1007 | #endif |
1003 | computeLayout(); | 1008 | computeLayout(); |
1004 | 1009 | ||
1005 | if ( mShowWeekView ) | 1010 | if ( mShowWeekView ) |
1006 | mWidStack->raiseWidget( mWeekView ); | 1011 | mWidStack->raiseWidget( mWeekView ); |
1007 | else | 1012 | else |
1008 | mWidStack->raiseWidget( mMonthView ); | 1013 | mWidStack->raiseWidget( mMonthView ); |
1009 | } | 1014 | } |
1010 | 1015 | ||
1011 | KOMonthView::~KOMonthView() | 1016 | KOMonthView::~KOMonthView() |
1012 | { | 1017 | { |
1013 | delete mContextMenu; | 1018 | delete mContextMenu; |
1014 | } | 1019 | } |
1015 | 1020 | ||
1016 | void KOMonthView::selectInternalWeekNum ( int n ) | 1021 | void KOMonthView::selectInternalWeekNum ( int n ) |
1017 | { | 1022 | { |
1018 | switchView(); | 1023 | switchView(); |
1019 | if ( !KOPrefs::instance()->mMonthViewWeek ) | 1024 | if ( !KOPrefs::instance()->mMonthViewWeek ) |
1020 | emit selectMonth (); | 1025 | emit selectMonth (); |
@@ -1330,77 +1335,91 @@ void KOMonthView::updateView() | |||
1330 | } | 1335 | } |
1331 | processSelectionChange(); | 1336 | processSelectionChange(); |
1332 | (*cells)[0]->setFocus(); | 1337 | (*cells)[0]->setFocus(); |
1333 | 1338 | ||
1334 | 1339 | ||
1335 | #else | 1340 | #else |
1336 | // old code | 1341 | // old code |
1337 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); | 1342 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); |
1338 | int i; | 1343 | int i; |
1339 | for( i = 0; i < (*cells).count(); ++i ) { | 1344 | for( i = 0; i < (*cells).count(); ++i ) { |
1340 | (*cells)[i]->updateCell(); | 1345 | (*cells)[i]->updateCell(); |
1341 | } | 1346 | } |
1342 | 1347 | ||
1343 | //qDebug("KOMonthView::updateView() "); | 1348 | //qDebug("KOMonthView::updateView() "); |
1344 | processSelectionChange(); | 1349 | processSelectionChange(); |
1345 | // qDebug("---------------------------------------------------------------------+ "); | 1350 | // qDebug("---------------------------------------------------------------------+ "); |
1346 | (*cells)[0]->setFocus(); | 1351 | (*cells)[0]->setFocus(); |
1347 | #endif | 1352 | #endif |
1348 | 1353 | ||
1349 | //qDebug("update time %d ", ti.elapsed()); | 1354 | //qDebug("update time %d ", ti.elapsed()); |
1350 | } | 1355 | } |
1351 | 1356 | ||
1352 | void KOMonthView::resizeEvent(QResizeEvent * e) | 1357 | void KOMonthView::resizeEvent(QResizeEvent * e) |
1353 | { | 1358 | { |
1354 | //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height()); | 1359 | qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height()); |
1360 | if ( isVisible() ) { | ||
1361 | qDebug("KOMonthView::isVisible "); | ||
1362 | slotComputeLayout(); | ||
1363 | } else | ||
1364 | mComputeLayoutTimer->start( 100 ); | ||
1365 | } | ||
1366 | |||
1367 | void KOMonthView::slotComputeLayout() | ||
1368 | { | ||
1369 | mComputeLayoutTimer->stop(); | ||
1370 | qDebug("KOMonthView::Post - resizeEvent %d %d ", width(), height() ); | ||
1355 | computeLayout(); | 1371 | computeLayout(); |
1356 | clPending = true; | 1372 | clPending = true; |
1357 | if ( mShowWeekView ) | 1373 | if ( mShowWeekView ) |
1358 | mCellsW[0]->setFocus(); | 1374 | mCellsW[0]->setFocus(); |
1359 | else | 1375 | else |
1360 | mCells[0]->setFocus(); | 1376 | mCells[0]->setFocus(); |
1377 | |||
1361 | } | 1378 | } |
1362 | void KOMonthView::computeLayoutWeek() | 1379 | void KOMonthView::computeLayoutWeek() |
1363 | { | 1380 | { |
1364 | static int lastWid = 0; | 1381 | static int lastWid = 0; |
1365 | static int lastHei = 0; | 1382 | static int lastHei = 0; |
1366 | int daysToShow; | 1383 | int daysToShow; |
1367 | bool combinedSatSun = false; | 1384 | bool combinedSatSun = false; |
1368 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { | 1385 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { |
1369 | daysToShow = 6; | 1386 | daysToShow = 6; |
1370 | combinedSatSun = true; | 1387 | combinedSatSun = true; |
1371 | } | 1388 | } |
1372 | int tWid = topLevelWidget()->size().width(); | 1389 | int tWid = topLevelWidget()->size().width(); |
1373 | int tHei = topLevelWidget()->size().height(); | 1390 | int tHei = topLevelWidget()->size().height(); |
1374 | 1391 | ||
1375 | int wid = width();//e | 1392 | int wid = width();//e |
1376 | int hei = height()-1-mNavigatorBar->height(); | 1393 | int hei = height()-1-mNavigatorBar->height(); |
1377 | 1394 | ||
1378 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) | 1395 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) |
1379 | return; | 1396 | return; |
1380 | 1397 | ||
1381 | if ( lastWid == width() && lastHei == height() ) | 1398 | if ( lastWid == width() && lastHei == height() ) { |
1399 | qDebug("KOListWeekView::No compute layout needed "); | ||
1382 | return; | 1400 | return; |
1401 | } | ||
1383 | lastWid = width(); | 1402 | lastWid = width(); |
1384 | lastHei = height(); | 1403 | lastHei = height(); |
1385 | 1404 | ||
1386 | 1405 | ||
1387 | if ( wid < hei ) | 1406 | if ( wid < hei ) |
1388 | daysToShow = 2; | 1407 | daysToShow = 2; |
1389 | else | 1408 | else |
1390 | daysToShow = 3; | 1409 | daysToShow = 3; |
1391 | mShowSatSunComp = true; | 1410 | mShowSatSunComp = true; |
1392 | combinedSatSun = true; | 1411 | combinedSatSun = true; |
1393 | 1412 | ||
1394 | //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ "); | 1413 | //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ "); |
1395 | QFontMetrics fm ( mWeekLabels[0]->font() ); | 1414 | QFontMetrics fm ( mWeekLabels[0]->font() ); |
1396 | int weeklabelwid = fm.width( "888" ); | 1415 | int weeklabelwid = fm.width( "888" ); |
1397 | wid -= weeklabelwid; | 1416 | wid -= weeklabelwid; |
1398 | 1417 | ||
1399 | int colWid = wid / daysToShow; | 1418 | int colWid = wid / daysToShow; |
1400 | int lastCol = wid - ( colWid*6 ); | 1419 | int lastCol = wid - ( colWid*6 ); |
1401 | int dayLabelHei = mDayLabelsW[0]->sizeHint().height(); | 1420 | int dayLabelHei = mDayLabelsW[0]->sizeHint().height(); |
1402 | int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); | 1421 | int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); |
1403 | int colModulo = wid % daysToShow; | 1422 | int colModulo = wid % daysToShow; |
1404 | int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; | 1423 | int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; |
1405 | //qDebug("rowmod %d ", rowModulo); | 1424 | //qDebug("rowmod %d ", rowModulo); |
1406 | int i; | 1425 | int i; |
@@ -1484,54 +1503,55 @@ void KOMonthView::computeLayout() | |||
1484 | 1503 | ||
1485 | static int lastWid = 0; | 1504 | static int lastWid = 0; |
1486 | static int lastHei = 0; | 1505 | static int lastHei = 0; |
1487 | 1506 | ||
1488 | if ( mShowWeekView ){ | 1507 | if ( mShowWeekView ){ |
1489 | computeLayoutWeek(); | 1508 | computeLayoutWeek(); |
1490 | return; | 1509 | return; |
1491 | } | 1510 | } |
1492 | int daysToShow = 7; | 1511 | int daysToShow = 7; |
1493 | bool combinedSatSun = false; | 1512 | bool combinedSatSun = false; |
1494 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { | 1513 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { |
1495 | daysToShow = 6; | 1514 | daysToShow = 6; |
1496 | combinedSatSun = true; | 1515 | combinedSatSun = true; |
1497 | } | 1516 | } |
1498 | int tWid = topLevelWidget()->size().width(); | 1517 | int tWid = topLevelWidget()->size().width(); |
1499 | int tHei = topLevelWidget()->size().height(); | 1518 | int tHei = topLevelWidget()->size().height(); |
1500 | 1519 | ||
1501 | int wid = width();//e | 1520 | int wid = width();//e |
1502 | int hei = height()-1-mNavigatorBar->height(); | 1521 | int hei = height()-1-mNavigatorBar->height(); |
1503 | 1522 | ||
1504 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) { | 1523 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) { |
1505 | return; | 1524 | return; |
1506 | } | 1525 | } |
1507 | if ( lastWid == width() && lastHei == height() ){ | 1526 | if ( lastWid == width() && lastHei == height() ){ |
1527 | qDebug("KOMonthview::No compute layout needed "); | ||
1508 | return; | 1528 | return; |
1509 | } | 1529 | } |
1510 | 1530 | ||
1511 | lastWid = width(); | 1531 | lastWid = width(); |
1512 | lastHei = height(); | 1532 | lastHei = height(); |
1513 | //qDebug("KOMonthView::computeLayout() MMM ------------------------------------ "); | 1533 | qDebug("KOMonthView::computeLayout() MMM ------------------- "); |
1514 | QFontMetrics fm ( mWeekLabels[0]->font() ); | 1534 | QFontMetrics fm ( mWeekLabels[0]->font() ); |
1515 | int weeklabelwid = fm.width( "888" ); | 1535 | int weeklabelwid = fm.width( "888" ); |
1516 | wid -= weeklabelwid; | 1536 | wid -= weeklabelwid; |
1517 | 1537 | ||
1518 | int colWid = wid / daysToShow; | 1538 | int colWid = wid / daysToShow; |
1519 | int lastCol = wid - ( colWid*6 ); | 1539 | int lastCol = wid - ( colWid*6 ); |
1520 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); | 1540 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); |
1521 | int cellHei = (hei - dayLabelHei) /6; | 1541 | int cellHei = (hei - dayLabelHei) /6; |
1522 | int colModulo = wid % daysToShow; | 1542 | int colModulo = wid % daysToShow; |
1523 | int rowModulo = (hei- dayLabelHei) % 6; | 1543 | int rowModulo = (hei- dayLabelHei) % 6; |
1524 | //qDebug("rowmod %d ", rowModulo); | 1544 | //qDebug("rowmod %d ", rowModulo); |
1525 | int i; | 1545 | int i; |
1526 | int x,y,w,h; | 1546 | int x,y,w,h; |
1527 | x= 0; | 1547 | x= 0; |
1528 | y= 0; | 1548 | y= 0; |
1529 | w = colWid; | 1549 | w = colWid; |
1530 | h = dayLabelHei ; | 1550 | h = dayLabelHei ; |
1531 | for ( i = 0; i < 7; i++) { | 1551 | for ( i = 0; i < 7; i++) { |
1532 | if ( i == daysToShow-colModulo ) | 1552 | if ( i == daysToShow-colModulo ) |
1533 | ++w; | 1553 | ++w; |
1534 | if ( combinedSatSun ) { | 1554 | if ( combinedSatSun ) { |
1535 | if ( i >= daysToShow-1 ) { | 1555 | if ( i >= daysToShow-1 ) { |
1536 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); | 1556 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); |
1537 | x -= w/2 ; | 1557 | x -= w/2 ; |