1671 } |
1672 } |
1672 } |
1673 } |
1673 } |
1674 } |
1674 TInt pointerIndex(-1); |
1675 TInt pointerIndex(-1); |
1675 TBool isItem (iGrid->View()->XYPosToItemIndex(aPointerEvent.iPosition, pointerIndex)); |
1676 TBool isItem (iGrid->View()->XYPosToItemIndex(aPointerEvent.iPosition, pointerIndex)); |
|
1677 if( isItem ) |
|
1678 { |
|
1679 pointerIndex = static_cast<CAknGridView*>(iGrid->View())->ActualDataIndex( pointerIndex ); |
|
1680 } |
1676 CAknGridM* gridModel = static_cast<CAknGridM*>(iGrid->Model()); |
1681 CAknGridM* gridModel = static_cast<CAknGridM*>(iGrid->Model()); |
1677 |
1682 |
1678 if(gridModel->NumberOfData() <= 0) |
1683 if(gridModel->NumberOfData() <= 0) |
1679 return; |
1684 return; |
1680 |
1685 |
1703 // Event modifiers are ignored for now because |
1708 // Event modifiers are ignored for now because |
1704 // those are not needed but cause problems |
1709 // those are not needed but cause problems |
1705 TPointerEvent pointerEvent( aPointerEvent ); |
1710 TPointerEvent pointerEvent( aPointerEvent ); |
1706 pointerEvent.iModifiers = |
1711 pointerEvent.iModifiers = |
1707 ( aPointerEvent.iModifiers & ( ~EAllModifiers ) ); |
1712 ( aPointerEvent.iModifiers & ( ~EAllModifiers ) ); |
1708 TInt index( iGrid->CurrentItemIndex() ); |
1713 TInt index( iGrid->CurrentDataIndex() ); |
1709 TTime isValidDay; |
1714 TTime isValidDay; |
1710 if( TPointerEvent::EButton1Up == aPointerEvent.iType ) |
1715 if( TPointerEvent::EButton1Up == aPointerEvent.iType ) |
1711 { |
1716 { |
1712 isValidDay = iOldFirstDayOfGrid + |
1717 isValidDay = iOldFirstDayOfGrid + |
1713 TTimeIntervalDays(pointerIndex); |
1718 TTimeIntervalDays(pointerIndex); |
1733 { |
1738 { |
1734 TTime newActiveDay( |
1739 TTime newActiveDay( |
1735 iDate + TTimeIntervalDays( pointerIndex - index ) ); |
1740 iDate + TTimeIntervalDays( pointerIndex - index ) ); |
1736 TDateTime newActiveDayTime = newActiveDay.DateTime(); |
1741 TDateTime newActiveDayTime = newActiveDay.DateTime(); |
1737 |
1742 |
1738 // set the context |
|
1739 TCalTime time; |
|
1740 time.SetTimeLocalL( newActiveDay ); |
|
1741 iServices.Context().SetFocusDateL( time, |
|
1742 TVwsViewId( KUidCalendar, KUidCalenMonthView ) ); |
|
1743 TMonth activeMonth( iDate.DateTime().Month() ); |
1743 TMonth activeMonth( iDate.DateTime().Month() ); |
1744 TMonth newMonth( newActiveDay.DateTime().Month() ); |
1744 TMonth newMonth( newActiveDay.DateTime().Month() ); |
1745 if ( aPointerEvent.iType == TPointerEvent::EButton1Down ) |
1745 if ( aPointerEvent.iType == TPointerEvent::EButton1Down ) |
1746 { |
1746 { |
|
1747 // set the context |
|
1748 TCalTime time; |
|
1749 time.SetTimeLocalL( newActiveDay ); |
|
1750 iServices.Context().SetFocusDateL( time, |
|
1751 TVwsViewId( KUidCalendar, KUidCalenMonthView ) ); |
1747 iGrid->HandlePointerEventL( pointerEvent ); |
1752 iGrid->HandlePointerEventL( pointerEvent ); |
1748 if (iPreview) |
1753 if (iPreview) |
1749 { |
1754 { |
1750 iPreview->Hide(); |
1755 iPreview->Hide(); |
1751 } |
1756 } |
1755 if ( activeMonth != newMonth ) |
1760 if ( activeMonth != newMonth ) |
1756 { |
1761 { |
1757 iChangeMonth = ETrue; |
1762 iChangeMonth = ETrue; |
1758 iGrid->View()->SetDisableRedraw(ETrue); |
1763 iGrid->View()->SetDisableRedraw(ETrue); |
1759 iView->BeginRepopulationL(); |
1764 iView->BeginRepopulationL(); |
|
1765 iDate = newActiveDay; |
1760 } |
1766 } |
1761 HandleDayChangeL( newActiveDay ); |
1767 HandleDayChangeL( newActiveDay ); |
1762 } |
1768 } |
1763 } |
1769 } |
1764 else if ( activeMonth == newMonth |
1770 else if ( activeMonth == newMonth |
1765 && newActiveDay != iDate && !iChangeMonth ) |
1771 && newActiveDay != iDate && !iChangeMonth ) |
1766 { |
1772 { |
1767 iGrid->HandlePointerEventL( pointerEvent ); |
1773 iChangeDay = ETrue; |
1768 // use grid index to make sure that correct grid |
1774 // use grid index to make sure that correct grid |
1769 // element is focused when dragged |
1775 // element is focused when dragged |
1770 TInt gridIndex = GridIndex(); |
1776 TInt gridIndex = GridIndex(); |
1771 newActiveDay = |
1777 newActiveDay = |
1772 ( iFirstDayOfGrid + TTimeIntervalDays( gridIndex ) ); |
1778 ( iFirstDayOfGrid + TTimeIntervalDays( gridIndex ) ); |
1773 HandleDayChangeL( newActiveDay ); |
1779 } |
|
1780 } |
|
1781 else if ( aPointerEvent.iType == TPointerEvent::EButton1Up ) |
|
1782 { |
|
1783 if( !iChangeDay && !iChangeMonth ) |
|
1784 { |
|
1785 iGrid->HandlePointerEventL( pointerEvent ); |
|
1786 } |
|
1787 iChangeDay = EFalse; |
1774 iChangeMonth = EFalse; |
1788 iChangeMonth = EFalse; |
1775 } |
|
1776 } |
|
1777 else if ( aPointerEvent.iType == TPointerEvent::EButton1Up ) |
|
1778 { |
|
1779 iGrid->HandlePointerEventL( pointerEvent ); |
|
1780 } |
1789 } |
1781 } |
1790 } |
1782 } |
1791 } |
1783 |
1792 |
1784 TRACE_EXIT_POINT; |
1793 TRACE_EXIT_POINT; |