-rw-r--r-- | korganizer/koagenda.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index 779f12e..0dd5ef5 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp | |||
@@ -1542,193 +1542,196 @@ void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// i | |||
1542 | 1542 | ||
1543 | // Draw selection | 1543 | // Draw selection |
1544 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1544 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1545 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | 1545 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { |
1546 | // TODO: paint only part within cx,cy,cw,ch | 1546 | // TODO: paint only part within cx,cy,cw,ch |
1547 | p->fillRect( selectionX, mSelectionYTop, mGridSpacingX, | 1547 | p->fillRect( selectionX, mSelectionYTop, mGridSpacingX, |
1548 | mSelectionHeight, KOPrefs::instance()->mHighlightColor ); | 1548 | mSelectionHeight, KOPrefs::instance()->mHighlightColor ); |
1549 | } | 1549 | } |
1550 | */ | 1550 | */ |
1551 | // Draw vertical lines of grid | 1551 | // Draw vertical lines of grid |
1552 | 1552 | ||
1553 | int x = ((int)(cx/mGridSpacingX))*mGridSpacingX; | 1553 | int x = ((int)(cx/mGridSpacingX))*mGridSpacingX; |
1554 | if ( mGridSpacingX > 0 ) { | 1554 | if ( mGridSpacingX > 0 ) { |
1555 | while (x < cx + cw) { | 1555 | while (x < cx + cw) { |
1556 | p->drawLine(x,cy,x,cy+ch); | 1556 | p->drawLine(x,cy,x,cy+ch); |
1557 | x+=mGridSpacingX; | 1557 | x+=mGridSpacingX; |
1558 | } | 1558 | } |
1559 | } | 1559 | } |
1560 | // Draw horizontal lines of grid | 1560 | // Draw horizontal lines of grid |
1561 | int y = ((int)(cy/lGridSpacingY))*lGridSpacingY; | 1561 | int y = ((int)(cy/lGridSpacingY))*lGridSpacingY; |
1562 | if ( lGridSpacingY > 0 ) { | 1562 | if ( lGridSpacingY > 0 ) { |
1563 | while (y < cy + ch) { | 1563 | while (y < cy + ch) { |
1564 | p->setPen( SolidLine ); | 1564 | p->setPen( SolidLine ); |
1565 | p->drawLine(cx,y,cx+cw,y); | 1565 | p->drawLine(cx,y,cx+cw,y); |
1566 | y+=lGridSpacingY; | 1566 | y+=lGridSpacingY; |
1567 | p->setPen( DotLine ); | 1567 | p->setPen( DotLine ); |
1568 | p->drawLine(cx,y,cx+cw,y); | 1568 | p->drawLine(cx,y,cx+cw,y); |
1569 | y+=lGridSpacingY; | 1569 | y+=lGridSpacingY; |
1570 | } | 1570 | } |
1571 | p->setPen( SolidLine ); | 1571 | p->setPen( SolidLine ); |
1572 | } | 1572 | } |
1573 | mPixPainter.end() ; | 1573 | mPixPainter.end() ; |
1574 | } | 1574 | } |
1575 | 1575 | ||
1576 | /* | 1576 | /* |
1577 | Convert srcollview contents coordinates to agenda grid coordinates. | 1577 | Convert srcollview contents coordinates to agenda grid coordinates. |
1578 | */ | 1578 | */ |
1579 | void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy) | 1579 | void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy) |
1580 | { | 1580 | { |
1581 | gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX : | 1581 | gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX : |
1582 | x/mGridSpacingX; | 1582 | x/mGridSpacingX; |
1583 | gy = y/mGridSpacingY; | 1583 | gy = y/mGridSpacingY; |
1584 | } | 1584 | } |
1585 | 1585 | ||
1586 | /* | 1586 | /* |
1587 | Convert agenda grid coordinates to scrollview contents coordinates. | 1587 | Convert agenda grid coordinates to scrollview contents coordinates. |
1588 | */ | 1588 | */ |
1589 | void KOAgenda::gridToContents (int gx, int gy, int& x, int& y) | 1589 | void KOAgenda::gridToContents (int gx, int gy, int& x, int& y) |
1590 | { | 1590 | { |
1591 | x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX: | 1591 | x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX: |
1592 | gx*mGridSpacingX; | 1592 | gx*mGridSpacingX; |
1593 | y = gy*mGridSpacingY; | 1593 | y = gy*mGridSpacingY; |
1594 | } | 1594 | } |
1595 | 1595 | ||
1596 | 1596 | ||
1597 | /* | 1597 | /* |
1598 | Return Y coordinate corresponding to time. Coordinates are rounded to fit into | 1598 | Return Y coordinate corresponding to time. Coordinates are rounded to fit into |
1599 | the grid. | 1599 | the grid. |
1600 | */ | 1600 | */ |
1601 | int KOAgenda::timeToY(const QTime &time) | 1601 | int KOAgenda::timeToY(const QTime &time) |
1602 | { | 1602 | { |
1603 | int minutesPerCell = 24 * 60 / mRows; | 1603 | int minutesPerCell = 24 * 60 / mRows; |
1604 | int timeMinutes = time.hour() * 60 + time.minute(); | 1604 | int timeMinutes = time.hour() * 60 + time.minute(); |
1605 | int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell; | 1605 | int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell; |
1606 | return Y; | 1606 | return Y; |
1607 | } | 1607 | } |
1608 | 1608 | ||
1609 | 1609 | ||
1610 | /* | 1610 | /* |
1611 | Return time corresponding to cell y coordinate. Coordinates are rounded to | 1611 | Return time corresponding to cell y coordinate. Coordinates are rounded to |
1612 | fit into the grid. | 1612 | fit into the grid. |
1613 | */ | 1613 | */ |
1614 | QTime KOAgenda::gyToTime(int gy) | 1614 | QTime KOAgenda::gyToTime(int gy) |
1615 | { | 1615 | { |
1616 | 1616 | ||
1617 | int secondsPerCell = 24 * 60 * 60/ mRows; | 1617 | int secondsPerCell = 24 * 60 * 60/ mRows; |
1618 | 1618 | ||
1619 | int timeSeconds = secondsPerCell * gy; | 1619 | int timeSeconds = secondsPerCell * gy; |
1620 | 1620 | ||
1621 | QTime time( 0, 0, 0 ); | 1621 | QTime time( 0, 0, 0 ); |
1622 | if ( timeSeconds < 24 * 60 * 60 ) { | 1622 | if ( timeSeconds < 24 * 60 * 60 ) { |
1623 | time = time.addSecs(timeSeconds); | 1623 | time = time.addSecs(timeSeconds); |
1624 | } else { | 1624 | } else { |
1625 | time.setHMS( 23, 59, 59 ); | 1625 | time.setHMS( 23, 59, 59 ); |
1626 | } | 1626 | } |
1627 | 1627 | ||
1628 | return time; | 1628 | return time; |
1629 | } | 1629 | } |
1630 | 1630 | ||
1631 | void KOAgenda::setStartHour(int startHour) | 1631 | void KOAgenda::setStartHour(int startHour) |
1632 | { | 1632 | { |
1633 | int startCell = startHour * mRows / 24; | 1633 | int startCell = startHour * mRows / 24; |
1634 | setContentsPos(0,startCell * gridSpacingY()); | 1634 | setContentsPos(0,startCell * gridSpacingY()); |
1635 | } | 1635 | } |
1636 | QTime KOAgenda::getEndTime() | 1636 | QTime KOAgenda::getEndTime() |
1637 | { | 1637 | { |
1638 | return QTime ( (contentsY ()+viewport()->height())*24/contentsHeight ()+1,0,0); | 1638 | int tim = (contentsY ()+viewport()->height())*24/contentsHeight (); |
1639 | if ( tim > 23 ) | ||
1640 | return QTime ( 23,59,59); | ||
1641 | return QTime ( tim,0,0); | ||
1639 | } | 1642 | } |
1640 | void KOAgenda::hideUnused() | 1643 | void KOAgenda::hideUnused() |
1641 | { | 1644 | { |
1642 | // experimental only | 1645 | // experimental only |
1643 | // return; | 1646 | // return; |
1644 | KOAgendaItem *item; | 1647 | KOAgendaItem *item; |
1645 | for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) { | 1648 | for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) { |
1646 | item->hide(); | 1649 | item->hide(); |
1647 | } | 1650 | } |
1648 | } | 1651 | } |
1649 | 1652 | ||
1650 | 1653 | ||
1651 | KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view) | 1654 | KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view) |
1652 | { | 1655 | { |
1653 | 1656 | ||
1654 | KOAgendaItem *fi; | 1657 | KOAgendaItem *fi; |
1655 | for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) { | 1658 | for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) { |
1656 | if ( fi->incidence() == event ) { | 1659 | if ( fi->incidence() == event ) { |
1657 | mUnusedItems.remove(); | 1660 | mUnusedItems.remove(); |
1658 | fi->init( event, qd ); | 1661 | fi->init( event, qd ); |
1659 | return fi; | 1662 | return fi; |
1660 | } | 1663 | } |
1661 | } | 1664 | } |
1662 | fi=mUnusedItems.first(); | 1665 | fi=mUnusedItems.first(); |
1663 | if ( fi ) { | 1666 | if ( fi ) { |
1664 | mUnusedItems.remove(); | 1667 | mUnusedItems.remove(); |
1665 | fi->init( event, qd ); | 1668 | fi->init( event, qd ); |
1666 | return fi; | 1669 | return fi; |
1667 | } | 1670 | } |
1668 | // qDebug("new KOAgendaItem "); | 1671 | // qDebug("new KOAgendaItem "); |
1669 | 1672 | ||
1670 | KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode ); | 1673 | KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode ); |
1671 | agendaItem->installEventFilter(this); | 1674 | agendaItem->installEventFilter(this); |
1672 | addChild(agendaItem,0,0); | 1675 | addChild(agendaItem,0,0); |
1673 | return agendaItem; | 1676 | return agendaItem; |
1674 | } | 1677 | } |
1675 | KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) | 1678 | KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) |
1676 | { | 1679 | { |
1677 | KOAgendaItem *item; | 1680 | KOAgendaItem *item; |
1678 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1681 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1679 | if ( item->incidence() == todo ) { | 1682 | if ( item->incidence() == todo ) { |
1680 | mItems.remove(); | 1683 | mItems.remove(); |
1681 | return item; | 1684 | return item; |
1682 | } | 1685 | } |
1683 | } | 1686 | } |
1684 | return 0; | 1687 | return 0; |
1685 | } | 1688 | } |
1686 | 1689 | ||
1687 | 1690 | ||
1688 | void KOAgenda::updateTodo( Todo * todo, int days, bool remove) | 1691 | void KOAgenda::updateTodo( Todo * todo, int days, bool remove) |
1689 | { | 1692 | { |
1690 | // ( todo->hasCompletedDate() && todo->completed().date() == currentDate )|| | 1693 | // ( todo->hasCompletedDate() && todo->completed().date() == currentDate )|| |
1691 | KOAgendaItem *item; | 1694 | KOAgendaItem *item; |
1692 | item = getItemForTodo ( todo ); | 1695 | item = getItemForTodo ( todo ); |
1693 | //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove); | 1696 | //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove); |
1694 | if ( item ) { | 1697 | if ( item ) { |
1695 | blockSignals( true ); | 1698 | blockSignals( true ); |
1696 | //qDebug("item found "); | 1699 | //qDebug("item found "); |
1697 | item->hide(); | 1700 | item->hide(); |
1698 | item->setCellX(-2, -1 ); | 1701 | item->setCellX(-2, -1 ); |
1699 | item->select(false); | 1702 | item->select(false); |
1700 | mUnusedItems.append( item ); | 1703 | mUnusedItems.append( item ); |
1701 | mItems.remove( item ); | 1704 | mItems.remove( item ); |
1702 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); | 1705 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); |
1703 | KOAgendaItem *itemit; | 1706 | KOAgendaItem *itemit; |
1704 | //globalFlagBlockAgendaItemPaint = 1; | 1707 | //globalFlagBlockAgendaItemPaint = 1; |
1705 | for ( itemit=oldconflictItems.first(); itemit != 0; | 1708 | for ( itemit=oldconflictItems.first(); itemit != 0; |
1706 | itemit=oldconflictItems.next() ) { | 1709 | itemit=oldconflictItems.next() ) { |
1707 | if ( itemit != item ) | 1710 | if ( itemit != item ) |
1708 | placeSubCells(itemit); | 1711 | placeSubCells(itemit); |
1709 | } | 1712 | } |
1710 | qApp->processEvents(); | 1713 | qApp->processEvents(); |
1711 | //globalFlagBlockAgendaItemPaint = 0; | 1714 | //globalFlagBlockAgendaItemPaint = 0; |
1712 | for ( itemit=oldconflictItems.first(); itemit != 0; | 1715 | for ( itemit=oldconflictItems.first(); itemit != 0; |
1713 | itemit=oldconflictItems.next() ) { | 1716 | itemit=oldconflictItems.next() ) { |
1714 | globalFlagBlockAgendaItemUpdate = 0; | 1717 | globalFlagBlockAgendaItemUpdate = 0; |
1715 | if ( itemit != item ) | 1718 | if ( itemit != item ) |
1716 | itemit->repaintMe(); | 1719 | itemit->repaintMe(); |
1717 | globalFlagBlockAgendaItemUpdate = 1; | 1720 | globalFlagBlockAgendaItemUpdate = 1; |
1718 | //qDebug("sigleshot "); | 1721 | //qDebug("sigleshot "); |
1719 | QTimer::singleShot( 0, itemit, SLOT ( repaintItem() )); | 1722 | QTimer::singleShot( 0, itemit, SLOT ( repaintItem() )); |
1720 | //itemit->repaint( false ); repaintItem() | 1723 | //itemit->repaint( false ); repaintItem() |
1721 | } | 1724 | } |
1722 | blockSignals( false ); | 1725 | blockSignals( false ); |
1723 | } | 1726 | } |
1724 | if ( remove ) { | 1727 | if ( remove ) { |
1725 | //qDebug("remove****************************************** "); | 1728 | //qDebug("remove****************************************** "); |
1726 | return; | 1729 | return; |
1727 | } | 1730 | } |
1728 | if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda ) | 1731 | if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda ) |
1729 | return; | 1732 | return; |
1730 | //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ "); | 1733 | //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ "); |
1731 | QDate currentDate = QDate::currentDate(); | 1734 | QDate currentDate = QDate::currentDate(); |
1732 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < currentDate)&& ( KOPrefs::instance()->mShowTodoInAgenda ); | 1735 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < currentDate)&& ( KOPrefs::instance()->mShowTodoInAgenda ); |
1733 | QDateTime dt; | 1736 | QDateTime dt; |
1734 | if ( todo->hasCompletedDate() ) | 1737 | if ( todo->hasCompletedDate() ) |