qtinternetradio/ui/src/iropenwebaddressview.cpp
changeset 15 065198191975
parent 14 896e9dbc5f19
child 17 38bbf2dcd608
equal deleted inserted replaced
14:896e9dbc5f19 15:065198191975
    23 #include <hblineedit.h>
    23 #include <hblineedit.h>
    24 #include <hbstyleloader.h>
    24 #include <hbstyleloader.h>
    25 #include <hbaction.h>
    25 #include <hbaction.h>
    26 #include <qinputcontext.h>
    26 #include <qinputcontext.h>
    27 #include <qapplication.h>
    27 #include <qapplication.h>
       
    28 #include <hbtapgesture.h>
       
    29 #include <hbinputvkbhostbridge.h>
    28 
    30 
    29 #include "irviewmanager.h"
    31 #include "irviewmanager.h"
    30 #include "irapplication.h"
    32 #include "irapplication.h"
    31 #include "irplaycontroller.h"
    33 #include "irplaycontroller.h"
    32 #include "iropenwebaddressview.h"
    34 #include "iropenwebaddressview.h"
    47     iUrl(NULL),
    49     iUrl(NULL),
    48     iName(NULL),
    50     iName(NULL),
    49     iNameEditorPtr(NULL),
    51     iNameEditorPtr(NULL),
    50     iPlayButton(NULL)
    52     iPlayButton(NULL)
    51 {
    53 {
    52     //this view won't be starting view, don't need lazy init
       
    53     IRBaseView::lazyInit();
       
    54     setInitCompleted(true);
       
    55     
       
    56     // Listen to the orientation change event
    54     // Listen to the orientation change event
    57     connect( getViewManager(), SIGNAL( orientationChanged(Qt::Orientation) ),
    55     connect( getViewManager(), SIGNAL( orientationChanged(Qt::Orientation) ),
    58              this, SLOT( handleOrientationChanged(Qt::Orientation) ) );
    56              this, SLOT( handleOrientationChanged(Qt::Orientation) ) );
    59     
    57     
    60     // Create widget hierarchy
    58     // Create widget hierarchy
    73     iForm = qobject_cast<HbDataForm *> (iLoader.findObject(OPEN_WEB_ADDRESS_VIEW_OBJECT_DATA_FORM));
    71     iForm = qobject_cast<HbDataForm *> (iLoader.findObject(OPEN_WEB_ADDRESS_VIEW_OBJECT_DATA_FORM));
    74     iModel = new HbDataFormModel();
    72     iModel = new HbDataFormModel();
    75     initDataForm();
    73     initDataForm();
    76     initDetails();
    74     initDetails();
    77     iForm->setModel(iModel);
    75     iForm->setModel(iModel);
       
    76     iForm->installEventFilter(this);
    78     initMenu();
    77     initMenu();
    79 
    78 
    80     // get a new instance different from the base class. Because it's used in destructor and 
    79     // get a new instance different from the base class. Because it's used in destructor and 
    81     // the viewmanager is destructed after application, the base class iSettings is NULL before
    80     // the viewmanager is destructed after application, the base class iSettings is NULL before
    82     // destruct this class.
    81     // destruct this class.
    94     QModelIndex indexUrl = iModel->indexFromItem(iUrl);
    93     QModelIndex indexUrl = iModel->indexFromItem(iUrl);
    95     HbAbstractViewItem* viewItemUrl = iForm->itemByIndex(indexUrl);
    94     HbAbstractViewItem* viewItemUrl = iForm->itemByIndex(indexUrl);
    96     HbDataFormViewItem* dataformviewitemUrl = static_cast<HbDataFormViewItem *>(viewItemUrl);
    95     HbDataFormViewItem* dataformviewitemUrl = static_cast<HbDataFormViewItem *>(viewItemUrl);
    97     HbWidget *widgetUrl = dataformviewitemUrl->dataItemContentWidget();
    96     HbWidget *widgetUrl = dataformviewitemUrl->dataItemContentWidget();
    98     iUrlEditorPtr = static_cast<HbLineEdit *>(widgetUrl);
    97     iUrlEditorPtr = static_cast<HbLineEdit *>(widgetUrl);
    99     iUrlEditorPtr->installEventFilter(this);
       
   100     
    98     
   101     // Find the play button objects
    99     // Find the play button objects
   102     iPlayButton = qobject_cast<HbPushButton *>(iLoader.findObject(OPEN_WEB_ADDRESS_VIEW_OBJECT_PLAY_BUTTON));
   100     iPlayButton = qobject_cast<HbPushButton *>(iLoader.findObject(OPEN_WEB_ADDRESS_VIEW_OBJECT_PLAY_BUTTON));
   103     connect(iPlayButton, SIGNAL(released()), this, SLOT(play()));
   101     connect(iPlayButton, SIGNAL(released()), this, SLOT(play()));
   104     HbStyleLoader::registerFilePath(OPEN_WEB_ADDRESS_VIEW_PUSH_BUTTON_CSS);
   102     HbStyleLoader::registerFilePath(OPEN_WEB_ADDRESS_VIEW_PUSH_BUTTON_CSS);
   107     connect(iNetworkController, SIGNAL(networkRequestNotified(IRQNetworkEvent)),
   105     connect(iNetworkController, SIGNAL(networkRequestNotified(IRQNetworkEvent)),
   108     this, SLOT(networkRequestNotified(IRQNetworkEvent)));
   106     this, SLOT(networkRequestNotified(IRQNetworkEvent)));
   109 
   107 
   110     // TODO: te be deleted if there's no difference between the landscape and portrait.
   108     // TODO: te be deleted if there's no difference between the landscape and portrait.
   111 //    handleOrientationChanged(getViewManager()->orientation());
   109 //    handleOrientationChanged(getViewManager()->orientation());
       
   110  
       
   111     grabGesture(Qt::TapGesture); 
   112 }
   112 }
   113 
   113 
   114 IROpenWebAddressView::~IROpenWebAddressView()
   114 IROpenWebAddressView::~IROpenWebAddressView()
   115 {
   115 {
   116     if (iSettings)
   116     if (iSettings)
   401 #endif
   401 #endif
   402         {
   402         {
   403             iName->setContentWidgetData(QString("text"), QString(""));
   403             iName->setContentWidgetData(QString("text"), QString(""));
   404         }
   404         }
   405     }
   405     }
   406     else if( (object == iUrlEditorPtr || object == iNameEditorPtr)
   406     else if( object == iForm && 
   407         && event->type() == QEvent::FocusOut )
   407              event->type() == QEvent::GestureOverride)
   408     {
   408     {
   409         hideVkb();
   409         QGestureEvent *e = static_cast<QGestureEvent *>(event);
       
   410         gestureEvent(e);
   410     }
   411     }
   411     
   412     
   412     return false;
   413     return false;
   413 }
   414 }
   414 void IROpenWebAddressView::hideVkb()
   415 void IROpenWebAddressView::hideVkb()
   419         QEvent *event = new QEvent(QEvent::CloseSoftwareInputPanel);
   420         QEvent *event = new QEvent(QEvent::CloseSoftwareInputPanel);
   420         ic->filterEvent(event);
   421         ic->filterEvent(event);
   421         delete event;
   422         delete event;
   422     }
   423     }
   423 }
   424 }
       
   425 
       
   426 void IROpenWebAddressView::gestureEvent(QGestureEvent *aEvent)
       
   427 {
       
   428     HbTapGesture *tapGesture = qobject_cast<HbTapGesture *>(aEvent->gesture(Qt::TapGesture));
       
   429     if (!tapGesture)
       
   430     {
       
   431         return;
       
   432     }
       
   433     
       
   434     if (Qt::GestureStarted == tapGesture->state())
       
   435     {
       
   436         QPointF tapScenePoint = tapGesture->scenePosition();
       
   437         QPointF tapLocalPointUrl = iUrlEditorPtr->sceneTransform().inverted().map(tapScenePoint);
       
   438         QPointF tapLocalPointName = iNameEditorPtr->sceneTransform().inverted().map(tapScenePoint);
       
   439 
       
   440         if (!iUrlEditorPtr->contains(tapLocalPointUrl) && 
       
   441             !iNameEditorPtr->contains(tapLocalPointName) &&
       
   442             HbVkbHost::HbVkbStatusOpened == HbVkbHostBridge::instance()->keypadStatus())
       
   443         {
       
   444             hideVkb();
       
   445         }
       
   446     }
       
   447 }