calendarui/editors/src/calenunifiededitor.cpp
branchRCL_3
changeset 60 96907930389d
parent 59 aba12c885d83
child 67 1539a383d7b6
equal deleted inserted replaced
59:aba12c885d83 60:96907930389d
    29 #include "CalenDescription.h"
    29 #include "CalenDescription.h"
    30 #include "calenattachmentinfo.h"
    30 #include "calenattachmentinfo.h"
    31 #include "calenattachmentmodel.h"
    31 #include "calenattachmentmodel.h"
    32 #include "CleanupResetAndDestroy.h"
    32 #include "CleanupResetAndDestroy.h"
    33 #include "CalendarPrivateCRKeys.h"
    33 #include "CalendarPrivateCRKeys.h"
       
    34 #include "CalenUid.h"
    34 
    35 
    35 // system includes
    36 // system includes
    36 #include <coemain.h>
    37 #include <coemain.h>
    37 #include <eikdialg.h>
    38 #include <eikdialg.h>
    38 #include <bacntf.h>
    39 #include <bacntf.h>
    65 #include <calencommands.hrh>            // Calendar commands
    66 #include <calencommands.hrh>            // Calendar commands
    66 #include <calencontext.h>
    67 #include <calencontext.h>
    67 #include <caleninstanceid.h>            // TCalenInstanceId
    68 #include <caleninstanceid.h>            // TCalenInstanceId
    68 #include <calenservices.h>
    69 #include <calenservices.h>
    69 #include <calcalendarinfo.h>
    70 #include <calcalendarinfo.h>
       
    71 #include <vwsdef.h>
    70 
    72 
    71 // debug
    73 // debug
    72 #include "calendarui_debug.h"
    74 #include "calendarui_debug.h"
    73 
    75 
    74 const TInt KCalenMaxELAFTextEditorLength(160);
    76 const TInt KCalenMaxELAFTextEditorLength(160);
    79 const TInt KCalenButtonIdCloseForm(-400);
    81 const TInt KCalenButtonIdCloseForm(-400);
    80 
    82 
    81 _LIT(KComma, ",");
    83 _LIT(KComma, ",");
    82 _LIT(KEmpty,"");
    84 _LIT(KEmpty,"");
    83 _LIT(KAttachmentSeparator,"; ");
    85 _LIT(KAttachmentSeparator,"; ");
       
    86 _LIT( KReplaceWhitespaceChars, "\x0009\x000A\x000B\x000C\x000D\x2028\x2029" );
    84 
    87 
    85 // -----------------------------------------------------------------------------
    88 // -----------------------------------------------------------------------------
    86 // CCalenUnifiedEditor::NewL
    89 // CCalenUnifiedEditor::NewL
    87 // Two-phased constructor.
    90 // Two-phased constructor.
    88 // -----------------------------------------------------------------------------
    91 // -----------------------------------------------------------------------------
   133 // -----------------------------------------------------------------------------
   136 // -----------------------------------------------------------------------------
   134 //
   137 //
   135 CCalenUnifiedEditor::~CCalenUnifiedEditor()
   138 CCalenUnifiedEditor::~CCalenUnifiedEditor()
   136     {
   139     {
   137     TRACE_ENTRY_POINT;
   140     TRACE_ENTRY_POINT;
       
   141 
       
   142 	iFetchedEntries.ResetAndDestroy();
   138 
   143 
   139     if( iGlobalData )
   144     if( iGlobalData )
   140         {
   145         {
   141         iGlobalData->Release();
   146         iGlobalData->Release();
   142         }
   147         }
   376     
   381     
   377         case ECalenNotifyEntryInstanceViewCreated:
   382         case ECalenNotifyEntryInstanceViewCreated:
   378             break;
   383             break;
   379         case ECalenNotifyCalendarFileDeleted:
   384         case ECalenNotifyCalendarFileDeleted:
   380             {
   385             {
       
   386             TRAP_IGNORE(HandleCalendarDeleteL());
       
   387             }
       
   388             break;
       
   389         default:
       
   390             break;
       
   391         }
       
   392     TRACE_EXIT_POINT;
       
   393     }
       
   394 	
       
   395 	
       
   396 void CCalenUnifiedEditor::HandleCalendarDeleteL()
       
   397     {
   381             TPtrC fileNamePtr = iServices->Context().GetCalendarFileNameL();
   398             TPtrC fileNamePtr = iServices->Context().GetCalendarFileNameL();
   382             if(!fileNamePtr.CompareF(iUnifiedEditorControl->GetCalendarNameForEntryL()))
   399     TInt index = iUnifiedEditorControl->GetCalendarNameForEntryL(fileNamePtr);
       
   400             if(index == KErrNotFound)
   383                 {
   401                 {
   384                 DisplayErrorMsgL( CCalenEditorDataHandler::EFormErrDbConflictEntryDeleted );
   402                 DisplayErrorMsgL( CCalenEditorDataHandler::EFormErrDbConflictEntryDeleted );
   385                 iEntryUiOutParams.iAction = EMeetingDeleted;
   403                 iEntryUiOutParams.iAction = EMeetingDeleted;
   386                 TryExitL( KCalenButtonIdCloseForm );
   404                 TryExitL( KCalenButtonIdCloseForm );
   387                 }
   405         }
   388             }
   406     
   389             break;
       
   390         default:
       
   391             break;
       
   392         }
       
   393     
       
   394     TRACE_EXIT_POINT;
       
   395     }
   407     }
   396 
   408 
   397 // -----------------------------------------------------------------------------
   409 // -----------------------------------------------------------------------------
   398 // CCalenUnifiedEditor::InsertFieldL
   410 // CCalenUnifiedEditor::InsertFieldL
   399 // Inserts dialog line (form field) defined by aResourceI
   411 // Inserts dialog line (form field) defined by aResourceI
   540                 else
   552                 else
   541                     {
   553                     {
   542                     SetAllDayFieldL( ETrue );
   554                     SetAllDayFieldL( ETrue );
   543                     active = ETrue;
   555                     active = ETrue;
   544                     }
   556                     }
   545                 iUnifiedEditorControl->SetAllDayEvent( active );
   557                 iUnifiedEditorControl->SetAllDayEventL( active );
   546                 
   558                 
   547                 }
   559                 }
   548             break;
   560             break;
   549             }
   561             }
   550         case EAknSoftkeyOptions:
   562         case EAknSoftkeyOptions:
   697                     {
   709                     {
   698                     if(Edited().AttachmentCount() || iServices->GetAttachmentData()->NumberOfItems())
   710                     if(Edited().AttachmentCount() || iServices->GetAttachmentData()->NumberOfItems())
   699                         {
   711                         {
   700                         iServices->IssueCommandL( ECalenViewAttachmentList );
   712                         iServices->IssueCommandL( ECalenViewAttachmentList );
   701                         }
   713                         }
       
   714                     else
       
   715                         {
       
   716                         iServices->IssueCommandL( ECalenAddAttachment );
       
   717                         }
   702                     }
   718                     }
   703                 break;
   719                 break;
   704             case EKeyEscape:
   720             case EKeyEscape:
   705                 // Calendar relaunched from cmd line - close viewer
   721                 // Calendar relaunched from cmd line - close viewer
   706                 // NOTE: This was changed from EAknCmdExit to ECalenCmdCloseDialog since launching
   722                 // NOTE: This was changed from EAknCmdExit to ECalenCmdCloseDialog since launching
   708                 // opened is closing the application.
   724                 // opened is closing the application.
   709                 TryExitL( ECalenCmdCloseDialog );
   725                 TryExitL( ECalenCmdCloseDialog );
   710                 keyResponse = EKeyWasConsumed;
   726                 keyResponse = EKeyWasConsumed;
   711                 break;
   727                 break;
   712             case EKeyEnter: // For Enter key
   728             case EKeyEnter: // For Enter key
       
   729                 {
       
   730                 if(ctrlid == ECalenEditorAttachment)
       
   731                     {
       
   732                     if(Edited().AttachmentCount() || iServices->GetAttachmentData()->NumberOfItems())
       
   733                         {
       
   734                         iServices->IssueCommandL( ECalenViewAttachmentList );
       
   735                         }
       
   736                     else
       
   737                         {
       
   738                         iServices->IssueCommandL( ECalenAddAttachment );
       
   739                         }
       
   740                     }
       
   741                 keyResponse = CAknForm::OfferKeyEventL(aKeyEvent,aType); // Let framework handle the key event
       
   742                 }
       
   743                 break;
   713             case EKeyDelete: // For Delete key
   744             case EKeyDelete: // For Delete key
   714 				{
   745 				{
   715 				keyResponse = CAknForm::OfferKeyEventL(aKeyEvent,aType); // Let framework handle the key event
   746 				keyResponse = CAknForm::OfferKeyEventL(aKeyEvent,aType); // Let framework handle the key event
   716 				}
   747 				}
   717 				break;
   748 				break;
   965     TRACE_ENTRY_POINT;
   996     TRACE_ENTRY_POINT;
   966 
   997 
   967     iUnifiedEditorControl->MakeUnifiedEditorL();
   998     iUnifiedEditorControl->MakeUnifiedEditorL();
   968     // Hides Entry type and Calendar Field for exceptional entry/single
   999     // Hides Entry type and Calendar Field for exceptional entry/single
   969     // instance of recurrent entry.
  1000     // instance of recurrent entry.
   970     HideFieldsForEditSingleInstance();
  1001     HideFieldsForEditSingleInstanceL();
   971 
  1002 
   972     TRACE_EXIT_POINT;         
  1003     TRACE_EXIT_POINT;         
   973     }
  1004     }
   974         
  1005         
   975 // -----------------------------------------------------------------------------
  1006 // -----------------------------------------------------------------------------
  1082         		MCalenContext& context = iServices->Context();
  1113         		MCalenContext& context = iServices->Context();
  1083         		context.SetLandMark(landmark);
  1114         		context.SetLandMark(landmark);
  1084         		}
  1115         		}
  1085         	else if(location.Length())
  1116         	else if(location.Length())
  1086         	    {
  1117         	    {
       
  1118                 AknTextUtils::ReplaceCharacters(location, KReplaceWhitespaceChars, TChar(' '));
  1087         	    CPosLandmark* landmark = CPosLandmark::NewL();
  1119         	    CPosLandmark* landmark = CPosLandmark::NewL();
  1088                 landmark->SetLandmarkNameL(location);
  1120                 landmark->SetLandmarkNameL(location);
  1089                 MCalenContext& context = iServices->Context();
  1121                 MCalenContext& context = iServices->Context();
  1090                 context.SetLandMark( landmark );
  1122                 context.SetLandMark( landmark );
  1091                 }
  1123                 }
  1184                 
  1216                 
  1185             }
  1217             }
  1186         else if ( focusControl == ECalenEditorAllDayItem )
  1218         else if ( focusControl == ECalenEditorAllDayItem )
  1187             {
  1219             {
  1188             // Tap on AllDay field, Switch the status of AllDay field  
  1220             // Tap on AllDay field, Switch the status of AllDay field  
  1189             iUnifiedEditorControl->SetAllDayEvent(
  1221             iUnifiedEditorControl->SetAllDayEventL(
  1190                     !( iUnifiedEditorControl->IsAllDayEvent() ) );
  1222                     !( iUnifiedEditorControl->IsAllDayEvent() ) );
  1191             }
  1223             }
  1192         else if ( focusControl == ECalenEditorReminder )
  1224         else if ( focusControl == ECalenEditorReminder )
  1193             {
  1225             {
  1194             TBool active;
  1226             TBool active;
  2028             }
  2060             }
  2029         }
  2061         }
  2030 
  2062 
  2031     if ( error == CCalenEditorDataHandler::EFormErrNone ) 
  2063     if ( error == CCalenEditorDataHandler::EFormErrNone ) 
  2032         {
  2064         {
  2033 		ModifyDbField();//default calendar code
  2065 		ModifyDbFieldL();//default calendar code
  2034         EditorDataHandler().WriteChangesToEntryL( iRepeatType );
  2066         EditorDataHandler().WriteChangesToEntryL( iRepeatType );
  2035         
  2067         
  2036         TCalTime newInstanceStartDate, newInstanceEndDate;
  2068         TCalTime newInstanceStartDate, newInstanceEndDate;
  2037         CalculateNewInstanceStartAndEndDateL( newInstanceStartDate, newInstanceEndDate );
  2069         CalculateNewInstanceStartAndEndDateL( newInstanceStartDate, newInstanceEndDate );
       
  2070         if(EditorDataHandler().IsRepeatRuleEdited() && !IsCreatingNewEntry())
       
  2071         	{
       
  2072             MCalenContext& context = iServices->Context();
       
  2073             TCalenInstanceId instanceId = context.InstanceId();
       
  2074 			context.SetFocusDateAndTimeL(newInstanceStartDate,TVwsViewId( KUidCalendar, KUidCalenEventView));
       
  2075             }
  2038 
  2076 
  2039         TInt saveErr( 0 );
  2077         TInt saveErr( 0 );
  2040         TBool dbChange = iEditorDataHandler->IsCalendarEditedL();
  2078         TBool dbChange = iEditorDataHandler->IsCalendarEditedL();
  2041         if( iEditedCalEntry.EntryTypeL() != Edited().EntryType() || dbChange )
  2079         if( iEditedCalEntry.EntryTypeL() != Edited().EntryType() || dbChange )
  2042             {
  2080             {
  2224         }
  2262         }
  2225         if ( action == CCalenEditorDataHandler::EActionSave )
  2263         if ( action == CCalenEditorDataHandler::EActionSave )
  2226             {
  2264             {
  2227             EditorDataHandler().ForceValidValuesL( iHasChosenRepeatType? iRepeatType 
  2265             EditorDataHandler().ForceValidValuesL( iHasChosenRepeatType? iRepeatType 
  2228                                                                                   : CalCommon::EThisAndAll );
  2266                                                                                   : CalCommon::EThisAndAll );
  2229             ModifyDbField();//Default Calendar code
  2267             ModifyDbFieldL();//Default Calendar code
  2230             EditorDataHandler().WriteChangesToEntryL( iHasChosenRepeatType? iRepeatType
  2268             EditorDataHandler().WriteChangesToEntryL( iHasChosenRepeatType? iRepeatType
  2231                                                                                   : CalCommon::EThisAndAll );
  2269                                                                                   : CalCommon::EThisAndAll );
  2232 
  2270 
  2233             TCalTime newInstanceStartDate, newInstanceEndDate;
  2271             TCalTime newInstanceStartDate, newInstanceEndDate;
  2234             CalculateNewInstanceStartAndEndDateL( newInstanceStartDate, 
  2272             CalculateNewInstanceStartAndEndDateL( newInstanceStartDate, 
  3127 // -----------------------------------------------------------------------------
  3165 // -----------------------------------------------------------------------------
  3128 // CCalenUnifiedEditor::ModifyDbField
  3166 // CCalenUnifiedEditor::ModifyDbField
  3129 // modifies the DB filed in cenrep if user has edited it.
  3167 // modifies the DB filed in cenrep if user has edited it.
  3130 // -----------------------------------------------------------------------------
  3168 // -----------------------------------------------------------------------------
  3131 //
  3169 //
  3132 void CCalenUnifiedEditor::ModifyDbField()
  3170 void CCalenUnifiedEditor::ModifyDbFieldL()
  3133     {
  3171     {
  3134     if(IsCreatingNewEntry())
  3172     if(IsCreatingNewEntry())
  3135         {                
  3173         {                
  3136         RPointerArray<CCalCalendarInfo> calendarInfoList; 
  3174         RPointerArray<CCalCalendarInfo> calendarInfoList; 
  3137         iServices->GetAllCalendarInfoL(calendarInfoList);
  3175         iServices->GetAllCalendarInfoL(calendarInfoList);
  3149 // CCalenUnifiedEditor::HideFieldsForEditSingleInstance
  3187 // CCalenUnifiedEditor::HideFieldsForEditSingleInstance
  3150 // Hides Entry type and Calendar Field for exceptional entry/single
  3188 // Hides Entry type and Calendar Field for exceptional entry/single
  3151 // instance of recurrent entry.
  3189 // instance of recurrent entry.
  3152 // -----------------------------------------------------------------------------
  3190 // -----------------------------------------------------------------------------
  3153 //
  3191 //
  3154 void CCalenUnifiedEditor::HideFieldsForEditSingleInstance()
  3192 void CCalenUnifiedEditor::HideFieldsForEditSingleInstanceL()
  3155     {
  3193     {
  3156     TRACE_ENTRY_POINT;
  3194     TRACE_ENTRY_POINT;
  3157     
  3195     
  3158     if( !IsCreatingNewEntry() )
  3196     if( !IsCreatingNewEntry() )
  3159         {
  3197         {