197 |
183 |
198 connect( mSoftKeyBack, SIGNAL( triggered() ), this, SLOT( back() ) ); |
184 connect( mSoftKeyBack, SIGNAL( triggered() ), this, SLOT( back() ) ); |
199 connect( mSongData, SIGNAL( albumArtReady() ), this, SLOT( albumArtChanged() ) ); |
185 connect( mSongData, SIGNAL( albumArtReady() ), this, SLOT( albumArtChanged() ) ); |
200 connect( mSongData, SIGNAL( playbackInfoChanged() ), this, SLOT( handlePlaybackInfoChanged() ) ); |
186 connect( mSongData, SIGNAL( playbackInfoChanged() ), this, SLOT( handlePlaybackInfoChanged() ) ); |
201 connect( mSongData, SIGNAL( songDetailInfoChanged() ), this, SLOT( songDetailInfoChanged() ) ); |
187 connect( mSongData, SIGNAL( songDetailInfoChanged() ), this, SLOT( songDetailInfoChanged() ) ); |
|
188 connect( mDetailList, SIGNAL( pressed( HbListWidgetItem * ) ), this, SLOT( handleListItemSelected( HbListWidgetItem * ) ) ); |
202 connect( mSongDetailsGroupBox, SIGNAL( toggled( bool ) ), this, SLOT( handleDetailsGroupBoxToggled( bool ) ) ); |
189 connect( mSongDetailsGroupBox, SIGNAL( toggled( bool ) ), this, SLOT( handleDetailsGroupBoxToggled( bool ) ) ); |
203 connect( mInspireMeGroupBox, SIGNAL( toggled( bool ) ), this, SLOT( handleInspireMeGroupBoxToggled( bool ) ) ); |
190 connect( mInspireMeGroupBox, SIGNAL( toggled( bool ) ), this, SLOT( handleInspireMeGroupBoxToggled( bool ) ) ); |
204 connect( mMpQueryManager, SIGNAL( networkError() ), this ,SLOT( handleNetworkError() ) ); |
191 connect( mMpQueryManager, SIGNAL(inspireMeItemsMetadataRetrieved()), this, SLOT(renderInspireMeMetadata())); |
205 connect( mMpQueryManager, SIGNAL(searchUrlRetrieved(const QString&)), this, SLOT(updateSharedData(const QString&))); |
192 connect( mMpQueryManager, SIGNAL(inspireMeItemAlbumArtReady()), this, SLOT(renderInspireMeAlbumArts())); |
206 connect( mMpQueryManager, SIGNAL(recommendationAlbumArtsReady()), this, SLOT(RenderInspireMeGroupBox())); |
193 connect( mMpQueryManager, SIGNAL(localMusicStoreRetrieved(bool)), this, SLOT(queryInspireMe(bool)), Qt::QueuedConnection); |
207 |
194 connect( mMpQueryManager, SIGNAL(localMusicStoreRetrievalError()), this, SLOT(abortInspireMeProcess())); |
208 #ifdef SHARE_FUNC_ENABLED |
195 connect( mMpQueryManager, SIGNAL(inspireMeItemsRetrievalError()), this, SLOT(queryLocalMusicStore()), Qt::QueuedConnection); |
209 connect( mShareButton, SIGNAL( clicked() ), this, SLOT( share() ) ); |
196 |
210 |
197 TX_EXIT |
211 // Preload the share popup |
198 } |
212 preloadShareDialog(); |
199 |
213 #endif |
200 void MpDetailsView::queryLocalMusicStore() |
214 TX_EXIT |
201 { |
|
202 TX_ENTRY |
|
203 mMpQueryManager->reset(); |
|
204 mMpQueryManager->queryLocalMusicStore(); |
|
205 TX_EXIT |
215 } |
206 } |
216 |
207 |
217 /*! |
208 /*! |
218 Activates the details view. |
209 Activates the details view. |
219 */ |
210 */ |
220 void MpDetailsView::activateView() |
211 void MpDetailsView::activateView() |
221 { |
212 { |
222 TX_ENTRY |
213 TX_ENTRY |
223 setNavigationAction( mSoftKeyBack ); |
214 setNavigationAction( mSoftKeyBack ); |
224 mMpEngine->retrieveSong(); |
|
225 |
215 |
226 mActivated = true; |
216 mActivated = true; |
227 mInspireMeOpen = MpSettingsManager::inspireMe(); |
217 TX_LOG_ARGS( "InspireMeVal: " << MpSettingsManager::inspireMe() ); |
228 mSongDetailsGbOpen = MpSettingsManager::songDetailsGb(); |
218 TX_LOG_ARGS( "SongDetailsGbVal: " << MpSettingsManager::songDetailsGb() ); |
229 TX_LOG_ARGS( "InspireMeVal: " << mInspireMeOpen ); |
219 mInspireMeGroupBox->setCollapsed(!MpSettingsManager::inspireMe()); |
230 TX_LOG_ARGS( "SongDetailsGbVal: " << mSongDetailsGbOpen ); |
220 mSongDetailsGroupBox->setCollapsed(!MpSettingsManager::songDetailsGb()); |
231 mInspireMeGroupBox->setCollapsed(!mInspireMeOpen); |
|
232 mSongDetailsGroupBox->setCollapsed(!mSongDetailsGbOpen); |
|
233 TX_EXIT |
221 TX_EXIT |
234 } |
222 } |
235 |
223 |
236 /*! |
224 /*! |
237 Deactivates the details view. |
225 Deactivates the details view. |
238 */ |
226 */ |
239 void MpDetailsView::deactivateView() |
227 void MpDetailsView::deactivateView() |
240 { |
228 { |
241 TX_ENTRY |
229 TX_ENTRY |
242 if (mInspireMeGroupBox->isCollapsed() ) { |
230 saveGroupBoxStates(); |
243 MpSettingsManager::setInspireMe(false); |
|
244 } else { |
|
245 MpSettingsManager::setInspireMe(true); |
|
246 } |
|
247 |
|
248 if (mSongDetailsGroupBox->isCollapsed() ) { |
|
249 MpSettingsManager::setSongDetailsGb(false); |
|
250 } else { |
|
251 MpSettingsManager::setSongDetailsGb(true); |
|
252 } |
|
253 |
|
254 setNavigationAction( 0 ); |
231 setNavigationAction( 0 ); |
255 mActivated = false; |
232 mActivated = false; |
256 TX_EXIT |
233 TX_EXIT |
257 } |
234 } |
258 |
235 |
|
236 void MpDetailsView::saveGroupBoxStates() |
|
237 { |
|
238 TX_ENTRY |
|
239 if (mInspireMeGroupBox->isCollapsed() ) { |
|
240 MpSettingsManager::setInspireMe(false); |
|
241 } |
|
242 else { |
|
243 MpSettingsManager::setInspireMe(true); |
|
244 } |
|
245 |
|
246 if (mSongDetailsGroupBox->isCollapsed() ) { |
|
247 MpSettingsManager::setSongDetailsGb(false); |
|
248 } |
|
249 else { |
|
250 MpSettingsManager::setSongDetailsGb(true); |
|
251 } |
|
252 TX_EXIT |
|
253 } |
|
254 |
259 /*! |
255 /*! |
260 Setup the menu. |
256 Setup the menu. |
261 */ |
257 */ |
262 void MpDetailsView::setupMenu() |
258 void MpDetailsView::setupMenu() |
263 { |
259 { |
289 } |
285 } |
290 |
286 |
291 /*! |
287 /*! |
292 Slot to handle network error. |
288 Slot to handle network error. |
293 */ |
289 */ |
294 void MpDetailsView::handleNetworkError() |
290 void MpDetailsView::abortInspireMeProcess() |
295 { |
291 { |
296 TX_ENTRY |
292 TX_ENTRY |
|
293 mInspireMeProgressBar->hide(); |
|
294 mInspireMeGroupBox->setCollapsed( true ); |
297 mInspireMeQueryOngoing = false; |
295 mInspireMeQueryOngoing = false; |
298 mInspireMeQueryRendered = false; |
296 mInspireMeQueryRendered = false; |
299 clearInspireMe(); |
297 // ensure that we dont get callbacks from previous queries. Especially true, |
300 mInspireMeGroupBox->setCollapsed( true ); |
298 // if details view is actived with a quick song change again |
|
299 mMpQueryManager->reset(); |
|
300 mInspireList->clear(); |
301 TX_EXIT |
301 TX_EXIT |
302 } |
302 } |
303 |
303 |
304 /*! |
304 /*! |
305 Render inspireme groupbox after album arts downloaded |
305 Render inspireme groupbox after album arts downloaded |
306 */ |
306 */ |
307 void MpDetailsView::RenderInspireMeGroupBox() |
307 void MpDetailsView::renderInspireMeMetadata() |
308 { |
308 { |
309 TX_ENTRY |
309 TX_ENTRY |
310 mInspireMeQueryOngoing = false; |
310 mInspireMeQueryOngoing = false; |
311 mInspireMeQueryRendered = true; |
311 mInspireMeQueryRendered = true; |
312 mInspireMeProgressBar->hide(); |
312 mInspireMeProgressBar->hide(); |
313 if( mMpQueryManager->recommendationAlbumArtsMap().count() ) { |
313 if( mMpQueryManager->recommendationsCount() ) { |
314 TX_LOG_ARGS( "There are recommendations." ) |
314 TX_LOG_ARGS( "There are recommendations." ) |
315 // we have recommendations |
315 // we have recommendations |
316 for ( int i = 0; i < KRecommendationCount; i++ ) { |
316 for ( int i = 0; i < mMpQueryManager->recommendationsCount(); ++i ) { |
317 // configure the layout properties |
317 // configure the layout properties |
318 if(!mInspireList->count()) { |
318 if(!mInspireList->count()) { |
319 // we havent configured the prototype before |
319 // we havent configured the prototype before |
320 HbListViewItem *prototype = mInspireList->listItemPrototype(); |
320 HbListViewItem *prototype = mInspireList->listItemPrototype(); |
321 prototype->setGraphicsSize( HbListViewItem::LargeIcon ); |
321 prototype->setGraphicsSize( HbListViewItem::LargeIcon ); |
322 } |
322 } |
323 // create the item |
323 // create the item |
324 HbListWidgetItem *inspireMeItem = new HbListWidgetItem(); |
324 HbListWidgetItem *inspireMeItem = new HbListWidgetItem(); |
325 HbIcon icon( QIcon( mMpQueryManager->recommendationAlbumArtsMap().value(mMpQueryManager->recommendationAlbumArtsLink().at( i ) ) ) ); |
325 inspireMeItem->setIcon( mMpQueryManager->recommendedAlbumArt( i )); |
326 inspireMeItem->setIcon( icon ); |
326 inspireMeItem->setText( mMpQueryManager->recommendedSong( i ) ); |
327 inspireMeItem->setText( mMpQueryManager->recommendationSongs().at( i ) ); |
327 inspireMeItem->setSecondaryText( mMpQueryManager->recommendedArtist( i ) ); |
328 inspireMeItem->setSecondaryText( mMpQueryManager->recommendationArtists().at( i ) ); |
|
329 mInspireList->addItem( inspireMeItem ); |
328 mInspireList->addItem( inspireMeItem ); |
330 } |
329 } |
331 } |
330 } |
332 else { |
331 else { |
333 TX_LOG_ARGS( "There is NO recommendation." ) |
332 TX_LOG_ARGS( "There are NO recommendations" ) |
334 // we dont have recommendations |
333 // we dont have recommendations |
335 // we havent configured the prototype before |
334 // we havent configured the prototype before |
336 HbListViewItem *prototype = mInspireList->listItemPrototype(); |
335 HbListViewItem *prototype = mInspireList->listItemPrototype(); |
337 const int maxTextRowCount = 20; |
336 const int maxTextRowCount = 20; |
338 const int minTextRowCount = 1; |
337 const int minTextRowCount = 1; |
339 prototype->setSecondaryTextRowCount(minTextRowCount,maxTextRowCount); |
338 prototype->setSecondaryTextRowCount(minTextRowCount,maxTextRowCount); |
340 |
339 |
341 HbListWidgetItem *inspireMeItem = new HbListWidgetItem(); |
340 HbListWidgetItem *inspireMeItem = new HbListWidgetItem(); |
342 QString info(tr("There are no recommendations for this track, but you can always discover new music on Ovi")); |
341 inspireMeItem->setSecondaryText( hbTrId( "txt_mus_dblist_val_there_are_no_recommendations" ) ); |
343 inspireMeItem->setText( QString( " " ) ); |
|
344 inspireMeItem->setSecondaryText( info ); |
|
345 mInspireList->addItem( inspireMeItem ); |
342 mInspireList->addItem( inspireMeItem ); |
346 } |
343 } |
347 |
344 |
348 TX_EXIT |
345 TX_EXIT |
349 } |
346 } |
350 |
347 |
351 bool MpDetailsView::canQueryRecommendations() const |
348 void MpDetailsView::renderInspireMeAlbumArts() |
|
349 { |
|
350 TX_ENTRY |
|
351 for( int i = 0; i < mInspireList->count(); ++i) { |
|
352 mInspireList->item(i)->setIcon( mMpQueryManager->recommendedAlbumArt( i ) ); |
|
353 } |
|
354 TX_EXIT |
|
355 } |
|
356 |
|
357 bool MpDetailsView::isMetadata() const |
352 { |
358 { |
353 bool result = ( ( !mSongData->album().isEmpty() ) || |
359 bool result = ( ( !mSongData->album().isEmpty() ) || |
354 ( !mSongData->artist().isEmpty() ) ) && |
360 ( !mSongData->artist().isEmpty() ) ); |
355 !( mInspireMeGroupBox->isCollapsed() ); |
361 TX_LOG_ARGS( "Inspire Me Query metadata available:" << result ); |
356 TX_LOG_ARGS( "Can query recommendations:" << result ); |
|
357 return result; |
362 return result; |
358 } |
363 } |
359 |
364 |
360 bool MpDetailsView::canQuerySharePlayerLink() const |
|
361 { |
|
362 bool result = ( !mSongData->title().isEmpty() ) && |
|
363 ( !mSongData->artist().isEmpty() ) ; |
|
364 TX_LOG_ARGS( "Can query share player link:" << result ); |
|
365 return result; |
|
366 } |
|
367 |
|
368 /*! |
365 /*! |
369 Slot to handle basic song information |
366 Slot to handle basic song information |
370 */ |
367 */ |
371 void MpDetailsView::handlePlaybackInfoChanged() |
368 void MpDetailsView::handlePlaybackInfoChanged() |
372 { |
369 { |
373 TX_ENTRY |
370 TX_ENTRY |
374 mMpQueryManager->clearNetworkReplies(); |
371 // ensure that we dont get callbacks from previous queries. Especially true, |
375 clearInspireMe(); |
372 // if details view is actived with a quick song change again |
|
373 mMpQueryManager->reset(); |
|
374 mInspireList->clear(); |
376 mInspireMeQueryRendered = false; |
375 mInspireMeQueryRendered = false; |
377 |
376 |
378 // Clear the song data link until new query has been made. |
377 // Clear the song data link until new query has been made. |
379 mSongData->setLink( "" ); |
378 mSongData->setLink( "" ); |
380 |
379 |
381 if ( !mSongData->title().isEmpty () ) { |
380 if ( !mSongData->title().isEmpty () ) { |
382 mSongText->setPlainText( mSongData->title() ); |
381 mSongText->setPlainText( mSongData->title() ); |
383 } else { |
382 } |
|
383 else { |
384 mSongText->setPlainText( mSongData->fileName() ); |
384 mSongText->setPlainText( mSongData->fileName() ); |
385 } |
385 } |
386 |
386 |
387 if ( !mSongData->album().isEmpty () ) { |
387 if ( !mSongData->album().isEmpty () ) { |
388 mAlbumText->setPlainText( mSongData->album() ); |
388 mAlbumText->setPlainText( mSongData->album() ); |
389 } else { |
389 } |
390 mAlbumText->setPlainText( tr( "Unknown") ); |
390 else { |
|
391 mAlbumText->setPlainText( hbTrId( "txt_mus_other_unknown7") ); |
391 } |
392 } |
392 |
393 |
393 if ( !mSongData->artist().isEmpty() ) { |
394 if ( !mSongData->artist().isEmpty() ) { |
394 mArtistText->setPlainText( mSongData->artist() ); |
395 mArtistText->setPlainText( mSongData->artist() ); |
395 } else { |
396 } |
396 mArtistText->setPlainText( tr( "Unknown") ); |
397 else { |
397 } |
398 mArtistText->setPlainText( hbTrId( "txt_mus_other_unknown6") ); |
398 |
399 } |
399 if (canQuerySharePlayerLink() ) { |
400 |
400 mMpQueryManager->queryLocalMusicStore(mSongData->artist(),mSongData->album(),mSongData->title()); |
401 if(!mInspireMeGroupBox->isCollapsed()) { |
401 } |
402 startInspireMe(); |
402 |
403 } |
403 if (canQueryRecommendations()) { |
404 TX_EXIT |
404 // start inspire me area progress bar |
405 } |
405 // TODO: currently, till we get to this callback from MPX the bar not shown |
406 |
406 // TODO: check if inspireMe is ON, if not, dont show |
407 void MpDetailsView::startInspireMe() |
|
408 { |
|
409 TX_ENTRY |
|
410 if(isMetadata()) { |
|
411 // show progress bar, start store query or inspire me query process |
407 mInspireMeProgressBar->show(); |
412 mInspireMeProgressBar->show(); |
408 mMpQueryManager->queryInspireMeItems(mSongData->artist(),mSongData->album(),mSongData->title()); |
|
409 mInspireMeQueryOngoing = true; |
413 mInspireMeQueryOngoing = true; |
410 } |
414 if( mMpQueryManager->isLocalMusicStore() ) { |
411 else { |
415 mMpQueryManager->queryInspireMeItems(mSongData->artist(),mSongData->album(),mSongData->title()); |
412 // metadata to query for inspire me items not available |
416 } |
413 // show information note |
417 else { |
414 if (!mInspireMeGroupBox->isCollapsed()) |
418 // no local store information present |
415 RenderInspireMeGroupBox(); |
419 mMpQueryManager->queryLocalMusicStore(); |
416 } |
420 } |
417 TX_EXIT |
421 } |
418 } |
422 else { |
419 |
423 // no metadata. show no recommendations |
420 void MpDetailsView::clearInspireMe() |
424 renderInspireMeMetadata(); |
421 { |
425 } |
422 TX_ENTRY |
426 TX_EXIT |
423 mInspireList->clear(); |
427 } |
424 mMpQueryManager->clearRecommendations(); |
428 |
425 TX_EXIT |
|
426 } |
|
427 /*! |
429 /*! |
428 Slot to handle detail song information |
430 Slot to handle detail song information |
429 */ |
431 */ |
430 void MpDetailsView::songDetailInfoChanged() |
432 void MpDetailsView::songDetailInfoChanged() |
431 { |
433 { |
432 TX_ENTRY |
434 TX_ENTRY |
433 mDetailList->clear(); |
435 mDetailList->clear(); |
434 |
436 |
435 if ( !mSongData->albumTrack().isNull() ) { |
437 if ( !mSongData->albumTrack().isNull() ) { |
436 HbListWidgetItem *item = new HbListWidgetItem(); |
438 HbListWidgetItem *item = new HbListWidgetItem(); |
437 item->setText( tr( "Song number" ) ); |
439 item->setText( hbTrId( "txt_mus_dblist_song_number" ) ); |
438 item->setSecondaryText( mSongData->albumTrack() ); |
440 item->setSecondaryText( mSongData->albumTrack() ); |
439 item->setEnabled( false ); |
441 item->setEnabled( false ); |
440 mDetailList->addItem( item ); |
442 mDetailList->addItem( item ); |
441 } |
443 } |
442 |
444 |
443 if ( !mSongData->year().isNull() ) { |
445 if ( !mSongData->year().isNull() ) { |
444 HbListWidgetItem *item = new HbListWidgetItem(); |
446 HbListWidgetItem *item = new HbListWidgetItem(); |
445 item->setText( tr( "Year" ) ); |
447 item->setText( hbTrId( "txt_mus_dblist_year" ) ); |
446 item->setSecondaryText( mSongData->year() ); |
448 item->setSecondaryText( mSongData->year() ); |
447 item->setEnabled( false ); |
449 item->setEnabled( false ); |
448 mDetailList->addItem( item ); |
450 mDetailList->addItem( item ); |
449 } |
451 } |
450 |
452 |
451 if ( !mSongData->genre().isNull() ) { |
453 if ( !mSongData->genre().isNull() ) { |
452 HbListWidgetItem *item = new HbListWidgetItem(); |
454 HbListWidgetItem *item = new HbListWidgetItem(); |
453 item->setText( tr( "Genre" ) ); |
455 item->setText( hbTrId( "txt_mus_dblist_genre" ) ); |
454 item->setSecondaryText( mSongData->genre() ); |
456 item->setSecondaryText( mSongData->genre() ); |
455 item->setEnabled( false ); |
457 item->setEnabled( false ); |
456 mDetailList->addItem( item ); |
458 mDetailList->addItem( item ); |
457 } |
459 } |
458 |
460 |
459 if ( !mSongData->composer().isNull() ) { |
461 if ( !mSongData->composer().isNull() ) { |
460 HbListWidgetItem *item = new HbListWidgetItem(); |
462 HbListWidgetItem *item = new HbListWidgetItem(); |
461 item->setText( tr( "Composer" ) ); |
463 item->setText( hbTrId( "txt_mus_dblist_composer" ) ); |
462 item->setSecondaryText( mSongData->composer() ); |
464 item->setSecondaryText( mSongData->composer() ); |
463 item->setEnabled( false ); |
465 item->setEnabled( false ); |
464 mDetailList->addItem( item ); |
466 mDetailList->addItem( item ); |
465 } |
467 } |
466 |
468 |
467 if ( !mSongData->fileName().isNull() ) { |
469 if ( !mSongData->fileName().isNull() ) { |
468 HbListWidgetItem *item = new HbListWidgetItem(); |
470 HbListWidgetItem *item = new HbListWidgetItem(); |
469 item->setText( tr( "File name" ) ); |
471 item->setText( hbTrId( "txt_mus_dblist_file_name" ) ); |
470 item->setSecondaryText( mSongData->fileName() ); |
472 item->setSecondaryText( mSongData->fileName() ); |
471 item->setEnabled( false ); |
473 item->setEnabled( false ); |
472 mDetailList->addItem( item ); |
474 mDetailList->addItem( item ); |
473 } |
475 } |
474 |
476 |
475 if ( !mSongData->mimeType().isNull() ) { |
477 if ( !mSongData->mimeType().isNull() ) { |
476 HbListWidgetItem *item = new HbListWidgetItem(); |
478 HbListWidgetItem *item = new HbListWidgetItem(); |
477 item->setText( tr( "Format" ) ); |
479 item->setText( hbTrId( "txt_mus_dblist_format" ) ); |
478 item->setSecondaryText( mSongData->mimeType() ); |
480 item->setSecondaryText( mSongData->mimeType() ); |
479 item->setEnabled( false ); |
481 item->setEnabled( false ); |
480 mDetailList->addItem( item ); |
482 mDetailList->addItem( item ); |
481 } |
483 } |
482 |
484 |
483 if ( !mSongData->duration().isNull() ) { |
485 if ( !mSongData->duration().isNull() ) { |
484 HbListWidgetItem *item = new HbListWidgetItem(); |
486 HbListWidgetItem *item = new HbListWidgetItem(); |
485 item->setText( tr( "Duration" ) ); |
487 item->setText( hbTrId( "txt_mus_dblist_duration" ) ); |
486 item->setSecondaryText( mSongData->duration() ); |
488 item->setSecondaryText( mSongData->duration() ); |
487 item->setEnabled( false ); |
489 item->setEnabled( false ); |
488 mDetailList->addItem( item ); |
490 mDetailList->addItem( item ); |
489 } |
491 } |
490 |
492 |
491 if ( !mSongData->bitRate().isNull() ) { |
493 if ( !mSongData->bitRate().isNull() ) { |
492 HbListWidgetItem *item = new HbListWidgetItem(); |
494 HbListWidgetItem *item = new HbListWidgetItem(); |
493 item->setText( tr( "Bitrate" ) ); |
495 item->setText( hbTrId( "txt_mus_dblist_bitrate" ) ); |
494 item->setSecondaryText( mSongData->bitRate().append( " Kbps" ) ); |
496 bool ok = false; |
|
497 int bitRate = mSongData->bitRate().toInt(&ok); |
|
498 TX_LOG_ARGS("Warning: If zero, bitrate is not read correctly. It wont show up in details" << ok); |
|
499 if(ok) { |
|
500 item->setSecondaryText( hbTrId("txt_mus_dblist_bitrate_val_ln_kbps", bitRate) ); |
|
501 } |
495 item->setEnabled( false ); |
502 item->setEnabled( false ); |
496 mDetailList->addItem( item ); |
503 mDetailList->addItem( item ); |
497 } |
504 } |
498 |
505 |
499 if ( !mSongData->sampleRate().isNull() ) { |
506 if ( !mSongData->sampleRate().isNull() ) { |
500 HbListWidgetItem *item = new HbListWidgetItem(); |
507 HbListWidgetItem *item = new HbListWidgetItem(); |
501 item->setText( tr( "Sampling rate" ) ); |
508 item->setText( hbTrId( "txt_mus_dblist_sampling_rate" ) ); |
502 item->setSecondaryText( mSongData->sampleRate().append( " hz" ) ); |
509 bool ok = false; |
|
510 int samplingRate = mSongData->sampleRate().toInt(&ok); |
|
511 TX_LOG_ARGS("Warning: If zero, sampling rate is not read correctly. It wont show up in details" << ok); |
|
512 if(ok) { |
|
513 item->setSecondaryText( hbTrId("txt_mus_dblist_sampling_rate_val_ln_hz", samplingRate) ); |
|
514 } |
503 item->setEnabled( false ); |
515 item->setEnabled( false ); |
504 mDetailList->addItem( item ); |
516 mDetailList->addItem( item ); |
505 } |
517 } |
506 |
518 |
507 if ( !mSongData->size().isNull() ) { |
519 if ( !mSongData->size().isNull() ) { |
508 HbListWidgetItem *item = new HbListWidgetItem(); |
520 HbListWidgetItem *item = new HbListWidgetItem(); |
509 item->setText( tr( "Size" ) ); |
521 item->setText( hbTrId( "txt_mus_dblist_size" ) ); |
510 item->setSecondaryText( mSongData->size().append( " MB" ) ); |
522 bool ok = false; |
|
523 long size = mSongData->size().toLong(&ok); // in bytes |
|
524 TX_LOG_ARGS("WARNING: If zero, Cant get song data size right. You wont see the size in details groupbox correctly" << ok ); |
|
525 if( size < KOneKiloByteInBytes) { |
|
526 // under 1 KB |
|
527 item->setSecondaryText( hbTrId("txt_mus_dblist_size_val_ln_b", size) ); |
|
528 } |
|
529 else if( size < KOneMegabyteInBytes ) { |
|
530 // under 1 MB |
|
531 size /= KOneKiloByteInBytes; // turn size into KB |
|
532 item->setSecondaryText( hbTrId("txt_mus_dblist_size_val_ln_kb", size) ); |
|
533 } |
|
534 else if( size < KOneGigaByteInBytes ) { |
|
535 // under 1 GB |
|
536 size /= KOneMegabyteInBytes; // turn size to MB |
|
537 item->setSecondaryText( hbTrId("txt_mus_dblist_size_val_ln_mb", size) ); |
|
538 } |
|
539 else { |
|
540 // 1 GB or higher |
|
541 size /= KOneGigaByteInBytes; // turn size to GB |
|
542 item->setSecondaryText( hbTrId("txt_mus_dblist_size_val_ln_gb", size) ); |
|
543 } |
511 item->setEnabled( false ); |
544 item->setEnabled( false ); |
512 mDetailList->addItem( item ); |
545 mDetailList->addItem( item ); |
513 } |
546 } |
514 |
547 |
515 if ( !mSongData->modified().isNull() ) { |
548 if ( !mSongData->modified().isNull() ) { |
516 HbListWidgetItem *item = new HbListWidgetItem(); |
549 HbListWidgetItem *item = new HbListWidgetItem(); |
517 item->setText( tr( "Modified" ) ); |
550 item->setText( hbTrId( "txt_mus_dblist_modified" ) ); |
518 item->setSecondaryText( mSongData->modified() ); |
551 item->setSecondaryText( mSongData->modified() ); |
519 item->setEnabled( false ); |
552 item->setEnabled( false ); |
520 mDetailList->addItem( item ); |
553 mDetailList->addItem( item ); |
521 } |
554 } |
522 |
555 |
523 if ( !mSongData->copyright().isNull() ) { |
556 if ( !mSongData->copyright().isNull() ) { |
524 HbListWidgetItem *item = new HbListWidgetItem(); |
557 HbListWidgetItem *item = new HbListWidgetItem(); |
525 item->setText( tr( "Copyright" ) ); |
558 item->setText( hbTrId( "txt_mus_dblist_copyright" ) ); |
526 item->setSecondaryText( mSongData->copyright() ); |
559 item->setSecondaryText( mSongData->copyright() ); |
527 item->setEnabled( false ); |
560 item->setEnabled( false ); |
528 mDetailList->addItem( item ); |
561 mDetailList->addItem( item ); |
529 } |
562 } |
530 |
563 |
531 if ( !mSongData->musicURL().isNull() ) { |
564 if ( !mSongData->musicURL().isNull() ) { |
532 HbListWidgetItem *item = new HbListWidgetItem(); |
565 HbListWidgetItem *item = new HbListWidgetItem(); |
533 item->setText( tr( "Web site" ) ); |
566 item->setText( hbTrId( "txt_mus_dblist_web_site" ) ); |
534 item->setSecondaryText( mSongData->musicURL() ); |
567 item->setSecondaryText( mSongData->musicURL() ); |
535 item->setEnabled( true ); |
568 item->setEnabled( true ); |
536 mDetailList->addItem( item ); |
569 mDetailList->addItem( item ); |
537 } |
570 } |
538 |
571 |
539 if ( mSongData->isDrmProtected() ) { |
572 if ( mSongData->isDrmProtected() ) { |
540 HbListWidgetItem *item = new HbListWidgetItem(); |
573 HbListWidgetItem *item = new HbListWidgetItem(); |
541 item->setText( tr( "Licences" ) ); |
574 item->setText( hbTrId( "txt_mus_dblist_licences" ) ); |
542 item->setSecondaryText( tr( "Click for details" ) ); |
575 item->setSecondaryText( hbTrId( "txt_mus_dblist_licences_val_click_for_details" ) ); |
543 item->setEnabled( true ); |
576 item->setEnabled( true ); |
544 mDetailList->addItem( item ); |
577 mDetailList->addItem( item ); |
545 } |
578 } |
546 |
579 |
547 TX_EXIT |
580 TX_EXIT |
563 TX_LOG_ARGS( "InspireMe is expanded." ) |
596 TX_LOG_ARGS( "InspireMe is expanded." ) |
564 mSongDetailsGroupBox->setCollapsed( true ); |
597 mSongDetailsGroupBox->setCollapsed( true ); |
565 if ( mInspireMeQueryOngoing ) { |
598 if ( mInspireMeQueryOngoing ) { |
566 TX_LOG_ARGS( "Query is ongoing " ) |
599 TX_LOG_ARGS( "Query is ongoing " ) |
567 mInspireMeProgressBar->show(); |
600 mInspireMeProgressBar->show(); |
568 } else { |
601 } |
|
602 else { |
569 TX_LOG_ARGS( "Query is NOT ongoing " ) |
603 TX_LOG_ARGS( "Query is NOT ongoing " ) |
570 if ( mInspireMeQueryRendered ) { |
604 if ( mInspireMeQueryRendered ) { |
571 TX_LOG_ARGS( "InspireMe is rendered already. " ) |
605 TX_LOG_ARGS( "InspireMe is rendered already. " ) |
572 mInspireMeProgressBar->hide(); |
606 mInspireMeProgressBar->hide(); |
573 } else { |
|
574 if ( canQueryRecommendations() ) { |
|
575 TX_LOG_ARGS( "InspireMe is NOT rendered yet but can query for recommendations. " ) |
|
576 mMpQueryManager->queryInspireMeItems(mSongData->artist(),mSongData->album(),mSongData->title()); |
|
577 mInspireMeProgressBar->show(); |
|
578 mInspireMeQueryOngoing = true; |
|
579 } else { |
|
580 TX_LOG_ARGS( "InspireMe is NOT rendered yet and CANNOT query for recommendations either. " ) |
|
581 RenderInspireMeGroupBox(); |
|
582 } |
|
583 } |
607 } |
584 } |
608 else { |
585 } else { |
609 startInspireMe(); |
|
610 } |
|
611 } |
|
612 } |
|
613 else { |
586 TX_LOG_ARGS( "InspireMe is collapsed." ) |
614 TX_LOG_ARGS( "InspireMe is collapsed." ) |
587 mInspireMeProgressBar->hide(); |
615 mInspireMeProgressBar->hide(); |
588 } |
616 } |
589 TX_EXIT |
617 TX_EXIT |
590 } |
618 } |
591 |
619 |
592 #ifdef SHARE_FUNC_ENABLED |
620 /*! |
593 /*! |
621 Slot to call when URL item in song details is pressed |
594 Slot to be called when share button is clicked |
|
595 */ |
|
596 void MpDetailsView::share() |
|
597 { |
|
598 TX_ENTRY |
|
599 createShareDialog(); |
|
600 if (canQuerySharePlayerLink() ) |
|
601 { |
|
602 mMpQueryManager->queryLocalMusicStore(mSongData->artist(),mSongData->album(),mSongData->title() ); |
|
603 } |
|
604 TX_EXIT |
|
605 } |
|
606 |
|
607 /*! |
|
608 Method to create the share dialog on demand. |
|
609 This will cause the share web view to be created and start loading. |
|
610 */ |
|
611 void MpDetailsView::createShareDialog() |
|
612 { |
|
613 TX_ENTRY |
|
614 if ( !mSharePopup ) |
|
615 { |
|
616 mSharePopup = new MpDetailsShareDialog(); |
|
617 } |
|
618 if ( !mSharePopup->isInitialized() ) |
|
619 { |
|
620 connect( mSharePopup, SIGNAL( closeShareDialog() ), this, SLOT( closeShareDialog() ) ); |
|
621 mSharePopup->initialize( mSongData, tr( "Unknown" ) ); |
|
622 } |
|
623 TX_EXIT |
|
624 } |
|
625 |
|
626 /*! |
|
627 Method to create the share dialog on demand and preload publishing player files. |
|
628 This will construct the share dialog but it will still be in "uninitialized" state. |
|
629 */ |
|
630 void MpDetailsView::preloadShareDialog() |
|
631 { |
|
632 TX_ENTRY |
|
633 if ( !mSharePopup ) |
|
634 { |
|
635 mSharePopup = new MpDetailsShareDialog(); |
|
636 } |
|
637 mSharePopup->cachePublishingPlayerFiles(); |
|
638 TX_EXIT |
|
639 } |
|
640 |
|
641 /*! |
|
642 Slot to be called when ok/close button in share dialog is pressed. |
|
643 */ |
|
644 void MpDetailsView::closeShareDialog() |
|
645 { |
|
646 TX_ENTRY |
|
647 if ( mSharePopup ) |
|
648 { |
|
649 // Dialog uses WA_DeleteOnClose so no need to delete it explicitely here, just close it. |
|
650 mSharePopup->close(); |
|
651 mSharePopup = NULL; |
|
652 } |
|
653 TX_EXIT |
|
654 } |
|
655 #endif |
|
656 |
|
657 /*! |
|
658 Slot to handle the music store URL retrieval from the query manager. |
|
659 */ |
622 */ |
660 void MpDetailsView::updateSharedData(const QString& url) |
623 void MpDetailsView::handleListItemSelected( HbListWidgetItem *item) |
661 { |
624 { |
662 TX_ENTRY |
625 TX_ENTRY_ARGS( "URL: " << item->secondaryText() ); |
663 mSongData->setLink( url ); |
626 QDesktopServices::openUrl( item->secondaryText() ); |
664 #ifdef SHARE_FUNC_ENABLED |
627 TX_EXIT |
665 if ( mSharePopup ) |
628 } |
666 { |
629 |
667 mSharePopup->updateSharedData(); |
630 /*! |
668 } |
631 Slot to call when MusicStore Info is Received |
669 #endif |
632 */ |
670 TX_EXIT |
633 void MpDetailsView::queryInspireMe(bool storeUpdated) |
671 } |
634 { |
|
635 TX_ENTRY |
|
636 // we asked query manager to update its local store information |
|
637 // if that store info didnt change (i.e. from empty string to "fi" or |
|
638 // from "bad old store" to "good new store") then we dont need to pursue a query |
|
639 if( storeUpdated ) { |
|
640 mMpQueryManager->queryInspireMeItems(mSongData->artist(),mSongData->album(),mSongData->title()); |
|
641 mInspireMeQueryOngoing = true; |
|
642 } |
|
643 else { |
|
644 mInspireMeQueryOngoing = false; |
|
645 mInspireMeProgressBar->hide(); |
|
646 } |
|
647 TX_EXIT |
|
648 } |
|
649 |