Bug 2257 - The alarm setting cannot be set to "On" in the Calendar application. RCL_3
authorToni Lehtonen <toni.lehtonen@nice.fi>
Tue, 02 Nov 2010 13:45:40 +0200
branchRCL_3
changeset 91 250f0dfb7d22
parent 88 9dfcaf1038dd
child 92 3b7c3fce86f2
Bug 2257 - The alarm setting cannot be set to "On" in the Calendar application.
calendarui/editors/inc/calenunifiededitor.h
calendarui/editors/src/calenunifiededitor.cpp
--- a/calendarui/editors/inc/calenunifiededitor.h	Thu Oct 28 13:23:18 2010 +0100
+++ b/calendarui/editors/inc/calenunifiededitor.h	Tue Nov 02 13:45:40 2010 +0200
@@ -665,6 +665,12 @@
          
          static TInt AsyncProcessCommandL(TAny* aThisPtr); 
          
+         /**
+          * @brief Tries to toggle on/off field
+          * @param aControlId The id of the field to toggle
+          * @return Indicates whether or not the field has been handled
+          */
+         TBool TryToggleOnOffL( TInt aControlId );
         
     private:
         /**
--- 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