eventsui/eventseditor/src/evteditor.cpp
branchRCL_3
changeset 18 870918037e16
equal deleted inserted replaced
17:1fc85118c3ae 18:870918037e16
       
     1 /*
       
     2 * Copyright (c) 2008 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:   Form class for creating events.
       
    15 *
       
    16 */
       
    17 
       
    18 #include <evtmgmteditorui.rsg>
       
    19 #include <avkon.rsg>
       
    20 #include <avkon.hrh>
       
    21 #include <eikedwin.h>
       
    22 #include <eikmenup.h>
       
    23 #include <eikenv.h>
       
    24 #include <aknlistquerydialog.h>
       
    25 #include <StringLoader.h>
       
    26 #include <eikaufty.h>
       
    27 #include <AknPopupFieldText.h> 
       
    28 #include <eikenv.h>
       
    29 #include <eikspane.h>       // Status pane
       
    30 #include <akntitle.h>       // CAknTitlePane
       
    31 #include <aknuniteditor.h> 
       
    32 #include <e32math.h>
       
    33 #include <AknIconArray.h>       // Icon Array
       
    34 #include <evteditor.mbg>
       
    35 #include <AknsUtils.h>
       
    36 #include <AknsSkinInstance.h>
       
    37 #include <data_caging_path_literals.hrh>
       
    38 #include <gulicon.h>            // Gul Icon
       
    39 #include <eikapp.h>
       
    40 #include <eikenv.h>
       
    41 #include <barsread.h>               // For TResourceReader
       
    42 #include <bautils.h> 
       
    43 #include <eikserverapp.h>
       
    44 #include <aknappui.h>
       
    45 #include <AknUtils.h>
       
    46 #include <aknnotewrappers.h>
       
    47 #include <hlplch.h>
       
    48 
       
    49 #include "evteditor.h"
       
    50 #include "evtmgmteditorui.hrh"
       
    51 #include "evtevent.h"
       
    52 #include "evttoneaction.h"
       
    53 #include "evtdebug.h"
       
    54 #include "evteditorconsts.h"
       
    55 #include "evtmgmtuiringtonecomponent.h"
       
    56 #include "evtdefs.h"
       
    57 
       
    58 // ---------------------------------------------------------------------------
       
    59 // CEvtEditor::NewL()
       
    60 // @param[in] aIsEditMode - It sets mode of editor. 
       
    61 //                          If true, edit mode is set else view mode is set. 
       
    62 // @param[in] aEvent - The event to be displayed on editor
       
    63 //                     Empty if new event is going to be created.
       
    64 // @param[in] aTriggerLocation - Coordinate based location details of 
       
    65 //                                  the event to be displayed on editor. 
       
    66 // @param[in] aExitCmdHandler - It handles all commands which may result into closing editor.
       
    67 // ---------------------------------------------------------------------------
       
    68 //
       
    69 CEvtEditor* CEvtEditor ::NewL(TBool                             aIsEditable, 
       
    70                              CEvtEvent&                         aEvent, 
       
    71                              CEvtMgmtUiEngine&                  aEventEngine,
       
    72                              TBool                              aDisplayExitMenuItem
       
    73                              )
       
    74     {
       
    75     CEvtEditor * self = new (ELeave) CEvtEditor(aIsEditable, aEvent, aEventEngine, aDisplayExitMenuItem );
       
    76     CleanupStack::PushL(self);
       
    77     self->ConstructL();
       
    78     CleanupStack::Pop(self);
       
    79     return self;
       
    80     }
       
    81 
       
    82 // ---------------------------------------------------------------------------
       
    83 // CEvtEditor::~CEvtEditor()
       
    84 // ---------------------------------------------------------------------------
       
    85 //
       
    86 CEvtEditor::~CEvtEditor()
       
    87     {  
       
    88 	EVTUIDEBUG("+ CEvtEditor::~CEvtEditor()");
       
    89     // Close the resource loader
       
    90     iResourceLoader.Close();
       
    91        
       
    92     if(iCmdHandler)
       
    93         {
       
    94         delete iCmdHandler;
       
    95         iCmdHandler = NULL;
       
    96         }
       
    97     
       
    98     delete iSysOfMeas;
       
    99     iSysOfMeas = NULL;
       
   100 	EVTUIDEBUG("- CEvtEditor::~CEvtEditor()");
       
   101     }
       
   102 
       
   103 // ---------------------------------------------------------------------------
       
   104 // CEvtEditor ::ConstructL()
       
   105 // ---------------------------------------------------------------------------
       
   106 //
       
   107 void CEvtEditor ::ConstructL()
       
   108     {
       
   109 	EVTUIDEBUG("+ CEvtEditor::ConstructL()");
       
   110     // Open the Resource File
       
   111     OpenLocalizedResourceFileL( KEvtEditorResFileName, iResourceLoader );
       
   112        
       
   113     CAknForm::ConstructL(R_EVTMGMTUI_CREATEEVENTFORM_MENUBAR);    
       
   114     iCmdHandler = CEvtMgmtUiEditorCmdHandler::NewL( iEvent, 
       
   115                                                     *this,
       
   116                                                     iEventEngine );
       
   117     
       
   118     // Observer for a change in System of Measurement
       
   119     iSysOfMeas = CEvtMgmtUiSysOfMeasurement::NewL(*this);
       
   120     	EVTUIDEBUG("- CEvtEditor::ConstructL()");
       
   121     }
       
   122 
       
   123 // ---------------------------------------------------------------------------
       
   124 // CEvtEditor ::CEvtEditor()
       
   125 // ---------------------------------------------------------------------------
       
   126 //
       
   127 CEvtEditor::CEvtEditor( TBool                           aIsEditable, 
       
   128                         CEvtEvent&                      aEvent,
       
   129                         CEvtMgmtUiEngine&               aEventEngine,
       
   130                         TBool                           aDisplayExitMenuItem)
       
   131     :iIsEditMode( aIsEditable ), 
       
   132     iEvent( aEvent ), 
       
   133     iResourceLoader( *CCoeEnv::Static()),
       
   134     iEventEngine( aEventEngine ),
       
   135     iDisplayExitMenuItem( aDisplayExitMenuItem )
       
   136     {
       
   137     iEventAttributeMask = 0;
       
   138     }
       
   139 
       
   140 // ---------------------------------------------------------------------------
       
   141 // Derived from CEikDialog
       
   142 // CEvtEditor ::OkToExitL()
       
   143 // ---------------------------------------------------------------------------
       
   144 //
       
   145 TBool CEvtEditor::OkToExitL( TInt aButtonId )
       
   146     {
       
   147 	EVTUIDEBUG1("+ CEvtEditor::OkToExitL() - %d", aButtonId );
       
   148     switch(aButtonId)
       
   149         {
       
   150         case EAknFormCmdEdit: // when MSK is pressed
       
   151             {
       
   152             //Handle MSK operation based on focused line.
       
   153             HandleMSKL(); 
       
   154             //dont close editor
       
   155             return EFalse;
       
   156             }
       
   157         case EAknSoftkeyOptions: //when LSK is pressed
       
   158             {
       
   159             //display menu specific to editor
       
   160             DisplayMenuL();
       
   161             //don't close editor
       
   162             return EFalse;
       
   163             }
       
   164         case EAknSoftkeyDone: // when RSK is pressed in edit mode
       
   165             {
       
   166             return ProcessDoneCommandL();
       
   167             }
       
   168         default: // close editor in all other cases
       
   169             {
       
   170             return ETrue;
       
   171             }
       
   172         }
       
   173     }
       
   174 
       
   175 // ---------------------------------------------------------------------------
       
   176 // CEvtEditor::ProcessDoneCommandL()
       
   177 // It checks if event is empty.
       
   178 // @ret true if event is empty else false
       
   179 // ---------------------------------------------------------------------------
       
   180 //
       
   181 TBool CEvtEditor::ProcessDoneCommandL()
       
   182     {                
       
   183     //validate event, if valid event, display 'Event status' popup dialog
       
   184     // and perform selected operation.          
       
   185     if( IsEmptyEventL() || !iEventAttributeMask )
       
   186         {
       
   187         return ETrue;
       
   188         }                
       
   189     else
       
   190         {
       
   191         //update attribute mask so that only those attributes of event will be modified                    
       
   192         iCmdHandler->SetEventAttributeMask( iEventAttributeMask );
       
   193 
       
   194         if(EActive == iEvent.EventStatus())
       
   195             {
       
   196             if(MandatoryFieldsFilled())
       
   197                 {
       
   198                 iCmdHandler->HandleEditorCmdL( EEvtEditorCmdActivate );
       
   199                 }
       
   200             else
       
   201                 {
       
   202                 HBufC* infoMsg = StringLoader::LoadLC(R_LOCEV_NOTE_MISSED_INFO );
       
   203                 CAknInformationNote* infoNote = new(ELeave) CAknInformationNote( ETrue );
       
   204                 infoNote->ExecuteLD( *infoMsg  );
       
   205                 CleanupStack::PopAndDestroy();
       
   206                 }
       
   207             }
       
   208         else
       
   209             {
       
   210             iCmdHandler->HandleEditorCmdL( EEvtEditorCmdSaveDraft );
       
   211             }
       
   212             
       
   213         return EFalse;
       
   214         }
       
   215     }
       
   216 
       
   217 // ---------------------------------------------------------------------------
       
   218 // CEvtEditor::IsEmptyEventL()
       
   219 // It checks if event is empty.
       
   220 // @ret true if event is empty else false
       
   221 // ---------------------------------------------------------------------------
       
   222 //
       
   223 TBool CEvtEditor::IsEmptyEventL()
       
   224     {    
       
   225     //if eventid is not zero, it means existing event is opened in editor
       
   226     //hence it is not empty event.
       
   227     if(iEvent.EventId())
       
   228         return EFalse;
       
   229 
       
   230     // Check for Default Action
       
   231     TBool defaultAction(EFalse);
       
   232     if( iEvent.HasAction() )
       
   233         {            
       
   234         CEvtToneAction* tone = CEvtToneAction::NewLC();  
       
   235         tone->InternalizeL( iEvent.Action() );  
       
   236         CEvtMgmtUiRingtoneComponent* ringtoneComponent = CEvtMgmtUiRingtoneComponent::NewLC( KNullDesC() );
       
   237         if( ringtoneComponent->DefaultRingtoneL().Compare( tone->FileName() ) == 0 && 
       
   238                 !tone->ToneLoop() )
       
   239             {
       
   240             defaultAction = ETrue;
       
   241             }
       
   242         CleanupStack::PopAndDestroy( 2 ); // tone, ringtoneComponent
       
   243         }
       
   244     
       
   245     //if eventid is zero, it means new event is about to create.
       
   246     //hence check if something is entered by the user.    
       
   247     if( 6 == GetNumberOfLinesOnPage(0) && //if only subject,place and repeat are present
       
   248         0 == iEvent.Subject().Compare(KNullDesC) && //if subject is empty
       
   249         0 == iEvent.Place().Compare(KNullDesC) && // if place is default
       
   250         0 == iEvent.Repeat() && // if repeat is OFF
       
   251         EDraft == iEvent.EventStatus() &&
       
   252         defaultAction ) // if Status is Draft
       
   253         {       
       
   254         return ETrue; 
       
   255         }  
       
   256     return EFalse;
       
   257     }
       
   258 
       
   259 // ---------------------------------------------------------------------------
       
   260 // CEvtEditor ::LoadFormValuesFromDataL()
       
   261 // Called when the form is  executed and when the user chooses to discard changes
       
   262 // in QuerySaveChangesL (via  DoNotSaveFormDataL).
       
   263 // ---------------------------------------------------------------------------
       
   264 // 
       
   265 void CEvtEditor::LoadFormValuesFromDataL()
       
   266     {
       
   267 	EVTUIDEBUG("+ CEvtEditor::LoadFormValuesFromDataL()");
       
   268     if(iEvent.EventId()==0) //if create event
       
   269         {
       
   270         CEikEdwin* placeEditor = static_cast <CEikEdwin*> (ControlOrNull(EEvtMgmtUiDlgCIdPlace));            
       
   271             if(placeEditor)
       
   272                 {   
       
   273                 if( iEvent.Place().Compare(KNullDesC) == 0 )  
       
   274                     {
       
   275                     HBufC* define = StringLoader::LoadLC(R_EVTUI_CREATENEW_FORM_DEFINED);   
       
   276                     placeEditor->SetTextL(define);
       
   277                     CleanupStack::PopAndDestroy(define);
       
   278                     }               
       
   279                 } 
       
   280             
       
   281         CAknPopupFieldText* repeatPopupFieldText = (CAknPopupFieldText*)Control( EEvtMgmtUiDlgCIdRepeat );
       
   282             if(repeatPopupFieldText)
       
   283                 {  
       
   284                 repeatPopupFieldText->SetCurrentValueIndex(1);      
       
   285                 }
       
   286 
       
   287         // Set the Default Ringtone
       
   288         CEvtMgmtUiRingtoneComponent* ringtoneComponent = CEvtMgmtUiRingtoneComponent::NewLC( KNullDesC() );
       
   289         if( ringtoneComponent->DefaultRingtoneL().Compare( KNullDesC ) == 0 )
       
   290             {
       
   291             iEvent.SetActionL( NULL );
       
   292             }
       
   293         else
       
   294             {
       
   295             CEvtToneAction* tone = CEvtToneAction::NewLC();
       
   296             tone->SetFileNameL( ringtoneComponent->Ringtone() );
       
   297             tone->SetToneLoop( EFalse );  
       
   298       
       
   299             CEvtAction* action = CEvtAction::NewLC();
       
   300             tone->ExternalizeL( *action );
       
   301             iEvent.SetActionL( action ); // ownership is transferred.
       
   302             CleanupStack::Pop( action ); // action  
       
   303 
       
   304             CleanupStack::PopAndDestroy( ); // tone        
       
   305             }
       
   306         CleanupStack::PopAndDestroy( ); // ringtoneComponent   
       
   307         
       
   308         SetRingtoneL();
       
   309         
       
   310         // Set Default Status
       
   311         iEvent.SetEventStatus(EDraft);
       
   312         SetStatusL();
       
   313         
       
   314         return;
       
   315         }
       
   316     
       
   317    //assign initial values
       
   318    	CEikEdwin* subjectEditor = static_cast <CEikEdwin*> (ControlOrNull(EEvtMgmtUiDlgCIdSubject));
       
   319     if(subjectEditor )
       
   320         {        
       
   321 		if( iEvent.Subject().Compare(KNullDesC) != 0 )
       
   322 			{
       
   323 			HBufC* subject = iEvent.Subject().AllocLC();   
       
   324 			subjectEditor->SetTextL( subject );
       
   325 			CleanupStack::PopAndDestroy(subject);
       
   326 			}
       
   327         }
       
   328    
       
   329     CEikEdwin* placeEditor = static_cast <CEikEdwin*> (ControlOrNull(EEvtMgmtUiDlgCIdPlace));            
       
   330     if(placeEditor)
       
   331         {   
       
   332         if( iEvent.Place().Compare(KNullDesC) == 0 )  
       
   333 	        {
       
   334 			HBufC* define = StringLoader::LoadLC(R_EVTUI_CREATENEW_FORM_DEFINED);   
       
   335 			placeEditor->SetTextL(define);
       
   336 			CleanupStack::PopAndDestroy(define);
       
   337 	        }
       
   338 	    else
       
   339 		    {
       
   340 			HBufC* place = iEvent.Place().AllocLC();   
       
   341 			placeEditor->SetTextL(place);
       
   342 			CleanupStack::PopAndDestroy(place);
       
   343             EVTUIDEBUG(" Setting Radius");
       
   344             InsertRadiusDlgLineL();
       
   345 		    }
       
   346 	    }     
       
   347     
       
   348     CAknPopupFieldText* repeatPopupFieldText = (CAknPopupFieldText*)Control( EEvtMgmtUiDlgCIdRepeat );
       
   349     if(repeatPopupFieldText)
       
   350         {    
       
   351         if(iEvent.Repeat())
       
   352             repeatPopupFieldText->SetCurrentValueIndex(0);
       
   353          else
       
   354              repeatPopupFieldText->SetCurrentValueIndex(1);      
       
   355         }
       
   356     
       
   357     // Set Ringtone
       
   358     SetRingtoneL();
       
   359     
       
   360     // Set Status
       
   361     SetStatusL();
       
   362        
       
   363     if( iEvent.Description().Compare(KNullDesC)!=0 )
       
   364         {
       
   365         InsertDesDlgLineL();
       
   366         SetDescL();
       
   367         }
       
   368 	EVTUIDEBUG("- CEvtEditor::LoadFormValuesFromDataL()");
       
   369     }
       
   370  
       
   371 // ---------------------------------------------------------------------------
       
   372 // Derived from CEikDialog
       
   373 // CEvtEditor ::PreLayoutDynInitL()
       
   374 // ---------------------------------------------------------------------------
       
   375 // 
       
   376 void CEvtEditor::PreLayoutDynInitL()
       
   377     {
       
   378 	EVTUIDEBUG("+ CEvtEditor::PreLayoutDynInitL()");
       
   379     CAknForm::PreLayoutDynInitL();
       
   380     
       
   381     //Load existing event if it is opened in viewe mode  
       
   382     LoadFormValuesFromDataL();
       
   383 	EVTUIDEBUG("- CEvtEditor::PreLayoutDynInitL()");
       
   384     }
       
   385  
       
   386 // ---------------------------------------------------------------------------
       
   387 // Derived from CEikDialog
       
   388 // CEvtEditor ::PostLayoutDynInitL()
       
   389 // ---------------------------------------------------------------------------
       
   390 // 
       
   391 void CEvtEditor::PostLayoutDynInitL()
       
   392     {
       
   393 	EVTUIDEBUG("+ CEvtEditor::PostLayoutDynInitL()");
       
   394    CAknForm::PostLayoutDynInitL();
       
   395    
       
   396      if(iEvent.Subject().Compare(KNullDesC) == 0)
       
   397         {
       
   398         if(iEvent.EventId())
       
   399             {
       
   400             TPtrC ptr = KNullDesC();
       
   401             MakeTitleL(ptr);  
       
   402             }
       
   403         else
       
   404             {
       
   405             HBufC* navititle = StringLoader::LoadLC( R_EVTUI_CREATENEW_FORM_DEFAULTNAVITITLE);
       
   406             MakeTitleL(*navititle);  
       
   407             CleanupStack::PopAndDestroy(navititle);
       
   408             }
       
   409         }
       
   410     else
       
   411         {
       
   412         TPtrC ptr = iEvent.Subject();
       
   413         MakeTitleL( ptr);
       
   414         }
       
   415             
       
   416     ChangeRSKCaptionL();
       
   417     SetEditableL(iIsEditMode);
       
   418 	EVTUIDEBUG("- CEvtEditor::PostLayoutDynInitL()");
       
   419     }
       
   420 // ---------------------------------------------------------------------------
       
   421 // Derived from CAknForm
       
   422 // CEvtEditor ::DynInitMenuPaneL()
       
   423 // ---------------------------------------------------------------------------
       
   424 //  
       
   425 void CEvtEditor ::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane)
       
   426     {
       
   427     CAknForm::DynInitMenuPaneL(aResourceId,aMenuPane);
       
   428 
       
   429     if (aResourceId == R_AVKON_FORM_MENUPANE)
       
   430         {  
       
   431         
       
   432         // Disable all the unwanted AKnForm's Default Menu Items 
       
   433         aMenuPane->SetItemDimmed(EAknFormCmdLabel, ETrue);
       
   434         aMenuPane->SetItemDimmed(EAknFormCmdAdd, ETrue);
       
   435         aMenuPane->SetItemDimmed(EAknFormCmdDelete, ETrue);
       
   436         aMenuPane->SetItemDimmed(EAknFormCmdSave, ETrue);
       
   437         
       
   438         if(iDisplayExitMenuItem)
       
   439             aMenuPane->SetItemDimmed(EAknCmdExit, EFalse);
       
   440         else
       
   441             aMenuPane->SetItemDimmed(EAknCmdExit, ETrue);
       
   442         
       
   443         if( IsEditable() )
       
   444 	        {
       
   445 	        // "Edit" present only in Viewer mode
       
   446 	        aMenuPane->SetItemDimmed(EAknFormCmdEdit, ETrue);
       
   447 	        
       
   448 	        // "Discard Changes" has to be present only in Edit mode
       
   449 	        // and if some changes are made
       
   450 	        if( IsEmptyEventL() || !iEventAttributeMask || !iEvent.EventId())
       
   451 	            aMenuPane->SetItemDimmed(EEvtEditorCmdDiscard, ETrue);
       
   452 	        else
       
   453                 aMenuPane->SetItemDimmed(EEvtEditorCmdDiscard, EFalse);
       
   454             
       
   455             // Initially display all the Editor specific Menu items which 
       
   456             // are dimmed based on focus and context
       
   457 			aMenuPane->SetItemDimmed(EEvtEditorCmdAddDesc, ETrue);
       
   458 			aMenuPane->SetItemDimmed(EEvtEditorCmdRemoveDesc, ETrue);
       
   459 			aMenuPane->SetItemDimmed(EEvtEditorCmdSetPlace, ETrue);
       
   460 			aMenuPane->SetItemDimmed(EEvtEditorCmdEditDesc, ETrue);
       
   461 
       
   462 			if(NULL == ControlOrNull(EEvtMgmtUiDlgCIdAssignTone))
       
   463 			    aMenuPane->SetItemDimmed(EEvtEditorCmdAssignTone, EFalse);
       
   464 			else
       
   465 			    aMenuPane->SetItemDimmed(EEvtEditorCmdAssignTone, ETrue);
       
   466 	        
       
   467 	        // "Add Description" / "Remove Description" is displayed based
       
   468 	        // on Decsription control's existance in Form
       
   469 	        if( NULL == ControlOrNull(EEvtMgmtUiDlgCIdDesc) )
       
   470 	            {
       
   471 	            aMenuPane->SetItemDimmed(EEvtEditorCmdAddDesc, EFalse);
       
   472 	        	aMenuPane->SetItemDimmed(EEvtEditorCmdRemoveDesc, ETrue);
       
   473 	            }
       
   474 	        else
       
   475 	            {
       
   476 	            aMenuPane->SetItemDimmed(EEvtEditorCmdAddDesc, ETrue);
       
   477 	        	aMenuPane->SetItemDimmed(EEvtEditorCmdRemoveDesc, EFalse);
       
   478 	            }
       
   479             
       
   480 	        // Menu items whose existance depends on the focussed control
       
   481 	        switch( IdOfFocusControl() )
       
   482 	            {
       
   483 	            case EEvtMgmtUiDlgCIdPlace:
       
   484 	                {
       
   485 	                aMenuPane->SetItemDimmed(EEvtEditorCmdSetPlace, EFalse);
       
   486 	                break;
       
   487 	                }
       
   488 	            case EEvtMgmtUiDlgCIdDesc:            
       
   489 	                {
       
   490 	                aMenuPane->SetItemDimmed(EEvtEditorCmdEditDesc, EFalse);
       
   491 	                break;
       
   492 	                }    
       
   493 	            case EEvtMgmtUiDlgCIdAssignTone:              
       
   494 	                {
       
   495 	                aMenuPane->SetItemDimmed(EAknFormCmdEdit, ETrue);
       
   496 	                aMenuPane->SetItemDimmed(EEvtEditorCmdAssignTone, EFalse);
       
   497 	                break;
       
   498 	                }    
       
   499 	            case EEvtMgmtUiDlgCIdRepeat:
       
   500 	            case EEvtMgmtUiDlgCIdAudioLoop:   
       
   501                 case EEvtMgmtUiDlgCIdStatus:            
       
   502 	                {
       
   503 	        		aMenuPane->SetItemDimmed(EAknFormCmdEdit, EFalse);
       
   504         			aMenuPane->SetItemTextL(EAknFormCmdEdit,R_EVTUI_CREATENEW_FORM_CMDCHANGE);
       
   505 	                break;
       
   506 	                }    
       
   507 	            default:
       
   508 	                {
       
   509 	                break;
       
   510 	                }                
       
   511 	            }//switch
       
   512  
       
   513             // Activate and Draft are absent in Edit mode
       
   514             aMenuPane->SetItemDimmed(EEvtEditorCmdActivate, ETrue);
       
   515             aMenuPane->SetItemDimmed(EEvtEditorCmdSaveDraft, ETrue);
       
   516 	            
       
   517 	        // Editor/Viewer specific menu items    
       
   518     		aMenuPane->SetItemDimmed(EEvtEditorCmdNavigateToPlace, ETrue);
       
   519     		aMenuPane->SetItemDimmed(EEvtEditorCmdShowOnMap, ETrue);
       
   520     		aMenuPane->SetItemDimmed(EEvtMgmtUiEventUiPosSettings, EFalse);
       
   521 	        }
       
   522 	    else   // View Mode
       
   523 	        {
       
   524 	        // "Edit" present only in Viewer mode
       
   525 	        aMenuPane->SetItemDimmed(EAknFormCmdEdit, EFalse);
       
   526             
       
   527             // "Discard Changes" has to be absent only in View mode
       
   528             aMenuPane->SetItemDimmed(EEvtEditorCmdDiscard, ETrue);
       
   529             
       
   530             // Dim all the Editor specific Menu items.
       
   531 			aMenuPane->SetItemDimmed(EEvtEditorCmdAddDesc, ETrue);
       
   532 			aMenuPane->SetItemDimmed(EEvtEditorCmdRemoveDesc, ETrue);
       
   533 			aMenuPane->SetItemDimmed(EEvtEditorCmdSetPlace, ETrue);
       
   534 			aMenuPane->SetItemDimmed(EEvtEditorCmdEditDesc, ETrue);
       
   535 			aMenuPane->SetItemDimmed(EEvtEditorCmdAssignTone, ETrue);
       
   536             
       
   537             // Menu items that depend on Event's status
       
   538     		switch( iEvent.EventStatus() )
       
   539     			{
       
   540     			case EActive:
       
   541     			    {
       
   542             		aMenuPane->SetItemDimmed(EEvtEditorCmdActivate, ETrue);
       
   543             		aMenuPane->SetItemDimmed(EEvtEditorCmdSaveDraft, EFalse);
       
   544     				break;
       
   545     			    }
       
   546     			case EDraft:
       
   547     			    {
       
   548     			    if(MandatoryFieldsFilled())
       
   549     			        aMenuPane->SetItemDimmed(EEvtEditorCmdActivate, EFalse);
       
   550     			    else
       
   551     			        aMenuPane->SetItemDimmed(EEvtEditorCmdActivate, ETrue);
       
   552             		aMenuPane->SetItemDimmed(EEvtEditorCmdSaveDraft, ETrue);
       
   553     				break;
       
   554     			    }
       
   555                 case ECompleted:
       
   556                     {
       
   557                     aMenuPane->SetItemDimmed(EEvtEditorCmdActivate, EFalse);
       
   558                     aMenuPane->SetItemDimmed(EEvtEditorCmdSaveDraft, EFalse);
       
   559                     break;
       
   560                     }
       
   561     			default:
       
   562     				break;
       
   563     			}
       
   564     			
       
   565 	        // if location is defined
       
   566     		if( Math::IsNaN( iEvent.Location().Latitude() ) || Math::IsNaN( iEvent.Location().Latitude() )
       
   567     			|| iEvent.Location().Latitude() == 0 || iEvent.Location().Latitude() == 0 ) 
       
   568     		    {
       
   569         		aMenuPane->SetItemDimmed(EEvtEditorCmdNavigateToPlace, ETrue);
       
   570         		aMenuPane->SetItemDimmed(EEvtEditorCmdShowOnMap, ETrue);
       
   571     		    }
       
   572     		else
       
   573     		    {
       
   574     		    aMenuPane->SetItemDimmed(EEvtEditorCmdNavigateToPlace, EFalse);
       
   575                 aMenuPane->SetItemDimmed(EEvtEditorCmdShowOnMap, EFalse);
       
   576                  }
       
   577     		aMenuPane->SetItemDimmed(EEvtMgmtUiEventUiPosSettings, ETrue);
       
   578 	        }
       
   579 
       
   580         }//if
       
   581     }
       
   582 // -----------------------------------------------------------------------------
       
   583 // Derived from CEikDialog
       
   584 // CEvtEditor::HandleControlStateChangeL()
       
   585 // Called when focus is moved from the specified line.
       
   586 // -----------------------------------------------------------------------------
       
   587 //
       
   588 void CEvtEditor::HandleControlStateChangeL(TInt aControlId)
       
   589     {
       
   590 	EVTUIDEBUG1("+ CEvtEditor::PostLayoutDynInitL() - %d", aControlId );
       
   591     switch(aControlId)
       
   592         {
       
   593         case EEvtMgmtUiDlgCIdSubject:
       
   594             {            
       
   595             iEventAttributeMask  = iEventAttributeMask | CEvtMgmtUiEngine::EEvtEventAttributeSubject;
       
   596             
       
   597             //Retrieve subject text 
       
   598             CEikEdwin* subjectEditor = static_cast <CEikEdwin*> (ControlOrNull(EEvtMgmtUiDlgCIdSubject));            
       
   599             if(subjectEditor)
       
   600                 {                       
       
   601                 HBufC* subject = subjectEditor->GetTextInHBufL();
       
   602                 if( subject )
       
   603 	                {
       
   604 	                CleanupStack::PushL(subject);
       
   605 	                subject->Des().Trim();
       
   606 	                iEvent.SetSubjectL(*subject);
       
   607                 	MakeTitleL(*subject); 
       
   608 	                CleanupStack::PopAndDestroy(subject);
       
   609 	                }
       
   610 	            else
       
   611 	                {
       
   612 	                iEvent.SetSubjectL(KNullDesC);
       
   613 	                HBufC* navititle = StringLoader::LoadLC( R_EVTUI_CREATENEW_FORM_DEFAULTNAVITITLE);
       
   614 	                MakeTitleL(*navititle);             
       
   615 	                CleanupStack::PopAndDestroy(navititle);	
       
   616 	                }
       
   617                 }              
       
   618             break;
       
   619             } 
       
   620         case EEvtMgmtUiDlgCIdRadius:
       
   621             {
       
   622             iEventAttributeMask  = iEventAttributeMask | CEvtMgmtUiEngine::EEvtEventAttributeRadius;
       
   623             CAknUnitEditor* radiusEd =
       
   624                  (CAknUnitEditor*)Control( EEvtMgmtUiDlgCIdRadius );
       
   625             if(radiusEd)
       
   626                 {
       
   627                 //convert radius in km unit
       
   628                 TReal val(0);
       
   629         		if( EAknUnitEditorMile == radiusEd->Unit() )
       
   630         			{        			
       
   631         			val = radiusEd->Value();
       
   632         			val /= KUnitConversion;        		       			       			
       
   633         			}
       
   634         		if( EAknUnitEditorKilometer ==radiusEd->Unit() )
       
   635         		    val = radiusEd->Value();
       
   636         		
       
   637         		//validate radius value
       
   638         		if( val<KMinRadiusInKm ) //if less than minima, set to minima
       
   639         		    iEvent.SetRadius( KMinRadiusInKm );
       
   640         		else if( val>KMaxRadiusInKm ) //if greater than maxima, set to maxima
       
   641         		    iEvent.SetRadius( KMaxRadiusInKm );
       
   642         		else
       
   643         		    iEvent.SetRadius( val );
       
   644                 }
       
   645             break;
       
   646             } 
       
   647         case EEvtMgmtUiDlgCIdRepeat:
       
   648            {
       
   649            iEventAttributeMask  = iEventAttributeMask | CEvtMgmtUiEngine::EEvtEventAttributeRepeat;
       
   650            CAknPopupFieldText* repeatPopupFieldText =
       
   651                  (CAknPopupFieldText*)Control( EEvtMgmtUiDlgCIdRepeat );
       
   652            if(repeatPopupFieldText)
       
   653                {
       
   654                if(repeatPopupFieldText->CurrentValueIndex() == 0)               
       
   655                    iEvent.SetRepeat( ETrue );
       
   656                else
       
   657                    iEvent.SetRepeat( EFalse );   
       
   658                }
       
   659            break;
       
   660            }
       
   661         case EEvtMgmtUiDlgCIdAudioLoop:
       
   662            {
       
   663            iEventAttributeMask  = iEventAttributeMask | CEvtMgmtUiEngine::EEvtEventAttributeAudioLoop;                 
       
   664            CAknPopupFieldText* audioLoopPopupFieldText =
       
   665                  (CAknPopupFieldText*)Control( EEvtMgmtUiDlgCIdAudioLoop );
       
   666            if(audioLoopPopupFieldText)
       
   667                {
       
   668                CEvtToneAction* tone = CEvtToneAction::NewLC();
       
   669                tone->InternalizeL( iEvent.Action() );
       
   670                if( audioLoopPopupFieldText->CurrentValueIndex() == 0)
       
   671                    tone->SetToneLoop( EFalse );
       
   672                else
       
   673                    tone->SetToneLoop( ETrue );   
       
   674                
       
   675                 CEvtAction* action = CEvtAction::NewLC();
       
   676                 tone->ExternalizeL( *action );
       
   677                 iEvent.SetActionL( action ); //ownership is transferred.
       
   678                 CleanupStack::Pop( action );
       
   679                 CleanupStack::PopAndDestroy( tone );
       
   680                }
       
   681            break;
       
   682            }    
       
   683         case EEvtMgmtUiDlgCIdStatus:
       
   684            {
       
   685            iEventAttributeMask  = iEventAttributeMask | CEvtMgmtUiEngine::EEvtEventAttributeStatus;                 
       
   686            CAknPopupFieldText* statusPopupFieldText =
       
   687                  (CAknPopupFieldText*)Control( EEvtMgmtUiDlgCIdStatus );
       
   688            if(statusPopupFieldText)
       
   689                {
       
   690                switch(statusPopupFieldText->CurrentValueIndex())
       
   691                    {
       
   692                    case 0:
       
   693                        iEvent.SetEventStatus(EActive);
       
   694                        break;
       
   695                    case 1:
       
   696                        iEvent.SetEventStatus(EDraft);
       
   697                        break;
       
   698                    case 2:
       
   699                        iEvent.SetEventStatus(ECompleted);
       
   700                        break;
       
   701                    default:
       
   702                        iEvent.SetEventStatus(EDraft);
       
   703                        break;
       
   704                    }
       
   705                }
       
   706            break;
       
   707            }                
       
   708         }
       
   709 	EVTUIDEBUG("- CEvtEditor::PostLayoutDynInitL()");
       
   710     }
       
   711 
       
   712 
       
   713 // -----------------------------------------------------------------------------
       
   714 // CEvtEditor::ProcessCommandL()
       
   715 // It handles command events
       
   716 // -----------------------------------------------------------------------------
       
   717 //
       
   718 void CEvtEditor::ProcessCommandL(TInt  aCommandId)
       
   719     {      
       
   720 	EVTUIDEBUG1("+ CEvtEditor::ProcessCommandL() - %d", aCommandId );         
       
   721     CAknForm::ProcessCommandL(aCommandId); //to hide menu  
       
   722  
       
   723     
       
   724     switch(aCommandId)
       
   725         {          
       
   726         case EEvtEditorCmdAddDescNew:
       
   727         case EEvtEditorCmdAddDescFromExisting:            
       
   728         case EEvtEditorCmdEditDesc:
       
   729         case EEvtEditorCmdAssignTone:
       
   730         case EEvtEditorCmdShowOnMap:
       
   731         case EEvtEditorCmdNavigateToPlace:
       
   732         case EEvtMgmtUiEventUiPosSettings:
       
   733         case EEvtEditorCmdSetPlace:
       
   734             {      
       
   735             iCmdHandler->HandleEditorCmdL( aCommandId );
       
   736             break;
       
   737             }
       
   738         case EEvtEditorCmdRemoveDesc:
       
   739             {
       
   740             RemoveDesDlgLineL();
       
   741             iEventAttributeMask  = iEventAttributeMask | CEvtMgmtUiEngine::EEvtEventAttributeDesc;
       
   742             DrawDeferred();
       
   743             break;
       
   744             }
       
   745         case EEvtEditorCmdDelete:    
       
   746             {
       
   747             if( IsEmptyEventL() )
       
   748                 TryExitL( EAknSoftkeyBack );
       
   749             else if( DisplayConfirmationQueryDlgL(R_EVTUI_CREATENEW_FORM_CONFIRMATION_DELETEEVENT) )
       
   750                 {
       
   751                 if( !iEvent.EventId() )
       
   752                     TryExitL( EAknSoftkeyBack );
       
   753                 else
       
   754                     iCmdHandler->HandleEditorCmdL( aCommandId );
       
   755                 }
       
   756             break;
       
   757             }
       
   758         case EEvtEditorCmdActivate:
       
   759             {         
       
   760             if(IsEditable())
       
   761                 ProcessDoneCommandL();
       
   762             else
       
   763                 {            
       
   764                 iEvent.SetEventStatus(EActive);
       
   765                 iEventAttributeMask  = iEventAttributeMask | CEvtMgmtUiEngine::EEvtEventAttributeStatus;          
       
   766                 iCmdHandler->SetEventAttributeMask( iEventAttributeMask );
       
   767                 iCmdHandler->HandleEditorCmdL( aCommandId );
       
   768                 }
       
   769             break;
       
   770             }    
       
   771         case EEvtEditorCmdSaveDraft:
       
   772             {         
       
   773             if(IsEditable())
       
   774                 ProcessDoneCommandL();
       
   775             else
       
   776                 {            
       
   777                 iEvent.SetEventStatus(EDraft);
       
   778                 iEventAttributeMask  = iEventAttributeMask | CEvtMgmtUiEngine::EEvtEventAttributeStatus;          
       
   779                 iCmdHandler->SetEventAttributeMask( iEventAttributeMask );
       
   780                 iCmdHandler->HandleEditorCmdL( aCommandId );
       
   781                 }
       
   782             break;
       
   783             }         
       
   784         case EAknCmdExit:
       
   785             {
       
   786             // The User has exited the application using the Exit option from
       
   787             //.Options menu.  But, thats possible only if we exit the application
       
   788             // with EAknCmdExit.
       
   789             // A bit of convoluted logic but needed because we are using the
       
   790             // same components for the Settings UI Server as well as LC.
       
   791             
       
   792            	CEikAppServer* server = iEikonEnv->AppServer();
       
   793 			if ( server )
       
   794 				{
       
   795 				server->NotifyServerExit( EAknCmdExit );
       
   796 				}
       
   797 		    CAknAppUi* appUi = static_cast< CAknAppUi* >( iEikonEnv->AppUi());
       
   798 		    appUi->RunAppShutter();            
       
   799             break;
       
   800             }
       
   801         case EAknFormCmdEdit:
       
   802             {
       
   803             HandleMSKL(); 
       
   804             if( !iIsEditMode )
       
   805                 {
       
   806                 iIsEditMode = ETrue;
       
   807                 }               
       
   808             DrawDeferred();             
       
   809             break;
       
   810             }
       
   811         case EEvtEditorCmdDiscard:
       
   812             if( !DisplayConfirmationQueryDlgL(R_LOCEV_QUERY_DISCARD_CHANGES) )
       
   813                 break;
       
   814         case EAknSoftkeyBack:
       
   815             {
       
   816             TryExitL( EAknSoftkeyBack );
       
   817             break;
       
   818             }
       
   819         case EAknCmdHelp:
       
   820             {
       
   821             HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(),
       
   822                 static_cast<CAknAppUi*>(
       
   823                     iCoeEnv->AppUi() )->AppHelpContextL() );
       
   824             break;
       
   825             }
       
   826         default:
       
   827             {
       
   828             //panic code
       
   829             break;
       
   830             }
       
   831         }  
       
   832 	EVTUIDEBUG("- CEvtEditor::ProcessCommandL()");
       
   833     }
       
   834 
       
   835 // -----------------------------------------------------------------------------
       
   836 // CEvtEditor::SetMopParent
       
   837 // -----------------------------------------------------------------------------
       
   838 //
       
   839 void CEvtEditor::SetMopParent(
       
   840     MObjectProvider* aParent )
       
   841     {        
       
   842     CCoeControl::SetMopParent( aParent );
       
   843     }
       
   844 
       
   845 // -----------------------------------------------------------------------------
       
   846 // CEvtEditor::SetHelpContext
       
   847 // -----------------------------------------------------------------------------
       
   848 //
       
   849 void CEvtEditor::SetHelpContext( TCoeHelpContext aContext )
       
   850     {    
       
   851     iHelpContext = aContext;
       
   852     }
       
   853 
       
   854 // -----------------------------------------------------------------------------
       
   855 // CEvtEditor::ExecuteL
       
   856 // -----------------------------------------------------------------------------
       
   857 //
       
   858 TInt CEvtEditor::ExecuteLD()
       
   859     {    
       
   860 	return CAknForm::ExecuteLD( R_EVTMGMTUI_CREATEEVENT_FORM_DIALOG );    	
       
   861     }
       
   862 
       
   863 // -----------------------------------------------------------------------------
       
   864 // CEvtEditor::GetHelpContext
       
   865 // -----------------------------------------------------------------------------
       
   866 //
       
   867 void CEvtEditor::GetHelpContext( TCoeHelpContext& aContext ) const
       
   868     {
       
   869     if ( iHelpContext.iContext.Length() > 0 )
       
   870         {
       
   871         aContext.iContext = iHelpContext.iContext;
       
   872         aContext.iMajor = iHelpContext.iMajor;
       
   873         }
       
   874     }
       
   875     
       
   876 // -----------------------------------------------------------------------------
       
   877 // CEvtEditor::DisplayConfirmationQueryDlg()
       
   878 // It shows confirmation query dialog
       
   879 // -----------------------------------------------------------------------------
       
   880 //
       
   881 TBool CEvtEditor::DisplayConfirmationQueryDlgL( TInt aResourceId )
       
   882     {
       
   883     HBufC* msg = StringLoader::LoadLC(aResourceId);
       
   884     TBool response= EFalse;
       
   885     CAknQueryDialog* confirmationQuery = CAknQueryDialog::NewL();     
       
   886     response = confirmationQuery->ExecuteLD(R_EVTUI_CONFIRMATION_QUERY, *msg);         
       
   887     CleanupStack::PopAndDestroy(msg);
       
   888     return response;
       
   889     }
       
   890 
       
   891 // -----------------------------------------------------------------------------
       
   892 // CEvtEditor::ChangeRSKCaptionL()
       
   893 // It changes caption of RSK key
       
   894 // -----------------------------------------------------------------------------
       
   895 //
       
   896 void CEvtEditor::ChangeRSKCaptionL()
       
   897     {
       
   898 	EVTUIDEBUG("+ CEvtEditor::ChangeRSKCaptionL()");
       
   899     //if edit mode then RSK =Done otherwise Back
       
   900     CEikButtonGroupContainer* cba   = CEikButtonGroupContainer::Current();
       
   901     CleanupStack::PushL( cba );
       
   902     if(iIsEditMode)
       
   903         cba->SetCommandSetL ( R_EVTMGMTUI_CREATEEVENT_CBA_NOMSK ); 
       
   904     else
       
   905         cba->SetCommandSetL(R_EVTMGMTUI_CREATEEVENT_CBA_BACK);         
       
   906     cba->DrawDeferred();    
       
   907     CleanupStack::Pop();//cba  
       
   908 	EVTUIDEBUG("- CEvtEditor::ChangeRSKCaptionL()");
       
   909     }
       
   910 
       
   911 // -----------------------------------------------------------------------------
       
   912 // CEvtEditor::ChangeMSKCaptionL()
       
   913 // It changes caption of MSK key
       
   914 // @param aControlId of current focused line
       
   915 // -----------------------------------------------------------------------------
       
   916 //
       
   917 void CEvtEditor::ChangeMSKCaptionL(TInt  aControlId)
       
   918     {
       
   919 	EVTUIDEBUG("+ CEvtEditor::ChangeMSKCaptionL()");
       
   920     CEikButtonGroupContainer* cba   = CEikButtonGroupContainer::Current();
       
   921     CleanupStack::PushL( cba );
       
   922          
       
   923     //attribute specific cba
       
   924     switch(aControlId)
       
   925         {
       
   926         case EEvtMgmtUiDlgCIdSubject:
       
   927         case EEvtMgmtUiDlgCIdRadius:
       
   928             {//Options Done
       
   929             cba->SetCommandSetL(R_EVTMGMTUI_CREATEEVENT_CBA_NOMSK);
       
   930             break;
       
   931             }
       
   932         case EEvtMgmtUiDlgCIdRepeat:
       
   933         case EEvtMgmtUiDlgCIdAssignTone:
       
   934         case EEvtMgmtUiDlgCIdAudioLoop:
       
   935         case EEvtMgmtUiDlgCIdStatus:
       
   936             { //Options Change Done
       
   937             cba->SetCommandSetL(R_EVTMGMTUI_CREATEEVENT_CBA);                
       
   938             break;
       
   939             }
       
   940         case EEvtMgmtUiDlgCIdDesc:
       
   941             {//Options Edit Done
       
   942             cba->SetCommandSetL(R_EVTMGMTUI_CREATEEVENT_CBA_EDIT);
       
   943             break;
       
   944             }
       
   945         case EEvtMgmtUiDlgCIdPlace:
       
   946             {
       
   947             if(iEvent.Place().Compare(KNullDesC)==0)//Options Define Done
       
   948                 cba->SetCommandSetL(R_EVTMGMTUI_CREATEEVENT_CBA_DEFINE);
       
   949             else //Options Change Done
       
   950                 cba->SetCommandSetL(R_EVTMGMTUI_CREATEEVENT_CBA);
       
   951             break;
       
   952             }
       
   953         default:
       
   954             break;
       
   955         }
       
   956     cba->DrawDeferred();    
       
   957     CleanupStack::Pop();//cba    
       
   958 	EVTUIDEBUG("- CEvtEditor::ChangeMSKCaptionL()");
       
   959     }
       
   960 
       
   961 // -----------------------------------------------------------------------------
       
   962 // CEvtEditor::HandleMSKL()
       
   963 // It performs the required action when MSK is pressed
       
   964 // -----------------------------------------------------------------------------
       
   965 //
       
   966 void CEvtEditor::HandleMSKL()
       
   967     {
       
   968 	EVTUIDEBUG("+ CEvtEditor::HandleMSKL()");
       
   969     if( !iIsEditMode )
       
   970         {
       
   971         iIsEditMode = ETrue;
       
   972         SetEditableL(ETrue);  
       
   973         ChangeRSKCaptionL();
       
   974         ChangeMSKCaptionL( IdOfFocusControl() ); 
       
   975         return;    
       
   976         }
       
   977     
       
   978     if(IsEditable())
       
   979         {
       
   980         //attribute specific action
       
   981         switch( IdOfFocusControl() )
       
   982             {
       
   983             case EEvtMgmtUiDlgCIdSubject:
       
   984                 {
       
   985                 CEikEdwin* subjectEditor = static_cast <CEikEdwin*> (ControlOrNull(EEvtMgmtUiDlgCIdSubject));
       
   986                 if(subjectEditor )
       
   987                     {    
       
   988                     subjectEditor->SetCursorPosL(iEvent.Subject().Length(),EFalse);
       
   989                     subjectEditor->DrawDeferred();
       
   990                     }
       
   991                 break;
       
   992                 }
       
   993             case EEvtMgmtUiDlgCIdPlace:
       
   994                 {
       
   995                 ProcessCommandL(EEvtEditorCmdSetPlace);
       
   996                 break;
       
   997                 }
       
   998             case EEvtMgmtUiDlgCIdDesc:
       
   999                 {
       
  1000                 ProcessCommandL(EEvtEditorCmdEditDesc);
       
  1001                 break;
       
  1002                 }
       
  1003             case EEvtMgmtUiDlgCIdAssignTone:
       
  1004                 {
       
  1005                 ProcessCommandL(EEvtEditorCmdAssignTone);
       
  1006                 break;
       
  1007                 }
       
  1008             case EEvtMgmtUiDlgCIdRepeat:    
       
  1009                 {
       
  1010                 //ProcessCommandL(EEvtMgmtUiDlgCIdRepeat);
       
  1011                 TogglePopupFieldControlL( EEvtMgmtUiDlgCIdRepeat );
       
  1012                 break;
       
  1013                 }
       
  1014             case EEvtMgmtUiDlgCIdAudioLoop:
       
  1015                 {              
       
  1016                 //ProcessCommandL(EEvtMgmtUiDlgCIdAudioLoop);
       
  1017                TogglePopupFieldControlL( EEvtMgmtUiDlgCIdAudioLoop );
       
  1018                 break;
       
  1019                 }  
       
  1020             case EEvtMgmtUiDlgCIdStatus:
       
  1021                 {      
       
  1022                 CheckStatusL();
       
  1023                 CAknPopupFieldText* statusEditor = static_cast <CAknPopupFieldText*> ( ControlOrNull(EEvtMgmtUiDlgCIdStatus) );
       
  1024                      if (statusEditor)
       
  1025                          {  
       
  1026                          TKeyEvent keyEvent;
       
  1027                          keyEvent.iCode = EKeyEnter;
       
  1028                          keyEvent.iModifiers = EModifierPureKeycode;
       
  1029                          statusEditor->OfferKeyEventL( keyEvent, EEventKey ); 
       
  1030                          }
       
  1031                 break;
       
  1032                 }                  
       
  1033             default:
       
  1034                 {  
       
  1035                 //error panic
       
  1036               break;
       
  1037                 }
       
  1038             }
       
  1039         }
       
  1040 	EVTUIDEBUG("- CEvtEditor::HandleMSKL()");
       
  1041     }
       
  1042     
       
  1043 // -----------------------------------------------------------------------------
       
  1044 // CEvtEditor::InsertDesDlgLineL()
       
  1045 // It inserts dialog line for descriptor
       
  1046 // -----------------------------------------------------------------------------
       
  1047 //
       
  1048 void CEvtEditor::InsertDesDlgLineL()
       
  1049     {
       
  1050 	EVTUIDEBUG("+ CEvtEditor::InsertDesDlgLineL()");
       
  1051     TInt lineIndex;
       
  1052     if( !ControlOrNull( EEvtMgmtUiDlgCIdRadius ))
       
  1053         {
       
  1054         lineIndex = FindLineIndex(* ControlOrNull(EEvtMgmtUiDlgCIdPlace)) + 1;
       
  1055         }
       
  1056     else
       
  1057         {
       
  1058         lineIndex = FindLineIndex(* ControlOrNull(EEvtMgmtUiDlgCIdRadius))  + 1;
       
  1059         }
       
  1060    InsertLineL(lineIndex,R_EVTUI_CREATENEWFORM_DLGLINE_DESC);
       
  1061    UpdatePageL(ETrue);
       
  1062 	EVTUIDEBUG("- CEvtEditor::InsertDesDlgLineL()");
       
  1063    }
       
  1064 
       
  1065 // -----------------------------------------------------------------------------
       
  1066 // CEvtEditor::RemoveDesDlgLineL()
       
  1067 // It removes dialog line for descriptor
       
  1068 // -----------------------------------------------------------------------------
       
  1069 //
       
  1070 void CEvtEditor::RemoveDesDlgLineL()
       
  1071     {      
       
  1072 	EVTUIDEBUG("+ CEvtEditor::RemoveDesDlgLineL()");
       
  1073     if( ControlOrNull(EEvtMgmtUiDlgCIdDesc))
       
  1074       {
       
  1075       DeleteLine(EEvtMgmtUiDlgCIdDesc,ETrue);
       
  1076       iEvent.SetDescriptionL(KNullDesC);
       
  1077       }               
       
  1078 	EVTUIDEBUG("- CEvtEditor::RemoveDesDlgLineL()");
       
  1079     }
       
  1080 
       
  1081 // -----------------------------------------------------------------------------
       
  1082 // CEvtEditor::SetDescL()
       
  1083 // It sets text to descriptor edwin
       
  1084 // -----------------------------------------------------------------------------
       
  1085 //
       
  1086 void CEvtEditor::SetDescL()
       
  1087     {
       
  1088 	EVTUIDEBUG("+ CEvtEditor::SetDescL()");
       
  1089     CEikEdwin* descEditor = static_cast <CEikEdwin*> (ControlOrNull(EEvtMgmtUiDlgCIdDesc));
       
  1090      if (descEditor)
       
  1091          {
       
  1092          TPtrC desc = iEvent.Description();
       
  1093          descEditor->SetTextL(&desc);  
       
  1094          UpdatePageL(ETrue);
       
  1095          }
       
  1096 	EVTUIDEBUG("- CEvtEditor::SetDescL()");
       
  1097     }
       
  1098 
       
  1099 // -----------------------------------------------------------------------------
       
  1100 // CEvtEditor::SetRadiusL()
       
  1101 // It sets radius to radius editor
       
  1102 // -----------------------------------------------------------------------------
       
  1103 //
       
  1104 void CEvtEditor::SetRadiusL()
       
  1105     {
       
  1106 	EVTUIDEBUG("+ CEvtEditor::SetRadiusL()");
       
  1107     CAknUnitEditor* radiusEd =
       
  1108                       (CAknUnitEditor*)Control( EEvtMgmtUiDlgCIdRadius );
       
  1109      if(radiusEd)
       
  1110          {
       
  1111          NotifySOMChangeL(); // to set unit value
       
  1112          }
       
  1113 	EVTUIDEBUG("- CEvtEditor::SetRadiusL()");
       
  1114     }
       
  1115 
       
  1116 // -----------------------------------------------------------------------------
       
  1117 // CEvtEditor::CheckStatusL()
       
  1118 // It Checks for the status and dynamically sets the popup list
       
  1119 // -----------------------------------------------------------------------------
       
  1120 //
       
  1121 void CEvtEditor::CheckStatusL()
       
  1122     {
       
  1123     CAknPopupFieldText* statusEditor = static_cast <CAknPopupFieldText*> ( ControlOrNull(EEvtMgmtUiDlgCIdStatus) );
       
  1124     if( statusEditor && statusEditor->MdcArray()->MdcaCount() == 3 )
       
  1125         {
       
  1126         MDesC16Array* statusArray = (MDesC16Array*) (statusEditor->MdcArray());
       
  1127         CAknQueryValueTextArray* aTextArray = static_cast <CAknQueryValueTextArray*> (statusArray);
       
  1128         CDesCArray* arr =  aTextArray->Array();      // Delete the previous Array
       
  1129         arr->Reset();
       
  1130         arr->Compress();
       
  1131         HBufC* strActive = StringLoader::LoadLC( R_LOCEV_LIST_VALUE_ACTIVE );
       
  1132         HBufC* strDraft = StringLoader::LoadLC( R_LOCEV_LIST_VALUE_DRAFT );
       
  1133         arr->AppendL( *strActive );
       
  1134         arr->AppendL( *strDraft );
       
  1135         CleanupStack::PopAndDestroy( strDraft );
       
  1136         CleanupStack::PopAndDestroy( strActive );   
       
  1137         
       
  1138         if(EActive == iEvent.EventStatus())
       
  1139             statusEditor->SetCurrentValueIndex (0);
       
  1140         else
       
  1141             statusEditor->SetCurrentValueIndex (1);
       
  1142             
       
  1143         statusEditor->SetFocus(ETrue);
       
  1144         }
       
  1145     }
       
  1146 
       
  1147 // -----------------------------------------------------------------------------
       
  1148 // CEvtEditor::SetStatusL()
       
  1149 // It sets Status of the event
       
  1150 // -----------------------------------------------------------------------------
       
  1151 //
       
  1152 void CEvtEditor::SetStatusL()
       
  1153     {
       
  1154     EVTUIDEBUG("+ CEvtEditor::SetStatusL()");
       
  1155     //Set Status of the Event
       
  1156     CAknPopupFieldText* statusEditor = static_cast <CAknPopupFieldText*> ( ControlOrNull(EEvtMgmtUiDlgCIdStatus) );
       
  1157     if(statusEditor)
       
  1158         {
       
  1159         switch(iEvent.EventStatus())
       
  1160             {
       
  1161             case EActive:
       
  1162                 statusEditor->SetCurrentValueIndex(0);
       
  1163                 break;
       
  1164             case EDraft:
       
  1165                 statusEditor->SetCurrentValueIndex(1);
       
  1166                 break;
       
  1167             case ECompleted:
       
  1168                 statusEditor->SetCurrentValueIndex(2);
       
  1169                 break;
       
  1170             default:
       
  1171                 statusEditor->SetCurrentValueIndex(0);
       
  1172                 break;
       
  1173             }
       
  1174        }
       
  1175     EVTUIDEBUG("- CEvtEditor::SetStatusL()");
       
  1176     }
       
  1177 
       
  1178 // -----------------------------------------------------------------------------
       
  1179 // CEvtEditor::SetPlaceL()
       
  1180 // It sets text to place edwin
       
  1181 // -----------------------------------------------------------------------------
       
  1182 //
       
  1183 void CEvtEditor::SetPlaceL()
       
  1184     {
       
  1185 	EVTUIDEBUG("+ CEvtEditor::SetPlaceL()");
       
  1186     //Set place dialog line to new place value
       
  1187     CEikEdwin* placeEditor = static_cast <CEikEdwin*> (ControlOrNull(EEvtMgmtUiDlgCIdPlace));
       
  1188     if (placeEditor)
       
  1189        { 
       
  1190        HBufC* place = iEvent.Place().AllocLC();   
       
  1191        if(place->Compare(KNullDesC)!=0)
       
  1192            {
       
  1193            iEventAttributeMask  = iEventAttributeMask | CEvtMgmtUiEngine::EEvtEventAttributePlace;
       
  1194            placeEditor->SetTextL(place);   
       
  1195            placeEditor->DrawDeferred();   
       
  1196            InsertRadiusDlgLineL();
       
  1197 		   DrawNow();
       
  1198            } 
       
  1199        CleanupStack::PopAndDestroy(place);       
       
  1200        }
       
  1201 	EVTUIDEBUG("- CEvtEditor::SetPlaceL()");
       
  1202     }
       
  1203 
       
  1204 // -----------------------------------------------------------------------------
       
  1205 // CEvtEditor::SetRingtoneL()
       
  1206 // It sets text to ringtone edwin
       
  1207 // -----------------------------------------------------------------------------
       
  1208 //
       
  1209 void CEvtEditor::SetRingtoneL()
       
  1210     {
       
  1211 	EVTUIDEBUG("+ CEvtEditor::SetRingtoneL()");
       
  1212     CEikEdwin* ringtoneEditor = static_cast <CEikEdwin*> ( ControlOrNull(EEvtMgmtUiDlgCIdAssignTone) );
       
  1213           
       
  1214     if ( ringtoneEditor )
       
  1215          {
       
  1216          if( iEvent.HasAction() )
       
  1217              {            
       
  1218              CEvtToneAction* tone = CEvtToneAction::NewLC();  
       
  1219              tone->InternalizeL( iEvent.Action() );      
       
  1220              TParsePtrC parse( tone->FileName() );
       
  1221              TPtrC filename = parse.NameAndExt();
       
  1222              ringtoneEditor->SetTextL( &filename ); 
       
  1223              
       
  1224              // Insert Loop
       
  1225              InsertAudioLoopDlgLinesL();
       
  1226              CAknPopupFieldText* audioLoopEditor = static_cast <CAknPopupFieldText*> ( ControlOrNull(EEvtMgmtUiDlgCIdAudioLoop) );
       
  1227              if(audioLoopEditor)
       
  1228                  {
       
  1229                  if(tone->ToneLoop())
       
  1230                      audioLoopEditor->SetCurrentValueIndex(1);
       
  1231                  else
       
  1232                      audioLoopEditor->SetCurrentValueIndex(0);
       
  1233                  }
       
  1234              CleanupStack::PopAndDestroy( tone );
       
  1235              }
       
  1236          else
       
  1237              {
       
  1238              HBufC* strOff = StringLoader::LoadLC( R_EVTUI_RINGTONESELECT_OFF );
       
  1239              ringtoneEditor->SetTextL( strOff ); 
       
  1240              CleanupStack::PopAndDestroy( strOff );
       
  1241              
       
  1242              // Remove Loop
       
  1243              RemoveAudioLoopDlgLineL();
       
  1244              }
       
  1245          UpdatePageL(ETrue);
       
  1246          }
       
  1247     Debug(_L("CEvtEditor::SetRingtoneL()"));
       
  1248       if( iEvent.HasAction() )
       
  1249           {        
       
  1250           CEvtToneAction* tone = CEvtToneAction::NewLC();
       
  1251           TFileName debug;
       
  1252           tone->InternalizeL( iEvent.Action() );
       
  1253           debug.Copy(_L("Ringtone: "));
       
  1254           debug.Append(tone->FileName());
       
  1255           Debug(debug);
       
  1256           debug.Copy(_L("Audio Loop: "));
       
  1257           debug.AppendNum(tone->ToneLoop());
       
  1258           Debug(debug);            
       
  1259           CleanupStack::PopAndDestroy(tone);
       
  1260           }
       
  1261 	EVTUIDEBUG("- CEvtEditor::SetRingtoneL()");
       
  1262     }
       
  1263 
       
  1264 // -----------------------------------------------------------------------------
       
  1265 // CEvtEditor::MandatoryFieldsFilled()
       
  1266 // It checks if all mandatory fields are filled
       
  1267 // @return ETrue if all mandatory fields are filled
       
  1268 //         KFalse otherwise
       
  1269 // -----------------------------------------------------------------------------
       
  1270 //
       
  1271 TBool CEvtEditor::MandatoryFieldsFilled()
       
  1272     {   
       
  1273     return (iEvent.Subject().Compare(KNullDesC)!=0 && iEvent.Place().Compare(KNullDesC)!=0);
       
  1274     }
       
  1275 
       
  1276 // -----------------------------------------------------------------------------
       
  1277 // CEvtEditor::LineChangedL()
       
  1278 // Derived from CAknDialog
       
  1279 // -----------------------------------------------------------------------------
       
  1280 //
       
  1281 void CEvtEditor::LineChangedL(TInt  aControlId)
       
  1282     {
       
  1283 	EVTUIDEBUG("+ CEvtEditor::LineChangedL()");
       
  1284     if(iIsEditMode)
       
  1285         ChangeMSKCaptionL(aControlId); 
       
  1286 	EVTUIDEBUG("- CEvtEditor::LineChangedL()");
       
  1287     }
       
  1288 
       
  1289 // -----------------------------------------------------------------------------
       
  1290 // CEvtEditor::InsertRadiusDlgLineL()
       
  1291 // It inserts dialog line for radius
       
  1292 // -----------------------------------------------------------------------------
       
  1293 //
       
  1294 void CEvtEditor::InsertRadiusDlgLineL()
       
  1295     {
       
  1296 	EVTUIDEBUG("+ CEvtEditor::InsertRadiusDlgLineL()");
       
  1297     if( ControlOrNull(EEvtMgmtUiDlgCIdRadius)==NULL )
       
  1298         {
       
  1299         TInt lineIndex;   
       
  1300         lineIndex = FindLineIndex(* ControlOrNull(EEvtMgmtUiDlgCIdPlace))+1;
       
  1301         InsertLineL(lineIndex,R_EVTUI_CREATENEWFORM_DLGLINE_RADIUS);
       
  1302 		SetRadiusL();
       
  1303         }
       
  1304 	EVTUIDEBUG("- CEvtEditor::InsertRadiusDlgLineL()");
       
  1305 	}
       
  1306 
       
  1307 // -----------------------------------------------------------------------------
       
  1308 // CEvtEditor::RemoveRadiusDlgLineL()
       
  1309 // It remove dialog line for radius
       
  1310 // -----------------------------------------------------------------------------
       
  1311 //
       
  1312 void CEvtEditor::RemoveRadiusDlgLineL()
       
  1313     {  
       
  1314 	EVTUIDEBUG("+ CEvtEditor::RemoveRadiusDlgLineL()");
       
  1315     if(ControlOrNull(EEvtMgmtUiDlgCIdRadius)!=NULL)
       
  1316           {
       
  1317           DeleteLine(EEvtMgmtUiDlgCIdRadius,ETrue); 
       
  1318           }  
       
  1319 	EVTUIDEBUG("- CEvtEditor::RemoveRadiusDlgLineL()");  
       
  1320     }
       
  1321 
       
  1322 // -----------------------------------------------------------------------------
       
  1323 // CEvtEditor::RemoveAudioLoopDlgLineL()
       
  1324 // It removes dialog line for ringtone and audio-loop
       
  1325 // -----------------------------------------------------------------------------
       
  1326 //
       
  1327 void CEvtEditor::RemoveAudioLoopDlgLineL()
       
  1328     {  
       
  1329 	EVTUIDEBUG("+ CEvtEditor::RemoveAudioLoopDlgLineL()");    
       
  1330     if(ControlOrNull(EEvtMgmtUiDlgCIdAudioLoop)!=NULL)
       
  1331       {
       
  1332       DeleteLine(EEvtMgmtUiDlgCIdAudioLoop,ETrue); 
       
  1333       }  
       
  1334 	EVTUIDEBUG("- CEvtEditor::RemoveAudioLoopDlgLineL()");             
       
  1335     }
       
  1336 // -----------------------------------------------------------------------------
       
  1337 // CEvtEditor::InsertAudioLoopDlgLinesL()
       
  1338 // It inserts dialog line for ringtone and audio-loop
       
  1339 // -----------------------------------------------------------------------------
       
  1340 //
       
  1341 void CEvtEditor::InsertAudioLoopDlgLinesL()
       
  1342     {
       
  1343 	EVTUIDEBUG("+ CEvtEditor::InsertAudioLoopDlgLinesL()"); 
       
  1344     if( ControlOrNull(EEvtMgmtUiDlgCIdAudioLoop)==NULL )
       
  1345         {
       
  1346         TInt lastLineIndex = FindLineIndex(* ControlOrNull(EEvtMgmtUiDlgCIdAssignTone));
       
  1347         InsertLineL(lastLineIndex+1,R_EVTUI_CREATENEWFORM_DLGLINE_AUDIOLOOP);
       
  1348         UpdatePageL(ETrue);
       
  1349         }
       
  1350 	EVTUIDEBUG("- CEvtEditor::InsertAudioLoopDlgLinesL()"); 
       
  1351     }
       
  1352 
       
  1353 // -----------------------------------------------------------------------------
       
  1354 // CEvtEditor::NotifyEditorL()
       
  1355 // Inherited from MEvtMgmtUiEditorObserver
       
  1356 // -----------------------------------------------------------------------------
       
  1357 //
       
  1358 void CEvtEditor::NotifyEditorL(TInt aCommand, TInt aErrorCode)
       
  1359     {
       
  1360 	EVTUIDEBUG1("+ CEvtEditor::NotifyEditorL() - %d", aErrorCode ); 
       
  1361     if(aErrorCode!=KErrNone && aErrorCode!=KErrCancel&& aErrorCode!=KErrNotFound)
       
  1362         return;
       
  1363     
       
  1364     switch(aCommand)
       
  1365         {              
       
  1366         case EEvtEditorCmdSetPlace:
       
  1367             {        
       
  1368             if( aErrorCode==KErrNone )              
       
  1369             	SetPlaceL();
       
  1370             ChangeMSKCaptionL(EEvtMgmtUiDlgCIdPlace);          
       
  1371             break;
       
  1372             }
       
  1373         case EEvtEditorCmdAddDescNew:
       
  1374         case EEvtEditorCmdAddDescFromExisting: 
       
  1375         case EEvtEditorCmdEditDesc:
       
  1376             {
       
  1377             if( aErrorCode == KErrNone )
       
  1378                 {
       
  1379                 if(!ControlOrNull(EEvtMgmtUiDlgCIdDesc))
       
  1380                     InsertDesDlgLineL();
       
  1381                 TryChangeFocusToL( EEvtMgmtUiDlgCIdDesc ); 
       
  1382                 SetDescL();
       
  1383                 }
       
  1384              else
       
  1385              	{
       
  1386 				RemoveDesDlgLineL();
       
  1387 				DrawNow();
       
  1388              	}     
       
  1389             iEventAttributeMask  = iEventAttributeMask | CEvtMgmtUiEngine::EEvtEventAttributeDesc;             
       
  1390             break;
       
  1391             }
       
  1392         case EEvtEditorCmdAssignTone:
       
  1393             {     
       
  1394             if (  aErrorCode == KErrNone  ||  aErrorCode == KErrNotFound )
       
  1395                 {
       
  1396                 // Ring tone assignment was successful
       
  1397                 SetRingtoneL();
       
  1398                 TryChangeFocusToL( EEvtMgmtUiDlgCIdAssignTone );   
       
  1399                 iEventAttributeMask  = iEventAttributeMask | CEvtMgmtUiEngine::EEvtEventAttributeTone;
       
  1400                 }        
       
  1401             break;
       
  1402             }
       
  1403         case EEvtEditorCmdDelete:        
       
  1404         case EEvtEditorCmdActivate:
       
  1405         case EEvtEditorCmdSaveDraft:
       
  1406             {  
       
  1407             if ( !aErrorCode )
       
  1408                 {
       
  1409                 TryExitL( EEvtEditorCmdCloseDlg );
       
  1410                 }
       
  1411             break;
       
  1412             }      
       
  1413         default:
       
  1414             {
       
  1415             break;
       
  1416             }
       
  1417         }
       
  1418 	EVTUIDEBUG("- CEvtEditor::NotifyEditorL()");
       
  1419     }
       
  1420     
       
  1421 // -----------------------------------------------------------------------------
       
  1422 // CEvtEditor::NotifySOMChangeL()
       
  1423 // Inherited from MEvtMgmtUiSOMObserver
       
  1424 // -----------------------------------------------------------------------------
       
  1425 //
       
  1426 void CEvtEditor::NotifySOMChangeL( )
       
  1427 	{
       
  1428 	EVTUIDEBUG("+ CEvtEditor::NotifySOMChangeL()");
       
  1429     if( ControlOrNull(EEvtMgmtUiDlgCIdRadius) != NULL )
       
  1430         {
       
  1431         CAknUnitEditor* radiusEd =
       
  1432              (CAknUnitEditor*)Control( EEvtMgmtUiDlgCIdRadius );
       
  1433              
       
  1434         //convert radius in km unit
       
  1435         TReal val(0);
       
  1436         switch( iSysOfMeas->GetCurrentSysofMeasL() )
       
  1437         	{
       
  1438         	case ELocImperial: // Mile
       
  1439         	    {
       
  1440                 val = iEvent.Radius();
       
  1441                 val *= KUnitConversion;
       
  1442                 TReal setVal;
       
  1443                 Math::Round(setVal, val, 2);
       
  1444                 radiusEd->SetMinimumAndMaximum( KMinRadiusInKm*KUnitConversion, KMaxRadiusInKm*KUnitConversion );
       
  1445                 radiusEd->SetValue( setVal );
       
  1446                 radiusEd->SetUnitL( EAknUnitEditorMile );      
       
  1447         		break;
       
  1448         	    }
       
  1449         	case ELocMetric:   // KiloMetre
       
  1450                 {
       
  1451                 val = iEvent.Radius();
       
  1452                 TReal setVal;
       
  1453                 Math::Round(setVal, val, 2);
       
  1454                 radiusEd->SetMinimumAndMaximum( KMinRadiusInKm, KMaxRadiusInKm );
       
  1455                 radiusEd->SetValue( setVal );
       
  1456                 radiusEd->SetUnitL( EAknUnitEditorKilometer );      
       
  1457                 break;  			
       
  1458                 }
       
  1459         	default: 
       
  1460         		break;
       
  1461         	}
       
  1462         UpdatePageL(ETrue);
       
  1463         }
       
  1464 	EVTUIDEBUG("- CEvtEditor::NotifySOMChangeL()");
       
  1465 	}
       
  1466 
       
  1467 // -----------------------------------------------------------------------------
       
  1468 // CEvtEditor::OfferKeyEventL()
       
  1469 // Inherited from CAknForm
       
  1470 // -----------------------------------------------------------------------------
       
  1471 //
       
  1472 TKeyResponse CEvtEditor::OfferKeyEventL (const TKeyEvent &aKeyEvent, TEventCode aType) 
       
  1473     {
       
  1474     // Handle the "C" key in View mode.
       
  1475     if(!IsEditable() && aType == EEventKeyUp)
       
  1476         {
       
  1477         switch ( aKeyEvent.iScanCode )
       
  1478             {
       
  1479             case EStdKeyBackspace:
       
  1480             case EStdKeyDelete:
       
  1481                 {
       
  1482                 ProcessCommandL( EEvtEditorCmdDelete );  
       
  1483                 return EKeyWasConsumed;               
       
  1484                 }
       
  1485             default:
       
  1486                 {
       
  1487                 break;  
       
  1488                 }
       
  1489             }
       
  1490         }  
       
  1491     
       
  1492     // Handle the Control Specific key events.
       
  1493     if( IdOfFocusControl() == EEvtMgmtUiDlgCIdPlace && aType == EEventKey )
       
  1494         {
       
  1495         switch(aKeyEvent.iCode)
       
  1496             {
       
  1497             case EKeyDownArrow:
       
  1498                 {
       
  1499                 if( ControlOrNull(EEvtMgmtUiDlgCIdRadius) )
       
  1500                     TryChangeFocusToL( EEvtMgmtUiDlgCIdRadius );  
       
  1501                 else if( ControlOrNull(EEvtMgmtUiDlgCIdDesc) )
       
  1502                     TryChangeFocusToL( EEvtMgmtUiDlgCIdDesc );  
       
  1503                 else if( ControlOrNull(EEvtMgmtUiDlgCIdRepeat) )
       
  1504                     TryChangeFocusToL( EEvtMgmtUiDlgCIdRepeat );  
       
  1505                 return EKeyWasConsumed;
       
  1506                 }
       
  1507             default:
       
  1508                 break;
       
  1509             }
       
  1510         }
       
  1511     if( IdOfFocusControl() == EEvtMgmtUiDlgCIdStatus && aType == EEventKey )
       
  1512         {
       
  1513         switch(aKeyEvent.iCode)
       
  1514             {
       
  1515             case EKeyLeftArrow:
       
  1516             case EKeyRightArrow:
       
  1517             case EKeyOK:
       
  1518             case EKeyEnter:
       
  1519                 {
       
  1520                 CheckStatusL();
       
  1521                 }
       
  1522             default:
       
  1523                 break;
       
  1524             }
       
  1525         }
       
  1526     return CAknForm::OfferKeyEventL( aKeyEvent, aType );  
       
  1527     }
       
  1528 
       
  1529 // -----------------------------------------------------------------------------
       
  1530 // CEvtEditor::HandlePointerEventL()
       
  1531 // Inherited from CAknForm
       
  1532 // -----------------------------------------------------------------------------
       
  1533 //
       
  1534 void CEvtEditor::HandlePointerEventL(const TPointerEvent& aPointerEvent)
       
  1535     {    
       
  1536     EVTUIDEBUG("+ CEvtEditor::HandlePointerEventL()");
       
  1537 
       
  1538     if( aPointerEvent.iType != TPointerEvent::EButton1Up  )
       
  1539         {
       
  1540         CAknForm::HandlePointerEventL( aPointerEvent );  
       
  1541         if( aPointerEvent.iType == TPointerEvent::EDrag  )
       
  1542             iIsDragging++;
       
  1543         return;
       
  1544         }
       
  1545     
       
  1546     EVTUIDEBUG1("iIsDragging =%d",iIsDragging );
       
  1547     
       
  1548     //ToDo: Hack for kinetic scrolling
       
  1549     // Must be removed once avkon fix is recieved.
       
  1550     if( iIsDragging >6 )
       
  1551         {        
       
  1552         CAknForm::HandlePointerEventL( aPointerEvent );
       
  1553         iIsDragging = 0;  
       
  1554         return;
       
  1555         }
       
  1556         
       
  1557     iIsDragging = 0;
       
  1558     // End of todo
       
  1559     
       
  1560     if( !IsEditable() )
       
  1561         {
       
  1562         iIsEditMode = ETrue;
       
  1563         SetEditableL(ETrue);
       
  1564         ChangeRSKCaptionL();
       
  1565         ChangeMSKCaptionL( IdOfFocusControl() ); 			
       
  1566 		return;
       
  1567         }	  
       
  1568     
       
  1569     CEikEdwin* editor = NULL;
       
  1570     CAknPopupFieldText* popupFieldText = NULL;
       
  1571     switch(IdOfFocusControl())
       
  1572         {
       
  1573         case EEvtMgmtUiDlgCIdPlace: // Place Editor
       
  1574             editor = static_cast <CEikEdwin*> (ControlOrNull(EEvtMgmtUiDlgCIdPlace));
       
  1575              if ( editor )
       
  1576                  { 
       
  1577                  iCmdHandler->HandleEditorCmdL( EEvtEditorCmdSetPlace );
       
  1578                  }
       
  1579             break;
       
  1580         case EEvtMgmtUiDlgCIdDesc: // Description Editor
       
  1581             editor = static_cast <CEikEdwin*> (ControlOrNull(EEvtMgmtUiDlgCIdDesc));
       
  1582              if ( editor )
       
  1583                  {
       
  1584                  iCmdHandler->HandleEditorCmdL( EEvtEditorCmdEditDesc );
       
  1585                  }
       
  1586             break;
       
  1587         case EEvtMgmtUiDlgCIdAssignTone: // Tone Editor
       
  1588             editor = static_cast <CEikEdwin*> (ControlOrNull(EEvtMgmtUiDlgCIdAssignTone));
       
  1589              if ( editor )
       
  1590                  {
       
  1591                  iCmdHandler->HandleEditorCmdL( EEvtEditorCmdAssignTone );
       
  1592                  }
       
  1593             break;
       
  1594         case EEvtMgmtUiDlgCIdStatus: // Status Editor
       
  1595             popupFieldText = static_cast <CAknPopupFieldText*> ( ControlOrNull(EEvtMgmtUiDlgCIdStatus) );
       
  1596             if( popupFieldText )
       
  1597                 {
       
  1598                 TInt editorStatus = popupFieldText->CurrentValueIndex();
       
  1599                 CheckStatusL();
       
  1600                 if( ECompleted != editorStatus )
       
  1601                     {
       
  1602                     if( EActive == editorStatus )
       
  1603                         {
       
  1604                         popupFieldText->SetCurrentValueIndex ( EDraft );
       
  1605                         }
       
  1606                     else
       
  1607                         {
       
  1608                         popupFieldText->SetCurrentValueIndex ( EActive );
       
  1609                         }
       
  1610           					HandleControlStateChangeL( EEvtMgmtUiDlgCIdStatus );
       
  1611                     UpdatePageL(ETrue);
       
  1612                     return;
       
  1613                     }
       
  1614                 else
       
  1615                     {
       
  1616                     CAknForm::HandlePointerEventL( aPointerEvent );  
       
  1617                     return;
       
  1618                     }
       
  1619                 }
       
  1620             break;
       
  1621         case EEvtMgmtUiDlgCIdRepeat: // Repeat editor
       
  1622         case EEvtMgmtUiDlgCIdAudioLoop: // audio loop editor
       
  1623         				TogglePopupFieldControlL( IdOfFocusControl() );
       
  1624             break;
       
  1625         default:
       
  1626             CAknForm::HandlePointerEventL( aPointerEvent );  
       
  1627             break;
       
  1628         }
       
  1629 		EVTUIDEBUG("- CEvtEditor::HandlePointerEventL()");
       
  1630     }
       
  1631 // ---------------------------------------------------------------------------
       
  1632 // CEvtEditor::MakeTitleL()
       
  1633 // Set the Title Text
       
  1634 // ---------------------------------------------------------------------------
       
  1635 //
       
  1636 void CEvtEditor::MakeTitleL( TDesC& aText )
       
  1637     {
       
  1638 	EVTUIDEBUG("+ CEvtEditor::MakeTitleL()");
       
  1639     
       
  1640     // Obtain the title from the Status Pane
       
  1641     CAknTitlePane* title = static_cast<CAknTitlePane*>( iEikonEnv->AppUiFactory()->
       
  1642     	StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidTitle )));
       
  1643        
       
  1644     // Set the Title's buffer    
       
  1645     HBufC* buf = aText.AllocL();
       
  1646     title->SetText( buf ); // Takes ownership of buf
       
  1647     title->DrawNow();
       
  1648 	EVTUIDEBUG("- CEvtEditor::MakeTitleL()");
       
  1649     }     
       
  1650 
       
  1651 // ---------------------------------------------------------------------------
       
  1652 // CEvtEditor::TogglePopupFieldControlL()
       
  1653 // it toggles  value of popupfield control
       
  1654 // ---------------------------------------------------------------------------
       
  1655 //
       
  1656 void CEvtEditor::TogglePopupFieldControlL( TInt aControlId )
       
  1657     {
       
  1658 	EVTUIDEBUG1("+ CEvtEditor::TogglePopupFieldControlL() - %d", aControlId );
       
  1659     CAknPopupFieldText* audioLoopPopupFieldText =
       
  1660                     (CAknPopupFieldText*)Control( aControlId );
       
  1661       if(audioLoopPopupFieldText)
       
  1662           {          
       
  1663           if( audioLoopPopupFieldText->CurrentValueIndex() == 0)
       
  1664               audioLoopPopupFieldText->SetCurrentValueIndex(1);
       
  1665           else
       
  1666               audioLoopPopupFieldText->SetCurrentValueIndex(0);    
       
  1667                     
       
  1668           HandleControlStateChangeL( aControlId );
       
  1669           
       
  1670           UpdatePageL(ETrue);
       
  1671           }
       
  1672 	EVTUIDEBUG("- CEvtEditor::TogglePopupFieldControlL()");
       
  1673     }
       
  1674     
       
  1675 // ---------------------------------------------------------------------------
       
  1676 // void CEvtMgmtUiModel::OpenLocalizedResourceFileL
       
  1677 // Opens the nearest localized resourcefile using aResourceLoader. 
       
  1678 // aResourceLoader should be opened only once before closing it. 
       
  1679 // Otherwise it will raise a panic. Therefore it is better to have 
       
  1680 // multiple resource loaders.
       
  1681 // 
       
  1682 // @param aResourceFileName Drive and name of resource file in format 
       
  1683 //                          <path>:<rsc_file_name>
       
  1684 // @param aResourceLoader Resource loader for the resource. The loader 
       
  1685 //                        must not be opened allready or it will raise 
       
  1686 //                        a panic. It is caller's responsibility to 
       
  1687 //                        close the resource loader after using the 
       
  1688 //                        resource.
       
  1689 // ---------------------------------------------------------------------------
       
  1690 //  
       
  1691 void CEvtEditor::OpenLocalizedResourceFileL( 
       
  1692                             const TDesC&               aResourceFileName, 
       
  1693                                   RConeResourceLoader& aResourceLoader )
       
  1694     {    
       
  1695     TFileName* tmpName = new(ELeave) TFileName;
       
  1696     CleanupStack::PushL( tmpName );
       
  1697     
       
  1698     // Append the Resource Files Directory
       
  1699     tmpName->Append( KDC_RESOURCE_FILES_DIR );
       
  1700     
       
  1701     // Append the Ressource File Name
       
  1702     tmpName->Append( aResourceFileName );
       
  1703     
       
  1704     // Obtain the drive where the DLL is installed
       
  1705     TFileName* dllDrive = new (ELeave) TFileName;
       
  1706     CleanupStack::PushL( dllDrive );
       
  1707     Dll::FileName( *dllDrive );
       
  1708     
       
  1709     // Obtain the Complete path for the Resource File
       
  1710     TParse parse;
       
  1711     User::LeaveIfError( parse.Set( *dllDrive, NULL, NULL ) );
       
  1712     User::LeaveIfError( parse.Set( parse.Drive(), tmpName, NULL ) );
       
  1713     TFileName* fileName = new(ELeave) TFileName;
       
  1714     CleanupStack::PushL( fileName );
       
  1715     fileName->Append( parse.FullName() );
       
  1716     
       
  1717     // Get language of resource file
       
  1718     BaflUtils::NearestLanguageFile( CEikonEnv::Static()->FsSession(), *fileName );
       
  1719     
       
  1720     // Open resource file    
       
  1721     aResourceLoader.OpenL( *fileName );
       
  1722     
       
  1723     // Pop all the fields
       
  1724     CleanupStack::PopAndDestroy( fileName );
       
  1725     CleanupStack::PopAndDestroy( dllDrive );
       
  1726     CleanupStack::PopAndDestroy( tmpName );    
       
  1727     }
       
  1728 
       
  1729 //End of file