calendarui/views/src/calendaycontainer.cpp
branchRCL_3
changeset 66 bd7edf625bdd
child 67 1539a383d7b6
child 74 97232defd20e
equal deleted inserted replaced
65:12af337248b1 66:bd7edf625bdd
       
     1 /*
       
     2 * Copyright (c) 2007 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:  For Day view container of calendar application.
       
    15  *                The class derived from CCalenContainer
       
    16  *
       
    17 */
       
    18 
       
    19 #include <Calendar.rsg>
       
    20 #include <calenconstants.h>
       
    21 #include <calendateutils.h>
       
    22 #include <calenagendautils.h>
       
    23 #include <calenservices.h>
       
    24 #include <csxhelp/cale.hlp.hrh>
       
    25 #include <AknsDrawUtils.h>
       
    26 #include <AknsFrameBackgroundControlContext.h>
       
    27 #include <AknUtils.h>
       
    28 #include <AknIconArray.h>
       
    29 #include <eikfrlbd.h>
       
    30 #include <eiklabel.h>
       
    31 #include <eikmenub.h>
       
    32 #include <StringLoader.h>
       
    33 #include <calenviewutils.h>
       
    34 #include <aknlayoutscalable_apps.cdl.h>
       
    35 #include <calinstance.h>
       
    36 #include <calentry.h>
       
    37 #include <calinstanceview.h>
       
    38 #include <caltime.h>
       
    39 #include <AknDef.h>
       
    40 #include <calencontext.h>
       
    41 #include <akntoolbar.h>
       
    42 #include <aknstyluspopupmenu.h>
       
    43 #include <barsread.h>
       
    44 #include <gesturehelper.h> //CGestureHelper
       
    45 
       
    46 // INCLUDE FILES
       
    47 #include "calendaycontainer.h"
       
    48 #include "calencontainerlayoutmanager.h"
       
    49 #include "calencontroller.h"
       
    50 #include "calenlocationutil.h"
       
    51 #include "calendaylistboxmodel.h"
       
    52 #include "calendaylistboxview.h"
       
    53 #include "calendaylistbox.h"
       
    54 #include "calendayview.h"
       
    55 #include "CalenUid.h"
       
    56 #include "calendar.hrh"
       
    57 //debug
       
    58 #include "calendarui_debug.h"
       
    59 
       
    60 //  LOCAL CONSTANTS AND MACROS
       
    61 const TInt KLayoutTableGranularity(10);
       
    62 const TInt KNullMinutes = -1;
       
    63 
       
    64 // ================= MEMBER FUNCTIONS =======================
       
    65 
       
    66 // ----------------------------------------------------------------------------
       
    67 // CCalenDayContainer::CCalenDayContainer
       
    68 // C++ constructor
       
    69 // (other items were commented in a header).
       
    70 // ----------------------------------------------------------------------------
       
    71 //
       
    72 CCalenDayContainer::CCalenDayContainer( CCalenNativeView* aView,
       
    73                                         TTime& aDate,
       
    74                                         TInt& aHighlightedRowNumber,
       
    75                                         TInt& aFirstEntryOnScreenIndex,
       
    76                                         MCalenServices& aServices )
       
    77     : CCalenContainer( aView, aServices ),
       
    78       iDeletedIndex( KIndexError ),
       
    79       iDate( aDate ),
       
    80       iHighlightedRowNumber( aHighlightedRowNumber ),
       
    81       iFirstEntryOnScreenIndex( aFirstEntryOnScreenIndex )
       
    82     {
       
    83     TRACE_ENTRY_POINT;
       
    84     TRACE_EXIT_POINT;
       
    85     }
       
    86 
       
    87 // ----------------------------------------------------------------------------
       
    88 // CCalenDayContainer::~CCalenDayContainer
       
    89 // Destructor
       
    90 // (other items were commented in a header).
       
    91 // ----------------------------------------------------------------------------
       
    92 //
       
    93 CCalenDayContainer::~CCalenDayContainer()
       
    94     {
       
    95     TRACE_ENTRY_POINT;
       
    96 
       
    97     delete iListBoxModel;
       
    98     delete iListBox;
       
    99     iInstanceList.ResetAndDestroy();
       
   100     delete iLayoutTable;
       
   101     // Skin contexts
       
   102     delete iBackgroundSkinContext;
       
   103     delete iGestureHelper;
       
   104 
       
   105     TRACE_EXIT_POINT;
       
   106     }
       
   107 	
       
   108 // ---------------------------------------------------------
       
   109 // CCalenDayOnlyEventContainer::HandleListBoxEventL
       
   110 // Handle events incoming from list instance. 
       
   111 // ---------------------------------------------------------
       
   112 //
       
   113 void CCalenDayContainer::HandleListBoxEventL(CEikListBox* /*aListBox*/, 
       
   114                                                       TListBoxEvent aEventType)
       
   115     {
       
   116     TRACE_ENTRY_POINT;
       
   117     switch( aEventType )
       
   118         {
       
   119         // Single click integration
       
   120         case EEventItemSingleClicked:
       
   121             {
       
   122             // left/right gestures (touch down, drag, touch release) are treated
       
   123              // by CEikListBox as single click, probably this should be fixed by AVKON team
       
   124              if ( !iGestureHandled )
       
   125                  {
       
   126                  if(iView->MenuBar()->IsDisplayed() == EFalse)
       
   127                      {
       
   128                      iView->HandleCommandL( ECalenViewCurrentEntry );
       
   129                      }
       
   130                  }
       
   131             break;
       
   132             }
       
   133         case EEventEmptyListClicked:
       
   134             {
       
   135             // left/right gestures (touch down, drag, touch release) are treated
       
   136             // by CEikListBox as single click, probably this should be fixed by AVKON team
       
   137             if ( !iGestureHandled )
       
   138                 {
       
   139                 if (iListBox->Model()->NumberOfItems() <= 0)
       
   140                     {
       
   141                     iView->HandleCommandL(ECalenCmdOpenMskDialog);
       
   142                     }
       
   143                 }
       
   144             break;
       
   145             }
       
   146             
       
   147         case EEventEmptyAreaClicked:
       
   148             {
       
   149             // left/right gestures (touch down, drag, touch release) are treated
       
   150             // by CEikListBox as single click, probably this should be fixed by AVKON team
       
   151 			break;
       
   152             }
       
   153 			
       
   154         // Single click integration
       
   155         case EEventEnterKeyPressed:
       
   156             {
       
   157             iView->HandleCommandL( ECalenViewCurrentEntry );
       
   158             break;
       
   159             }
       
   160         default:
       
   161             break;
       
   162         };
       
   163     TRACE_EXIT_POINT;
       
   164     }
       
   165 	
       
   166 
       
   167 // ----------------------------------------------------------------------------
       
   168 // CCalenDayContainer::UpdateContainerL
       
   169 // Refresh Day view data and draws.
       
   170 // Data is based on active context.
       
   171 // (other items were commented in a header).
       
   172 // ----------------------------------------------------------------------------
       
   173 //
       
   174 void CCalenDayContainer::UpdateContainerL()
       
   175     {
       
   176     TRACE_ENTRY_POINT;
       
   177 
       
   178     UpdateStatusPaneAndExtensionsL();
       
   179 
       
   180     iView->BeginRepopulationL();
       
   181     iListBox->View()->SetDisableRedraw(ETrue);   
       
   182 
       
   183     TRACE_EXIT_POINT;
       
   184     }
       
   185 
       
   186 // ----------------------------------------------------------------------------
       
   187 // CCalenDayContainer::UpdateTimeFormat
       
   188 // ?implementation_description
       
   189 // (other items were commented in a header).
       
   190 // ----------------------------------------------------------------------------
       
   191 //
       
   192 void CCalenDayContainer::UpdateTimeFormat()
       
   193     {
       
   194     TRACE_ENTRY_POINT;
       
   195 
       
   196     SizeChanged();
       
   197 
       
   198     TRACE_EXIT_POINT;
       
   199     }
       
   200 
       
   201 // ----------------------------------------------------------------------------
       
   202 // CCalenDayContainer::DestroyInstanceListL
       
   203 // ?implementation_description
       
   204 // (other items were commented in a header).
       
   205 // ----------------------------------------------------------------------------
       
   206 //
       
   207 void CCalenDayContainer::DestroyInstanceListL()
       
   208     {
       
   209     TRACE_ENTRY_POINT;
       
   210 
       
   211     // NULL temporary instance references in layout table
       
   212     for ( TInt i=0; i < iLayoutTable->Count(); ++i )
       
   213         {
       
   214         iLayoutTable->At(i).iTmpInstance = NULL;
       
   215         }
       
   216 
       
   217     // Destroy instances.
       
   218     iInstanceList.ResetAndDestroy();
       
   219 
       
   220     TRACE_EXIT_POINT;
       
   221     }
       
   222 
       
   223 // ----------------------------------------------------------------------------
       
   224 // CCalenDayContainer::CreateListBoxDataL
       
   225 // Set Listbox data to ListBox
       
   226 // Step 4 of construction of ListBox data
       
   227 // (other items were commented in a header).
       
   228 // ----------------------------------------------------------------------------
       
   229 //
       
   230 void CCalenDayContainer::CreateListBoxDataL()
       
   231     {
       
   232     TRACE_ENTRY_POINT;
       
   233 
       
   234     MCalenContext& context = iServices.Context();
       
   235 	TInt aIndex = FindItemIndex( context.InstanceId() );
       
   236 	
       
   237     // ---------------------
       
   238     // Listbox model and view setup
       
   239     iListBox->View()->SetDisableRedraw(ETrue);
       
   240 
       
   241     CArrayFixFlat<TInt>* cellArray = new(ELeave)CArrayFixFlat<TInt>(5);
       
   242     CleanupStack::PushL(cellArray);
       
   243 
       
   244     iListBoxModel->CreateListBoxDataL( *iLayoutTable,
       
   245                                        *cellArray,
       
   246                                        iServices,
       
   247                                        iDate );
       
   248 
       
   249     CleanupStack::Pop( cellArray );
       
   250     View()->SetCellArray( cellArray );
       
   251     
       
   252     UpdateHighlightedRowIfDeletedL();
       
   253     if(iHighlightedRowNumber!=KErrNotFound)
       
   254         {
       
   255         // Cycled to from another view when no one changed the context,
       
   256         // or refreshing current view. No need to set context.
       
   257       	if (aIndex!=KErrNotFound ) 
       
   258        		{
       
   259        		SItemInfo& itemInfo = (*iLayoutTable)[aIndex];
       
   260         	iHighlightedRowNumber = itemInfo.iTopLine;  
       
   261        		}
       
   262       	else if(iDeletedIndex!=KErrNotFound)
       
   263       	    {
       
   264       	    iDeletedIndex = KErrNotFound;
       
   265       	    }
       
   266       	else 
       
   267        	    {
       
   268        	    iHighlightedRowNumber = KErrNotFound;
       
   269        	    iFirstEntryOnScreenIndex = KErrNotFound;
       
   270        	    }
       
   271         }
       
   272 
       
   273     if(iDateWasNull) // iDate was null when population was started.
       
   274         {
       
   275         // Cycled to from another view after someone else changed the context.
       
   276         // Set the new highlight based on the context.
       
   277         SetHighlightFromContextL();
       
   278         }
       
   279     SetContextFromHighlightL();
       
   280 
       
   281     DestroyInstanceListL();
       
   282     
       
   283     HBufC* emptyText = StringLoader::LoadLC(R_CALEN_QTN_CALE_NO_EVENTS,
       
   284                                                    iEikonEnv);
       
   285     //Whenever listbox is empty, it will set with this empty text.
       
   286     iListBox->View()->SetListEmptyTextL( *emptyText ); 
       
   287     CleanupStack::PopAndDestroy(emptyText);
       
   288     
       
   289     iListBox->HandleItemAdditionL(); // Is this causing unnecessary draw?
       
   290 
       
   291     iListBox->View()->SetDisableRedraw(EFalse);
       
   292     iListBox->SetFocus(ETrue);
       
   293     iListBox->DrawNow();
       
   294     DayView().UpdateCbaL();
       
   295 
       
   296     TRACE_EXIT_POINT;
       
   297     }
       
   298 
       
   299 // ----------------------------------------------------------------------------
       
   300 // CCalenDayContainer::IsEmptyView
       
   301 // ?implementation_description
       
   302 // (other items were commented in a header).
       
   303 // ----------------------------------------------------------------------------
       
   304 //
       
   305 TBool CCalenDayContainer::IsEmptyView() const
       
   306     {
       
   307     TRACE_ENTRY_POINT;
       
   308 
       
   309     TRACE_EXIT_POINT;
       
   310     return (iListBox->Model()->NumberOfItems() <= 0);
       
   311     }
       
   312 
       
   313 // ----------------------------------------------------------------------------
       
   314 // CCalenDayContainer::FindItem
       
   315 // ?implementation_description
       
   316 // (other items were commented in a header).
       
   317 // ----------------------------------------------------------------------------
       
   318 //
       
   319 CCalenDayContainer::SItemInfo& CCalenDayContainer::FindItem( TInt aLineIndex ) const
       
   320     {
       
   321     TRACE_ENTRY_POINT;
       
   322 
       
   323     ASSERT( aLineIndex >= 0 );
       
   324 
       
   325     TInt itemIx = FindItemIndexForRow( aLineIndex );
       
   326     __ASSERT_DEBUG(itemIx >= 0, User::Invariant());
       
   327 
       
   328     SItemInfo& result = (*iLayoutTable)[itemIx];
       
   329 
       
   330     TRACE_EXIT_POINT;
       
   331     return result;
       
   332     }
       
   333 
       
   334 // ----------------------------------------------------------------------------
       
   335 // ?classname::?member_function
       
   336 // ?implementation_description
       
   337 // (other items were commented in a header).
       
   338 // ----------------------------------------------------------------------------
       
   339 //
       
   340 MCalenServices& CCalenDayContainer::Services()
       
   341     {
       
   342     TRACE_ENTRY_POINT
       
   343     TRACE_EXIT_POINT
       
   344     return iServices;
       
   345     }
       
   346 
       
   347 // ----------------------------------------------------------------------------
       
   348 // ?classname::?member_function
       
   349 // ?implementation_description
       
   350 // (other items were commented in a header).
       
   351 // ----------------------------------------------------------------------------
       
   352 //
       
   353 TInt CCalenDayContainer::FindItemIndexForRow( TInt aListIndex ) const
       
   354     {
       
   355     TRACE_ENTRY_POINT;
       
   356 
       
   357     for ( TInt i(0); i < iLayoutTable->Count(); ++i )
       
   358         {
       
   359         SItemInfo& item = (*iLayoutTable)[i];
       
   360         if ( aListIndex >= item.iTopLine && aListIndex <= item.iBottomLine )
       
   361             {
       
   362             TRACE_EXIT_POINT;
       
   363             return i;
       
   364             }
       
   365         }
       
   366         
       
   367     TRACE_EXIT_POINT;
       
   368     return KIndexError;
       
   369     }
       
   370 
       
   371 // ----------------------------------------------------------------------------
       
   372 // CCalenDayContainer::UpdateHighlightedRowIfDeletedL
       
   373 // Updates the highlighted index based on whether an entry has just been
       
   374 // deleted.
       
   375 // (other items were commented in a header).
       
   376 // ----------------------------------------------------------------------------
       
   377 //
       
   378 void CCalenDayContainer::UpdateHighlightedRowIfDeletedL()
       
   379     {
       
   380     TRACE_ENTRY_POINT;
       
   381 
       
   382     CCalenDayListBoxView* view =  View();
       
   383     if ( iDeletedIndex != KErrNotFound )
       
   384         // If just deleted an entry
       
   385         {
       
   386         if ( iLayoutTable->Count() > 0 )
       
   387             {
       
   388             // Precondition: iDeletedIndex can contain only index to first line
       
   389             // of deleted item.
       
   390             // Fixed to work as specifed in Selection Service
       
   391             // 2.1.1 Focus while adding or deleting items.
       
   392             //TInt previousLine = iDeletedIndex;
       
   393             //highlightLine = previousLine;
       
   394 
       
   395             iHighlightedRowNumber = iDeletedIndex-1;
       
   396             }
       
   397         else
       
   398             {
       
   399             iHighlightedRowNumber = KErrNotFound;
       
   400             }
       
   401        // iDeletedIndex = KErrNotFound;
       
   402         }
       
   403 
       
   404     TRACE_EXIT_POINT;
       
   405     }
       
   406 
       
   407 // ----------------------------------------------------------------------------
       
   408 // CCalenDayContainer::SetHighlightFromContextL
       
   409 // Sets the highlighted row based on the context.
       
   410 // (other items were commented in a header).
       
   411 // ----------------------------------------------------------------------------
       
   412 //
       
   413 void CCalenDayContainer::SetHighlightFromContextL()
       
   414     {
       
   415     TRACE_ENTRY_POINT;
       
   416 
       
   417     MCalenContext& context = iServices.Context();
       
   418     TCalenInstanceId instId = context.InstanceId();
       
   419 
       
   420     if ( instId == TCalenInstanceId::NullInstanceId() )
       
   421         {
       
   422         iHighlightedRowNumber = 0;
       
   423 
       
   424         // Context points at a day/time, not an entry.
       
   425         // If we have an entry for this day set it to be the context,
       
   426         // as long as we weren't cycled to.
       
   427         if ( iLayoutTable->Count() )
       
   428             {
       
   429             if ( context.FocusTime().Int() == -1 )
       
   430                 {
       
   431                 // Context has a date but no time and no instance.
       
   432                 // We're not being cycled to, so set the context.
       
   433                 SetContextFromHighlightL();
       
   434                 }
       
   435             // else context has a date and time but no instance. This happens
       
   436             // for example when the week view highlights a cell with no instance,
       
   437             // then cycles to us - don't reset the context.
       
   438             }
       
   439 //      else Nothing on this day. Don't set context, as it's already set to this day.
       
   440         }
       
   441     else
       
   442         {
       
   443         TInt index = FindItemIndex( context.InstanceId() );
       
   444         if(index != KErrNotFound)
       
   445             {
       
   446             SItemInfo& itemInfo = (*iLayoutTable)[index];
       
   447             iHighlightedRowNumber = itemInfo.iTopLine;
       
   448             iFirstEntryOnScreenIndex = iListBox->TopItemIndex();
       
   449             SetHighlightAndVisibleItem( iHighlightedRowNumber, iFirstEntryOnScreenIndex );
       
   450             }
       
   451         }
       
   452 
       
   453     TRACE_EXIT_POINT;
       
   454     }
       
   455 
       
   456 // ----------------------------------------------------------------------------
       
   457 // CCalenDayContainer::SetContextFromHighlightL
       
   458 // Sets the context based on what's highlighted.
       
   459 // (other items were commented in a header).
       
   460 // ----------------------------------------------------------------------------
       
   461 //
       
   462 void CCalenDayContainer::SetContextFromHighlightL()
       
   463     {
       
   464     TRACE_ENTRY_POINT;
       
   465 
       
   466     MCalenContext& context = iServices.Context();
       
   467 	
       
   468     if ( iLayoutTable->Count() <= 0 )
       
   469         {
       
   470         // Nothing in the day view. Set context to this day.
       
   471         TCalTime dayCalTime;
       
   472         dayCalTime.SetTimeLocalL( iDate );
       
   473         context.SetFocusDateL( dayCalTime,
       
   474                                TVwsViewId( KUidCalendar, KUidCalenDayView ) );
       
   475         iHighlightedRowNumber = KErrNotFound;
       
   476         }
       
   477     else
       
   478         {
       
   479         // Stuff is present for this day.
       
   480      	
       
   481      	SetHighlightAndVisibleItem( iHighlightedRowNumber, iFirstEntryOnScreenIndex );
       
   482 		
       
   483 		TInt lineIx = iListBox->View()->CurrentItemIndex();
       
   484 	
       
   485     	// If list is empty, index is -1
       
   486     	if (lineIx >= 0)
       
   487         	{ 
       
   488         	TInt itemIx = FindItemIndexForRow(lineIx);
       
   489         	if( itemIx != KIndexError)
       
   490             	{
       
   491           		SItemInfo& item = (*iLayoutTable)[itemIx];
       
   492           		iHighlightedRowNumber = item.iTopLine;
       
   493           
       
   494           		if ( item.iTimedNote )
       
   495             		{
       
   496             		// Timed entry.
       
   497             		TCalTime dayCalTime;
       
   498             		dayCalTime.SetTimeLocalL( CalenDateUtils::BeginningOfDay( iDate ) + item.iStartTime );
       
   499             		context.SetFocusDateAndTimeAndInstanceL( dayCalTime,
       
   500                     		                                 item.iId,
       
   501                             		                         TVwsViewId( KUidCalendar, KUidCalenDayView ) );
       
   502             		}
       
   503         		else
       
   504             		{
       
   505             		// Untimed entry.
       
   506             		if ( item.iId.iType == CCalEntry::ETodo &&
       
   507                  		item.iId.iInstanceTime < CalenDateUtils::Today() )
       
   508                 		{
       
   509                 		TCalTime dayCalTime;
       
   510                 		dayCalTime.SetTimeLocalL( CalenDateUtils::Today() );
       
   511                 		// For todos in the past, set focus on the todo but view it today.
       
   512                 		context.SetFocusDateAndTimeAndInstanceL(
       
   513                         		                            dayCalTime,
       
   514                                 		                    item.iId,
       
   515                                         		            TVwsViewId( KUidCalendar, KUidCalenDayView ) );
       
   516                 		}
       
   517             		else
       
   518                 		{
       
   519                 		if ( CalenDateUtils::OnSameDay( item.iId.iInstanceTime, iDate ) )
       
   520                     		{
       
   521                     		context.SetInstanceIdL( item.iId,
       
   522                             		                TVwsViewId( KUidCalendar, KUidCalenDayView ) );
       
   523                     		}
       
   524                 		else
       
   525                     		{
       
   526                     		// Multi-day untimed note (either multi-day day note or weird todo).
       
   527                     		// Focus on the instance and set the focus time to the highlighted day.
       
   528                     		TCalTime dayCalTime;
       
   529                     		dayCalTime.SetTimeLocalL( iDate );
       
   530                     		context.SetFocusDateAndTimeAndInstanceL( dayCalTime,
       
   531                             		                                 item.iId,
       
   532                                                              TVwsViewId( KUidCalendar, KUidCalenDayView ) );
       
   533  		                   }
       
   534         		        }
       
   535             		}
       
   536             
       
   537             
       
   538             
       
   539              	}
       
   540         	else 
       
   541             	{
       
   542             	// FIXME: If item is not found, should we do something? 
       
   543             	__ASSERT_DEBUG(EFalse, User::Invariant());
       
   544             	}
       
   545         	}
       
   546     	else
       
   547         	{ // Empty list
       
   548         	// do nothing
       
   549         	}
       
   550         }
       
   551 
       
   552     TRACE_EXIT_POINT;
       
   553     }
       
   554 
       
   555 // ----------------------------------------------------------------------------
       
   556 // CCalenDayContainer::FindItemIndex
       
   557 // Returns the index into iLayoutTable of the given instance id (for highlighting).
       
   558 // (other items were commented in a header).
       
   559 // ----------------------------------------------------------------------------
       
   560 //
       
   561 TInt CCalenDayContainer::FindItemIndex( const TCalenInstanceId& aId ) const
       
   562     {
       
   563     TRACE_ENTRY_POINT;
       
   564 
       
   565     // For instances finishing the next day (now possible with unified DateTime editor),
       
   566     // we have to do our best to match the instance time exactly - otherwise we could
       
   567     // match the LocalUid to the incorrect instance in a series.
       
   568     for(TInt index(0); index < iLayoutTable->Count(); ++index)
       
   569         {
       
   570         SItemInfo& itemInfo = (*iLayoutTable)[index];
       
   571 
       
   572         if( itemInfo.iId.iEntryLocalUid == aId.iEntryLocalUid )
       
   573             {
       
   574             // Check the instance time matches.
       
   575             if( itemInfo.iId.iInstanceTime == aId.iInstanceTime )
       
   576                 {
       
   577                 return index;
       
   578                 }
       
   579             }
       
   580         }
       
   581 
       
   582     // Couldn't match the instance time exactly - just use the instance
       
   583     // with the same LocalUid as the one we're looking for.
       
   584     // In theory this shouldn't happen but it's good to have a failsafe.
       
   585     for(TInt index(0); index < iLayoutTable->Count(); ++index)
       
   586         {
       
   587         SItemInfo& itemInfo = (*iLayoutTable)[index];
       
   588 
       
   589         if( itemInfo.iId.iEntryLocalUid == aId.iEntryLocalUid )
       
   590             {
       
   591             return index;
       
   592             }
       
   593         }
       
   594 
       
   595     TRACE_EXIT_POINT;
       
   596     return KErrNotFound;
       
   597     }
       
   598 
       
   599 // ----------------------------------------------------------------------------
       
   600 // CCalenDayContainer::SetHighlightAndVisibleItem
       
   601 // Sets highlight item in ListBox
       
   602 // (other items were commented in a header).
       
   603 // ----------------------------------------------------------------------------
       
   604 //
       
   605 void CCalenDayContainer::SetHighlightAndVisibleItem( TInt aIndex,
       
   606                                                      TInt aTopItem )
       
   607     {
       
   608     TRACE_ENTRY_POINT;
       
   609 
       
   610     TInt count(iListBox->Model()->NumberOfItems());
       
   611     if ( count <= 0 )
       
   612         {
       
   613         return;
       
   614         }
       
   615 
       
   616     // aIndex and aTopItem can be indexes to any
       
   617     // line, not just first lines of items.
       
   618     // But we want to make sure that current item and top item indexes points
       
   619     // always only to the first line of item.
       
   620 
       
   621     // Limit range
       
   622     aIndex = Min(count - 1, aIndex);
       
   623     aIndex = Max(0, aIndex);
       
   624 
       
   625     // FIXME: can be done with layout table, no need for view-> calls  !
       
   626     TInt firstLine = View()->FirstLineOfCell(aIndex);
       
   627     iListBox->SetCurrentItemIndex(firstLine);
       
   628 
       
   629     SetVisibleLines(firstLine, aTopItem);
       
   630 
       
   631     TRACE_EXIT_POINT;
       
   632     }
       
   633 
       
   634 // ----------------------------------------------------------------------------
       
   635 // ?classname::?member_function
       
   636 // ?implementation_description
       
   637 // (other items were commented in a header).
       
   638 // ----------------------------------------------------------------------------
       
   639 //
       
   640 void CCalenDayContainer::SetVisibleLines( TInt aHighlightFirstLine,
       
   641                                           TInt aPreferredTopLine )
       
   642     {
       
   643     TRACE_ENTRY_POINT;
       
   644 
       
   645     CCalenDayListBoxView* view =  View();
       
   646 
       
   647     TInt highLightLastLine = view->LastLineOfCell( aHighlightFirstLine );
       
   648 
       
   649     TInt maxVisibleLines = view->NumberOfItemsThatFitInRect( view->ViewRect() );
       
   650     TInt totalListLines = iListBox->Model()->NumberOfItems();
       
   651 
       
   652     // Initial top line
       
   653     TInt topLine = aPreferredTopLine == KIndexError ? aHighlightFirstLine : aPreferredTopLine;
       
   654     topLine = Min(totalListLines - 1, topLine);
       
   655     topLine = Max(0, topLine);
       
   656 
       
   657     if ( aHighlightFirstLine < topLine )
       
   658         {
       
   659         topLine = aHighlightFirstLine;
       
   660         }
       
   661 
       
   662     // Adjust bottom line
       
   663     TInt bottomLine = topLine + maxVisibleLines - 1;
       
   664     TInt lastListLine = totalListLines - 1;
       
   665     bottomLine = bottomLine > lastListLine ? lastListLine : bottomLine;
       
   666     if ( highLightLastLine > bottomLine )
       
   667         {
       
   668         bottomLine = highLightLastLine;
       
   669         }
       
   670 
       
   671     TInt currentlyVisibleLines = bottomLine - topLine + 1;
       
   672     if ( currentlyVisibleLines > maxVisibleLines )
       
   673         {
       
   674         topLine = bottomLine - maxVisibleLines + 1;
       
   675         }
       
   676     // Now we have ensured that highlight is between [topLine, bottomLine]
       
   677     // If there are room for more lines in display, and still more lines
       
   678     // in list, we can scroll view up
       
   679 
       
   680     currentlyVisibleLines = bottomLine - topLine + 1;
       
   681     if ( (currentlyVisibleLines < maxVisibleLines - 1)
       
   682          && (totalListLines >= currentlyVisibleLines))
       
   683         {
       
   684         topLine = bottomLine - maxVisibleLines + 1;
       
   685         topLine = topLine < 0 ? 0 : topLine;
       
   686         }
       
   687 
       
   688     iListBox->SetTopItemIndex( topLine );
       
   689 
       
   690     TRACE_EXIT_POINT;
       
   691     }
       
   692 
       
   693 // ---------------------------------------------------------
       
   694 // CCalenDayContainer::SearchNearestItem
       
   695 // Searches list item that is nearest to aTime
       
   696 // (other items were commented in a header).
       
   697 // ---------------------------------------------------------
       
   698 //
       
   699 TInt CCalenDayContainer::SearchNearestItem( TTimeIntervalMinutes aTime ) const
       
   700     {
       
   701     TRACE_ENTRY_POINT;
       
   702 
       
   703     TInt foundIndex( KIndexError );
       
   704     const TInt count( iLayoutTable->Count() );
       
   705 
       
   706     for( TInt index(0); index < count; ++index )
       
   707         {
       
   708         SItemInfo& itemInfo = (*iLayoutTable)[index];
       
   709 
       
   710         // times match
       
   711         if( itemInfo.iStartTime == aTime )
       
   712             {
       
   713             foundIndex = index;
       
   714             break;
       
   715             }
       
   716         // times fall into same hour
       
   717         else if( (itemInfo.iStartTime.Int()/KCalenMinutesInHour) == (aTime.Int() / KCalenMinutesInHour)
       
   718                  && foundIndex == KIndexError )
       
   719             {
       
   720                 // Same starting hour
       
   721                 foundIndex = index;
       
   722             }
       
   723         }
       
   724 
       
   725     TRACE_EXIT_POINT;
       
   726     return foundIndex;
       
   727     }
       
   728 
       
   729 // ----------------------------------------------------------------------------
       
   730 // CCalenDayContainer::SizeChanged
       
   731 // Resizes child controls
       
   732 // (other items were commented in a header).
       
   733 // ----------------------------------------------------------------------------
       
   734 //
       
   735 void CCalenDayContainer::SizeChanged()
       
   736     {
       
   737     TRACE_ENTRY_POINT;
       
   738 
       
   739     CCalenContainer::SizeChanged( Rect() );
       
   740     
       
   741     TRAPD(error,iLayoutManager->GetLayoutAndExtensionL());
       
   742     if(error!=KErrNone)
       
   743     	{
       
   744     	// do avoid warning
       
   745     	}
       
   746               
       
   747     // Find the layout variant based upon a preview pane building present or not.
       
   748     TInt layoutVariant = LayoutVariantIndex( EListScrollCaleDayPane );
       
   749        
       
   750     TAknLayoutRect main_cale_day_pane;
       
   751     main_cale_day_pane.LayoutRect( Rect(), 
       
   752                     AknLayoutScalable_Apps::main_cale_day_pane(0).LayoutLine() );
       
   753         
       
   754     TAknLayoutRect listscroll_cale_day_pane;
       
   755     listscroll_cale_day_pane.LayoutRect( main_cale_day_pane.Rect(), 
       
   756             AknLayoutScalable_Apps::listscroll_cale_day_pane( layoutVariant ).LayoutLine() );
       
   757     
       
   758 
       
   759 #ifdef RD_CALEN_MIDNIGHT_VISUALIZATION
       
   760     PIM_TRAPD_HANDLE(GetMidnightVisualizationL()) // sets iMidnight
       
   761 #endif // RD_CALEN_MIDNIGHT_VISUALIZATION
       
   762 
       
   763 
       
   764     iListBoxModel->UpdateLayoutValues( layoutVariant
       
   765 #ifdef RD_CALEN_MIDNIGHT_VISUALIZATION
       
   766         , iMidnight
       
   767 #endif // RD_CALEN_MIDNIGHT_VISUALIZATION
       
   768         );
       
   769 
       
   770     // Now get the correct version for if we have a info bar or not
       
   771     listscroll_cale_day_pane.LayoutRect( main_cale_day_pane.Rect(), AknLayoutScalable_Apps::listscroll_cale_day_pane(layoutVariant).LayoutLine() );
       
   772 
       
   773 
       
   774     layoutVariant = LayoutVariantIndex( EBgCalePane );
       
   775 
       
   776     TAknLayoutRect bg_cale_pane;
       
   777     bg_cale_pane.LayoutRect( listscroll_cale_day_pane.Rect(), AknLayoutScalable_Apps::bg_cale_pane( layoutVariant ).LayoutLine() );
       
   778 
       
   779     TAknLayoutRect cale_bg_pane_center;
       
   780     cale_bg_pane_center.LayoutRect( bg_cale_pane.Rect(), AknLayoutScalable_Apps::cale_bg_pane_g1().LayoutLine() );
       
   781 
       
   782     iBackgroundSkinContext->SetFrameRects( bg_cale_pane.Rect(), cale_bg_pane_center.Rect() );
       
   783     iBackgroundSkinContext->SetParentContext( iBgContext );
       
   784 
       
   785     // Listbox layout
       
   786     TAknLayoutRect list_cale_pane;
       
   787     list_cale_pane.LayoutRect( main_cale_day_pane.Rect(), AknLayoutScalable_Apps::list_cale_pane( layoutVariant ).LayoutLine() );
       
   788 
       
   789     iListBox->SetRect( list_cale_pane.Rect() );
       
   790 
       
   791     // Inside of listbox.
       
   792     iListBox->ItemDrawer()->FormattedCellData()->SetBackgroundSkinStyle( &KAknsIIDQsnFrCaleCenter, cale_bg_pane_center.Rect() );
       
   793     layoutVariant = LayoutVariantIndex( EScrollPaneCp09 );
       
   794     // Scrollbar layout
       
   795     AknLayoutUtils::LayoutVerticalScrollBar( iListBox->ScrollBarFrame(),
       
   796                                              listscroll_cale_day_pane.Rect(),
       
   797                                              AknLayoutScalable_Apps::scroll_pane_cp09( layoutVariant ).LayoutLine() );
       
   798     
       
   799    
       
   800        
       
   801     PIM_TRAPD_HANDLE( UpdateStatusPaneAndExtensionsL() )
       
   802     
       
   803     CCoeControl* infoControl = iLayoutManager->ControlOrNull();
       
   804     if(infoControl)
       
   805     	{
       
   806     	TRAP_IGNORE(infoControl->ActivateL());
       
   807     	}
       
   808         
       
   809     
       
   810     DrawNow();
       
   811     TRACE_EXIT_POINT;
       
   812     }
       
   813 
       
   814 // ----------------------------------------------------------------------------
       
   815 // CCalenDayContainer::FocusChanged
       
   816 // ?implementation_description
       
   817 // (other items were commented in a header).
       
   818 // ----------------------------------------------------------------------------
       
   819 //
       
   820 void CCalenDayContainer::FocusChanged( TDrawNow aDrawNow )
       
   821     {
       
   822     TRACE_ENTRY_POINT;
       
   823 
       
   824     CCalenContainer::FocusChanged( aDrawNow );
       
   825 
       
   826     if( iListBox )
       
   827         {
       
   828         iListBox->SetFocus( IsFocused() );
       
   829         }
       
   830 
       
   831     TRACE_EXIT_POINT;
       
   832     }
       
   833 
       
   834 // ----------------------------------------------------------------------------
       
   835 // CCalenDayContainer::UpdateIconsL
       
   836 // update icons
       
   837 // (other items were commented in a header).
       
   838 // ----------------------------------------------------------------------------
       
   839 //
       
   840 void CCalenDayContainer::UpdateIconsL()
       
   841     {
       
   842     TRACE_ENTRY_POINT;
       
   843     
       
   844     CAknIconArray* iconList = CreateIconsL( iIconIndices );
       
   845     if(iListBox)
       
   846     {
       
   847     CArrayPtr<CGulIcon>* iconArray =iListBox->ItemDrawer()->FormattedCellData()->IconArray();
       
   848     delete iconArray;
       
   849     iconArray = NULL;
       
   850     iListBox->ItemDrawer()->ColumnData()->SetIconArray( iconList );
       
   851     }
       
   852     
       
   853     TRACE_EXIT_POINT;
       
   854     }
       
   855     
       
   856 // ----------------------------------------------------------------------------
       
   857 // CCalenDayContainer::HandleResourceChange
       
   858 // Called when layout or skin changes
       
   859 // (other items were commented in a header).
       
   860 // ----------------------------------------------------------------------------
       
   861 //
       
   862 void CCalenDayContainer::HandleResourceChange( TInt aType )
       
   863     {
       
   864     TRACE_ENTRY_POINT;
       
   865 
       
   866     CCalenContainer::HandleResourceChange( aType );
       
   867 
       
   868     if ( aType == KAknsMessageSkinChange || aType == KEikDynamicLayoutVariantSwitch )
       
   869         {
       
   870         TRAPD(error,UpdateIconsL());
       
   871 	    if(error!=KErrNone)
       
   872 	       	{
       
   873 	       	// do avoid warning
       
   874 	       	}     
       
   875         // refresh
       
   876         TRAPD(err,iView->BeginRepopulationL());
       
   877 	    if(err!=KErrNone)
       
   878 	       	{
       
   879 	       	// do avoid warning
       
   880 	       	}
       
   881 	    SizeChanged();
       
   882 
       
   883 	            // Update date formats to status pane
       
   884 	    TRAP_IGNORE(UpdateStatusPaneAndExtensionsL());
       
   885 
       
   886         }
       
   887 
       
   888     CCoeControl::HandleResourceChange( aType );
       
   889 
       
   890     TRACE_EXIT_POINT;
       
   891     }
       
   892 
       
   893 // ----------------------------------------------------------------------------
       
   894 // CCalenDayContainer::CountComponentControls
       
   895 // Gets child control count
       
   896 // (other items were commented in a header).
       
   897 // ----------------------------------------------------------------------------
       
   898 TInt CCalenDayContainer::CountComponentControls() const
       
   899     {
       
   900     TRACE_ENTRY_POINT;
       
   901     
       
   902     TInt controlCount;
       
   903 
       
   904     if ( iLayoutManager->ControlOrNull() )
       
   905         {
       
   906         controlCount = 2;
       
   907         }
       
   908     else
       
   909         {
       
   910         controlCount = 1;
       
   911         }
       
   912 
       
   913     TRACE_EXIT_POINT;
       
   914     return controlCount;
       
   915     }
       
   916 
       
   917 // ----------------------------------------------------------------------------
       
   918 // CCalenDayContainer::ComponentControl
       
   919 // Gets child control pointer
       
   920 // (other items were commented in a header).
       
   921 // ----------------------------------------------------------------------------
       
   922 CCoeControl* CCalenDayContainer::ComponentControl(TInt aIndex) const
       
   923     {
       
   924     TRACE_ENTRY_POINT;
       
   925 
       
   926     CCoeControl* control( NULL );
       
   927 
       
   928     switch (aIndex)
       
   929         {
       
   930         case 0:
       
   931             control = iListBox;
       
   932             break;
       
   933         
       
   934         case 1:
       
   935             control = iLayoutManager->ControlOrNull();
       
   936             break;
       
   937         
       
   938         default:
       
   939             __ASSERT_DEBUG( 0, User::Invariant() );
       
   940             break;
       
   941         }
       
   942 
       
   943     TRACE_EXIT_POINT;
       
   944     return control;
       
   945     }
       
   946 
       
   947 // ----------------------------------------------------------------------------
       
   948 // CCalenDayContainer::OfferKeyEventL
       
   949 // Process key event
       
   950 // (other items were commented in a header).
       
   951 // ----------------------------------------------------------------------------
       
   952 //
       
   953 TKeyResponse CCalenDayContainer::OfferKeyEventL( const TKeyEvent& aKeyEvent,
       
   954                                                           TEventCode aType )
       
   955     {
       
   956     TRACE_ENTRY_POINT;
       
   957 
       
   958     // common view key handling
       
   959     if (CCalenContainer::OfferKeyEventL(aKeyEvent, aType) == EKeyWasConsumed)
       
   960         {
       
   961         return EKeyWasConsumed;
       
   962         }
       
   963 
       
   964     // day view specific key handling
       
   965     TKeyResponse exitCode(EKeyWasNotConsumed);
       
   966 
       
   967     if (aType == EEventKey)
       
   968         {
       
   969         TBool mirrored(AknLayoutUtils::LayoutMirrored());
       
   970         switch (aKeyEvent.iCode)
       
   971             {
       
   972             case EKeyLeftArrow:
       
   973                 {
       
   974                 HandleHorizontalScrollL(TTimeIntervalDays(mirrored ? 1 : -1));
       
   975                 exitCode = EKeyWasConsumed;
       
   976                 break;
       
   977                 }
       
   978             case EKeyRightArrow:
       
   979                 {
       
   980                 HandleHorizontalScrollL(TTimeIntervalDays(mirrored ? -1 : 1));
       
   981                 exitCode = EKeyWasConsumed;
       
   982                 break;
       
   983                 }
       
   984             case EKeyBackspace:
       
   985                 {
       
   986                  // Single click integration
       
   987                 if( iView->MenuBar()->ItemSpecificCommandsEnabled()
       
   988                         && !IsEmptyView() )
       
   989 	                {
       
   990 	                iView->HandleCommandL( ECalenDeleteCurrentEntry );
       
   991 	                exitCode = EKeyWasConsumed;
       
   992 	                }
       
   993                 break;
       
   994                 }
       
   995             case EKeyOK:
       
   996                 {
       
   997                 if(iListBox->Model()->NumberOfItems() > 0)
       
   998                     {
       
   999                      // Single click integration
       
  1000                     iListBox->OfferKeyEventL( aKeyEvent, aType );
       
  1001                     }
       
  1002                 else
       
  1003                     {
       
  1004                     CEikMenuBar* menuBar = iView->MenuBar();
       
  1005                     menuBar->SetContextMenuTitleResourceId( R_CALENDAR_DAY_CASE_MENUBAR );
       
  1006                     menuBar->TryDisplayContextMenuBarL();
       
  1007                     }
       
  1008                 exitCode = EKeyWasConsumed;
       
  1009                 break;
       
  1010                 }
       
  1011             case EKeyEnter:    
       
  1012         		{
       
  1013         		if(IsEmptyView())
       
  1014                    	{ 
       
  1015                    	iView->HandleCommandL(ECalenCmdOpenMskDialog);                    
       
  1016                     }
       
  1017                 else
       
  1018 	                {
       
  1019                      // Single click integration
       
  1020                     iListBox->OfferKeyEventL( aKeyEvent, aType );
       
  1021 	            	}
       
  1022          		exitCode = EKeyWasConsumed;	
       
  1023                 break;
       
  1024         		}
       
  1025             default:
       
  1026                 break;
       
  1027             }
       
  1028         }
       
  1029 
       
  1030 	// For handling geokeys on corolla hardware
       
  1031 	// For Add location hard key
       
  1032 	if( aKeyEvent.iScanCode == EStdKeyApplication1C && aType == EEventKeyUp )
       
  1033 		{
       
  1034          // Single click integration
       
  1035         if( iView->MenuBar()->ItemSpecificCommandsEnabled()
       
  1036                 && CCalenLocationUtil::IsMapProviderAvailableL() )
       
  1037 			{
       
  1038 			MCalenContext& context = iServices.Context();
       
  1039 			TCalLocalUid instanceId = context.InstanceId().iEntryLocalUid;
       
  1040 			CCalEntry* entry = iServices.EntryViewL(context.InstanceId().iColId)->FetchL(instanceId);
       
  1041 			CleanupStack::PushL( entry );
       
  1042 			if(entry)
       
  1043 				{
       
  1044 				CCalEntry::TType entryType = entry->EntryTypeL();
       
  1045 				if(entryType == CCalEntry::EAppt)
       
  1046 					{
       
  1047 					iServices.IssueCommandL(ECalenGetLocationAndSave);
       
  1048 					}
       
  1049 				}
       
  1050 			CleanupStack::PopAndDestroy( entry );
       
  1051 			}
       
  1052 		exitCode = EKeyWasConsumed;
       
  1053 		}
       
  1054 	// For Show location hard key
       
  1055     // Single click integration 
       
  1056     else if( aKeyEvent.iScanCode == EStdKeyApplication1B && aType == EEventKeyUp
       
  1057             && iView->MenuBar()->ItemSpecificCommandsEnabled() )
       
  1058 		{
       
  1059 		MCalenContext& context = iServices.Context();
       
  1060 		TCalLocalUid instanceId = context.InstanceId().iEntryLocalUid;
       
  1061 		
       
  1062 		CCalEntry* entry = iServices.EntryViewL(context.InstanceId().iColId)->FetchL(instanceId);
       
  1063 		CleanupStack::PushL( entry );
       
  1064 		if(entry)
       
  1065 			{
       
  1066 			CCalEntry::TType entryType = entry->EntryTypeL();
       
  1067 			if(entryType == CCalEntry::EAppt)
       
  1068 				{
       
  1069 				TPtrC location = entry->LocationL();
       
  1070 				if( entry->GeoValueL())
       
  1071 					{ 
       
  1072 					iServices.IssueCommandL(ECalenShowLocation);
       
  1073 					}
       
  1074 				else if(location.Length())
       
  1075 					{
       
  1076 					iServices.IssueCommandL(ECalenGetLocationAndReplace);
       
  1077 					}
       
  1078 				else
       
  1079 					{
       
  1080 					iServices.IssueCommandL(ECalenShowLocationQuery);
       
  1081 					}
       
  1082 				}
       
  1083 			}
       
  1084 		CleanupStack::PopAndDestroy( entry );
       
  1085 		}
       
  1086 		
       
  1087     // listbox key handling
       
  1088     if (exitCode == EKeyWasConsumed || !iListBox)
       
  1089         {        // if DoDeactivate() is done, iListBox will be NULL.
       
  1090         // do nothing
       
  1091         }
       
  1092     else
       
  1093         {
       
  1094         TInt oldCursor = iListBox->View()->CurrentItemIndex();
       
  1095         exitCode = iListBox->OfferKeyEventL( aKeyEvent, aType );
       
  1096         TInt newCursor = iListBox->View()->CurrentItemIndex();
       
  1097         if (oldCursor != newCursor)
       
  1098             {
       
  1099             HandleVerticalScrollL( newCursor );
       
  1100             }
       
  1101         }
       
  1102 
       
  1103     TRACE_EXIT_POINT;
       
  1104     return exitCode;
       
  1105     }
       
  1106 
       
  1107 // ----------------------------------------------------------------------------
       
  1108 // CCalenDayContainer::HandleHorizontalScrollL
       
  1109 // Handles moving left or right to a new day.
       
  1110 // (other items were commented in a header).
       
  1111 // ----------------------------------------------------------------------------
       
  1112 //
       
  1113 void CCalenDayContainer::HandleHorizontalScrollL( TTimeIntervalDays aDirection )
       
  1114     {
       
  1115     TRACE_ENTRY_POINT;
       
  1116 
       
  1117     TTime time = CalenDateUtils::BeginningOfDay( iDate + aDirection );
       
  1118     time += iServices.Context().DefaultTimeForViews();
       
  1119 
       
  1120     if ( CalenDateUtils::IsValidDay( time ) )
       
  1121         {
       
  1122         iDate = time;
       
  1123         iHighlightedRowNumber = KErrNotFound;
       
  1124         iFirstEntryOnScreenIndex = KErrNotFound;
       
  1125 
       
  1126         // set the idate in to context
       
  1127         TCalTime time;
       
  1128         time.SetTimeLocalL( iDate );
       
  1129         iServices.Context().SetFocusDateL( time,
       
  1130                          TVwsViewId( KUidCalendar, KUidCalenDayView ) );
       
  1131 
       
  1132         UpdateContainerL(); // Repopulate.
       
  1133         }
       
  1134     else
       
  1135         {
       
  1136         CalenViewUtils::ShowDateOutOfRangeErrorNoteL();
       
  1137         }
       
  1138 
       
  1139     TRACE_EXIT_POINT;
       
  1140     }
       
  1141 
       
  1142 // ----------------------------------------------------------------------------
       
  1143 // CCalenDayContainer::HandleVerticalScrollL
       
  1144 // Handles moving up or down in the same day.
       
  1145 // (other items were commented in a header).
       
  1146 // ----------------------------------------------------------------------------
       
  1147 //
       
  1148 void CCalenDayContainer::HandleVerticalScrollL( TInt aNewCursor )
       
  1149     {
       
  1150     TRACE_ENTRY_POINT;
       
  1151 
       
  1152     iHighlightedRowNumber = aNewCursor;
       
  1153     ASSERT( iHighlightedRowNumber >= 0 );
       
  1154     iFirstEntryOnScreenIndex = iListBox->TopItemIndex();
       
  1155     SetContextFromHighlightL();
       
  1156 
       
  1157     TRACE_EXIT_POINT;
       
  1158     }
       
  1159 
       
  1160 // ----------------------------------------------------------------------------
       
  1161 // CCalenDayContainer::Draw
       
  1162 // Drawing day name
       
  1163 // (other items were commented in a header).
       
  1164 // ----------------------------------------------------------------------------
       
  1165 //
       
  1166 void CCalenDayContainer::Draw(const TRect& /*aRect*/) const  // Clipping rectangle
       
  1167     {
       
  1168     TRACE_ENTRY_POINT;
       
  1169 
       
  1170     CWindowGc& gc = SystemGc();
       
  1171 
       
  1172     MAknsControlContext* cc =AknsDrawUtils::ControlContext( this );
       
  1173 
       
  1174     if( cc )
       
  1175         {
       
  1176         TRect main_pane( Rect() );
       
  1177 
       
  1178         // To prevent "tearing" (tearing resembles flickering), we don't want to clear
       
  1179         // area under bottom-most skin image (KAknsDrawParamNoClearUnderImage).
       
  1180         // But if bottom-most skin is semitransparent, we need to draw it without alpha channel,
       
  1181         // so that something else doesn't show through it (KAknsDrawParamBottomLevelRGBOnly).
       
  1182         const TInt drawParams = KAknsDrawParamNoClearUnderImage | KAknsDrawParamBottomLevelRGBOnly;
       
  1183         AknsDrawUtils::Background( AknsUtils::SkinInstance(),
       
  1184                                    cc,
       
  1185                                    NULL,
       
  1186                                    gc,
       
  1187                                    main_pane,
       
  1188                                    drawParams);
       
  1189         }
       
  1190 
       
  1191     TRACE_EXIT_POINT;
       
  1192     }
       
  1193 
       
  1194 // ----------------------------------------------------------------------------
       
  1195 // CCalenDayContainer::GetHelpContext
       
  1196 // Gets help context
       
  1197 // (other items were commented in a header).
       
  1198 // ----------------------------------------------------------------------------
       
  1199 //
       
  1200 void CCalenDayContainer::GetHelpContext( TCoeHelpContext& aContext ) const
       
  1201     {
       
  1202     TRACE_ENTRY_POINT;
       
  1203 
       
  1204     aContext.iMajor = KUidCalendar;
       
  1205     // This is specified in HRH file.
       
  1206     aContext.iContext = KCALE_HLP_DAY_VIEW;
       
  1207 
       
  1208     TRACE_EXIT_POINT;
       
  1209     }
       
  1210 
       
  1211 // ----------------------------------------------------------------------------
       
  1212 // CCalenDayContainer::UpdateSize
       
  1213 // Do layout changes after calendar settings are
       
  1214 // changed.  No necessary actions for this view.
       
  1215 // ----------------------------------------------------------------------------
       
  1216 //
       
  1217 void CCalenDayContainer::UpdateSize()
       
  1218     {
       
  1219     TRACE_ENTRY_POINT;
       
  1220 
       
  1221     SizeChanged();
       
  1222 
       
  1223     TRACE_EXIT_POINT;
       
  1224     }
       
  1225 
       
  1226 // ----------------------------------------------------------------------------
       
  1227 // CCalenDayContainer::ConstructImplL
       
  1228 // Third phase constructor.
       
  1229 // This function was called CCalenNativeView::ConstructL().
       
  1230 // (other items were commented in a header).
       
  1231 // ----------------------------------------------------------------------------
       
  1232 //
       
  1233 void CCalenDayContainer::ConstructImplL()
       
  1234     {
       
  1235     TRACE_ENTRY_POINT;
       
  1236 
       
  1237     // 1) Extension plugins
       
  1238   //  InitializeUiExtensionL();
       
  1239 
       
  1240     // 2) Background Skins
       
  1241     iBackgroundSkinContext = CAknsFrameBackgroundControlContext::NewL(
       
  1242         KAknsIIDQsnFrCale, TRect(0,0,0,0), TRect(0,0,0,0), EFalse );
       
  1243 
       
  1244     // 3) Listbox initialization
       
  1245     iListBox = CCalenDayListBox::NewL(this, iServices);
       
  1246     iListBox->SetListBoxObserver( this );
       
  1247 
       
  1248     iListBoxModel = CCalenDayListBoxModel::NewL( this );
       
  1249     CTextListBoxModel* model = iListBox->Model();
       
  1250     model->SetItemTextArray(iListBoxModel->ItemTextArray());
       
  1251     model->SetOwnershipType(ELbmDoesNotOwnItemArray);
       
  1252     
       
  1253     CAknIconArray* iconList = CreateIconsL( iIconIndices );
       
  1254     iListBox->ItemDrawer()->ColumnData()->SetIconArray( iconList );
       
  1255     
       
  1256     iGestureHelper = GestureHelper::CGestureHelper::NewL( *this );
       
  1257     iGestureHelper->SetHoldingEnabled( EFalse );
       
  1258     iGestureHelper->SetDoubleTapEnabled( EFalse );
       
  1259     
       
  1260     TRACE_EXIT_POINT;
       
  1261     }
       
  1262 
       
  1263 // ----------------------------------------------------------------------------
       
  1264 // CCalenDayContainer::NotifyDeleteItemL
       
  1265 // Delete note command notification handler
       
  1266 // (other items were commented in a header).
       
  1267 // ----------------------------------------------------------------------------
       
  1268 //
       
  1269 void CCalenDayContainer::NotifyDeleteItemL()
       
  1270     {
       
  1271     TRACE_ENTRY_POINT;
       
  1272 
       
  1273     iDeletedIndex = iListBox->View()->CurrentItemIndex();
       
  1274 //    CCalenContainer::NotifyDeleteItemL();
       
  1275 
       
  1276     TRACE_EXIT_POINT;
       
  1277     }
       
  1278 
       
  1279 // ----------------------------------------------------------------------------
       
  1280 // CCalenDayContainer::NotifyChangeDateL
       
  1281 // Date cahnge operation notification handler.
       
  1282 // (other items were commented in a header).
       
  1283 // ----------------------------------------------------------------------------
       
  1284 //
       
  1285 void CCalenDayContainer::NotifyChangeDateL()
       
  1286     {
       
  1287     TRACE_ENTRY_POINT;
       
  1288 
       
  1289     TTime newDay = iServices.Context().FocusDateAndTimeL().TimeLocalL();
       
  1290 
       
  1291     if ( ! CalenDateUtils::OnSameDay( iDate, newDay ) )
       
  1292         {
       
  1293         iDate = newDay;
       
  1294         UpdateContainerL();
       
  1295         }
       
  1296     else
       
  1297         {
       
  1298         iListBox->View()->SetDisableRedraw( ETrue );
       
  1299         SetContextFromHighlightL();
       
  1300         iListBox->View()->SetDisableRedraw( EFalse );
       
  1301         iListBox->DrawNow();
       
  1302         }
       
  1303 
       
  1304     TRACE_EXIT_POINT;
       
  1305     }
       
  1306 
       
  1307 // ----------------------------------------------------------------------------
       
  1308 // CCalenDayContainer::MopSupplyObject
       
  1309 // Pass skin information if needed.
       
  1310 // ----------------------------------------------------------------------------
       
  1311 //
       
  1312 TTypeUid::Ptr CCalenDayContainer::MopSupplyObject(TTypeUid aId)
       
  1313     {
       
  1314     TRACE_ENTRY_POINT;
       
  1315 
       
  1316     if(aId.iUid == MAknsControlContext::ETypeId )
       
  1317         {
       
  1318         MAknsControlContext* cc = iBackgroundSkinContext;
       
  1319         if ( !cc ) cc = iBgContext;
       
  1320 
       
  1321         if ( cc )
       
  1322             {
       
  1323             TRACE_EXIT_POINT;
       
  1324             return MAknsControlContext::SupplyMopObject( aId, cc );
       
  1325             }
       
  1326         }
       
  1327 
       
  1328     TRACE_EXIT_POINT;
       
  1329     return CCoeControl::MopSupplyObject( aId );
       
  1330     }
       
  1331 
       
  1332 // ----------------------------------------------------------------------------
       
  1333 // CCalenDayContainer::View
       
  1334 // ?implementation_description
       
  1335 // (other items were commented in a header).
       
  1336 // ----------------------------------------------------------------------------
       
  1337 //
       
  1338 CCalenDayListBoxView* CCalenDayContainer::View()
       
  1339     {
       
  1340     TRACE_ENTRY_POINT;
       
  1341 
       
  1342     TRACE_EXIT_POINT;
       
  1343     return static_cast<CCalenDayListBoxView*>(iListBox->View());
       
  1344     }
       
  1345 
       
  1346 // ----------------------------------------------------------------------------
       
  1347 // CCalenDayContainer::DayView
       
  1348 // ?implementation_description
       
  1349 // (other items were commented in a header).
       
  1350 // ----------------------------------------------------------------------------
       
  1351 //
       
  1352 CCalenDayView& CCalenDayContainer::DayView() const
       
  1353     {
       
  1354     TRACE_ENTRY_POINT;
       
  1355 
       
  1356     TRACE_EXIT_POINT;
       
  1357     return *(static_cast<CCalenDayView*>(iView));
       
  1358     }
       
  1359 
       
  1360 // ----------------------------------------------------------------------------
       
  1361 // CCalenDayContainer::LayoutVariantIndex
       
  1362 // ----------------------------------------------------------------------------
       
  1363 //
       
  1364 TInt CCalenDayContainer::LayoutVariantIndex( TDayLayoutVariant aLayout ) const
       
  1365     {
       
  1366     TRACE_ENTRY_POINT;
       
  1367     
       
  1368     TBitFlags layoutFlags = iLayoutManager->LayoutFlags();
       
  1369 
       
  1370     TInt layoutVariant(ENoLayoutVariantSet);
       
  1371     switch (aLayout)
       
  1372         {
       
  1373         case EListScrollCaleDayPane:
       
  1374             {
       
  1375             if( layoutFlags.IsSet( 
       
  1376                     CCalenContainerLayoutManager::ECalenContainerToolbar ) )
       
  1377                 layoutVariant = 1;
       
  1378             else
       
  1379                 layoutVariant = 0;
       
  1380             break;
       
  1381             }
       
  1382         case EPopupToolbarWindowCp02:
       
  1383             {
       
  1384             if( layoutFlags.IsSet( 
       
  1385                     CCalenContainerLayoutManager::ECalenContainerToolbar ) )
       
  1386                 layoutVariant = 0;
       
  1387             else
       
  1388                 __ASSERT_DEBUG(0, User::Invariant());
       
  1389             break;
       
  1390             }
       
  1391         case EBgCalePane:
       
  1392         case EListCalePane:
       
  1393         case EScrollPaneCp09:
       
  1394             {
       
  1395             if( layoutFlags.IsSet( 
       
  1396                     CCalenContainerLayoutManager::ECalenContainerToolbar ) && 
       
  1397                 layoutFlags.IsSet( 
       
  1398                     CCalenContainerLayoutManager::ECalenContainerInfobar ) )
       
  1399                 layoutVariant = 3;
       
  1400                 
       
  1401             else if( layoutFlags.IsSet( 
       
  1402                     CCalenContainerLayoutManager::ECalenContainerToolbar ) )
       
  1403                 layoutVariant = 2;
       
  1404                 
       
  1405             else if( layoutFlags.IsSet( 
       
  1406                     CCalenContainerLayoutManager::ECalenContainerInfobar ) )
       
  1407                 layoutVariant = 3;
       
  1408             else
       
  1409                 layoutVariant = 0;
       
  1410             break;
       
  1411             }
       
  1412         case EListScrollCaleDayPaneT1:
       
  1413             {
       
  1414             if( layoutFlags.IsSet(
       
  1415                     CCalenContainerLayoutManager::ECalenContainerToolbar ) && 
       
  1416                 layoutFlags.IsSet( 
       
  1417                     CCalenContainerLayoutManager::ECalenContainerInfobar ) )
       
  1418                 layoutVariant = 1;
       
  1419                 
       
  1420             else if( layoutFlags.IsSet( 
       
  1421                     CCalenContainerLayoutManager::ECalenContainerInfobar ) )
       
  1422                 layoutVariant = 0;
       
  1423             else
       
  1424                 __ASSERT_DEBUG(0, User::Invariant());
       
  1425             break;
       
  1426             }
       
  1427          case ENoLayoutVariantSet:
       
  1428             {
       
  1429             ASSERT(EFalse);
       
  1430             break;
       
  1431             }
       
  1432         }
       
  1433 
       
  1434     TRACE_EXIT_POINT;
       
  1435     return layoutVariant;
       
  1436     }
       
  1437 
       
  1438 
       
  1439 // ----------------------------------------------------------------------------
       
  1440 // CCalenDayContainer::HandleLongTapEventL
       
  1441 // processing of a long tap event
       
  1442 // (other items were commented in a header).
       
  1443 // ----------------------------------------------------------------------------
       
  1444 //
       
  1445 void CCalenDayContainer::HandleLongTapEventL( const TPoint& /*aPenEventLocation*/,
       
  1446                                               const TPoint& /*aPenEventScreenLocation*/ )
       
  1447     {
       
  1448     TRACE_ENTRY_POINT;
       
  1449 
       
  1450 
       
  1451     TRACE_EXIT_POINT;
       
  1452     }
       
  1453 
       
  1454 // ----------------------------------------------------------------------------
       
  1455 // CCalenDayContainer::HandlePointerEventL
       
  1456 // ?implementation_description
       
  1457 // (other items were commented in a header).
       
  1458 // ----------------------------------------------------------------------------
       
  1459 //
       
  1460 void CCalenDayContainer::HandlePointerEventL( const TPointerEvent& aPointerEvent )
       
  1461     {
       
  1462     TRACE_ENTRY_POINT;
       
  1463     CCoeControl* control( NULL );
       
  1464 
       
  1465     if(! AknLayoutUtils::PenEnabled() )
       
  1466         {
       
  1467         return;
       
  1468         }
       
  1469     if(iView->IsEventViewLaunchedFromAlarm())
       
  1470         {
       
  1471         return;
       
  1472         }
       
  1473     if(aPointerEvent.iType == TPointerEvent::EButton1Down)
       
  1474         {
       
  1475         this->GenerateTactileFeedback(); //Tactile feedback.
       
  1476         control = iLayoutManager->ControlOrNull();
       
  1477         if(control)
       
  1478             {
       
  1479             if(control->Rect().Contains(aPointerEvent.iPosition))
       
  1480                 {
       
  1481                 control->HandlePointerEventL(aPointerEvent);	
       
  1482                 return;
       
  1483                 }
       
  1484             }
       
  1485         }
       
  1486 		if(iGestureHelper)
       
  1487         {
       
  1488         iGestureHelper->HandlePointerEventL( aPointerEvent );
       
  1489         }
       
  1490 	        	
       
  1491 	        	
       
  1492     TInt pointerIndex(-1);    
       
  1493      // Single click integration
       
  1494     if ( aPointerEvent.iType == TPointerEvent::EButton1Down
       
  1495             && iListBox->View()->XYPosToItemIndex(
       
  1496                     aPointerEvent.iPosition, pointerIndex ) )
       
  1497         {
       
  1498         CCalenDayListBoxView* view =
       
  1499             static_cast<CCalenDayListBoxView*>( iListBox->View() );
       
  1500         TInt pointerItemIndex( view->FirstLineOfCell( pointerIndex ) );
       
  1501         if ( iListBox->CurrentItemIndex() != pointerItemIndex )
       
  1502             {
       
  1503             HandleVerticalScrollL( pointerItemIndex );
       
  1504             }
       
  1505         }
       
  1506     if ( aPointerEvent.iType != TPointerEvent::EButtonRepeat )
       
  1507         {
       
  1508         iListBox->HandlePointerEventL( aPointerEvent );
       
  1509         }
       
  1510 
       
  1511     TRACE_EXIT_POINT;
       
  1512     }
       
  1513 
       
  1514 // ---------------------------------------------------------------------------
       
  1515 // CCalenDayContainer::HandleGestureL
       
  1516 // Handle the gesture event
       
  1517 // ---------------------------------------------------------------------------
       
  1518 //
       
  1519 void CCalenDayContainer::HandleGestureL( const GestureHelper::MGestureEvent& aEvent )
       
  1520     {
       
  1521     TRACE_ENTRY_POINT;
       
  1522     GestureHelper::TGestureCode code = aEvent.Code( GestureHelper::MGestureEvent::EAxisBoth );
       
  1523     
       
  1524     switch ( code )
       
  1525         {
       
  1526         case GestureHelper::EGestureStart:
       
  1527             {
       
  1528             iGestureHandled = EFalse;
       
  1529             break;
       
  1530             }
       
  1531         case GestureHelper::EGestureSwipeRight:
       
  1532             {
       
  1533             //Handle swipe only if event view command
       
  1534             //is not yet handled
       
  1535             if(!DayView().isEventViewCommandHandled())
       
  1536                 {
       
  1537                 HandleNaviDecoratorEventL( EAknNaviDecoratorEventLeftTabArrow );
       
  1538                 iGestureHandled = ETrue;
       
  1539                 }
       
  1540             break;
       
  1541             }
       
  1542         case GestureHelper::EGestureSwipeLeft:
       
  1543             {
       
  1544             //Handle swipe only if event view command
       
  1545             //is not yet handled
       
  1546             if(!DayView().isEventViewCommandHandled())
       
  1547                 {
       
  1548                 HandleNaviDecoratorEventL( EAknNaviDecoratorEventRightTabArrow );
       
  1549                 iGestureHandled = ETrue;
       
  1550                 }
       
  1551             
       
  1552             }
       
  1553             break;
       
  1554         default:
       
  1555             // Other gestures are not handled here
       
  1556             break;
       
  1557         }
       
  1558     
       
  1559     TRACE_EXIT_POINT;
       
  1560     }
       
  1561 // ----------------------------------------------------------------------------
       
  1562 // CCalenDayContainer::HandleNaviDecoratorEventL
       
  1563 // ?implementation_description
       
  1564 // (other items were commented in a header).
       
  1565 // ----------------------------------------------------------------------------
       
  1566 //
       
  1567 void CCalenDayContainer::HandleNaviDecoratorEventL( TInt aEventID )
       
  1568     {
       
  1569     TRACE_ENTRY_POINT;
       
  1570 
       
  1571     if(AknLayoutUtils::PenEnabled())
       
  1572         {
       
  1573         TInt direction(0);
       
  1574         if(aEventID == EAknNaviDecoratorEventLeftTabArrow)
       
  1575                     {
       
  1576                     if(AknLayoutUtils::LayoutMirrored())
       
  1577                         direction = 1;
       
  1578                     else
       
  1579                         direction = -1;
       
  1580                     }
       
  1581                     
       
  1582                 else if(aEventID == EAknNaviDecoratorEventRightTabArrow)
       
  1583                     { 
       
  1584                     if(AknLayoutUtils::LayoutMirrored())
       
  1585                          direction = -1;
       
  1586                     else
       
  1587                          direction = 1;
       
  1588                     }
       
  1589         else
       
  1590             return;
       
  1591 
       
  1592         HandleHorizontalScrollL(TTimeIntervalDays(direction));
       
  1593         }
       
  1594 
       
  1595     TRACE_EXIT_POINT;
       
  1596     }
       
  1597 
       
  1598 
       
  1599 #ifdef RD_CALEN_MIDNIGHT_VISUALIZATION
       
  1600 void CCalenDayContainer::GetMidnightVisualizationL()
       
  1601     {
       
  1602     TRACE_ENTRY_POINT;
       
  1603 
       
  1604     iMidnight = EFalse;
       
  1605     TTime focusedDayBeginning = CalenDateUtils::BeginningOfDay(iDate);
       
  1606     TTime focusedDayEnd = focusedDayBeginning + TTimeIntervalDays(1);
       
  1607 
       
  1608     TInt count = iInstanceList.Count();
       
  1609     for(TInt i = 0; i < count; ++i )
       
  1610         {
       
  1611         CCalInstance* instance = iInstanceList[i];
       
  1612         if((instance->StartTimeL().TimeLocalL() < focusedDayBeginning)
       
  1613         || (instance->EndTimeL().TimeLocalL() > focusedDayEnd))
       
  1614             {
       
  1615             iMidnight = ETrue;
       
  1616             break;
       
  1617             }
       
  1618         }
       
  1619 
       
  1620     TRACE_EXIT_POINT;
       
  1621     }
       
  1622 
       
  1623 TBool CCalenDayContainer::IsMidnightVisualization() const
       
  1624     {
       
  1625     TRACE_ENTRY_POINT;
       
  1626 
       
  1627     TRACE_EXIT_POINT;
       
  1628     return iMidnight;
       
  1629     }
       
  1630 
       
  1631 #endif // RD_CALEN_MIDNIGHT_VISUALIZATION
       
  1632 
       
  1633 // ----------------------------------------------------------------------------
       
  1634 // CCalenDayContainer::GetInstanceListL
       
  1635 // Get instances for day. List of instances is processed during construction
       
  1636 // of list box data and destroyed once it's done.
       
  1637 // Step 1 of construction of listbox data.
       
  1638 // ----------------------------------------------------------------------------
       
  1639 //
       
  1640 void CCalenDayContainer::GetInstanceListL()
       
  1641     {
       
  1642     TRACE_ENTRY_POINT;
       
  1643 
       
  1644     iInstanceList.ResetAndDestroy();
       
  1645 
       
  1646     iDateWasNull = iDate == Time::NullTTime();
       
  1647     iDate = CCalenContainer::DateFromContextL( iServices.Context() );
       
  1648     iDateWasNull = EFalse;
       
  1649     
       
  1650     RArray<TInt> colIdArray;
       
  1651     CCalenNativeView::GetActiveCollectionidsL( iServices, colIdArray );
       
  1652     
       
  1653     if(colIdArray.Count() > 0)
       
  1654           {
       
  1655           CalenAgendaUtils::CreateEntryIdListForDayL( iInstanceList,
       
  1656                                                 iServices.InstanceViewL(colIdArray),
       
  1657                                                 iDate );          
       
  1658           }
       
  1659     else
       
  1660         {
       
  1661         CalenAgendaUtils::CreateEntryIdListForDayL( iInstanceList,
       
  1662                                                       iServices.InstanceViewL(),
       
  1663                                                       iDate );
       
  1664         }
       
  1665     colIdArray.Reset();
       
  1666     TRACE_EXIT_POINT;
       
  1667     }
       
  1668 
       
  1669 // ----------------------------------------------------------------------------
       
  1670 // CCalenDayContainer::CreateSlotTableL
       
  1671 // Setup layout table. Step 2 of construction of listbox data
       
  1672 // (other items were commented in a header).
       
  1673 // ----------------------------------------------------------------------------
       
  1674 //
       
  1675 void CCalenDayContainer::CreateSlotTableL()
       
  1676     {
       
  1677     TRACE_ENTRY_POINT;
       
  1678 
       
  1679     // Init layoyt table
       
  1680     delete iLayoutTable;
       
  1681     iLayoutTable = NULL;
       
  1682     iLayoutTable = new( ELeave )CArrayFixFlat<SItemInfo>( KLayoutTableGranularity );
       
  1683     
       
  1684         // Process non-timed entries second
       
  1685     for ( TInt instanceIndex = 0; instanceIndex < iInstanceList.Count(); ++instanceIndex )
       
  1686         {
       
  1687         CCalInstance* instance = iInstanceList[ instanceIndex ];
       
  1688         if ( ! CalenAgendaUtils::IsTimedEntryL( instance->Entry().EntryTypeL()) 
       
  1689             && (!CalenViewUtils::IsAlldayEventL( *instance))  )
       
  1690             {
       
  1691             SItemInfo itemInfo;
       
  1692             itemInfo.iId = TCalenInstanceId::CreateL( *instance );
       
  1693             itemInfo.iStartTime = TTimeIntervalMinutes( KNullMinutes );
       
  1694             itemInfo.iTimedNote = EFalse;
       
  1695             itemInfo.iTopLine = KErrNotFound;
       
  1696 
       
  1697             itemInfo.iTmpInstance = instance;
       
  1698 
       
  1699             iLayoutTable->AppendL( itemInfo );
       
  1700             }
       
  1701         }
       
  1702     
       
  1703     // Process Alldayevent timed entries first
       
  1704     for ( TInt instanceIndex = 0; instanceIndex < iInstanceList.Count(); ++instanceIndex )
       
  1705         {
       
  1706         CCalInstance* instance = iInstanceList[ instanceIndex ];
       
  1707         if( (instance->Entry().EntryTypeL() == CCalEntry::EAppt
       
  1708              || instance->Entry().EntryTypeL() == CCalEntry::EEvent) 
       
  1709              && (CalenViewUtils::IsAlldayEventL( *instance)) )
       
  1710             {
       
  1711             TTime start = instance->Time().TimeLocalL();
       
  1712             SItemInfo itemInfo;
       
  1713             itemInfo.iId = TCalenInstanceId::CreateL( *instance );
       
  1714             itemInfo.iStartTime = CalenDateUtils::TimeOfDay( start );
       
  1715             itemInfo.iTimedNote = EFalse;
       
  1716             itemInfo.iTopLine = KErrNotFound;
       
  1717             itemInfo.iTmpInstance = instance;
       
  1718 
       
  1719             iLayoutTable->AppendL( itemInfo );
       
  1720             }
       
  1721         }
       
  1722 
       
  1723 
       
  1724     // Process timed entries second
       
  1725     for ( TInt instanceIndex = 0; instanceIndex < iInstanceList.Count(); ++instanceIndex )
       
  1726         {
       
  1727         CCalInstance* instance = iInstanceList[ instanceIndex ];
       
  1728         if ( ( CalenAgendaUtils::IsTimedEntryL( instance->Entry().EntryTypeL() ) )
       
  1729              && ( !CalenViewUtils::IsAlldayEventL( *instance ) ) ) 
       
  1730             {
       
  1731             TTime start = instance->Time().TimeLocalL();
       
  1732 
       
  1733             SItemInfo itemInfo;
       
  1734             itemInfo.iId = TCalenInstanceId::CreateL( *instance );
       
  1735             itemInfo.iStartTime = CalenDateUtils::TimeOfDay( start );
       
  1736             itemInfo.iTimedNote = ETrue;
       
  1737             itemInfo.iTopLine = KErrNotFound;
       
  1738 
       
  1739             itemInfo.iTmpInstance = instance;
       
  1740 
       
  1741             iLayoutTable->AppendL( itemInfo );
       
  1742             }
       
  1743         }
       
  1744 
       
  1745     TRACE_EXIT_POINT;
       
  1746     }
       
  1747 
       
  1748 // ----------------------------------------------------------------------------
       
  1749 // CCalenDayContainer::CompletePopulationL
       
  1750 // Completes population. Third and last stage stage of population.
       
  1751 // (other items were commented in a header).
       
  1752 // ----------------------------------------------------------------------------
       
  1753 //
       
  1754 void CCalenDayContainer::CompletePopulationL()
       
  1755     {
       
  1756     TRACE_ENTRY_POINT;
       
  1757 
       
  1758     CreateListBoxDataL();
       
  1759     AddToStackAndMakeVisibleL();
       
  1760     UpdateStatusPaneAndExtensionsL();
       
  1761 	// Hide/unhide "today" toolbar item based on the focused day
       
  1762     UpdateTodayToolbarItemL();
       
  1763     DrawNow();
       
  1764     TRACE_EXIT_POINT;
       
  1765     }
       
  1766     
       
  1767 // ----------------------------------------------------------------------------
       
  1768 // CCalenDayContainer::CreateIconIndicesL
       
  1769 // Create icon index for day view
       
  1770 // ----------------------------------------------------------------------------
       
  1771 //
       
  1772 void CCalenDayContainer::CreateIconIndicesL( RArray<MCalenServices::TCalenIcons>& aIndexArray )
       
  1773     {
       
  1774     TRACE_ENTRY_POINT;
       
  1775     // Icons needed for the day view
       
  1776     aIndexArray.Reset();
       
  1777     aIndexArray.AppendL( MCalenServices::ECalenBirthdayIcon );
       
  1778     aIndexArray.AppendL( MCalenServices::ECalenMeetingIcon );
       
  1779     aIndexArray.AppendL( MCalenServices::ECalenDaynoteIcon );
       
  1780     aIndexArray.AppendL( MCalenServices::ECalenToDoIcon );
       
  1781     aIndexArray.AppendL( MCalenServices::ECalenAlarmIcon );
       
  1782     aIndexArray.AppendL( MCalenServices::ECalenRepeatIcon );
       
  1783     aIndexArray.AppendL( MCalenServices::ECalenRepeatExceptionIcon );
       
  1784     aIndexArray.AppendL( MCalenServices::ECalenNotePriorityLow );
       
  1785     aIndexArray.AppendL( MCalenServices::ECalenNotePriorityHigh );
       
  1786     aIndexArray.AppendL( MCalenServices::ECalenMapIcon );
       
  1787 
       
  1788     TRACE_EXIT_POINT;
       
  1789     }
       
  1790 
       
  1791 // ----------------------------------------------------------------------------
       
  1792 // CCalenDayContainer::InfoBarRectL
       
  1793 // Returns the available info bar rect for this container
       
  1794 // ----------------------------------------------------------------------------
       
  1795 TRect CCalenDayContainer::InfoBarRectL( TBool aToolbarAvailable )
       
  1796     {
       
  1797     TRACE_ENTRY_POINT;
       
  1798    
       
  1799     // Get the main pane
       
  1800     TAknLayoutRect main_cale_day_pane;
       
  1801     main_cale_day_pane.LayoutRect( Rect(), 
       
  1802                     AknLayoutScalable_Apps::main_cale_day_pane().LayoutLine() );
       
  1803         
       
  1804     TAknLayoutRect listscroll_cale_day_pane;
       
  1805     listscroll_cale_day_pane.LayoutRect( main_cale_day_pane.Rect(), 
       
  1806             AknLayoutScalable_Apps::listscroll_cale_day_pane(1).LayoutLine() );
       
  1807 
       
  1808     // Create a dummy label to find the layout rect
       
  1809     CEikLabel* dummyLabel = new( ELeave ) CEikLabel;
       
  1810     CleanupStack::PushL( dummyLabel );
       
  1811 
       
  1812     // Get the layout variant for the month view infobar.
       
  1813     // We assume that we have one for this check, as we need to
       
  1814     // find the size that would be available if we do have one.
       
  1815     TInt layoutVariant = 0;
       
  1816     if( aToolbarAvailable )
       
  1817         {
       
  1818         layoutVariant = 1;
       
  1819         }
       
  1820     else
       
  1821         {
       
  1822         layoutVariant = 0;
       
  1823         }
       
  1824            
       
  1825     AknLayoutUtils::LayoutLabel( dummyLabel, listscroll_cale_day_pane.Rect(),
       
  1826         AknLayoutScalable_Apps::listscroll_cale_day_pane_t1( layoutVariant ).LayoutLine() );        
       
  1827               
       
  1828     TRect infoRect = dummyLabel->Rect();
       
  1829 
       
  1830     // Discard the label
       
  1831     CleanupStack::PopAndDestroy( dummyLabel );
       
  1832     
       
  1833     TRACE_EXIT_POINT;
       
  1834     return infoRect;
       
  1835     }
       
  1836     
       
  1837 // ----------------------------------------------------------------------------
       
  1838 // CCalenDayContainer::PreviewRectL
       
  1839 // Returns an empty rect - Day view does not support preview pane
       
  1840 // ----------------------------------------------------------------------------
       
  1841 TRect CCalenDayContainer::PreviewRectL()
       
  1842     {
       
  1843     TRACE_ENTRY_POINT;
       
  1844 
       
  1845     TRect rect;
       
  1846 
       
  1847     TRACE_EXIT_POINT;
       
  1848     return rect;
       
  1849     }
       
  1850 
       
  1851 // ----------------------------------------------------------------------------
       
  1852 // CCalenDayContainer::IsEventHasMapLocationL
       
  1853 // Stores the necessary information in the context
       
  1854 // and returns ETrue if event has geo coordinates else EFalse
       
  1855 // ----------------------------------------------------------------------------
       
  1856 TBool CCalenDayContainer::IsEventHasMapLocationL()
       
  1857 	{
       
  1858 	TRACE_ENTRY_POINT;
       
  1859 	MCalenContext& context = iServices.Context();
       
  1860 	TCalLocalUid instanceId = context.InstanceId().iEntryLocalUid;
       
  1861 	
       
  1862 	CCalEntry* entry = iServices.EntryViewL(context.InstanceId().iColId)->FetchL(instanceId);
       
  1863 	CleanupStack::PushL(entry);
       
  1864 	CCalGeoValue* geoValue = entry->GeoValueL();
       
  1865 	CleanupStack::PopAndDestroy(entry);
       
  1866 	if(geoValue)
       
  1867 		{
       
  1868 		delete geoValue;
       
  1869 		// Event has saved map location, put "Show on Map"
       
  1870 		TRACE_EXIT_POINT;
       
  1871 		return 	ETrue;
       
  1872 		}
       
  1873 	else
       
  1874 		{
       
  1875 		TRACE_EXIT_POINT;
       
  1876 		return EFalse;
       
  1877 		}
       
  1878 	}
       
  1879 	
       
  1880 // ----------------------------------------------------------------------------
       
  1881 // CCalenDayContainer::IsEventHasNoLocationTextL
       
  1882 // Returns ETrue if event has location text else EFalse
       
  1883 // ----------------------------------------------------------------------------
       
  1884 TBool CCalenDayContainer::IsEventHasNoLocationTextL()
       
  1885 	{
       
  1886 	TRACE_ENTRY_POINT;
       
  1887 	MCalenContext& context = iServices.Context();
       
  1888 	TCalLocalUid instanceId = context.InstanceId().iEntryLocalUid;
       
  1889 	
       
  1890 	CCalEntry* entry = iServices.EntryViewL(context.InstanceId().iColId)->FetchL(instanceId);
       
  1891 	CleanupStack::PushL(entry);
       
  1892 	TPtrC location = entry->LocationL();
       
  1893 	
       
  1894 	TBool ret = EFalse;
       
  1895 	if(!location.Length())
       
  1896 		{
       
  1897 		ret = ETrue;
       
  1898 		}
       
  1899 	CleanupStack::PopAndDestroy(entry);
       
  1900 	TRACE_EXIT_POINT;
       
  1901 	return ret;
       
  1902 	}
       
  1903 // ----------------------------------------------------------------------------
       
  1904 // CCalenDayContainer::IsValidEntryL()
       
  1905 // Check whether entry exists or not
       
  1906 // ----------------------------------------------------------------------------
       
  1907 TBool CCalenDayContainer::IsValidEntryL()
       
  1908     {
       
  1909     TRACE_ENTRY_POINT;
       
  1910     
       
  1911     MCalenContext& context = iServices.Context();
       
  1912     TCalLocalUid instanceId = context.InstanceId().iEntryLocalUid;
       
  1913         
       
  1914     CCalEntry* entry = iServices.EntryViewL(context.InstanceId().iColId)->FetchL(instanceId);
       
  1915     CleanupStack::PushL(entry);
       
  1916     TBool iSEntry(EFalse);
       
  1917     if(entry)
       
  1918         {
       
  1919         iSEntry = ETrue;
       
  1920         }
       
  1921     else 
       
  1922         {
       
  1923         iSEntry = EFalse;
       
  1924         }
       
  1925     CleanupStack::PopAndDestroy(entry);
       
  1926     TRACE_EXIT_POINT;
       
  1927     return iSEntry;
       
  1928     }
       
  1929 // End of File