calendarui/regionalplugins/calenregionalutil/src/calenlunarlocalizer.cpp
changeset 75 7ac58b2aae6f
parent 55 2c54b51f39c4
child 89 b57382753122
equal deleted inserted replaced
72:27feeedec790 75:7ac58b2aae6f
    19 
    19 
    20 #include <qdatetime.h>
    20 #include <qdatetime.h>
    21 #include <qstringlist.h>
    21 #include <qstringlist.h>
    22 #include <hbi18ndef.h>
    22 #include <hbi18ndef.h>
    23 #include <hbglobal.h>
    23 #include <hbglobal.h>
       
    24 #include <hbparameterlengthlimiter.h>
    24 
    25 
    25 #include <badesca.h> 
    26 #include <badesca.h> 
    26 #include <eikenv.h>
    27 #include <eikenv.h>
    27 #include <bautils.h>
    28 #include <bautils.h>
    28 #include <data_caging_path_literals.hrh>
    29 #include <data_caging_path_literals.hrh>
   182 
   183 
   183 
   184 
   184 	if ( aInfo.HasFestival() ) 
   185 	if ( aInfo.HasFestival() ) 
   185 	{
   186 	{
   186 		QString festival = iFestivalNames.at(aInfo.iFestival);
   187 		QString festival = iFestivalNames.at(aInfo.iFestival);
   187 		localized->iFestival.Set( static_cast<const TUint16*>(festival.utf16()),festival.length());
   188 		localized->iFestival.Set( 
       
   189 			static_cast<const TUint16*>(festival.utf16()),festival.length());
   188 	}
   190 	}
   189 
   191 
   190 	if ( aInfo.HasSolarTerm() ) 
   192 	if ( aInfo.HasSolarTerm() ) 
   191 	{
   193 	{
   192 		QString solarTerm = iSolarTermNames.at(aInfo.iSolarTerm);
   194 		QString solarTerm = iSolarTermNames.at(aInfo.iSolarTerm);
   193 		localized->iSolarTerm.Set( static_cast<const TUint16*>(solarTerm.utf16()),solarTerm.length());
   195 		localized->iSolarTerm.Set( 
       
   196 			static_cast<const TUint16*>(solarTerm.utf16()),solarTerm.length());
   194 	}
   197 	}
   195 
   198 
   196 	// Animal year
   199 	// Animal year
   197 	QString animalYear = iAnimalYearNames.at(aInfo.AnimalYear());
   200 	QString animalYear = iAnimalYearNames.at(aInfo.AnimalYear());
   198 	localized->iAnimalYear.Set( static_cast<const TUint16*>(animalYear.utf16()),animalYear.length());
   201 	localized->iAnimalYear.Set( 
       
   202 		static_cast<const TUint16*>(animalYear.utf16()),animalYear.length());
   199 
   203 
   200 	// Lunar year
   204 	// Lunar year
   201 	QString heavenlyStemNames = iHeavenlyStemNames.at(aInfo.iHeavenlyStem);
   205 	QString heavenlyStemNames = iHeavenlyStemNames.at(aInfo.iHeavenlyStem);
   202 	QString terrestialBranchNames = iTerrestialBranchNames.at(aInfo.iTerrestialBranch);
   206 	QString terrestialBranchNames = 
   203 	QString lunarYear = hbTrId("txt_calendar_info_lunar_year").arg(heavenlyStemNames).arg(terrestialBranchNames);
   207 						iTerrestialBranchNames.at(aInfo.iTerrestialBranch);
   204 	localized->iLunarYear = static_cast<const TUint16*> (lunarYear.utf16()), lunarYear.length();
   208 	QString lunarYear = HbParameterLengthLimiter(
       
   209 						hbTrId("txt_calendar_info_lunar_year")).arg(
       
   210 						heavenlyStemNames).arg(terrestialBranchNames);
       
   211 	localized->iLunarYear = 
       
   212 			static_cast<const TUint16*> (lunarYear.utf16()), lunarYear.length();
   205 
   213 
   206 	LocalizeMonthAndDayL(localized, aInfo);
   214 	LocalizeMonthAndDayL(localized, aInfo);
   207 
   215 
   208 	QString monthAndDay = QString::fromUtf16(localized->LunarMonthAndDay().Ptr(),localized->LunarMonthAndDay().Length());
   216 	QString monthAndDay = 
   209 	QString yearString = QString::fromUtf16(localized->LunarYear().Ptr(),localized->LunarYear().Length());
   217 			QString::fromUtf16(localized->LunarMonthAndDay().Ptr(),
   210 	QString fullLunarDate = hbTrId("txt_calendar_info_lunar_full_date").arg(monthAndDay).arg(yearString);
   218 								localized->LunarMonthAndDay().Length());
       
   219 	QString yearString = 
       
   220 			QString::fromUtf16(localized->LunarYear().Ptr(),
       
   221 								localized->LunarYear().Length());
       
   222 	QString fullLunarDate = HbParameterLengthLimiter(
       
   223 							hbTrId("txt_calendar_info_lunar_full_date")).arg(
       
   224 							monthAndDay).arg(yearString);
   211 	
   225 	
   212 	localized->iFullLunarDate = static_cast<const TUint16*> (fullLunarDate.utf16()), fullLunarDate.length();
   226 	localized->iFullLunarDate = 
       
   227 			static_cast<const TUint16*> (fullLunarDate.utf16()), 
       
   228 													fullLunarDate.length();
   213 
   229 
   214 	QString format(r_qtn_date_usual_with_zero);
   230 	QString format(r_qtn_date_usual_with_zero);
   215 	TBuf<100> gregFormatBuf;
   231 	TBuf<100> gregFormatBuf;
   216 	gregFormatBuf = static_cast<const TUint16*> (format.utf16()), format.length();
   232 	gregFormatBuf = 
       
   233 			static_cast<const TUint16*> (format.utf16()), format.length();
   217 	
   234 	
   218 	aInfo.iGregorianDate.FormatL( localized->iGregorianDate, gregFormatBuf );
   235 	aInfo.iGregorianDate.FormatL( localized->iGregorianDate, gregFormatBuf );
   219 
   236 
   220 	CleanupStack::Pop( localized );
   237 	CleanupStack::Pop( localized );
   221 	
   238 	
   260 	GetChineseMonth(aInfo.iLunarDate, month);
   277 	GetChineseMonth(aInfo.iLunarDate, month);
   261 	GetChineseDay(aInfo.iLunarDate, day);
   278 	GetChineseDay(aInfo.iLunarDate, day);
   262 
   279 
   263 	QString formattedString;
   280 	QString formattedString;
   264 	if(aInfo.iLunarDate.iLeapMonth) {
   281 	if(aInfo.iLunarDate.iLeapMonth) {
   265 		formattedString = hbTrId(
   282 		formattedString = HbParameterLengthLimiter(hbTrId(
   266 						"txt_calendar_info_lunar_leap_date").arg(
   283 						"txt_calendar_info_lunar_leap_date")).arg(
   267 						QString((QChar*)month.Ptr(),month.Length())).arg(
   284 						QString((QChar*)month.Ptr(),month.Length())).arg(
   268 						QString((QChar*)day.Ptr(),day.Length()));
   285 						QString((QChar*)day.Ptr(),day.Length()));
   269 	}else {
   286 	}else {
   270 		formattedString = hbTrId(
   287 		formattedString = HbParameterLengthLimiter(hbTrId(
   271 						"txt_calendar_info_lunar_date").arg(
   288 						"txt_calendar_info_lunar_date")).arg(
   272 						QString((QChar*)month.Ptr(),month.Length())).arg(
   289 						QString((QChar*)month.Ptr(),month.Length())).arg(
   273 						QString((QChar*)day.Ptr(),day.Length()));
   290 						QString((QChar*)day.Ptr(),day.Length()));
   274 	}
   291 	}
   275 	aLocInfo->iLunarMonthAndDay = static_cast<const TUint16*> (
   292 	aLocInfo->iLunarMonthAndDay = static_cast<const TUint16*> (
   276 							formattedString.utf16()), formattedString.length();
   293 							formattedString.utf16()), formattedString.length();