--- a/calendarui/regionalplugins/lunarVietnamese/src/calenlunarvietnameseplugin.cpp Tue Feb 02 10:12:19 2010 +0200
+++ b/calendarui/regionalplugins/lunarVietnamese/src/calenlunarvietnameseplugin.cpp Fri Apr 16 14:57:40 2010 +0300
@@ -15,32 +15,38 @@
*
*/
+#include <QtGui>
#include "calendarui_debug.h"
#include <eikenv.h>
-#include <AknUtils.h>
+#include <aknutils.h>
#include <eiklabel.h>
#include <avkon.hrh>
#include <StringLoader.h>
-#include <aknsettingitemlist.h>
-#include <aknmessagequerydialog.h>
#include <data_caging_path_literals.hrh>
#include <bautils.h>
-#include <AknBidiTextUtils.h>
+#include <aknbiditextutils.h>
#include <CalenLunarVietnamesePluginData.rsg>
#include <layoutmetadata.cdl.h>
-#include <mcalenpreview.h>
+#include <hblabel.h>
+#include <hbwidget.h>
+#include <qstring.h>
+#include <hbaction.h>
+#include <hbtextedit.h>
+#include <hbmainwindow.h>
+#include <hbview.h>
+#include <hbmenu.h>
#include "calendarui_debug.h"
-#include "calenlunarvietnameseplugin.h"
-#include "calenlunarvietnameselocalizer.h"
-#include "calenlunarpanic.h"
-#include "calenlunarlocalizedinfo.h"
-#include "calenlunarlocalizer.h"
-#include "calenlunarinfoprovider.h"
+#include "CalenLunarVietnamesePlugin.h"
+#include "CalenLunarVietnameseLocalizer.h"
+#include "CalenLunarPanic.h"
+#include "CalenLunarLocalizedInfo.h"
+#include "CalenLunarLocalizer.h"
+#include "CalenLunarInfoProvider.h"
-#include "calencommands.hrh"
+#include "hb_calencommands.hrh"
//CONSTANTS
_LIT( KFieldSeparator, "\n" );
@@ -145,87 +151,25 @@
iServices->GetCommandRange( iStart, iEnd );
iInfoProvider = CCalenLunarInfoProvider::NewL(CEikonEnv::Static()->FsSession());
-
- iLabelControl = CCalenPluginLabel::NewL(*this);
-
+
iLocalizer = CCalenLunarVietnameseLocalizer::NewL();
+ iLabelControl = new CalenPluginLabel(*this);
TRACE_EXIT_POINT;
}
-
-// -----------------------------------------------------------------------------
-// CCalenLunarVietnamesePlugin::SetLabelContentExtraL
-// -----------------------------------------------------------------------------
-//
-void CCalenLunarVietnamesePlugin::SetLabelContentExtraL( CEikLabel& aLabel ,TRect& aRect)
- {
- TRACE_ENTRY_POINT;
-
- TRect nullRect;
- aLabel.SetRect(nullRect);
-
- FormatExtraRowStringL( aLabel, ETrue );
-
- CArrayFixFlat<TPtrC>* textLines = new(ELeave)CArrayFixFlat<TPtrC>( 2 );
- CleanupStack::PushL( textLines );
-
- CArrayFixFlat<TInt>* lineWidths = new( ELeave )CArrayFixFlat<TInt>( 1 );
- CleanupStack::PushL( lineWidths );
-
- TInt maxWidth = aRect.Size().iWidth;
- lineWidths->AppendL( maxWidth );
-
- const CFont* fontLabel = AknLayoutUtils::FontFromId(EAknLogicalFontPrimarySmallFont,NULL);
-
- HBufC* visualText = AknBidiTextUtils::ConvertToVisualAndWrapToArrayWholeTextL(
- iExtraRowText,
- *lineWidths,
- *fontLabel,
- *textLines);
-
- if(textLines->Count() < 3 && textLines->Count() > 0)
- {
- TInt nH = textLines->Count();
- aRect.iBr.iY = aRect.iBr.iY * nH;
- }
-
- HBufC* newLinedText = HBufC::NewLC( iExtraRowText.Length() + 4);
-
- for(TInt i = 0 ; i < textLines->Count();i++)
- {
- newLinedText->Des().Append(textLines->At(i));
- newLinedText->Des().Append( KFieldSeparator );
- }
-
- aLabel.UseLogicalToVisualConversion(ETrue);
- aLabel.SetLabelAlignment(ELayoutAlignCenter);
- aLabel.SetTextL( *newLinedText);
-
- CleanupStack::PopAndDestroy( newLinedText );
- CleanupStack::PopAndDestroy( lineWidths );
- CleanupStack::PopAndDestroy( textLines );
- delete visualText;
-
- TRACE_EXIT_POINT;
- }
-
// -----------------------------------------------------------------------------
// CCalenLunarVietnamesePlugin::SetLabelContentL
// -----------------------------------------------------------------------------
//
-void CCalenLunarVietnamesePlugin::SetLabelContentL( CEikLabel& aLabel,
- const TRect& /*aRect*/ )
+void CCalenLunarVietnamesePlugin::SetLabelContentL( HbLabel& aLabel )
{
TRACE_ENTRY_POINT;
- TRect nullRect;
- aLabel.SetRect(nullRect);
- FormatExtraRowStringL( aLabel, EFalse );
- aLabel.UseLogicalToVisualConversion(ETrue);
- aLabel.SetLabelAlignment(ELayoutAlignCenter);
- aLabel.SetTextL( iExtraRowText );
+ FormatExtraRowStringL( aLabel, EFalse );
+ QString text = QString::fromUtf16(iExtraRowText.Ptr(),iExtraRowText.Length());
+ aLabel.setPlainText(text);
TRACE_EXIT_POINT;
}
@@ -235,11 +179,11 @@
// CCalenLunarVietnamesePlugin::FormatExtraRowStringL
// -----------------------------------------------------------------------------
//
-void CCalenLunarVietnamesePlugin::FormatExtraRowStringL( CEikLabel& aLabel,
- TBool aTwoLines)
+void CCalenLunarVietnamesePlugin::FormatExtraRowStringL(HbLabel& aLabel,TBool aTwoLines)
{
TRACE_ENTRY_POINT;
+ Q_UNUSED(aLabel);
const CFont* labelFont = NULL;
if( aTwoLines )
@@ -251,8 +195,16 @@
labelFont = AknLayoutUtils::FontFromId(EAknLogicalFontSecondaryFont,NULL);
}
- aLabel.SetFont( labelFont );
- TInt maxWidth = iRect.Size().iWidth;
+ //aLabel.SetFont( labelFont );
+ TInt maxWidth = 0;
+ if(iRect.IsEmpty())
+ {
+ maxWidth = 450; //For hitch we take max value
+ }
+ else
+ {
+ maxWidth = iRect.Size().iWidth;
+ }
if ( labelFont && iLocInfo )
{
@@ -274,24 +226,14 @@
// CCalenLunarVietnamesePlugin::InfobarL
// -----------------------------------------------------------------------------
//
-CCoeControl* CCalenLunarVietnamesePlugin::InfobarL( const TRect& aRect )
+HbWidget* CCalenLunarVietnamesePlugin::InfobarL( )
{
TRACE_ENTRY_POINT;
UpdateLocalizerInfoL();
- iRect = aRect;
-
- if(iLabelControl)
- {
- delete iLabelControl;
- iLabelControl = NULL;
- }
-
- iLabelControl = CCalenPluginLabel::NewL(*this);
- SetLabelContentL(*iLabelControl,aRect);
- iLabelControl->SetRect(aRect);
-
+ SetLabelContentL(*iLabelControl);
+
return iLabelControl;
TRACE_EXIT_POINT;
@@ -302,7 +244,7 @@
// This function is called in case of Hitchcock views
// ----------------------------------------------------------------------------
//
-const TDesC& CCalenLunarVietnamesePlugin::InfobarL( )
+QString* CCalenLunarVietnamesePlugin::InfobarTextL( )
{
TRACE_ENTRY_POINT;
TRect nullRect(0,0,0,0);
@@ -315,89 +257,31 @@
//Update the local information based on current context
//from framework.
UpdateLocalizerInfoL();
-
- //Dummy label for formatting the iExtraRowText
- CEikLabel* dummyLabel = new(ELeave) CEikLabel;
- CleanupStack::PushL(dummyLabel);
- SetLabelContentL(*dummyLabel,TRect());
- CleanupStack::PopAndDestroy();
-
+ SetLabelContentL(*iLabelControl);
iInfoBarText = iExtraRowText.AllocLC();
CleanupStack::Pop();
TRACE_EXIT_POINT;
- return *iInfoBarText;
+ return (new QString((QChar*)iInfoBarText->Des().Ptr(),iInfoBarText->Length()));
}
-// -----------------------------------------------------------------------------
-// CCalenLunarVietnamesePlugin::CustomPreviewPaneL
-// -----------------------------------------------------------------------------
+// ----------------------------------------------------------------------------
+// CCalenThaiPlugin::InfobarL
+// This function is called to add menuitem
+// ----------------------------------------------------------------------------
//
-MCalenPreview* CCalenLunarVietnamesePlugin::CustomPreviewPaneL( TRect& /*aRect*/ )
- {
- TRACE_ENTRY_POINT
- TRACE_EXIT_POINT
- return NULL;
- }
-
-// -----------------------------------------------------------------------------
-// CCalenLunarVietnamesePlugin::PreviewPaneL
-// -----------------------------------------------------------------------------
-//
-CCoeControl* CCalenLunarVietnamesePlugin::PreviewPaneL( TRect& aRect )
- {
- TRACE_ENTRY_POINT;
-
- UpdateLocalizerInfoL();
- iRect = aRect;
- if (iLabelControl)
- {
- delete iLabelControl;
- iLabelControl = NULL;
- }
- iLabelControl = CCalenPluginLabel::NewL(*this);
-
- if(!Layout_Meta_Data::IsLandscapeOrientation()) //Portriat
- {
- SetLabelContentL(*iLabelControl, aRect);
- }
- else
- {
- SetLabelContentExtraL(*iLabelControl,aRect);
- }
-
-
- return iLabelControl;
- TRACE_EXIT_POINT;
- }
+void CCalenLunarVietnamesePlugin::CustomiseMenu(HbMenu* aHbMenu)
+ {
+ HbAction* lunarAction = new HbAction("Show Lunar Data");
+ QList<QAction*> actionList = aHbMenu->actions();
+ TInt count = actionList.count() - 1;
+ if(count >= 0)
+ aHbMenu->insertAction(actionList[count], lunarAction);
+ QObject::connect(lunarAction, SIGNAL(triggered()), iLabelControl, SLOT(showLunarData()));
+ }
// -----------------------------------------------------------------------------
-// CCalenLunarVietnamesePlugin::CustomiseMenuPaneL
-// -----------------------------------------------------------------------------
-//
-TBool CCalenLunarVietnamesePlugin::CustomiseMenuPaneL( TInt /*aResourceId*/,
- CEikMenuPane* aMenuPane )
- {
- TRACE_ENTRY_POINT;
- HBufC* itemText = HBufC::NewLC(100);//= StringLoader::LoadLC(R_CALENDAR_SHOW_LUNAR_DATA);
- itemText->Des().Append(_L("Viet No Settings"));
-
- CEikMenuPaneItem::SData menuItem;
- menuItem.iCommandId = iStart;
- menuItem.iCascadeId = 0;
- menuItem.iFlags = 0;
- menuItem.iText = *itemText;
- menuItem.iExtraText = KNullDesC;
-
- aMenuPane->InsertMenuItemL( menuItem, 1 );
-
- CleanupStack::PopAndDestroy(itemText);
- TRACE_EXIT_POINT;
- return ETrue;
- }
-
-// -----------------------------------------------------------------------------
// CCalenLunarVietnamesePlugin::HandleCommandL
// -----------------------------------------------------------------------------
//
@@ -444,55 +328,6 @@
return commandHandler;
TRACE_EXIT_POINT;
}
-
-// -----------------------------------------------------------------------------
-// CCalenLunarVietnamesePlugin::RemoveViewsFromCycle
-// -----------------------------------------------------------------------------
-//
-void CCalenLunarVietnamesePlugin::RemoveViewsFromCycle( RArray<TInt>& /*aViews*/ )
- {
- TRACE_ENTRY_POINT;
- TRACE_EXIT_POINT;
- }
-
-// -----------------------------------------------------------------------------
-// CCalenLunarVietnamesePlugin::CanBeEnabledDisabled
-// -----------------------------------------------------------------------------
-//
-TBool CCalenLunarVietnamesePlugin::CanBeEnabledDisabled()
- {
- TRACE_ENTRY_POINT;
- TRACE_EXIT_POINT;
- return ETrue;
- }
-
-TAny* CCalenLunarVietnamesePlugin::CalenCustomisationExtensionL( TUid /*aExtensionUid*/ )
- {
- TRACE_ENTRY_POINT;
- TRACE_EXIT_POINT;
- return NULL;
- }
-// -----------------------------------------------------------------------------
-// CCalenLunarVietnamesePlugin::GetCustomSettingsL
-// -----------------------------------------------------------------------------
-//
-void CCalenLunarVietnamesePlugin::GetCustomSettingsL( RPointerArray<CAknSettingItem>&
- /*aCustomSettingArray*/)
- {
- TRACE_ENTRY_POINT;
- TRACE_EXIT_POINT;
- }
-
-// -----------------------------------------------------------------------------
-// CCalenLunarVietnamesePlugin::GetCustomViewsL
-// -----------------------------------------------------------------------------
-//
-void CCalenLunarVietnamesePlugin::GetCustomViewsL( RPointerArray<CCalenView>&
- /*aCustomViewArray*/ )
- {
- TRACE_ENTRY_POINT;
- TRACE_EXIT_POINT;
- }
// -----------------------------------------------------------------------------
@@ -599,87 +434,86 @@
//
void CCalenLunarVietnamesePlugin::ExecuteMessageDialogL(TDesC& aMsgText)
{
- TRACE_ENTRY_POINT;
+ TRACE_ENTRY_POINT;
+ QString text = QString::fromUtf16(aMsgText.Ptr(),aMsgText.Length());
- CAknMessageQueryDialog* dlg = CAknMessageQueryDialog::NewL(aMsgText);
- CleanupStack::PushL(dlg);
- dlg->PrepareLC(R_CALEN_LUNAR_DETAILS_DIALOG);
- CleanupStack::Pop(dlg);
- dlg->RunLD();
+ // Instantiate a popup
+ HbPopup popup;
+
+ // Set dismiss policy that determines what tap events will cause the popup
+ // to be dismissed
+ popup.setDismissPolicy(HbPopup::NoDismiss);
+ popup.setTimeout(HbPopup::NoTimeout);
+
+ // Set the label as heading widget
+ popup.setHeadingWidget(new HbLabel("Lunar Calendar"));
+ HbTextEdit* contentWidget = new HbTextEdit (text);
+ contentWidget->setReadOnly(true);
+ contentWidget->setCursorHidden(true);
+ QSizeF size = contentWidget->maximumSize();
+ contentWidget->setMinimumSize(200,250);
+ popup.setContentWidget(contentWidget);
+
+ // Sets the primary action
+ popup.setPrimaryAction(new HbAction("Ok",&popup));
+
+ // Launch popup syncronously
+ popup.exec();
TRACE_EXIT_POINT;
}
-// -----------------------------------------------------------------------------
-// CCalenPluginLabel::NewL
-// -----------------------------------------------------------------------------
-//
-CCalenPluginLabel* CCalenPluginLabel::NewL(CCalenLunarVietnamesePlugin& aPlugin)
- {
+
+CalenPluginLabel::CalenPluginLabel(CCalenLunarVietnamesePlugin& aPlugin , QGraphicsItem* parent)
+ :HbLabel(parent),iPlugin(aPlugin)
+ {
TRACE_ENTRY_POINT;
- CCalenPluginLabel* self = new(ELeave)CCalenPluginLabel(aPlugin);
- CleanupStack::PushL(self);
- self->ConstructL();
- CleanupStack::Pop(self);
- TRACE_EXIT_POINT;
- return self;
- }
-// -----------------------------------------------------------------------------
-// CPluginLabel::CCalenLunarVietnamesePlugin
-// -----------------------------------------------------------------------------
-//
-CCalenPluginLabel::CCalenPluginLabel(CCalenLunarVietnamesePlugin& aPlugin) :
- iPlugin(aPlugin)
- {
+ setAlignment(Qt::AlignHCenter);
+ setTextColor(Qt::blue);
+ QFont font("Times", 9, QFont::Bold);
+ setFont(font);
+ setTextWrapping(Hb::TextWrapping);
+ setOpacity(12);
+
+ TRACE_EXIT_POINT;
+ }
+
+CalenPluginLabel::~CalenPluginLabel()
+ {
TRACE_ENTRY_POINT;
- TRACE_EXIT_POINT;
- }
-
-
-// -----------------------------------------------------------------------------
-// CPluginLabel::ConstructL
-// -----------------------------------------------------------------------------
-//
-void CCalenPluginLabel::ConstructL()
- {
- TRACE_ENTRY_POINT;
- SetContainerWindowL(*this);
+ TRACE_EXIT_POINT;
+ }
+
+void CalenPluginLabel::showLunarData()
+ {
+ TRACE_ENTRY_POINT;
+ iPlugin.ShowDetailsL();
TRACE_EXIT_POINT;
- }
-
-// -----------------------------------------------------------------------------
-// CCalenPluginLabel::~CCalenPluginLabel
-// -----------------------------------------------------------------------------
-//
-CCalenPluginLabel::~CCalenPluginLabel()
- {
- TRACE_ENTRY_POINT;
- TRACE_EXIT_POINT;
- }
-
-// -----------------------------------------------------------------------------
-// CCalenPluginLabel::Draw
-// -----------------------------------------------------------------------------
-//
-void CCalenPluginLabel::Draw( const TRect& aRect) const
- {
+ }
+void CalenPluginLabel::paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget )
+ {
TRACE_ENTRY_POINT;
- CEikLabel::Draw(aRect);
- TRACE_EXIT_POINT;
- }
-
-// -----------------------------------------------------------------------------
-// CCalenPluginLabel::HandlePointerEventL
-// -----------------------------------------------------------------------------
-//
-void CCalenPluginLabel::HandlePointerEventL(const TPointerEvent&
- /*aPointerEvent*/)
- {
+
+ HbLabel::paint(painter,option,widget);
+ QPen pen;//
+ pen.setStyle(Qt::SolidLine);
+ pen.setWidth(1);
+ pen.setBrush(Qt::gray);
+ painter->setPen(pen);
+ QRectF rect = this->rect();
+ painter->eraseRect(rect);
+ painter->drawRect(rect);
+ painter->fillRect(rect,Qt::gray);
+ TRACE_EXIT_POINT;
+ }
+
+void CalenPluginLabel::mousePressEvent(QGraphicsSceneMouseEvent* event)
+ {
TRACE_ENTRY_POINT;
+ Q_UNUSED(event);
iPlugin.ShowDetailsL();
- TRACE_EXIT_POINT;
- }
-
-
-//EOF
+ TRACE_EXIT_POINT;
+ }
+
+//EOF