calendarui/views/src/calenweekcontainer.cpp
branchRCL_3
changeset 30 bd7edf625bdd
child 31 97232defd20e
equal deleted inserted replaced
29:12af337248b1 30:bd7edf625bdd
       
     1 /*
       
     2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Container control for Week View .
       
    15  *
       
    16 */
       
    17 
       
    18 #include <calcommon.h>
       
    19 #include <caltime.h>
       
    20 #include <calinstance.h>
       
    21 #include <calentry.h>
       
    22 #include <calinstanceview.h>
       
    23 #include <calcalendarinfo.h>
       
    24 #include <AknIconArray.h>
       
    25 #include <AknsDrawUtils.h>
       
    26 #include <AknsFrameBackgroundControlContext.h>
       
    27 #include <AknUtils.h>
       
    28 #include <AknIconUtils.h>
       
    29 #include <eikenv.h>
       
    30 #include <eikfrlbd.h>
       
    31 #include <eiklabel.h>
       
    32 #include <gulicon.h>
       
    33 #include <StringLoader.h>
       
    34 #include <calencontext.h>
       
    35 #include <aknlayoutscalable_apps.cdl.h>
       
    36 #include <caleninstanceid.h>            // TCalenInstanceId
       
    37 #include <layoutmetadata.cdl.h>
       
    38 #include <centralrepository.h>
       
    39 #include <calenviewutils.h>
       
    40 #include <calenservices.h>
       
    41 #include <calenagendautils.h>
       
    42 #include <calendateutils.h>
       
    43 #include <mcalenpreview.h>
       
    44 #include <Calendar.rsg>
       
    45 #include <csxhelp/cale.hlp.hrh>
       
    46 #include <gesturehelper.h> //CGestureHelper
       
    47 
       
    48 #include "calendarui_debug.h"
       
    49 #include "calenweekcontainer.h"
       
    50 #include "calencontainerlayoutmanager.h"
       
    51 #include "calencontroller.h"
       
    52 #include "calendrawutils.h"
       
    53 #include "calenicons.h"
       
    54 #include "calenpreview.h"
       
    55 #include "CalenUid.h"
       
    56 #include "CalendarPrivateCRKeys.h"
       
    57 #include "calenweeklistboxview.h"
       
    58 #include "calenweeklistbox.h"
       
    59 #include "calenweeklistboxlayout.h"
       
    60 #include "calenweekview.h"
       
    61 #include "CalenUid.h"
       
    62 #include "calendar.hrh"
       
    63 
       
    64 //  LOCAL CONSTANTS AND MACROS
       
    65 const TInt KNonTimedNoteDefautDisplayTime(8);
       
    66 const TInt KNullMinutes = -1;
       
    67 const TInt KBeforeActiveTime(0);
       
    68 const TInt KHoursInADay( 24 );
       
    69 
       
    70 
       
    71 // METHOD DEFINITIONS
       
    72 // ----------------------------------------------------------------------------
       
    73 // ?classname::?member_function
       
    74 // ?implementation_description
       
    75 // (other items were commented in a header).
       
    76 // ----------------------------------------------------------------------------
       
    77 //
       
    78 void CCalenWeekContainer::DrawBackground(CWindowGc& aGc) const
       
    79     {
       
    80     TRACE_ENTRY_POINT;
       
    81 
       
    82     MAknsControlContext* cc =AknsDrawUtils::ControlContext( this );
       
    83 
       
    84     if( cc )
       
    85         {
       
    86         TRect main_pane( Rect() );
       
    87         AknsDrawUtils::Background( AknsUtils::SkinInstance(),
       
    88                                    cc,
       
    89                                    NULL,
       
    90                                    aGc,
       
    91                                    main_pane );
       
    92         }
       
    93 
       
    94     TRACE_EXIT_POINT;
       
    95     }
       
    96 
       
    97 // ----------------------------------------------------------------------------
       
    98 // Draws horizontal and vertical grid lines
       
    99 // (other items were commented in a header).
       
   100 // ----------------------------------------------------------------------------
       
   101 //
       
   102 void CCalenWeekContainer::DrawGridLines(CWindowGc& aGc) const
       
   103     {
       
   104     TRACE_ENTRY_POINT;
       
   105     
       
   106     TRect main_pane_Rect = ReducePreview( Rect() );
       
   107 
       
   108     TAknLayoutRect main_cale_week_pane;
       
   109     main_cale_week_pane.LayoutRect( main_pane_Rect, AknLayoutScalable_Apps::main_cale_week_pane().LayoutLine() );
       
   110 
       
   111     // FIXME: use member variable?
       
   112     TAknLayoutRect listscroll_cale_week_pane;
       
   113     TWeekListBoxLayout lay( UseInfobar(), UseToolbar(), UsePreview(), main_pane_Rect );
       
   114     TInt layoutVariant = lay.LayoutVariantIndex(TWeekListBoxLayout::EListScrollCaleWeekPane );
       
   115     listscroll_cale_week_pane.LayoutRect( main_cale_week_pane.Rect(), AknLayoutScalable_Apps::listscroll_cale_week_pane(layoutVariant).LayoutLine() );
       
   116 
       
   117     layoutVariant = lay.LayoutVariantIndex(TWeekListBoxLayout::ECaleWeekScrollPaneG1);
       
   118     const TRect parentRect = listscroll_cale_week_pane.Rect();
       
   119     // Primary lines were drawn in different functions
       
   120     TAknLayoutRect horizontalPrimaryLine;
       
   121     horizontalPrimaryLine.LayoutRect( parentRect, AknLayoutScalable_Apps::cale_week_scroll_pane_g1( layoutVariant ).LayoutLine() );
       
   122 
       
   123     TAknLayoutRect verticalPrimaryLine;
       
   124     verticalPrimaryLine.LayoutRect( parentRect, AknLayoutScalable_Apps::cale_week_scroll_pane_g2( layoutVariant ).LayoutLine() );
       
   125 
       
   126     TRgb lineColor( verticalPrimaryLine.Color() );
       
   127     AknsUtils::GetCachedColor(AknsUtils::SkinInstance(), lineColor,
       
   128                               KAknsIIDQsnLineColors,
       
   129                               EAknsCIQsnLineColorsCG1);
       
   130     aGc.SetBrushColor( lineColor );
       
   131     aGc.SetBrushStyle( CGraphicsContext::ESolidBrush );
       
   132 
       
   133     aGc.Clear( verticalPrimaryLine.Rect() );
       
   134     aGc.Clear( horizontalPrimaryLine.Rect() );
       
   135 
       
   136     // There are six secondary vertical lines
       
   137     const TInt verticalLineCount = 6;
       
   138     TAknLayoutRect verticalLines[ verticalLineCount ];
       
   139     verticalLines[0].LayoutRect( parentRect, AknLayoutScalable_Apps::cale_week_scroll_pane_g3( layoutVariant ).LayoutLine() );
       
   140     verticalLines[1].LayoutRect( parentRect, AknLayoutScalable_Apps::cale_week_scroll_pane_g4( layoutVariant ).LayoutLine() );
       
   141     verticalLines[2].LayoutRect( parentRect, AknLayoutScalable_Apps::cale_week_scroll_pane_g5( layoutVariant ).LayoutLine() );
       
   142     verticalLines[3].LayoutRect( parentRect, AknLayoutScalable_Apps::cale_week_scroll_pane_g6( layoutVariant ).LayoutLine() );
       
   143     verticalLines[4].LayoutRect( parentRect, AknLayoutScalable_Apps::cale_week_scroll_pane_g7( layoutVariant ).LayoutLine() );
       
   144     verticalLines[5].LayoutRect( parentRect, AknLayoutScalable_Apps::cale_week_scroll_pane_g8( layoutVariant ).LayoutLine() );
       
   145 
       
   146     // and seven secondary horizontal lines
       
   147     const TInt horizontalLineCount = 7;
       
   148     TAknLayoutRect horizontalLines[ horizontalLineCount ];
       
   149     horizontalLines[0].LayoutRect( parentRect, AknLayoutScalable_Apps::cale_week_scroll_pane_g9( layoutVariant ).LayoutLine() );
       
   150     horizontalLines[1].LayoutRect( parentRect, AknLayoutScalable_Apps::cale_week_scroll_pane_g10( layoutVariant ).LayoutLine() );
       
   151     horizontalLines[2].LayoutRect( parentRect, AknLayoutScalable_Apps::cale_week_scroll_pane_g11( layoutVariant ).LayoutLine() );
       
   152     horizontalLines[3].LayoutRect( parentRect, AknLayoutScalable_Apps::cale_week_scroll_pane_g12( layoutVariant ).LayoutLine() );
       
   153     horizontalLines[4].LayoutRect( parentRect, AknLayoutScalable_Apps::cale_week_scroll_pane_g13( layoutVariant ).LayoutLine() );
       
   154     horizontalLines[5].LayoutRect( parentRect, AknLayoutScalable_Apps::cale_week_scroll_pane_g14( layoutVariant ).LayoutLine() );
       
   155     horizontalLines[6].LayoutRect( parentRect, AknLayoutScalable_Apps::cale_week_scroll_pane_g15( layoutVariant ).LayoutLine() );
       
   156 
       
   157     lineColor = verticalLines[0].Color();
       
   158     AknsUtils::GetCachedColor(AknsUtils::SkinInstance(), lineColor,
       
   159                               KAknsIIDQsnLineColors,
       
   160                               EAknsCIQsnLineColorsCG2);
       
   161     aGc.SetBrushColor( lineColor );
       
   162     aGc.SetBrushStyle( CGraphicsContext::ESolidBrush );
       
   163 
       
   164     for (TInt i=0; i < verticalLineCount; ++i)
       
   165         {
       
   166         aGc.Clear( verticalLines[i].Rect() );
       
   167         }
       
   168 
       
   169     for (TInt i=0; i < horizontalLineCount; ++i)
       
   170         {
       
   171         aGc.Clear( horizontalLines[i].Rect() );
       
   172         }
       
   173 
       
   174     TRACE_EXIT_POINT;
       
   175     }
       
   176 
       
   177 
       
   178 
       
   179 // ================= MEMBER FUNCTIONS =======================
       
   180 
       
   181 // ----------------------------------------------------------------------------
       
   182 // CCalenWeekContainer::CCalenWeekContainer
       
   183 // C++ constructor can NOT contain any code, that might leave.
       
   184 // (other items were commented in a header).
       
   185 // ----------------------------------------------------------------------------
       
   186 //
       
   187 CCalenWeekContainer::CCalenWeekContainer( CCalenNativeView* aView,
       
   188                                           TTime& aTime,
       
   189                                           TInt& aSelectedRowNumber,
       
   190                                           TTimeIntervalMinutes& aFirstRowTime,
       
   191                                           MCalenServices& aServices )
       
   192     : CCalenContainer( aView, aServices ),
       
   193 //      iCurrentDay( TInt64(0) ),
       
   194       iStartDay( TInt64(0) ),
       
   195       iViewPopulationComplete( EFalse ),
       
   196       iTime( aTime ),
       
   197       iSelectedRowNumber( aSelectedRowNumber ),
       
   198       iFirstRowTime( aFirstRowTime )
       
   199     {
       
   200     TRACE_ENTRY_POINT;
       
   201     TRACE_EXIT_POINT;
       
   202     }
       
   203 
       
   204 // ----------------------------------------------------------------------------
       
   205 // CCalenWeekContainer::~CCalenWeekContainer
       
   206 // Destructor
       
   207 // (other items were commented in a header).
       
   208 // ----------------------------------------------------------------------------
       
   209 //
       
   210 CCalenWeekContainer::~CCalenWeekContainer()
       
   211     {
       
   212     TRACE_ENTRY_POINT;
       
   213 
       
   214     delete iListBox;
       
   215     
       
   216     delete iDesArray;
       
   217 
       
   218     CleanupInstances();
       
   219 
       
   220     ResetSlotTable();
       
   221     delete iBackgroundSkinContext;
       
   222     delete iGestureControl;
       
   223 
       
   224     TRACE_EXIT_POINT;
       
   225     }
       
   226 
       
   227 
       
   228 
       
   229 // ---------------------------------------------------------
       
   230 // CCalenWeekContainer::SetCursorToActiveDayL
       
   231 // Sets cursor in Active day
       
   232 // (other items were commented in a header).
       
   233 // ----------------------------------------------------------------------------
       
   234 //
       
   235 void CCalenWeekContainer::SetCursorToActiveDayL()
       
   236     {
       
   237     TRACE_ENTRY_POINT;
       
   238 
       
   239     iTime = CCalenContainer::DateFromContextL( iServices.Context() );
       
   240 
       
   241     TLocale locale;
       
   242 
       
   243     TInt column( iTime.DayNoInWeek() - locale.StartOfWeek() );
       
   244 
       
   245     if( column < 0 )
       
   246         {
       
   247         column += KCalenDaysInWeek;
       
   248         }
       
   249     iColumn = column;
       
   250 
       
   251     TTime startDay( iTime - TTimeIntervalDays( column ) );
       
   252 
       
   253     if (iStartDay != startDay)
       
   254         {
       
   255         iStartDay = startDay;
       
   256         iView->BeginRepopulationL();
       
   257         iListBox->View()->SetDisableRedraw(ETrue);
       
   258         }
       
   259     else if ( iViewPopulationComplete )
       
   260         {
       
   261         iListBox->View()->SetDisableRedraw(ETrue);
       
   262         SelectHighlightedCellAndVisibleRangeL();
       
   263         iListBox->View()->SetDisableRedraw(EFalse);
       
   264         FocusChangeForPopupL();
       
   265         UpdateStatusPaneAndExtensionsL();
       
   266         DrawNow();
       
   267         }
       
   268     
       
   269     TRACE_EXIT_POINT;
       
   270     }
       
   271 
       
   272 // ----------------------------------------------------------------------------
       
   273 // CCalenWeekContainer::RedrawLocaleChangeL
       
   274 // Redrawing when locale change
       
   275 // (other items were commented in a header).
       
   276 // ----------------------------------------------------------------------------
       
   277 //
       
   278 void CCalenWeekContainer::RedrawLocaleChangeL(TLocaleChangeRedraw aFlag) // ERedrawAll | ERedrawWeek
       
   279     {
       
   280     TRACE_ENTRY_POINT;
       
   281 
       
   282     if (aFlag == ERedrawAll)
       
   283         {
       
   284         iStartDay = Time::NullTTime();
       
   285         SetCursorToActiveDayL();
       
   286         }
       
   287     FocusChangeForPopupL();    
       
   288     UpdateStatusPaneAndExtensionsL();
       
   289 
       
   290     TRACE_EXIT_POINT;
       
   291     }
       
   292 
       
   293 // ----------------------------------------------------------------------------
       
   294 // ?classname::?member_function
       
   295 // ?implementation_description
       
   296 // (other items were commented in a header).
       
   297 // ----------------------------------------------------------------------------
       
   298 //
       
   299 TInt CCalenWeekContainer::HighlightRowFromActiveContextL(TInt aColumn)
       
   300     {
       
   301     TRACE_ENTRY_POINT;
       
   302     
       
   303     TInt row = KErrNotFound;
       
   304 
       
   305     MCalenContext& context = iServices.Context();
       
   306     
       
   307     // row is selected while moving up/dowm left/right
       
   308     if ( iSelectedRowNumber != KErrNotFound )  
       
   309        {
       
   310         row = iSelectedRowNumber;
       
   311         iFirstRowTime = context.FocusTime();
       
   312 		
       
   313 		if(iFirstRowTime != TTimeIntervalMinutes(KNullMinutes))
       
   314 			{
       
   315 			iRow = EFalse;
       
   316 			}
       
   317 		else
       
   318 			{
       
   319 			iRow = ETrue;
       
   320 			row = FindItemFromColumnL( context.InstanceId(),aColumn );
       
   321 			}
       
   322 		
       
   323 		if(iFirstRowTime == TTimeIntervalMinutes(0))
       
   324 			{
       
   325 			row = KErrNotFound;
       
   326 			iFirstRowTime = TTimeIntervalMinutes(KNullMinutes);
       
   327 			}
       
   328 	    
       
   329         }
       
   330      else if ( !(context.InstanceId() == TCalenInstanceId::NullInstanceId() ) )
       
   331         {
       
   332         // based on the instanceid
       
   333         row = FindItemFromColumnL( context.InstanceId(),
       
   334                                           aColumn );
       
   335                                           
       
   336         }
       
   337      else if ( context.FocusDateAndTimeL().TimeUtcL() != Time::NullTTime() )
       
   338         {
       
   339         // weekview is activated from other views/view switching
       
   340         if(	iSelectedRowNumber == KErrNotFound && 
       
   341         	iFirstRowTime == TTimeIntervalMinutes(KNullMinutes)  )
       
   342         	{
       
   343         	row = KErrNotFound;
       
   344         	}
       
   345         else
       
   346         	{
       
   347         	// based on the context time
       
   348         	row = FindRowForTime(
       
   349             	    CalenDateUtils::RoundToPreviousHour(
       
   350                 	CalenDateUtils::TimeOfDay(
       
   351                     context.FocusDateAndTimeL().TimeLocalL().DateTime() ) ) );
       
   352         	}
       
   353         }
       
   354 
       
   355     // if we still haven't found anything to highlight,
       
   356     // highlight to first entry or 8:00 row.
       
   357     if (row == KErrNotFound)
       
   358         {
       
   359         row = FindFirstItemOfColumn(aColumn);
       
   360 
       
   361         if (row == KErrNotFound)
       
   362             {
       
   363             TInt eightOclock = KNonTimedNoteDefautDisplayTime * KCalenMinutesInHour;
       
   364             row = FindRowForTime( eightOclock );
       
   365             iTopRowDefault = ETrue;
       
   366             }
       
   367         }
       
   368     ASSERT( row != KErrNotFound );
       
   369 	
       
   370 	TRACE_EXIT_POINT;
       
   371     return row;
       
   372     
       
   373     }
       
   374 
       
   375 // ----------------------------------------------------------------------------
       
   376 // CCalenWeekContainer::SelectHighlightedCellAndVisibleRangeL()
       
   377 // Sets highlight item in ListBox at active time
       
   378 // (other items were commented in a header).
       
   379 // ----------------------------------------------------------------------------
       
   380 //
       
   381 void CCalenWeekContainer::SelectHighlightedCellAndVisibleRangeL()
       
   382     {
       
   383     TRACE_ENTRY_POINT;
       
   384 
       
   385     TInt row = HighlightRowFromActiveContextL( iColumn );
       
   386 	TInt topRow = SearchTopIndexL( iColumn );
       
   387 	
       
   388     if (row == KErrNotFound)
       
   389         {
       
   390         // If not yet found, Then just take 8:00 row
       
   391         TInt eightOclock = KNonTimedNoteDefautDisplayTime * KCalenMinutesInHour;
       
   392         row = FindRowForTime(eightOclock);
       
   393         }
       
   394 
       
   395     SetHighlightAndVisibleRange( row, iColumn, topRow );
       
   396 	SetActiveContextFromHighlightL();
       
   397 	 
       
   398     TRACE_EXIT_POINT;
       
   399     }
       
   400 
       
   401 // ----------------------------------------------------------------------------
       
   402 // CCalenWeekContainer::SetActiveContextFromHighlightL
       
   403 // Set Active date and time
       
   404 // (other items were commented in a header).
       
   405 // ----------------------------------------------------------------------------
       
   406 //
       
   407 void CCalenWeekContainer::SetActiveContextFromHighlightL(TBool aInstAvailable)
       
   408     {
       
   409     TRACE_ENTRY_POINT;
       
   410 
       
   411     MCalenContext& context = iServices.Context();
       
   412     TCalTime currentDayCalTime;
       
   413     TDateTime dt = iTime.DateTime();
       
   414     currentDayCalTime.SetTimeLocalL( iTime );
       
   415     context.SetFocusDateAndTimeL( currentDayCalTime,
       
   416                                   TVwsViewId( KUidCalendar, KUidCalenWeekView ) );
       
   417 
       
   418     TInt row = iListBox->View()->CurrentItemIndex();
       
   419     // In under processing of DoStepL(), row is -1.
       
   420     if (row >= 0)
       
   421         {
       
   422         CWeekSlotArrayPtr slotTable = iSlotTable[iColumn];
       
   423         const CCalHourItem& itemInfo = *(*slotTable)[row];
       
   424         // Focused item
       
   425         // 1. Non-timed item, 1 for each cell, on same/ different day
       
   426         //    * Focus on instanceId and datetime
       
   427         // 2. Timed item, 1-n for each cell, on same/ different day
       
   428         //    * Focus on datetime
       
   429         if( itemInfo.HasInstance() && aInstAvailable && iViewPopulationComplete)
       
   430             {
       
   431             TCalenInstanceId instId = TCalenInstanceId::CreateL( *itemInfo.iInstance );
       
   432             if( !itemInfo.IsTimed() )       // todo/anniv/memo
       
   433                 {
       
   434                 dt.SetHour( KNonTimedNoteDefautDisplayTime );
       
   435                 currentDayCalTime.SetTimeLocalL( TTime( dt ) );
       
   436                 context.SetFocusDateAndTimeAndInstanceL( currentDayCalTime, instId, 
       
   437                                                 TVwsViewId( KUidCalendar, KUidCalenWeekView ) );
       
   438                 }
       
   439             else    // meeting
       
   440                 {
       
   441                 TTime focusTime = CalenDateUtils::BeginningOfDay( iTime ) + itemInfo.iStartTime;
       
   442                 currentDayCalTime.SetTimeLocalL( focusTime );
       
   443                 context.SetFocusDateAndTimeAndInstanceL( currentDayCalTime, instId, 
       
   444                                             TVwsViewId( KUidCalendar, KUidCalenWeekView ) );
       
   445                 }
       
   446             }
       
   447         else if( itemInfo.iStartTime.Int() == KErrNotFound )    // empty non-timed cell
       
   448             {
       
   449             dt.SetHour( KNonTimedNoteDefautDisplayTime );
       
   450             currentDayCalTime.SetTimeLocalL( TTime( dt ) );
       
   451             context.SetFocusDateAndTimeL( currentDayCalTime,
       
   452                                                 TVwsViewId( KUidCalendar, KUidCalenWeekView ) );
       
   453             }
       
   454         else    // empty timed cell
       
   455             {
       
   456             TTime focusTime = CalenDateUtils::BeginningOfDay( iTime ) + itemInfo.iStartTime;
       
   457             currentDayCalTime.SetTimeLocalL( focusTime );
       
   458             context.SetFocusDateAndTimeL( currentDayCalTime,
       
   459                                                 TVwsViewId( KUidCalendar, KUidCalenWeekView ) );
       
   460             }
       
   461         FocusChangeForPopupL();
       
   462         }
       
   463 	// Hide/unhide "today" toolbar item based on the focused day
       
   464     UpdateTodayToolbarItemL();
       
   465     TRACE_EXIT_POINT;
       
   466     }
       
   467 
       
   468 // ----------------------------------------------------------------------------
       
   469 // CCalenWeekContainer::CalcDayFromColumn
       
   470 // Calculates and Sets day from ListBox column
       
   471 // (other items were commented in a header).
       
   472 // ----------------------------------------------------------------------------
       
   473 //
       
   474 void CCalenWeekContainer::CalcDayFromColumn()
       
   475     {
       
   476     TRACE_ENTRY_POINT;
       
   477 
       
   478     iTime = iStartDay + TTimeIntervalDays( iColumn );
       
   479     TDateTime dt = iStartDay.DateTime();
       
   480 
       
   481     TRACE_EXIT_POINT;
       
   482     }
       
   483 
       
   484 
       
   485 // ----------------------------------------------------------------------------
       
   486 // CCalenWeekContainer::PopulatesDayListsL
       
   487 // Populate whole week daylist from Agenda server
       
   488 // (other items were commented in a header).
       
   489 // ----------------------------------------------------------------------------
       
   490 //
       
   491 void CCalenWeekContainer::PopulatesDayListsL()
       
   492     {
       
   493     TRACE_ENTRY_POINT;
       
   494 
       
   495     TTime indexDay( iStartDay );
       
   496     TTimeIntervalDays oneDay( 1 );
       
   497     
       
   498     RArray<TInt> colIdArray;
       
   499     CCalenNativeView::GetActiveCollectionidsL( iServices, colIdArray );
       
   500     
       
   501     if(colIdArray.Count() > 0)
       
   502          {    
       
   503          for( TInt i(0); i < KCalenDaysInWeek; ++i, indexDay+=oneDay )
       
   504             {
       
   505             iIdList[i].ResetAndDestroy();
       
   506             CalenAgendaUtils::CreateEntryIdListForDayL( iIdList[i],
       
   507                                                         iServices.InstanceViewL(colIdArray),
       
   508                                                         indexDay );
       
   509             }
       
   510          }
       
   511      else
       
   512          {
       
   513          for( TInt i(0); i < KCalenDaysInWeek; ++i, indexDay+=oneDay )
       
   514              {
       
   515              iIdList[i].ResetAndDestroy();
       
   516              CalenAgendaUtils::CreateEntryIdListForDayL( iIdList[i],
       
   517                                                          iServices.InstanceViewL(),
       
   518                                                          indexDay );
       
   519              }
       
   520          }
       
   521     
       
   522     colIdArray.Reset();
       
   523     TRACE_EXIT_POINT;
       
   524     }
       
   525 
       
   526 // ----------------------------------------------------------------------------
       
   527 // CCalenWeekContainer::InsertTimedNotesToSlotTableL
       
   528 //
       
   529 // After this function, slotTable for each column (weekday)
       
   530 // will contain:
       
   531 // 1) for each hour row without meetings:
       
   532 //       SHourItem.iStartTime = hour as a minutes from beginning of day
       
   533 //       SHourItem.iInstanceId = NullInstanceId
       
   534 //       SHourItem.iTimedNote = EFalse
       
   535 //       SHourItem.iHourData = -- (nothing set)
       
   536 // 2) for each hour row with at least one meeting:
       
   537 //       SHourItem.iStartTime = hour as a minutes from beginning of day
       
   538 //       SHourItem.iInstanceId = instance id of first entry falling to the hour
       
   539 //                               (sorting order as in day view)
       
   540 //       SHourItem.iTimedNote = ETrue
       
   541 //       SHourItem.iHourData = hour data as a table of six color values.
       
   542 //
       
   543 // (other items were commented in a header).
       
   544 // ----------------------------------------------------------------------------
       
   545 //
       
   546 void CCalenWeekContainer::InsertTimedNotesToSlotTableL()
       
   547     {
       
   548     TRACE_ENTRY_POINT;
       
   549 		//Parsing items for each day in week
       
   550 
       
   551     TTime instStart;
       
   552     TTime instEnd;
       
   553 
       
   554     TDateTime daybegin;
       
   555     TDateTime startDateTime;
       
   556     TDateTime endDateTime;
       
   557     TTimeIntervalMinutes durationInMinutes;
       
   558 
       
   559 	TTimeIntervalHours instStartHour;
       
   560 	TTimeIntervalHours instEndHour;
       
   561 	TTimeIntervalMinutes instStartMin;
       
   562 	TTimeIntervalMinutes instEndMin;
       
   563 	
       
   564 	TInt markStart;
       
   565 	TInt markEnd;
       
   566 	TInt instEndHourInt;
       
   567 	TInt instStartMinInt;
       
   568 	TInt instEndMinInt;
       
   569 	TInt eventsInHour;
       
   570 	TInt hours;
       
   571 	
       
   572     TInt KEveryMinutes = KCalenMinutesInHour / KEventsInHour;	//10min
       
   573 
       
   574     // For each day in a week
       
   575     for (TInt dayIx(0); dayIx < KCalenDaysInWeek; dayIx++)
       
   576     	{
       
   577         TTime day((iStartDay + TTimeIntervalDays(dayIx)));
       
   578         CWeekSlotArrayPtr slotTable = iSlotTable[dayIx];
       
   579         RPointerArray<CCalInstance>& dayList = iIdList[dayIx];	//Event for day
       
   580         
       
   581         //Get start time of day
       
   582         TTime dayBegin = CalenDateUtils::BeginningOfDay( day );
       
   583 		
       
   584 		//Initialize the ptr list with empty items but take account the non timed events
       
   585 		TInt beginMinutes(0);
       
   586 		
       
   587 		// For each hour in a day initialisation for the slot table and other hour item required.
       
   588 		for(TInt i(0) ; i < KCalenHoursInDay; i++)
       
   589  			{				      
       
   590 	   		CCalHourItem* emptyInfo = CCalHourItem::NewL();
       
   591 	        CleanupStack::PushL( emptyInfo );
       
   592 	        emptyInfo->iInstance = NULL;
       
   593 	        emptyInfo->iStartTime = TTimeIntervalMinutes( beginMinutes );
       
   594 	        emptyInfo->iTimedNote = EFalse;
       
   595 			
       
   596 		    // For instances before non - timed notes
       
   597 			if(i < KNonTimedNoteDefautDisplayTime)
       
   598             	{
       
   599             	slotTable->InsertL(i, emptyInfo);
       
   600             	}
       
   601         	else // For instances after non - timed notes
       
   602             	{
       
   603                 emptyInfo->iTimedNote=ETrue;
       
   604             	slotTable->AppendL(emptyInfo);
       
   605             	}				
       
   606 	 		CleanupStack::Pop();
       
   607 	 		beginMinutes = beginMinutes + KCalenMinutesInHour;
       
   608  			}
       
   609         
       
   610         
       
   611 
       
   612  	    //Go through the whole instance list
       
   613 		for(TInt item(0);  item < dayList.Count();  item++)
       
   614  			{
       
   615  			RPointerArray<CCalCalendarInfo> calendarInfoList;
       
   616  			iServices.GetAllCalendarInfoL(calendarInfoList);
       
   617  			CleanupClosePushL(calendarInfoList);  
       
   618  			CCalInstance* inst = dayList[item];
       
   619  			CCalEntry& entry = inst->Entry();
       
   620        		TCalCollectionId colId = inst->InstanceIdL().iCollectionId;
       
   621             HBufC* calendarFileName = iServices.GetCalFileNameForCollectionId(colId).AllocLC();
       
   622             TInt index = calendarInfoList.Find( *calendarFileName, 
       
   623        	         CCalenWeekContainer::CalendarInfoIdentifierL);
       
   624        	    CleanupStack::PopAndDestroy(calendarFileName);
       
   625             
       
   626             //Handle only the timed node, ignore nontimed and non-allday
       
   627             if( ( IsTimedNoteL( entry ) || CalenViewUtils::IsAlldayEventL(*inst) )
       
   628                 && index != KErrNotFound && calendarInfoList[index]->Enabled() )
       
   629 	        	{
       
   630 	            //Get the start and end time of instance
       
   631 				instStart = inst->Time().TimeLocalL();
       
   632 				entry.EndTimeL().TimeLocalL().MinutesFrom( entry.StartTimeL().TimeLocalL(), durationInMinutes );
       
   633         		instEnd = instStart + durationInMinutes;
       
   634         		
       
   635         		//  Get the day' begin time, instance start time and
       
   636         		// instance end time in TDateTime format.
       
   637         		daybegin = dayBegin.DateTime();
       
   638         		startDateTime = instStart.DateTime();
       
   639         		endDateTime = instEnd.DateTime();
       
   640         		
       
   641         		// If the instance start time is before the day begin,
       
   642         		// then initialise it to day begin's time
       
   643         		if(startDateTime.Year() != daybegin.Year() ||
       
   644         		   startDateTime.Month() != daybegin.Month() ||
       
   645         		   startDateTime.Day() != daybegin.Day() )
       
   646             		{
       
   647             		startDateTime = daybegin;
       
   648             		}
       
   649         		
       
   650         		// If the instance end day one or more days ahead than
       
   651         		// day begin, then initialise it to end of day begin
       
   652         		if(endDateTime.Year() != daybegin.Year() ||
       
   653         		   endDateTime.Month() != daybegin.Month() ||
       
   654         		   endDateTime.Day() != daybegin.Day() )
       
   655             		{
       
   656             		endDateTime = daybegin;
       
   657             		endDateTime.SetHour(23);
       
   658             		endDateTime.SetMinute(59);
       
   659             		}
       
   660         		
       
   661         		//Get time interval between beginning of day and instance start and end time
       
   662         		// in minutes in TTimeIntervalMinutes format.
       
   663 	        	TTime(startDateTime).HoursFrom(dayBegin, instStartHour);
       
   664 	 			TTime(endDateTime).HoursFrom(dayBegin,instEndHour); 
       
   665 	 			
       
   666 	 			//Get time interval between beginning of day and instance start and end time				
       
   667         		// in hours in TTimeIntervalHours format.	        	
       
   668 	        	TTime(startDateTime).MinutesFrom(dayBegin,instStartMin);
       
   669 	 			TTime(endDateTime).MinutesFrom(dayBegin,instEndMin);
       
   670 
       
   671         		// The no. of hours from day begin to instance end time
       
   672         		instEndHourInt = instEndHour.Int();   //From Day Begin
       
   673         		
       
   674         		// The no. of min from day begin to instance start time.
       
   675         		instStartMinInt = instStartMin.Int();
       
   676         		// The no. of min from day begin to instance end time
       
   677         		instEndMinInt = instEndMin.Int();
       
   678         		
       
   679                 // The hour to start with.
       
   680                 hours = instStartHour.Int();
       
   681                 eventsInHour = startDateTime.Minute() / 10;
       
   682                 
       
   683                 // The minute to start with.
       
   684         		markStart = instStartMin.Int();
       
   685 	            
       
   686 	            // The minute to end with.
       
   687                 markEnd = markStart + KEveryMinutes;
       
   688                 
       
   689                 // From instance start hour to end hour
       
   690                 for( ; hours <= instEndHourInt; hours++ )            	
       
   691 	            	{
       
   692 	                TInt itemIndex(0);
       
   693 		       		// Before non - timed notes
       
   694 		       		if(hours < KNonTimedNoteDefautDisplayTime )
       
   695 		       			{
       
   696 						itemIndex = hours;		       	  		
       
   697 		       			}
       
   698 			        else  // After non-time notes
       
   699 			        	{
       
   700 						itemIndex = hours + iNonTimedAreaRowCount;
       
   701 			        	}
       
   702 			        
       
   703 		      //Get correct item
       
   704 		      CCalHourItem& itemInfo = *(*slotTable)[itemIndex];
       
   705 			  itemInfo.iInstance = inst;	
       
   706 			  TUint32 color;
       
   707 	                
       
   708 	                // For all the events in this hour
       
   709 	                for( ; eventsInHour < KEventsInHour; eventsInHour++ )	// 6 times
       
   710 	                    {
       
   711 	                    // If this instance is there between mark start and end
       
   712 	                    if( ( instStartMinInt >= markStart && instStartMinInt < markEnd) ||
       
   713 	                            ( instStartMinInt <= markStart && instEndMinInt > markStart) )
       
   714                             { 
       
   715                             if( itemInfo.iHourData.Event(eventsInHour) )
       
   716                                 {
       
   717                                 // conflicting meeting from same/different db
       
   718                                 color = (TUint32)EManyEvents;
       
   719                                 }
       
   720                             else
       
   721                                 {
       
   722                                 color = calendarInfoList[index]->Color().Value();
       
   723                                 if(color == KRgbBlack.Value())
       
   724                                     {
       
   725                                     color = EBlackColoredEvent;
       
   726                                     }
       
   727                                 }
       
   728                       		itemInfo.iHourData.SetEvent( eventsInHour, color );
       
   729                             }
       
   730 	                    markStart += KEveryMinutes;
       
   731 	                    markEnd += KEveryMinutes;
       
   732 	                    }
       
   733 	                	eventsInHour = 0;
       
   734 	            	}
       
   735             	}
       
   736             CleanupStack::PopAndDestroy(&calendarInfoList);
       
   737  			}
       
   738  		ClearOneDayEntryCache();
       
   739     	}
       
   740     TRACE_EXIT_POINT; 
       
   741 
       
   742     }
       
   743 
       
   744 // ----------------------------------------------------------------------------
       
   745 // CCalenWeekContainer::InsertNonTimedNotesToSlotTableL
       
   746 //
       
   747 // After this function, slotTable for each column (weekday)
       
   748 // will contain:
       
   749 // 1) for each empty non-timed note row (those days that have less
       
   750 //    non-timed notes than others, contain empty rows):
       
   751 //       SHourItem.iStartTime = KCalenActiveTimeNull
       
   752 //       SHourItem.iInstanceId = NullInstanceId
       
   753 //       SHourItem.iTimedNote = EFalse
       
   754 //       SHourItem.iHourData = -- (nothing set)
       
   755 // 2) for each non-timed note row with note :
       
   756 //       SHourItem.iStartTime = KCalenActiveTimeNull
       
   757 //       SHourItem.iInstanceId = instance id of entry
       
   758 //       SHourItem.iTimedNote = EFalse
       
   759 //       SHourItem.iHourData = icon index representing non-timed note
       
   760 //
       
   761 // (other items were commented in a header).
       
   762 // ----------------------------------------------------------------------------
       
   763 //
       
   764 void CCalenWeekContainer::InsertNonTimedNotesToSlotTableL()
       
   765     {
       
   766     TRACE_ENTRY_POINT;
       
   767 
       
   768     TInt maxNotes( 0 );
       
   769     TInt nonTimedNotes[ KCalenDaysInWeek ];
       
   770 
       
   771     TInt dayIx( 0 );
       
   772 
       
   773     for( dayIx = 0; dayIx < KCalenDaysInWeek; ++dayIx )
       
   774         {
       
   775         nonTimedNotes[dayIx] = 0;
       
   776 
       
   777         // instances
       
   778         RPointerArray<CCalInstance>& dayList = iIdList[dayIx];
       
   779 
       
   780 
       
   781         for (TInt i(0); i < dayList.Count(); ++i)
       
   782             {
       
   783             CCalEntry& entry = dayList[i]->Entry();
       
   784             CCalEntry::TType type = entry.EntryTypeL();
       
   785             
       
   786             TCalCollectionId colId = dayList[i]->InstanceIdL().iCollectionId;
       
   787             
       
   788                     
       
   789                 if ( type != CCalEntry::EAppt && !CalenViewUtils::IsAlldayEventL( *( dayList[i] ) ) )
       
   790                     {
       
   791                     nonTimedNotes[dayIx] += 1;
       
   792                     }
       
   793             }
       
   794         maxNotes = Max( maxNotes, nonTimedNotes[dayIx] );
       
   795         }
       
   796     iNonTimedAreaRowCount = maxNotes;
       
   797 
       
   798 
       
   799     for( dayIx = 0; dayIx < KCalenDaysInWeek; ++dayIx )
       
   800         {
       
   801         CWeekSlotArrayPtr slotTable = iSlotTable[dayIx];
       
   802 
       
   803         // Empty slots
       
   804         TInt nonTimedAreaRow( 0 );
       
   805         for ( ; nonTimedAreaRow < iNonTimedAreaRowCount - nonTimedNotes[dayIx]; ++nonTimedAreaRow )
       
   806             {
       
   807             // create new hour item
       
   808             CCalHourItem* itemInfo = CCalHourItem::NewL();
       
   809             CleanupStack::PushL( itemInfo );
       
   810             itemInfo->iStartTime = TTimeIntervalMinutes( KNullMinutes );
       
   811             itemInfo->iTimedNote = EFalse;
       
   812             // Empty slots
       
   813             itemInfo->iInstance = NULL;
       
   814             slotTable->AppendL( itemInfo );
       
   815             CleanupStack::Pop();  // iteminfo
       
   816             // we just put non-timed notes to slot table
       
   817             }
       
   818 
       
   819         // Slots with notes
       
   820         if (nonTimedAreaRow < iNonTimedAreaRowCount)
       
   821             {
       
   822             RPointerArray<CCalInstance>& dayList = iIdList[dayIx];
       
   823 
       
   824             for( TInt item(0); item < dayList.Count(); ++item )
       
   825                 {
       
   826                 CCalEntry& entry = dayList[item]->Entry();
       
   827                 TCalCollectionId colId = dayList[item]->InstanceIdL().iCollectionId;
       
   828                 
       
   829                 if( !IsTimedNoteL( entry ) && !CalenViewUtils::IsAlldayEventL( *( dayList[item] ) ) ) ///*&& index != KErrNotFound && infoArray[index]->GetCalendarStatus()*/)
       
   830                     {
       
   831                     ++nonTimedAreaRow;
       
   832 
       
   833                     CCalHourItem* itemInfo = CCalHourItem::NewL();
       
   834                     CleanupStack::PushL( itemInfo );
       
   835                     itemInfo->iInstance = dayList[item];
       
   836                     // set icon index
       
   837                     TInt iconIndex = static_cast<TInt>( IconIndexFromEntryL( entry ,
       
   838                             CalenViewUtils::IsAlldayEventL( *( dayList[ item ] ) ) ) );
       
   839                     itemInfo->iHourData.SetIconIndex( iconIndex );
       
   840                     slotTable->AppendL( itemInfo );
       
   841                     CleanupStack::Pop(); // iteminfo
       
   842                     }
       
   843                 }
       
   844             }
       
   845         }
       
   846 
       
   847     TRACE_EXIT_POINT;
       
   848     }
       
   849 
       
   850 // ----------------------------------------------------------------------------
       
   851 // CCalenWeekContainer::SetListBoxDataL
       
   852 // Sets Week data to ListBox
       
   853 // (other items were commented in a header).
       
   854 // ----------------------------------------------------------------------------
       
   855 //
       
   856 void CCalenWeekContainer::SetListBoxDataL()
       
   857     {
       
   858     TRACE_ENTRY_POINT;
       
   859 
       
   860     iListBox->View()->SetDisableRedraw(ETrue);
       
   861 
       
   862     TLocale locale;
       
   863 
       
   864     const TInt resID( locale.TimeFormat() == ETime24 ?
       
   865                       R_QTN_TIME_USUAL : R_CALEN_WEEKVIEW_TIMEFORMAT_12 );
       
   866     HBufC* timeFormat = StringLoader::LoadLC( resID, iEikonEnv );
       
   867 
       
   868     iDesArray->Reset();
       
   869 
       
   870     CWeekSlotArrayPtr firstDaySlotTable = iSlotTable[0];
       
   871     TInt count( firstDaySlotTable->Count() );
       
   872 
       
   873     for (TInt row(0); row < count; ++row)
       
   874         {
       
   875         TTime time(TInt64(0));
       
   876         const CCalHourItem& hourItemInfo = *(*firstDaySlotTable)[row];
       
   877 
       
   878         SDisplayData dispData;
       
   879         if( hourItemInfo.iStartTime.Int() >= 0 )
       
   880             {
       
   881             time += hourItemInfo.iStartTime;
       
   882             time.FormatL(dispData.iHourDes, *timeFormat);
       
   883             }
       
   884 
       
   885         for (TInt day(0); day < KCalenDaysInWeek; ++day)
       
   886             {
       
   887             CWeekSlotArrayPtr daySlotTable = iSlotTable[day];
       
   888 
       
   889             const CCalHourItem& itemInfo = *(*daySlotTable)[row];
       
   890             dispData.iHourData[day] = itemInfo.iHourData;
       
   891             }
       
   892 
       
   893         TInt size((sizeof(dispData) / sizeof(TText)));
       
   894         TPtr16 ptr((TUint16 *)&dispData, size, size);
       
   895         iDesArray->AppendL(ptr);
       
   896         }
       
   897 
       
   898     CleanupStack::PopAndDestroy(timeFormat);
       
   899 
       
   900     iListBox->SetStartDay(iStartDay);
       
   901     iListBox->HandleItemAdditionL();
       
   902 
       
   903     static_cast<CCalenWeekLBView*>(iListBox->View())->SetColumn(iColumn);
       
   904     SelectHighlightedCellAndVisibleRangeL();
       
   905 
       
   906     iListBox->View()->SetDisableRedraw(EFalse);
       
   907     DrawDeferred();
       
   908 
       
   909 //Changing RSK to back / exit
       
   910     WeekView().UpdateCbaL();
       
   911     TRACE_EXIT_POINT;
       
   912     }
       
   913 
       
   914 // ----------------------------------------------------------------------------
       
   915 // CCalenWeekContainer::SearchMatchedNoteL
       
   916 // The note contained in within a time is searched.
       
   917 // (other items were commented in a header).
       
   918 // ----------------------------------------------------------------------------
       
   919 //
       
   920 void CCalenWeekContainer::SearchMatchedNoteL(RPointerArray<CCalInstance>& aDayList,// InstanceId array
       
   921                                              TTime aTime) // Search Timezone
       
   922     {
       
   923     TRACE_ENTRY_POINT;
       
   924 
       
   925     TTime aTimeEnd( aTime );
       
   926     aTimeEnd += TTimeIntervalHours( 1 );
       
   927 
       
   928     for( TInt i(0); i < aDayList.Count(); ++i )
       
   929         {
       
   930         CCalInstance* instance = aDayList[i];
       
   931         CCalEntry& entry = instance->Entry();
       
   932 
       
   933         if( IsTimedNoteL( entry ) )
       
   934             {
       
   935             TTime start( instance->Time().TimeLocalL() );
       
   936             TTimeIntervalMinutes duration;
       
   937             entry.EndTimeL().TimeLocalL().MinutesFrom( entry.StartTimeL().TimeLocalL(), duration );
       
   938             TTime end = start +duration;
       
   939 
       
   940             if( (start >= aTime && start < aTimeEnd) ||
       
   941                 (start <= aTime && end > aTime) )
       
   942                 {
       
   943                 CleanupStack::PushL( instance );
       
   944                 iEntryCache.AppendL( instance );
       
   945                 CleanupStack::Pop(); // instance
       
   946                 }
       
   947             }
       
   948         }
       
   949 
       
   950     if( !iEntryCache.Count() )
       
   951         {
       
   952         iEntryCache.Reset();
       
   953         }
       
   954 
       
   955     TRACE_EXIT_POINT;
       
   956     }
       
   957 
       
   958 // ----------------------------------------------------------------------------
       
   959 // CCalenWeekContainer::IsTimedNote
       
   960 // Check specified entry whether Timed Note.
       
   961 // (other items were commented in a header).
       
   962 // ----------------------------------------------------------------------------
       
   963 //
       
   964 TBool CCalenWeekContainer::IsTimedNoteL(CCalEntry& aEntry)
       
   965     {
       
   966     TRACE_ENTRY_POINT;
       
   967 
       
   968     TRACE_EXIT_POINT;
       
   969     return( aEntry.EntryTypeL() == CCalEntry::EAppt );
       
   970     }
       
   971 
       
   972 // ----------------------------------------------------------------------------
       
   973 // CCalenWeekContainer::ResetSlotTable
       
   974 // Reset slot time table.
       
   975 // (other items were commented in a header).
       
   976 // ----------------------------------------------------------------------------
       
   977 //
       
   978 void CCalenWeekContainer::ResetSlotTable()
       
   979     {
       
   980     TRACE_ENTRY_POINT;
       
   981 
       
   982 // loop through days
       
   983     for (TInt dayIx(0); dayIx < KCalenDaysInWeek; ++dayIx)
       
   984         {
       
   985 // current day
       
   986         CWeekSlotArrayPtr daySlotTable = iSlotTable[dayIx];
       
   987 // go thorugh items in a day
       
   988         if (daySlotTable)
       
   989             {
       
   990             for (TInt i=0; i<daySlotTable->Count(); ++i)
       
   991                 {
       
   992                 // free instances on a day
       
   993                 CCalHourItem* itemInfo = (*daySlotTable)[i];
       
   994                 delete itemInfo;
       
   995                 (*daySlotTable)[i]=NULL;
       
   996                 }
       
   997 
       
   998 // delete day
       
   999             delete daySlotTable;
       
  1000             }
       
  1001 
       
  1002         iSlotTable[dayIx] = NULL;
       
  1003         }
       
  1004 
       
  1005     TRACE_EXIT_POINT;
       
  1006     }
       
  1007 
       
  1008 void CCalenWeekContainer::InitSlotTableL()
       
  1009     {
       
  1010     TRACE_ENTRY_POINT;
       
  1011 
       
  1012     ResetSlotTable();
       
  1013     for (TInt dayIx(0); dayIx < KCalenDaysInWeek; ++dayIx)
       
  1014         {
       
  1015         iSlotTable[dayIx] = new(ELeave) CArrayFixFlat<CCalHourItem*>(10);
       
  1016         }
       
  1017 
       
  1018     TRACE_EXIT_POINT;
       
  1019     }
       
  1020 
       
  1021 TInt CCalenWeekContainer::FindFirstItemOfColumn(TInt aColumn)
       
  1022     {
       
  1023     TRACE_ENTRY_POINT;
       
  1024 
       
  1025     CWeekSlotArrayPtr slotTable = iSlotTable[aColumn];
       
  1026     TInt count = slotTable->Count();
       
  1027     for(TInt index = 0; index < count; ++index)
       
  1028         {
       
  1029         const CCalHourItem& itemInfo = *(*slotTable)[index];
       
  1030         if (!(itemInfo.iInstance==NULL))
       
  1031             {
       
  1032             TRACE_EXIT_POINT;
       
  1033             return index;
       
  1034             }
       
  1035         }
       
  1036     TRACE_EXIT_POINT;
       
  1037     return KErrNotFound;
       
  1038     }
       
  1039 
       
  1040 
       
  1041 TInt CCalenWeekContainer::FindItemFromColumnL( const TCalenInstanceId& aId, 
       
  1042                                                                     TInt aColumn)
       
  1043     {
       
  1044     TRACE_ENTRY_POINT;
       
  1045 
       
  1046     CWeekSlotArrayPtr slotTable = iSlotTable[aColumn];
       
  1047     TInt count = slotTable->Count();
       
  1048     CCalEntry::TType type = aId.iType;
       
  1049 
       
  1050     if( type == CCalEntry::ETodo || 
       
  1051         type == CCalEntry::EEvent || 
       
  1052         type == CCalEntry::EReminder ||
       
  1053         type == CCalEntry::EAnniv )
       
  1054         {  // non-timed entry, each entry should occupy 1 cell in the weekview
       
  1055         for(TInt index = 0; index < count; ++index)
       
  1056             {
       
  1057             const CCalHourItem& itemInfo = *(*slotTable)[index];
       
  1058             CCalInstance * itemInstance = itemInfo.iInstance;
       
  1059 
       
  1060             if (itemInstance && (itemInstance->Entry().LocalUidL() == aId.iEntryLocalUid))
       
  1061                 {
       
  1062                 TRACE_EXIT_POINT;
       
  1063                 return index;
       
  1064                 }
       
  1065             }
       
  1066         }
       
  1067     else if( aId.iType == CCalEntry::EAppt )
       
  1068         {  // timed entry, e.g Meeting, should search for it's timed cell
       
  1069         TInt hr = aId.iInstanceTime.DateTime().Hour();
       
  1070         if( hr < KNonTimedNoteDefautDisplayTime )
       
  1071             {
       
  1072             hr = hr;
       
  1073             }
       
  1074         else
       
  1075             {
       
  1076             hr = hr + count - KHoursInADay;
       
  1077             }
       
  1078         TRACE_EXIT_POINT;
       
  1079         return hr;
       
  1080         }
       
  1081         
       
  1082    // unknown entry type
       
  1083     TRACE_EXIT_POINT;
       
  1084     return KErrNotFound;
       
  1085     }
       
  1086 
       
  1087 // ----------------------------------------------------------------------------
       
  1088 // CCalenWeekContainer::FindRowForTime
       
  1089 // Searches specified time
       
  1090 // (other items were commented in a header).
       
  1091 // ----------------------------------------------------------------------------
       
  1092 //
       
  1093 TInt CCalenWeekContainer::FindRowForTime(TTimeIntervalMinutes aTime)
       
  1094     {
       
  1095     TRACE_ENTRY_POINT;
       
  1096 
       
  1097     // We can use first column, as all columns have same amount of non-timed
       
  1098     // rows.
       
  1099     CWeekSlotArrayPtr slotTable = iSlotTable[0];
       
  1100     for(TInt row = 0; row < slotTable->Count(); ++row)
       
  1101         {
       
  1102         const CCalHourItem& item = *(*slotTable)[row];
       
  1103         if (item.iStartTime == aTime)
       
  1104             {
       
  1105             return row;
       
  1106             }
       
  1107         }
       
  1108 
       
  1109     TRACE_EXIT_POINT;
       
  1110     return KErrNotFound;
       
  1111     }
       
  1112 
       
  1113 // ----------------------------------------------------------------------------
       
  1114 // CCalenWeekContainer::SetHighlightAndVisibleRange
       
  1115 // Sets highlight item in ListBox
       
  1116 // (other items were commented in a header).
       
  1117 // ----------------------------------------------------------------------------
       
  1118 //
       
  1119 void CCalenWeekContainer::SetHighlightAndVisibleRange(
       
  1120     TInt aRow,           // Selected item index in ListBox
       
  1121     TInt aColumn,       // Day of the week
       
  1122     TInt aTopRow)         // Top item index in ListBox
       
  1123     {
       
  1124     TRACE_ENTRY_POINT;
       
  1125 
       
  1126     __ASSERT_ALWAYS(aRow != KErrNotFound, User::Invariant());
       
  1127     __ASSERT_ALWAYS(aColumn >= 0, User::Invariant());
       
  1128     __ASSERT_ALWAYS(aColumn < KCalenDaysInWeek, User::Invariant());
       
  1129     // Purpose of the function is to set position of focus and
       
  1130     // set and select topmost visible row.
       
  1131 
       
  1132     // Set highlight
       
  1133     iListBox->SetCurrentItemIndex(aRow);
       
  1134     CCalenWeekLBView* view =
       
  1135         static_cast<CCalenWeekLBView*>( iListBox->View() );
       
  1136     if (aColumn != view->Column())
       
  1137         {
       
  1138         view->SetColumn(aColumn, ETrue);
       
  1139         }
       
  1140 
       
  1141     // Select topmost visible row
       
  1142     if (KErrNotFound == aTopRow)
       
  1143         {
       
  1144         aTopRow = aRow;
       
  1145         }
       
  1146 
       
  1147     // FIXME: Take middle SetTopItemIndex calls away
       
  1148     TInt top(aTopRow < 0 ? aRow - KBeforeActiveTime : aTopRow);
       
  1149     TInt items(view->NumberOfItemsThatFitInRect(view->ViewRect()));
       
  1150     CWeekSlotArrayPtr slotTable = iSlotTable[aColumn];
       
  1151     top = Min(top, slotTable->Count() - items);
       
  1152     top = Max(top, 0);
       
  1153     iListBox->SetTopItemIndex(top);
       
  1154     if (top > aRow)
       
  1155         {
       
  1156         iListBox->SetTopItemIndex(aRow);
       
  1157         }
       
  1158     else if (iListBox->BottomItemIndex() <= aRow)
       
  1159         {
       
  1160         iListBox->SetTopItemIndex(aRow - items + 1);
       
  1161         CWeekSlotArrayPtr firstDaySlotTable = iSlotTable[0];
       
  1162         const CCalHourItem& itemInfo = *(*firstDaySlotTable)[aRow];
       
  1163         if ( (! itemInfo.IsTimed()) && aRow == iListBox->BottomItemIndex())
       
  1164             {
       
  1165             TTimeIntervalMinutes bottomTime =
       
  1166                 KNonTimedNoteDefautDisplayTime * KCalenMinutesInHour;
       
  1167             TInt bottomIndex = FindRowForTime(bottomTime) - (items - 1);
       
  1168             if (bottomIndex > aRow)
       
  1169                 {
       
  1170                 iListBox->SetCurrentItemIndex(bottomIndex);
       
  1171                 }
       
  1172             }
       
  1173         }
       
  1174 
       
  1175     TRACE_EXIT_POINT;
       
  1176     }
       
  1177 
       
  1178 // ----------------------------------------------------------------------------
       
  1179 // CCalenWeekContainer::ClearOneDayEntryCache
       
  1180 // Clear entry of array for cash
       
  1181 // (other items were commented in a header).
       
  1182 // ----------------------------------------------------------------------------
       
  1183 //
       
  1184 void CCalenWeekContainer::ClearOneDayEntryCache()
       
  1185     {
       
  1186     TRACE_ENTRY_POINT;
       
  1187 
       
  1188     iOneDayEntryCache.ResetAndDestroy();
       
  1189 
       
  1190     TRACE_EXIT_POINT;
       
  1191     }
       
  1192 
       
  1193 // ----------------------------------------------------------------------------
       
  1194 // CCalenWeekContainer::TopTime
       
  1195 // Gets time of top item in ListBox
       
  1196 // (other items were commented in a header).
       
  1197 // ----------------------------------------------------------------------------
       
  1198 //
       
  1199 TTimeIntervalMinutes CCalenWeekContainer::TopTime() const
       
  1200     {
       
  1201     TRACE_ENTRY_POINT;
       
  1202 
       
  1203     CWeekSlotArrayPtr slotTable = iSlotTable[0];
       
  1204     TInt index(iListBox->TopItemIndex());
       
  1205     const CCalHourItem& item = *(*slotTable)[index];
       
  1206 
       
  1207     TRACE_EXIT_POINT;
       
  1208     return item.iStartTime;
       
  1209     }
       
  1210 
       
  1211 // ----------------------------------------------------------------------------
       
  1212 // CCalenWeekContainer::UpdateSize
       
  1213 // Do layout changes after calendar settings are
       
  1214 // changed.  No necessary actions for this view.
       
  1215 // ----------------------------------------------------------------------------
       
  1216 //
       
  1217 void CCalenWeekContainer::UpdateSize()
       
  1218     {
       
  1219     TRACE_ENTRY_POINT;
       
  1220 
       
  1221     SizeChanged();
       
  1222 
       
  1223     TRACE_EXIT_POINT;
       
  1224     }
       
  1225 
       
  1226 // ----------------------------------------------------------------------------
       
  1227 // CCalenWeekContainer::ConstructImplL
       
  1228 // Third phase constructor.
       
  1229 // (other items were commented in a header).
       
  1230 // ----------------------------------------------------------------------------
       
  1231 //
       
  1232 void CCalenWeekContainer::ConstructImplL()
       
  1233     {
       
  1234     TRACE_ENTRY_POINT;
       
  1235 
       
  1236     TLocale locale;
       
  1237     // Create preview pane
       
  1238     TRect aRect = PreviewRectL();
       
  1239     iPreview = iServices.CustomPreviewPaneL(aRect);
       
  1240     
       
  1241     // ownership of builder transferred
       
  1242 
       
  1243     // 3) Listbox
       
  1244     iListBox = new (ELeave) CCalenWeekListbox( *this );
       
  1245     // compile error argument is (CCoeControl*, TInt aFlag)
       
  1246     iListBox->ConstructL(this);
       
  1247     iListBox->SetBorder(TGulBorder::ENone);
       
  1248     iListBox->DisableScrolling(ETrue);
       
  1249      // Single click integration
       
  1250     iListBox->DisableSingleClick( ETrue );
       
  1251 
       
  1252 
       
  1253     // 4) Listbox model
       
  1254     iDesArray = new(ELeave) CDesCArrayFlat(5);
       
  1255 
       
  1256     CTextListBoxModel* model = iListBox->Model();
       
  1257     model->SetItemTextArray(iDesArray);
       
  1258     model->SetOwnershipType(ELbmDoesNotOwnItemArray);
       
  1259 
       
  1260     iListBox->HandleItemAdditionL();
       
  1261 
       
  1262 
       
  1263     // 5) Icons
       
  1264     CArrayPtr<CGulIcon>* iconArray = iListBox->ItemDrawer()->FormattedCellData()->IconArray();
       
  1265     if(iconArray)
       
  1266         {
       
  1267         iconArray->ResetAndDestroy();
       
  1268         delete iconArray; // owned by CFormattedCellListBoxData
       
  1269         iconArray = NULL; // to suppress codescanner error
       
  1270         iListBox->ItemDrawer()->FormattedCellData()->SetIconArray(NULL);
       
  1271         }
       
  1272 
       
  1273     CArrayPtr<CGulIcon>* icons = CreateIconsL( iIconIndices );
       
  1274     iListBox->ItemDrawer()->FormattedCellData()->SetIconArray(icons);
       
  1275 
       
  1276     iListBox->SetCursorObserver(this);
       
  1277 
       
  1278     // 6) Scroll bar
       
  1279     iListBox->CreateScrollBarFrameL(ETrue);
       
  1280     iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(
       
  1281         CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
       
  1282 
       
  1283 
       
  1284     // 7) Background skin contexts
       
  1285     PIM_TRAPD_HANDLE( CCalenWeekContainer::ConstructBackgroundContextL() );
       
  1286     
       
  1287     iRow = EFalse;
       
  1288     iTopRowDefault =  EFalse;
       
  1289 
       
  1290     iGestureControl = GestureHelper::CGestureHelper::NewL( *this );
       
  1291     iGestureControl->SetDoubleTapEnabled( EFalse );
       
  1292     iGestureControl->SetHoldingEnabled( EFalse );
       
  1293 
       
  1294     TRACE_EXIT_POINT;
       
  1295     }
       
  1296 
       
  1297 void CCalenWeekContainer::ConstructBackgroundContextL()
       
  1298     {
       
  1299     TRACE_ENTRY_POINT;
       
  1300 
       
  1301     TRect dummy(0,0,0,0);
       
  1302     if( AknLayoutUtils::ScalableLayoutInterfaceAvailable() )
       
  1303         {
       
  1304             iBackgroundSkinContext = CAknsFrameBackgroundControlContext::NewL(
       
  1305                 KAknsIIDQsnFrCale, dummy, dummy, EFalse );
       
  1306             iHeadingBgContext = CAknsFrameBackgroundControlContext::NewL(
       
  1307                 KAknsIIDQsnFrCaleHeading, dummy, dummy, EFalse );
       
  1308             iSideBgContext = CAknsFrameBackgroundControlContext::NewL(
       
  1309                 KAknsIIDQsnFrCaleSide, dummy, dummy, EFalse );
       
  1310         }
       
  1311 
       
  1312     TRACE_EXIT_POINT;
       
  1313     }
       
  1314 
       
  1315 // ----------------------------------------------------------------------------
       
  1316 // CCalenWeekContainer::NotifyChangeDateL
       
  1317 // Date change operation notification handler.
       
  1318 // (other items were commented in a header).
       
  1319 // ----------------------------------------------------------------------------
       
  1320 //
       
  1321 void CCalenWeekContainer::NotifyChangeDateL()
       
  1322     {
       
  1323     TRACE_ENTRY_POINT;
       
  1324 
       
  1325     SetCursorToActiveDayL();
       
  1326 
       
  1327     TRACE_EXIT_POINT;
       
  1328     }
       
  1329 
       
  1330 // ----------------------------------------------------------------------------
       
  1331 // CCalenWeekContainer::SizeChanged
       
  1332 // Resizes child controls
       
  1333 // (other items were commented in a header).
       
  1334 // ----------------------------------------------------------------------------
       
  1335 //
       
  1336 void CCalenWeekContainer::SizeChanged()
       
  1337     {
       
  1338     TRACE_ENTRY_POINT;
       
  1339 
       
  1340     /* LAF doesn't specify week view listbox directly.
       
  1341      * Calculation of listbox rect is done inside listbox.
       
  1342      */  
       
  1343     CCalenContainer::SizeChanged( Rect() );
       
  1344     
       
  1345     TRAP_IGNORE(iLayoutManager->GetLayoutAndExtensionL());
       
  1346 
       
  1347     TRect main_pane = ReducePreview( Rect() );
       
  1348 
       
  1349     TAknLayoutRect main_cale_week_pane;
       
  1350     main_cale_week_pane.LayoutRect( main_pane, AknLayoutScalable_Apps::main_cale_week_pane().LayoutLine() );
       
  1351 
       
  1352     TWeekListBoxLayout layToolBar( UseInfobar(), UseToolbar(), UsePreview(), main_pane );
       
  1353     TInt layoutToolBarVariant = layToolBar.LayoutVariantIndex(TWeekListBoxLayout::EListScrollCaleWeekPane);
       
  1354     // Cached layout value:
       
  1355     i_listscroll_cale_week_pane.LayoutRect( main_cale_week_pane.Rect(),
       
  1356                                             AknLayoutScalable_Apps::listscroll_cale_week_pane(layoutToolBarVariant).LayoutLine() );
       
  1357                                             
       
  1358 
       
  1359     TWeekListBoxLayout lay( UseInfobar(), UseToolbar(), UsePreview(), main_pane ); 
       
  1360 
       
  1361     iListBox->SetRect( iListBox->LayoutRect() );
       
  1362     TInt layoutVariant = lay.LayoutVariantIndex(TWeekListBoxLayout::EScrollPaneCp08);
       
  1363     AknLayoutUtils::LayoutVerticalScrollBar( iListBox->ScrollBarFrame(),
       
  1364                                              i_listscroll_cale_week_pane.Rect(),
       
  1365                                              AknLayoutScalable_Apps::scroll_pane_cp08( layoutVariant ).LayoutLine() );
       
  1366 
       
  1367     if( iBgContext && iHeadingBgContext && iSideBgContext )
       
  1368         {
       
  1369         TAknLayoutRect bg_cale_pane_cp01;
       
  1370         layoutVariant = lay.LayoutVariantIndex(TWeekListBoxLayout::EBgCalePaneCp01);
       
  1371         bg_cale_pane_cp01.LayoutRect( i_listscroll_cale_week_pane.Rect(), AknLayoutScalable_Apps::bg_cale_pane_cp01( layoutVariant ).LayoutLine() );
       
  1372         
       
  1373         TAknLayoutRect cale_bg_pane_center;
       
  1374         cale_bg_pane_center.LayoutRect( bg_cale_pane_cp01.Rect(), AknLayoutScalable_Apps::cale_bg_pane_g1().LayoutLine() );
       
  1375 
       
  1376         iBackgroundSkinContext->SetFrameRects( bg_cale_pane_cp01.Rect(), cale_bg_pane_center.Rect() );
       
  1377 
       
  1378         // Heading pane layout
       
  1379         TAknLayoutRect bg_cale_heading_pane;
       
  1380         layoutVariant = lay.LayoutVariantIndex(TWeekListBoxLayout::EBgCaleHeadingPane);
       
  1381         bg_cale_heading_pane.LayoutRect( i_listscroll_cale_week_pane.Rect(), AknLayoutScalable_Apps::bg_cale_heading_pane( layoutVariant ).LayoutLine() );
       
  1382 
       
  1383         // center
       
  1384         TAknLayoutRect bg_cale_heading_pane_g1;
       
  1385         bg_cale_heading_pane_g1.LayoutRect( bg_cale_heading_pane.Rect(), AknLayoutScalable_Apps::bg_cale_heading_pane_g1().LayoutLine() );
       
  1386 
       
  1387         iHeadingBgContext->SetFrameRects( bg_cale_heading_pane.Rect(), bg_cale_heading_pane_g1.Rect() );
       
  1388 
       
  1389         // Side pane layout
       
  1390         TAknLayoutRect cale_week_time_pane;
       
  1391         layoutVariant = lay.LayoutVariantIndex(TWeekListBoxLayout::ECaleWeekTimePane);
       
  1392         cale_week_time_pane.LayoutRect( i_listscroll_cale_week_pane.Rect(), AknLayoutScalable_Apps::cale_week_time_pane( layoutVariant ).LayoutLine() );
       
  1393 
       
  1394         TAknLayoutRect bg_cale_side_pane;
       
  1395         layoutVariant = lay.LayoutVariantIndex(TWeekListBoxLayout::EBgCaleSidePane);
       
  1396         bg_cale_side_pane.LayoutRect( cale_week_time_pane.Rect(), AknLayoutScalable_Apps::bg_cale_side_pane(layoutVariant).LayoutLine() );
       
  1397 
       
  1398         // center
       
  1399         TAknLayoutRect bg_cale_side_pane_g1;
       
  1400         bg_cale_side_pane_g1.LayoutRect( bg_cale_side_pane.Rect(), AknLayoutScalable_Apps::bg_cale_side_pane_g1().LayoutLine() );
       
  1401 
       
  1402         iSideBgContext->SetFrameRects( bg_cale_side_pane.Rect(), bg_cale_side_pane_g1.Rect() );
       
  1403 
       
  1404         iBackgroundSkinContext->SetParentContext( iBgContext );
       
  1405         iHeadingBgContext->SetParentContext( iBackgroundSkinContext );
       
  1406         iSideBgContext->SetParentContext( iHeadingBgContext );
       
  1407         }
       
  1408 
       
  1409     PIM_TRAPD_HANDLE( UpdateStatusPaneAndExtensionsL() );
       
  1410 
       
  1411     TRACE_EXIT_POINT;
       
  1412     }
       
  1413 
       
  1414 // ----------------------------------------------------------------------------
       
  1415 // CCalenWeekContainer::FocusChanged
       
  1416 // (other items were commented in a header).
       
  1417 // ----------------------------------------------------------------------------
       
  1418 //
       
  1419 void CCalenWeekContainer::FocusChanged( TDrawNow aDrawNow )
       
  1420     {
       
  1421     TRACE_ENTRY_POINT;
       
  1422 
       
  1423     CCalenContainer::FocusChanged( aDrawNow );
       
  1424     if( iListBox )
       
  1425         {
       
  1426         iListBox->SetFocus( IsFocused() );
       
  1427         }
       
  1428 
       
  1429     TRACE_EXIT_POINT;
       
  1430     }
       
  1431 
       
  1432 // ----------------------------------------------------------------------------
       
  1433 // CCalenWeekContainer::HandleResourceChange(TInt aType)
       
  1434 // Called when layout or skin change occurs
       
  1435 // (other items were commented in a header).
       
  1436 // ----------------------------------------------------------------------------
       
  1437 //
       
  1438 void CCalenWeekContainer::HandleResourceChange(TInt aType)
       
  1439     {
       
  1440     TRACE_ENTRY_POINT;
       
  1441 
       
  1442     CCalenContainer::HandleResourceChange( aType );
       
  1443 
       
  1444     if ( aType == KAknsMessageSkinChange || aType == KEikDynamicLayoutVariantSwitch )
       
  1445         {
       
  1446         CArrayPtr<CGulIcon>* iconArray = iListBox->ItemDrawer()->FormattedCellData()->IconArray();
       
  1447         if(iconArray)
       
  1448             {
       
  1449             iconArray->ResetAndDestroy();
       
  1450             delete iconArray; // owned by CFormattedCellListBoxData
       
  1451             iconArray = NULL; // to suppress codescanner error
       
  1452             iListBox->ItemDrawer()->FormattedCellData()->SetIconArray(NULL);
       
  1453             }
       
  1454 
       
  1455         TRAPD(leave, iconArray = CreateIconsL( iIconIndices ) );
       
  1456         if(!leave && iconArray)
       
  1457             {
       
  1458             iListBox->ItemDrawer()->FormattedCellData()->SetIconArray(iconArray);
       
  1459             }
       
  1460 
       
  1461         SizeChanged();
       
  1462 
       
  1463         // if layout change and res.change is allowed do the refresh
       
  1464         if ( aType == KEikDynamicLayoutVariantSwitch )
       
  1465             {
       
  1466             iLayoutManager->HandleResourceChange( aType );
       
  1467             TRAP_IGNORE(iView->BeginRepopulationL());
       
  1468             }
       
  1469         }
       
  1470 
       
  1471     CCoeControl::HandleResourceChange( aType );
       
  1472 
       
  1473     TRACE_EXIT_POINT;
       
  1474     }
       
  1475 
       
  1476 // ----------------------------------------------------------------------------
       
  1477 // CCalenWeekContainer::CountComponentControls
       
  1478 // Return components count
       
  1479 // (other items were commented in a header).
       
  1480 // ----------------------------------------------------------------------------
       
  1481 //
       
  1482 TInt CCalenWeekContainer::CountComponentControls() const
       
  1483     {
       
  1484     TRACE_ENTRY_POINT;
       
  1485     TInt controlCount;
       
  1486 
       
  1487     if ( iLayoutManager->ControlOrNull() )
       
  1488         {
       
  1489         controlCount = 2;
       
  1490         }
       
  1491     else
       
  1492         {
       
  1493         controlCount = 1;
       
  1494         }
       
  1495     TRACE_EXIT_POINT;
       
  1496     return controlCount;        
       
  1497     }
       
  1498 
       
  1499 // ----------------------------------------------------------------------------
       
  1500 // CCalenWeekContainer::ComponentControl
       
  1501 // Retrun the component specified by aIndex
       
  1502 // (other items were commented in a header).
       
  1503 // ----------------------------------------------------------------------------
       
  1504 //
       
  1505 CCoeControl* CCalenWeekContainer::ComponentControl
       
  1506 (TInt aIndex) const
       
  1507     {
       
  1508    TRACE_ENTRY_POINT;
       
  1509 
       
  1510     CCoeControl* control( NULL );
       
  1511 
       
  1512     switch (aIndex)
       
  1513         {
       
  1514         case 0:
       
  1515             control = iListBox;
       
  1516             break;
       
  1517         
       
  1518         case 1:
       
  1519             control = iLayoutManager->ControlOrNull();
       
  1520             break;
       
  1521         
       
  1522         default:
       
  1523             __ASSERT_DEBUG( 0, User::Invariant() );
       
  1524             break;
       
  1525         }
       
  1526         
       
  1527     TRACE_EXIT_POINT;
       
  1528     return control;
       
  1529     }
       
  1530 
       
  1531 // ----------------------------------------------------------------------------
       
  1532 // CCalenWeekContainer::OfferKeyEventL
       
  1533 // processing of a key event
       
  1534 // (other items were commented in a header).
       
  1535 // ----------------------------------------------------------------------------
       
  1536 //
       
  1537 TKeyResponse CCalenWeekContainer::OfferKeyEventL( const TKeyEvent& aKeyEvent,
       
  1538                                                   TEventCode aType )
       
  1539     {
       
  1540     TRACE_ENTRY_POINT;
       
  1541 
       
  1542     // always hide popup on key events
       
  1543     if (iPreview && aType == EEventKeyDown)
       
  1544         {
       
  1545         iPreview->Hide();
       
  1546         }
       
  1547 
       
  1548     // common view key handling.
       
  1549     // NOTE! Common key handling has to be performed before custom handling
       
  1550     // otherwise view-cycling state handling breaks.
       
  1551     if (CCalenContainer::OfferKeyEventL(aKeyEvent, aType) == EKeyWasConsumed)
       
  1552         {
       
  1553         return EKeyWasConsumed;
       
  1554         }
       
  1555 
       
  1556     // month view specific key handling
       
  1557     TKeyResponse exitCode(EKeyWasNotConsumed);
       
  1558     if (aType == EEventKey)
       
  1559         {
       
  1560         switch (aKeyEvent.iCode)
       
  1561             {            	
       
  1562             case EKeyOK:
       
  1563                 iServices.IssueCommandL( ECalenForwardsToDayView );
       
  1564                 exitCode = EKeyWasConsumed;
       
  1565                 break;
       
  1566            case EKeyEnter:    	        		
       
  1567 	            	iView->HandleCommandL(EAknSoftkeyOpen);
       
  1568 	            	exitCode = EKeyWasConsumed;
       
  1569                 break;
       
  1570             default:
       
  1571                 break;
       
  1572             }
       
  1573         }
       
  1574 
       
  1575     // listbox key handling
       
  1576     if ( exitCode == EKeyWasConsumed || !iListBox || !iViewPopulationComplete )
       
  1577         { // if DoDeactivate() is done, iListBox will be NULL.
       
  1578         // do nothing
       
  1579         }
       
  1580     else
       
  1581         {
       
  1582         TInt oldRow(iListBox->View()->CurrentItemIndex());
       
  1583         TInt oldColumn(iColumn);
       
  1584         exitCode = iListBox->OfferKeyEventL(aKeyEvent, aType);
       
  1585 
       
  1586         if (exitCode == EKeyWasConsumed)
       
  1587             {
       
  1588             TInt newRow(iListBox->View()->CurrentItemIndex());
       
  1589             TInt newColumn(iColumn);
       
  1590             if (newRow != oldRow || newColumn != oldColumn)
       
  1591                 {
       
  1592                 iFirstRowTime = TopTime();
       
  1593                 CalcDayFromColumn();
       
  1594                 SetActiveContextFromHighlightL();
       
  1595                 if (newColumn != oldColumn)
       
  1596                     {
       
  1597                     UpdateStatusPaneAndExtensionsL();
       
  1598                     }
       
  1599                 }
       
  1600             }
       
  1601         }
       
  1602 
       
  1603     TRACE_EXIT_POINT;
       
  1604     return exitCode;
       
  1605     }
       
  1606 
       
  1607 // ----------------------------------------------------------------------------
       
  1608 // CCalenWeekContainer::GetHelpContext
       
  1609 // Gets help context
       
  1610 // (other items were commented in a header).
       
  1611 // ----------------------------------------------------------------------------
       
  1612 //
       
  1613 void CCalenWeekContainer::GetHelpContext( TCoeHelpContext& aContext ) const
       
  1614     {
       
  1615     TRACE_ENTRY_POINT;
       
  1616 
       
  1617     aContext.iMajor = KUidCalendar;
       
  1618     // This is specified in HRH file.
       
  1619     aContext.iContext = KCALE_HLP_WEEK_VIEW;
       
  1620 
       
  1621     TRACE_EXIT_POINT;
       
  1622     }
       
  1623 
       
  1624 // ----------------------------------------------------------------------------
       
  1625 // ?classname::?member_function
       
  1626 // ?implementation_description
       
  1627 // (other items were commented in a header).
       
  1628 // ----------------------------------------------------------------------------
       
  1629 //
       
  1630 TKeyResponse CCalenWeekContainer::CursorMovedL(MCalenWeekCursorObserver::TCursorMove aDir)
       
  1631     {
       
  1632     TRACE_ENTRY_POINT;
       
  1633 
       
  1634     TKeyResponse consumed(EKeyWasNotConsumed);
       
  1635     if (aDir == MCalenWeekCursorObserver::ECalenLeft)
       
  1636         {
       
  1637         consumed = HorizontalMoveL(-1);
       
  1638         }
       
  1639     else if (aDir == MCalenWeekCursorObserver::ECalenRight)
       
  1640         {
       
  1641         consumed = HorizontalMoveL(+1);
       
  1642         }
       
  1643     else
       
  1644         {
       
  1645         // up or down
       
  1646         iSelectedRowNumber = iListBox->View()->CurrentItemIndex();
       
  1647         }
       
  1648 
       
  1649     TRACE_EXIT_POINT;
       
  1650     return consumed;
       
  1651     }
       
  1652 
       
  1653 // ----------------------------------------------------------------------------
       
  1654 // ?classname::?member_function
       
  1655 // ?implementation_description
       
  1656 // (other items were commented in a header).
       
  1657 // ----------------------------------------------------------------------------
       
  1658 //
       
  1659 TKeyResponse CCalenWeekContainer::HorizontalMoveL(TInt aDir)
       
  1660     {
       
  1661     TRACE_ENTRY_POINT;
       
  1662 
       
  1663     CCalenWeekLBView* view =
       
  1664         static_cast<CCalenWeekLBView*>( iListBox->View() );
       
  1665 
       
  1666     TTime newDay = iTime + TTimeIntervalDays( aDir );
       
  1667 
       
  1668     if (CalenDateUtils::IsValidDay(newDay))
       
  1669         {
       
  1670         TInt newColumn = iColumn + aDir;
       
  1671         if (newColumn < 0 || KCalenDaysInWeek <= newColumn) // went over left or right border
       
  1672             {
       
  1673             if( newColumn < 0 )
       
  1674                 {
       
  1675                 iColumn = KCalenDaysInWeek - 1;
       
  1676                 }
       
  1677             else
       
  1678                 {
       
  1679                 iColumn = 0;
       
  1680                 }
       
  1681 
       
  1682             view->SetColumn(iColumn);
       
  1683             iTime = newDay;
       
  1684             iStartDay = iTime - TTimeIntervalDays( iColumn );
       
  1685             iSelectedRowNumber = KErrNotFound; // Recalculate when repopulation occurs
       
  1686 
       
  1687             // Refresh listbox
       
  1688             iView->BeginRepopulationL();
       
  1689             iListBox->View()->SetDisableRedraw(ETrue);
       
  1690 
       
  1691             TRACE_EXIT_POINT;
       
  1692             return EKeyWasConsumed;
       
  1693             }
       
  1694         else if ( iViewPopulationComplete )
       
  1695             {
       
  1696             // Actual processing is performed by the List box side.
       
  1697             iColumn += aDir;
       
  1698 
       
  1699             TRACE_EXIT_POINT;
       
  1700             return EKeyWasNotConsumed;
       
  1701             }
       
  1702         else
       
  1703             {
       
  1704             TRACE_EXIT_POINT;
       
  1705             return EKeyWasNotConsumed;
       
  1706             }
       
  1707         }
       
  1708     else
       
  1709         {
       
  1710         view->SetColumn(iColumn);
       
  1711         CalenViewUtils::ShowDateOutOfRangeErrorNoteL();
       
  1712 
       
  1713         TRACE_EXIT_POINT;
       
  1714         return EKeyWasConsumed;
       
  1715         }
       
  1716     }
       
  1717 
       
  1718 // ----------------------------------------------------------------------------
       
  1719 // CCalenWeekContainer::MopSupplyObject()
       
  1720 // Pass skin information if needed.
       
  1721 // ----------------------------------------------------------------------------
       
  1722 //
       
  1723 TTypeUid::Ptr CCalenWeekContainer::MopSupplyObject(TTypeUid aId)
       
  1724     {
       
  1725     TRACE_ENTRY_POINT;
       
  1726 
       
  1727     if( aId.iUid == MAknsControlContext::ETypeId )
       
  1728         {
       
  1729         MAknsControlContext* cc = iSideBgContext;
       
  1730 
       
  1731         if( !cc )
       
  1732             {
       
  1733             cc = iBgContext;
       
  1734             }
       
  1735         if ( cc )
       
  1736             {
       
  1737             TRACE_EXIT_POINT;
       
  1738             return MAknsControlContext::SupplyMopObject( aId, cc );
       
  1739             }
       
  1740         }
       
  1741 
       
  1742     TRACE_EXIT_POINT;
       
  1743     return CCoeControl::MopSupplyObject( aId );
       
  1744     }
       
  1745 
       
  1746 // ----------------------------------------------------------------------------
       
  1747 // ?classname::?member_function
       
  1748 // ?implementation_description
       
  1749 // (other items were commented in a header).
       
  1750 // ----------------------------------------------------------------------------
       
  1751 //
       
  1752 void CCalenWeekContainer::FocusChangeForPopupL()
       
  1753     {
       
  1754     TRACE_ENTRY_POINT;
       
  1755 
       
  1756     if( iViewPopulationComplete )
       
  1757         {
       
  1758         CalcDayFromColumn();
       
  1759         
       
  1760         CWeekSlotArrayPtr slotTable = iSlotTable[iColumn];
       
  1761         CCalHourItem& itemInfo = *(*slotTable)[iListBox->CurrentItemIndex()];
       
  1762         
       
  1763         // dont focus the preview popup/previewpane if any dialog or faster app is active        
       
  1764 		if(iPreview && !iView->IsEditorActiveOrFasterAppExit())
       
  1765 			{
       
  1766 	        if( !itemInfo.IsTimed() )
       
  1767 	            { 
       
  1768 	            // Non-timed cell
       
  1769 	            iPreview->FocusChangedL(itemInfo.iInstance);
       
  1770 	            }
       
  1771 	        else
       
  1772 	            {
       
  1773 	            TDateTime dt = iTime.DateTime();    // TACOTEMP
       
  1774 	            iPreview->FocusChangedL( iServices.Context().FocusDateAndTimeL().TimeLocalL() );
       
  1775 	            }
       
  1776 			}
       
  1777         }
       
  1778     else
       
  1779         {
       
  1780         HidePopup();
       
  1781         }
       
  1782 
       
  1783     TRACE_EXIT_POINT;
       
  1784     }
       
  1785 
       
  1786 // ----------------------------------------------------------------------------
       
  1787 // CCalenWeekContainer::Draw
       
  1788 // Draws most of the main pane dependend parts of week view
       
  1789 // - skinned or normal background
       
  1790 // - Day names
       
  1791 // - grid lines
       
  1792 // - line between day names and grid
       
  1793 // - line between hours and grid (which is drawn also inside
       
  1794 //                list, to make scrolling work)
       
  1795 // (other items were commented in a header).
       
  1796 // ----------------------------------------------------------------------------
       
  1797 //
       
  1798 void CCalenWeekContainer::Draw(const TRect& /*aRect*/) const
       
  1799     {
       
  1800     TRACE_ENTRY_POINT;
       
  1801 
       
  1802     CWindowGc& gc = SystemGc();
       
  1803 
       
  1804     DrawBackground(gc);
       
  1805     TRAPD(error,DrawDayNamesL(gc));
       
  1806     if(error!=KErrNone)
       
  1807         {
       
  1808         // to avoid warning
       
  1809         }
       
  1810     DrawGridLines(gc);
       
  1811 
       
  1812     TRACE_EXIT_POINT;
       
  1813     }
       
  1814 
       
  1815 // ----------------------------------------------------------------------------
       
  1816 // CCalenWeekListbox::DrawDayNames
       
  1817 // Draw day names
       
  1818 // (other items were commented in a header).
       
  1819 // ----------------------------------------------------------------------------
       
  1820 //
       
  1821 void CCalenWeekContainer::DrawDayNamesL(CWindowGc& aGc) const      // Window graphic context
       
  1822     {
       
  1823     TRACE_ENTRY_POINT;
       
  1824 
       
  1825     // No need to clear background in this function, because this is
       
  1826     // called only from Draw.
       
  1827     // If popup needs to call this from DrawDayNamesNow, clearing
       
  1828     // should be done there.
       
  1829     TRect mainPane = ReducePreview( Rect() );
       
  1830     TWeekListBoxLayout lay( UseInfobar(), UseToolbar(), UsePreview(), mainPane );
       
  1831     TInt layoutVariant = lay.LayoutVariantIndex(TWeekListBoxLayout::ECaleWeekDayHeadingPane);
       
  1832     TAknLayoutRect cale_week_day_heading_pane;
       
  1833     cale_week_day_heading_pane.LayoutRect( i_listscroll_cale_week_pane.Rect(),
       
  1834                                            AknLayoutScalable_Apps::cale_week_day_heading_pane( layoutVariant ).LayoutLine() );
       
  1835 
       
  1836     TRect dayHeadingRect = cale_week_day_heading_pane.Rect();
       
  1837     TAknLayoutText dayHeadingLayouts[ KCalenDaysInWeek ];
       
  1838     layoutVariant = lay.LayoutVariantIndex(TWeekListBoxLayout::ECaleWeekDayHeadingPaneT1);
       
  1839     dayHeadingLayouts[0].LayoutText( dayHeadingRect, AknLayoutScalable_Apps::cale_week_day_heading_pane_t1(layoutVariant).LayoutLine() );
       
  1840     dayHeadingLayouts[1].LayoutText( dayHeadingRect, AknLayoutScalable_Apps::cale_week_day_heading_pane_t2(layoutVariant).LayoutLine() );
       
  1841     dayHeadingLayouts[2].LayoutText( dayHeadingRect, AknLayoutScalable_Apps::cale_week_day_heading_pane_t3(layoutVariant).LayoutLine() );
       
  1842     dayHeadingLayouts[3].LayoutText( dayHeadingRect, AknLayoutScalable_Apps::cale_week_day_heading_pane_t4(layoutVariant).LayoutLine() );
       
  1843     dayHeadingLayouts[4].LayoutText( dayHeadingRect, AknLayoutScalable_Apps::cale_week_day_heading_pane_t5(layoutVariant).LayoutLine() );
       
  1844     dayHeadingLayouts[5].LayoutText( dayHeadingRect, AknLayoutScalable_Apps::cale_week_day_heading_pane_t6(layoutVariant).LayoutLine() );
       
  1845     dayHeadingLayouts[6].LayoutText( dayHeadingRect, AknLayoutScalable_Apps::cale_week_day_heading_pane_t7(layoutVariant).LayoutLine() );
       
  1846 
       
  1847     // Get drawing color
       
  1848     TRgb textColor = dayHeadingLayouts[0].Color();
       
  1849     AknsUtils::GetCachedColor(AknsUtils::SkinInstance(), textColor,
       
  1850                               KAknsIIDQsnTextColors,
       
  1851                               EAknsCIQsnTextColorsCG23);
       
  1852 
       
  1853     TTime date( iStartDay );
       
  1854     TLocale locale;
       
  1855 
       
  1856     for (TInt i=0; i < KCalenDaysInWeek; ++i)
       
  1857         {
       
  1858         TBool isToday = CalenDateUtils::OnSameDay( CalenDateUtils::Today(), date );
       
  1859         aGc.SetUnderlineStyle( isToday ? EUnderlineOn : EUnderlineOff );
       
  1860         TInt dayNoInWeek( i + locale.StartOfWeek() );
       
  1861         if( dayNoInWeek >= KCalenDaysInWeek )
       
  1862             {
       
  1863             dayNoInWeek -= KCalenDaysInWeek;
       
  1864             }
       
  1865         dayHeadingLayouts[ i ].DrawText( aGc,
       
  1866                                          WeekView().AbbreviatedDayArrayL()[dayNoInWeek],
       
  1867                                          ETrue,
       
  1868                                          textColor);
       
  1869         date += TTimeIntervalDays( 1 );
       
  1870         }
       
  1871 
       
  1872     TRACE_EXIT_POINT;
       
  1873     }
       
  1874 
       
  1875 CCalenWeekView& CCalenWeekContainer::WeekView() const
       
  1876     {
       
  1877     TRACE_ENTRY_POINT;
       
  1878 
       
  1879     TRACE_EXIT_POINT;
       
  1880     return *(static_cast<CCalenWeekView*>(iView));
       
  1881     }
       
  1882 
       
  1883 // ---------------- class CCHourItem ------------------------ //
       
  1884 
       
  1885 // ----------------------------------------------------------------------------
       
  1886 // ?classname::?member_function
       
  1887 // ?implementation_description
       
  1888 // (other items were commented in a header).
       
  1889 // ----------------------------------------------------------------------------
       
  1890 //
       
  1891 CCalHourItem::CCalHourItem()
       
  1892     {
       
  1893     TRACE_ENTRY_POINT;
       
  1894 
       
  1895     iStartTime = TTimeIntervalMinutes( KNullMinutes );
       
  1896     iInstance = NULL;
       
  1897     iTimedNote = EFalse;
       
  1898 
       
  1899     TRACE_EXIT_POINT;
       
  1900     }
       
  1901 
       
  1902 // ----------------------------------------------------------------------------
       
  1903 // ?classname::?member_function
       
  1904 // ?implementation_description
       
  1905 // (other items were commented in a header).
       
  1906 // ----------------------------------------------------------------------------
       
  1907 //
       
  1908 CCalHourItem::~CCalHourItem()
       
  1909     {
       
  1910     TRACE_ENTRY_POINT;
       
  1911 
       
  1912 // not owned
       
  1913 //    delete iInstance;
       
  1914     iInstance = NULL;
       
  1915 
       
  1916     TRACE_EXIT_POINT;
       
  1917     }
       
  1918 
       
  1919 // ----------------------------------------------------------------------------
       
  1920 // ?classname::?member_function
       
  1921 // ?implementation_description
       
  1922 // (other items were commented in a header).
       
  1923 // ----------------------------------------------------------------------------
       
  1924 //
       
  1925 void CCalHourItem::ConstructL()
       
  1926     {
       
  1927     TRACE_ENTRY_POINT;
       
  1928     TRACE_EXIT_POINT;
       
  1929     }
       
  1930 
       
  1931 // ----------------------------------------------------------------------------
       
  1932 // ?classname::?member_function
       
  1933 // ?implementation_description
       
  1934 // (other items were commented in a header).
       
  1935 // ----------------------------------------------------------------------------
       
  1936 //
       
  1937 void CCalHourItem::ConstructL(CCalInstance& aInstance)
       
  1938     {
       
  1939     TRACE_ENTRY_POINT;
       
  1940 
       
  1941     iInstance = &aInstance;
       
  1942 
       
  1943     TRACE_EXIT_POINT;
       
  1944     }
       
  1945 
       
  1946 // ----------------------------------------------------------------------------
       
  1947 // ?classname::?member_function
       
  1948 // ?implementation_description
       
  1949 // (other items were commented in a header).
       
  1950 // ----------------------------------------------------------------------------
       
  1951 //
       
  1952 CCalHourItem* CCalHourItem::NewL()
       
  1953     {
       
  1954     TRACE_ENTRY_POINT;
       
  1955 
       
  1956     CCalHourItem* self=new (ELeave) CCalHourItem();
       
  1957     CleanupStack::PushL(self);
       
  1958     self->ConstructL();
       
  1959     CleanupStack::Pop( self );
       
  1960 
       
  1961     TRACE_EXIT_POINT;
       
  1962     return self;
       
  1963     }
       
  1964 
       
  1965 // ----------------------------------------------------------------------------
       
  1966 // ?classname::?member_function
       
  1967 // ?implementation_description
       
  1968 // (other items were commented in a header).
       
  1969 // ----------------------------------------------------------------------------
       
  1970 //
       
  1971 CCalHourItem* CCalHourItem::NewL(CCalInstance& aInstance)
       
  1972     {
       
  1973     TRACE_ENTRY_POINT;
       
  1974 
       
  1975     CCalHourItem* self=new (ELeave) CCalHourItem();
       
  1976     CleanupStack::PushL(self);
       
  1977     self->ConstructL(aInstance);
       
  1978     CleanupStack::Pop(self);
       
  1979 
       
  1980     TRACE_EXIT_POINT;
       
  1981     return self;
       
  1982     }
       
  1983 
       
  1984 // ----------------------------------------------------------------------------
       
  1985 // ?classname::?member_function
       
  1986 // ?implementation_description
       
  1987 // (other items were commented in a header).
       
  1988 // ----------------------------------------------------------------------------
       
  1989 //
       
  1990 void CCalHourItem::SetDataL( CCalInstance& aInstance,
       
  1991                              TTimeIntervalMinutes aStartTime,
       
  1992                              TBool aTimedNote,
       
  1993                              TCalenWeekHour aHourData )
       
  1994     {
       
  1995     TRACE_ENTRY_POINT;
       
  1996 
       
  1997     ConstructL( aInstance );
       
  1998     iStartTime = aStartTime;
       
  1999     iTimedNote = aTimedNote;
       
  2000     iHourData = aHourData;
       
  2001 
       
  2002     TRACE_EXIT_POINT;
       
  2003     }
       
  2004 
       
  2005 
       
  2006 TBool CCalHourItem::HasInstance() const
       
  2007     {
       
  2008     TRACE_ENTRY_POINT;
       
  2009 
       
  2010     TRACE_EXIT_POINT;
       
  2011     return iInstance != NULL;
       
  2012     }
       
  2013 
       
  2014 
       
  2015 TBool CCalHourItem::IsTimed() const
       
  2016     {
       
  2017     TRACE_ENTRY_POINT;
       
  2018 
       
  2019     TRACE_EXIT_POINT;
       
  2020     return iTimedNote;
       
  2021     }
       
  2022 
       
  2023 // ----------------------------------------------------------------------------
       
  2024 // CCalenMonthContainer::HandleGestureL
       
  2025 // 
       
  2026 // ----------------------------------------------------------------------------
       
  2027 void CCalenWeekContainer::HandleGestureL( const GestureHelper::MGestureEvent& aEvent )
       
  2028     {
       
  2029     GestureHelper::TGestureCode code = aEvent.Code( GestureHelper::MGestureEvent::EAxisBoth ); 
       
  2030     
       
  2031     switch ( code )
       
  2032         {
       
  2033         case GestureHelper::EGestureStart:
       
  2034             {
       
  2035             iGestureHandled = EFalse;
       
  2036             break;
       
  2037             }
       
  2038         case GestureHelper::EGestureSwipeRight:
       
  2039             {
       
  2040             HandleNaviDecoratorEventL( EAknNaviDecoratorEventLeftTabArrow );
       
  2041             }
       
  2042             iGestureHandled = ETrue;
       
  2043             break;
       
  2044             
       
  2045         case GestureHelper::EGestureSwipeLeft:
       
  2046             {
       
  2047             HandleNaviDecoratorEventL( EAknNaviDecoratorEventRightTabArrow );
       
  2048             }
       
  2049             iGestureHandled = ETrue;
       
  2050             break;
       
  2051          default:
       
  2052             // Other gestures are not handled here
       
  2053             break;
       
  2054         }
       
  2055     }
       
  2056 
       
  2057 // ----------------------------------------------------------------------------
       
  2058 // CCalenWeekContainer::HorizontalWeekMoveL
       
  2059 // processing of a week move (from touch ui navi decoration)
       
  2060 // (other items were commented in a header).
       
  2061 // ----------------------------------------------------------------------------
       
  2062 //
       
  2063 void CCalenWeekContainer::HorizontalWeekMoveL(TInt aDir)
       
  2064     {
       
  2065     TRACE_ENTRY_POINT;
       
  2066 
       
  2067     if(AknLayoutUtils::PenEnabled())
       
  2068         {
       
  2069         __ASSERT_ALWAYS( (aDir == 1 || aDir == -1), User::Invariant());
       
  2070         CCalenWeekLBView* view =
       
  2071             static_cast<CCalenWeekLBView*>( iListBox->View() );
       
  2072 
       
  2073         TTime newDay = iTime + TTimeIntervalDays( aDir*KCalenDaysInWeek );
       
  2074 
       
  2075         if ( CalenDateUtils::IsValidDay( newDay ) )
       
  2076             {
       
  2077             iTime = newDay;
       
  2078             iStartDay = iTime - TTimeIntervalDays(iColumn);
       
  2079             // Refresh listbox
       
  2080             iListBox->View()->SetDisableRedraw(ETrue);
       
  2081             }
       
  2082         else
       
  2083             {
       
  2084             view->SetColumn(iColumn);
       
  2085             CalenViewUtils::ShowDateOutOfRangeErrorNoteL();
       
  2086             }
       
  2087         }
       
  2088 
       
  2089     TRACE_EXIT_POINT;
       
  2090     }
       
  2091 
       
  2092 // ----------------------------------------------------------------------------
       
  2093 // CCalenWeekContainer::HandleNaviDecorationPointerEventL
       
  2094 // processing of a navi decoration event
       
  2095 // (other items were commented in a header).
       
  2096 // ----------------------------------------------------------------------------
       
  2097 //
       
  2098 void CCalenWeekContainer::HandleNaviDecoratorEventL(TInt aEventID)
       
  2099     {
       
  2100     TRACE_ENTRY_POINT;
       
  2101 
       
  2102     if(AknLayoutUtils::PenEnabled())
       
  2103         {
       
  2104         TInt direction(0);
       
  2105         if(aEventID == EAknNaviDecoratorEventLeftTabArrow)
       
  2106             {
       
  2107             if(AknLayoutUtils::LayoutMirrored())
       
  2108                 {
       
  2109                 direction = 1;
       
  2110                 }
       
  2111             else
       
  2112                 {
       
  2113                 direction = -1;
       
  2114                 }
       
  2115             }            
       
  2116         else if(aEventID == EAknNaviDecoratorEventRightTabArrow)
       
  2117             { 
       
  2118             if(AknLayoutUtils::LayoutMirrored())
       
  2119                 {
       
  2120                 direction = -1;
       
  2121                 }
       
  2122             else
       
  2123                 {
       
  2124                 direction = 1;
       
  2125                 }
       
  2126             }
       
  2127         else
       
  2128             return;
       
  2129         
       
  2130         HorizontalWeekMoveL(direction);
       
  2131         SetActiveContextFromHighlightL(EFalse);
       
  2132         WeekView().SetStatusPaneFromActiveContextL();
       
  2133         iView->BeginRepopulationL();
       
  2134         }
       
  2135 
       
  2136     TRACE_EXIT_POINT;
       
  2137     }
       
  2138 
       
  2139 // ----------------------------------------------------------------------------
       
  2140 // CCalenWeekContainer::PointerMovedL
       
  2141 // processing of a move to new column (from touch ui)
       
  2142 // (other items were commented in a header).
       
  2143 // ----------------------------------------------------------------------------
       
  2144 //
       
  2145 void CCalenWeekContainer::PointerMovedL(TInt aNewColumn)
       
  2146     {
       
  2147     TRACE_ENTRY_POINT;
       
  2148 
       
  2149     if(AknLayoutUtils::PenEnabled())
       
  2150         {
       
  2151         CCalenWeekLBView* view =
       
  2152             static_cast<CCalenWeekLBView*>( iListBox->View() );
       
  2153                TInt indexDiff = aNewColumn-iColumn;
       
  2154                TTime newDay = iTime + TTimeIntervalDays(indexDiff);
       
  2155                if (!CalenDateUtils::IsValidDay(newDay)) 
       
  2156                     {    
       
  2157                     iValidDay=ETrue;
       
  2158                     view->SetColumn(iColumn);                                              
       
  2159                     CalenViewUtils::ShowDateOutOfRangeErrorNoteL();                   
       
  2160                     return ;                                           
       
  2161                     }
       
  2162                 else
       
  2163                     {   
       
  2164                     iValidDay=EFalse;
       
  2165                     view->PointerMoveToItemL(aNewColumn);
       
  2166                     iColumn = aNewColumn;
       
  2167                     }
       
  2168         }
       
  2169 
       
  2170     TRACE_EXIT_POINT;
       
  2171     }
       
  2172 
       
  2173 // ----------------------------------------------------------------------------
       
  2174 // CCalenMonthContainer::HandleLongTapEventL
       
  2175 // processing of a long tap event
       
  2176 // (other items were commented in a header).
       
  2177 // ----------------------------------------------------------------------------
       
  2178 //
       
  2179 void CCalenWeekContainer::HandleLongTapEventL( const TPoint& /*aPenEventLocation*/,
       
  2180                                                const TPoint& /*aPenEventScreenLocation*/ )
       
  2181     {
       
  2182     TRACE_ENTRY_POINT;
       
  2183 
       
  2184 
       
  2185     TRACE_EXIT_POINT;
       
  2186     }
       
  2187 
       
  2188 // ----------------------------------------------------------------------------
       
  2189 // CCalenWeekContainer::HandlePointerEventL
       
  2190 // processing of a navi decoration event
       
  2191 // (other items were commented in a header).
       
  2192 // ----------------------------------------------------------------------------
       
  2193 //
       
  2194 void CCalenWeekContainer::HandlePointerEventL(const TPointerEvent& aPointerEvent)
       
  2195     {
       
  2196     TRACE_ENTRY_POINT;
       
  2197 
       
  2198     if(AknLayoutUtils::PenEnabled())
       
  2199         {
       
  2200         if(iView->IsEventViewLaunchedFromAlarm())
       
  2201             {
       
  2202             return;
       
  2203             }
       
  2204         TInt pointerIndex(-1);
       
  2205         TInt oldRow(0);
       
  2206         TInt oldColumn(0);
       
  2207         TInt newRow(0);
       
  2208         TInt newColumn(0);
       
  2209         
       
  2210         TBool isItem (iListBox->View()->XYPosToItemIndex(aPointerEvent.iPosition,
       
  2211                                                          pointerIndex));
       
  2212 
       
  2213         if( !iListBox->IsValidPointer(aPointerEvent.iPosition) &&
       
  2214             aPointerEvent.iType == TPointerEvent::EButton1Down )
       
  2215             {
       
  2216             IgnoreEventsUntilNextPointerUp();
       
  2217             CCoeControl* control(NULL);
       
  2218             if (aPointerEvent.iType == TPointerEvent::EButton1Down)
       
  2219                 {
       
  2220                 control = iLayoutManager->ControlOrNull();
       
  2221                 if (control)
       
  2222                     {
       
  2223                     if (control->Rect().Contains(aPointerEvent.iPosition))
       
  2224                         {
       
  2225                         control->HandlePointerEventL(aPointerEvent);
       
  2226                         }
       
  2227                     }
       
  2228                 }
       
  2229             return;
       
  2230             }
       
  2231         
       
  2232         if ( iGestureControl )
       
  2233             {
       
  2234             iGestureControl->HandlePointerEventL( aPointerEvent );
       
  2235             if ( iGestureHandled )
       
  2236                 {
       
  2237                 TRACE_EXIT_POINT;
       
  2238                 return;
       
  2239                 }
       
  2240             }
       
  2241         
       
  2242         switch(aPointerEvent.iType)
       
  2243             {
       
  2244             case TPointerEvent::EButton1Down:
       
  2245                 {
       
  2246                 this->GenerateTactileFeedback(); //Tactile feedback.
       
  2247                 if(isItem)
       
  2248                     {
       
  2249                     oldRow = iListBox->View()->CurrentItemIndex();
       
  2250                     oldColumn = iColumn;
       
  2251                     iListBox->HandlePointerEventL(aPointerEvent);
       
  2252                     newRow = iListBox->View()->CurrentItemIndex();
       
  2253                     newColumn = iColumn;
       
  2254                     if (newRow != oldRow || newColumn != oldColumn)
       
  2255                         {
       
  2256                         CalcDayFromColumn();
       
  2257                         SetActiveContextFromHighlightL();
       
  2258                         if (newColumn != oldColumn)
       
  2259                             {
       
  2260                             UpdateStatusPaneAndExtensionsL();
       
  2261                             }
       
  2262                         }
       
  2263                     }
       
  2264                 else
       
  2265                     {
       
  2266                     IgnoreEventsUntilNextPointerUp();
       
  2267                     }
       
  2268                 break;
       
  2269                 }
       
  2270             case TPointerEvent::EButtonRepeat:
       
  2271                 {
       
  2272                 if(isItem)
       
  2273                     break;
       
  2274                 } // else this is drag event
       
  2275             case TPointerEvent::EDrag:
       
  2276                 {
       
  2277                 // for themable support - clear Pressed Down State when dragging
       
  2278                 oldRow = iListBox->View()->CurrentItemIndex();
       
  2279                 oldColumn = iColumn;
       
  2280                 newColumn = iListBox->PointerEventColumn(aPointerEvent.iPosition);
       
  2281                 newRow = pointerIndex;
       
  2282                 if (newRow != oldRow || newColumn != oldColumn)
       
  2283                     {
       
  2284                     iHourChange = ETrue;
       
  2285                     }
       
  2286                 break;
       
  2287                 }
       
  2288             case TPointerEvent::EButton1Up:
       
  2289                 if(isItem &&
       
  2290                    iView->MenuBar()->IsDisplayed() == EFalse && !iHourChange)
       
  2291                     {
       
  2292                     iServices.IssueCommandL( ECalenForwardsToDayView );
       
  2293                     }
       
  2294                 iHourChange = EFalse;
       
  2295                 break;
       
  2296             default:
       
  2297                 break;
       
  2298             }
       
  2299         }
       
  2300 
       
  2301 
       
  2302     TRACE_EXIT_POINT;
       
  2303     }
       
  2304 
       
  2305 
       
  2306 
       
  2307 // ----------------------------------------------------------------------------
       
  2308 // CCalenWeekContainer::HidePopup
       
  2309 // Hides the popup window
       
  2310 // (other items were commented in a header).
       
  2311 // ----------------------------------------------------------------------------
       
  2312 //
       
  2313 void CCalenWeekContainer::HidePopup()
       
  2314     {
       
  2315     TRACE_ENTRY_POINT;
       
  2316     if (iPreview)
       
  2317         {
       
  2318         iPreview->Hide();
       
  2319         }
       
  2320     TRACE_EXIT_POINT;
       
  2321     }
       
  2322 
       
  2323 // ----------------------------------------------------------------------------
       
  2324 // CCalenWeekContainer::BeginPopulationWithInstanceViewL
       
  2325 // Beings populating the view. First stage of view population.
       
  2326 // (other items were commented in a header).
       
  2327 // ----------------------------------------------------------------------------
       
  2328 //
       
  2329 void CCalenWeekContainer::BeginPopulationWithInstanceViewL()
       
  2330     {
       
  2331     TRACE_ENTRY_POINT;
       
  2332     SizeChanged();
       
  2333     iViewPopulationComplete = EFalse;
       
  2334     
       
  2335     if (iPreview)
       
  2336         {
       
  2337         iPreview->Hide();
       
  2338         }
       
  2339     iListBox->View()->SetDisableRedraw( ETrue );
       
  2340     PopulatesDayListsL();
       
  2341 
       
  2342     TRACE_EXIT_POINT;
       
  2343     }
       
  2344 
       
  2345 // ----------------------------------------------------------------------------
       
  2346 // CCalenWeekContainer::FirstPopulateOfSlotTableL
       
  2347 // Prepares and puts non timed notes into the slot table.
       
  2348 // Second stage of view population.
       
  2349 // (other items were commented in a header).
       
  2350 // ----------------------------------------------------------------------------
       
  2351 //
       
  2352 void CCalenWeekContainer::FirstPopulateOfSlotTableL()
       
  2353     {
       
  2354     TRACE_ENTRY_POINT;
       
  2355 
       
  2356     InitSlotTableL();
       
  2357     InsertNonTimedNotesToSlotTableL();
       
  2358 
       
  2359     TRACE_EXIT_POINT;
       
  2360     }
       
  2361 
       
  2362 // ----------------------------------------------------------------------------
       
  2363 // CCalenWeekContainer::SecondPopulateOfSlotTableL
       
  2364 // Puts timed notes into the slot table. Third stage of view population.
       
  2365 // (other items were commented in a header).
       
  2366 // ----------------------------------------------------------------------------
       
  2367 //
       
  2368 void CCalenWeekContainer::SecondPopulateOfSlotTableL()
       
  2369     {
       
  2370     TRACE_ENTRY_POINT;
       
  2371 
       
  2372     InsertTimedNotesToSlotTableL();
       
  2373 
       
  2374     TRACE_EXIT_POINT;
       
  2375     }
       
  2376 
       
  2377 // ----------------------------------------------------------------------------
       
  2378 // CCalenWeekContainer::CompletePopulationL
       
  2379 // Completes population. Fourth and final stage of view population.
       
  2380 // (other items were commented in a header).
       
  2381 // ----------------------------------------------------------------------------
       
  2382 //
       
  2383 void CCalenWeekContainer::CompletePopulationL()
       
  2384     {
       
  2385     TRACE_ENTRY_POINT;
       
  2386     
       
  2387     iListBox->View()->SetDisableRedraw( EFalse );
       
  2388     SetCursorToActiveDayL();  
       
  2389     SetListBoxDataL();
       
  2390     AddToStackAndMakeVisibleL();
       
  2391     iViewPopulationComplete = ETrue;
       
  2392 		
       
  2393 		iView->SetEditorActive( EFalse );
       
  2394 		
       
  2395     // Popup needs to check if iViewPopulationComplete is set
       
  2396     FocusChangeForPopupL();
       
  2397     
       
  2398     UpdateStatusPaneAndExtensionsL();
       
  2399     DrawDeferred();
       
  2400 	// Hide/unhide "today" toolbar item based on the focused day
       
  2401     UpdateTodayToolbarItemL();
       
  2402     TRACE_EXIT_POINT;
       
  2403     }
       
  2404 
       
  2405 // ----------------------------------------------------------------------------
       
  2406 // CCalenWeekContainer::CreateIconIndicesL
       
  2407 // Create icon index for day view
       
  2408 // ----------------------------------------------------------------------------
       
  2409 //
       
  2410 void CCalenWeekContainer::CreateIconIndicesL( RArray<MCalenServices::TCalenIcons>& aIndexArray )
       
  2411     {
       
  2412     TRACE_ENTRY_POINT;
       
  2413     // Icons needed for the week view
       
  2414     aIndexArray.Reset();
       
  2415     aIndexArray.AppendL( MCalenServices::ECalenBirthdayIcon );
       
  2416     aIndexArray.AppendL( MCalenServices::ECalenMeetingIcon );
       
  2417     aIndexArray.AppendL( MCalenServices::ECalenDaynoteIcon );
       
  2418     aIndexArray.AppendL( MCalenServices::ECalenToDoIcon );
       
  2419     
       
  2420     TRACE_EXIT_POINT;
       
  2421     }
       
  2422 
       
  2423 // ----------------------------------------------------------------------------
       
  2424 // CCalenWeekContainer::InfoBarRectL
       
  2425 // Returns the available info bar rect for this container
       
  2426 // ----------------------------------------------------------------------------
       
  2427 TRect CCalenWeekContainer::InfoBarRectL( TBool aToolbarAvailable )
       
  2428     {
       
  2429     TRACE_ENTRY_POINT;
       
  2430    
       
  2431     // Get the main pane
       
  2432     TAknLayoutRect main_cale_week_pane;
       
  2433     main_cale_week_pane.LayoutRect( Rect(), 
       
  2434                     AknLayoutScalable_Apps::main_cale_week_pane().LayoutLine() );
       
  2435         
       
  2436     TAknLayoutRect listscroll_cale_week_pane;
       
  2437     listscroll_cale_week_pane.LayoutRect( main_cale_week_pane.Rect(), 
       
  2438             AknLayoutScalable_Apps::listscroll_cale_week_pane(1).LayoutLine() );
       
  2439 
       
  2440     // Create a dummy label to find the layout rect
       
  2441     CEikLabel* dummyLabel = new( ELeave ) CEikLabel;
       
  2442     CleanupStack::PushL( dummyLabel );
       
  2443 
       
  2444     // Get the layout variant for the week view infobar.
       
  2445     // We assume that we have one for this check, as we need to
       
  2446     // find the size that would be available if we do have one.
       
  2447     TInt layoutVariant = 0;
       
  2448     if( aToolbarAvailable )
       
  2449         {
       
  2450         layoutVariant = 1;
       
  2451         }
       
  2452     else
       
  2453         {
       
  2454         layoutVariant = 0;
       
  2455         }
       
  2456            
       
  2457     AknLayoutUtils::LayoutLabel( dummyLabel, listscroll_cale_week_pane.Rect(),
       
  2458         AknLayoutScalable_Apps::listscroll_cale_week_pane_t1( layoutVariant ).LayoutLine() );        
       
  2459               
       
  2460     TRect infoRect = dummyLabel->Rect();
       
  2461     TRect rect;
       
  2462     // Discard the label
       
  2463     CleanupStack::PopAndDestroy( dummyLabel );
       
  2464     
       
  2465     TRACE_EXIT_POINT;
       
  2466     return infoRect;
       
  2467     }
       
  2468 
       
  2469 // ----------------------------------------------------------------------------
       
  2470 // CCalenWeekContainer::CheckLayoutAndExtensionsL
       
  2471 // check with layoutmanager for any layout changes
       
  2472 // ----------------------------------------------------------------------------
       
  2473 void CCalenWeekContainer::CheckLayoutAndExtensionL()
       
  2474     {
       
  2475     TRACE_ENTRY_POINT;
       
  2476     
       
  2477     iLayoutManager->GetLayoutAndExtensionL();
       
  2478     
       
  2479     TRACE_EXIT_POINT;
       
  2480     }
       
  2481 
       
  2482 // ----------------------------------------------------------------------------
       
  2483 // CCalenWeekContainer::SearchTopIndexL
       
  2484 // Searches for the top index
       
  2485 // ----------------------------------------------------------------------------    
       
  2486 TInt CCalenWeekContainer::SearchTopIndexL(TInt /*aColumn*/)    
       
  2487 	{
       
  2488 	TRACE_ENTRY_POINT;
       
  2489 	
       
  2490 	TInt row = KErrNotFound;
       
  2491 
       
  2492 	MCalenContext& context = iServices.Context();
       
  2493 		
       
  2494 	if( iSelectedRowNumber == KErrNotFound && iRow)
       
  2495     	{
       
  2496     	row = KErrNotFound;
       
  2497     	}
       
  2498     else
       
  2499     	{
       
  2500     	if(iListBox->TopItemIndex()!=0 && !iTopRowDefault)
       
  2501     		{
       
  2502     		// row is top item index..
       
  2503     		row = iListBox->TopItemIndex();
       
  2504     		}
       
  2505     	else
       
  2506     		{
       
  2507     		// row for the time
       
  2508     		row = FindRowForTime(iFirstRowTime);	
       
  2509     		iTopRowDefault =  EFalse;
       
  2510     		}
       
  2511     	}
       
  2512     
       
  2513 	TRACE_EXIT_POINT;
       
  2514 	
       
  2515     return row;	
       
  2516 	}
       
  2517 	
       
  2518 // -----------------------------------------------------------------------------
       
  2519 // CCalenWeekContainer::PreviewPane
       
  2520 // Return preview pane pointer
       
  2521 // -----------------------------------------------------------------------------
       
  2522 //	
       
  2523 const MCalenPreview* CCalenWeekContainer::PreviewPane()
       
  2524     {
       
  2525     TRACE_ENTRY_POINT
       
  2526     TRACE_EXIT_POINT
       
  2527     return iPreview;
       
  2528     }	
       
  2529 
       
  2530 // ----------------------------------------------------------------------------
       
  2531 // CCalenWeekContainer::UpdatePreviewPaneL
       
  2532 // Updates preview pane whenever application comes to foreground
       
  2533 // ----------------------------------------------------------------------------    
       
  2534 void CCalenWeekContainer::UpdatePreviewPaneL()
       
  2535     {
       
  2536     TRACE_ENTRY_POINT;
       
  2537     
       
  2538     if( iViewPopulationComplete )
       
  2539         {
       
  2540         CalcDayFromColumn();
       
  2541         
       
  2542         CWeekSlotArrayPtr slotTable = iSlotTable[iColumn];
       
  2543         CCalHourItem& itemInfo = *(*slotTable)[iListBox->CurrentItemIndex()];
       
  2544         
       
  2545         // dont focus the preview popup/previewpane if any dialog or faster app is active
       
  2546         if( iPreview && !iView->IsEditorActiveOrFasterAppExit())
       
  2547             {
       
  2548             if( !itemInfo.IsTimed() )
       
  2549                 { 
       
  2550                 // Non-timed cell
       
  2551                 iPreview->FocusChangedL(itemInfo.iInstance);
       
  2552                 }
       
  2553             else
       
  2554                 {
       
  2555                 TDateTime dt = iTime.DateTime();    // TACOTEMP
       
  2556                 iPreview->FocusChangedL( iServices.Context().FocusDateAndTimeL().TimeLocalL() );
       
  2557                 }
       
  2558             }
       
  2559         }
       
  2560     else
       
  2561         {
       
  2562         HidePopup();
       
  2563         }
       
  2564     
       
  2565     TRACE_EXIT_POINT;
       
  2566     }
       
  2567 
       
  2568 // -----------------------------------------------------------------------------
       
  2569 // CCalenWeekContainer::CalendarInfoIdentifierL
       
  2570 // Searches for the index in calendar info list based on calendar file name
       
  2571 // -----------------------------------------------------------------------------
       
  2572 //
       
  2573 TBool CCalenWeekContainer::CalendarInfoIdentifierL( const HBufC* aName,
       
  2574                                         const CCalCalendarInfo& aCalendarInfo)
       
  2575     {
       
  2576     TRACE_ENTRY_POINT;
       
  2577     TBool retVal = EFalse;
       
  2578     HBufC* calendarFileName = aCalendarInfo.FileNameL().AllocLC();
       
  2579     retVal = calendarFileName->CompareF(*aName);
       
  2580     CleanupStack::PopAndDestroy(calendarFileName);
       
  2581     TRACE_EXIT_POINT;
       
  2582     return (!retVal);
       
  2583     }
       
  2584 
       
  2585 // --------------------------------------------------------------------------
       
  2586 // CCalenWeekContainer::CleanupInstancesL
       
  2587 // (other items were commented in a header).
       
  2588 // --------------------------------------------------------------------------
       
  2589 //
       
  2590 void CCalenWeekContainer::CleanupInstances()
       
  2591     {
       
  2592     TRACE_ENTRY_POINT
       
  2593     for (TInt loop(0); loop < KCalenDaysInWeek; ++loop)
       
  2594           {
       
  2595           iIdList[loop].ResetAndDestroy();
       
  2596           }
       
  2597     TRACE_EXIT_POINT     
       
  2598     }
       
  2599 
       
  2600 
       
  2601 // End of File