12 * Contributors: |
12 * Contributors: |
13 * |
13 * |
14 * Description: |
14 * Description: |
15 * |
15 * |
16 */ |
16 */ |
17 #include <hbpushbutton.h> |
17 |
18 #include <hbtoolbar.h> |
18 #include <qtimer.h> |
19 #include <hbaction.h> |
19 #include <hblistview.h> |
20 #include <QFont> |
20 #include <hbsearchpanel.h> |
21 #include <QActionGroup> |
21 #include <hbaction.h> |
22 #include <QSizePolicy> |
22 #include <hbprogressdialog.h> |
23 #include <QStringList> |
23 |
24 #include <QStringListModel> |
24 #include "irsearchchannelsview.h" |
25 #include <QTimer> |
25 #include "iruidefines.h" |
26 |
26 #include "irqisdsclient.h" |
|
27 #include "irapplication.h" |
|
28 #include "irviewmanager.h" |
|
29 #include "irqnetworkcontroller.h" |
|
30 #include "irchannelmodel.h" |
27 #include "irqisdsdatastructure.h" |
31 #include "irqisdsdatastructure.h" |
28 #include "irsearchchannelsview.h" |
|
29 #include "irabstractviewmanager.h" |
|
30 #include "irstationsview.h" |
|
31 #include "irqnetworkcontroller.h" |
|
32 #include "irbannerlabel.h" |
|
33 #include "irqmetadata.h" |
|
34 #include "irplaycontroller.h" |
32 #include "irplaycontroller.h" |
35 #include "irqisdsclient.h" |
33 |
36 #include "irapplication.h" |
34 const uint KBitmapSize = 59; |
37 #include "irsearchcriteriadb.h" |
|
38 #include "ircombobox.h" |
|
39 #include "iruidefines.h" |
|
40 |
|
41 const QString KInitialString = "Input key string"; |
|
42 |
35 |
43 IRSearchChannelsView::IRSearchChannelsView(IRApplication* aApplication, |
36 IRSearchChannelsView::IRSearchChannelsView(IRApplication* aApplication, |
44 TIRViewId aViewId): IRBaseView(aApplication, aViewId),iCollectionsAction(NULL),iFavoritesAction(NULL), |
37 TIRViewId aViewId): IRBaseView(aApplication, aViewId), |
45 iGenresAction(NULL),iSearchAction(NULL),iSearchButton(NULL),iSearchText(NULL),iSearchIconLabel(NULL), |
38 iListView(NULL),iSearchPanelWidget(NULL), |
46 iSearchCombobox(NULL),iFirstTime(true),iBannerLabel(NULL),iDB(NULL) |
39 iSearchState(ESearch_init),iChannelModel(NULL),iSearchingDialog(NULL), |
47 |
40 iPreset(NULL),iLogoPreset(NULL),iConvertTimer(NULL) |
|
41 { |
|
42 //if this view is not starting view, finish all initialization in constructor |
|
43 if (getViewManager()->views().count() > 0) |
|
44 { |
|
45 if (!initCompleted()) |
|
46 { |
|
47 normalInit(); |
|
48 } |
|
49 } |
|
50 } |
|
51 |
|
52 void IRSearchChannelsView::lazyInit() |
|
53 { |
|
54 if (!initCompleted()) |
|
55 { |
|
56 normalInit(); |
|
57 } |
|
58 } |
|
59 |
|
60 void IRSearchChannelsView::normalInit() |
|
61 { |
|
62 if (!initCompleted()) |
|
63 { |
|
64 IRBaseView::lazyInit(); |
|
65 loadLayout(); |
|
66 connectWidget(); |
|
67 switch2InitState(); |
|
68 initMenu(); |
|
69 initTimer(); |
|
70 setInitCompleted(true); |
|
71 } |
|
72 } |
|
73 |
|
74 void IRSearchChannelsView::initMenu() |
|
75 { |
|
76 |
|
77 } |
|
78 |
|
79 void IRSearchChannelsView::initTimer() |
|
80 { |
|
81 iConvertTimer = new QTimer(this); |
|
82 iConvertTimer->setInterval(10); |
|
83 |
|
84 connect(iConvertTimer, SIGNAL(timeout()), this, SLOT(convertAnother())); |
|
85 } |
|
86 |
|
87 IRSearchChannelsView::~IRSearchChannelsView() |
|
88 { |
|
89 if( iSearchingDialog != NULL ) |
|
90 { |
|
91 iSearchingDialog->close(); |
|
92 delete iSearchingDialog; |
|
93 iSearchingDialog = NULL; |
|
94 } |
|
95 |
|
96 if( iPreset != NULL ) |
|
97 { |
|
98 delete iPreset; |
|
99 iPreset = NULL; |
|
100 } |
|
101 |
|
102 if( iLogoPreset != NULL ) |
|
103 { |
|
104 delete iLogoPreset; |
|
105 iLogoPreset = NULL; |
|
106 } |
|
107 } |
|
108 |
|
109 void IRSearchChannelsView::loadLayout() |
48 { |
110 { |
49 // Create widget hierarchy |
111 // Create widget hierarchy |
50 setObjectName( SEARCH_CHANNELS_VIEW_OBJECT_VIEW ); |
112 setObjectName( SEARCH_CHANNELS_VIEW_OBJECT_VIEW ); |
51 |
113 iChannelModel = new IrChannelModel(this); |
52 // List existing root elements - this allows us to refer to objects in the XML |
114 // List existing root elements - this allows us to refer to objects in the XML |
53 // which are created outside the document. |
115 // which are created outside the document. |
54 QObjectList roots; |
116 QObjectList roots; |
55 roots.append( this ); |
117 roots.append( this ); |
56 iLoader.setObjectTree( roots ); |
118 iLoader.setObjectTree( roots ); |
57 |
|
58 iLoader.load(SEARCH_CHANNELS_VIEW_LAYOUT_FILENAME); |
119 iLoader.load(SEARCH_CHANNELS_VIEW_LAYOUT_FILENAME); |
59 iLoader.load(SEARCH_CHANNELS_VIEW_LAYOUT_FILENAME,SEARCH_CHANNELS_VIEW_NO_PLAYINGBANNER_SECTION); |
120 iSearchPanelWidget = qobject_cast<HbSearchPanel *>(iLoader.findWidget(SEARCH_CHANNELS_VIEW_SEARCHPANEL_WIDGET)); |
60 |
121 iListView = qobject_cast<HbListView *>(iLoader.findWidget(SEARCH_CHANNELS_VIEW_SEARCHLISTVIEW_WIDGET)); |
61 iSearchCombobox = qobject_cast<IrComboBox *> (iLoader.findObject(SEARCH_CHANNELS_VIEW_OBJECT_SEARCHKEY_LABEL)); |
122 iListView->setModel(iChannelModel); |
62 iSearchButton = qobject_cast<HbPushButton *>(iLoader.findObject(SEARCH_CHANNELS_VIEW_OBJECT_SEARCHKEY_BUTTON)); |
123 } |
63 iBannerLabel = qobject_cast<IrNowPlayingBannerLabel *>(iLoader.findObject(SEARCH_CHANNELS_VIEW_OBJECT_PLAYING_BANNER)); |
124 |
64 |
125 void IRSearchChannelsView::connectWidget() |
65 initContentWidget(); |
126 { |
66 initToolBar(); |
127 connect(iListView, SIGNAL(activated(const QModelIndex&)), this, SLOT(clickItem(const QModelIndex&))); |
67 initMenu(); |
128 connect(iChannelModel, SIGNAL(dataAvailable()), this, SLOT(dataChanged())); |
68 createDB(); |
129 connect(iNetworkController, SIGNAL(networkRequestNotified(IRQNetworkEvent)), this, SLOT(networkRequestNotified(IRQNetworkEvent))); |
69 } |
130 connect(iSearchPanelWidget,SIGNAL(criteriaChanged(const QString&)),this,SLOT(searchTextAlready(const QString&))); |
70 |
131 } |
71 IRSearchChannelsView::~IRSearchChannelsView() |
132 |
72 { |
133 void IRSearchChannelsView::connectIsdsClient() |
73 delete iDB; |
134 { |
74 iDB = NULL; |
135 connect(iIsdsClient, SIGNAL(channelItemsChanged(QList<IRQChannelItem *> *)), |
75 } |
136 iChannelModel, SLOT(updateData(QList<IRQChannelItem *> *))); |
76 |
137 connect(iIsdsClient, SIGNAL(operationException(IRQError)), |
|
138 this, SLOT(operationException(IRQError))); |
|
139 connect(iIsdsClient, SIGNAL(presetResponse(IRQPreset *)), |
|
140 this, SLOT(presetResponse(IRQPreset *))); |
|
141 connect(iIsdsClient, SIGNAL(presetLogoDownloaded(IRQPreset* )), |
|
142 this, SLOT(presetLogoDownload(IRQPreset* ))); |
|
143 connect(iIsdsClient, SIGNAL(presetLogoDownloadError()), |
|
144 this, SLOT(presetLogoDownloadError())); |
|
145 |
|
146 |
|
147 } |
|
148 |
|
149 void IRSearchChannelsView::disconnectIsdsClient() |
|
150 { |
|
151 disconnect(iIsdsClient, SIGNAL(channelItemsChanged(QList<IRQChannelItem *> *)), |
|
152 iChannelModel, SLOT(updateData(QList<IRQChannelItem *> *))); |
|
153 disconnect(iIsdsClient, SIGNAL(operationException(IRQError)), this, |
|
154 SLOT(operationException(IRQError))); |
|
155 disconnect(iIsdsClient, SIGNAL(presetResponse(IRQPreset *)), |
|
156 this, SLOT(presetResponse(IRQPreset *))); |
|
157 disconnect(iIsdsClient, SIGNAL(presetLogoDownloaded(IRQPreset*)), |
|
158 this, SLOT(presetLogoDownload(IRQPreset* ))); |
|
159 disconnect(iIsdsClient, SIGNAL(presetLogoDownloadError()), |
|
160 this, SLOT(presetLogoDownloadError())); |
|
161 } |
|
162 |
|
163 |
|
164 void IRSearchChannelsView::switch2InitState() |
|
165 { |
|
166 iLoader.load(SEARCH_CHANNELS_VIEW_LAYOUT_FILENAME,SEARCH_CHANNELS_VIEW_NO_LISTVIEW_SECTION); |
|
167 iSearchState = ESearch_init; |
|
168 } |
|
169 |
|
170 void IRSearchChannelsView::switch2SearchedState() |
|
171 { |
|
172 iLoader.load(SEARCH_CHANNELS_VIEW_LAYOUT_FILENAME,SEARCH_CHANNELS_VIEW_LISTVIEW_SECTION); |
|
173 iSearchState = ESearch_Searched; |
|
174 } |
|
175 void IRSearchChannelsView::switch2SearchingState() |
|
176 { |
|
177 iSearchState = ESearch_Searching; |
|
178 startSearchingAnimation(); |
|
179 } |
77 |
180 |
78 void IRSearchChannelsView::helpAction() |
181 void IRSearchChannelsView::createSearchingDialog() |
79 { |
182 { |
80 popupNote(tr("Not ready"), HbMessageBox::MessageTypeInformation); |
183 if ( NULL == iSearchingDialog) |
81 } |
184 { |
82 |
185 //needs to add this , otherwise memory leak |
83 |
186 iSearchingDialog = new HbProgressDialog(HbProgressDialog::WaitDialog); |
84 |
187 iSearchingDialog->setModal(true); |
85 TIRHandleResult IRSearchChannelsView::handleCommand(TIRViewCommand aCommand, TIRViewCommandReason aReason) |
188 iSearchingDialog->setTimeout(HbPopup::NoTimeout); |
86 { |
189 QAction *cancelAction = iSearchingDialog->actions().at(0); |
87 Q_UNUSED(aReason); |
190 cancelAction->setText(hbTrId("txt_common_button_cancel")); |
88 TIRHandleResult ret = EIR_DoDefault; |
191 connect(cancelAction, SIGNAL(triggered()), this, SLOT(cancelRequest())); |
89 QString str = ""; |
192 } |
90 |
193 |
91 switch (aCommand) |
194 iSearchingDialog->setText(hbTrId("txt_common_info_searching")); |
92 { |
195 iSearchingDialog->show(); |
93 case EIR_ViewCommand_ACTIVATED: |
196 } |
94 updateView(); |
197 |
95 iBannerLabel->startAnimation(); |
198 void IRSearchChannelsView::closeSearchingDialog() |
96 str = iSearchCombobox->currentText(); |
199 { |
97 str = str.trimmed(); |
200 if( iSearchingDialog ) |
98 if( str == KInitialString || "" == str) |
201 { |
99 iSearchButton->setEnabled(false); |
202 iSearchingDialog->close(); |
100 else |
203 iSearchingDialog->deleteLater(); |
101 iSearchButton->setEnabled(true); |
204 iSearchingDialog = NULL; |
102 |
205 } |
103 iSearchAction->setChecked(true); |
206 } |
104 break; |
207 |
105 |
208 void IRSearchChannelsView::startSearchingAnimation() |
106 case EIR_ViewCommand_DEACTIVATE: |
209 { |
107 iBannerLabel->stopAnimation(); |
210 |
108 break; |
211 } |
109 } |
212 |
110 |
213 void IRSearchChannelsView::stopSearchingAnimation() |
111 return ret; |
214 { |
112 } |
215 |
113 |
216 } |
114 |
217 |
115 void IRSearchChannelsView::initContentWidget() |
218 |
116 { |
219 void IRSearchChannelsView::handleItemSelected() |
117 iBannerLabel->setFontSpec(HbFontSpec(HbFontSpec::Primary)); |
220 { |
118 |
221 if (iListView) |
119 iSearchButton->setEnabled(false); |
222 { |
120 iSearchCombobox->setEditable(true); |
223 int index = iListView->currentIndex().row(); |
121 iSearchCombobox->setEditText(KInitialString); |
224 if (index != -1) |
122 |
225 { |
123 connect(iSearchButton, SIGNAL(clicked(bool)),this, SLOT(startSearch(bool))); |
226 if (iIsdsClient) |
124 connect(iSearchCombobox, SIGNAL(editTextChanged(const QString&)), this, SLOT(searchBoxTextChanged(const QString&))); |
227 { |
125 connect(iNetworkController, SIGNAL(networkRequestNotified(IRQNetworkEvent)), this, SLOT(networkRequestNotified(IRQNetworkEvent))); |
228 //once an item is selected, we show a dialog to prevent user from clicking the |
126 connect(iSearchCombobox, SIGNAL(pressed()), this, SLOT(comboboxClicked())); |
229 //item again |
127 connect(iPlayController, SIGNAL(metaDataAvailable(IRQMetaData*)), this, |
230 iPlayController->createBufferingDialog(this, SLOT(cancelRequest())); |
128 SLOT(metaDataAvailable(IRQMetaData*))); |
231 |
129 connect(iPlayController, SIGNAL(playingStopped()), this, |
232 if (iIsdsClient->isdsIsChannelBanner()) |
130 SLOT(removeBanner())); |
233 { |
131 connect(iBannerLabel, SIGNAL(pressed()), this, SLOT(gotoNowPlaying())); |
234 iIsdsClient->isdsListenRequest(index + 1); |
132 } |
235 } |
133 |
236 else |
134 void IRSearchChannelsView::initMenu() |
237 { |
135 { |
238 iIsdsClient->isdsListenRequest(index); |
136 |
239 } |
137 HbAction *settings = qobject_cast<HbAction *>(iLoader.findObject(SEARCH_CHANNELS_VIEW_OBJECT_SETTING_ACTION)); |
240 } |
138 HbAction *openWebAdressAction = qobject_cast<HbAction*>(iLoader.findObject(SEARCH_CHANNELS_VIEW_OBJECT_OPEN_WEB_ADDRESS_ACTION)); |
241 } |
139 HbAction *helpAction = qobject_cast<HbAction *>(iLoader.findObject(SEARCH_CHANNELS_VIEW_OBJECT_HELP_ACTION)); |
242 } |
140 HbAction *exitAction = qobject_cast<HbAction *>(iLoader.findObject(SEARCH_CHANNELS_VIEW_OBJECT_EXIT_ACTION)); |
243 } |
141 |
|
142 connect(settings, SIGNAL(triggered()), this, SLOT(launchSettingsView())); |
|
143 connect(openWebAdressAction, SIGNAL(triggered()), this, SLOT(openWebAddress())); |
|
144 connect(helpAction, SIGNAL(triggered()), this, SLOT(helpAction())); |
|
145 connect(exitAction, SIGNAL(triggered()), iApplication, SIGNAL(quit())); |
|
146 } |
|
147 |
|
148 |
|
149 void IRSearchChannelsView::initToolBar() |
|
150 { |
|
151 HbToolBar *viewToolBar = qobject_cast<HbToolBar *>(iLoader.findObject(SEARCH_CHANNELS_VIEW_OBJECT_TOOLBAR)); |
|
152 |
|
153 QActionGroup *actionGroup = new QActionGroup(this); |
|
154 |
|
155 iCollectionsAction = qobject_cast<HbAction *>(iLoader.findObject(SEARCH_CHANNELS_VIEW_OBJECT_COLLECTION_ACTION)); |
|
156 iCollectionsAction->setActionGroup(actionGroup); |
|
157 |
|
158 iFavoritesAction = qobject_cast<HbAction *>(iLoader.findObject(SEARCH_CHANNELS_VIEW_OBJECT_FAVORITES_ACTION)); |
|
159 iFavoritesAction->setActionGroup(actionGroup); |
|
160 |
|
161 iGenresAction = qobject_cast<HbAction *>(iLoader.findObject(SEARCH_CHANNELS_VIEW_OBJECT_GENRES_ACTION)); |
|
162 iGenresAction->setActionGroup(actionGroup); |
|
163 |
|
164 iSearchAction = qobject_cast<HbAction *>(iLoader.findObject(SEARCH_CHANNELS_VIEW_OBJECT_SEARCH_ACTION)); |
|
165 iSearchAction->setActionGroup(actionGroup); |
|
166 |
|
167 connect(iCollectionsAction, SIGNAL(triggered()), this, SLOT(collectionsActionClicked())); |
|
168 connect(iFavoritesAction, SIGNAL(triggered()), this, SLOT(favoritesActionClicked())); |
|
169 connect(iGenresAction, SIGNAL(triggered()), iApplication, SLOT(loadGenre())); |
|
170 |
|
171 iSearchAction->setChecked(true); |
|
172 } |
|
173 |
|
174 void IRSearchChannelsView::collectionsActionClicked() |
|
175 { |
|
176 getViewManager()->activateView(EIRView_MainView); |
|
177 } |
|
178 |
|
179 void IRSearchChannelsView::favoritesActionClicked() |
|
180 { |
|
181 getViewManager()->activateView(EIRView_FavoritesView); |
|
182 } |
|
183 |
|
184 void IRSearchChannelsView::startSearch(bool aBool) |
|
185 { |
|
186 Q_UNUSED(aBool); |
|
187 setUseNetworkReason(EIR_UseNetwork_StartSearch); |
|
188 if (false == iApplication->verifyNetworkConnectivity()) |
|
189 { |
|
190 return; |
|
191 } |
|
192 setUseNetworkReason(EIR_UseNetwork_NoReason); |
|
193 |
|
194 QString str = iSearchCombobox->currentText(); |
|
195 str = str.trimmed(); |
|
196 |
|
197 if( "" == str ) |
|
198 { |
|
199 return; |
|
200 } |
|
201 |
|
202 bool exists = iDB->isAlreadyExist(str); |
|
203 if (!exists) |
|
204 { |
|
205 iDB->addOneCriteria(str); |
|
206 } |
|
207 |
|
208 IRStationsView *searchResultView = |
|
209 static_cast<IRStationsView*> (getViewManager()->getView( |
|
210 EIRView_SearchResultView, true)); |
|
211 |
|
212 searchResultView->loadSearchResult(str); |
|
213 } |
|
214 |
|
215 |
|
216 void IRSearchChannelsView::searchBoxTextChanged(const QString &aString) |
|
217 { |
|
218 QString str = aString.trimmed(); |
|
219 if( "" != str ) |
|
220 { |
|
221 iSearchButton->setEnabled(true); |
|
222 } |
|
223 else |
|
224 { |
|
225 iSearchButton->setEnabled(false); |
|
226 } |
|
227 } |
|
228 |
244 |
229 void IRSearchChannelsView::cancelRequest() |
245 void IRSearchChannelsView::cancelRequest() |
230 { |
246 { |
231 iIsdsClient->isdsCancelRequest(); |
247 iSearchState = ESearch_init; |
|
248 iIsdsClient->isdsCancelRequest(); |
|
249 stopSearchingAnimation(); |
|
250 //the following will remove into the stopSearchingAnimation() function |
|
251 closeSearchingDialog(); |
232 } |
252 } |
233 |
253 |
234 void IRSearchChannelsView::networkRequestNotified(IRQNetworkEvent aEvent) |
254 void IRSearchChannelsView::networkRequestNotified(IRQNetworkEvent aEvent) |
235 { |
255 { |
236 if (getViewManager()->currentView() != this) |
256 if (getViewManager()->currentView() != this) |
239 } |
259 } |
240 |
260 |
241 switch (aEvent) |
261 switch (aEvent) |
242 { |
262 { |
243 case EIRQNetworkConnectionEstablished: |
263 case EIRQNetworkConnectionEstablished: |
244 iApplication->closeConnectingDialog(); |
264 |
245 if(EIR_UseNetwork_StartSearch == getUseNetworkReason()) |
265 if(EIR_UseNetwork_StartSearch == getUseNetworkReason()) |
246 { |
266 { |
247 QString str = iSearchCombobox->currentText(); |
267 Q_ASSERT( !iKeyText.isEmpty() ); |
248 str = str.trimmed(); |
268 iIsdsClient->isdsSearchRequest(iKeyText); |
249 |
|
250 if ("" == str) |
|
251 { |
|
252 return; |
|
253 } |
|
254 |
|
255 bool exists = iDB->isAlreadyExist(str); |
|
256 if (!exists) |
|
257 { |
|
258 iDB->addOneCriteria(str); |
|
259 } |
|
260 |
|
261 IRStationsView *searchResultView = static_cast<IRStationsView*> (getViewManager()->getView( |
|
262 EIRView_SearchResultView, true)); |
|
263 |
|
264 searchResultView->loadSearchResult(str); |
|
265 } |
269 } |
266 |
270 else if( EIR_UseNetwork_SelectItem == getUseNetworkReason() ) |
|
271 { |
|
272 handleItemSelected(); |
|
273 } |
267 setUseNetworkReason(EIR_UseNetwork_NoReason); |
274 setUseNetworkReason(EIR_UseNetwork_NoReason); |
268 break; |
275 break; |
269 |
276 |
270 default: |
277 default: |
271 iSearchAction->setChecked(true); |
278 stopSearchingAnimation(); |
|
279 //the following will remove into the stopSearchingAnimation() function |
|
280 closeSearchingDialog(); |
|
281 setUseNetworkReason(EIR_UseNetwork_NoReason); |
|
282 iSearchState = ESearch_init; |
272 break; |
283 break; |
273 } |
284 } |
274 } |
285 } |
275 |
286 |
276 void IRSearchChannelsView::comboboxClicked() |
287 void IRSearchChannelsView::searchTextAlready(const QString& aSearchCriteria) |
277 { |
288 { |
278 if( iFirstTime ) |
289 iKeyText = aSearchCriteria.trimmed(); |
279 { |
290 |
280 iSearchCombobox->clearEditText(); |
291 if( iKeyText.isEmpty() ) |
281 iFirstTime = false; |
292 { |
|
293 //show some error info here to let user input some criteria |
|
294 return; |
|
295 } |
|
296 |
|
297 setUseNetworkReason(EIR_UseNetwork_StartSearch); |
|
298 if (false == iApplication->verifyNetworkConnectivity(hbTrId("txt_common_info_searching"))) |
|
299 { |
|
300 switch2SearchingState(); |
|
301 return; |
|
302 } |
|
303 |
|
304 setUseNetworkReason(EIR_UseNetwork_NoReason); |
|
305 switch2SearchingState(); |
|
306 iIsdsClient->isdsSearchRequest(iKeyText); |
|
307 createSearchingDialog(); |
|
308 } |
|
309 |
|
310 |
|
311 |
|
312 void IRSearchChannelsView::operationException(IRQError aError) |
|
313 { |
|
314 iApplication->closeConnectingDialog(); |
|
315 iPlayController->closeBufferingDialog(); |
|
316 closeSearchingDialog(); |
|
317 stopSearchingAnimation(); |
|
318 iSearchState = ESearch_init; |
|
319 |
|
320 QString errStr; |
|
321 |
|
322 switch(aError) |
|
323 { |
|
324 case EIRQErrorNotFound: |
|
325 errStr = hbTrId("txt_irad_info_no_matching_stations_found"); |
|
326 break; |
|
327 default: |
|
328 errStr = hbTrId("txt_irad_info_failed_to_connect"); |
|
329 break; |
|
330 } |
|
331 popupNote(errStr, HbMessageBox::MessageTypeWarning); |
|
332 } |
|
333 |
|
334 void IRSearchChannelsView::clickItem(const QModelIndex&) |
|
335 { |
|
336 setUseNetworkReason(EIR_UseNetwork_SelectItem); |
|
337 if (false == iApplication->verifyNetworkConnectivity()) |
|
338 { |
|
339 return; |
|
340 } |
|
341 setUseNetworkReason(EIR_UseNetwork_NoReason); |
|
342 handleItemSelected(); |
|
343 } |
|
344 |
|
345 |
|
346 void IRSearchChannelsView::presetResponse(IRQPreset *aPreset) |
|
347 { |
|
348 delete iPreset; |
|
349 iPreset = aPreset; |
|
350 |
|
351 if (iPreset) |
|
352 { |
|
353 iPlayController->connectToChannel(iPreset,EIRQIsds); |
|
354 } |
|
355 } |
|
356 |
|
357 void IRSearchChannelsView::convertAnother() |
|
358 { |
|
359 iConvertTimer->stop(); |
|
360 int leftCount = iIconIndexArray.count(); |
|
361 |
|
362 if( leftCount > 0 ) |
|
363 { |
|
364 startConvert(iIconIndexArray[0]); |
|
365 } |
|
366 } |
|
367 |
|
368 void IRSearchChannelsView::dataChanged() |
|
369 { |
|
370 iApplication->closeConnectingDialog(); |
|
371 stopSearchingAnimation(); |
|
372 |
|
373 //the following will remove into the stopSearchingAnimation() function |
|
374 closeSearchingDialog(); |
|
375 switch2SearchedState(); |
|
376 iListView->reset(); |
|
377 iListView->setCurrentIndex(iChannelModel->index(0)); |
|
378 iListView->scrollTo(iChannelModel->index(0)); |
|
379 GraphicsItemFlags flags = iListView->flags(); |
|
380 bool focusEnable = flags & QGraphicsItem::ItemIsFocusable; |
|
381 if( focusEnable ) |
|
382 { |
|
383 //we move the focus to the listview and the search panel will |
|
384 //hide the virtual keyboard at the same time |
|
385 iListView->setFocus(Qt::OtherFocusReason); |
|
386 } |
|
387 |
|
388 iIconIndexArray.clear(); |
|
389 //initialize the iconindices |
|
390 for (int i = 0; i < iChannelModel->rowCount(); ++i) |
|
391 { |
|
392 if (iChannelModel->imageUrl(i) != "") |
|
393 { |
|
394 iIconIndexArray.append(i); |
|
395 } |
|
396 } |
|
397 |
|
398 if( iIconIndexArray.count() > 0 ) |
|
399 { |
|
400 iConvertTimer->start(); |
|
401 } |
|
402 } |
|
403 |
|
404 void IRSearchChannelsView::startConvert(int aIndex) |
|
405 { |
|
406 QString url = iChannelModel->imageUrl(aIndex); |
|
407 |
|
408 IRQPreset tempPreset; |
|
409 tempPreset.imgUrl = url; |
|
410 tempPreset.type = IRQPreset::EIsds; |
|
411 |
|
412 bool cached = iIsdsClient->isdsIsLogoCached(&tempPreset, KBitmapSize, KBitmapSize); |
|
413 |
|
414 if( !cached ) |
|
415 { |
|
416 bool network = iNetworkController->getNetworkStatus(); |
|
417 //if the network is not ready, some exception happens and we don't get the logos |
|
418 //for they are not so important. |
|
419 if( !network ) |
|
420 { |
|
421 return; |
|
422 } |
|
423 } |
|
424 |
|
425 iIsdsClient->isdsLogoDownSendRequest(&tempPreset, 0, KBitmapSize, KBitmapSize); |
|
426 } |
|
427 |
|
428 //if the logo is downloaded ok |
|
429 void IRSearchChannelsView::presetLogoDownload(IRQPreset* aPreset) |
|
430 { |
|
431 if( NULL == aPreset ) |
|
432 { |
|
433 presetLogoDownloadError(); |
|
434 return; |
|
435 } |
|
436 |
|
437 |
|
438 delete iLogoPreset; |
|
439 iLogoPreset = aPreset; |
|
440 |
|
441 if (iLogoPreset->logoData != KNullDesC8) |
|
442 { |
|
443 QPixmap tempMap; |
|
444 const unsigned char * logoData = iLogoPreset->logoData.Ptr(); |
|
445 bool ret = tempMap.loadFromData(logoData, iLogoPreset->logoData.Length()); |
|
446 QIcon convertIcon(tempMap); |
|
447 |
|
448 if( ret ) |
|
449 { |
|
450 HbIcon *hbIcon = new HbIcon(convertIcon); |
|
451 int index = iIconIndexArray[0]; |
|
452 iChannelModel->setLogo(hbIcon, index); |
|
453 iIconIndexArray.removeAt(0); |
|
454 int leftCount = iIconIndexArray.count(); |
|
455 if( leftCount > 0 ) |
|
456 { |
|
457 iConvertTimer->start(); |
|
458 } |
|
459 return; |
|
460 } |
|
461 } |
|
462 |
|
463 presetLogoDownloadError(); |
|
464 } |
|
465 |
|
466 //if the logo download fails |
|
467 void IRSearchChannelsView::presetLogoDownloadError() |
|
468 { |
|
469 // if the logo download fails, try to download the next |
|
470 iIconIndexArray.removeAt(0); |
|
471 int leftCount = iIconIndexArray.count(); |
|
472 if( leftCount > 0 ) |
|
473 { |
|
474 iConvertTimer->start(); |
282 } |
475 } |
283 } |
476 } |
284 |
477 |
285 |
478 TIRHandleResult IRSearchChannelsView::handleCommand(TIRViewCommand aCommand, TIRViewCommandReason aReason) |
286 void IRSearchChannelsView::launchSettingsView() |
479 { |
287 { |
480 TIRHandleResult ret = IRBaseView::handleCommand(aCommand, aReason); |
288 getViewManager()->activateView(EIRView_SettingsView); |
481 |
289 } |
482 switch (aCommand) |
290 |
483 { |
291 void IRSearchChannelsView::openWebAddress() |
484 case EIR_ViewCommand_ACTIVATED: |
292 { |
485 //wether to start logo downloading when activated needs more discussing and testing, future. |
293 getViewManager()->activateView(EIRView_OpenWebAddressView); |
486 iIconIndexArray.clear(); |
294 } |
487 connectIsdsClient(); |
295 |
488 break; |
296 void IRSearchChannelsView::gotoNowPlaying() |
489 |
297 { |
490 case EIR_ViewCommand_DEACTIVATE: |
298 Q_ASSERT(iPlayController->isPlaying()); |
491 disconnectIsdsClient(); |
299 |
492 iIsdsClient->isdsCancelRequest(); |
300 getViewManager()->activateView(EIRView_PlayingView); |
493 iConvertTimer->stop(); |
301 } |
494 iIsdsClient->isdsLogoDownCancelTransaction(); |
302 |
495 break; |
303 void IRSearchChannelsView::addBanner(const QString &aText) |
496 |
304 { |
497 default: |
305 iLoader.load(SEARCH_CHANNELS_VIEW_LAYOUT_FILENAME, SEARCH_CHANNELS_VIEW_WITH_PLAYINGBANNER_SECTION); |
498 break; |
306 iBannerLabel->setText(aText); |
499 } |
307 iBannerLabel->setLoopCount(-1); |
500 |
308 } |
501 return ret; |
309 |
502 } |
310 void IRSearchChannelsView::metaDataAvailable(IRQMetaData* aMetaData) |
503 |
311 { |
504 |
312 if (!aMetaData) |
505 |
313 { |
506 |
314 return; |
507 |
315 } |
|
316 |
|
317 const QString artistSongName = aMetaData->getArtistSongName(); |
|
318 if ("" != artistSongName.trimmed() && "-" != artistSongName.trimmed()) |
|
319 { |
|
320 addBanner(aMetaData->getArtistSongName()); |
|
321 } |
|
322 else |
|
323 { |
|
324 //set the banner text as station name |
|
325 IRQPreset *nowPlayingPreset = iPlayController->getNowPlayingPreset(); |
|
326 Q_ASSERT(nowPlayingPreset); |
|
327 addBanner(nowPlayingPreset->name); |
|
328 } |
|
329 } |
|
330 |
|
331 void IRSearchChannelsView::updateView() |
|
332 { |
|
333 if (iPlayController->isPlaying()) |
|
334 { |
|
335 IRQMetaData *metaData = iPlayController->getMetaData(); |
|
336 if (metaData && "" != metaData->getArtistSongName().trimmed() && |
|
337 "-" != metaData->getArtistSongName().trimmed()) |
|
338 { |
|
339 //set the banner text as song name |
|
340 addBanner(metaData->getArtistSongName()); |
|
341 } |
|
342 else |
|
343 { |
|
344 //set the banner text as station name |
|
345 IRQPreset *nowPlayingPreset = iPlayController->getNowPlayingPreset(); |
|
346 Q_ASSERT(nowPlayingPreset); |
|
347 addBanner(nowPlayingPreset->name); |
|
348 } |
|
349 } |
|
350 else |
|
351 { |
|
352 removeBanner(); |
|
353 } |
|
354 } |
|
355 |
|
356 void IRSearchChannelsView::removeBanner() |
|
357 { |
|
358 iBannerLabel->stopAnimation(); |
|
359 iLoader.load(SEARCH_CHANNELS_VIEW_LAYOUT_FILENAME,SEARCH_CHANNELS_VIEW_NO_PLAYINGBANNER_SECTION); |
|
360 } |
|
361 |
|
362 void IRSearchChannelsView::createDB() |
|
363 { |
|
364 iDB = new IRSearchCriteriaDB(); |
|
365 QStringList strList; |
|
366 iDB->getAllCriteria(strList); |
|
367 QStringListModel* comboboxListModel = new QStringListModel(iSearchCombobox); |
|
368 iSearchCombobox->setModel(comboboxListModel); |
|
369 comboboxListModel->setStringList(strList); |
|
370 connect(iDB, SIGNAL(dataAdded()),this, SLOT(dbDataChanged())); |
|
371 } |
|
372 |
|
373 void IRSearchChannelsView::dbDataChanged() |
|
374 { |
|
375 QStringList strList; |
|
376 bool ret = iDB->getAllCriteria(strList); |
|
377 |
|
378 if (ret) |
|
379 { |
|
380 (static_cast<QStringListModel*> (iSearchCombobox->model()))->setStringList( |
|
381 strList); |
|
382 } |
|
383 } |
|
384 |
|