102 delete iInfoBarText; |
99 delete iInfoBarText; |
103 iInfoBarText = NULL; |
100 iInfoBarText = NULL; |
104 } |
101 } |
105 |
102 |
106 delete iInfoProvider; |
103 delete iInfoProvider; |
|
104 iInfoProvider = NULL; |
107 delete iLocalizer; |
105 delete iLocalizer; |
|
106 iLocalizer = NULL; |
108 delete iLocInfo; |
107 delete iLocInfo; |
109 |
108 iLocInfo = NULL; |
110 if( iResourceFileOffset ) |
109 |
111 { |
110 // Remove the translator for plugin |
112 CCoeEnv::Static()->DeleteResourceFile( iResourceFileOffset ); |
111 if (iTranslator) { |
113 } |
112 delete iTranslator; |
|
113 iTranslator = 0; |
|
114 } |
114 TRACE_EXIT_POINT; |
115 TRACE_EXIT_POINT; |
115 } |
116 } |
116 |
117 |
117 // ----------------------------------------------------------------------------- |
118 // ----------------------------------------------------------------------------- |
118 // CCalenLunarChinesePlugin::ContructL |
119 // CCalenLunarChinesePlugin::ContructL |
119 // ----------------------------------------------------------------------------- |
120 // ----------------------------------------------------------------------------- |
120 // |
121 // |
121 void CCalenLunarChinesePlugin::ConstructL() |
122 void CCalenLunarChinesePlugin::ConstructL() |
122 { |
123 { |
123 TRACE_ENTRY_POINT; |
124 TRACE_ENTRY_POINT; |
124 |
|
125 TFileName dllName; |
|
126 // Get the complate path of the DLL from where it is currently loaded |
|
127 Dll::FileName( dllName ); |
|
128 |
|
129 TFileName resourceFilename; |
|
130 resourceFilename.Append(dllName.Mid(0,2)); |
|
131 resourceFilename.Append(KResourcePath); |
|
132 resourceFilename.Append(KResourceChinesePluginFile); |
|
133 BaflUtils::NearestLanguageFile( CEikonEnv::Static()->FsSession(), |
|
134 resourceFilename ); |
|
135 // Add the resource file. |
|
136 iResourceFileOffset = CEikonEnv::Static()->AddResourceFileL( |
|
137 resourceFilename ); |
|
138 |
|
139 iServices->RegisterForNotificationsL( this, ECalenNotifyContextChanged ); |
125 iServices->RegisterForNotificationsL( this, ECalenNotifyContextChanged ); |
140 iServices->GetCommandRange( iStart, iEnd ); |
126 iServices->GetCommandRange( iStart, iEnd ); |
141 |
127 |
|
128 // Install the translator before the CCalenLunarLocalizer is constructed |
|
129 iTranslator = new HbTranslator("calenregional"); |
|
130 |
142 iLocalizer = CCalenLunarLocalizer::NewL(); |
131 iLocalizer = CCalenLunarLocalizer::NewL(); |
143 |
132 |
144 iInfoProvider = CCalenLunarInfoProvider::NewL( |
133 iInfoProvider = CCalenLunarInfoProvider::NewL( |
145 CEikonEnv::Static()->FsSession() ); |
134 CEikonEnv::Static()->FsSession() ); |
|
135 |
146 |
136 |
147 TRACE_EXIT_POINT; |
137 TRACE_EXIT_POINT; |
148 } |
138 } |
149 |
139 |
150 // ----------------------------------------------------------------------------- |
140 // ----------------------------------------------------------------------------- |
272 // ----------------------------------------------------------------------------- |
262 // ----------------------------------------------------------------------------- |
273 // |
263 // |
274 void CCalenLunarChinesePlugin::UpdateLocalizerInfoL() |
264 void CCalenLunarChinesePlugin::UpdateLocalizerInfoL() |
275 { |
265 { |
276 TRACE_ENTRY_POINT; |
266 TRACE_ENTRY_POINT; |
277 QDateTime focusDateTime= iServices->Context().focusDateAndTimeL(); |
267 QDateTime focusDateTime= iServices->Context().focusDateAndTime(); |
278 TDateTime tempDateTime( |
268 TDateTime tempDateTime( |
279 focusDateTime.date().year(), |
269 focusDateTime.date().year(), |
280 static_cast<TMonth>(focusDateTime.date().month() - 1), |
270 static_cast<TMonth>(focusDateTime.date().month() - 1), |
281 focusDateTime.date().day() - 1, focusDateTime.time().hour(), |
271 focusDateTime.date().day() - 1, focusDateTime.time().hour(), |
282 focusDateTime.time().minute(), 0, 0); |
272 focusDateTime.time().minute(), 0, 0); |
310 // CCalenLunarChinesePlugin::ShowDetailsL |
300 // CCalenLunarChinesePlugin::ShowDetailsL |
311 // Message popup from menu |
301 // Message popup from menu |
312 // ----------------------------------------------------------------------------- |
302 // ----------------------------------------------------------------------------- |
313 // |
303 // |
314 void CCalenLunarChinesePlugin::ShowDetailsL( ) |
304 void CCalenLunarChinesePlugin::ShowDetailsL( ) |
315 { |
305 { |
316 TRACE_ENTRY_POINT; |
306 QString msgText; |
317 HBufC* msgText = HBufC::NewLC( 1000 ); |
307 if(iLocInfo) { |
318 if ( iLocInfo ) |
308 QStringList headerIds; |
319 { |
309 headerIds.append(hbTrId("txt_calendar_info_festival")); |
320 TInt headerIds[KFieldCount] = { |
310 headerIds.append(hbTrId("txt_calendar_solar_term")); |
321 R_CALENDAR_LUNAR_INFO_FESTIVAL, |
311 headerIds.append(hbTrId("txt_calendar_lunar_date")); |
322 R_CALENDAR_LUNAR_INFO_SOLAR, |
312 headerIds.append(hbTrId("txt_calendar_animal_year")); |
323 R_CALENDAR_LUNAR_INFO_DATE, |
313 headerIds.append(hbTrId("txt_calendar_gregorian_date")); |
324 R_CALENDAR_LUNAR_INFO_ANIMAL_YEAR, |
314 |
325 R_CALENDAR_LUNAR_INFO_WESTERN_DATE |
315 QStringList fieldInfo; |
326 }; |
316 QString data; |
327 |
317 |
328 RPointerArray<HBufC> headersArray; |
318 data = QString::fromUtf16(iLocInfo->Festival().Ptr(),iLocInfo->Festival().Length()); |
329 |
319 fieldInfo.append(data); |
330 for ( TInt i=0; i < KFieldCount; i++) |
320 data = QString::fromUtf16(iLocInfo->SolarTerm().Ptr(),iLocInfo->SolarTerm().Length()); |
331 { |
321 fieldInfo.append(data); |
332 headersArray.Append( StringLoader::LoadL( headerIds[i] ) ); |
322 data = QString::fromUtf16(iLocInfo->FullLunarDate().Ptr(),iLocInfo->FullLunarDate().Length()); |
333 } |
323 fieldInfo.append(data); |
334 |
324 data = QString::fromUtf16(iLocInfo->AnimalYear().Ptr(),iLocInfo->AnimalYear().Length()); |
335 CPtrCArray* fieldsArray = new (ELeave) CPtrCArray(5); |
325 fieldInfo.append(data); |
336 CleanupStack::PushL( fieldsArray ); |
326 data = QString::fromUtf16(iLocInfo->GregorianDate().Ptr(),iLocInfo->GregorianDate().Length()); |
337 fieldsArray->AppendL( iLocInfo->Festival() ); |
327 fieldInfo.append(data); |
338 fieldsArray->AppendL( iLocInfo->SolarTerm() ); |
328 // Append the data in the proper order |
339 fieldsArray->AppendL( iLocInfo->FullLunarDate() ); |
329 for (TInt i=0; i < KFieldCount; i++) { |
340 fieldsArray->AppendL( iLocInfo->AnimalYear() ); |
330 if(!fieldInfo.at(i).isEmpty()) { |
341 fieldsArray->AppendL( iLocInfo->GregorianDate() ); |
331 msgText.append(headerIds[i]); |
342 |
332 msgText.append(headerSeparator); |
343 for (TInt i=0; i < KFieldCount; i++) |
333 msgText.append(fieldInfo[i]); |
344 { |
334 if ( i < KFieldCount - 1 ) { |
345 TPtrC fieldPtrC = fieldsArray->At(i); |
335 // not last item |
346 if ( fieldPtrC != KNullDesC ) |
336 msgText.append(fieldSeparator); |
347 { |
337 } |
348 msgText->Des().Append( *(headersArray[i]) ); |
338 } |
349 msgText->Des().Append( KHeaderSeparator ); |
339 } |
350 msgText->Des().Append( fieldPtrC ); |
340 } |
351 if ( i < KFieldCount - 1 ) // not last |
341 ExecuteMessageDialogL(msgText); |
352 { |
342 } |
353 msgText->Des().Append( KFieldSeparator ); |
343 |
354 } |
344 // ----------------------------------------------------------------------------- |
355 } |
345 // CCalenLunarChinesePlugin::ExecuteMessageDialogL |
356 } |
346 // ----------------------------------------------------------------------------- |
357 CleanupStack::PopAndDestroy( fieldsArray ); |
347 // |
358 headersArray.ResetAndDestroy(); |
348 void CCalenLunarChinesePlugin::ExecuteMessageDialogL(QString aMsgText) |
359 } |
|
360 |
|
361 |
|
362 ExecuteMessageDialogL(*msgText); |
|
363 |
|
364 CleanupStack::PopAndDestroy( msgText ); |
|
365 |
|
366 TRACE_EXIT_POINT; |
|
367 } |
|
368 |
|
369 // ----------------------------------------------------------------------------- |
|
370 // CCalenLunarChinesePlugin::ShowMessageDialogL |
|
371 // ----------------------------------------------------------------------------- |
|
372 // |
|
373 void CCalenLunarChinesePlugin::ExecuteMessageDialogL(TDesC& aMsgText) |
|
374 { |
349 { |
375 TRACE_ENTRY_POINT; |
350 TRACE_ENTRY_POINT; |
376 QString text = QString::fromUtf16(aMsgText.Ptr(),aMsgText.Length()); |
351 // Instantiate a popup |
377 |
352 HbMessageBox *popup = new HbMessageBox(); |
378 // Instantiate a popup |
353 popup->setDismissPolicy(HbDialog::NoDismiss); |
379 HbMessageBox popup; |
354 popup->setTimeout(HbDialog::NoTimeout); |
380 popup.setDismissPolicy(HbDialog::NoDismiss); |
355 popup->setIconVisible(false); |
381 popup.setTimeout(HbDialog::NoTimeout); |
356 popup->setAttribute( Qt::WA_DeleteOnClose, true ); |
382 popup.setIconVisible(false); |
357 |
383 |
358 popup->setHeadingWidget(new HbLabel(hbTrId("txt_calendar_title_lunar_calendar"))); |
384 popup.setHeadingWidget(new HbLabel("Lunar Calendar")); |
359 popup->setText(aMsgText); |
385 popup.setText(text); |
360 |
386 |
361 // Remove the default actions |
387 // Sets the primary action |
362 QList<QAction*> list = popup->actions(); |
388 popup.setPrimaryAction(new HbAction(hbTrId("txt_calendar_button_cancel"), |
363 for(int i=0; i < list.count(); i++) |
389 &popup)); |
364 { |
390 |
365 popup->removeAction(list[i]); |
391 // Launch popup syncronously |
366 } |
392 popup.exec(); |
367 // Sets the primary action |
|
368 popup->addAction(new HbAction(hbTrId("txt_calendar_button_close"), popup)); |
|
369 |
|
370 // Launch popup |
|
371 popup->open(); |
393 TRACE_EXIT_POINT; |
372 TRACE_EXIT_POINT; |
394 } |
373 } |
395 |
|
396 //EOF |
374 //EOF |
397 |
375 |
398 |
376 |