56 |
57 |
57 iModel = new IRHistoryModel(this); |
58 iModel = new IRHistoryModel(this); |
58 iListView->setModel(iModel); |
59 iListView->setModel(iModel); |
59 iListView->setCurrentIndex(iModel->index(0)); |
60 iListView->setCurrentIndex(iModel->index(0)); |
60 |
61 |
61 iClearHistoryAction = new HbAction(hbTrId("txt_irad_opt_clear_station_history"), menu()); |
62 #ifdef SUBTITLE_STR_BY_LOCID |
62 |
63 iClearHistoryAction = new HbAction(hbTrId("txt_irad_opt_clear_list"), menu()); |
|
64 #else |
|
65 iClearHistoryAction = new HbAction(hbTrId("Clear list"), menu()); |
|
66 #endif |
63 |
67 |
64 iConvertTimer = new QTimer(this); |
68 iConvertTimer = new QTimer(this); |
65 iConvertTimer->setInterval(10); |
69 iConvertTimer->setInterval(10); |
66 |
70 |
67 connect(iClearHistoryAction, SIGNAL(triggered()), this, SLOT(clearAllList())); |
71 connect(iClearHistoryAction, SIGNAL(triggered()), this, SLOT(popupClearHistoryConfirmMessageBox())); |
68 connect(iNetworkController, SIGNAL(networkRequestNotified(IRQNetworkEvent)), |
72 connect(iNetworkController, SIGNAL(networkRequestNotified(IRQNetworkEvent)), |
69 this, SLOT(networkRequestNotified(IRQNetworkEvent))); |
73 this, SLOT(networkRequestNotified(IRQNetworkEvent))); |
70 connect(iModel, SIGNAL(modelChanged()), this, SLOT(modelChanged())); |
74 connect(iModel, SIGNAL(modelChanged()), this, SLOT(modelChanged())); |
71 connect(iConvertTimer, SIGNAL(timeout()), this, SLOT(convertAnother())); |
75 connect(iConvertTimer, SIGNAL(timeout()), this, SLOT(convertAnother())); |
72 } |
76 } |
73 |
77 void IRHistoryView::popupClearHistoryConfirmMessageBox() |
74 void IRHistoryView::gotoSongHistory() |
78 { |
75 { |
79 #ifdef SUBTITLE_STR_BY_LOCID |
76 getViewManager()->activateView(EIRView_SongHistoryView); |
80 HbMessageBox::question(hbTrId("txt_irad_info_clear_station_list"), this, SLOT(clearAllList(HbAction*)), hbTrId("txt_common_button_ok"), hbTrId("txt_common_button_cancel")); |
77 } |
81 #else |
78 |
82 HbMessageBox::question(hbTrId("Clear station list?"), this, SLOT(clearAllList(HbAction*)), hbTrId("Ok"), hbTrId("Cancel")); |
|
83 #endif |
|
84 } |
79 /* |
85 /* |
80 * Description : destructor |
86 * Description : destructor |
81 */ |
87 */ |
82 IRHistoryView::~IRHistoryView() |
88 IRHistoryView::~IRHistoryView() |
83 { |
89 { |
98 TIRHandleResult ret = IrAbstractListViewBase::handleCommand(aCommand, aReason); |
104 TIRHandleResult ret = IrAbstractListViewBase::handleCommand(aCommand, aReason); |
99 int leftCount = 0; |
105 int leftCount = 0; |
100 |
106 |
101 switch (aCommand) |
107 switch (aCommand) |
102 { |
108 { |
|
109 |
|
110 case EIR_ViewCommand_TOBEACTIVATED: |
|
111 showHistory(); |
|
112 ret = EIR_NoDefault; |
|
113 break; |
|
114 |
103 case EIR_ViewCommand_ACTIVATED: |
115 case EIR_ViewCommand_ACTIVATED: |
104 connect(iIsdsClient, SIGNAL(presetResponse(IRQPreset *)), |
|
105 this, SLOT(presetResponse(IRQPreset *))); |
|
106 connect(iIsdsClient, SIGNAL(operationException(IRQError)), |
|
107 this, SLOT(operationException(IRQError))); |
|
108 connect(iIsdsClient, SIGNAL(presetLogoDownloaded(IRQPreset* )), |
116 connect(iIsdsClient, SIGNAL(presetLogoDownloaded(IRQPreset* )), |
109 this, SLOT(presetLogoDownload(IRQPreset* ))); |
117 this, SLOT(presetLogoDownload(IRQPreset* ))); |
110 connect(iIsdsClient, SIGNAL(presetLogoDownloadError()), |
118 connect(iIsdsClient, SIGNAL(presetLogoDownloadError()), |
111 this, SLOT(presetLogoDownloadError())); |
119 this, SLOT(presetLogoDownloadError())); |
112 |
120 |
113 showHistory(); |
|
114 leftCount = iIconIndexArray.count(); |
121 leftCount = iIconIndexArray.count(); |
115 if( leftCount > 0 ) |
122 if( leftCount > 0 ) |
116 { |
123 { |
117 iConvertTimer->start(); |
124 iConvertTimer->start(); |
118 } |
125 } |
126 iIsdsClient->isdsLogoDownCancelTransaction(); |
133 iIsdsClient->isdsLogoDownCancelTransaction(); |
127 |
134 |
128 //iIconIndexArray must be cleared, because timer call back convertAnother() might be |
135 //iIconIndexArray must be cleared, because timer call back convertAnother() might be |
129 //called after view is deactivated. In that case, iModel->getImgURL(aIndex); will crash |
136 //called after view is deactivated. In that case, iModel->getImgURL(aIndex); will crash |
130 iIconIndexArray.clear(); |
137 iIconIndexArray.clear(); |
131 |
138 |
132 disconnect(iIsdsClient, SIGNAL(presetResponse(IRQPreset *)), |
|
133 this, SLOT(presetResponse(IRQPreset *))); |
|
134 disconnect(iIsdsClient, SIGNAL(operationException(IRQError)), |
|
135 this, SLOT(operationException(IRQError))); |
|
136 disconnect(iIsdsClient, SIGNAL(presetLogoDownloaded(IRQPreset*)), |
139 disconnect(iIsdsClient, SIGNAL(presetLogoDownloaded(IRQPreset*)), |
137 this, SLOT(presetLogoDownload(IRQPreset* ))); |
140 this, SLOT(presetLogoDownload(IRQPreset* ))); |
138 disconnect(iIsdsClient, SIGNAL(presetLogoDownloadError()), |
141 disconnect(iIsdsClient, SIGNAL(presetLogoDownloadError()), |
139 this, SLOT(presetLogoDownloadError())); |
142 this, SLOT(presetLogoDownloadError())); |
140 ret = EIR_NoDefault; |
143 ret = EIR_NoDefault; |
161 if (NULL == hisInfo) |
164 if (NULL == hisInfo) |
162 { |
165 { |
163 return; |
166 return; |
164 } |
167 } |
165 |
168 |
|
169 IRQPreset preset; |
|
170 convertStationHistory2Preset(*hisInfo, preset); |
|
171 |
166 if (hisInfo->getChannelType()) |
172 if (hisInfo->getChannelType()) |
167 { |
173 { |
168 // channel from isds server, get this preset |
174 // channel from isds server |
169 iPlayController->createBufferingDialog(this, SLOT(cancelRequest())); |
175 iPlayController->connectToChannel(&preset, EIRQHistoryIsds); |
170 iIsdsClient->isdsListenRequest(hisInfo->getChannelId(), true); |
|
171 } |
176 } |
172 else |
177 else |
173 { |
178 { |
174 // user defined channel |
179 // user defined channel |
175 IRQChannelServerURL server; |
|
176 server.bitrate = hisInfo->getBitrate(); |
|
177 server.url = hisInfo->getStreamUrl(); |
|
178 server.serverName = hisInfo->getChannelName(); |
|
179 IRQPreset preset; |
|
180 preset.insertChannelServer(server); |
|
181 preset.name = hisInfo->getChannelName(); |
|
182 preset.description = hisInfo->getChannelDesc(); |
|
183 preset.shortDesc = hisInfo->getChannelDesc(); |
|
184 preset.type = 0; |
|
185 preset.uniqID = 0; |
|
186 preset.presetId = 0; |
|
187 |
|
188 iPlayController->connectToChannel(&preset,EIRQHistoryAdhoc); |
180 iPlayController->connectToChannel(&preset,EIRQHistoryAdhoc); |
189 } |
181 } |
190 } |
182 } |
191 |
183 |
192 // --------------------------------------------------------------------------- |
184 #ifdef HS_WIDGET_ENABLED |
193 // IRHistoryView::presetResponse() |
185 void IRHistoryView::itemAboutToBeSelected(bool &aNeedNetwork) |
194 // gets the preset from isds client and play |
186 { |
195 //--------------------------------------------------------------------------- |
187 aNeedNetwork = true; |
196 void IRHistoryView::presetResponse(IRQPreset *aPreset) |
188 |
197 { |
189 int index = iListView->currentIndex().row(); |
198 iPlayController->connectToChannel(aPreset,EIRQHistoryIsds); |
190 iPlayController->setConnectingStationName(iModel->getHistoryInfo(index)->getChannelName()); |
199 } |
191 } |
200 |
192 #endif |
201 void IRHistoryView::operationException(IRQError aError) |
|
202 { |
|
203 Q_UNUSED(aError); |
|
204 iPlayController->closeBufferingDialog(); |
|
205 |
|
206 popupNote(hbTrId("txt_irad_info_failed_to_connect"), HbMessageBox::MessageTypeWarning); |
|
207 } |
|
208 |
193 |
209 void IRHistoryView::networkRequestNotified(IRQNetworkEvent aEvent) |
194 void IRHistoryView::networkRequestNotified(IRQNetworkEvent aEvent) |
210 { |
195 { |
211 if (getViewManager()->currentView() != this) |
196 if (getViewManager()->currentView() != this) |
212 { |
197 { |
214 } |
199 } |
215 |
200 |
216 switch (aEvent) |
201 switch (aEvent) |
217 { |
202 { |
218 case EIRQNetworkConnectionEstablished: |
203 case EIRQNetworkConnectionEstablished: |
219 iApplication->closeConnectingDialog(); |
|
220 |
|
221 if (EIR_UseNetwork_SelectItem == getUseNetworkReason()) |
204 if (EIR_UseNetwork_SelectItem == getUseNetworkReason()) |
222 { |
205 { |
223 handleItemSelected(); |
206 handleItemSelected(); |
224 } |
207 } |
225 |
|
226 setUseNetworkReason(EIR_UseNetwork_NoReason); |
|
227 break; |
208 break; |
228 |
209 |
229 default: |
210 default: |
230 setCheckedAction(); |
211 setCheckedAction(); |
231 break; |
212 break; |
232 } |
213 } |
233 } |
214 |
234 |
215 setUseNetworkReason(EIR_UseNetwork_NoReason); |
235 void IRHistoryView::cancelRequest() |
|
236 { |
|
237 iIsdsClient->isdsCancelRequest(); |
|
238 } |
216 } |
239 |
217 |
240 // --------------------------------------------------------------------------- |
218 // --------------------------------------------------------------------------- |
241 // IRHistoryView::showHistory() |
219 // IRHistoryView::showHistory() |
242 // gets the List which was stored earlier |
220 // gets the List which was stored earlier |
264 |
242 |
265 // --------------------------------------------------------------------------- |
243 // --------------------------------------------------------------------------- |
266 // IRHistoryView::clearAllList() |
244 // IRHistoryView::clearAllList() |
267 // gets the List which was stored earlier |
245 // gets the List which was stored earlier |
268 //--------------------------------------------------------------------------- |
246 //--------------------------------------------------------------------------- |
269 void IRHistoryView::clearAllList() |
247 void IRHistoryView::clearAllList(HbAction *aAction) |
270 { |
248 { |
271 iIconIndexArray.clear(); |
249 HbMessageBox *dialog = static_cast<HbMessageBox*>(sender()); |
272 iModel->clearAllList(); |
250 if (dialog) |
273 iConvertTimer->stop(); |
251 { |
274 iIsdsClient->isdsLogoDownCancelTransaction(); |
252 if (aAction == dialog->actions().at(0)) |
275 iListView->reset(); |
253 { |
|
254 iIconIndexArray.clear(); |
|
255 iModel->clearAllList(); |
|
256 iConvertTimer->stop(); |
|
257 iIsdsClient->isdsLogoDownCancelTransaction(); |
|
258 iListView->reset(); |
|
259 } |
|
260 } |
276 } |
261 } |
277 |
262 |
278 void IRHistoryView::prepareMenu() |
263 void IRHistoryView::prepareMenu() |
279 { |
264 { |
280 HbMenu *viewMenu = menu(); |
265 HbMenu *viewMenu = menu(); |
394 IRQSongHistoryInfo * currentInfo = iModel->getHistoryInfo(current.row()); |
384 IRQSongHistoryInfo * currentInfo = iModel->getHistoryInfo(current.row()); |
395 IRQPreset preset; |
385 IRQPreset preset; |
396 convertStationHistory2Preset(*currentInfo, preset); |
386 convertStationHistory2Preset(*currentInfo, preset); |
397 int retValue = iFavorites->addPreset(preset); |
387 int retValue = iFavorites->addPreset(preset); |
398 |
388 |
|
389 HbNotificationDialog *add2FavNote = new HbNotificationDialog(); |
|
390 add2FavNote->setModal(true); |
|
391 add2FavNote->setAttribute(Qt::WA_DeleteOnClose); |
|
392 |
399 switch (retValue) |
393 switch (retValue) |
400 { |
394 { |
401 case EIRQErrorNone: |
395 case EIRQErrorNone: |
402 popupNote(hbTrId("txt_irad_menu_add_to_favorite"), HbMessageBox::MessageTypeInformation); |
396 #ifdef SUBTITLE_STR_BY_LOCID |
403 |
397 add2FavNote->setTitle(hbTrId("txt_irad_info_added_to_favorites")); |
|
398 #else |
|
399 add2FavNote->setTitle(hbTrId("Added to Favorites")); |
|
400 #endif |
|
401 //add2FavNote->setIcon(HbIcon( QString("qtg_large_ok"))); |
|
402 add2FavNote->show(); |
404 break; |
403 break; |
405 |
404 |
406 case EIRQErrorOutOfMemory: |
405 case EIRQErrorOutOfMemory: |
407 popupNote(hbTrId("txt_irad_info_can_not_add_more"), HbMessageBox::MessageTypeInformation); |
406 #ifdef SUBTITLE_STR_BY_LOCID |
408 break; |
407 add2FavNote->setTitle(hbTrId("txt_irad_info_can_not_add_more")); |
|
408 #else |
|
409 add2FavNote->setTitle(hbTrId("Can't add more")); |
|
410 #endif |
|
411 //add2FavNote->setIcon(HbIcon( QString("qtg_large_ok"))); |
|
412 add2FavNote->show(); |
|
413 break; |
409 |
414 |
410 case EIRQErrorAlreadyExist: |
415 case EIRQErrorAlreadyExist: |
411 popupNote(hbTrId("txt_irad_info_favorite_updated"), HbMessageBox::MessageTypeInformation); |
416 #ifdef SUBTITLE_STR_BY_LOCID |
412 break; |
417 add2FavNote->setTitle(hbTrId("txt_irad_info_favorite_updated")); |
413 |
418 #else |
414 default: |
419 add2FavNote->setTitle(hbTrId("Favorite updated")); |
415 break; |
420 #endif |
|
421 //add2FavNote->setIcon(HbIcon( QString("qtg_large_ok"))); |
|
422 add2FavNote->show(); |
|
423 break; |
|
424 |
|
425 default: |
|
426 Q_ASSERT(false); |
|
427 break; |
416 } |
428 } |
417 } |
429 } |
418 |
430 |
419 void IRHistoryView::deleteContextAction() |
431 void IRHistoryView::deleteContextAction() |
420 { |
432 { |
421 int current = iListView->currentIndex().row(); |
433 int current = iListView->currentIndex().row(); |
422 bool ret = iModel->deleteOneItem(current); |
434 bool ret = iModel->deleteOneItem(current); |
423 if( !ret ) |
435 if( !ret ) |
424 { |
436 { |
|
437 #ifdef SUBTITLE_STR_BY_LOCID |
425 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 |
426 } |
442 } |
427 } |
443 } |
428 void IRHistoryView::detailContextAction() |
444 void IRHistoryView::detailsContextAction() |
429 { |
445 { |
430 getViewManager()->activateView(EIRView_StationDetailsView); |
|
431 IRStationDetailsView *channelHistoryView = static_cast<IRStationDetailsView*>(getViewManager()->getView(EIRView_StationDetailsView)); |
|
432 int selectedItemIndex = iListView->currentIndex().row(); |
446 int selectedItemIndex = iListView->currentIndex().row(); |
433 IRQSongHistoryInfo *channelDetailInfo = iModel->getHistoryInfo(selectedItemIndex); |
447 IRQSongHistoryInfo *channelDetailInfo = iModel->getHistoryInfo(selectedItemIndex); |
434 channelHistoryView->setDetails(channelDetailInfo); |
448 |
|
449 IRQPreset channelPreset; |
|
450 convertStationHistory2Preset(*channelDetailInfo, channelPreset); |
|
451 |
|
452 IRStationDetailsView *stationDetailsView = static_cast<IRStationDetailsView*>(getViewManager()->getView(EIRView_StationDetailsView, true)); |
|
453 stationDetailsView->setDetails(&channelPreset); |
|
454 |
|
455 getViewManager()->activateView(EIRView_StationDetailsView); |
435 } |
456 } |
436 |
457 |
437 void IRHistoryView::listViewLongPressed(HbAbstractViewItem *aItem, const QPointF& aCoords) |
458 void IRHistoryView::listViewLongPressed(HbAbstractViewItem *aItem, const QPointF& aCoords) |
438 { |
459 { |
439 Q_UNUSED(aItem); |
460 Q_UNUSED(aItem); |
442 HbAction *action = NULL; |
463 HbAction *action = NULL; |
443 HbMenu *contextMenu = new HbMenu; |
464 HbMenu *contextMenu = new HbMenu; |
444 contextMenu->setAttribute(Qt::WA_DeleteOnClose); |
465 contextMenu->setAttribute(Qt::WA_DeleteOnClose); |
445 connect(contextMenu, SIGNAL(triggered(HbAction*)), this, SLOT(actionClicked(HbAction*))); |
466 connect(contextMenu, SIGNAL(triggered(HbAction*)), this, SLOT(actionClicked(HbAction*))); |
446 |
467 |
|
468 #ifdef SUBTITLE_STR_BY_LOCID |
447 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 |
448 action->setObjectName(KActionAddName); |
473 action->setObjectName(KActionAddName); |
|
474 #ifdef SUBTITLE_STR_BY_LOCID |
449 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 |
450 action->setObjectName(KActionDeleteName); |
479 action->setObjectName(KActionDeleteName); |
|
480 #ifdef SUBTITLE_STR_BY_LOCID |
451 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 |
452 action->setObjectName(KActionDetailsName); |
485 action->setObjectName(KActionDetailsName); |
453 |
486 |
454 contextMenu->open(); |
487 contextMenu->open(); |
455 } |
488 } |
456 |
489 |
457 void IRHistoryView::convertStationHistory2Preset(const IRQSongHistoryInfo& aHistoryInfo, IRQPreset& aPreset) |
490 void IRHistoryView::convertStationHistory2Preset(const IRQSongHistoryInfo& aHistoryInfo, IRQPreset& aPreset) |
458 { |
491 { |
459 IRQChannelServerURL url; |
492 IRQChannelServerURL url; |
|
493 url.serverName = aHistoryInfo.getChannelName(); |
460 url.url = aHistoryInfo.getStreamUrl(); |
494 url.url = aHistoryInfo.getStreamUrl(); |
461 url.bitrate = aHistoryInfo.getBitrate(); |
495 url.bitrate = aHistoryInfo.getBitrate(); |
462 aPreset.name = aHistoryInfo.getChannelName(); |
496 aPreset.name = aHistoryInfo.getChannelName(); |
463 aPreset.insertChannelServer(url); |
497 aPreset.insertChannelServer(url); |
464 aPreset.type = aHistoryInfo.getChannelType(); |
498 aPreset.type = aHistoryInfo.getChannelType(); |
465 aPreset.presetId = aHistoryInfo.getChannelId(); |
499 aPreset.presetId = aHistoryInfo.getChannelId(); |
466 aPreset.shortDesc = aHistoryInfo.getChannelDesc(); |
500 aPreset.shortDesc = aHistoryInfo.getChannelDesc(); |
467 aPreset.imgUrl = aHistoryInfo.getImageUrl(); |
501 aPreset.imgUrl = aHistoryInfo.getImageUrl(); |
|
502 aPreset.genreName = aHistoryInfo.getGenreName(); |
|
503 aPreset.countryName = aHistoryInfo.getCountryName(); |
|
504 aPreset.languageName = aHistoryInfo.getLanguageName(); |
468 aPreset.description = aHistoryInfo.getChannelDesc(); |
505 aPreset.description = aHistoryInfo.getChannelDesc(); |
469 aPreset.musicStoreStatus = aHistoryInfo.getMusicStoreStatus(); |
506 aPreset.musicStoreStatus = aHistoryInfo.getMusicStoreStatus(); |
470 } |
507 } |
471 |
508 |
472 |
509 |