16 */ |
16 */ |
17 #include <QPixmap> |
17 #include <QPixmap> |
18 #include <hblistview.h> |
18 #include <hblistview.h> |
19 #include <hbaction.h> |
19 #include <hbaction.h> |
20 #include <QTimer> |
20 #include <QTimer> |
21 #include <hbprogressdialog.h> |
|
22 |
21 |
23 #include "irviewmanager.h" |
22 #include "irviewmanager.h" |
24 #include "irstationsview.h" |
23 #include "irstationsview.h" |
25 #include "irapplication.h" |
24 #include "irapplication.h" |
26 #include "irplaycontroller.h" |
25 #include "irplaycontroller.h" |
40 * Description : constructor |
39 * Description : constructor |
41 */ |
40 */ |
42 IRStationsView::IRStationsView(IRApplication* aApplication, TIRViewId aViewId) |
41 IRStationsView::IRStationsView(IRApplication* aApplication, TIRViewId aViewId) |
43 : IrAbstractListViewBase(aApplication, aViewId), |
42 : IrAbstractListViewBase(aApplication, aViewId), |
44 iLogoPreset(NULL), iPreset(NULL), |
43 iLogoPreset(NULL), iPreset(NULL), |
45 iWaitDialog(NULL), |
44 iLastSelectitem(0) |
46 iLastSelectitem(0), |
|
47 iLastPopularItem(0) |
|
48 { |
45 { |
49 //this view won't be starting view, don't need lazy init |
46 //this view won't be starting view, don't need lazy init |
50 IrAbstractListViewBase::lazyInit(); |
47 IrAbstractListViewBase::lazyInit(); |
51 setInitCompleted(true); |
48 setInitCompleted(true); |
52 |
49 |
76 delete iPreset; |
73 delete iPreset; |
77 iPreset = NULL; |
74 iPreset = NULL; |
78 |
75 |
79 delete iLogoPreset; |
76 delete iLogoPreset; |
80 iLogoPreset = NULL; |
77 iLogoPreset = NULL; |
81 |
|
82 delete iWaitDialog; |
|
83 iWaitDialog = NULL; |
|
84 |
|
85 |
|
86 |
|
87 } |
78 } |
88 |
79 |
89 void IRStationsView::loadCategoryStations(int aIndex, const QString &aHeadingText) |
80 void IRStationsView::loadCategoryStations(int aIndex, const QString &aHeadingText) |
90 { |
81 { |
91 connectToIsdsClient(); |
82 connectToIsdsClient(); |
92 setHeadingText(aHeadingText); |
83 setHeadingText(aHeadingText); |
93 setViewParameter(EIRViewPara_CategoryStations); |
|
94 |
84 |
95 bool cache = false; |
85 bool cache = false; |
96 iIsdsClient->isdsChannelRequest(aIndex, cache); |
86 iIsdsClient->isdsChannelRequest(aIndex, cache); |
97 |
87 |
98 if (!cache) |
88 if (!cache) |
99 { |
89 { |
100 createWaitDialog(hbTrId("txt_common_info_loading")); |
90 iApplication->startLoadingAnimation(this, SLOT(cancelRequest())); |
101 } |
91 } |
102 } |
|
103 |
|
104 void IRStationsView::loadPopularStations(bool aShowWaitDialog) |
|
105 { |
|
106 connectToIsdsClient(); |
|
107 setViewParameter(EIRViewPara_PopularStations); |
|
108 setHeadingText(tr("Popular stations")); |
|
109 bool cache = false; |
|
110 iIsdsClient->isdsCategoryRequest(IRQIsdsClient::Ehotpicks, cache); |
|
111 |
|
112 if (!cache && aShowWaitDialog) |
|
113 { |
|
114 createWaitDialog(hbTrId("txt_common_info_loading")); |
|
115 } |
|
116 } |
|
117 |
|
118 void IRStationsView::loadSearchResult(const QString &aStr) |
|
119 { |
|
120 connectToIsdsClient(); |
|
121 setViewParameter(EIRViewPara_SearchResults); |
|
122 setHeadingText(hbTrId("txt_irad_subtitle_search_result")); |
|
123 iIsdsClient->isdsSearchRequest(aStr); |
|
124 if( iConnectTimer->isActive() ) |
|
125 { |
|
126 iConnectTimer->stop(); |
|
127 } |
|
128 |
|
129 iConnectTimer->start(); |
|
130 createWaitDialog(hbTrId("txt_common_info_searching")); |
|
131 } |
92 } |
132 |
93 |
133 void IRStationsView::storeCurrentItem() |
94 void IRStationsView::storeCurrentItem() |
134 { |
95 { |
135 switch (getViewParameter()) |
96 iLastSelectitem = iListView->currentIndex().row(); |
136 { |
|
137 case EIRViewPara_PopularStations: |
|
138 iLastPopularItem = iListView->currentIndex().row(); |
|
139 break; |
|
140 case EIRViewPara_CategoryStations: |
|
141 iLastSelectitem = iListView->currentIndex().row(); |
|
142 break; |
|
143 default: |
|
144 break; |
|
145 } |
|
146 } |
97 } |
147 |
98 |
148 void IRStationsView::resetCurrentItem() |
99 void IRStationsView::resetCurrentItem() |
149 { |
100 { |
150 iLastSelectitem = 0; |
101 iLastSelectitem = 0; |
204 } |
155 } |
205 |
156 |
206 return ret; |
157 return ret; |
207 } |
158 } |
208 |
159 |
209 void IRStationsView::launchAction() |
160 #ifdef HS_WIDGET_ENABLED |
210 { |
161 void IRStationsView::itemAboutToBeSelected(bool &aNeedNetwork) |
211 setUseNetworkReason(EIR_UseNetwork_StartingView); |
162 { |
212 iApplication->verifyNetworkConnectivity(); |
163 aNeedNetwork = true; |
213 } |
164 |
|
165 int index = iListView->currentIndex().row(); |
|
166 iPlayController->setConnectingStationName(iChannelModel->getChannelItemByIndex(index)->channelName); |
|
167 } |
|
168 #endif |
214 |
169 |
215 // slots functions |
170 // slots functions |
216 |
171 |
217 /* |
172 /* |
218 * Description : slot function when an item in a list is clicked. |
173 * Description : slot function when an item in a list is clicked. |
231 connect(iIsdsClient, SIGNAL(operationException(IRQError)), |
186 connect(iIsdsClient, SIGNAL(operationException(IRQError)), |
232 this, SLOT(operationException(IRQError))); |
187 this, SLOT(operationException(IRQError))); |
233 |
188 |
234 //once an item is selected, we show a dialog to prevent user from clicking the |
189 //once an item is selected, we show a dialog to prevent user from clicking the |
235 //item again |
190 //item again |
236 iPlayController->createBufferingDialog(this, SLOT(cancelRequest())); |
191 iApplication->startLoadingAnimation(this, SLOT(cancelRequest())); |
237 |
192 |
238 if (iIsdsClient->isdsIsChannelBanner()) |
193 if (iIsdsClient->isdsIsChannelBanner()) |
239 { |
194 { |
240 iIsdsClient->isdsListenRequest(index + 1); |
195 iIsdsClient->isdsListenRequest(index + 1); |
241 } |
196 } |
252 * Description : data is received from isds client. Load the data to the list widget and display |
207 * Description : data is received from isds client. Load the data to the list widget and display |
253 * the stations view |
208 * the stations view |
254 */ |
209 */ |
255 void IRStationsView::dataChanged() |
210 void IRStationsView::dataChanged() |
256 { |
211 { |
257 |
|
258 int currentItem = 0; |
|
259 iApplication->closeConnectingDialog(); |
|
260 iConnectTimer->stop(); |
212 iConnectTimer->stop(); |
261 |
213 |
262 disconnectIsdsClient(); |
214 disconnectIsdsClient(); |
263 cleanupResource(); |
215 cleanupResource(); |
264 |
216 |
265 |
|
266 switch (getViewParameter()) |
|
267 { |
|
268 case EIRViewPara_SearchResults: |
|
269 currentItem = 0; |
|
270 break; |
|
271 case EIRViewPara_PopularStations: |
|
272 currentItem = iLastPopularItem; |
|
273 break; |
|
274 case EIRViewPara_CategoryStations: |
|
275 currentItem = iLastSelectitem; |
|
276 break; |
|
277 default: |
|
278 break; |
|
279 } |
|
280 iListView->reset(); |
217 iListView->reset(); |
281 iListView->setCurrentIndex(iChannelModel->index(currentItem)); |
218 iListView->setCurrentIndex(iChannelModel->index(iLastSelectitem)); |
282 iListView->scrollTo(iChannelModel->index(currentItem)); |
219 iListView->scrollTo(iChannelModel->index(iLastSelectitem)); |
283 |
220 |
284 //initialize the iconindices |
221 //initialize the iconindices |
285 for (int i = 0; i < iChannelModel->rowCount(); ++i) |
222 for (int i = 0; i < iChannelModel->rowCount(); ++i) |
286 { |
223 { |
287 if (iChannelModel->imageUrl(i) != "") |
224 if (iChannelModel->imageUrl(i) != "") |
289 iIconIndexArray.append(i); |
226 iIconIndexArray.append(i); |
290 } |
227 } |
291 } |
228 } |
292 |
229 |
293 getViewManager()->activateView(this); |
230 getViewManager()->activateView(this); |
294 if (iWaitDialog) |
231 iApplication->stopLoadingAnimation(); |
295 { |
|
296 iWaitDialog->close(); |
|
297 } |
|
298 } |
232 } |
299 |
233 |
300 /* |
234 /* |
301 * Description : the preset of the selected station is received from isds client. |
235 * Description : the preset of the selected station is received from isds client. |
302 * application is responsible for deleting old preset. |
236 * application is responsible for deleting old preset. |
322 * Description : slot function for operation failure. The signal is emitted by isds client |
256 * Description : slot function for operation failure. The signal is emitted by isds client |
323 * Parameters : aError : see the definition of IRQError |
257 * Parameters : aError : see the definition of IRQError |
324 */ |
258 */ |
325 void IRStationsView::operationException(IRQError aError) |
259 void IRStationsView::operationException(IRQError aError) |
326 { |
260 { |
327 iApplication->closeConnectingDialog(); |
261 iApplication->stopLoadingAnimation(); |
328 iPlayController->closeBufferingDialog(); |
262 |
329 |
|
330 if (iWaitDialog) |
|
331 { |
|
332 iWaitDialog->close(); |
|
333 } |
|
334 |
|
335 disconnectIsdsClient(); |
263 disconnectIsdsClient(); |
|
264 #ifdef SUBTITLE_STR_BY_LOCID |
336 QString errorString = hbTrId("txt_irad_info_failed_to_connect"); |
265 QString errorString = hbTrId("txt_irad_info_failed_to_connect"); |
|
266 #else |
|
267 QString errorString = hbTrId("Connecting failed"); |
|
268 #endif |
337 |
269 |
338 switch (aError) |
270 switch (aError) |
339 { |
271 { |
340 case EIRQErrorNotFound: |
272 case EIRQErrorNotFound: |
341 errorString = hbTrId("txt_irad_info_no_matching_stations_found"); |
273 #ifdef SUBTITLE_STR_BY_LOCID |
|
274 errorString = hbTrId("txt_irad_info_no_matching_station_found"); |
|
275 #else |
|
276 errorString = hbTrId("No matching station found"); |
|
277 #endif |
342 if (iConnectTimer->isActive()) |
278 if (iConnectTimer->isActive()) |
343 { |
279 { |
344 iConnectTimer->stop(); |
280 iConnectTimer->stop(); |
345 } |
281 } |
346 break; |
282 break; |
351 popupNote(errorString, HbMessageBox::MessageTypeWarning); |
287 popupNote(errorString, HbMessageBox::MessageTypeWarning); |
352 } |
288 } |
353 |
289 |
354 void IRStationsView::cancelRequest() |
290 void IRStationsView::cancelRequest() |
355 { |
291 { |
356 if( iWaitDialog ) |
|
357 { |
|
358 iWaitDialog->close(); |
|
359 } |
|
360 |
|
361 if( iConnectTimer->isActive()) |
292 if( iConnectTimer->isActive()) |
362 { |
293 { |
363 iConnectTimer->stop(); |
294 iConnectTimer->stop(); |
364 } |
295 } |
365 iIsdsClient->isdsCancelRequest(); |
296 iIsdsClient->isdsCancelRequest(); |
366 disconnectIsdsClient(); |
297 disconnectIsdsClient(); |
|
298 iApplication->stopLoadingAnimation(); |
367 } |
299 } |
368 |
300 |
369 void IRStationsView::startConvert(int aIndex) |
301 void IRStationsView::startConvert(int aIndex) |
370 { |
302 { |
371 QString url = iChannelModel->imageUrl(aIndex); |
303 QString url = iChannelModel->imageUrl(aIndex); |
372 |
304 |
373 IRQPreset tempPreset; |
305 IRQPreset tempPreset; |
374 tempPreset.imgUrl = url; |
306 tempPreset.imgUrl = url; |
375 tempPreset.type = IRQPreset::EIsds; |
307 tempPreset.type = IRQPreset::EIsds; |
376 |
|
377 bool cached = iIsdsClient->isdsIsLogoCached(&tempPreset, KBitmapSize, KBitmapSize); |
|
378 |
|
379 if( !cached ) |
|
380 { |
|
381 bool network = iApplication->verifyNetworkConnectivity(hbTrId("txt_irad_info_downloading_logos")); |
|
382 if( !network ) |
|
383 { |
|
384 //if user has clicked an item and the connection is being setup, we don't change the reason |
|
385 if (EIR_UseNetwork_NoReason == getUseNetworkReason()) |
|
386 { |
|
387 setUseNetworkReason(EIR_UseNetwork_DownloadLogo); |
|
388 } |
|
389 iConvertTimer->stop(); |
|
390 return; |
|
391 } |
|
392 } |
|
393 |
308 |
394 iIsdsClient->isdsLogoDownSendRequest(&tempPreset, 0, KBitmapSize, KBitmapSize); |
309 iIsdsClient->isdsLogoDownSendRequest(&tempPreset, 0, KBitmapSize, KBitmapSize); |
395 } |
310 } |
396 |
311 |
397 |
312 |
461 } |
376 } |
462 |
377 |
463 switch (aEvent) |
378 switch (aEvent) |
464 { |
379 { |
465 case EIRQNetworkConnectionEstablished: |
380 case EIRQNetworkConnectionEstablished: |
466 if (EIR_UseNetwork_StartingView == getUseNetworkReason()) |
381 if (EIR_UseNetwork_SelectItem == getUseNetworkReason()) |
467 { |
382 { |
468 //when stations view is starting view(used to show popular stations), don't show wait dialog |
|
469 loadPopularStations(false); |
|
470 } |
|
471 else if(EIR_UseNetwork_DownloadLogo == getUseNetworkReason()) |
|
472 { |
|
473 iApplication->closeConnectingDialog(); |
|
474 int leftCount = iIconIndexArray.count(); |
|
475 if(0 != leftCount) |
|
476 { |
|
477 iConvertTimer->start(); |
|
478 } |
|
479 } |
|
480 else if (EIR_UseNetwork_SelectItem == getUseNetworkReason()) |
|
481 { |
|
482 iApplication->closeConnectingDialog(); |
|
483 handleItemSelected(); |
383 handleItemSelected(); |
484 int leftCount = iIconIndexArray.count(); |
384 int leftCount = iIconIndexArray.count(); |
485 if(0 != leftCount) |
385 if(0 != leftCount) |
486 { |
386 { |
487 iConvertTimer->start(); |
387 iConvertTimer->start(); |
488 } |
388 } |
489 } |
389 } |
490 setUseNetworkReason(EIR_UseNetwork_NoReason); |
390 |
491 |
|
492 break; |
|
493 |
|
494 case EIRQConnectingCancelled: |
|
495 case EIRQDisplayNetworkMessageNoConnectivity: |
|
496 if (iListView->model()->rowCount() == 0) |
|
497 { |
|
498 getViewManager()->activateView(EIRView_MainView); |
|
499 } |
|
500 else |
|
501 { |
|
502 setCheckedAction(); |
|
503 } |
|
504 setUseNetworkReason(EIR_UseNetwork_NoReason); |
|
505 break; |
391 break; |
506 |
392 |
507 default: |
393 default: |
508 setCheckedAction(); |
394 setCheckedAction(); |
509 setUseNetworkReason(EIR_UseNetwork_NoReason); |
395 break; |
510 break; |
396 } |
511 } |
397 |
|
398 setUseNetworkReason(EIR_UseNetwork_NoReason); |
512 } |
399 } |
513 |
400 |
514 void IRStationsView::connectToIsdsClient() |
401 void IRStationsView::connectToIsdsClient() |
515 { |
402 { |
516 connect(iIsdsClient, SIGNAL(channelItemsChanged(QList<IRQChannelItem *> *)), |
403 connect(iIsdsClient, SIGNAL(channelItemsChanged(QList<IRQChannelItem *> *)), |
525 disconnect(iIsdsClient, SIGNAL(channelItemsChanged(QList<IRQChannelItem *> *)), |
412 disconnect(iIsdsClient, SIGNAL(channelItemsChanged(QList<IRQChannelItem *> *)), |
526 iChannelModel, SLOT(updateData(QList<IRQChannelItem *> *))); |
413 iChannelModel, SLOT(updateData(QList<IRQChannelItem *> *))); |
527 |
414 |
528 disconnect(iIsdsClient, SIGNAL(operationException(IRQError)), |
415 disconnect(iIsdsClient, SIGNAL(operationException(IRQError)), |
529 this, SLOT(operationException(IRQError))); |
416 this, SLOT(operationException(IRQError))); |
530 } |
|
531 |
|
532 void IRStationsView::createWaitDialog(const QString &aStr) |
|
533 { |
|
534 if (!iWaitDialog) |
|
535 { |
|
536 iWaitDialog = new HbProgressDialog(HbProgressDialog::WaitDialog); |
|
537 iWaitDialog->setTimeout(HbPopup::NoTimeout); |
|
538 iWaitDialog->setModal(true); |
|
539 iWaitDialog->setDismissPolicy(HbPopup::NoDismiss); |
|
540 QList<QAction*> actionsList = iWaitDialog->actions(); |
|
541 QAction *action = actionsList.at(0); |
|
542 action->setText(hbTrId("txt_common_button_cancel")); |
|
543 connect(action, SIGNAL(triggered()), this, SLOT(cancelRequest())); |
|
544 } |
|
545 |
|
546 iWaitDialog->setText(aStr); |
|
547 iWaitDialog->open(); |
|
548 } |
417 } |
549 |
418 |
550 void IRStationsView::convertAnother() |
419 void IRStationsView::convertAnother() |
551 { |
420 { |
552 iConvertTimer->stop(); |
421 iConvertTimer->stop(); |
560 |
429 |
561 void IRStationsView::connectTimeOut() |
430 void IRStationsView::connectTimeOut() |
562 { |
431 { |
563 iConnectTimer->stop(); |
432 iConnectTimer->stop(); |
564 cancelRequest(); |
433 cancelRequest(); |
|
434 #ifdef SUBTITLE_STR_BY_LOCID |
565 popupNote(hbTrId("txt_irad_info_connecting_timout"), HbMessageBox::MessageTypeWarning); |
435 popupNote(hbTrId("txt_irad_info_connecting_timout"), HbMessageBox::MessageTypeWarning); |
566 } |
436 #else |
|
437 popupNote(hbTrId("Connecting timeout"), HbMessageBox::MessageTypeWarning); |
|
438 #endif |
|
439 } |