diff -r bd7edf625bdd -r 97232defd20e calendarui/editors/src/calenunifiededitorcontrol.cpp --- a/calendarui/editors/src/calenunifiededitorcontrol.cpp Wed Sep 01 12:32:31 2010 +0100 +++ b/calendarui/editors/src/calenunifiededitorcontrol.cpp Tue Sep 14 21:17:03 2010 +0300 @@ -24,7 +24,7 @@ #include #include #include - +#include // user includes #include "calenunifiededitorcontrol.h" #include "calenunifiededitor.h" @@ -37,6 +37,9 @@ #include "calenpriorityfield.h" #include "calendbfield.h" #include "CalenDescription.h" +#include "KoreanLunarDateEditor.h" +#include "KoreanLunarTypeField.h" + // debug #include "calendarui_debug.h" @@ -81,6 +84,18 @@ delete iDbField; delete iDescription; + if( iKoreanLunarTypeField ) + { + delete iKoreanLunarTypeField; + } + + // Do not call UnInitializeLib() if InitalizeLib() leaves. + if ( iFeatMgrInitialized ) + { + // Frees the TLS. Must be done after FeatureManager is used. + FeatureManager::UnInitializeLib(); + } + TRACE_EXIT_POINT; } @@ -101,6 +116,16 @@ iDbField = CCalenDbField::NewL( iUnifiedEditor,aServices ); iDescription = CCalenDescription::NewL( iUnifiedEditor ); + // Sets up TLS, must be done before FeatureManager is used. + FeatureManager::InitializeLibL(); + // Used in destructor. + iFeatMgrInitialized = ETrue; + + if( FeatureManager::FeatureSupported( KFeatureIdKorean ) ) + { + iKoreanLunarTypeField = CKoreanLunarTypeField::NewL( iUnifiedEditor ); + } + TRACE_EXIT_POINT; } @@ -342,6 +367,13 @@ } CleanupStack::PopAndDestroy( &calendarInfoList ); + + if( CCalEntry::EAnniv == iUnifiedEditor.GetEntryType() + && FeatureManager::FeatureSupported( KFeatureIdKorean ) ) + { + iKoreanLunarTypeField->PreLayoutDynInitL(); + } + iDescription->InitDescritpionFieldLayoutL(); TRACE_EXIT_POINT; @@ -356,40 +388,64 @@ { TRACE_ENTRY_POINT; // event type, subject, date & year,more details + + TInt prevItem = 0; + prevItem=ECalenEditorSubject; - RPointerArray calendarInfoList; - iUnifiedEditor.GetServices().GetAllCalendarInfoL(calendarInfoList); - CleanupClosePushL( calendarInfoList ); - - if( calendarInfoList.Count() > 1 ) - { - iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_DB_NAME_ITEM, - ECalenEditorDBName, ECalenEditorSubject ); - - iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_START_DATE_ITEM, - ECalenEditorStartDate, ECalenEditorDBName ); - } + if(FeatureManager::FeatureSupported( KFeatureIdKorean )) + { + iUnifiedEditor.InsertFieldL( R_KOREAN_LUNAR_NOTEVIEW_TYPE_LINE, + EKoreanLunarTypeSelectSolarLunarLeap, ECalenEditorSubject ); + prevItem=EKoreanLunarTypeSelectSolarLunarLeap; + } + + TLunarCalendarType type = iUnifiedEditor.Edited().CalendarType(); + + if( type != ESolar && FeatureManager::FeatureSupported( KFeatureIdKorean )) + { + iUnifiedEditor.InsertFieldL( R_KOREAN_LUNAR_DATE_EDITOR_LINE, + EKoreanLunarAniversityStart, prevItem ); + prevItem=EKoreanLunarAniversityStart; + + TTime birthDayYear = iUnifiedEditor.Edited().EventDateTime(); + SetDateField( ECalenEditorStartDate, birthDayYear, ETrue ); + } else - { - iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_START_DATE_ITEM, - ECalenEditorStartDate, ECalenEditorSubject ); - } + { + RPointerArray calendarInfoList; + iUnifiedEditor.GetServices().GetAllCalendarInfoL(calendarInfoList); + CleanupClosePushL( calendarInfoList ); - CleanupStack::PopAndDestroy( &calendarInfoList ); - - // "Start Date" Label should be "Date of Birth" for Birthday - iUnifiedEditor.SetControlCaptionL( ECalenEditorStartDate, - R_QTN_CALEN_EDITOR_DATE_OF_BIRTH ); + if( calendarInfoList.Count() > 1 ) + { + iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_DB_NAME_ITEM, + ECalenEditorDBName, prevItem ); + prevItem = ECalenEditorDBName; + iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_START_DATE_ITEM, + ECalenEditorStartDate, prevItem ); + prevItem=ECalenEditorStartDate; + } + else + { + iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_START_DATE_ITEM, + ECalenEditorStartDate, prevItem ); + prevItem = ECalenEditorStartDate; + } - iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_REMINDER_ITEM, - ECalenEditorReminder, ECalenEditorStartDate ); + CleanupStack::PopAndDestroy( &calendarInfoList ); + + // "Start Date" Label should be "Date of Birth" for Birthday + iUnifiedEditor.SetControlCaptionL( ECalenEditorStartDate, + R_QTN_CALEN_EDITOR_DATE_OF_BIRTH ); + } + + + iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_REMINDER_ITEM, + ECalenEditorReminder, prevItem ); + iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_PLACE_ITEM, ECalenEditorPlace, ECalenEditorReminder ); -/* iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_PEOPLE_ITEM, - ECalenEditorPeople, ECalenEditorPlace ); -*/ /* iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_DB_NAME_ITEM, - ECalenEditorDBName, ECalenEditorPlace );*/ // TODO: Uncomment this when enabling attachment support // Replace ECalenEditorDBName with ECalenEditorAttachment in the next statement @@ -564,17 +620,47 @@ { TRACE_ENTRY_POINT; - CEikDateEditor* dateField = NULL; - dateField = static_cast( iUnifiedEditor.ControlOrNull( aControlId ) ); - if( dateField ) + TBool useLunarDate = EFalse; + if(aControlId == ECalenEditorStartDate + && FeatureManager::FeatureSupported( KFeatureIdKorean )) + { + if( CCalEntry::EAnniv == iUnifiedEditor.GetEntryType() ) + { + TLunarCalendarType type = iUnifiedEditor.Edited().CalendarType(); + if( type != ESolar ) + { + useLunarDate = ETrue; + } + } + } + + if(useLunarDate || aControlId == EKoreanLunarAniversityStart + && FeatureManager::FeatureSupported( KFeatureIdKorean ) ) + { + CKoreanLunarDateEditor* dateField = NULL; + dateField = static_cast( iUnifiedEditor.ControlOrNull( EKoreanLunarAniversityStart ) ); + if( dateField ) + { + dateField->SetDate(aTime, EFalse); + } + if ( aDoDraw ) + { + dateField->DrawDeferred(); + } + } + else { - dateField->SetDate( aTime ); - if( aDoDraw ) - { - dateField->DrawDeferred(); - } - } - + CEikDateEditor* dateField = NULL; + dateField = static_cast( iUnifiedEditor.ControlOrNull( aControlId ) ); + if( dateField ) + { + dateField->SetDate( aTime ); + if( aDoDraw ) + { + dateField->DrawDeferred(); + } + } + } TRACE_EXIT_POINT; } @@ -721,6 +807,19 @@ iDbField->HandleControlStateChangeL( aControlId ); } break; + case EKoreanLunarTypeSelectSolarLunarLeap: + { + if (FeatureManager::FeatureSupported( KFeatureIdKorean )) + { + iKoreanLunarTypeField->HandleControlStateChangeL( aControlId ); + } + } + break; + case EKoreanLunarAniversityStart: + { + iKoreanLunarDateEditor->HandleControlStateChangeL( aControlId ); + } + default: break; } @@ -750,6 +849,7 @@ case ECalenEditorStartTime: case ECalenEditorStartDate: + case EKoreanLunarAniversityStart: { ReadStartDateTimeFromEditorL( ETrue, aFocusedId ); UpdateMeetingDurationL(); @@ -804,6 +904,8 @@ break; case ECalenEditorDescription: break; + case EKoreanLunarTypeSelectSolarLunarLeap: + break; default: break; } @@ -844,6 +946,44 @@ } // ----------------------------------------------------------------------------- +// CCalenUnifiedEditorControl::OnLunarTypeChangedL +// Handles lunar type changed +// ----------------------------------------------------------------------------- +// +void CCalenUnifiedEditorControl::OnLunarTypeChangedL( TLunarCalendarType aNewEventType ) + { + TRACE_ENTRY_POINT; + if( FeatureManager::FeatureSupported( KFeatureIdKorean ) ) + { + TLunarCalendarType oldType = iUnifiedEditor.Edited().CalendarType(); + if(oldType != aNewEventType) + { + iUnifiedEditor.Edited().SetCalendarTypeL(aNewEventType); + if(aNewEventType == ESolar) + { + iUnifiedEditor.DeleteLine(EKoreanLunarAniversityStart, ETrue); + iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_START_DATE_ITEM, + ECalenEditorStartDate, EKoreanLunarTypeSelectSolarLunarLeap ); + iUnifiedEditor.SetControlCaptionL( ECalenEditorStartDate, + R_QTN_CALEN_EDITOR_DATE_OF_BIRTH ); + SetDataToEditorL(); + } + else + { + if(oldType == ESolar) + { + iUnifiedEditor.DeleteLine(ECalenEditorStartDate, ETrue); + iUnifiedEditor.InsertFieldL( R_KOREAN_LUNAR_DATE_EDITOR_LINE, + EKoreanLunarAniversityStart, EKoreanLunarTypeSelectSolarLunarLeap ); + SetDataToEditorL(); + } + } + } + } + TRACE_EXIT_POINT; + } + +// ----------------------------------------------------------------------------- // CCalenUnifiedEditorControl::DeletePreviousEntryTypeFieldsL // Delete previous entry type fields on selcting // the new entry type @@ -866,7 +1006,20 @@ break; case CCalEntry::EAnniv: { - iUnifiedEditor.DeleteLine( ECalenEditorStartDate, EFalse ); + TLunarCalendarType type = iUnifiedEditor.Edited().CalendarType(); + if( type != ESolar && FeatureManager::FeatureSupported( KFeatureIdKorean ) ) + { + iUnifiedEditor.DeleteLine( EKoreanLunarAniversityStart, EFalse ); + } + else + { + iUnifiedEditor.DeleteLine( ECalenEditorStartDate, EFalse ); + } + + if(FeatureManager::FeatureSupported( KFeatureIdKorean )) + { + iUnifiedEditor.DeleteLine( EKoreanLunarTypeSelectSolarLunarLeap, EFalse ); + } } break; case CCalEntry::EAppt: @@ -1061,6 +1214,16 @@ } } + if( iUnifiedEditor.GetEntryType() == CCalEntry::EAnniv + && FeatureManager::FeatureSupported( KFeatureIdKorean ) ) + { + CCoeControl* lunarcaltype = iUnifiedEditor.ControlOrNull( EKoreanLunarTypeSelectSolarLunarLeap ); + if( lunarcaltype ) + { + iKoreanLunarTypeField->ReadDataFromFormL( aContinueOnError ); + } + } + iDbField->ReadDataFromFormL( aContinueOnError ); TRACE_EXIT_POINT; @@ -1251,6 +1414,20 @@ TTime CCalenUnifiedEditorControl::ReadTimeField( TInt aControlId ) { TRACE_ENTRY_POINT; + + if(aControlId == ECalenEditorStartDate && FeatureManager::FeatureSupported( KFeatureIdKorean )) + { + if( CCalEntry::EAnniv == iUnifiedEditor.GetEntryType() ) + { + TLunarCalendarType type = iUnifiedEditor.Edited().CalendarType(); + if( type != ESolar ) + { + aControlId = EKoreanLunarAniversityStart; + TRACE_EXIT_POINT; + return static_cast( iUnifiedEditor.Control( aControlId ) )->Date(); + } + } + } TRACE_EXIT_POINT; return static_cast( iUnifiedEditor.Control( aControlId ) )->GetTTime(); } @@ -1263,6 +1440,21 @@ TTime CCalenUnifiedEditorControl::ReadDateField( TInt aControlId ) { TRACE_ENTRY_POINT; + + if(aControlId == ECalenEditorStartDate && FeatureManager::FeatureSupported( KFeatureIdKorean )) + { + if( CCalEntry::EAnniv == iUnifiedEditor.GetEntryType() ) + { + TLunarCalendarType type = iUnifiedEditor.Edited().CalendarType(); + if( type != ESolar ) + { + aControlId = EKoreanLunarAniversityStart; + TRACE_EXIT_POINT; + return static_cast( iUnifiedEditor.Control( aControlId ) )->Date(); + } + } + } + TRACE_EXIT_POINT; return static_cast( iUnifiedEditor.Control( aControlId ) )->Date(); } @@ -1355,14 +1547,23 @@ case CCalEntry::EAnniv: { - iUnifiedEditor.DeleteLine( ECalenEditorStartDate, EFalse ); - iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_START_DATE_ITEM, - ECalenEditorStartDate, ECalenEditorEventType ); - - // "Start Date" Label should be "Date of Birth" for Birthday - iUnifiedEditor.SetControlCaptionL( ECalenEditorStartDate, - R_QTN_CALEN_EDITOR_DATE_OF_BIRTH ); - + TLunarCalendarType type = iUnifiedEditor.Edited().CalendarType(); + if( type != ESolar && FeatureManager::FeatureSupported( KFeatureIdKorean )) + { + iUnifiedEditor.DeleteLine( EKoreanLunarAniversityStart, EFalse ); + iUnifiedEditor.InsertFieldL( R_KOREAN_LUNAR_DATE_EDITOR_LINE, + EKoreanLunarAniversityStart, EKoreanLunarTypeSelectSolarLunarLeap ); + } + else + { + iUnifiedEditor.DeleteLine( ECalenEditorStartDate, EFalse ); + iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_START_DATE_ITEM, + ECalenEditorStartDate, ECalenEditorEventType ); + // "Start Date" Label should be "Date of Birth" for Birthday + iUnifiedEditor.SetControlCaptionL( ECalenEditorStartDate, + R_QTN_CALEN_EDITOR_DATE_OF_BIRTH ); + } + } break;