summaryrefslogtreecommitdiffabout
path: root/korganizer/koagenda.cpp
Unidiff
Diffstat (limited to 'korganizer/koagenda.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagenda.cpp5
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
@@ -1590,97 +1590,100 @@ 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*/
1601int KOAgenda::timeToY(const QTime &time) 1601int 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*/
1614QTime KOAgenda::gyToTime(int gy) 1614QTime 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
1631void KOAgenda::setStartHour(int startHour) 1631void 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}
1636QTime KOAgenda::getEndTime() 1636QTime 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}
1640void KOAgenda::hideUnused() 1643void 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
1651KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view) 1654KOAgendaItem *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}
1675KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) 1678KOAgendaItem * 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