qtinternetradio/ui/src/irhistoryview.cpp
changeset 12 608f67c22514
parent 11 f683e24efca3
child 14 896e9dbc5f19
equal deleted inserted replaced
11:f683e24efca3 12:608f67c22514
    57     
    57     
    58     iModel = new IRHistoryModel(this);
    58     iModel = new IRHistoryModel(this);
    59     iListView->setModel(iModel);
    59     iListView->setModel(iModel);
    60     iListView->setCurrentIndex(iModel->index(0));
    60     iListView->setCurrentIndex(iModel->index(0));
    61     
    61     
    62     iClearHistoryAction = new HbAction(hbTrId("txt_irad_menu_clear_list"), menu());
    62 #ifdef SUBTITLE_STR_BY_LOCID
    63 
    63     iClearHistoryAction = new HbAction(hbTrId("txt_irad_opt_clear_list"), menu());
       
    64 #else
       
    65     iClearHistoryAction = new HbAction(hbTrId("Clear list"), menu());    
       
    66 #endif
    64     
    67     
    65     iConvertTimer = new QTimer(this);
    68     iConvertTimer = new QTimer(this);
    66     iConvertTimer->setInterval(10);
    69     iConvertTimer->setInterval(10);
    67     
    70     
    68     connect(iClearHistoryAction, SIGNAL(triggered()), this, SLOT(clearAllList()));
    71     connect(iClearHistoryAction, SIGNAL(triggered()), this, SLOT(popupClearHistoryConfirmMessageBox()));
    69     connect(iNetworkController, SIGNAL(networkRequestNotified(IRQNetworkEvent)),
    72     connect(iNetworkController, SIGNAL(networkRequestNotified(IRQNetworkEvent)),
    70     this, SLOT(networkRequestNotified(IRQNetworkEvent)));
    73     this, SLOT(networkRequestNotified(IRQNetworkEvent)));
    71     connect(iModel, SIGNAL(modelChanged()), this, SLOT(modelChanged()));
    74     connect(iModel, SIGNAL(modelChanged()), this, SLOT(modelChanged()));
    72     connect(iConvertTimer, SIGNAL(timeout()), this, SLOT(convertAnother()));
    75     connect(iConvertTimer, SIGNAL(timeout()), this, SLOT(convertAnother()));
    73 }
    76 }
    74 
    77 void IRHistoryView::popupClearHistoryConfirmMessageBox()
       
    78 {
       
    79 #ifdef SUBTITLE_STR_BY_LOCID
       
    80     HbMessageBox::question(hbTrId("txt_irad_info_clear_station_list"), this, SLOT(clearAllList(HbAction*)), hbTrId("txt_common_button_ok"), hbTrId("txt_common_button_cancel"));
       
    81 #else
       
    82     HbMessageBox::question(hbTrId("Clear station list?"), this, SLOT(clearAllList(HbAction*)), hbTrId("Ok"), hbTrId("Cancel"));    
       
    83 #endif
       
    84 }
    75 /* 
    85 /* 
    76  * Description : destructor
    86  * Description : destructor
    77  */
    87  */
    78 IRHistoryView::~IRHistoryView()
    88 IRHistoryView::~IRHistoryView()
    79 {
    89 {
   169         // user defined channel
   179         // user defined channel
   170         iPlayController->connectToChannel(&preset,EIRQHistoryAdhoc);
   180         iPlayController->connectToChannel(&preset,EIRQHistoryAdhoc);
   171     }
   181     }
   172 }
   182 }
   173 
   183 
       
   184 #ifdef HS_WIDGET_ENABLED
       
   185 void IRHistoryView::itemAboutToBeSelected(bool &aNeedNetwork)
       
   186 {
       
   187     aNeedNetwork =  true;
       
   188     
       
   189     int index = iListView->currentIndex().row();
       
   190     iPlayController->setConnectingStationName(iModel->getHistoryInfo(index)->getChannelName()); 
       
   191 }
       
   192 #endif
       
   193 
   174 void IRHistoryView::networkRequestNotified(IRQNetworkEvent aEvent)
   194 void IRHistoryView::networkRequestNotified(IRQNetworkEvent aEvent)
   175 {
   195 {
   176     if (getViewManager()->currentView() != this)
   196     if (getViewManager()->currentView() != this)
   177     {
   197     {
   178         return;
   198         return;
   222 
   242 
   223 // ---------------------------------------------------------------------------
   243 // ---------------------------------------------------------------------------
   224 // IRHistoryView::clearAllList()
   244 // IRHistoryView::clearAllList()
   225 // gets the List which was stored earlier
   245 // gets the List which was stored earlier
   226 //---------------------------------------------------------------------------
   246 //---------------------------------------------------------------------------
   227 void IRHistoryView::clearAllList()
   247 void IRHistoryView::clearAllList(HbAction *aAction)
   228 {
   248 {
   229     iIconIndexArray.clear();
   249     HbMessageBox *dialog = static_cast<HbMessageBox*>(sender());
   230     iModel->clearAllList();
   250     if (dialog)
   231     iConvertTimer->stop();
   251     {
   232     iIsdsClient->isdsLogoDownCancelTransaction();
   252         if (aAction == dialog->actions().at(0))
   233     iListView->reset();
   253         {
       
   254             iIconIndexArray.clear();
       
   255             iModel->clearAllList();
       
   256             iConvertTimer->stop();
       
   257             iIsdsClient->isdsLogoDownCancelTransaction();
       
   258             iListView->reset();
       
   259         }
       
   260     }    
   234 }
   261 }
   235 
   262 
   236 void IRHistoryView::prepareMenu()
   263 void IRHistoryView::prepareMenu()
   237 {
   264 {
   238     HbMenu *viewMenu = menu();
   265     HbMenu *viewMenu = menu();
   364     add2FavNote->setAttribute(Qt::WA_DeleteOnClose);
   391     add2FavNote->setAttribute(Qt::WA_DeleteOnClose);
   365         
   392         
   366     switch (retValue)
   393     switch (retValue)
   367     {
   394     {
   368     case EIRQErrorNone:
   395     case EIRQErrorNone:
       
   396 #ifdef SUBTITLE_STR_BY_LOCID
   369         add2FavNote->setTitle(hbTrId("txt_irad_info_added_to_favorites"));
   397         add2FavNote->setTitle(hbTrId("txt_irad_info_added_to_favorites"));
       
   398 #else
       
   399         add2FavNote->setTitle(hbTrId("Added to Favorites"));        
       
   400 #endif
   370         //add2FavNote->setIcon(HbIcon( QString("qtg_large_ok")));
   401         //add2FavNote->setIcon(HbIcon( QString("qtg_large_ok")));
   371         add2FavNote->show();
   402         add2FavNote->show();
   372         break;
   403         break;
   373 
   404 
   374     case EIRQErrorOutOfMemory:
   405     case EIRQErrorOutOfMemory:
       
   406 #ifdef SUBTITLE_STR_BY_LOCID
   375         add2FavNote->setTitle(hbTrId("txt_irad_info_can_not_add_more"));
   407         add2FavNote->setTitle(hbTrId("txt_irad_info_can_not_add_more"));
       
   408 #else
       
   409         add2FavNote->setTitle(hbTrId("Can't add more"));        
       
   410 #endif
   376         //add2FavNote->setIcon(HbIcon( QString("qtg_large_ok")));
   411         //add2FavNote->setIcon(HbIcon( QString("qtg_large_ok")));
   377         add2FavNote->show();        
   412         add2FavNote->show();        
   378         break;
   413         break;
   379 
   414 
   380     case EIRQErrorAlreadyExist:
   415     case EIRQErrorAlreadyExist:
       
   416 #ifdef SUBTITLE_STR_BY_LOCID
   381         add2FavNote->setTitle(hbTrId("txt_irad_info_favorite_updated"));
   417         add2FavNote->setTitle(hbTrId("txt_irad_info_favorite_updated"));
       
   418 #else
       
   419         add2FavNote->setTitle(hbTrId("Favorite updated"));        
       
   420 #endif
   382         //add2FavNote->setIcon(HbIcon( QString("qtg_large_ok")));
   421         //add2FavNote->setIcon(HbIcon( QString("qtg_large_ok")));
   383         add2FavNote->show();           
   422         add2FavNote->show();           
   384         break;
   423         break;
   385  
   424  
   386     default:
   425     default:
   393 {
   432 {
   394     int current = iListView->currentIndex().row();     
   433     int current = iListView->currentIndex().row();     
   395     bool ret = iModel->deleteOneItem(current);     
   434     bool ret = iModel->deleteOneItem(current);     
   396     if( !ret )
   435     if( !ret )
   397 	  {
   436 	  {
       
   437 #ifdef SUBTITLE_STR_BY_LOCID
   398 	    popupNote(hbTrId("txt_irad_info_operation_failed"), HbMessageBox::MessageTypeWarning);
   438 	    popupNote(hbTrId("txt_irad_info_operation_failed"), HbMessageBox::MessageTypeWarning);
       
   439 #else
       
   440 	    popupNote(hbTrId("Operation failed"), HbMessageBox::MessageTypeWarning);	    
       
   441 #endif
   399 	  }
   442 	  }
   400 }
   443 }
   401 void IRHistoryView::detailsContextAction()
   444 void IRHistoryView::detailsContextAction()
   402 {   
   445 {   
   403     int selectedItemIndex = iListView->currentIndex().row();
   446     int selectedItemIndex = iListView->currentIndex().row();
   420     HbAction *action = NULL;
   463     HbAction *action = NULL;
   421     HbMenu *contextMenu = new HbMenu;
   464     HbMenu *contextMenu = new HbMenu;
   422     contextMenu->setAttribute(Qt::WA_DeleteOnClose);
   465     contextMenu->setAttribute(Qt::WA_DeleteOnClose);
   423     connect(contextMenu, SIGNAL(triggered(HbAction*)), this, SLOT(actionClicked(HbAction*)));
   466     connect(contextMenu, SIGNAL(triggered(HbAction*)), this, SLOT(actionClicked(HbAction*)));
   424     
   467     
       
   468 #ifdef SUBTITLE_STR_BY_LOCID
   425     action = contextMenu->addAction(hbTrId("txt_irad_menu_add_to_favorite"));
   469     action = contextMenu->addAction(hbTrId("txt_irad_menu_add_to_favorite"));
       
   470 #else
       
   471     action = contextMenu->addAction(hbTrId("Add to favorites"));    
       
   472 #endif
   426     action->setObjectName(KActionAddName);
   473     action->setObjectName(KActionAddName);
       
   474 #ifdef SUBTITLE_STR_BY_LOCID
   427     action = contextMenu->addAction(hbTrId("txt_common_menu_delete"));
   475     action = contextMenu->addAction(hbTrId("txt_common_menu_delete"));
       
   476 #else
       
   477     action = contextMenu->addAction(hbTrId("Delete"));    
       
   478 #endif
   428     action->setObjectName(KActionDeleteName);
   479     action->setObjectName(KActionDeleteName);
       
   480 #ifdef SUBTITLE_STR_BY_LOCID
   429     action = contextMenu->addAction(hbTrId("txt_common_menu_details"));
   481     action = contextMenu->addAction(hbTrId("txt_common_menu_details"));
       
   482 #else
       
   483     action = contextMenu->addAction(hbTrId("Details"));    
       
   484 #endif
   430     action->setObjectName(KActionDetailsName);
   485     action->setObjectName(KActionDetailsName);
   431     
   486     
   432     contextMenu->open();
   487     contextMenu->open();
   433 }
   488 }
   434 
   489