calendarui/editors/src/calenunifiededitor.cpp
branchRCL_3
changeset 91 250f0dfb7d22
parent 86 ed599363c2d7
--- a/calendarui/editors/src/calenunifiededitor.cpp	Thu Oct 28 13:23:18 2010 +0100
+++ b/calendarui/editors/src/calenunifiededitor.cpp	Tue Nov 02 13:45:40 2010 +0200
@@ -520,36 +520,10 @@
 	                ctrl->ActivateSelectionListL();
 	                }
 				}
-			else if( newCtrlId == ECalenEditorReminder ) 
-                {
-                if( iUnifiedEditorControl->IsAlarmActiveInForm() )
-                    { 
-                    SetAlarmFieldOnOffL( EFalse );           
-                    active = EFalse;
-                    } 
-                else
-                    {
-                    SetAlarmFieldOnOffL( ETrue );                
-                    active = ETrue;
-                    }
-                iUnifiedEditorControl->CheckAlarmActive( active );
-                TryChangeFocusToL( ECalenEditorReminder );
-                }
-            else if( newCtrlId == ECalenEditorAllDayItem )
-                {
-                if( iUnifiedEditorControl->IsAllDayEvent() )
-                    {
-                    SetAllDayFieldL( EFalse );
-                    active = EFalse;
-                    }
-                else
-                    {
-                    SetAllDayFieldL( ETrue );
-                    active = ETrue;
-                    }
-                iUnifiedEditorControl->SetAllDayEvent( active );
-                
-                }
+			else
+				{
+				TryToggleOnOffL( newCtrlId );
+				}
             break;
             }
         case EAknSoftkeyOptions:
@@ -698,17 +672,25 @@
             case EKeyOK:
                 // TODO: Uncomment this when enabling attachment support
                 
-                if(ctrlid == ECalenEditorAttachment)
+                if(TryToggleOnOffL(ctrlid))
+                    {
+                	keyResponse = EKeyWasConsumed;
+                    }
+                else
                     {
-                    if(Edited().AttachmentCount() || iServices->GetAttachmentData()->NumberOfItems())
-                        {
-                        iServices->IssueCommandL( ECalenViewAttachmentList );
-                        }
-                    else
-                        {
-                        iServices->IssueCommandL( ECalenAddAttachment );
-                        }
-                    }
+					if(ctrlid == ECalenEditorAttachment)
+						{
+						if(Edited().AttachmentCount() || iServices->GetAttachmentData()->NumberOfItems())
+							{
+							iServices->IssueCommandL( ECalenViewAttachmentList );
+							}
+						else
+							{
+							iServices->IssueCommandL( ECalenAddAttachment );
+							}
+						}
+					keyResponse = CAknForm::OfferKeyEventL(aKeyEvent,aType);
+                	}
                 break;
             case EKeyEscape:
                 // Calendar relaunched from cmd line - close viewer
@@ -750,7 +732,7 @@
             case EKeyLeftArrow:
             case EKeyRightArrow:
                 {
-                if( ECalenEditorEventType == IdOfFocusControl() )
+                if( ECalenEditorEventType == IdOfFocusControl() || TryToggleOnOffL( ctrlid ) )
                     {
                     keyResponse = EKeyWasConsumed; 
                     }
@@ -1165,29 +1147,24 @@
     if ( aEventID == MEikDialogPageObserver::EDialogPageTapped )
         {
         TInt focusControl( IdOfFocusControl() );
-        if ( focusControl == ECalenEditorAttachment
-                || focusControl == ECalenEditorDescription )
-            {
-            
-            
-                switch ( focusControl )
-                    {
-                    case ECalenEditorAttachment:
-                        {
-                        
-                        if(Edited().AttachmentCount() || iServices->GetAttachmentData()->NumberOfItems())
-                            {
-                                ProcessCommandL( ECalenCmdViewAttachmentList );
-                            }
-                        else
-                            {
-                                ProcessCommandL( ECalenCmdAddAttachment );
-                            }
-                        break;
-                        }
-                       
-                    case ECalenEditorDescription:
-                        {
+		switch ( focusControl )
+			{
+			case ECalenEditorAttachment:
+				{
+				
+				if(Edited().AttachmentCount() || iServices->GetAttachmentData()->NumberOfItems())
+					{
+						ProcessCommandL( ECalenCmdViewAttachmentList );
+					}
+				else
+					{
+						ProcessCommandL( ECalenCmdAddAttachment );
+					}
+				break;
+				}
+			   
+			case ECalenEditorDescription:
+				{
 //                        CEikEdwin* edwin = static_cast<CEikEdwin*>( Control( focusControl ) );  
 //                        if ( edwin && edwin->Text()->DocumentLength() == 0 )
 //                            {
@@ -1197,40 +1174,17 @@
 //                            {
 //                                ProcessCommandL( ECalenCmdShowDescription );
 //                            }
-                        iAsyncCallback->CallBack();
-                        break;
-                        }
-                       
-                    default:
-                        {
-                        break;
-                        }
-                    }
-                
-            }
-        else if ( focusControl == ECalenEditorAllDayItem )
-            {
-            // Tap on AllDay field, Switch the status of AllDay field  
-            iUnifiedEditorControl->SetAllDayEvent(
-                    !( iUnifiedEditorControl->IsAllDayEvent() ) );
-            }
-        else if ( focusControl == ECalenEditorReminder )
-            {
-            TBool active;
-            if( iUnifiedEditorControl->IsAlarmActiveInForm() )
-                { 
-                SetAlarmFieldOnOffL( EFalse );           
-                active = EFalse;
-                } 
-            else
-                {
-                SetAlarmFieldOnOffL( ETrue );                
-                active = ETrue;
-                }
-            iUnifiedEditorControl->CheckAlarmActive( active );
-            TryChangeFocusToL( ECalenEditorReminder );
-            }
-        }
+				iAsyncCallback->CallBack();
+				break;
+				}
+			   
+			default:
+				{
+				TryToggleOnOffL( focusControl );
+				break;
+				}
+			}                
+		}
     }
 
 
@@ -1252,6 +1206,27 @@
     return 0;
     }
 
+TBool CCalenUnifiedEditor::TryToggleOnOffL( TInt aControlId )
+    {
+    TBool res = ETrue;
+    switch( aControlId )
+        {
+        case ECalenEditorAllDayItem:
+            iUnifiedEditorControl->SetAllDayEvent( 
+            		!( iUnifiedEditorControl->IsAllDayEvent() ) );
+            break;
+        case ECalenEditorReminder:
+            TBool active = !( iUnifiedEditorControl->IsAlarmActiveInForm() );
+            SetAlarmFieldOnOffL( active );
+            iUnifiedEditorControl->CheckAlarmActive( active );
+            TryChangeFocusToL( ECalenEditorReminder );
+            break;
+        default:
+            res = EFalse;
+            break;
+        }
+    return res;
+    }
 
 // -----------------------------------------------------------------------------
 //  CCalenUnifiedEditor::HandleResourceChange