39 |
39 |
40 const uint KBitmapSize = 59; |
40 const uint KBitmapSize = 59; |
41 |
41 |
42 IRSearchChannelsView::IRSearchChannelsView(IRApplication* aApplication, |
42 IRSearchChannelsView::IRSearchChannelsView(IRApplication* aApplication, |
43 TIRViewId aViewId): IRBaseView(aApplication, aViewId), |
43 TIRViewId aViewId): IRBaseView(aApplication, aViewId), |
44 iHeadingLabel(NULL),iListView(NULL),iSearchPanelWidget(NULL),iSearchState(ESearch_init), |
44 iListView(NULL),iSearchPanelWidget(NULL),iSearchState(ESearch_init), |
45 iChannelModel(NULL),iPreset(NULL),iLogoPreset(NULL), |
45 iChannelModel(NULL),iPreset(NULL),iLogoPreset(NULL), |
46 iConvertTimer(NULL) |
46 iConvertTimer(NULL) |
47 { |
47 { |
48 //if this view is not starting view, finish all initialization in constructor |
48 //if this view is not starting view, finish all initialization in constructor |
49 if (getViewManager()->views().count() > 0) |
49 if (getViewManager()->views().count() > 0) |
122 // List existing root elements - this allows us to refer to objects in the XML |
122 // List existing root elements - this allows us to refer to objects in the XML |
123 // which are created outside the document. |
123 // which are created outside the document. |
124 QObjectList roots; |
124 QObjectList roots; |
125 roots.append( this ); |
125 roots.append( this ); |
126 iLoader.setObjectTree( roots ); |
126 iLoader.setObjectTree( roots ); |
127 iLoader.load(SEARCH_CHANNELS_VIEW_LAYOUT_FILENAME); |
127 iLoader.load(SEARCH_CHANNELS_VIEW_LAYOUT_FILENAME); |
128 |
|
129 iHeadingLabel = qobject_cast<HbGroupBox *>(iLoader.findWidget(SEARCH_CHANNELS_VIEW_HEADINGTEXT_WIDGET)); |
|
130 |
|
131 |
128 |
132 iSearchPanelWidget = qobject_cast<HbSearchPanel *>(iLoader.findWidget(SEARCH_CHANNELS_VIEW_SEARCHPANEL_WIDGET)); |
129 iSearchPanelWidget = qobject_cast<HbSearchPanel *>(iLoader.findWidget(SEARCH_CHANNELS_VIEW_SEARCHPANEL_WIDGET)); |
133 |
130 |
134 iListView = qobject_cast<HbListView *>(iLoader.findWidget(SEARCH_CHANNELS_VIEW_SEARCHLISTVIEW_WIDGET)); |
131 iListView = qobject_cast<HbListView *>(iLoader.findWidget(SEARCH_CHANNELS_VIEW_SEARCHLISTVIEW_WIDGET)); |
135 iListView->setFlag(ItemIsFocusable); |
132 iListView->setFlag(ItemIsFocusable); |
138 scrollbar->setInteractive(true); |
135 scrollbar->setInteractive(true); |
139 iListView->setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAsNeeded); |
136 iListView->setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAsNeeded); |
140 |
137 |
141 iChannelModel = new IrChannelModel(this); |
138 iChannelModel = new IrChannelModel(this); |
142 iChannelModel->initWithCache(); |
139 iChannelModel->initWithCache(); |
143 iListView->setModel(iChannelModel); |
140 iListView->setModel(iChannelModel); |
144 //anywhere, before show the count, updated it ahead. |
|
145 #ifdef SUBTITLE_STR_BY_LOCID |
|
146 QString headingStr = hbTrId("txt_irad_subtitle_search_results") + " (" + QString::number(iChannelModel->rowCount()) + ")"; |
|
147 #else |
|
148 QString headingStr = hbTrId("Search results") + " (" + QString::number(iChannelModel->rowCount()) + ")"; |
|
149 #endif |
|
150 |
|
151 setHeadingText(headingStr); |
|
152 } |
141 } |
153 |
142 |
154 void IRSearchChannelsView::connectWidget() |
143 void IRSearchChannelsView::connectWidget() |
155 { |
144 { |
156 connect(iListView, SIGNAL(activated(const QModelIndex&)), this, SLOT(clickItem(const QModelIndex&))); |
145 connect(iListView, SIGNAL(activated(const QModelIndex&)), this, SLOT(clickItem(const QModelIndex&))); |
198 |
187 |
199 void IRSearchChannelsView::switch2LoadingState() |
188 void IRSearchChannelsView::switch2LoadingState() |
200 { |
189 { |
201 iSearchPanelWidget->clearFocus(); |
190 iSearchPanelWidget->clearFocus(); |
202 iListView->setFocus(); |
191 iListView->setFocus(); |
203 iSearchState = ESearch_Loading; |
192 iSearchState = ESearch_Loading; |
204 |
193 iApplication->startLoadingAnimation(this, SLOT(minimizeSearchPanel())); |
205 QSizeF searchPanelSize = iSearchPanelWidget->size(); |
|
206 QSizeF windowSize = getViewManager()->size(); |
|
207 QPointF pos(windowSize.width()/2,(windowSize.height() - searchPanelSize.height())/2); |
|
208 QPointF iconPos(LOADING_ANIMATION_ICON_SIZE/2, LOADING_ANIMATION_ICON_SIZE/2); |
|
209 pos -= iconPos; |
|
210 iApplication->startLoadingAnimation(pos); |
|
211 } |
194 } |
212 |
195 |
213 void IRSearchChannelsView::handleItemSelected() |
196 void IRSearchChannelsView::handleItemSelected() |
214 { |
197 { |
215 if (iListView) |
198 if (iListView) |
297 |
280 |
298 QString errStr; |
281 QString errStr; |
299 switch(aError) |
282 switch(aError) |
300 { |
283 { |
301 case EIRQErrorNotFound: |
284 case EIRQErrorNotFound: |
302 errStr = hbTrId("txt_irad_info_no_matching_stations_found"); |
285 #ifdef SUBTITLE_STR_BY_LOCID |
|
286 errStr = hbTrId("txt_irad_info_no_matching_station_found"); |
|
287 #else |
|
288 errStr = hbTrId("No matching station found"); |
|
289 #endif |
303 break; |
290 break; |
304 default: |
291 default: |
|
292 #ifdef SUBTITLE_STR_BY_LOCID |
305 errStr = hbTrId("txt_irad_info_failed_to_connect"); |
293 errStr = hbTrId("txt_irad_info_failed_to_connect"); |
|
294 #else |
|
295 errStr = hbTrId("Connecting failed"); |
|
296 #endif |
306 break; |
297 break; |
307 } |
298 } |
308 |
299 |
309 popupNote(errStr, HbMessageBox::MessageTypeWarning); |
300 popupNote(errStr, HbMessageBox::MessageTypeWarning); |
310 iChannelModel->cleanupDatabase(); |
301 iChannelModel->cleanupDatabase(); |
311 } |
302 } |
312 |
303 |
313 void IRSearchChannelsView::clickItem(const QModelIndex&) |
304 void IRSearchChannelsView::clickItem(const QModelIndex&) |
314 { |
305 { |
315 setUseNetworkReason(EIR_UseNetwork_SelectItem); |
306 setUseNetworkReason(EIR_UseNetwork_SelectItem); |
|
307 #ifdef HS_WIDGET_ENABLED |
|
308 int index = iListView->currentIndex().row(); |
|
309 IRQChannelItem* currentItem = iChannelModel->getChannelItemByIndex(index); |
|
310 iPlayController->setConnectingStationName(currentItem->channelName,true); |
|
311 #endif |
316 if (false == iApplication->verifyNetworkConnectivity()) |
312 if (false == iApplication->verifyNetworkConnectivity()) |
317 { |
313 { |
318 switch2LoadingState(); |
314 switch2LoadingState(); |
319 return; |
315 return; |
320 } |
316 } |
344 if( leftCount > 0 ) |
340 if( leftCount > 0 ) |
345 { |
341 { |
346 startConvert(iIconIndexArray[0]); |
342 startConvert(iIconIndexArray[0]); |
347 } |
343 } |
348 } |
344 } |
349 |
345 |
350 //set the subtitle and counter; |
|
351 void IRSearchChannelsView::setHeadingText(const QString &aText) |
|
352 { |
|
353 if (iHeadingLabel) |
|
354 { |
|
355 iHeadingLabel->setHeading(aText); |
|
356 } |
|
357 } |
|
358 void IRSearchChannelsView::dataChanged() |
346 void IRSearchChannelsView::dataChanged() |
359 { |
347 { |
360 switch2InitState(); |
348 switch2InitState(); |
361 //here update count in subtitle |
|
362 #ifdef SUBTITLE_STR_BY_LOCID |
|
363 QString headingStr = hbTrId("txt_irad_subtitle_search_results") + " (" + QString::number(iChannelModel->rowCount()) + ")"; |
|
364 #else |
|
365 QString headingStr = hbTrId("Search results") + " (" + QString::number(iChannelModel->rowCount()) + ")"; |
|
366 #endif |
|
367 setHeadingText(headingStr); |
|
368 iListView->reset(); |
349 iListView->reset(); |
369 if( iChannelModel->rowCount() ) |
350 if( iChannelModel->rowCount() ) |
370 { |
351 { |
371 iListView->setCurrentIndex(iChannelModel->index(0)); |
352 iListView->setCurrentIndex(iChannelModel->index(0)); |
372 iListView->scrollTo(iChannelModel->index(0)); |
353 iListView->scrollTo(iChannelModel->index(0)); |
468 |
449 |
469 void IRSearchChannelsView::minimizeSearchPanel() |
450 void IRSearchChannelsView::minimizeSearchPanel() |
470 { |
451 { |
471 if( ESearch_Loading == iSearchState ) |
452 if( ESearch_Loading == iSearchState ) |
472 { |
453 { |
473 if( ! ( iPlayController->isStopped() || iPlayController->isIdle() ) ) |
454 iPlayController->cancelBuffering(); |
474 { |
|
475 //cancel buffering |
|
476 iPlayController->cancelBuffering(); |
|
477 } |
|
478 |
|
479 disconnectIsdsClient(); |
|
480 iIsdsClient->isdsCancelRequest(); |
455 iIsdsClient->isdsCancelRequest(); |
481 iConvertTimer->stop(); |
456 iConvertTimer->stop(); |
482 iIsdsClient->isdsLogoDownCancelTransaction(); |
457 iIsdsClient->isdsLogoDownCancelTransaction(); |
483 switch2InitState(); |
458 switch2InitState(); |
484 } |
459 } |