eventsui/eventsmgmtui/src/evtmgmtuistartupcontainer.cpp
changeset 15 13ae750350c9
parent 0 522cd55cc3d7
child 17 0f22fb80ebba
equal deleted inserted replaced
0:522cd55cc3d7 15:13ae750350c9
     1 /*
       
     2 * Copyright (c) 2008-2009 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 class for Events Management UI startup view.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // SYSTEM INCLUDES
       
    20 #include <avkon.hrh>
       
    21 #include <barsread.h> 
       
    22 #include <aknlists.h>
       
    23 #include <AknIconArray.h>		// Icon Array
       
    24 #include <eikclbd.h>			// Column Listbox
       
    25 #include <gulicon.h>			// Gul Icon
       
    26 #include <barsread.h>   		// TResourceReader
       
    27 #include <eikspane.h>       // Status pane
       
    28 #include <akntitle.h>       // CAknTitlePane
       
    29 #include <StringLoader.h>   // String Loader
       
    30 #include <evtmgmtui.rsg>
       
    31 #include <csxhelp/loc.hlp.hrh>
       
    32 #include <AknUtils.h>
       
    33 #include <evtmgmtui.mbg>
       
    34 #include <featmgr.h>
       
    35 #include <data_caging_path_literals.hrh>
       
    36 #include <AknUtils.h> 
       
    37 #include <eikmenup.h> 
       
    38 #include <AknsConstants.h> 		// Skin Ids
       
    39 #include <AknIconUtils.h>
       
    40 #include <AknLayout.lag>          // AVKON LAF layouts
       
    41 #include <AknLayoutDef.h>
       
    42 #include <aknsfld.h> // For SearchField
       
    43 
       
    44 // USER INCLUDES
       
    45 #include "evtmgmtui.hrh"
       
    46 #include "evtmgmtuiuid.hrh"
       
    47 #include "evtmgmtuiappui.h"
       
    48 #include "evtmgmtuimodel.h"
       
    49 #include "evtmgmtuistartupcontainer.h"
       
    50 #include "evtmgmtuilistbox.h"
       
    51 #include "evtmgmtuilistboxmodel.h"
       
    52 #include "evtdebug.h"
       
    53 
       
    54 // CONSTANT DEFINITIONS
       
    55 const TInt KIconArrayGranularity = 5; // The number of default icons
       
    56 const TInt KFindBoxTextLength = 32;	// Find Box text length.
       
    57 const TInt KMinCountForFilter = 2;
       
    58 _LIT( KEvtMgmtUiIconFileName, "evtmgmtui.mif" );
       
    59  
       
    60 // ----------------- Member funtions for CEvtMgmtUiStartupContainer class ------------------
       
    61 
       
    62 // ---------------------------------------------------------------------------
       
    63 // CEvtMgmtUiStartupContainer::CEvtMgmtUiStartupContainer
       
    64 // ---------------------------------------------------------------------------
       
    65 //
       
    66 CEvtMgmtUiStartupContainer::CEvtMgmtUiStartupContainer( MEvtMgmtUiCmdHdlr& aCmdHandler )
       
    67 									:iCmdHandler(aCmdHandler)
       
    68     {
       
    69     }
       
    70 
       
    71 
       
    72 // ---------------------------------------------------------------------------
       
    73 // CEvtMgmtUiStartupContainer::~CEvtMgmtUiStartupContainer
       
    74 // ---------------------------------------------------------------------------
       
    75 //
       
    76 CEvtMgmtUiStartupContainer::~CEvtMgmtUiStartupContainer()
       
    77     {
       
    78     // Delete the List box
       
    79 	delete iListBox;
       
    80 	
       
    81 	delete iFindBox;
       
    82     }
       
    83     
       
    84 // ---------------------------------------------------------------------------
       
    85 // CEvtMgmtUiStartupContainer::NewL
       
    86 // ---------------------------------------------------------------------------
       
    87 //
       
    88 CEvtMgmtUiStartupContainer* CEvtMgmtUiStartupContainer::NewL( 
       
    89                                     const TRect&	aRect, CEvtMgmtUiModel* aModel,
       
    90                                     MEvtMgmtUiCmdHdlr& aCmdHandler )     
       
    91     {
       
    92     CEvtMgmtUiStartupContainer* self = new ( ELeave ) CEvtMgmtUiStartupContainer( aCmdHandler );
       
    93     CleanupStack::PushL( self );
       
    94     self->ConstructL( aRect, aModel );
       
    95     CleanupStack::Pop();    
       
    96     return self;
       
    97     }
       
    98     
       
    99 // ---------------------------------------------------------------------------
       
   100 // CEvtMgmtUiStartupContainer::CEvtMgmtUiStartupContainer
       
   101 // ---------------------------------------------------------------------------
       
   102 //
       
   103 void CEvtMgmtUiStartupContainer::ConstructL( const TRect& 	aRect, CEvtMgmtUiModel* aModel )
       
   104     {
       
   105     // This is the cheif control for this application. This has to be made a 
       
   106     // Window owning control
       
   107     CreateWindowL();
       
   108     
       
   109     // Create the List box
       
   110     EVTUIDEBUG( "Listbox creation" );
       
   111     CreateListboxL(aModel); 
       
   112     CreateFindBoxL();
       
   113     
       
   114     // Check for FindBox Visiblity
       
   115     HandleFindBoxVisibility();
       
   116     
       
   117     // Get the Help context
       
   118     iContextName = KHLP_LOC_EVENTS_VIEW();
       
   119     
       
   120     // Set Title
       
   121     MakeTitleL();
       
   122             
       
   123     SetRect(aRect);
       
   124     ActivateL();
       
   125     }
       
   126 
       
   127 // ---------------------------------------------------------------------------
       
   128 // void CEvtMgmtUiStartupContainer::GetHelpContext
       
   129 // ---------------------------------------------------------------------------
       
   130 //
       
   131 void CEvtMgmtUiStartupContainer::GetHelpContext( TCoeHelpContext& aContext ) const
       
   132 	{
       
   133     aContext.iContext = iContextName;
       
   134     aContext.iMajor = TUid::Uid( KEvtMgmtUiUid );	
       
   135 	}
       
   136 
       
   137 // --------------------------------------------------------------------------
       
   138 // CEvtMgmtUiStartupContainer::FocusChanged
       
   139 // --------------------------------------------------------------------------
       
   140 //
       
   141 void CEvtMgmtUiStartupContainer::FocusChanged( TDrawNow aDrawNow )
       
   142     {
       
   143     if ( iListBox )
       
   144         {
       
   145         iListBox->SetFocus( IsFocused(), aDrawNow );
       
   146         }
       
   147         
       
   148     if ( iFindBox && iFindBox->IsVisible() )
       
   149         {
       
   150         iFindBox->SetFocus( IsFocused(), aDrawNow );
       
   151         if ( aDrawNow == EDrawNow && IsFocused() )
       
   152             {
       
   153             iFindBox->DrawDeferred();
       
   154             }
       
   155         }
       
   156     }
       
   157 		
       
   158 // ---------------------------------------------------------------------------
       
   159 // void CEvtMgmtUiStartupContainer::SizeChanged
       
   160 // ---------------------------------------------------------------------------
       
   161 //
       
   162 void CEvtMgmtUiStartupContainer::SizeChanged()
       
   163     {
       
   164     EVTUIDEBUG("+ CEvtMgmtUiStartupContainer::SizeChanged()" );
       
   165 	const TRect rect( Rect() );
       
   166     TAknLayoutRect controlRect;
       
   167 
       
   168     // Since iFindBox->IsVisible() returns EFalse if Adaptive Chars are shown, 
       
   169     // We check on FilteredNumberOfItems meaning the FindBox should be visible when 
       
   170     // FilteredNumberOfItems is greater than 1
       
   171     if( iListBox && iFindBox && 
       
   172             ( iFindBox->IsVisible() || iListBox->Model()->Filter()->FilteredNumberOfItems() > 1 ) )
       
   173         {
       
   174         controlRect.LayoutRect(rect, AknLayout::list_gen_pane( 1 ) );
       
   175         iListBox->SetRect( controlRect.Rect() );
       
   176         controlRect.LayoutRect(rect, AknLayout::find_pane() );
       
   177         iFindBox->SetRect( controlRect.Rect() );  
       
   178         }
       
   179     else if( iListBox )
       
   180         {
       
   181         controlRect.LayoutRect(rect, AknLayout::list_gen_pane( 0 ) );
       
   182         iListBox->SetRect( controlRect.Rect() );
       
   183         }
       
   184     EVTUIDEBUG("- CEvtMgmtUiStartupContainer::SizeChanged()" );
       
   185     }
       
   186 
       
   187 // ---------------------------------------------------------------------------
       
   188 // TInt CEvtMgmtUiStartupContainer::CountComponentControls
       
   189 // ---------------------------------------------------------------------------
       
   190 //
       
   191 TInt CEvtMgmtUiStartupContainer::CountComponentControls() const
       
   192     {
       
   193     TInt count = 0;
       
   194     CCoeControl* controls[] = { iListBox, iFindBox };
       
   195 
       
   196     for ( TUint i = 0; i < sizeof( controls ) / sizeof( CCoeControl* ); i++ )
       
   197     {
       
   198         if ( controls[i] ) // Test for valid controls
       
   199         {
       
   200         count++;
       
   201         }
       
   202     }
       
   203 
       
   204     return count;
       
   205     }
       
   206 
       
   207 // ---------------------------------------------------------------------------
       
   208 // CCoeControl* CEvtMgmtUiStartupContainer::CEvtMgmtUiStartupContainer
       
   209 // ---------------------------------------------------------------------------
       
   210 //
       
   211 CCoeControl* CEvtMgmtUiStartupContainer::ComponentControl(TInt aIndex ) const
       
   212     {
       
   213     CCoeControl* controls[] = { iListBox,
       
   214                                 iFindBox};
       
   215 
       
   216     for ( TUint i = 0; i < sizeof( controls ) / sizeof( CCoeControl* ); i++ )
       
   217     {
       
   218         // Index is decremented only if control is not NULL
       
   219         if ( controls[i] && aIndex-- == 0 ) 
       
   220         {
       
   221         return controls[i];
       
   222         }
       
   223     }
       
   224 
       
   225     return NULL;
       
   226     }
       
   227 
       
   228 // ---------------------------------------------------------------------------
       
   229 // TKeyResponse CEvtMgmtUiStartupContainer::OfferKeyEventL
       
   230 // ---------------------------------------------------------------------------
       
   231 //    
       
   232 TKeyResponse CEvtMgmtUiStartupContainer::OfferKeyEventL( const TKeyEvent& aKeyEvent,
       
   233 								  				               TEventCode aType )
       
   234     {
       
   235     TKeyResponse keyresponse;
       
   236     
       
   237     TBool needRefresh = EFalse;
       
   238     TInt keyConsumed = iFindBox->TextLength();
       
   239 	
       
   240 	// Key is first offered to the Find box based on the key press.
       
   241     keyresponse = AknFind::HandleFindOfferKeyEventL(aKeyEvent, aType,
       
   242                         this, iListBox, iFindBox, EFalse, needRefresh);
       
   243     
       
   244     // Handle the ListBox Filter count changed event
       
   245     iCmdHandler.HandleCmdL( MEvtMgmtUiCmdHdlr::EListBoxFilterCountChanged ); 
       
   246     
       
   247 	// This is to avoid the Mark for the First item of the list box.
       
   248 	// We reset the modifier attribute
       
   249     TKeyEvent& keyEvent = const_cast<TKeyEvent&>(aKeyEvent);
       
   250     TInt index = CurrentItemIndex();
       
   251     if(index == 0 || 
       
   252        (index == iListBox->Model()->NumberOfItems() - 1) && aKeyEvent.iScanCode == EStdKeyDownArrow ||
       
   253        (index == 1) && aKeyEvent.iScanCode == EStdKeyUpArrow )
       
   254         {
       
   255         if(keyEvent.iModifiers & EModifierShift)
       
   256             keyEvent.iModifiers&= ~EModifierShift;
       
   257         if(keyEvent.iModifiers & EModifierLeftShift)
       
   258             keyEvent.iModifiers&= ~EModifierLeftShift;
       
   259         if(keyEvent.iModifiers & EModifierRightShift)
       
   260             keyEvent.iModifiers&= ~EModifierRightShift;
       
   261         if(keyEvent.iModifiers & EModifierCtrl)
       
   262             keyEvent.iModifiers&= ~EModifierCtrl;
       
   263         if(keyEvent.iModifiers & EModifierRightCtrl)
       
   264             keyEvent.iModifiers&= ~EModifierRightCtrl;
       
   265         }
       
   266     
       
   267 	// Now handle the Key Event based on the Key type
       
   268     switch ( aKeyEvent.iScanCode )
       
   269         {            
       
   270         case EStdKeyUpArrow:
       
   271         case EStdKeyDownArrow:
       
   272             {
       
   273     	    keyresponse = iListBox->OfferKeyEventL( aKeyEvent, aType );
       
   274             iCmdHandler.HandleCmdL( MEvtMgmtUiCmdHdlr::EListBoxItemFocused );    
       
   275             return keyresponse;        	
       
   276             }
       
   277         case EStdKeyBackspace:
       
   278         case EStdKeyDelete:
       
   279             {
       
   280             if(aType == EEventKey && !keyConsumed )
       
   281                 {
       
   282                 keyresponse = iListBox->OfferKeyEventL( aKeyEvent, aType );
       
   283                 iCmdHandler.HandleCmdL( MEvtMgmtUiCmdHdlr::EListBoxItemDeleted );
       
   284                 }
       
   285             return keyresponse;               
       
   286             }
       
   287         case EStdKeyHash:
       
   288 			{
       
   289             if(!index)
       
   290                 {
       
   291                 keyresponse = EKeyWasConsumed;
       
   292                 }
       
   293             else
       
   294                 {
       
   295                 TBool shiftKeyPressed = ( aKeyEvent.iModifiers & EModifierShift );
       
   296                 keyresponse = iListBox->OfferKeyEventL( aKeyEvent, aType );
       
   297                 if( aType == EEventKeyUp && ( EKeyWasConsumed == keyresponse || !shiftKeyPressed ) )
       
   298                     iCmdHandler.HandleCmdL( MEvtMgmtUiCmdHdlr::EListBoxItemFocused );  
       
   299                 }
       
   300             return keyresponse; 
       
   301 			}
       
   302         default:
       
   303             {
       
   304             break;  
       
   305             }
       
   306         }
       
   307     // Now it's List box's job to process the key event
       
   308     return iListBox->OfferKeyEventL( aKeyEvent, aType ); 
       
   309     }   
       
   310 
       
   311 // ---------------------------------------------------------------------------
       
   312 // void CEvtMgmtUiStartupContainer::HandleResourceChange
       
   313 // ---------------------------------------------------------------------------
       
   314 //
       
   315 void CEvtMgmtUiStartupContainer::HandleResourceChange( TInt aType )
       
   316 	{
       
   317     // Pass the event to the base class
       
   318     CCoeControl::HandleResourceChange(aType);
       
   319     
       
   320     switch( aType )
       
   321         {
       
   322     	case KAknsMessageSkinChange:
       
   323         	{
       
   324         	TRAPD( error, UpdateIconsL() );
       
   325         	if ( error != KErrNone )
       
   326             	{
       
   327             	iEikonEnv->HandleError( error );
       
   328             	}                 
       
   329         	DrawDeferred();
       
   330         	   	
       
   331         	break;
       
   332         	}
       
   333         // Dynamic Layout switch
       
   334         case KEikDynamicLayoutVariantSwitch:
       
   335             {
       
   336             // Handle the screen change event
       
   337             // Trap and Ignore the error
       
   338             TRAP_IGNORE(
       
   339                 iCmdHandler.HandleCmdL( MEvtMgmtUiCmdHdlr::EScreenSizeChanged ));
       
   340             break;
       
   341             }
       
   342         default:
       
   343             {
       
   344             break;
       
   345             }
       
   346         }
       
   347 	}
       
   348 
       
   349 // ---------------------------------------------------------------------------
       
   350 // void CEvtMgmtUiStartupContainer::HandleListBoxEventL
       
   351 // ---------------------------------------------------------------------------
       
   352 //	
       
   353 void CEvtMgmtUiStartupContainer::HandleListBoxEventL( 
       
   354                                     CEikListBox*      /* aListBox */, 
       
   355                           		    TListBoxEvent      aEventType  )
       
   356 	{
       
   357     switch (aEventType)
       
   358         {
       
   359         // List box Item Selection
       
   360         case EEventEnterKeyPressed:
       
   361         case EEventItemSingleClicked:
       
   362             {            
       
   363             iCmdHandler.HandleCmdL( MEvtMgmtUiCmdHdlr::EListBoxItemDoubleClicked );
       
   364             break;  
       
   365             }
       
   366         case EEventItemClicked:
       
   367             {
       
   368             iCmdHandler.HandleCmdL( MEvtMgmtUiCmdHdlr::EListBoxItemFocused);
       
   369             break;
       
   370             }
       
   371         default:
       
   372            break;
       
   373         }	
       
   374 	}
       
   375 	
       
   376 // ---------------------------------------------------------------------------
       
   377 // void CEvtMgmtUiStartupContainer::CreateListboxL
       
   378 // ---------------------------------------------------------------------------
       
   379 // 	
       
   380 void CEvtMgmtUiStartupContainer::CreateListboxL( CEvtMgmtUiModel* aModel )
       
   381     {	
       
   382     EVTUIDEBUG("+ CEvtMgmtUiStartupContainer::CreateListboxL()" );
       
   383 	// Create the List box
       
   384 	iListBox = new ( ELeave ) CEvtMgmtUiListBox();
       
   385     iListBox->ConstructL( this, EAknListBoxStylusMarkableList );
       
   386     iListBox->SetContainerWindowL( *this ); 
       
   387     iListBox->SetListBoxObserver( this );
       
   388     iListBox->CreateScrollBarFrameL(ETrue);
       
   389     iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff,
       
   390     													 CEikScrollBarFrame::EAuto ); 
       
   391  
       
   392     UpdateIconsL();
       
   393      
       
   394 	// Create the Listbox model
       
   395     CEvtMgmtUiListBoxModel* model = static_cast<CEvtMgmtUiListBoxModel*>(iListBox->Model());
       
   396     model->SetItemTextArray( aModel );	
       
   397     model->SetOwnershipType( ELbmDoesNotOwnItemArray ); 
       
   398     model->SetItemTextArrayToFilterModel();
       
   399    								
       
   400     iListBox->ItemDrawer()->ColumnData()->EnableMarqueeL( ETrue );
       
   401         								
       
   402     iListBox->ActivateL();    
       
   403     
       
   404     EVTUIDEBUG("- CEvtMgmtUiStartupContainer::CreateListboxL()" );
       
   405     }
       
   406 
       
   407 // -----------------------------------------------------------------------------
       
   408 // CEvtMgmtUiStartupContainer::CreateFindBoxL()
       
   409 //
       
   410 // Creates the member iFindBox
       
   411 // -----------------------------------------------------------------------------
       
   412 //
       
   413 void CEvtMgmtUiStartupContainer::CreateFindBoxL()
       
   414     {
       
   415     EVTUIDEBUG("+ CEvtMgmtUiStartupContainer::CreateFindBoxL()" );
       
   416 
       
   417     // Create the findbox.
       
   418     iFindBox = CAknSearchField::NewL( *this, CAknSearchField::EAdaptiveSearch, 
       
   419         NULL, KFindBoxTextLength );
       
   420     
       
   421     // Set default input mode to Katakana if current UI language is Japanese
       
   422     if (FeatureManager::FeatureSupported(KFeatureIdJapanese) &&
       
   423         (User::Language() == ELangJapanese))
       
   424         {
       
   425         iFindBox->Editor().SetAknEditorInputMode(EAknEditorKatakanaInputMode);
       
   426         }
       
   427     else
       
   428         {
       
   429         iFindBox->Editor().SetAknEditorCurrentInputMode(EAknEditorTextInputMode);
       
   430         }
       
   431 
       
   432     // Set Column mask
       
   433     iFindBox->SetListColumnFilterFlags(2); // This is set to search only "Subject" column
       
   434 
       
   435     STATIC_CAST(CAknFilteredTextListBoxModel*, iListBox->Model())->CreateFilterL(iListBox,iFindBox);
       
   436     STATIC_CAST(CAknFilteredTextListBoxModel*, iListBox->Model())->Filter()->SetParentControl( this );
       
   437     iListBox->Model()->SetFindToFilterModel(iFindBox);
       
   438         
       
   439     iFindBox->ActivateL();    
       
   440     
       
   441     EVTUIDEBUG("- CEvtMgmtUiStartupContainer::CreateFindBoxL()" );
       
   442     }
       
   443 
       
   444 // -----------------------------------------------------------------------------
       
   445 // CEvtMgmtUiStartupContainer::MakeFindBoxVisible()
       
   446 //
       
   447 // Deletes the member iFindBox
       
   448 // -----------------------------------------------------------------------------
       
   449 //
       
   450 void CEvtMgmtUiStartupContainer::HandleFindBoxVisibility()
       
   451     {
       
   452     if( iListBox && iFindBox )
       
   453         {
       
   454         if(iListBox->Model()->Filter()->FilteredNumberOfItems() < KMinCountForFilter )
       
   455             {
       
   456             iFindBox->SetFocusing( EFalse );
       
   457             iFindBox->MakeVisible( EFalse );
       
   458             iListBox->SetFocusing( ETrue );
       
   459             }
       
   460         else
       
   461             {
       
   462             iFindBox->SetFocusing( ETrue );
       
   463             iFindBox->MakeVisible( ETrue );
       
   464             iListBox->SetFocusing( EFalse );
       
   465             }
       
   466         
       
   467         SizeChanged();
       
   468         DrawNow();
       
   469         }
       
   470     }
       
   471 
       
   472 // -----------------------------------------------------------------------------
       
   473 // CEvtMgmtUiStartupContainer::UpdateIconsL
       
   474 // -----------------------------------------------------------------------------
       
   475 void CEvtMgmtUiStartupContainer::UpdateIconsL()
       
   476     {
       
   477     EVTUIDEBUG( "+ CEvtMgmtUiStartupContainer::UpdateIconsL()" );
       
   478     
       
   479     CAknIconArray* icons = new( ELeave ) CAknIconArray( KIconArrayGranularity );
       
   480     CleanupStack::PushL( icons );
       
   481 
       
   482 	TFileName *iconFile = IconFileNameLC();
       
   483 
       
   484 //Create new event
       
   485     AddIconL( *icons, 
       
   486     		  *iconFile,
       
   487     		  KAknsIIDQgnPropLocevNew, 
       
   488     		  EMbmEvtmgmtuiQgn_prop_locev_new, EMbmEvtmgmtuiQgn_prop_locev_new_mask);
       
   489     
       
   490     //active
       
   491      AddIconL( *icons, 
       
   492              *iconFile,
       
   493              KAknsIIDQgnPropLocevTrigger, 
       
   494              EMbmEvtmgmtuiQgn_prop_locev_trigger, EMbmEvtmgmtuiQgn_prop_locev_trigger_mask);
       
   495             
       
   496     //draft            
       
   497     AddIconL( *icons, 
       
   498              *iconFile,
       
   499              KAknsIIDQgnPropLocevDraft, 
       
   500              EMbmEvtmgmtuiQgn_prop_locev_draft, EMbmEvtmgmtuiQgn_prop_locev_draft_mask);
       
   501        
       
   502    //completed       
       
   503     AddIconL( *icons, 
       
   504                 *iconFile,
       
   505                 KAknsIIDQgnPropLocevCompleted, 
       
   506                 EMbmEvtmgmtuiQgn_prop_locev_completed, EMbmEvtmgmtuiQgn_prop_locev_completed_mask);
       
   507                
       
   508   // repeat                
       
   509 	AddColorIconL( *icons, 
       
   510                 *iconFile,
       
   511                 KAknsIIDQgnIndiRepeatAdd, 
       
   512                 EMbmEvtmgmtuiQgn_indi_repeat_add, EMbmEvtmgmtuiQgn_indi_repeat_add_mask);
       
   513                 
       
   514     CleanupStack::PopAndDestroy(iconFile);
       
   515 
       
   516     //get old icons and delete those
       
   517     CAknIconArray* oldIcons = static_cast<CAknIconArray*>(
       
   518         iListBox->ItemDrawer()->ColumnData()->IconArray() );    
       
   519     delete oldIcons;
       
   520 
       
   521     //set new icons to array
       
   522     iListBox->ItemDrawer()->ColumnData()->SetIconArray( icons );  
       
   523     CleanupStack::Pop(icons);
       
   524     
       
   525     EVTUIDEBUG( "- CEvtMgmtUiStartupContainer::UpdateIconsL()" );
       
   526         
       
   527     }
       
   528     
       
   529 // -----------------------------------------------------------------------------
       
   530 // CEvtMgmtUiStartupContainer::AddIconL
       
   531 // -----------------------------------------------------------------------------
       
   532 void CEvtMgmtUiStartupContainer::AddIconL( CAknIconArray&  aIcons,
       
   533                                            const TDesC&    aIconFileWithPath,
       
   534                                            TAknsItemID     aSkinID,
       
   535                                            TInt            aIconGraphicsIndex,
       
   536                                            TInt            aIconGraphicsMaskIndex )
       
   537     {
       
   538     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   539 
       
   540     EVTUIDEBUG( "AknsUtils::SkinInstance" );
       
   541     
       
   542     CFbsBitmap* bitmap = NULL;
       
   543     CFbsBitmap* bitmapMask = NULL;
       
   544     TRAPD( err, AknsUtils::CreateIconL( skin,
       
   545                             aSkinID,
       
   546                             bitmap,
       
   547                             bitmapMask,
       
   548                             aIconFileWithPath,
       
   549                             aIconGraphicsIndex,
       
   550                             aIconGraphicsMaskIndex ) );
       
   551 
       
   552 	
       
   553     EVTUIDEBUG1( "AknsUtils::CreateIconL - %d", err );
       
   554     if(err != KErrNone)
       
   555 	    {
       
   556 	    TRAP( err, AknIconUtils::CreateIconL( bitmap,
       
   557 	                            bitmapMask,
       
   558 	                            aIconFileWithPath,
       
   559 	                            aIconGraphicsIndex,
       
   560 	                            aIconGraphicsMaskIndex ) );
       
   561     	EVTUIDEBUG1( "AknIconUtils::CreateIconL - %d", err );
       
   562 	    }
       
   563     User::LeaveIfError( err );
       
   564     
       
   565     CleanupStack::PushL( bitmap );
       
   566     CleanupStack::PushL( bitmapMask );
       
   567     
       
   568     CGulIcon* icon = CGulIcon::NewL( bitmap, bitmapMask );
       
   569     
       
   570     // Remove the Bitmap and the Bitmap Icon from the Clean up stack since 
       
   571     // the ownership is taken over by the icon
       
   572     CleanupStack::Pop( bitmapMask );
       
   573     CleanupStack::Pop( bitmap ); 
       
   574     
       
   575     CleanupStack::PushL( icon );
       
   576     aIcons.AppendL( icon );
       
   577     CleanupStack::Pop( icon ); // icon
       
   578     }
       
   579     
       
   580 // -----------------------------------------------------------------------------
       
   581 // CEvtMgmtUiStartupContainer::AddColorIconL
       
   582 // -----------------------------------------------------------------------------
       
   583 void CEvtMgmtUiStartupContainer::AddColorIconL( CAknIconArray&  aIcons,
       
   584                                            const TDesC&    aIconFileWithPath,
       
   585                                            TAknsItemID     aSkinID,
       
   586                                            TInt            aIconGraphicsIndex,
       
   587                                            TInt            aIconGraphicsMaskIndex )
       
   588     {
       
   589     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   590 
       
   591     // Repeat icon. Color skinned with day view icon color 
       
   592     // FIXME: highlight coloring in lists doesn't work for icons.
       
   593     // When Avkon suplies some method to do that, change these 
       
   594     TAknsItemID colorGroup = KAknsIIDQsnIconColors;
       
   595     TInt colorIndex = EAknsCIQsnIconColorsCG19;
       
   596     TRgb nonSkinColor = AKN_LAF_COLOR(215);
       
   597     
       
   598     CFbsBitmap* bitmap = NULL;
       
   599     CFbsBitmap* bitmapMask = NULL;
       
   600     AknsUtils::CreateColorIconLC( skin,
       
   601                             aSkinID,
       
   602                             colorGroup,
       
   603                             colorIndex,
       
   604                             bitmap,
       
   605                             bitmapMask,
       
   606                             aIconFileWithPath,
       
   607                             aIconGraphicsIndex,
       
   608                             aIconGraphicsMaskIndex,
       
   609                             nonSkinColor );
       
   610     
       
   611     CGulIcon* icon = CGulIcon::NewL( bitmap, bitmapMask );
       
   612     
       
   613     // Remove the Bitmap and the Bitmap Icon from the Clean up stack since 
       
   614     // the ownership is taken over by the icon
       
   615     CleanupStack::Pop( bitmapMask );
       
   616     CleanupStack::Pop( bitmap ); 
       
   617     
       
   618     CleanupStack::PushL( icon );
       
   619     aIcons.AppendL( icon );
       
   620     CleanupStack::Pop( icon ); // icon
       
   621     }
       
   622 
       
   623 // -----------------------------------------------------------------------------
       
   624 // CEvtMgmtUiStartupContainer::IconFileNameLC
       
   625 // -----------------------------------------------------------------------------
       
   626 TFileName* CEvtMgmtUiStartupContainer::IconFileNameLC() const
       
   627     {
       
   628     TFileName* fileName = new(ELeave) TFileName;
       
   629     CleanupStack::PushL( fileName );
       
   630     
       
   631 	TFileName* tmpName = new(ELeave) TFileName;
       
   632     CleanupStack::PushL( tmpName );
       
   633 	
       
   634     tmpName->Append( KDC_BITMAP_DIR );
       
   635     tmpName->Append( KEvtMgmtUiIconFileName );
       
   636 
       
   637     CEikAppUi *appUi = ( CEikAppUi *)( CEikonEnv::Static()->AppUi());
       
   638     TFileName appDrive = appUi->Application()->AppFullName();
       
   639     
       
   640     TParse parse;
       
   641     User::LeaveIfError( parse.Set( appDrive, NULL, NULL ) );
       
   642     User::LeaveIfError( parse.Set( parse.Drive(), tmpName, NULL ) );
       
   643     
       
   644 	fileName->Copy(parse.FullName());
       
   645 
       
   646     CleanupStack::PopAndDestroy( tmpName );
       
   647 
       
   648     return fileName;
       
   649     }    
       
   650 // ---------------------------------------------------------------------------
       
   651 // CEvtMgmtUiModel::UpdateListBoxL()
       
   652 // It will update listbox
       
   653 // ---------------------------------------------------------------------------
       
   654 //
       
   655 void CEvtMgmtUiStartupContainer::UpdateListBoxL(TInt aSelectedItemIndex)
       
   656     {   
       
   657     iListBox->Model()->Filter()->ResetFilteringL();
       
   658     iFindBox->ResetL();
       
   659     iListBox->ClearSelection();
       
   660     
       
   661     TInt count = iListBox->Model()->NumberOfItems();
       
   662     if( iPrevCount > count )
       
   663 		{
       
   664         iListBox->HandleItemRemovalL();
       
   665 		iListBox->DrawNow();
       
   666 		}
       
   667     else
       
   668 		{
       
   669         iListBox->HandleItemAdditionL();
       
   670 		}
       
   671             
       
   672     iPrevCount = count;
       
   673                
       
   674     if( aSelectedItemIndex >= count )
       
   675         aSelectedItemIndex = count-1;
       
   676     if(aSelectedItemIndex<0)
       
   677           aSelectedItemIndex = 0;
       
   678 
       
   679     iListBox->SetCurrentItemIndexAndDraw( aSelectedItemIndex );   
       
   680     
       
   681     // Check for FindBox Visiblity
       
   682     HandleFindBoxVisibility();
       
   683     }
       
   684 
       
   685 // ---------------------------------------------------------------------------
       
   686 // CEvtMgmtUiStartupContainer::CurrentItemIndex()
       
   687 // It will return the index of the selected item 
       
   688 // ---------------------------------------------------------------------------
       
   689 //
       
   690 TInt CEvtMgmtUiStartupContainer::CurrentItemIndex()
       
   691     {
       
   692         return iListBox->Model()->Filter()->FilteredItemIndex( iListBox->CurrentItemIndex() );
       
   693     }
       
   694 
       
   695 // ---------------------------------------------------------------------------
       
   696 // CEvtMgmtUiStartupContainer::HandleMarkCmd()
       
   697 // It will handle mark functionality.
       
   698 // ---------------------------------------------------------------------------
       
   699 //
       
   700 void CEvtMgmtUiStartupContainer::HandleMarkCmdL( TInt aIndex, TBool aIsMarked )
       
   701     {
       
   702     CListBoxView* listBoxView = iListBox->View();
       
   703     CAknFilteredTextListBoxModel* model = iListBox->Model();
       
   704     if( aIndex != KErrNotFound )
       
   705         {
       
   706         TInt visibleIndex = model->Filter()->VisibleItemIndex(aIndex);
       
   707         if (aIsMarked)
       
   708              {
       
   709              listBoxView->SelectItemL(visibleIndex);
       
   710              }
       
   711         else
       
   712             {
       
   713             listBoxView->DeselectItem(visibleIndex);
       
   714             }
       
   715         }
       
   716     else
       
   717         {
       
   718         TInt itemCount = model->NumberOfItems();
       
   719         for (TUint i = 1; i < itemCount; i++)
       
   720             {
       
   721             TInt visibleIndex = model->Filter()->VisibleItemIndex(i);
       
   722             if (aIsMarked)
       
   723                 {
       
   724                 listBoxView->SelectItemL(i);
       
   725                 }
       
   726             else
       
   727                 {
       
   728                 listBoxView->DeselectItem(i);
       
   729                 }
       
   730             }
       
   731         }
       
   732     }
       
   733 
       
   734 // ---------------------------------------------------------------------------
       
   735 // CEvtMgmtUiStartupContainer::HandleMarkableListDynInitMenuPane()
       
   736 // It will display mark menu items dynamically
       
   737 // ---------------------------------------------------------------------------
       
   738 //
       
   739 void CEvtMgmtUiStartupContainer::HandleMarkableListDynInitMenuPane( TInt /*ResourceId */, CEikMenuPane *aMenuPane )
       
   740     {
       
   741     TInt pos;
       
   742     if( !aMenuPane->MenuItemExists(EAknCmdMark, pos) )
       
   743         return;
       
   744     
       
   745     TInt markItems = iListBox->SelectionIndexes()->Count();
       
   746     if( iListBox->CurrentItemIndex() == 0 ) //if 'Create New Event'
       
   747         {
       
   748         aMenuPane->SetItemDimmed( EAknCmdMark, ETrue );
       
   749         aMenuPane->SetItemDimmed( EAknCmdUnmark, ETrue );        
       
   750         }
       
   751     else
       
   752         {
       
   753         if(iListBox->View()->ItemIsSelected(iListBox->CurrentItemIndex()) )
       
   754             {
       
   755             aMenuPane->SetItemDimmed( EAknCmdMark, ETrue );
       
   756             aMenuPane->SetItemDimmed( EAknCmdUnmark, EFalse );
       
   757             }
       
   758         else
       
   759             {
       
   760             aMenuPane->SetItemDimmed( EAknCmdMark, EFalse );
       
   761             aMenuPane->SetItemDimmed( EAknCmdUnmark, ETrue );
       
   762             }       
       
   763         }
       
   764     if( markItems < 1 )// if no item is selected
       
   765         {
       
   766         aMenuPane->SetItemDimmed( EAknUnmarkAll, ETrue );
       
   767         }
       
   768     else
       
   769         {
       
   770        aMenuPane->SetItemDimmed( EAknUnmarkAll, EFalse );
       
   771         }
       
   772     
       
   773     if( markItems == iListBox->Model()->NumberOfItems()-1 )// if all items are selected
       
   774         {
       
   775         aMenuPane->SetItemDimmed( EAknMarkAll, ETrue );
       
   776         }
       
   777     else
       
   778         {
       
   779         aMenuPane->SetItemDimmed( EAknMarkAll, EFalse );
       
   780         }   
       
   781     }
       
   782 
       
   783 // ---------------------------------------------------------------------------
       
   784 // CEvtMgmtUiStartupContainer::NumberOfMarkedItems()
       
   785 // It will return count of marked items
       
   786 // ---------------------------------------------------------------------------
       
   787 //
       
   788 TInt CEvtMgmtUiStartupContainer::NumberOfMarkedItems()
       
   789     {
       
   790     return iListBox->SelectionIndexes()->Count();
       
   791     }
       
   792 
       
   793 // ---------------------------------------------------------------------------
       
   794 // CEvtMgmtUiStartupContainer::MarkItems()
       
   795 // It will return marked items
       
   796 // ---------------------------------------------------------------------------
       
   797 //
       
   798 const CArrayFix<TInt>* CEvtMgmtUiStartupContainer::MarkItems()
       
   799     {
       
   800     return iListBox->SelectionIndexes();
       
   801     }
       
   802 
       
   803 // ---------------------------------------------------------------------------
       
   804 // CEvtMgmtUiStartupContainer::FilteredIndex()
       
   805 // It will return marked items
       
   806 // ---------------------------------------------------------------------------
       
   807 //
       
   808 TInt CEvtMgmtUiStartupContainer::FilteredIndex(TInt aIndex)
       
   809     {
       
   810     return iListBox->Model()->Filter()->FilteredItemIndex( aIndex );
       
   811     }
       
   812 
       
   813 // ---------------------------------------------------------------------------
       
   814 // CEvtMgmtUiStartupContainer::FilteredCount()
       
   815 // It will return count of marked items
       
   816 // ---------------------------------------------------------------------------
       
   817 //
       
   818 TInt CEvtMgmtUiStartupContainer::FilteredCount()
       
   819     {
       
   820     return iListBox->Model()->Filter()->FilteredNumberOfItems();
       
   821     }
       
   822 
       
   823 // ---------------------------------------------------------------------------
       
   824 // CEvtMgmtUiStartupContainer::MakeTitleL()
       
   825 // Set the Title Text
       
   826 // ---------------------------------------------------------------------------
       
   827 //
       
   828 void CEvtMgmtUiStartupContainer::MakeTitleL()
       
   829     {
       
   830     // Obtain the title from the Status Pane
       
   831     CAknTitlePane* title = static_cast<CAknTitlePane*>( iEikonEnv->AppUiFactory()->
       
   832     	StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidTitle )));
       
   833        
       
   834     // Set the Title's buffer    
       
   835     HBufC* buf = StringLoader::LoadL( R_EVTUI_TITLE );    
       
   836     title->SetText( buf ); // Takes ownership of buf 
       
   837     }    
       
   838 // End of File