qtinternetradio/ui/src/iropenwebaddressview.cpp
branchGCC_SURGE
changeset 13 c9471d26c7f2
parent 12 608f67c22514
child 14 896e9dbc5f19
equal deleted inserted replaced
9:bfc95e24a059 13:c9471d26c7f2
    32 #include "irqnetworkcontroller.h"
    32 #include "irqnetworkcontroller.h"
    33 #include "irqutility.h"
    33 #include "irqutility.h"
    34 #include "irqenums.h"
    34 #include "irqenums.h"
    35 #include "iruidefines.h"
    35 #include "iruidefines.h"
    36 #include "irqsettings.h"
    36 #include "irqsettings.h"
       
    37 static const int MAX_URL_CHARACTOR_NUMBER = 255;
    37 
    38 
    38 IROpenWebAddressView::IROpenWebAddressView(IRApplication* aApplication, TIRViewId aViewId) :
    39 IROpenWebAddressView::IROpenWebAddressView(IRApplication* aApplication, TIRViewId aViewId) :
    39     IRBaseView(aApplication, aViewId),
    40     IRBaseView(aApplication, aViewId),
    40     iForm(NULL),
    41     iForm(NULL),
    41     iModel(NULL),
    42     iModel(NULL),
    89     iPlayButton = qobject_cast<HbPushButton *>(iLoader.findObject(OPEN_WEB_ADDRESS_VIEW_OBJECT_PLAY_BUTTON));
    90     iPlayButton = qobject_cast<HbPushButton *>(iLoader.findObject(OPEN_WEB_ADDRESS_VIEW_OBJECT_PLAY_BUTTON));
    90     connect(iPlayButton, SIGNAL(released()), this, SLOT(play()));
    91     connect(iPlayButton, SIGNAL(released()), this, SLOT(play()));
    91     HbStyleLoader::registerFilePath(OPEN_WEB_ADDRESS_VIEW_PUSH_BUTTON_CSS);
    92     HbStyleLoader::registerFilePath(OPEN_WEB_ADDRESS_VIEW_PUSH_BUTTON_CSS);
    92     HbStyleLoader::registerFilePath(OPEN_WEB_ADDRESS_VIEW_PUSH_BUTTON_WIDGETML);
    93     HbStyleLoader::registerFilePath(OPEN_WEB_ADDRESS_VIEW_PUSH_BUTTON_WIDGETML);
    93 
    94 
    94     // This view need not to be stacked.
       
    95     setFlag(EViewFlag_UnStackable);
       
    96 
       
    97     connect(iNetworkController, SIGNAL(networkRequestNotified(IRQNetworkEvent)),
    95     connect(iNetworkController, SIGNAL(networkRequestNotified(IRQNetworkEvent)),
    98     this, SLOT(networkRequestNotified(IRQNetworkEvent)));
    96     this, SLOT(networkRequestNotified(IRQNetworkEvent)));
    99 
    97 
   100     // TODO: te be deleted if there's no difference between the landscape and portrait.
    98     // TODO: te be deleted if there's no difference between the landscape and portrait.
   101 //    handleOrientationChanged(getViewManager()->orientation());
    99 //    handleOrientationChanged(getViewManager()->orientation());
   102 }
   100 }
   103 
   101 
   104 IROpenWebAddressView::~IROpenWebAddressView()
   102 IROpenWebAddressView::~IROpenWebAddressView()
   105 {
   103 {
   106     iSettings->setManuallyInputtedStationUrl(iUrl->contentWidgetData(QString("text")).toString());
   104     if (iSettings)
   107     iSettings->setManuallyInputtedStationName(iName->contentWidgetData(QString("text")).toString());    
   105     {
   108     iSettings->closeInstance();
   106         iSettings->setManuallyInputtedStationUrl(iUrl->contentWidgetData(QString("text")).toString());
       
   107         iSettings->setManuallyInputtedStationName(iName->contentWidgetData(QString("text")).toString());    
       
   108         iSettings->closeInstance();
       
   109     }
   109 }
   110 }
   110 
   111 
   111 /*
   112 /*
   112  * Description : from base class IRBaseView.
   113  * Description : from base class IRBaseView.
   113  *               handle view commands.
   114  *               handle view commands.
   164         iUrl->setContentWidgetData(QString("text"), stationUrl);
   165         iUrl->setContentWidgetData(QString("text"), stationUrl);
   165     }
   166     }
   166 
   167 
   167     if (0 == stationName.size())
   168     if (0 == stationName.size())
   168     {
   169     {
   169         iName->setContentWidgetData(QString("text"), hbTrId("txt_irad_info_unnamed"));
   170 #ifdef SUBTITLE_STR_BY_LOCID
       
   171         iName->setContentWidgetData(QString("text"), hbTrId("txt_irad_info_unnamed_station"));
       
   172 #else
       
   173         iName->setContentWidgetData(QString("text"), hbTrId("Unnamed station"));        
       
   174 #endif
   170     }
   175     }
   171     else
   176     else
   172     {
   177     {
   173         iName->setContentWidgetData(QString("text"), stationName);
   178         iName->setContentWidgetData(QString("text"), stationName);
   174     }
   179     }
   186     }
   191     }
   187 
   192 
   188     temp = iName->contentWidgetData(QString("text")).toString();
   193     temp = iName->contentWidgetData(QString("text")).toString();
   189     if (0 == temp.size())
   194     if (0 == temp.size())
   190     {
   195     {
   191         iName->setContentWidgetData(QString("text"), hbTrId("txt_irad_info_unnamed"));
   196 #ifdef SUBTITLE_STR_BY_LOCID
       
   197         iName->setContentWidgetData(QString("text"), hbTrId("txt_irad_info_unnamed_station"));
       
   198 #else
       
   199         iName->setContentWidgetData(QString("text"), hbTrId("Unnamed station"));        
       
   200 #endif
   192     }
   201     }
   193 }
   202 }
   194 
   203 
   195 /*
   204 /*
   196  * Description : initialize the details.
   205  * Description : initialize the details.
   197  */
   206  */
   198 void IROpenWebAddressView::initDataForm()
   207 void IROpenWebAddressView::initDataForm()
   199 {
   208 {
   200     iUrl = new HbDataFormModelItem(
   209 #ifdef SUBTITLE_STR_BY_LOCID
   201             HbDataFormModelItem::TextItem, hbTrId("txt_irad_formlabel_station_url"));
   210     iUrl = new HbDataFormModelItem(HbDataFormModelItem::TextItem, hbTrId("txt_irad_formlabel_station_address"));
       
   211 #else
       
   212     iUrl = new HbDataFormModelItem(HbDataFormModelItem::TextItem, hbTrId("Station address"));
       
   213 #endif     
       
   214     iUrl->setContentWidgetData("maxLength",MAX_URL_CHARACTOR_NUMBER);
   202     iModel->appendDataFormItem(iUrl);
   215     iModel->appendDataFormItem(iUrl);
   203 
   216 
       
   217 #ifdef SUBTITLE_STR_BY_LOCID
   204     iName = new HbDataFormModelItem(
   218     iName = new HbDataFormModelItem(
   205             HbDataFormModelItem::TextItem, hbTrId("txt_irad_formlabel_station_name"));
   219             HbDataFormModelItem::TextItem, hbTrId("txt_irad_formlabel_station_name"));
       
   220 #else
       
   221     iName = new HbDataFormModelItem(
       
   222             HbDataFormModelItem::TextItem, hbTrId("Station name"));    
       
   223 #endif
       
   224     iName->setContentWidgetData("maxLength", MAX_URL_CHARACTOR_NUMBER);
   206     iModel->appendDataFormItem(iName);
   225     iModel->appendDataFormItem(iName);
   207 
   226 
   208     iForm->addConnection(iUrl, SIGNAL(textChanged(const QString&)),
   227     iForm->addConnection(iUrl, SIGNAL(textChanged(const QString&)),
   209     this, SLOT(urlEditorTextChanged(const QString&)));
   228     this, SLOT(urlEditorTextChanged(const QString&)));
   210 }
   229 }
   221     {
   240     {
   222         return;
   241         return;
   223     }
   242     }
   224 
   243 
   225     setUseNetworkReason(EIR_UseNetwork_OpenWebAddress);
   244     setUseNetworkReason(EIR_UseNetwork_OpenWebAddress);
   226 
   245 #ifdef HS_WIDGET_ENABLED	
       
   246     iPlayController->setConnectingStationName(preset.name);
       
   247 #endif
   227     // Verify the connectivity
   248     // Verify the connectivity
   228     if (false == iApplication->verifyNetworkConnectivity())
   249     if (false == iApplication->verifyNetworkConnectivity())
   229     {
   250     {
   230         return;
   251         return;
   231     }
   252     }
   247     }
   268     }
   248     
   269     
   249     switch (aEvent)
   270     switch (aEvent)
   250     {
   271     {
   251     case EIRQNetworkConnectionEstablished:
   272     case EIRQNetworkConnectionEstablished:
   252         iApplication->closeConnectingDialog();
       
   253 
       
   254         if (EIR_UseNetwork_OpenWebAddress == getUseNetworkReason())
   273         if (EIR_UseNetwork_OpenWebAddress == getUseNetworkReason())
   255         {
   274         {
   256             play();
   275             play();
   257         }
   276         }
   258 
       
   259         setUseNetworkReason(EIR_UseNetwork_NoReason);
       
   260         break;
   277         break;
   261         
   278         
   262     default:
   279     default:
   263         break;
   280         break;
   264     }
   281     }
       
   282     
       
   283     setUseNetworkReason(EIR_UseNetwork_NoReason);
   265 }
   284 }
   266 
   285 
   267 /*
   286 /*
   268  * Description : initialize a preset.
   287  * Description : initialize a preset.
   269  * return parameter: true, initialization succeeds; vice versa.
   288  * return parameter: true, initialization succeeds; vice versa.
   276     server.url.remove(" ");
   295     server.url.remove(" ");
   277 
   296 
   278     // check the URL
   297     // check the URL
   279     if (!IRQUtility::isValidUrl(server.url))
   298     if (!IRQUtility::isValidUrl(server.url))
   280     {
   299     {
   281         popupNote(hbTrId("txt_irad_info_invalid_link_please_change_it"), HbMessageBox::MessageTypeInformation);
   300 #ifdef SUBTITLE_STR_BY_LOCID
       
   301         popupNote(hbTrId("txt_irad_info_invalid_station_address"), HbMessageBox::MessageTypeInformation);
       
   302 #else
       
   303         popupNote(hbTrId("Invalid station address"), HbMessageBox::MessageTypeInformation);        
       
   304 #endif
   282         return false;
   305         return false;
   283     }
   306     }
   284 
   307 
   285     // Give it an initial value, supposed to be 32 kbps.
   308     // Give it an initial value, supposed to be 32 kbps.
   286     server.bitrate = 32;
   309     server.bitrate = 32;
   287     server.serverName = iName->contentWidgetData(QString("text")).toString();
   310     server.serverName = iName->contentWidgetData(QString("text")).toString();
   288     if (0 == server.serverName.size())
   311     if (0 == server.serverName.size())
   289     {
   312     {
   290         server.serverName = hbTrId("txt_irad_info_unnamed");
   313 #ifdef SUBTITLE_STR_BY_LOCID
       
   314         server.serverName = hbTrId("txt_irad_info_unnamed_station");
       
   315 #else
       
   316         server.serverName = hbTrId("Unnamed station");        
       
   317 #endif
   291     }
   318     }
   292 
   319 
   293     aPreset.insertChannelServer(server);
   320     aPreset.insertChannelServer(server);
   294     aPreset.name = server.serverName;
   321     aPreset.name = server.serverName;
   295     aPreset.description = hbTrId("txt_irad_info_added_station_description");
   322     aPreset.description = hbTrId("txt_irad_info_added_station_description");
   339 bool IROpenWebAddressView::eventFilter(QObject *object, QEvent *event)
   366 bool IROpenWebAddressView::eventFilter(QObject *object, QEvent *event)
   340 {
   367 {
   341     if( object == iNameEditorPtr
   368     if( object == iNameEditorPtr
   342         && event->type() == QEvent::FocusIn )
   369         && event->type() == QEvent::FocusIn )
   343     {
   370     {
   344         if(hbTrId("txt_irad_info_unnamed") == iName->contentWidgetData(QString("text")).toString())
   371 #ifdef SUBTITLE_STR_BY_LOCID
       
   372         if(hbTrId("txt_irad_info_unnamed_station") == iName->contentWidgetData(QString("text")).toString())
       
   373 #else
       
   374         if(hbTrId("Unnamed station") == iName->contentWidgetData(QString("text")).toString())            
       
   375 #endif
   345         {
   376         {
   346             iName->setContentWidgetData(QString("text"), QString(""));
   377             iName->setContentWidgetData(QString("text"), QString(""));
   347         }
   378         }
   348     }
   379     }
   349     return false;
   380     return false;