calendarui/views/src/calentodocontainer.cpp
changeset 0 f979ecb2b13e
child 19 1984aceb8774
equal deleted inserted replaced
-1:000000000000 0:f979ecb2b13e
       
     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:  Container for To-Do view's controls.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include <AknIconArray.h>
       
    21 #include <aknlists.h>
       
    22 #include <AknsUtils.h>
       
    23 #include <avkon.mbg>
       
    24 #include <calalarm.h>
       
    25 #include <calentry.h>
       
    26 #include <calinstance.h>
       
    27 #include <data_caging_path_literals.hrh>
       
    28 #include <eikclbd.h>
       
    29 #include <eikmenub.h>
       
    30 #include <gulicon.h>
       
    31 #include <StringLoader.h>
       
    32 #include <aknlayoutscalable_avkon.cdl.h>
       
    33 #include <barsread.h>
       
    34 #include <calencontext.h>
       
    35 #include <aknlayoutscalable_apps.cdl.h>
       
    36 #include <AknsFrameBackgroundControlContext.h>
       
    37 #include <centralrepository.h>
       
    38 #include <caleninstanceid.h>
       
    39 #include <calenviewutils.h>
       
    40 #include <calenservices.h>
       
    41 #include <calendateutils.h>
       
    42 #include <calenagendautils.h>
       
    43 #include <calendar.mbg>
       
    44 #include <Calendar.rsg>
       
    45 #include <csxhelp/cale.hlp.hrh> // For help context of ToDo
       
    46 #include <calcalendarinfo.h>
       
    47 
       
    48 #include "calendarui_debug.h"
       
    49 #include "calentodoview.h"
       
    50 #include "calentodocontainer.h"
       
    51 #include "calentodocontroller.h"
       
    52 #include "calencontainerlayoutmanager.h" // CCalenContainerLayoutManager
       
    53 #include "calencontroller.h"
       
    54 #include "CalendarPrivateCRKeys.h"
       
    55 #include "calenglobaldata.h"
       
    56 #include "calendar.hrh"
       
    57 #include "CalenUid.h"
       
    58 #include "calenicons.h"
       
    59 
       
    60 // LOCAL CONSTANTS AND MACROS
       
    61 const TInt KListDataLength(100);
       
    62 const TInt KListDataLengthOfSubject(60);
       
    63 
       
    64 _LIT( KTaskStateFormat, "%d\t" );
       
    65 _LIT( KListSeparatorFormat, "\t" );
       
    66 _LIT( KIconSeparatorFormat, " \t%d" );
       
    67 _LIT( KSpaceText, " " );
       
    68 
       
    69 
       
    70 // LOCAL FUNCTIONS
       
    71 
       
    72 // ----------------------------------------------------------------------------
       
    73 // Check the date of todo entry is valid
       
    74 // ----------------------------------------------------------------------------
       
    75 //
       
    76 static TBool IsValidDueDateL(CCalInstance* aInstance)
       
    77     {
       
    78     TRACE_ENTRY_POINT;
       
    79 
       
    80     CCalEntry& entry = aInstance->Entry();
       
    81 
       
    82     if( entry.EntryTypeL() == CCalEntry::ETodo )
       
    83         {
       
    84         TTime endTime = entry.EndTimeL().TimeLocalL();
       
    85 
       
    86         if( endTime != Time::NullTTime() )
       
    87             {
       
    88             TRACE_EXIT_POINT;
       
    89             return CalenDateUtils::IsValidDay( endTime );
       
    90             }
       
    91         }
       
    92 
       
    93     TRACE_EXIT_POINT;
       
    94     return EFalse; // The due date is NULL or entry is not Todo entry
       
    95     }
       
    96 
       
    97 
       
    98 // ================= MEMBER FUNCTIONS =======================
       
    99 
       
   100 // ----------------------------------------------------------------------------
       
   101 // CCalenTodoListBoxItemDrawer::CCalenTodoListBoxItemDrawer
       
   102 // ----------------------------------------------------------------------------
       
   103 //
       
   104 CCalenTodoListBoxItemDrawer::CCalenTodoListBoxItemDrawer( MTextListBoxModel* aTextListBoxModel,
       
   105                                                                  const CFont* aFont,
       
   106                                                                  CColumnListBoxData* aFormattedCellData,
       
   107                                                                  CEikListBox* aListBox ,
       
   108                                                                  const RArray<TInt>& aColorUidArray)
       
   109     :CSingleHeadingStyleItemDrawer(aTextListBoxModel, aFont, aFormattedCellData),
       
   110      iListBox( aListBox ),
       
   111      iColorUidArray(aColorUidArray)
       
   112     {
       
   113     TRACE_ENTRY_POINT
       
   114     TRACE_EXIT_POINT
       
   115     }
       
   116 
       
   117 
       
   118 // ----------------------------------------------------------------------------
       
   119 // CCalenTodoListBoxItemDrawer::~CCalenTodoListBoxItemDrawer
       
   120 // ----------------------------------------------------------------------------
       
   121 //
       
   122 CCalenTodoListBoxItemDrawer::~CCalenTodoListBoxItemDrawer()
       
   123     {
       
   124     TRACE_ENTRY_POINT
       
   125     TRACE_ENTRY_POINT
       
   126     }
       
   127 
       
   128 // ----------------------------------------------------------------------------
       
   129 // CCalenTodoListBoxItemDrawer::DrawItem
       
   130 // ----------------------------------------------------------------------------
       
   131 //
       
   132 void CCalenTodoListBoxItemDrawer::DrawItem(TInt aItemIndex, 
       
   133                                                 TPoint aItemRectPos, 
       
   134                                                 TBool aItemIsSelected, 
       
   135                                                 TBool aItemIsCurrent, 
       
   136                                                 TBool aViewIsEmphasized,
       
   137                                                 TBool aViewIsDimmed) const
       
   138     {
       
   139     TRACE_ENTRY_POINT
       
   140     TRect actualItemRect(aItemRectPos, iItemCellSize);
       
   141     
       
   142     SetupGc(aItemIndex);
       
   143     
       
   144     CSingleHeadingStyleItemDrawer::DrawItem(aItemIndex,
       
   145                                              aItemRectPos,
       
   146                                              aItemIsSelected,
       
   147                                              aItemIsCurrent,
       
   148                                              aViewIsEmphasized,
       
   149                                              aViewIsDimmed);
       
   150     
       
   151     
       
   152     
       
   153 
       
   154     TAknWindowComponentLayout tempLayout = 
       
   155             AknLayoutScalable_Apps::list_cale_time_pane_g6( aItemIndex - static_cast<CCalenTodoListBox*>(iListBox)->TopItemIndex()) ;     
       
   156     
       
   157     TAknLayoutRect colourstrips;
       
   158     colourstrips.LayoutRect( actualItemRect, tempLayout.LayoutLine() );
       
   159       
       
   160      iGc->SetPenColor( CGraphicsContext::ENullPen );
       
   161      iGc->DrawRect( colourstrips.Rect() );
       
   162      iGc->SetBrushStyle( CGraphicsContext::ESolidBrush );
       
   163      iGc->SetBrushColor( TRgb(iColorUidArray[aItemIndex] ));
       
   164      iGc->DrawRect( colourstrips.Rect() );
       
   165  
       
   166     TRACE_EXIT_POINT 
       
   167     }
       
   168 
       
   169 // ----------------------------------------------------------------------------
       
   170 // CCalenTodoListBox::CCalenTodoListBox
       
   171 // ----------------------------------------------------------------------------
       
   172 //
       
   173 CCalenTodoListBox::CCalenTodoListBox(const RArray<TInt>& aColorUidArray) :
       
   174                                                             iColorUidArray(aColorUidArray)    
       
   175     {
       
   176     TRACE_ENTRY_POINT
       
   177     TRACE_EXIT_POINT
       
   178     }
       
   179 
       
   180 // ----------------------------------------------------------------------------
       
   181 // CCalenTodoListBox::CreateItemDrawerL
       
   182 // ----------------------------------------------------------------------------
       
   183 //
       
   184 void CCalenTodoListBox::CreateItemDrawerL()
       
   185     {
       
   186     TRACE_ENTRY_POINT
       
   187     CColumnListBoxData* listboxData = CColumnListBoxData::NewL();
       
   188     CleanupStack::PushL( listboxData );
       
   189     iItemDrawer = new ( ELeave) CCalenTodoListBoxItemDrawer( Model(),
       
   190                                                              iEikonEnv->NormalFont(),
       
   191                                                              listboxData,
       
   192                                                              this ,
       
   193                                                              iColorUidArray);
       
   194     CleanupStack::Pop( listboxData );
       
   195     TRACE_EXIT_POINT
       
   196     }
       
   197 
       
   198 // ----------------------------------------------------------------------------
       
   199 // CCalenTodoListBox::SizeChangedL
       
   200 // ----------------------------------------------------------------------------
       
   201 //
       
   202 void CCalenTodoListBox::SizeChangedL()
       
   203     {
       
   204     //Pass to base class 
       
   205     CAknSingleGraphicHeadingStyleListBox::SizeChanged();
       
   206     
       
   207     //Reposition the listbox column items 
       
   208     TAknWindowComponentLayout itemGraphic1 = AknLayoutScalable_Avkon::list_single_graphic_heading_pane_g1( 0 );
       
   209     TAknWindowLineLayout windowLineLayout1 = itemGraphic1.LayoutLine();
       
   210     windowLineLayout1.il += 30;
       
   211     itemGraphic1 = windowLineLayout1;
       
   212     
       
   213     ItemDrawer()->ColumnData()->SetStretchableGraphicSubCellL(0,itemGraphic1,
       
   214                                     AknLayoutScalable_Avkon::list_single_graphic_heading_pane_vc_g1( 0 ));
       
   215     
       
   216     
       
   217     TAknTextComponentLayout itemText1 =  AknLayoutScalable_Avkon::list_single_graphic_heading_pane_t2( 0 );
       
   218     TAknTextLineLayout textLineLayout1 = itemText1.LayoutLine();
       
   219     textLineLayout1.il += 30;
       
   220     itemText1 = textLineLayout1;
       
   221     
       
   222     ItemDrawer()->ColumnData()->SetStretchableTextSubCellL(1,itemText1, 
       
   223                                    AknLayoutScalable_Avkon::list_single_graphic_heading_pane_vc_t2( 0 ));
       
   224     
       
   225     //further reposition if required for other columns
       
   226     
       
   227     //TAknTextComponentLayout itemText2 = AknLayoutScalable_Avkon::list_single_graphic_heading_pane_t1( 0 );
       
   228     //TAknTextComponentLayout itemText2Stretch  = AknLayoutScalable_Avkon::list_single_graphic_heading_pane_vc_t1( 0 );
       
   229     }
       
   230 
       
   231 // ----------------------------------------------------------------------------
       
   232 // CCalenTodoListBox::SizeChanged
       
   233 // ----------------------------------------------------------------------------
       
   234 //
       
   235 void CCalenTodoListBox::SizeChanged()
       
   236     {
       
   237     TRACE_ENTRY_POINT
       
   238     TRAP_IGNORE(SizeChangedL());
       
   239     TRACE_EXIT_POINT
       
   240     }
       
   241 
       
   242 // ----------------------------------------------------------------------------
       
   243 // CCalenTodoListBox::MakeViewClassInstanceL
       
   244 // ----------------------------------------------------------------------------
       
   245 //
       
   246 CListBoxView* CCalenTodoListBox::MakeViewClassInstanceL()
       
   247     {
       
   248     TRACE_ENTRY_POINT
       
   249     TRACE_EXIT_POINT
       
   250     return new(ELeave) CSingleHeadingStyleView;
       
   251     }
       
   252 
       
   253 // ----------------------------------------------------------------------------
       
   254 // CCalenTodoContainer::CCalenTodoContainer
       
   255 // C++ constructor.
       
   256 // ----------------------------------------------------------------------------
       
   257 //
       
   258 CCalenTodoContainer::CCalenTodoContainer( CCalenNativeView* aView,
       
   259                                           TInt& aHighlightedRowNumber,
       
   260                                           TInt& aFirstEntryOnScreenIndex,
       
   261                                           MCalenServices& aServices )
       
   262     : CCalenContainer( aView, aServices ),
       
   263       iHighlightedRowNumber( aHighlightedRowNumber ),
       
   264       iFirstEntryOnScreenIndex( aFirstEntryOnScreenIndex )
       
   265     {
       
   266     TRACE_ENTRY_POINT;
       
   267     TRACE_EXIT_POINT;
       
   268     }
       
   269 
       
   270 // ----------------------------------------------------------------------------
       
   271 // CCalenTodoContainer::~CCalenTodoContainer
       
   272 // Destructor
       
   273 // ----------------------------------------------------------------------------
       
   274 //
       
   275 CCalenTodoContainer::~CCalenTodoContainer()
       
   276     {
       
   277     TRACE_ENTRY_POINT;
       
   278     delete iController;
       
   279     delete iDesArray;
       
   280     delete iListBox;
       
   281     delete iEmptyListText;
       
   282     
       
   283     iColorUidArray.Close();
       
   284     TRACE_EXIT_POINT;
       
   285     }
       
   286 	
       
   287 // ---------------------------------------------------------
       
   288 // CToDoContainer::HandleListBoxEventL
       
   289 // Handle events incoming from list instance. 
       
   290 // ---------------------------------------------------------
       
   291 //
       
   292 void CCalenTodoContainer::HandleListBoxEventL( CEikListBox* /*aListBox*/,
       
   293                                           TListBoxEvent aEventType)
       
   294     {
       
   295     TRACE_ENTRY_POINT;
       
   296     switch( aEventType )
       
   297         {
       
   298         case EEventItemSingleClicked:
       
   299         case EEventEnterKeyPressed:
       
   300             {
       
   301             if(iView->MenuBar()->IsDisplayed() == EFalse )
       
   302                 {
       
   303                  // Single click integration
       
   304                 if( MarkedCount() )
       
   305                     {
       
   306                     // display the context sensitive menu
       
   307                     /*CEikMenuBar* menuBar = iView->MenuBar();
       
   308                     menuBar->SetContextMenuTitleResourceId(
       
   309                             R_TODO_LIST_SELECTION_CONTEXT_MENUBAR );
       
   310                     menuBar->TryDisplayContextMenuBarL();*/
       
   311                     }
       
   312                 else
       
   313                     {
       
   314                     static_cast<CCalenTodoView*>( iView )->HandleCommandL(
       
   315                             ECalenViewCurrentEntry );
       
   316                     }
       
   317                 }
       
   318             break;
       
   319             }
       
   320         default:
       
   321             break;
       
   322         }
       
   323     TRACE_EXIT_POINT;
       
   324     }	
       
   325 
       
   326 // ----------------------------------------------------------------------------
       
   327 // CCalenTodoContainer::Controller
       
   328 // Return pointer of controler for Agenda server.
       
   329 // ----------------------------------------------------------------------------
       
   330 //
       
   331 CCalenTodoController* CCalenTodoContainer::Controller()
       
   332     {
       
   333     TRACE_ENTRY_POINT;
       
   334 
       
   335     TRACE_EXIT_POINT;
       
   336     return iController;
       
   337     }
       
   338 
       
   339 // ----------------------------------------------------------------------------
       
   340 // CCalenTodoContainer::CurrentItemIndex
       
   341 // Return a focused item index.
       
   342 // (other items were commented in a header).
       
   343 // ----------------------------------------------------------------------------
       
   344 //
       
   345 TInt CCalenTodoContainer::CurrentItemIndex() const
       
   346     {
       
   347     TRACE_ENTRY_POINT;
       
   348 
       
   349     TInt index( KErrNotFound );
       
   350 
       
   351     if( iListBox->Model()->NumberOfItems() )
       
   352         {
       
   353         index = iListBox->CurrentItemIndex();
       
   354         }
       
   355 
       
   356     TRACE_EXIT_POINT;
       
   357     return index;
       
   358     }
       
   359 
       
   360 // ----------------------------------------------------------------------------
       
   361 // CCalenTodoContainer::ConstructImplL
       
   362 // Third phase constructor.
       
   363 // (other items were commented in a header).
       
   364 // ----------------------------------------------------------------------------
       
   365 //
       
   366 void CCalenTodoContainer::ConstructImplL()
       
   367     {
       
   368     TRACE_ENTRY_POINT;
       
   369 
       
   370     iController = new( ELeave )CCalenTodoController( iServices );
       
   371     iController->ConstructL();
       
   372 
       
   373     iDesArray = new (ELeave) CDesCArrayFlat(5);
       
   374     iListBox = new (ELeave) CCalenTodoListBox(iColorUidArray);
       
   375     iListBox->SetContainerWindowL( *this );
       
   376     iListBox->ConstructL(this, EAknListBoxMarkableList);
       
   377     iListBox->SetListBoxObserver( this );
       
   378 
       
   379     // Create scroll bar
       
   380     iListBox->CreateScrollBarFrameL(ETrue);
       
   381     iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(
       
   382         CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
       
   383 
       
   384     CTextListBoxModel* model = iListBox->Model();
       
   385     model->SetItemTextArray(iDesArray);
       
   386     model->SetOwnershipType(ELbmDoesNotOwnItemArray);
       
   387 
       
   388     CAknIconArray* iconList = CreateIconsL( iIconIndices );
       
   389 
       
   390     // Transfer iconlist ownership to the listbox
       
   391     iListBox->ItemDrawer()->ColumnData()->SetIconArray( iconList );
       
   392 
       
   393     // Save empty text and set null for list box.
       
   394     // It is made not to display "No data".
       
   395     iEmptyListText = iListBox->View()->EmptyListText()->AllocL();
       
   396     iListBox->View()->SetListEmptyTextL( KNullDesC );
       
   397 
       
   398     TRACE_EXIT_POINT;
       
   399     }
       
   400 
       
   401 // ----------------------------------------------------------------------------
       
   402 // CCalenTodoContainer::SetCurrentItemIndex
       
   403 // Set current item index.
       
   404 // (other items were commented in a header).
       
   405 // ----------------------------------------------------------------------------
       
   406 //
       
   407 void CCalenTodoContainer::SetCurrentItemIndex(TInt aIndex)
       
   408     {
       
   409     TRACE_ENTRY_POINT;
       
   410 
       
   411     TInt count( iController->Count() );
       
   412 
       
   413     if( aIndex < count )
       
   414         {
       
   415         iHighlightedRowNumber = aIndex;
       
   416         }
       
   417     else
       
   418         {
       
   419         iHighlightedRowNumber = count -1;
       
   420         }
       
   421 
       
   422     TRACE_EXIT_POINT;
       
   423     }
       
   424 
       
   425 // ----------------------------------------------------------------------------
       
   426 // CCalenTodoContainer::ListBox
       
   427 // Return list box pointer.
       
   428 // ----------------------------------------------------------------------------
       
   429 //
       
   430 CEikColumnListBox* CCalenTodoContainer::ListBox() const
       
   431     {
       
   432     TRACE_ENTRY_POINT;
       
   433 
       
   434     TRACE_EXIT_POINT;
       
   435     return iListBox;
       
   436     }
       
   437 
       
   438 // ----------------------------------------------------------------------------
       
   439 // CCalenTodoContainer::MarkedCount
       
   440 // Return marked count of list box.
       
   441 // ----------------------------------------------------------------------------
       
   442 //
       
   443 TInt CCalenTodoContainer::MarkedCount()
       
   444     {
       
   445     TRACE_ENTRY_POINT;
       
   446 
       
   447     TRACE_EXIT_POINT;
       
   448     return ListBox()->SelectionIndexes()->Count();
       
   449     }
       
   450 
       
   451 // ----------------------------------------------------------------------------
       
   452 // CCalenTodoContainer::SetCurrentItemIndexAndDraw
       
   453 // Set current item index and draw list.
       
   454 // ----------------------------------------------------------------------------
       
   455 //
       
   456 void CCalenTodoContainer::SetCurrentItemIndexAndDraw()
       
   457     {
       
   458     TRACE_ENTRY_POINT;
       
   459 
       
   460     if( iHighlightedRowNumber != KErrNotFound &&
       
   461         iHighlightedRowNumber < iListBox->Model()->NumberOfItems() )
       
   462         {
       
   463         iListBox->SetCurrentItemIndexAndDraw( iHighlightedRowNumber );
       
   464         }
       
   465 
       
   466     TRACE_EXIT_POINT;
       
   467     }
       
   468 
       
   469 // ----------------------------------------------------------------------------
       
   470 // CCalenTodoContainer::SetHighlightingL
       
   471 // Sets the highlighting
       
   472 // ----------------------------------------------------------------------------
       
   473 //
       
   474 void CCalenTodoContainer::SetHighlightingL()
       
   475     {
       
   476     TRACE_ENTRY_POINT;
       
   477 
       
   478     TInt focusIx = KErrNotFound;
       
   479 
       
   480     // If top item is specified, set it
       
   481     if ( iFirstEntryOnScreenIndex != KErrNotFound )
       
   482         {
       
   483         iListBox->SetTopItemIndex( iFirstEntryOnScreenIndex );
       
   484         }
       
   485 
       
   486     if ( iHighlightedRowNumber != KErrNotFound )
       
   487         {
       
   488         focusIx = iHighlightedRowNumber;
       
   489         }
       
   490     else
       
   491         {
       
   492         MCalenContext& context = iServices.Context();
       
   493         if ( !(context.InstanceId() == TCalenInstanceId::NullInstanceId()) )
       
   494             {
       
   495             iHighlightedRowNumber = focusIx = iController->FindInstanceIndexL( context.InstanceId() );
       
   496             }
       
   497         }
       
   498 
       
   499     // If everything else fails, focus on first item
       
   500     if ( focusIx == KErrNotFound )
       
   501         {
       
   502         focusIx = 0;
       
   503         }
       
   504 
       
   505     // Set iHighlightedRowNumber as the current focus
       
   506     SetCurrentItemIndex( focusIx );
       
   507     // Draw listbox with this new iHighlightedRowNumber value.
       
   508     // otherwise we won't get updated focus
       
   509     SetCurrentItemIndexAndDraw();
       
   510 
       
   511     iListBox->View()->SetDisableRedraw( EFalse );
       
   512     DrawNow();
       
   513 
       
   514    // static_cast<CCalenTodoView*>(iView)->SaveCurrentItemIndexL();
       
   515 
       
   516     TRACE_EXIT_POINT;
       
   517     }
       
   518 
       
   519 // ----------------------------------------------------------------------------
       
   520 // CCalenTodoContainer::CreateEntryItertorL
       
   521 // Creat all item data and draw for list box.
       
   522 // ----------------------------------------------------------------------------
       
   523 //
       
   524 void CCalenTodoContainer::CreateEntryItertorL()
       
   525     {
       
   526     TRACE_ENTRY_POINT;
       
   527 
       
   528     TInt cnt( iController->Count() );
       
   529     TInt empflag( 0 );
       
   530 
       
   531     if( cnt == 0 )
       
   532         {
       
   533         empflag = 1; // Set empty flag.
       
   534         cnt = 1;
       
   535         }
       
   536     else
       
   537         {
       
   538         iController->SetToStartL();
       
   539         }
       
   540 
       
   541     iListBox->View()->SetDisableRedraw( ETrue );
       
   542     iListBox->Reset(); // Clear all items.
       
   543     iDesArray->Reset();
       
   544     iColorUidArray.Reset();
       
   545     
       
   546     RPointerArray<CCalCalendarInfo> calendarInfoList;
       
   547     iServices.GetAllCalendarInfoL(calendarInfoList);
       
   548     CleanupClosePushL(calendarInfoList);
       
   549 
       
   550     HBufC* listDes = HBufC::NewLC( KListDataLength );
       
   551     for( TInt loop(0); loop < cnt; ++loop )
       
   552         {
       
   553         TPtr ptr = listDes->Des();
       
   554         ptr.Zero(); // Set zero length.
       
   555 
       
   556         if( !empflag )
       
   557             {
       
   558             TBool dbStatus = EFalse;
       
   559             // List is not empty.
       
   560             if( !iController->IsAtEnd() )
       
   561                 {
       
   562                 // Make one line data for list box.
       
   563                 CCalInstance* instance = iController->Instance();
       
   564                 TCalCollectionId colId = instance->InstanceIdL().iCollectionId;
       
   565                 HBufC* calendarFileName = iServices.GetCalFileNameForCollectionId(colId).AllocLC();
       
   566                 TInt index = calendarInfoList.Find( *calendarFileName, 
       
   567                         CCalenTodoContainer::CalendarInfoIdentifierL );
       
   568                 CleanupStack::PopAndDestroy(calendarFileName);
       
   569                 
       
   570                 if(index != KErrNotFound && calendarInfoList[index]->Enabled())
       
   571                     {
       
   572                     MakeListDataL( instance, ptr );
       
   573                     dbStatus = ETrue;
       
   574                     //We want this in the listbox drawer
       
   575                     iColorUidArray.Append(calendarInfoList[index]->Color().Value());
       
   576                     iController->iActiveListIndices.AppendL(loop);
       
   577                     }
       
   578                 iController->SetToNextL();
       
   579                 }
       
   580             else
       
   581                 {
       
   582                 cnt = 0;
       
   583                 }
       
   584             
       
   585             if(dbStatus)
       
   586                 iDesArray->AppendL( *listDes );
       
   587                 
       
   588             }
       
   589         }
       
   590    
       
   591     CleanupStack::PopAndDestroy( listDes );
       
   592     CleanupStack::PopAndDestroy( &calendarInfoList ); 
       
   593     iListBox->HandleItemAdditionL();
       
   594     iListBox->View()->SetListEmptyTextL( *iEmptyListText );
       
   595 
       
   596     TRACE_EXIT_POINT;
       
   597     }
       
   598 
       
   599 // ----------------------------------------------------------------------------
       
   600 // CCalenTodoContainer::MakeListDataL
       
   601 // Make a list data of ToDo list.
       
   602 // (other items were commented in a header).
       
   603 // ----------------------------------------------------------------------------
       
   604 //
       
   605 void CCalenTodoContainer::MakeListDataL(CCalInstance* aInstance, TPtr& aPtr)
       
   606     {
       
   607     TRACE_ENTRY_POINT;
       
   608 
       
   609     CCalEntry& entry = aInstance->Entry();
       
   610 
       
   611     // Set a due date
       
   612     TTime duedate;
       
   613 
       
   614     if( IsValidDueDateL( aInstance ) )
       
   615         {
       
   616         duedate = entry.EndTimeL().TimeLocalL();
       
   617         }
       
   618     else
       
   619         {
       
   620         // If due date is invalid, set today date to note.
       
   621         duedate = CalenDateUtils::Today();
       
   622         }
       
   623 
       
   624     TBuf<20> tempString;
       
   625 
       
   626     CCalEntry::TStatus status = entry.StatusL();
       
   627     tempString.Format( KTaskStateFormat, status == CCalEntry::ETodoCompleted ? 
       
   628                                                                        IconIndex( MCalenServices::ECalenTodoIconDone ) :
       
   629                                                                        IconIndex( MCalenServices::ECalenTodoIconUndone ));
       
   630     aPtr.Append( tempString );
       
   631 
       
   632     // Read format text from resource.
       
   633     HBufC* listdateFormat = StringLoader::LoadLC( R_QTN_DATE_WITHOUT_YEAR_WITH_ZERO, iCoeEnv );
       
   634 
       
   635     duedate.FormatL( tempString, *listdateFormat );
       
   636 
       
   637     // convert the date numbers into Arabic-Indic numbers
       
   638     AknTextUtils::DisplayTextLanguageSpecificNumberConversion( tempString );
       
   639     aPtr.Append( tempString );
       
   640     aPtr.Append( KListSeparatorFormat );
       
   641 
       
   642     CleanupStack::PopAndDestroy( listdateFormat );
       
   643 
       
   644     // Set summary
       
   645     // Create temporary buffer for summary
       
   646     const TInt summaryMaxLength = aPtr.MaxLength() - aPtr.Length();
       
   647     HBufC* summary = HBufC::NewLC( summaryMaxLength );
       
   648     TPtr summaryPtr = summary->Des();
       
   649 
       
   650     CalenViewUtils::GetSummaryLocationTextL( entry, summaryPtr, summaryMaxLength );
       
   651 
       
   652     // Append only as much as needed or fits
       
   653     TInt freeSpace = Min( Min( summary->Length(), KListDataLengthOfSubject ),
       
   654                           aPtr.MaxLength() - aPtr.Length() );
       
   655     
       
   656     aPtr.Append( _L(" ") );
       
   657     aPtr.Append( _L(" ") );
       
   658     aPtr.Append( _L(" ") );
       
   659     
       
   660     aPtr.Append( summary->Left( freeSpace ) );
       
   661     CleanupStack::PopAndDestroy( summary );
       
   662 
       
   663     // EFalse: do not push _\t to push icon to right
       
   664     // in case there is 1 icon to show
       
   665     // ETrue: mirror the order of icons
       
   666     InsertAdditionalIconsL(entry, KIconSeparatorFormat(), aPtr, EFalse, ETrue);
       
   667 
       
   668     TRACE_EXIT_POINT;
       
   669     }
       
   670 
       
   671 // ----------------------------------------------------------------------------
       
   672 // CCalenTodoContainer::CreateAndAppendIconL
       
   673 // ----------------------------------------------------------------------------
       
   674 //
       
   675 void CCalenTodoContainer::CreateAndAppendIconL(const TAknsItemID& aID,
       
   676                                           const TDesC& aFileName,
       
   677                                           const TInt aBitmapId,
       
   678                                           const TInt aMaskId,
       
   679                                           CAknIconArray* aIconList)
       
   680     {
       
   681     TRACE_ENTRY_POINT;
       
   682 
       
   683     CGulIcon* icon = AknsUtils::CreateGulIconL(
       
   684         AknsUtils::SkinInstance(), aID, aFileName, aBitmapId, aMaskId );
       
   685 
       
   686     CleanupStack::PushL( icon );
       
   687     aIconList->AppendL( icon );
       
   688     CleanupStack::Pop( icon );
       
   689 
       
   690     TRACE_EXIT_POINT;
       
   691     }
       
   692 
       
   693 // ----------------------------------------------------------------------------
       
   694 // CCalenTodoContainer::ReplaceToWhiteSpace
       
   695 // Replace a white space character in text buffer by blank
       
   696 // character (" ").
       
   697 // ----------------------------------------------------------------------------
       
   698 //
       
   699 void CCalenTodoContainer::ReplaceToWhiteSpace(TDes& aBuf)
       
   700     {
       
   701     TRACE_ENTRY_POINT;
       
   702 
       
   703     TInt length( aBuf.Length() );
       
   704 
       
   705     for( TInt i(0); i < length; ++i)
       
   706         {
       
   707         TChar onechar( aBuf[i] );
       
   708 
       
   709         if( onechar.IsSpace() )
       
   710             {
       
   711             // Replace by blank character.
       
   712             aBuf.Replace( i, 1, KSpaceText );
       
   713             }
       
   714         }
       
   715 
       
   716     TRACE_EXIT_POINT;
       
   717     }
       
   718 
       
   719 // ----------------------------------------------------------------------------
       
   720 // CCalenTodoContainer::SizeChanged
       
   721 // Child control was resized.
       
   722 // ----------------------------------------------------------------------------
       
   723 //
       
   724 void CCalenTodoContainer::SizeChanged()
       
   725     {
       
   726     TRACE_ENTRY_POINT;
       
   727 
       
   728     TRect main_pane( Rect() );
       
   729     CCalenContainer::SizeChanged( main_pane );
       
   730     iLayoutManager->GetLayoutAndExtensionL(); 
       
   731     iListBox->SetRect( main_pane );
       
   732 
       
   733     TRACE_EXIT_POINT;
       
   734     }
       
   735 
       
   736 // ----------------------------------------------------------------------------
       
   737 // CCalenTodoContainer::CountComponentControls
       
   738 // Return child control count.
       
   739 // (other items were commented in a header).
       
   740 // ----------------------------------------------------------------------------
       
   741 //
       
   742 TInt CCalenTodoContainer::CountComponentControls() const
       
   743     {
       
   744     TRACE_ENTRY_POINT;
       
   745 
       
   746     TRACE_EXIT_POINT;
       
   747     return 1;
       
   748     }
       
   749 
       
   750 // ----------------------------------------------------------------------------
       
   751 // CCalenTodoContainer::ComponentControl
       
   752 // Return child control pointer.
       
   753 // (other items were commented in a header).
       
   754 // ----------------------------------------------------------------------------
       
   755 //
       
   756 CCoeControl* CCalenTodoContainer::ComponentControl(TInt /*aIndex*/) const     // Child control index
       
   757     {
       
   758     TRACE_ENTRY_POINT;
       
   759 
       
   760     TRACE_EXIT_POINT;
       
   761     return iListBox;
       
   762     }
       
   763 
       
   764 // ----------------------------------------------------------------------------
       
   765 // CCalenTodoContainer::OfferKeyEventL
       
   766 // Process key event.
       
   767 // (other items were commented in a header).
       
   768 // ----------------------------------------------------------------------------
       
   769 //
       
   770 TKeyResponse CCalenTodoContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
       
   771     {
       
   772     TRACE_ENTRY_POINT;
       
   773 
       
   774     // common view key handling
       
   775     // NOTE! Common key handling has to be performed before custom handling
       
   776     // otherwise view-cycling state handling breaks.
       
   777     if (CCalenContainer::OfferKeyEventL(aKeyEvent, aType) == EKeyWasConsumed)
       
   778         {
       
   779         TRACE_EXIT_POINT;
       
   780         return EKeyWasConsumed;
       
   781         }
       
   782 
       
   783     TKeyResponse exitCode(EKeyWasNotConsumed);
       
   784     TUint modifiers = aKeyEvent.iModifiers;
       
   785 
       
   786     if (aType == EEventKey)
       
   787         {
       
   788         if (aKeyEvent.iCode == EKeyOK)
       
   789             {
       
   790             // Check no pressing shift key.
       
   791             if( !(modifiers & (EModifierShift+EModifierRightShift)) )
       
   792                 {
       
   793                  // Single click integration
       
   794                 if( !iController->Count() )
       
   795                     {
       
   796                     // display the context sensitive menu
       
   797                     /*CEikMenuBar* menuBar = iView->MenuBar();
       
   798                     menuBar->SetContextMenuTitleResourceId( R_TODO_LIST_SELECTION_CONTEXT_MENUBAR );
       
   799                     menuBar->TryDisplayContextMenuBarL();
       
   800 */                    }
       
   801                 else
       
   802                     {
       
   803                     iListBox->OfferKeyEventL( aKeyEvent, aType );
       
   804                     }
       
   805                 exitCode = EKeyWasConsumed;
       
   806                 }
       
   807 
       
   808             }
       
   809         else if( ( aKeyEvent.iCode == EKeyBackspace )
       
   810                 && iView->MenuBar()->ItemSpecificCommandsEnabled() &&
       
   811                  (iController->Count()) )
       
   812             {
       
   813             // Handle delete command.
       
   814             static_cast<CCalenTodoView*>(iView)->HandleCommandL( ECalenDeleteCurrentEntry );
       
   815             exitCode = EKeyWasConsumed;
       
   816             }
       
   817             // Change Note View.
       
   818         else if( aKeyEvent.iCode == EKeyEnter )
       
   819     		{
       
   820        		if(IsEmptyView())
       
   821 	       		{
       
   822 	       		iView->HandleCommandL(ECalenCmdOpenMskDialog); 	
       
   823 	       		}
       
   824        		else
       
   825 	       		{       		
       
   826                  // Single click integration
       
   827                 iListBox->OfferKeyEventL( aKeyEvent, aType );
       
   828 	       		}
       
   829        		exitCode = EKeyWasConsumed;
       
   830        		}
       
   831         }
       
   832 
       
   833     if (exitCode == EKeyWasNotConsumed)
       
   834         {
       
   835         TInt oldCursor = iListBox->View()->CurrentItemIndex();
       
   836         exitCode = iListBox->OfferKeyEventL(aKeyEvent, aType);
       
   837         TInt newCursor = iListBox->View()->CurrentItemIndex();
       
   838 
       
   839         if (oldCursor != newCursor)
       
   840             {
       
   841             static_cast<CCalenTodoView*>(iView)->SaveCurrentItemIndexL();
       
   842             }
       
   843         }
       
   844     static_cast<CCalenTodoView*>(iView)->UpdateCBAButtonsL();
       
   845 
       
   846     TRACE_EXIT_POINT;
       
   847 
       
   848     return exitCode;
       
   849     }
       
   850 
       
   851 // ----------------------------------------------------------------------------
       
   852 // CCalenTodoContainer::GetHelpContext
       
   853 // Get help context.
       
   854 // (other items were commented in a header).
       
   855 // ----------------------------------------------------------------------------
       
   856 //
       
   857 void CCalenTodoContainer::GetHelpContext(TCoeHelpContext& aContext) const
       
   858     {
       
   859     TRACE_ENTRY_POINT;
       
   860 
       
   861     aContext.iMajor = KUidCalendar;
       
   862     aContext.iContext = KCALE_HLP_TODO_VIEW;
       
   863 
       
   864     TRACE_EXIT_POINT;
       
   865     }
       
   866 
       
   867 // ----------------------------------------------------------------------------
       
   868 // CCalenTodoContainer::UpdateSize
       
   869 // Do layout changes after calendar settings are
       
   870 // changed.  No necessary actions for this view.
       
   871 // ----------------------------------------------------------------------------
       
   872 //
       
   873 void CCalenTodoContainer::UpdateSize()
       
   874     {
       
   875     TRACE_ENTRY_POINT;
       
   876     SizeChanged();
       
   877     TRACE_EXIT_POINT;
       
   878     }
       
   879 
       
   880 // ----------------------------------------------------------------------------
       
   881 // CCalenTodoContainer::HandleResourceChange
       
   882 // Handles a resource relative event
       
   883 // (other items were commented in a header).
       
   884 // ----------------------------------------------------------------------------
       
   885 //
       
   886 void CCalenTodoContainer::HandleResourceChange(TInt aType)
       
   887     {
       
   888     TRACE_ENTRY_POINT;
       
   889 
       
   890     CCalenContainer::HandleResourceChange( aType );
       
   891 
       
   892     if ( aType == KAknsMessageSkinChange || aType == KEikDynamicLayoutVariantSwitch )
       
   893         {
       
   894         SizeChanged();
       
   895 
       
   896         // refresh
       
   897         TRAPD(error,iView->BeginRepopulationL());
       
   898 	    if(error!=KErrNone)
       
   899 	       	{
       
   900 	       	// do avoid warning
       
   901 	       	}         
       
   902         }
       
   903 
       
   904     CCoeControl::HandleResourceChange( aType );
       
   905 
       
   906     TRACE_EXIT_POINT;
       
   907     }
       
   908 
       
   909 // ----------------------------------------------------------------------------
       
   910 // CCalenTodoContainer::MarkCurrentL
       
   911 // (other items were commented in a header).
       
   912 // ----------------------------------------------------------------------------
       
   913 //
       
   914 void CCalenTodoContainer::MarkCurrentL(TBool aMark)
       
   915     {
       
   916     TRACE_ENTRY_POINT;
       
   917     
       
   918     const CListBoxView::CSelectionIndexArray* oldArray = iListBox->SelectionIndexes();
       
   919     CListBoxView::CSelectionIndexArray* newArray = new( ELeave )CArrayFixFlat<TInt>( oldArray->Count() + 1 );
       
   920     CleanupStack::PushL( newArray );
       
   921 
       
   922     TInt currentIndex( iListBox->CurrentItemIndex() );
       
   923 
       
   924     for( TInt i(0); i < oldArray->Count(); ++i )
       
   925         {
       
   926         if( oldArray->At( i ) != currentIndex )
       
   927             {
       
   928             newArray->AppendL( oldArray->At( i ) );
       
   929             }
       
   930         }
       
   931 
       
   932     if( aMark )
       
   933         {
       
   934         newArray->AppendL( currentIndex );
       
   935         }
       
   936     else
       
   937         {
       
   938         // when a todo item is unmarked,clear marked to do item info
       
   939         static_cast<CCalenTodoView*>( iView )->ClearMarkedToDoItems();
       
   940         }
       
   941     
       
   942     iListBox->SetSelectionIndexesL( newArray );
       
   943     
       
   944     // set marked todo items info
       
   945     static_cast<CCalenTodoView*>( iView )->SetMarkedToDoItems(newArray);
       
   946     
       
   947     CleanupStack::Pop( newArray );
       
   948 
       
   949     TRACE_EXIT_POINT;
       
   950     }
       
   951 
       
   952 // ----------------------------------------------------------------------------
       
   953 // CCalenTodoContainer::MarkAllL
       
   954 // (other items were commented in a header).
       
   955 // ----------------------------------------------------------------------------
       
   956 //
       
   957 void CCalenTodoContainer::MarkAllL(TBool aMark)
       
   958     {
       
   959     TRACE_ENTRY_POINT;
       
   960 
       
   961     if( aMark )
       
   962         {
       
   963         TInt count = iListBox->Model()->NumberOfItems();
       
   964         CListBoxView::CSelectionIndexArray* array = new( ELeave )CArrayFixFlat<TInt>( count );
       
   965         CleanupStack::PushL( array );
       
   966 
       
   967         for( TInt i(0); i < count; ++i )
       
   968             {
       
   969             array->AppendL( i );
       
   970             }
       
   971         iListBox->SetSelectionIndexesL( array );
       
   972 
       
   973         // set marked todo items info
       
   974         static_cast<CCalenTodoView*>( iView )->SetMarkedToDoItems(array);
       
   975 
       
   976         CleanupStack::Pop( array );
       
   977         }
       
   978     else
       
   979         {
       
   980         iListBox->ClearSelection();
       
   981         
       
   982         // when all the todo items are unmarked,clear all marked todo items info from View
       
   983         static_cast<CCalenTodoView*>( iView )->ClearMarkedToDoItems();
       
   984         }
       
   985 
       
   986     TRACE_EXIT_POINT;
       
   987     }
       
   988 
       
   989 // ----------------------------------------------------------------------------
       
   990 // CCalenTodoContainer::IsCurrentItemSelected
       
   991 // (other items were commented in a header).
       
   992 // ----------------------------------------------------------------------------
       
   993 //
       
   994 TBool CCalenTodoContainer::IsCurrentItemSelected(void)
       
   995     {
       
   996     TRACE_ENTRY_POINT;
       
   997 
       
   998     const CListBoxView::CSelectionIndexArray* selectionArray = iListBox->SelectionIndexes();
       
   999 
       
  1000     TInt currentIndex( iListBox->CurrentItemIndex() );
       
  1001 
       
  1002     for( TInt i(0); i < selectionArray->Count(); ++i )
       
  1003         {
       
  1004         if( selectionArray->At( i ) == currentIndex )
       
  1005             {
       
  1006             TRACE_EXIT_POINT;
       
  1007             return ETrue;
       
  1008             }
       
  1009         }
       
  1010 
       
  1011     TRACE_EXIT_POINT;
       
  1012     return EFalse;
       
  1013     }
       
  1014 
       
  1015 
       
  1016 // ----------------------------------------------------------------------------
       
  1017 // CCalenTodoContainer::FocusChanged(TDrawNow aDrawNow)
       
  1018 // Called when focus is changed
       
  1019 // (other items were commented in a header).
       
  1020 // ----------------------------------------------------------------------------
       
  1021 //
       
  1022 void CCalenTodoContainer::FocusChanged(TDrawNow aDrawNow)
       
  1023     {
       
  1024     TRACE_ENTRY_POINT;
       
  1025 
       
  1026     // Super-class does some common routines when focus is changed
       
  1027     CCalenContainer::FocusChanged( aDrawNow );
       
  1028     // Pass focus change event to grid for highlight animation
       
  1029     if ( iListBox )
       
  1030         {
       
  1031         iListBox->SetFocus( IsFocused() );
       
  1032         }
       
  1033 
       
  1034     TRACE_EXIT_POINT;
       
  1035     }
       
  1036 
       
  1037 // ----------------------------------------------------------------------------
       
  1038 // CCalenTodoContainer::IsEmptyView()
       
  1039 // Return ETrue if view is currently empty.
       
  1040 // (other items were commented in a header).
       
  1041 // ----------------------------------------------------------------------------
       
  1042 //
       
  1043 TBool CCalenTodoContainer::IsEmptyView() const
       
  1044     {
       
  1045     TRACE_ENTRY_POINT;
       
  1046 
       
  1047     TInt count=iController->Count();
       
  1048 
       
  1049     TRACE_EXIT_POINT;
       
  1050     return ( count <= 0);
       
  1051     }
       
  1052 
       
  1053 
       
  1054 // ----------------------------------------------------------------------------
       
  1055 // CCalenTodoContainer::MopSupplyObject()
       
  1056 // Pass skin information if needed.
       
  1057 // ----------------------------------------------------------------------------
       
  1058 //
       
  1059 TTypeUid::Ptr CCalenTodoContainer::MopSupplyObject(TTypeUid aId)
       
  1060     {
       
  1061     TRACE_ENTRY_POINT;
       
  1062 
       
  1063     if(aId.iUid == MAknsControlContext::ETypeId )
       
  1064         {
       
  1065         MAknsControlContext* cc = iBgContext;
       
  1066         if ( cc )
       
  1067             {
       
  1068             TRACE_EXIT_POINT;
       
  1069             return MAknsControlContext::SupplyMopObject( aId, cc );
       
  1070             }
       
  1071         }
       
  1072     TRACE_EXIT_POINT;
       
  1073     return CCoeControl::MopSupplyObject( aId );
       
  1074     }
       
  1075 
       
  1076 // ----------------------------------------------------------------------------
       
  1077 // CCalenTodoContainer::Draw
       
  1078 // drawing todo view background
       
  1079 // (other items were commented in a header).
       
  1080 // ----------------------------------------------------------------------------
       
  1081 //
       
  1082 void CCalenTodoContainer::Draw(const TRect& /*aRect*/) const
       
  1083     {
       
  1084     TRACE_ENTRY_POINT;
       
  1085     CWindowGc& gc = SystemGc();
       
  1086     TRect main_pane( Rect() );
       
  1087 
       
  1088     MAknsControlContext* cc = AknsDrawUtils::ControlContext( this );
       
  1089 
       
  1090     const TInt drawParams = 0;
       
  1091     AknsDrawUtils::Background( AknsUtils::SkinInstance(),
       
  1092                                cc,
       
  1093                                NULL,
       
  1094                                gc,
       
  1095                                main_pane,
       
  1096                                drawParams);
       
  1097 
       
  1098     TRACE_EXIT_POINT;
       
  1099     }
       
  1100 
       
  1101 // ----------------------------------------------------------------------------
       
  1102 // CCalenTodoContainer::HandleNaviDecorationPointerEventL
       
  1103 // Navi decoration is not present in todo view
       
  1104 // (other items were commented in a header).
       
  1105 // ----------------------------------------------------------------------------
       
  1106 //
       
  1107 void CCalenTodoContainer::HandleNaviDecoratorEventL(TInt)
       
  1108     {
       
  1109     TRACE_ENTRY_POINT;
       
  1110     TRACE_EXIT_POINT;
       
  1111     }
       
  1112 
       
  1113 // ----------------------------------------------------------------------------
       
  1114 // CCalenMonthContainer::HandleLongTapEventL
       
  1115 // processing of a long tap event
       
  1116 // (other items were commented in a header).
       
  1117 // ----------------------------------------------------------------------------
       
  1118 //
       
  1119 void CCalenTodoContainer::HandleLongTapEventL( const TPoint& /*aPenEventLocation*/,
       
  1120                                                const TPoint& /*aPenEventScreenLocation*/ )
       
  1121     {
       
  1122     TRACE_ENTRY_POINT;    
       
  1123     TRACE_EXIT_POINT;
       
  1124     }
       
  1125 
       
  1126 // ----------------------------------------------------------------------------
       
  1127 // CCalenTodoContainer::HandlePointerEventL
       
  1128 // Process pointer event.
       
  1129 // (other items were commented in a header).
       
  1130 // ----------------------------------------------------------------------------
       
  1131 //
       
  1132 void CCalenTodoContainer::HandlePointerEventL(const TPointerEvent& aPointerEvent)
       
  1133     {
       
  1134     TRACE_ENTRY_POINT;
       
  1135 
       
  1136     if(AknLayoutUtils::PenEnabled())
       
  1137         {
       
  1138         TInt pointerIndex(-1);
       
  1139         TBool isItem (iListBox->View()->XYPosToItemIndex(aPointerEvent.iPosition, pointerIndex));
       
  1140 
       
  1141         if(isItem == EFalse && IsEmptyView())
       
  1142             {
       
  1143             iListBox->HandlePointerEventL(aPointerEvent);
       
  1144             iView->HandleCommandL(ECalenCmdOpenMskDialog);
       
  1145             return;
       
  1146             }
       
  1147 
       
  1148          // Single click integration
       
  1149         /** Event modifiers are ignored for now because
       
  1150          *  those are not needed but cause problems
       
  1151          */
       
  1152         TPointerEvent pointerEvent( aPointerEvent );
       
  1153         pointerEvent.iModifiers =
       
  1154             ( aPointerEvent.iModifiers & ( ~EAllModifiers ) );
       
  1155         iListBox->HandlePointerEventL( pointerEvent );
       
  1156         }
       
  1157 
       
  1158     TRACE_EXIT_POINT;
       
  1159     }
       
  1160 
       
  1161 
       
  1162 // ----------------------------------------------------------------------------
       
  1163 // CCalenTodoContainer::BeginPopulationWithInstanceViewL
       
  1164 // First stage of population.
       
  1165 // (other items were commented in a header).
       
  1166 // ----------------------------------------------------------------------------
       
  1167 //
       
  1168 void CCalenTodoContainer::BeginPopulationWithInstanceViewL()
       
  1169     {
       
  1170     TRACE_ENTRY_POINT;
       
  1171 
       
  1172     iController->RefreshL();
       
  1173     // prepare listbox model with data from entries
       
  1174     CreateEntryItertorL();
       
  1175     
       
  1176     MCalenContext& context = iServices.Context();
       
  1177     if ( !(context.InstanceId() == TCalenInstanceId::NullInstanceId()) )
       
  1178         {
       
  1179         iHighlightedRowNumber = Controller()->FindInstanceIndexL( context.InstanceId() );
       
  1180         }
       
  1181 
       
  1182     // handle possible view cycling and set current item index.
       
  1183     SetHighlightingL();
       
  1184     
       
  1185     // get marked todo items from view if any items are marked.
       
  1186     iListBox->SetSelectionIndexesL(static_cast<CCalenTodoView*>( iView )->GetMarkedToDoItems());
       
  1187 
       
  1188     iListBox->View()->SetDisableRedraw( EFalse );
       
  1189     DrawNow();
       
  1190 
       
  1191     TRACE_EXIT_POINT;
       
  1192     }
       
  1193 
       
  1194 // ----------------------------------------------------------------------------
       
  1195 // CCalenTodoContainer::CompletePopulationL
       
  1196 // Second and final stage of population.
       
  1197 // (other items were commented in a header).
       
  1198 // ----------------------------------------------------------------------------
       
  1199 //
       
  1200 void CCalenTodoContainer::CompletePopulationL()
       
  1201     {
       
  1202     TRACE_ENTRY_POINT;
       
  1203 
       
  1204     AddToStackAndMakeVisibleL();
       
  1205     // Now we know if the view is empty or not we can update the CBA buttons.
       
  1206     static_cast<CCalenTodoView*>( iView )->UpdateCBAButtonsL();
       
  1207     UpdateStatusPaneAndExtensionsL();
       
  1208 
       
  1209     TRACE_EXIT_POINT;
       
  1210     }
       
  1211 
       
  1212 // ----------------------------------------------------------------------------
       
  1213 // CCalenTodoContainer::CreateIconIndicesL
       
  1214 // Second and final stage of population.
       
  1215 // (other items were commented in a header).
       
  1216 // ----------------------------------------------------------------------------
       
  1217 //
       
  1218 void CCalenTodoContainer::CreateIconIndicesL( RArray<MCalenServices::TCalenIcons>& aIndexArray )
       
  1219     {
       
  1220     TRACE_ENTRY_POINT;
       
  1221     aIndexArray.Reset();
       
  1222     aIndexArray.AppendL( MCalenServices::ECalenMarkedTodoIcon );
       
  1223     aIndexArray.AppendL( MCalenServices::ECalenAlarmIcon );
       
  1224     aIndexArray.AppendL( MCalenServices::ECalenNotePriorityLow );
       
  1225     aIndexArray.AppendL( MCalenServices::ECalenNotePriorityHigh );
       
  1226     aIndexArray.AppendL( MCalenServices::ECalenTodoIconUndone );
       
  1227     aIndexArray.AppendL( MCalenServices::ECalenTodoIconDone );
       
  1228 
       
  1229     TRACE_EXIT_POINT;
       
  1230     }
       
  1231 
       
  1232 
       
  1233 void CCalenTodoContainer::CleanupInstances()
       
  1234     {
       
  1235     TRACE_ENTRY_POINT
       
  1236     iController->CleanupInstances();
       
  1237     TRACE_EXIT_POINT
       
  1238     }
       
  1239 
       
  1240 // ----------------------------------------------------------------------------
       
  1241 // CCalenTodoContainer::PreviewRectL
       
  1242 // Returns an empty rect - Day view does not support preview pane
       
  1243 // ----------------------------------------------------------------------------
       
  1244 TRect CCalenTodoContainer::PreviewRectL()
       
  1245     {
       
  1246     TRACE_ENTRY_POINT;
       
  1247 
       
  1248     TRect rect;
       
  1249 
       
  1250     TRACE_EXIT_POINT;
       
  1251     return rect;
       
  1252     }
       
  1253 
       
  1254 // -----------------------------------------------------------------------------
       
  1255 // CCalenTodoContainer::CalendarInfoIdentifierL
       
  1256 // Searches for the index in calendar info list based on calendar file name
       
  1257 // -----------------------------------------------------------------------------
       
  1258 //
       
  1259 TBool CCalenTodoContainer::CalendarInfoIdentifierL( const HBufC* aName,
       
  1260                                         const CCalCalendarInfo& aCalendarInfo)
       
  1261     {
       
  1262     TRACE_ENTRY_POINT;
       
  1263     TBool retVal = EFalse;
       
  1264     HBufC* calendarFileName = aCalendarInfo.FileNameL().AllocLC();
       
  1265     retVal = calendarFileName->CompareF(*aName);
       
  1266     CleanupStack::PopAndDestroy(calendarFileName);    
       
  1267     TRACE_EXIT_POINT;
       
  1268     return (!retVal);
       
  1269     }
       
  1270     
       
  1271 // End of File