-rw-r--r-- | korganizer/koagenda.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index b290020..779f12e 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp | |||
@@ -1588,96 +1588,100 @@ void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy) | |||
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() | ||
1637 | { | ||
1638 | return QTime ( (contentsY ()+viewport()->height())*24/contentsHeight ()+1,0,0); | ||
1639 | } | ||
1636 | void KOAgenda::hideUnused() | 1640 | void KOAgenda::hideUnused() |
1637 | { | 1641 | { |
1638 | // experimental only | 1642 | // experimental only |
1639 | // return; | 1643 | // return; |
1640 | KOAgendaItem *item; | 1644 | KOAgendaItem *item; |
1641 | for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) { | 1645 | for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) { |
1642 | item->hide(); | 1646 | item->hide(); |
1643 | } | 1647 | } |
1644 | } | 1648 | } |
1645 | 1649 | ||
1646 | 1650 | ||
1647 | KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view) | 1651 | KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view) |
1648 | { | 1652 | { |
1649 | 1653 | ||
1650 | KOAgendaItem *fi; | 1654 | KOAgendaItem *fi; |
1651 | for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) { | 1655 | for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) { |
1652 | if ( fi->incidence() == event ) { | 1656 | if ( fi->incidence() == event ) { |
1653 | mUnusedItems.remove(); | 1657 | mUnusedItems.remove(); |
1654 | fi->init( event, qd ); | 1658 | fi->init( event, qd ); |
1655 | return fi; | 1659 | return fi; |
1656 | } | 1660 | } |
1657 | } | 1661 | } |
1658 | fi=mUnusedItems.first(); | 1662 | fi=mUnusedItems.first(); |
1659 | if ( fi ) { | 1663 | if ( fi ) { |
1660 | mUnusedItems.remove(); | 1664 | mUnusedItems.remove(); |
1661 | fi->init( event, qd ); | 1665 | fi->init( event, qd ); |
1662 | return fi; | 1666 | return fi; |
1663 | } | 1667 | } |
1664 | // qDebug("new KOAgendaItem "); | 1668 | // qDebug("new KOAgendaItem "); |
1665 | 1669 | ||
1666 | KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode ); | 1670 | KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode ); |
1667 | agendaItem->installEventFilter(this); | 1671 | agendaItem->installEventFilter(this); |
1668 | addChild(agendaItem,0,0); | 1672 | addChild(agendaItem,0,0); |
1669 | return agendaItem; | 1673 | return agendaItem; |
1670 | } | 1674 | } |
1671 | KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) | 1675 | KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) |
1672 | { | 1676 | { |
1673 | KOAgendaItem *item; | 1677 | KOAgendaItem *item; |
1674 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1678 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1675 | if ( item->incidence() == todo ) { | 1679 | if ( item->incidence() == todo ) { |
1676 | mItems.remove(); | 1680 | mItems.remove(); |
1677 | return item; | 1681 | return item; |
1678 | } | 1682 | } |
1679 | } | 1683 | } |
1680 | return 0; | 1684 | return 0; |
1681 | } | 1685 | } |
1682 | 1686 | ||
1683 | 1687 | ||