author | zautrix <zautrix> | 2005-03-08 11:48:20 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-08 11:48:20 (UTC) |
commit | f20f8ca063abd322387a72f3f5a65c480f6a4233 (patch) (unidiff) | |
tree | 6136c01f0ac27b0ee869d5fb1169ebe95229faef | |
parent | 90f53697a44fdcccec00ef8c53fe5c9c15aca713 (diff) | |
download | kdepimpi-f20f8ca063abd322387a72f3f5a65c480f6a4233.zip kdepimpi-f20f8ca063abd322387a72f3f5a65c480f6a4233.tar.gz kdepimpi-f20f8ca063abd322387a72f3f5a65c480f6a4233.tar.bz2 |
list weekview fix
-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 | |||
@@ -1442,223 +1442,229 @@ void KOMonthView::computeLayoutWeek() | |||
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 | } |