--- a/calendarui/regionalplugins/lunarchinese/src/CalenLunarChinesePlugin.cpp Mon May 03 12:30:32 2010 +0300
+++ b/calendarui/regionalplugins/lunarchinese/src/CalenLunarChinesePlugin.cpp Mon Jun 28 15:22:02 2010 +0530
@@ -16,18 +16,18 @@
*/
-#include <eikenv.h>
-#include <StringLoader.h>
-#include <data_caging_path_literals.hrh>
-#include <bautils.h>
-#include <CalenLunarChinesePluginData.rsg>
-
#include <QString>
+#include <QStringList>
#include <HbAction>
#include <HbView>
#include <HbMenu>
#include <HbMessageBox>
#include <HbLabel>
+#include <HbTranslator>
+
+#include <eikenv.h>
+#include <data_caging_path_literals.hrh>
+#include <bautils.h>
#include "calendarui_debug.h"
#include "CalenLunarChinesePlugin.h"
@@ -39,10 +39,8 @@
#include "hb_calencommands.hrh"
//CONSTANTS
-_LIT( KFieldSeparator, "\n" );
-_LIT( KHeaderSeparator, "\n ");
-_LIT( KResourceChinesePluginFile, "calenlunarchineseplugindata.rsc" );
-#define KResourcePath KDC_RESOURCE_FILES_DIR
+static const QString fieldSeparator("\n");
+static const QString headerSeparator("\n ");
const TInt KFieldCount = 5;
@@ -57,8 +55,7 @@
:iLocalizer(NULL),
iLocInfo(NULL),
iServices(aServices),
- iInfoBarText(NULL),
- iResourceFileOffset( NULL )
+ iInfoBarText(NULL)
{
TRACE_ENTRY_POINT;
@@ -104,13 +101,17 @@
}
delete iInfoProvider;
+ iInfoProvider = NULL;
delete iLocalizer;
+ iLocalizer = NULL;
delete iLocInfo;
+ iLocInfo = NULL;
- if( iResourceFileOffset )
- {
- CCoeEnv::Static()->DeleteResourceFile( iResourceFileOffset );
- }
+ // Remove the translator for plugin
+ if (iTranslator) {
+ delete iTranslator;
+ iTranslator = 0;
+ }
TRACE_EXIT_POINT;
}
@@ -121,29 +122,18 @@
void CCalenLunarChinesePlugin::ConstructL()
{
TRACE_ENTRY_POINT;
-
- TFileName dllName;
- // Get the complate path of the DLL from where it is currently loaded
- Dll::FileName( dllName );
-
- TFileName resourceFilename;
- resourceFilename.Append(dllName.Mid(0,2));
- resourceFilename.Append(KResourcePath);
- resourceFilename.Append(KResourceChinesePluginFile);
- BaflUtils::NearestLanguageFile( CEikonEnv::Static()->FsSession(),
- resourceFilename );
- // Add the resource file.
- iResourceFileOffset = CEikonEnv::Static()->AddResourceFileL(
- resourceFilename );
-
iServices->RegisterForNotificationsL( this, ECalenNotifyContextChanged );
iServices->GetCommandRange( iStart, iEnd );
+ // Install the translator before the CCalenLunarLocalizer is constructed
+ iTranslator = new HbTranslator("calenregional");
+
iLocalizer = CCalenLunarLocalizer::NewL();
iInfoProvider = CCalenLunarInfoProvider::NewL(
CEikonEnv::Static()->FsSession() );
+
TRACE_EXIT_POINT;
}
@@ -274,7 +264,7 @@
void CCalenLunarChinesePlugin::UpdateLocalizerInfoL()
{
TRACE_ENTRY_POINT;
- QDateTime focusDateTime= iServices->Context().focusDateAndTimeL();
+ QDateTime focusDateTime= iServices->Context().focusDateAndTime();
TDateTime tempDateTime(
focusDateTime.date().year(),
static_cast<TMonth>(focusDateTime.date().month() - 1),
@@ -312,87 +302,75 @@
// -----------------------------------------------------------------------------
//
void CCalenLunarChinesePlugin::ShowDetailsL( )
- {
- TRACE_ENTRY_POINT;
- HBufC* msgText = HBufC::NewLC( 1000 );
- if ( iLocInfo )
- {
- TInt headerIds[KFieldCount] = {
- R_CALENDAR_LUNAR_INFO_FESTIVAL,
- R_CALENDAR_LUNAR_INFO_SOLAR,
- R_CALENDAR_LUNAR_INFO_DATE,
- R_CALENDAR_LUNAR_INFO_ANIMAL_YEAR,
- R_CALENDAR_LUNAR_INFO_WESTERN_DATE
- };
-
- RPointerArray<HBufC> headersArray;
-
- for ( TInt i=0; i < KFieldCount; i++)
- {
- headersArray.Append( StringLoader::LoadL( headerIds[i] ) );
- }
-
- CPtrCArray* fieldsArray = new (ELeave) CPtrCArray(5);
- CleanupStack::PushL( fieldsArray );
- fieldsArray->AppendL( iLocInfo->Festival() );
- fieldsArray->AppendL( iLocInfo->SolarTerm() );
- fieldsArray->AppendL( iLocInfo->FullLunarDate() );
- fieldsArray->AppendL( iLocInfo->AnimalYear() );
- fieldsArray->AppendL( iLocInfo->GregorianDate() );
-
- for (TInt i=0; i < KFieldCount; i++)
- {
- TPtrC fieldPtrC = fieldsArray->At(i);
- if ( fieldPtrC != KNullDesC )
- {
- msgText->Des().Append( *(headersArray[i]) );
- msgText->Des().Append( KHeaderSeparator );
- msgText->Des().Append( fieldPtrC );
- if ( i < KFieldCount - 1 ) // not last
- {
- msgText->Des().Append( KFieldSeparator );
- }
- }
- }
- CleanupStack::PopAndDestroy( fieldsArray );
- headersArray.ResetAndDestroy();
- }
-
-
- ExecuteMessageDialogL(*msgText);
-
- CleanupStack::PopAndDestroy( msgText );
-
- TRACE_EXIT_POINT;
- }
+{
+ QString msgText;
+ if(iLocInfo) {
+ QStringList headerIds;
+ headerIds.append(hbTrId("txt_calendar_info_festival"));
+ headerIds.append(hbTrId("txt_calendar_solar_term"));
+ headerIds.append(hbTrId("txt_calendar_lunar_date"));
+ headerIds.append(hbTrId("txt_calendar_animal_year"));
+ headerIds.append(hbTrId("txt_calendar_gregorian_date"));
+
+ QStringList fieldInfo;
+ QString data;
+
+ data = QString::fromUtf16(iLocInfo->Festival().Ptr(),iLocInfo->Festival().Length());
+ fieldInfo.append(data);
+ data = QString::fromUtf16(iLocInfo->SolarTerm().Ptr(),iLocInfo->SolarTerm().Length());
+ fieldInfo.append(data);
+ data = QString::fromUtf16(iLocInfo->FullLunarDate().Ptr(),iLocInfo->FullLunarDate().Length());
+ fieldInfo.append(data);
+ data = QString::fromUtf16(iLocInfo->AnimalYear().Ptr(),iLocInfo->AnimalYear().Length());
+ fieldInfo.append(data);
+ data = QString::fromUtf16(iLocInfo->GregorianDate().Ptr(),iLocInfo->GregorianDate().Length());
+ fieldInfo.append(data);
+ // Append the data in the proper order
+ for (TInt i=0; i < KFieldCount; i++) {
+ if(!fieldInfo.at(i).isEmpty()) {
+ msgText.append(headerIds[i]);
+ msgText.append(headerSeparator);
+ msgText.append(fieldInfo[i]);
+ if ( i < KFieldCount - 1 ) {
+ // not last item
+ msgText.append(fieldSeparator);
+ }
+ }
+ }
+ }
+ ExecuteMessageDialogL(msgText);
+}
// -----------------------------------------------------------------------------
-// CCalenLunarChinesePlugin::ShowMessageDialogL
+// CCalenLunarChinesePlugin::ExecuteMessageDialogL
// -----------------------------------------------------------------------------
-//
-void CCalenLunarChinesePlugin::ExecuteMessageDialogL(TDesC& aMsgText)
+//
+void CCalenLunarChinesePlugin::ExecuteMessageDialogL(QString aMsgText)
{
TRACE_ENTRY_POINT;
- QString text = QString::fromUtf16(aMsgText.Ptr(),aMsgText.Length());
+ // Instantiate a popup
+ HbMessageBox *popup = new HbMessageBox();
+ popup->setDismissPolicy(HbDialog::NoDismiss);
+ popup->setTimeout(HbDialog::NoTimeout);
+ popup->setIconVisible(false);
+ popup->setAttribute( Qt::WA_DeleteOnClose, true );
- // Instantiate a popup
- HbMessageBox popup;
- popup.setDismissPolicy(HbDialog::NoDismiss);
- popup.setTimeout(HbDialog::NoTimeout);
- popup.setIconVisible(false);
+ popup->setHeadingWidget(new HbLabel(hbTrId("txt_calendar_title_lunar_calendar")));
+ popup->setText(aMsgText);
+
+ // Remove the default actions
+ QList<QAction*> list = popup->actions();
+ for(int i=0; i < list.count(); i++)
+ {
+ popup->removeAction(list[i]);
+ }
+ // Sets the primary action
+ popup->addAction(new HbAction(hbTrId("txt_calendar_button_close"), popup));
- popup.setHeadingWidget(new HbLabel("Lunar Calendar"));
- popup.setText(text);
-
- // Sets the primary action
- popup.setPrimaryAction(new HbAction(hbTrId("txt_calendar_button_cancel"),
- &popup));
-
- // Launch popup syncronously
- popup.exec();
+ // Launch popup
+ popup->open();
TRACE_EXIT_POINT;
}
-
//EOF