101 if(iInfoBarText) |
107 if(iInfoBarText) |
102 { |
108 { |
103 delete iInfoBarText; |
109 delete iInfoBarText; |
104 iInfoBarText = NULL; |
110 iInfoBarText = NULL; |
105 } |
111 } |
106 if(iRegionalInfo) |
112 |
107 { |
|
108 delete iRegionalInfo; |
|
109 iRegionalInfo = NULL; |
|
110 } |
|
111 delete iInfoProvider; |
113 delete iInfoProvider; |
112 iInfoProvider = NULL; |
|
113 delete iLocalizer; |
114 delete iLocalizer; |
114 iLocalizer = NULL; |
|
115 delete iLocInfo; |
115 delete iLocInfo; |
116 iLocInfo = NULL; |
116 |
117 |
117 if( iResourceFileOffset ) |
118 // Remove the translator for plugin |
118 { |
119 if (iTranslator) { |
119 CCoeEnv::Static()->DeleteResourceFile( iResourceFileOffset ); |
120 delete iTranslator; |
120 } |
121 iTranslator = 0; |
121 TRACE_EXIT_POINT; |
122 } |
|
123 OstTraceFunctionExit0( DUP1_CCALENLUNARCHINESEPLUGIN_CCALENLUNARCHINESEPLUGIN_EXIT ); |
|
124 } |
122 } |
125 |
123 |
126 // ----------------------------------------------------------------------------- |
124 // ----------------------------------------------------------------------------- |
127 // CCalenLunarChinesePlugin::ContructL |
125 // CCalenLunarChinesePlugin::ContructL |
128 // ----------------------------------------------------------------------------- |
126 // ----------------------------------------------------------------------------- |
129 // |
127 // |
130 void CCalenLunarChinesePlugin::ConstructL() |
128 void CCalenLunarChinesePlugin::ConstructL() |
131 { |
129 { |
132 OstTraceFunctionEntry0( CCALENLUNARCHINESEPLUGIN_CONSTRUCTL_ENTRY ); |
130 TRACE_ENTRY_POINT; |
|
131 |
|
132 TFileName dllName; |
|
133 // Get the complate path of the DLL from where it is currently loaded |
|
134 Dll::FileName( dllName ); |
|
135 |
|
136 TFileName resourceFilename; |
|
137 resourceFilename.Append(dllName.Mid(0,2)); |
|
138 resourceFilename.Append(KResourcePath); |
|
139 resourceFilename.Append(KResourceChinesePluginFile); |
|
140 BaflUtils::NearestLanguageFile( CEikonEnv::Static()->FsSession(), resourceFilename ); |
|
141 // Add the resource file. |
|
142 iResourceFileOffset = CEikonEnv::Static()->AddResourceFileL( resourceFilename ); |
|
143 |
133 iServices->RegisterForNotificationsL( this, ECalenNotifyContextChanged ); |
144 iServices->RegisterForNotificationsL( this, ECalenNotifyContextChanged ); |
134 iServices->GetCommandRange( iStart, iEnd ); |
145 iServices->GetCommandRange( iStart, iEnd ); |
135 |
146 |
136 // Install the translator before the CCalenLunarLocalizer is constructed |
|
137 iTranslator = new HbTranslator("calenregional"); |
|
138 |
|
139 iLocalizer = CCalenLunarLocalizer::NewL(); |
147 iLocalizer = CCalenLunarLocalizer::NewL(); |
140 |
148 |
141 iInfoProvider = CCalenLunarInfoProvider::NewL( |
149 iInfoProvider = CCalenLunarInfoProvider::NewL(CEikonEnv::Static()->FsSession()); |
142 CEikonEnv::Static()->FsSession() ); |
150 |
143 //Qt class having a slot ,calls when user clicked show lunar data option |
151 iLabelControl = CCalenPluginLabel::NewL(*this); |
144 iRegionalInfo = new CalenRegionalInfo(*this); |
152 |
145 |
153 |
146 OstTraceFunctionExit0( CCALENLUNARCHINESEPLUGIN_CONSTRUCTL_EXIT ); |
154 TRACE_EXIT_POINT; |
147 } |
155 } |
148 |
156 |
|
157 |
|
158 // ----------------------------------------------------------------------------- |
|
159 // CCalenLunarChinesePlugin::SetLabelContentExtraL |
|
160 // ----------------------------------------------------------------------------- |
|
161 // |
|
162 void CCalenLunarChinesePlugin::SetLabelContentExtraL(CEikLabel& aLabel, |
|
163 TRect& aRect) |
|
164 { |
|
165 TRACE_ENTRY_POINT; |
|
166 |
|
167 TRect nullRect; |
|
168 aLabel.SetRect(nullRect); |
|
169 |
|
170 FormatExtraRowStringL( aLabel, ETrue ); |
|
171 |
|
172 CArrayFixFlat<TPtrC>* textLines = new(ELeave)CArrayFixFlat<TPtrC>( 2 ); |
|
173 CleanupStack::PushL( textLines ); |
|
174 |
|
175 CArrayFixFlat<TInt>* lineWidths = new( ELeave )CArrayFixFlat<TInt>( 1 ); |
|
176 CleanupStack::PushL( lineWidths ); |
|
177 |
|
178 TInt maxWidth = aRect.Size().iWidth; |
|
179 lineWidths->AppendL(maxWidth); |
|
180 |
|
181 const CFont* fontLabel = AknLayoutUtils::FontFromId( |
|
182 EAknLogicalFontPrimarySmallFont, NULL); |
|
183 |
|
184 HBufC* visualText = |
|
185 AknBidiTextUtils::ConvertToVisualAndWrapToArrayWholeTextL( |
|
186 iExtraRowText, *lineWidths, *fontLabel, *textLines); |
|
187 |
|
188 if (textLines->Count() < 3 && textLines->Count() > 0) |
|
189 { |
|
190 TInt nH = textLines->Count(); |
|
191 aRect.iBr.iY = aRect.iBr.iY * nH; |
|
192 } |
|
193 |
|
194 HBufC* newLinedText = HBufC::NewLC(iExtraRowText.Length() + 4); |
|
195 |
|
196 for (TInt i = 0; i < textLines->Count(); i++) |
|
197 { |
|
198 newLinedText->Des().Append(textLines->At(i)); |
|
199 newLinedText->Des().Append(KFieldSeparator); |
|
200 } |
|
201 |
|
202 aLabel.UseLogicalToVisualConversion(ETrue); |
|
203 aLabel.SetLabelAlignment(ELayoutAlignCenter); |
|
204 aLabel.SetTextL( *newLinedText); |
|
205 |
|
206 // Query the text colour based on the theme and update the label text |
|
207 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
208 TRgb color; |
|
209 TInt error = AknsUtils::GetCachedColor(skin, color, |
|
210 KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG6); |
|
211 if (error == KErrNone) |
|
212 { |
|
213 aLabel.OverrideColorL(EColorLabelText, color); |
|
214 } |
|
215 CleanupStack::PopAndDestroy(newLinedText); |
|
216 CleanupStack::PopAndDestroy(lineWidths); |
|
217 CleanupStack::PopAndDestroy(textLines); |
|
218 delete visualText; |
|
219 |
|
220 TRACE_EXIT_POINT; |
|
221 } |
|
222 |
|
223 // ----------------------------------------------------------------------------- |
|
224 // CCalenLunarChinesePlugin::SetLabelContentL |
|
225 // ----------------------------------------------------------------------------- |
|
226 // |
|
227 void CCalenLunarChinesePlugin::SetLabelContentL(CEikLabel& aLabel, |
|
228 const TRect& /*aRect*/) |
|
229 { |
|
230 TRACE_ENTRY_POINT; |
|
231 TRect nullRect(0,0,0,0); |
|
232 aLabel.SetRect(nullRect); |
|
233 |
|
234 FormatExtraRowStringL( aLabel, EFalse ); |
|
235 aLabel.UseLogicalToVisualConversion(ETrue); |
|
236 aLabel.SetLabelAlignment(ELayoutAlignCenter); |
|
237 aLabel.SetTextL( iExtraRowText ); |
|
238 |
|
239 // Query the text colour based on the theme and update the label text |
|
240 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
241 TRgb color; |
|
242 TInt error = AknsUtils::GetCachedColor(skin, color, |
|
243 KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG6); |
|
244 if (error == KErrNone) |
|
245 { |
|
246 aLabel.OverrideColorL(EColorLabelText, color); |
|
247 } |
|
248 |
|
249 TRACE_EXIT_POINT; |
|
250 } |
|
251 |
|
252 |
149 // ----------------------------------------------------------------------------- |
253 // ----------------------------------------------------------------------------- |
150 // CCalenLunarChinesePlugin::FormatExtraRowStringL |
254 // CCalenLunarChinesePlugin::FormatExtraRowStringL |
151 // ----------------------------------------------------------------------------- |
255 // ----------------------------------------------------------------------------- |
152 // |
256 // |
153 void CCalenLunarChinesePlugin::FormatExtraRowStringL() |
257 void CCalenLunarChinesePlugin::FormatExtraRowStringL( CEikLabel& aLabel,TBool aTwoLines) |
154 |
258 { |
155 { |
259 TRACE_ENTRY_POINT; |
156 OstTraceFunctionEntry0( CCALENLUNARCHINESEPLUGIN_FORMATEXTRAROWSTRINGL_ENTRY ); |
260 |
157 if ( iLocInfo ) |
261 const CFont* labelFont = NULL; |
158 { |
262 |
159 iExtraRowText.Set( iLocalizer->GetExtraRowTextL( *iLocInfo) ); |
263 if( aTwoLines ) |
160 } |
264 { |
|
265 labelFont = AknLayoutUtils::FontFromId(EAknLogicalFontPrimarySmallFont,NULL); |
|
266 } |
|
267 else |
|
268 { |
|
269 labelFont = AknLayoutUtils::FontFromId(EAknLogicalFontSecondaryFont,NULL); |
|
270 } |
|
271 |
|
272 aLabel.SetFont( labelFont ); |
|
273 TInt maxWidth = 0; |
|
274 if(iRect.IsEmpty()) |
|
275 { |
|
276 maxWidth = 450; //For hitch we take max value |
|
277 } |
161 else |
278 else |
|
279 { |
|
280 maxWidth = iRect.Size().iWidth; |
|
281 } |
|
282 |
|
283 if ( labelFont && iLocInfo ) |
|
284 { |
|
285 iExtraRowText.Set( iLocalizer->GetExtraRowTextL( *iLocInfo, |
|
286 maxWidth, |
|
287 *labelFont, |
|
288 aTwoLines ) |
|
289 ); |
|
290 } |
|
291 else |
162 { |
292 { |
163 iExtraRowText.Set( KNullDesC ); |
293 iExtraRowText.Set( KNullDesC ); |
164 } |
294 } |
165 OstTraceFunctionExit0( CCALENLUNARCHINESEPLUGIN_FORMATEXTRAROWSTRINGL_EXIT ); |
295 |
|
296 TRACE_EXIT_POINT; |
166 } |
297 } |
167 |
298 |
168 // ----------------------------------------------------------------------------- |
299 // ----------------------------------------------------------------------------- |
169 // CCalenLunarChinesePlugin::InfobarL |
300 // CCalenLunarChinesePlugin::InfobarL |
170 // ----------------------------------------------------------------------------- |
301 // ----------------------------------------------------------------------------- |
171 // |
302 // |
172 HbWidget* CCalenLunarChinesePlugin::InfobarL( ) |
303 CCoeControl* CCalenLunarChinesePlugin::InfobarL( const TRect& aRect ) |
173 { |
304 { |
174 OstTraceFunctionEntry0( CCALENLUNARCHINESEPLUGIN_INFOBARL_ENTRY ); |
305 TRACE_ENTRY_POINT; |
175 OstTraceFunctionExit0( CCALENLUNARCHINESEPLUGIN_INFOBARL_EXIT ); |
306 |
176 return NULL; |
307 UpdateLocalizerInfoL(); |
|
308 iRect = aRect; |
|
309 |
|
310 if(iLabelControl) |
|
311 { |
|
312 delete iLabelControl; |
|
313 iLabelControl = NULL; |
|
314 } |
|
315 |
|
316 iLabelControl = CCalenPluginLabel::NewL(*this); |
|
317 |
|
318 SetLabelContentL(*iLabelControl,aRect); |
|
319 iLabelControl->SetRect(aRect); |
|
320 |
|
321 return iLabelControl; |
|
322 |
|
323 TRACE_EXIT_POINT; |
177 } |
324 } |
178 |
325 |
179 // ---------------------------------------------------------------------------- |
326 // ---------------------------------------------------------------------------- |
180 // CCalenThaiPlugin::InfobarL |
327 // CCalenThaiPlugin::InfobarL |
181 // This function is called in case of Hitchcock views |
328 // This function is called in case of Hitchcock views |
182 // ---------------------------------------------------------------------------- |
329 // ---------------------------------------------------------------------------- |
183 // |
330 // |
184 QString* CCalenLunarChinesePlugin::InfobarTextL( ) |
331 const TDesC& CCalenLunarChinesePlugin::InfobarL( ) |
185 { |
332 { |
186 OstTraceFunctionEntry0( CCALENLUNARCHINESEPLUGIN_INFOBARTEXTL_ENTRY ); |
333 TRACE_ENTRY_POINT; |
|
334 TRect nullRect(0,0,0,0); |
|
335 iRect = nullRect; |
187 if(iInfoBarText) |
336 if(iInfoBarText) |
188 { |
337 { |
189 delete iInfoBarText; |
338 delete iInfoBarText; |
190 iInfoBarText = NULL; |
339 iInfoBarText = NULL; |
191 } |
340 } |
192 //Update the local information based on current context |
341 //Update the local information based on current context |
193 //from framework. |
342 //from framework. |
194 UpdateLocalizerInfoL(); |
343 UpdateLocalizerInfoL(); |
195 FormatExtraRowStringL(); |
344 |
|
345 //Dummy label for formatting the iExtraRowText |
|
346 CEikLabel* dummyLabel = new(ELeave) CEikLabel; |
|
347 CleanupStack::PushL(dummyLabel); |
|
348 SetLabelContentL(*dummyLabel,TRect()); |
|
349 CleanupStack::PopAndDestroy(); |
|
350 |
196 iInfoBarText = iExtraRowText.AllocLC(); |
351 iInfoBarText = iExtraRowText.AllocLC(); |
197 CleanupStack::Pop(); |
352 CleanupStack::Pop(); |
198 |
353 |
199 return (new QString((QChar*)iInfoBarText->Des().Ptr(),iInfoBarText->Length())); |
354 TRACE_EXIT_POINT; |
200 } |
355 return *iInfoBarText; |
201 |
356 } |
202 // ---------------------------------------------------------------------------- |
357 |
203 // CCalenThaiPlugin::InfobarL |
358 // ----------------------------------------------------------------------------- |
204 // This function is called to add menuitem |
359 // CCalenLunarChinesePlugin::CustomPreviewPaneL |
205 // ---------------------------------------------------------------------------- |
360 // ----------------------------------------------------------------------------- |
206 // |
361 // |
207 |
362 MCalenPreview* CCalenLunarChinesePlugin::CustomPreviewPaneL( TRect& /*aRect*/ ) |
208 void CCalenLunarChinesePlugin::CustomiseMenu(HbMenu* aHbMenu) |
363 { |
209 { |
364 TRACE_ENTRY_POINT |
210 OstTraceFunctionEntry0( CCALENLUNARCHINESEPLUGIN_CUSTOMISEMENU_ENTRY ); |
365 TRACE_EXIT_POINT |
211 HbAction* lunarAction = new HbAction(hbTrId("txt_calendar_opt_show_lunar_data")); |
366 return NULL; |
212 QList<QAction*> actionList = aHbMenu->actions(); |
367 } |
213 TInt count = actionList.count() - 1; //To show the option "show lunar data" |
368 |
214 //as a second last action item for all |
369 // ----------------------------------------------------------------------------- |
215 //Menu |
370 // CCalenLunarChinesePlugin::PreviewPaneL |
216 if(count >= 0) |
371 // ----------------------------------------------------------------------------- |
217 aHbMenu->insertAction(actionList[count], lunarAction); |
372 // |
218 //calls a slot whenever user clicked "show lunar data" option |
373 CCoeControl* CCalenLunarChinesePlugin::PreviewPaneL( TRect& aRect ) |
219 QObject::connect(lunarAction,SIGNAL(triggered()), iRegionalInfo,SLOT(showRegionalDetails())); |
374 { |
220 OstTraceFunctionExit0( CCALENLUNARCHINESEPLUGIN_CUSTOMISEMENU_EXIT ); |
375 TRACE_ENTRY_POINT; |
221 } |
376 |
222 |
377 UpdateLocalizerInfoL(); |
|
378 iRect = aRect; |
|
379 if (iLabelControl) |
|
380 { |
|
381 delete iLabelControl; |
|
382 iLabelControl = NULL; |
|
383 } |
|
384 |
|
385 iLabelControl = CCalenPluginLabel::NewL(*this); |
|
386 |
|
387 if(!Layout_Meta_Data::IsLandscapeOrientation()) //Portriat |
|
388 { |
|
389 SetLabelContentL(*iLabelControl, aRect); |
|
390 } |
|
391 else |
|
392 { |
|
393 SetLabelContentExtraL(*iLabelControl,aRect); |
|
394 } |
|
395 |
|
396 |
|
397 return iLabelControl; |
|
398 TRACE_EXIT_POINT; |
|
399 } |
|
400 |
|
401 // ----------------------------------------------------------------------------- |
|
402 // CCalenLunarChinesePlugin::CustomiseMenuPaneL |
|
403 // ----------------------------------------------------------------------------- |
|
404 // |
|
405 TBool CCalenLunarChinesePlugin::CustomiseMenuPaneL( TInt /*aResourceId*/, |
|
406 CEikMenuPane* aMenuPane ) |
|
407 { |
|
408 TRACE_ENTRY_POINT; |
|
409 HBufC* itemText = StringLoader::LoadLC(R_CALENDAR_SHOW_LUNAR_DATA); |
|
410 |
|
411 CEikMenuPaneItem::SData menuItem; |
|
412 menuItem.iCommandId = iStart; |
|
413 menuItem.iCascadeId = 0; |
|
414 menuItem.iFlags = 0; |
|
415 menuItem.iText = *itemText; |
|
416 menuItem.iExtraText = KNullDesC; |
|
417 |
|
418 aMenuPane->InsertMenuItemL( menuItem, 1 ); |
|
419 |
|
420 CleanupStack::PopAndDestroy(itemText); |
|
421 TRACE_EXIT_POINT; |
|
422 return ETrue; |
|
423 } |
|
424 |
|
425 // ----------------------------------------------------------------------------- |
|
426 // CCalenLunarChinesePlugin::CanBeEnabledDisabled |
|
427 // ----------------------------------------------------------------------------- |
|
428 // |
|
429 TBool CCalenLunarChinesePlugin::CanBeEnabledDisabled() |
|
430 { |
|
431 TRACE_ENTRY_POINT; |
|
432 TRACE_EXIT_POINT; |
|
433 return ETrue; |
|
434 } |
|
435 |
|
436 // ----------------------------------------------------------------------------- |
|
437 // CCalenLunarChinesePlugin::CalenCustomisationExtensionL |
|
438 // ----------------------------------------------------------------------------- |
|
439 // |
|
440 TAny* CCalenLunarChinesePlugin::CalenCustomisationExtensionL( TUid /*aExtensionUid*/ ) |
|
441 { |
|
442 TRACE_ENTRY_POINT; |
|
443 TRACE_EXIT_POINT; |
|
444 return NULL; |
|
445 } |
223 // ----------------------------------------------------------------------------- |
446 // ----------------------------------------------------------------------------- |
224 // CCalenLunarChinesePlugin::HandleCommandL |
447 // CCalenLunarChinesePlugin::HandleCommandL |
225 // ----------------------------------------------------------------------------- |
448 // ----------------------------------------------------------------------------- |
226 // |
449 // |
227 TBool CCalenLunarChinesePlugin::HandleCommandL( const TCalenCommand& aCommand ) |
450 TBool CCalenLunarChinesePlugin::HandleCommandL( const TCalenCommand& aCommand ) |
228 { |
451 { |
229 OstTraceFunctionEntry0( CCALENLUNARCHINESEPLUGIN_HANDLECOMMANDL_ENTRY ); |
452 TRACE_ENTRY_POINT; |
|
453 |
230 const TInt commandId = aCommand.Command(); |
454 const TInt commandId = aCommand.Command(); |
231 if(ECalenRegionalPluginTapEvent == commandId) |
455 if(iStart == commandId) |
232 { |
456 { |
233 ShowDetailsL(); |
457 ShowDetailsL(); |
234 } |
458 } |
235 OstTraceFunctionExit0( CCALENLUNARCHINESEPLUGIN_HANDLECOMMANDL_EXIT ); |
459 TRACE_EXIT_POINT; |
236 return EFalse; |
460 return EFalse; |
237 } |
461 } |
238 |
462 |
239 // ---------------------------------------------------------------------------- |
463 // ---------------------------------------------------------------------------- |
240 // CCalenLunarChinesePlugin::CalenCommandHandlerExtensionL |
464 // CCalenLunarChinesePlugin::CalenCommandHandlerExtensionL |
241 // |
465 // |
242 // ---------------------------------------------------------------------------- |
466 // ---------------------------------------------------------------------------- |
243 // |
467 // |
244 TAny* CCalenLunarChinesePlugin::CalenCommandHandlerExtensionL( |
468 TAny* CCalenLunarChinesePlugin::CalenCommandHandlerExtensionL( TUid /*aExtensionUid*/ ) |
245 TUid /*aExtensionUid*/ ) |
469 { |
246 { |
470 TRACE_ENTRY_POINT; |
247 OstTraceFunctionEntry0( CCALENLUNARCHINESEPLUGIN_CALENCOMMANDHANDLEREXTENSIONL_ENTRY ); |
471 TRACE_EXIT_POINT; |
248 OstTraceFunctionExit0( CCALENLUNARCHINESEPLUGIN_CALENCOMMANDHANDLEREXTENSIONL_EXIT ); |
|
249 return NULL; |
472 return NULL; |
250 } |
473 } |
251 |
474 |
252 // ----------------------------------------------------------------------------- |
475 // ----------------------------------------------------------------------------- |
253 // CCalenLunarChinesePlugin::CommandHandlerL |
476 // CCalenLunarChinesePlugin::CommandHandlerL |
254 // ----------------------------------------------------------------------------- |
477 // ----------------------------------------------------------------------------- |
255 // |
478 // |
256 MCalenCommandHandler* CCalenLunarChinesePlugin::CommandHandlerL( TInt aCommand ) |
479 MCalenCommandHandler* CCalenLunarChinesePlugin::CommandHandlerL( TInt aCommand ) |
257 { |
480 { |
258 OstTraceFunctionEntry0( CCALENLUNARCHINESEPLUGIN_COMMANDHANDLERL_ENTRY ); |
481 TRACE_ENTRY_POINT; |
|
482 |
259 MCalenCommandHandler* commandHandler = NULL; |
483 MCalenCommandHandler* commandHandler = NULL; |
260 |
484 |
261 if(ECalenRegionalPluginTapEvent == aCommand) |
485 if(iStart == aCommand) |
262 { |
486 { |
263 commandHandler = this; |
487 commandHandler = this; |
264 } |
488 } |
265 |
489 |
266 OstTraceFunctionExit0( CCALENLUNARCHINESEPLUGIN_COMMANDHANDLERL_EXIT ); |
|
267 return commandHandler; |
490 return commandHandler; |
|
491 TRACE_EXIT_POINT; |
|
492 } |
|
493 |
|
494 // ----------------------------------------------------------------------------- |
|
495 // CCalenLunarChinesePlugin::RemoveViewsFromCycle |
|
496 // ----------------------------------------------------------------------------- |
|
497 // |
|
498 void CCalenLunarChinesePlugin::RemoveViewsFromCycle( RArray<TInt>& /*aViews*/ ) |
|
499 { |
|
500 TRACE_ENTRY_POINT; |
|
501 TRACE_EXIT_POINT; |
|
502 } |
|
503 |
|
504 // ----------------------------------------------------------------------------- |
|
505 // CCalenLunarChinesePlugin::GetCustomSettingsL |
|
506 // ----------------------------------------------------------------------------- |
|
507 // |
|
508 void CCalenLunarChinesePlugin::GetCustomSettingsL( RPointerArray<CAknSettingItem>& |
|
509 /*aCustomSettingArray*/) |
|
510 { |
|
511 TRACE_ENTRY_POINT; |
|
512 TRACE_EXIT_POINT; |
|
513 } |
|
514 |
|
515 // ----------------------------------------------------------------------------- |
|
516 // CCalenLunarChinesePlugin::GetCustomViewsL |
|
517 // ----------------------------------------------------------------------------- |
|
518 // |
|
519 void CCalenLunarChinesePlugin::GetCustomViewsL( RPointerArray<CCalenView>& |
|
520 /*aCustomViewArray*/ ) |
|
521 { |
|
522 TRACE_ENTRY_POINT; |
|
523 TRACE_EXIT_POINT; |
268 } |
524 } |
269 |
525 |
270 // ----------------------------------------------------------------------------- |
526 // ----------------------------------------------------------------------------- |
271 // CCalenLunarChinesePlugin::UpdateInfoLabelL |
527 // CCalenLunarChinesePlugin::UpdateInfoLabelL |
272 // ----------------------------------------------------------------------------- |
528 // ----------------------------------------------------------------------------- |
273 // |
529 // |
274 void CCalenLunarChinesePlugin::UpdateLocalizerInfoL() |
530 void CCalenLunarChinesePlugin::UpdateLocalizerInfoL() |
275 { |
531 { |
276 OstTraceFunctionEntry0( CCALENLUNARCHINESEPLUGIN_UPDATELOCALIZERINFOL_ENTRY ); |
532 TRACE_ENTRY_POINT; |
277 QDateTime focusDateTime= iServices->Context().focusDateAndTime(); |
533 TTime focusTime = iServices->Context().FocusDateAndTimeL().TimeLocalL(); |
278 TDateTime tempDateTime( |
|
279 focusDateTime.date().year(), |
|
280 static_cast<TMonth>(focusDateTime.date().month() - 1), |
|
281 focusDateTime.date().day() - 1, focusDateTime.time().hour(), |
|
282 focusDateTime.time().minute(), 0, 0); |
|
283 TTime focusTime(tempDateTime); |
|
284 TCalenLunarInfo lunarInfo = iInfoProvider->GetLunarInfoL( focusTime ); |
534 TCalenLunarInfo lunarInfo = iInfoProvider->GetLunarInfoL( focusTime ); |
285 delete iLocInfo; |
535 delete iLocInfo; |
286 iLocInfo = NULL; |
536 iLocInfo = NULL; |
287 if(iLocalizer) |
537 if(iLocalizer) |
288 { |
538 { |
289 iLocInfo = iLocalizer->LocalizeL( lunarInfo ); |
539 iLocInfo = iLocalizer->LocalizeL( lunarInfo ); |
290 } |
540 } |
291 OstTraceFunctionExit0( CCALENLUNARCHINESEPLUGIN_UPDATELOCALIZERINFOL_EXIT ); |
541 TRACE_EXIT_POINT; |
292 } |
542 } |
293 |
543 |
294 // ----------------------------------------------------------------------------- |
544 // ----------------------------------------------------------------------------- |
295 // CCalenLunarChinesePlugin::HandleNotification |
545 // CCalenLunarChinesePlugin::HandleNotification |
296 // ----------------------------------------------------------------------------- |
546 // ----------------------------------------------------------------------------- |
297 // |
547 // |
298 void CCalenLunarChinesePlugin::HandleNotification( |
548 void CCalenLunarChinesePlugin::HandleNotification(const TCalenNotification aNotification) |
299 const TCalenNotification aNotification ) |
549 { |
300 { |
550 TRACE_ENTRY_POINT; |
301 OstTraceFunctionEntry0( CCALENLUNARCHINESEPLUGIN_HANDLENOTIFICATION_ENTRY ); |
|
302 if (aNotification == ECalenNotifyContextChanged) |
551 if (aNotification == ECalenNotifyContextChanged) |
303 { |
552 { |
304 TRAP_IGNORE(UpdateLocalizerInfoL()); |
553 TRAP_IGNORE(UpdateLocalizerInfoL()); |
305 } |
554 } |
306 OstTraceFunctionExit0( CCALENLUNARCHINESEPLUGIN_HANDLENOTIFICATION_EXIT ); |
555 TRACE_EXIT_POINT; |
307 } |
556 } |
308 |
557 |
309 // ----------------------------------------------------------------------------- |
558 // ----------------------------------------------------------------------------- |
310 // CCalenLunarChinesePlugin::ShowDetailsL |
559 // CCalenLunarChinesePlugin::ShowDetailsL |
311 // Message popup from menu |
560 // Message popup from menu |
312 // ----------------------------------------------------------------------------- |
561 // ----------------------------------------------------------------------------- |
313 // |
562 // |
314 void CCalenLunarChinesePlugin::ShowDetailsL( ) |
563 void CCalenLunarChinesePlugin::ShowDetailsL( ) |
315 { |
564 { |
316 OstTraceFunctionEntry0( CCALENLUNARCHINESEPLUGIN_SHOWDETAILSL_ENTRY ); |
565 TRACE_ENTRY_POINT; |
317 QString msgText; |
566 HBufC* msgText = HBufC::NewLC( 1000 ); |
318 if(iLocInfo) { |
567 if ( iLocInfo ) |
319 QStringList headerIds; |
568 { |
320 headerIds.append(hbTrId("txt_calendar_info_festival")); |
569 TInt headerIds[KFieldCount] = { |
321 headerIds.append(hbTrId("txt_calendar_solar_term")); |
570 R_CALENDAR_LUNAR_INFO_FESTIVAL, |
322 headerIds.append(hbTrId("txt_calendar_lunar_date")); |
571 R_CALENDAR_LUNAR_INFO_SOLAR, |
323 headerIds.append(hbTrId("txt_calendar_animal_year")); |
572 R_CALENDAR_LUNAR_INFO_DATE, |
324 headerIds.append(hbTrId("txt_calendar_gregorian_date")); |
573 R_CALENDAR_LUNAR_INFO_ANIMAL_YEAR, |
325 |
574 R_CALENDAR_LUNAR_INFO_WESTERN_DATE |
326 QStringList fieldInfo; |
575 }; |
327 QString data; |
576 |
328 |
577 RPointerArray<HBufC> headersArray; |
329 data = QString::fromUtf16(iLocInfo->Festival().Ptr(),iLocInfo->Festival().Length()); |
578 |
330 fieldInfo.append(data); |
579 for ( TInt i=0; i < KFieldCount; i++) |
331 data = QString::fromUtf16(iLocInfo->SolarTerm().Ptr(),iLocInfo->SolarTerm().Length()); |
580 { |
332 fieldInfo.append(data); |
581 headersArray.Append( StringLoader::LoadL( headerIds[i] ) ); |
333 data = QString::fromUtf16(iLocInfo->FullLunarDate().Ptr(),iLocInfo->FullLunarDate().Length()); |
582 } |
334 fieldInfo.append(data); |
583 |
335 data = QString::fromUtf16(iLocInfo->AnimalYear().Ptr(),iLocInfo->AnimalYear().Length()); |
584 CPtrCArray* fieldsArray = new (ELeave) CPtrCArray(5); |
336 fieldInfo.append(data); |
585 CleanupStack::PushL( fieldsArray ); |
337 data = QString::fromUtf16(iLocInfo->GregorianDate().Ptr(),iLocInfo->GregorianDate().Length()); |
586 fieldsArray->AppendL( iLocInfo->Festival() ); |
338 fieldInfo.append(data); |
587 fieldsArray->AppendL( iLocInfo->SolarTerm() ); |
339 // Append the data in the proper order |
588 fieldsArray->AppendL( iLocInfo->FullLunarDate() ); |
340 for (TInt i=0; i < KFieldCount; i++) { |
589 fieldsArray->AppendL( iLocInfo->AnimalYear() ); |
341 if(!fieldInfo.at(i).isEmpty()) { |
590 fieldsArray->AppendL( iLocInfo->GregorianDate() ); |
342 msgText.append(headerIds[i]); |
591 |
343 msgText.append(headerSeparator); |
592 for (TInt i=0; i < KFieldCount; i++) |
344 msgText.append(fieldInfo[i]); |
593 { |
345 if ( i < KFieldCount - 1 ) { |
594 TPtrC fieldPtrC = fieldsArray->At(i); |
346 // not last item |
595 if ( fieldPtrC != KNullDesC ) |
347 msgText.append(fieldSeparator); |
596 { |
348 } |
597 msgText->Des().Append( *(headersArray[i]) ); |
349 } |
598 msgText->Des().Append( KHeaderSeparator ); |
350 } |
599 msgText->Des().Append( fieldPtrC ); |
351 } |
600 if ( i < KFieldCount - 1 ) // not last |
352 ExecuteMessageDialogL(msgText); |
601 { |
353 OstTraceFunctionExit0( CCALENLUNARCHINESEPLUGIN_SHOWDETAILSL_EXIT ); |
602 msgText->Des().Append( KFieldSeparator ); |
354 } |
603 } |
355 |
604 } |
356 // ----------------------------------------------------------------------------- |
605 } |
357 // CCalenLunarChinesePlugin::ExecuteMessageDialogL |
606 CleanupStack::PopAndDestroy( fieldsArray ); |
358 // ----------------------------------------------------------------------------- |
607 headersArray.ResetAndDestroy(); |
359 // |
608 } |
360 void CCalenLunarChinesePlugin::ExecuteMessageDialogL(QString aMsgText) |
609 |
361 { |
610 |
362 OstTraceFunctionEntry0( CCALENLUNARCHINESEPLUGIN_EXECUTEMESSAGEDIALOGL_ENTRY ); |
611 ExecuteMessageDialogL(*msgText); |
363 // Instantiate a popup |
612 |
364 HbMessageBox *popup = new HbMessageBox(); |
613 CleanupStack::PopAndDestroy( msgText ); |
365 popup->setDismissPolicy(HbDialog::NoDismiss); |
614 |
366 popup->setTimeout(HbDialog::NoTimeout); |
615 TRACE_EXIT_POINT; |
367 popup->setIconVisible(false); |
616 } |
368 popup->setAttribute( Qt::WA_DeleteOnClose, true ); |
617 |
369 |
618 // ----------------------------------------------------------------------------- |
370 popup->setHeadingWidget(new HbLabel(hbTrId("txt_calendar_title_lunar_calendar"))); |
619 // CCalenLunarChinesePlugin::ShowMessageDialogL |
371 popup->setText(aMsgText); |
620 // ----------------------------------------------------------------------------- |
372 |
621 // |
373 // Remove the default actions |
622 void CCalenLunarChinesePlugin::ExecuteMessageDialogL(TDesC& aMsgText) |
374 QList<QAction*> list = popup->actions(); |
623 { |
375 for(int i=0; i < list.count(); i++) |
624 TRACE_ENTRY_POINT; |
376 { |
625 |
377 popup->removeAction(list[i]); |
626 CAknMessageQueryDialog* dlg = CAknMessageQueryDialog::NewL(aMsgText); |
378 } |
627 CleanupStack::PushL(dlg); |
379 // Sets the primary action |
628 dlg->PrepareLC(R_CALEN_LUNAR_DETAILS_DIALOG); |
380 popup->addAction(new HbAction(hbTrId("txt_common_button_close_singledialog"), popup)); |
629 CleanupStack::Pop(dlg); |
381 |
630 dlg->RunLD(); |
382 // Launch popup |
631 |
383 popup->open(); |
632 TRACE_EXIT_POINT; |
384 OstTraceFunctionExit0( CCALENLUNARCHINESEPLUGIN_EXECUTEMESSAGEDIALOGL_EXIT ); |
633 } |
385 } |
634 |
|
635 // ----------------------------------------------------------------------------- |
|
636 // CCalenPluginLabel::NewL |
|
637 // ----------------------------------------------------------------------------- |
|
638 // |
|
639 CCalenPluginLabel* CCalenPluginLabel::NewL(CCalenLunarChinesePlugin& aPlugin) |
|
640 { |
|
641 TRACE_ENTRY_POINT; |
|
642 CCalenPluginLabel* self = new(ELeave)CCalenPluginLabel(aPlugin); |
|
643 CleanupStack::PushL(self); |
|
644 self->ConstructL(); |
|
645 CleanupStack::Pop(self); |
|
646 TRACE_EXIT_POINT; |
|
647 return self; |
|
648 } |
|
649 |
|
650 // ----------------------------------------------------------------------------- |
|
651 // CPluginLabel::CCalenLunarChinesePlugin |
|
652 // ----------------------------------------------------------------------------- |
|
653 // |
|
654 CCalenPluginLabel::CCalenPluginLabel(CCalenLunarChinesePlugin& aPlugin) : iPlugin(aPlugin) |
|
655 { |
|
656 TRACE_ENTRY_POINT; |
|
657 TRACE_EXIT_POINT; |
|
658 } |
|
659 |
|
660 |
|
661 // ----------------------------------------------------------------------------- |
|
662 // CPluginLabel::ConstructL |
|
663 // ----------------------------------------------------------------------------- |
|
664 // |
|
665 void CCalenPluginLabel::ConstructL() |
|
666 { |
|
667 TRACE_ENTRY_POINT; |
|
668 SetContainerWindowL(*this); |
|
669 TRACE_EXIT_POINT; |
|
670 } |
|
671 |
|
672 // ----------------------------------------------------------------------------- |
|
673 // CCalenPluginLabel::~CCalenPluginLabel |
|
674 // ----------------------------------------------------------------------------- |
|
675 // |
|
676 CCalenPluginLabel::~CCalenPluginLabel() |
|
677 { |
|
678 TRACE_ENTRY_POINT; |
|
679 TRACE_EXIT_POINT; |
|
680 } |
|
681 |
|
682 // ----------------------------------------------------------------------------- |
|
683 // CCalenPluginLabel::Draw |
|
684 // ----------------------------------------------------------------------------- |
|
685 // |
|
686 void CCalenPluginLabel::Draw( const TRect& aRect) const |
|
687 { |
|
688 TRACE_ENTRY_POINT; |
|
689 CEikLabel::Draw(aRect); |
|
690 TRACE_EXIT_POINT; |
|
691 } |
|
692 |
|
693 // ----------------------------------------------------------------------------- |
|
694 // CCalenPluginLabel::HandlePointerEventL |
|
695 // ----------------------------------------------------------------------------- |
|
696 // |
|
697 void CCalenPluginLabel::HandlePointerEventL(const TPointerEvent& |
|
698 aPointerEvent) |
|
699 { |
|
700 TRACE_ENTRY_POINT; |
|
701 |
|
702 if( AknLayoutUtils::PenEnabled() && |
|
703 aPointerEvent.iType == TPointerEvent::EButton1Down ) |
|
704 { |
|
705 iPlugin.ShowDetailsL(); |
|
706 } |
|
707 |
|
708 TRACE_EXIT_POINT; |
|
709 } |
|
710 |
386 //EOF |
711 //EOF |
387 |
712 |
388 |
713 |