qtinternetradio/ui/src/irsonghistoryview.cpp
branchGCC_SURGE
changeset 13 c9471d26c7f2
parent 12 608f67c22514
child 14 896e9dbc5f19
equal deleted inserted replaced
9:bfc95e24a059 13:c9471d26c7f2
    29 #include "irqenums.h"
    29 #include "irqenums.h"
    30 #include "irqstatisticsreporter.h"
    30 #include "irqstatisticsreporter.h"
    31 #include "irqsettings.h"
    31 #include "irqsettings.h"
    32 #include "iruidefines.h"
    32 #include "iruidefines.h"
    33 
    33 
    34  
    34 const QString KActionSearchInMusicStoreName("SearchInMusicStore");
       
    35 const QString KActionDeleteName("Delete");
    35 
    36 
    36 //                                         public functions
    37 //                                         public functions
    37 
    38 
    38 /*
    39 /*
    39  * Description : constructor
    40  * Description : constructor
    49     iModel = new IRSongHistoryModel(this);
    50     iModel = new IRSongHistoryModel(this);
    50     iModel->setOrientation(getViewManager()->orientation());
    51     iModel->setOrientation(getViewManager()->orientation());
    51     iListView->setModel(iModel);
    52     iListView->setModel(iModel);
    52     iListView->setCurrentIndex(iModel->index(0));
    53     iListView->setCurrentIndex(iModel->index(0));
    53     
    54     
    54     iClearSongHistoryAction = new HbAction(hbTrId("txt_irad_opt_clear_song_history"), this);
    55 #ifdef SUBTITLE_STR_BY_LOCID
       
    56     iClearSongHistoryAction = new HbAction(hbTrId("txt_irad_opt_clear_list"), this);
       
    57 #else
       
    58     iClearSongHistoryAction = new HbAction(hbTrId("Clear list"), this);    
       
    59 #endif
    55     iStatisticsReporter = IRQStatisticsReporter::openInstance();
    60     iStatisticsReporter = IRQStatisticsReporter::openInstance();
    56     
    61 
    57     
       
    58     iShowPrompt = iSettings->getSongHistoryShow();    
    62     iShowPrompt = iSettings->getSongHistoryShow();    
    59     if( iShowPrompt )
    63     if( iShowPrompt )
    60     {
    64     {
    61         iSettings->setSongHistoryShow(0);
    65         iSettings->setSongHistoryShow(0);
    62     }  
    66     }  
    63     
    67     
    64     connect(iClearSongHistoryAction, SIGNAL(triggered()), this, SLOT(clearHisotrySongDB()));    
    68     connect(iClearSongHistoryAction, SIGNAL(triggered()), this, SLOT(popupClearHistoryConfirmMessageBox()));    
    65     connect(iModel, SIGNAL(modelChanged()), this, SLOT(modelChanged()));        
    69     connect(iModel, SIGNAL(modelChanged()), this, SLOT(modelChanged()));        
    66 }
    70 }
    67 
    71 
    68 /* 
    72 /* 
    69  * Description : destructor
    73  * Description : destructor
    89     TIRHandleResult ret = IrAbstractListViewBase::handleCommand(aCommand, aReason);
    93     TIRHandleResult ret = IrAbstractListViewBase::handleCommand(aCommand, aReason);
    90      
    94      
    91 
    95 
    92     switch (aCommand)
    96     switch (aCommand)
    93     {
    97     {
       
    98     case EIR_ViewCommand_TOBEACTIVATED:       
       
    99         showSongHistory();
       
   100         ret = EIR_NoDefault;
       
   101         break;
       
   102                 
    94     case EIR_ViewCommand_ACTIVATED:        
   103     case EIR_ViewCommand_ACTIVATED:        
    95         connect(iPlayController, SIGNAL(metaDataAvailable(IRQMetaData*)), this, SLOT(newMetadataAdded(IRQMetaData*)));
   104         connect(iPlayController, SIGNAL(metaDataAvailable(IRQMetaData*)), this, SLOT(newMetadataAdded(IRQMetaData*)));
    96         showSongHistory();
       
    97         
       
    98         if( iShowPrompt )
   105         if( iShowPrompt )
    99         {             
   106         {             
   100             QTimer::singleShot(5, this, SLOT(showPrompt()));
   107             QTimer::singleShot(5, this, SLOT(showPrompt()));
   101             iShowPrompt = false;
   108             iShowPrompt = false;
   102         }         
   109         }         
   137         return;
   144         return;
   138     }
   145     }
   139 
   146 
   140     // TODO : Add the report in future. Add the channel id in the song info db
   147     // TODO : Add the report in future. Add the channel id in the song info db
   141     // iStatisticsReporter->logNmsEvents(EIRQFind,channelId);
   148     // iStatisticsReporter->logNmsEvents(EIRQFind,channelId);
   142     popupNote(hbTrId("txt_irad_info_music_store_not_available"), HbMessageBox::MessageTypeInformation);    
   149 #ifdef SUBTITLE_STR_BY_LOCID
       
   150     popupNote(hbTrId("txt_irad_info_music_store_not_available"), HbMessageBox::MessageTypeInformation);
       
   151 #else
       
   152     popupNote(hbTrId("Music store not available"), HbMessageBox::MessageTypeInformation);    
       
   153 #endif
   143 }
   154 }
   144    
   155    
   145 
   156 
   146 // ---------------------------------------------------------------------------
   157 // ---------------------------------------------------------------------------
   147 // IRSongHistoryView::showSongHistory()
   158 // IRSongHistoryView::showSongHistory()
   171 }
   182 }
   172     
   183     
   173 void IRSongHistoryView::modelChanged()
   184 void IRSongHistoryView::modelChanged()
   174 {    
   185 {    
   175     iListView->reset();
   186     iListView->reset();
   176     QString headingStr = hbTrId("txt_irad_list_recently_played_songs") + " (" + QString::number(iModel->rowCount()) + ")";    
   187     
       
   188 #ifdef SUBTITLE_STR_BY_LOCID
       
   189     QString headingStr = hbTrId("txt_irad_subtitle_recently_played_songs") + " (" + QString::number(iModel->rowCount()) + ")";   
       
   190 #else
       
   191     QString headingStr = hbTrId("Recently played songs") + " (" + QString::number(iModel->rowCount()) + ")";
       
   192 #endif    
       
   193  
   177     setHeadingText(headingStr);   
   194     setHeadingText(headingStr);   
   178 }
   195 }
   179 
   196 
   180 void IRSongHistoryView::newMetadataAdded(IRQMetaData *aMetadata)
   197 void IRSongHistoryView::newMetadataAdded(IRQMetaData *aMetadata)
   181 {
   198 {
   182     Q_UNUSED(aMetadata);     
   199     Q_UNUSED(aMetadata);     
   183     iModel->checkSongHistoryUpdate();
   200     iModel->checkSongHistoryUpdate();
   184      
   201      
   185 }
   202 }
   186 
   203 
   187 void IRSongHistoryView::clearHisotrySongDB()
   204 void IRSongHistoryView::popupClearHistoryConfirmMessageBox()
   188 {
   205 {
   189     iModel->clearHisotrySongDB();  
   206 #ifdef SUBTITLE_STR_BY_LOCID
       
   207     HbMessageBox::question(hbTrId("txt_irad_info_clear_song_list"), this, SLOT(clearList(HbAction*)), hbTrId("txt_common_button_ok"), hbTrId("txt_common_button_cancel"));
       
   208 #else
       
   209     HbMessageBox::question(hbTrId("Clear song list?"), this, SLOT(clearList(HbAction*)), hbTrId("Ok"), hbTrId("Cancel"));    
       
   210 #endif
       
   211 }
       
   212 void IRSongHistoryView::clearList(HbAction *aAction)
       
   213 {
       
   214     HbMessageBox *dialog = static_cast<HbMessageBox*>(sender());
       
   215     if (dialog)
       
   216     {
       
   217         if (aAction == dialog->actions().at(0))
       
   218         {
       
   219             iModel->clearList();
       
   220         }
       
   221     }
   190 }
   222 }
   191 
   223 
   192 void IRSongHistoryView::showPrompt()
   224 void IRSongHistoryView::showPrompt()
   193 {
   225 {
       
   226 #ifdef SUBTITLE_STR_BY_LOCID
   194     QString str = hbTrId("txt_irad_info_click_the_song_and_find_it_in_nokia_music_store");
   227     QString str = hbTrId("txt_irad_info_click_the_song_and_find_it_in_nokia_music_store");
       
   228 #else
       
   229     QString str = hbTrId("Click the song and find it in nokia music store");    
       
   230 #endif
   195     popupNote(str, HbMessageBox::MessageTypeInformation);
   231     popupNote(str, HbMessageBox::MessageTypeInformation);
   196 }
   232 }
   197 
   233 
   198 void IRSongHistoryView::itemAboutToBeSelected(bool& needNetwork)
   234 void IRSongHistoryView::itemAboutToBeSelected(bool& needNetwork)
   199 {
   235 {
   200     /* for in song history view, the data will retrived from the web browser*/
   236     /* for in song history view, the data will retrived from the web browser*/
   201     needNetwork = false;
   237     needNetwork = false;
   202 }
   238 }
   203  
   239 
       
   240 void IRSongHistoryView::listViewLongPressed(HbAbstractViewItem *aItem, const QPointF& aCoords)
       
   241 {
       
   242     Q_UNUSED(aItem);
       
   243     Q_UNUSED(aCoords);
       
   244 
       
   245     HbAction *action = NULL;
       
   246     HbMenu *contextMenu = new HbMenu;
       
   247     contextMenu->setAttribute(Qt::WA_DeleteOnClose);
       
   248     connect(contextMenu, SIGNAL(triggered(HbAction*)), this, SLOT(actionClicked(HbAction*)));
       
   249 
       
   250 #ifdef SUBTITLE_STR_BY_LOCID
       
   251     action = contextMenu->addAction(hbTrId("txt_irad_menu_search_in_music_store"));
       
   252 #else
       
   253     action = contextMenu->addAction(hbTrId("Search in music store"));    
       
   254 #endif
       
   255     action->setObjectName(KActionSearchInMusicStoreName);
       
   256 #ifdef SUBTITLE_STR_BY_LOCID
       
   257     action = contextMenu->addAction(hbTrId("txt_common_menu_delete"));
       
   258 #else
       
   259     action = contextMenu->addAction(hbTrId("Delete"));    
       
   260 #endif
       
   261     action->setObjectName(KActionDeleteName);
       
   262 
       
   263     contextMenu->open();
       
   264 }
       
   265 
       
   266 void IRSongHistoryView::searchInMusicStoreContextAction()
       
   267 {
       
   268     // Need to log the find song in NMS event, iStatisticsReporter->logNmsEvent(IRQStatisticsReporter::EIRFind,channelId);  
       
   269 #ifdef SUBTITLE_STR_BY_LOCID
       
   270     popupNote(hbTrId("txt_irad_info_music_store_not_available"), HbMessageBox::MessageTypeInformation);
       
   271 #else
       
   272     popupNote(hbTrId("Music store not available"), HbMessageBox::MessageTypeInformation);    
       
   273 #endif
       
   274 }
       
   275 void IRSongHistoryView::deleteContextAction()
       
   276 {
       
   277     int current = iListView->currentIndex().row();     
       
   278     bool ret = iModel->deleteOneItem(current);     
       
   279     if( !ret )
       
   280     {
       
   281 #ifdef SUBTITLE_STR_BY_LOCID
       
   282         popupNote(hbTrId("txt_irad_info_operation_failed"), HbMessageBox::MessageTypeWarning);
       
   283 #else
       
   284         popupNote(hbTrId("Operation failed"), HbMessageBox::MessageTypeWarning);        
       
   285 #endif
       
   286     }
       
   287 }
       
   288 
   204 void IRSongHistoryView::gotoStationHistory()
   289 void IRSongHistoryView::gotoStationHistory()
   205 {
   290 {
   206 	  getViewManager()->activateView(EIRView_HistoryView);
   291 	  getViewManager()->activateView(EIRView_HistoryView);
   207 }
   292 }
   208 
   293 
   210 {
   295 {
   211     IrAbstractListViewBase::handleOrientationChanged(aOrientation);
   296     IrAbstractListViewBase::handleOrientationChanged(aOrientation);
   212     iModel->setOrientation(aOrientation);
   297     iModel->setOrientation(aOrientation);
   213     iListView->reset();
   298     iListView->reset();
   214 }
   299 }
       
   300 
       
   301 void IRSongHistoryView::actionClicked(HbAction *aAction)
       
   302 {
       
   303     if ( aAction )
       
   304     {
       
   305         QString objectName = aAction->objectName();
       
   306         if ( objectName == KActionSearchInMusicStoreName )
       
   307         {
       
   308             searchInMusicStoreContextAction();
       
   309         }
       
   310         else if( objectName == KActionDeleteName)
       
   311         {
       
   312             deleteContextAction();
       
   313         }
       
   314     }
       
   315 }