Skip to content
This repository
Browse code

[musicgui] cosmetic: reroll the album/artist GUI to make them much cl…

…eaner and more logical
  • Loading branch information...
commit 5704b96c71a4a515050f06623654d5c4e1f1fb80 1 parent 84216ce
night199uk authored April 09, 2013
213  xbmc/music/windows/GUIWindowMusicBase.cpp
@@ -323,14 +323,11 @@ void CGUIWindowMusicBase::OnInfo(CFileItem *pItem, bool bShowInfo)
323 323
     CDirectoryNode::GetDatabaseInfo(pItem->GetPath(), params);
324 324
     if (params.GetAlbumId() == -1)
325 325
     { // artist lookup
326  
-      artist.idArtist = params.GetArtistId();
327  
-      artist.strArtist = StringUtils::Join(pItem->GetMusicInfoTag()->GetArtist(), g_advancedSettings.m_musicItemSeparator);
  326
+      m_musicdatabase.GetArtistInfo(params.GetArtistId(), artist);
328 327
     }
329 328
     else
330 329
     { // album lookup
331  
-      album.idAlbum = params.GetAlbumId();
332  
-      album.strAlbum = pItem->GetMusicInfoTag()->GetAlbum();
333  
-      album.artist = pItem->GetMusicInfoTag()->GetArtist();
  330
+      m_musicdatabase.GetAlbumInfo(params.GetAlbumId(), album, NULL);
334 331
 
335 332
       // we're going to need it's path as well (we assume that there's only one) - this is for
336 333
       // assigning thumbs to folders, and obtaining the local folder.jpg
@@ -392,9 +389,9 @@ void CGUIWindowMusicBase::OnInfo(CFileItem *pItem, bool bShowInfo)
392 389
   }
393 390
 
394 391
   if (album.idAlbum == -1 && foundAlbum == false)
395  
-    ShowArtistInfo(artist, pItem->GetPath(), false, bShowInfo);
  392
+    ShowArtistInfo(artist, pItem->GetPath(), bShowInfo);
396 393
   else
397  
-    ShowAlbumInfo(album, strPath, false, bShowInfo);
  394
+    ShowAlbumInfo(album, strPath, bShowInfo);
398 395
   m_musicdatabase.Close();
399 396
 }
400 397
 
@@ -412,183 +409,115 @@ void CGUIWindowMusicBase::OnManualAlbumInfo()
412 409
   ShowAlbumInfo(album,"",true);
413 410
 }
414 411
 
415  
-void CGUIWindowMusicBase::ShowArtistInfo(const CArtist& artist, const CStdString& path, bool bRefresh, bool bShowInfo)
  412
+void CGUIWindowMusicBase::ShowArtistInfo(const CArtist& artist, const CStdString& path, bool bShowInfo /* = true */)
416 413
 {
417 414
   bool saveDb = artist.idArtist != -1;
418 415
   if (!CProfilesManager::Get().GetCurrentProfile().canWriteDatabases() && !g_passwordManager.bMasterUser)
419 416
     saveDb = false;
420 417
 
421  
-  // check cache
422  
-  CArtist artistInfo;
423  
-  if (!bRefresh && m_musicdatabase.GetArtistInfo(artist.idArtist, artistInfo))
  418
+  CMusicArtistInfo artistInfo;
  419
+  while (1)
424 420
   {
425  
-    if (!bShowInfo)
426  
-      return;
427  
-
428  
-    CGUIDialogMusicInfo *pDlgArtistInfo = (CGUIDialogMusicInfo*)g_windowManager.GetWindow(WINDOW_DIALOG_MUSIC_INFO);
429  
-    if (pDlgArtistInfo)
  421
+    if (!m_musicdatabase.HasArtistInfo(artist.idArtist) ||
  422
+        !m_musicdatabase.GetArtistInfo(artist.idArtist, artistInfo.GetArtist()))
430 423
     {
431  
-      pDlgArtistInfo->SetArtist(artistInfo, path);
  424
+      if (g_application.IsMusicScanning())
  425
+      {
  426
+        CGUIDialogOK::ShowAndGetInput(189, 14057, 0, 0);
  427
+        break;
  428
+      }
432 429
 
433  
-      if (bShowInfo)
434  
-        pDlgArtistInfo->DoModal();
  430
+      if (!FindArtistInfo(artist.strArtist, artistInfo, bShowInfo ? SELECTION_ALLOWED : SELECTION_AUTO))
  431
+        break;
435 432
 
436  
-      if (!pDlgArtistInfo->NeedRefresh())
  433
+      if (!artistInfo.Loaded())
437 434
       {
438  
-        if (pDlgArtistInfo->HasUpdatedThumb())
439  
-          Refresh();
440  
-
441  
-        return;
  435
+        // Failed to download album info
  436
+        CGUIDialogOK::ShowAndGetInput(21889, 0, 20199, 0);
  437
+        break;
442 438
       }
443  
-      bRefresh = true;
444  
-      m_musicdatabase.DeleteArtistInfo(artistInfo.idArtist);
445  
-    }
446  
-  }
447 439
 
448  
-  // If we are scanning for music info in the background,
449  
-  // other writing access to the database is prohibited.
450  
-  if (g_application.IsMusicScanning())
451  
-  {
452  
-    CGUIDialogOK::ShowAndGetInput(189, 14057, 0, 0);
453  
-    return;
454  
-  }
  440
+      if (saveDb)
  441
+        m_musicdatabase.SetArtistInfo(artist.idArtist, artistInfo.GetArtist());
  442
+    }
455 443
 
456  
-  CMusicArtistInfo info;
457  
-  if (FindArtistInfo(artist.strArtist, info, bShowInfo ? (bRefresh ? SELECTION_FORCED : SELECTION_ALLOWED) : SELECTION_AUTO))
458  
-  {
459  
-    // download the album info
460  
-    if ( info.Loaded() )
  444
+    CGUIDialogMusicInfo *pDlgArtistInfo = (CGUIDialogMusicInfo*)g_windowManager.GetWindow(WINDOW_DIALOG_MUSIC_INFO);
  445
+    if (pDlgArtistInfo)
461 446
     {
462  
-      if (saveDb)
463  
-      {
464  
-        // save to database
465  
-        m_musicdatabase.SetArtistInfo(artist.idArtist, info.GetArtist());
466  
-      }
467  
-      if (m_dlgProgress && bShowInfo)
468  
-        m_dlgProgress->Close();
  447
+      pDlgArtistInfo->SetArtist(artistInfo.GetArtist(), path);
  448
+      pDlgArtistInfo->DoModal();
469 449
 
470  
-      // ok, show album info
471  
-      CGUIDialogMusicInfo *pDlgArtistInfo = (CGUIDialogMusicInfo*)g_windowManager.GetWindow(WINDOW_DIALOG_MUSIC_INFO);
472  
-      if (pDlgArtistInfo)
  450
+      if (pDlgArtistInfo->NeedRefresh())
473 451
       {
474  
-        pDlgArtistInfo->SetArtist(info.GetArtist(), path);
475  
-        if (bShowInfo)
476  
-          pDlgArtistInfo->DoModal();
477  
-
478  
-        CArtist artistInfo = info.GetArtist();
479  
-        artistInfo.idArtist = artist.idArtist;
480  
-/*
481  
-        if (pDlgAlbumInfo->HasUpdatedThumb())
482  
-          UpdateThumb(artistInfo, path);
483  
-*/
484  
-        // just update for now
485  
-        Refresh();
486  
-        if (pDlgArtistInfo->NeedRefresh())
487  
-        {
488  
-          m_musicdatabase.DeleteArtistInfo(artistInfo.idArtist);
489  
-          ShowArtistInfo(artist, path, true, bShowInfo);
490  
-          return;
491  
-        }
  452
+        m_musicdatabase.DeleteArtistInfo(artist.idArtist);
  453
+        continue;
  454
+      } 
  455
+      else if (pDlgArtistInfo->HasUpdatedThumb()) 
  456
+      {
  457
+        Update(m_vecItems->GetPath());
492 458
       }
493 459
     }
494  
-    else
495  
-    {
496  
-      // failed 2 download album info
497  
-      CGUIDialogOK::ShowAndGetInput(21889, 0, 20199, 0);
498  
-    }
  460
+    break;
499 461
   }
500  
-
501  
-  if (m_dlgProgress && bShowInfo)
  462
+  if (m_dlgProgress)
502 463
     m_dlgProgress->Close();
503 464
 }
504 465
 
505  
-void CGUIWindowMusicBase::ShowAlbumInfo(const CAlbum& album, const CStdString& path, bool bRefresh, bool bShowInfo)
  466
+void CGUIWindowMusicBase::ShowAlbumInfo(const CAlbum& album, const CStdString& path, bool bShowInfo /* = true */)
506 467
 {
507 468
   bool saveDb = album.idAlbum != -1;
508 469
   if (!CProfilesManager::Get().GetCurrentProfile().canWriteDatabases() && !g_passwordManager.bMasterUser)
509 470
     saveDb = false;
510 471
 
511  
-  // check cache
512  
-  CAlbum albumInfo;
513  
-  if (!bRefresh && m_musicdatabase.GetAlbumInfo(album.idAlbum, albumInfo, &albumInfo.songs))
  472
+  CMusicAlbumInfo albumInfo;
  473
+  while (1)
514 474
   {
515  
-    if (!bShowInfo)
516  
-      return;
517  
-
518  
-    CGUIDialogMusicInfo *pDlgAlbumInfo = (CGUIDialogMusicInfo*)g_windowManager.GetWindow(WINDOW_DIALOG_MUSIC_INFO);
519  
-    if (pDlgAlbumInfo)
  475
+    if (!m_musicdatabase.HasAlbumInfo(album.idAlbum) || 
  476
+        !m_musicdatabase.GetAlbumInfo(album.idAlbum, albumInfo.GetAlbum(), &albumInfo.GetAlbum().songs))
520 477
     {
521  
-      pDlgAlbumInfo->SetAlbum(albumInfo, path);
522  
-      if (bShowInfo)
523  
-        pDlgAlbumInfo->DoModal();
  478
+      if (g_application.IsMusicScanning())
  479
+      {
  480
+        CGUIDialogOK::ShowAndGetInput(189, 14057, 0, 0);
  481
+        break;
  482
+      }
524 483
 
525  
-      if (!pDlgAlbumInfo->NeedRefresh())
  484
+      if (!FindAlbumInfo(album.strAlbum, 
  485
+                         StringUtils::Join(album.artist, g_advancedSettings.m_musicItemSeparator),
  486
+                         albumInfo,
  487
+                         bShowInfo ? SELECTION_ALLOWED : SELECTION_AUTO))
  488
+        break;
  489
+      
  490
+      if (!albumInfo.Loaded())
526 491
       {
527  
-        if (pDlgAlbumInfo->HasUpdatedThumb())
528  
-          UpdateThumb(albumInfo, path);
529  
-        return;
  492
+        CGUIDialogOK::ShowAndGetInput(185, 0, 500, 0);
  493
+        break;
530 494
       }
531  
-      bRefresh = true;
532  
-      m_musicdatabase.DeleteAlbumInfo(albumInfo.idAlbum);
533  
-    }
534  
-  }
535 495
 
536  
-  // If we are scanning for music info in the background,
537  
-  // other writing access to the database is prohibited.
538  
-  if (g_application.IsMusicScanning())
539  
-  {
540  
-    CGUIDialogOK::ShowAndGetInput(189, 14057, 0, 0);
541  
-    return;
542  
-  }
  496
+      albumInfo.GetAlbum().strAlbum = album.strAlbum;
543 497
 
544  
-  CMusicAlbumInfo info;
545  
-  if (FindAlbumInfo(album.strAlbum, StringUtils::Join(album.artist, g_advancedSettings.m_musicItemSeparator), info, bShowInfo ? (bRefresh ? SELECTION_FORCED : SELECTION_ALLOWED) : SELECTION_AUTO))
546  
-  {
547  
-    // download the album info
548  
-    if ( info.Loaded() )
  498
+      if (saveDb)
  499
+        m_musicdatabase.SetAlbumInfo(album.idAlbum, albumInfo.GetAlbum(), albumInfo.GetSongs());
  500
+    }
  501
+
  502
+    CGUIDialogMusicInfo *pDlgAlbumInfo = (CGUIDialogMusicInfo*)g_windowManager.GetWindow(WINDOW_DIALOG_MUSIC_INFO);
  503
+    if (pDlgAlbumInfo)
549 504
     {
550  
-      // set album title from musicinfotag, not the one we got from allmusic.com
551  
-      info.SetTitle(album.strAlbum);
  505
+      pDlgAlbumInfo->SetAlbum(albumInfo.GetAlbum(), path);
  506
+      pDlgAlbumInfo->DoModal();
552 507
 
553  
-      if (saveDb)
  508
+      if (pDlgAlbumInfo->NeedRefresh())
554 509
       {
555  
-        // save to database
556  
-        m_musicdatabase.SetAlbumInfo(album.idAlbum, info.GetAlbum(), info.GetSongs());
  510
+        m_musicdatabase.DeleteAlbumInfo(album.idAlbum);
  511
+        continue;
557 512
       }
558  
-      if (m_dlgProgress && bShowInfo)
559  
-        m_dlgProgress->Close();
560  
-
561  
-      UpdateThumb(album, path);
562  
-
563  
-      // ok, show album info
564  
-      CGUIDialogMusicInfo *pDlgAlbumInfo = (CGUIDialogMusicInfo*)g_windowManager.GetWindow(WINDOW_DIALOG_MUSIC_INFO);
565  
-      if (pDlgAlbumInfo)
  513
+      else if (pDlgAlbumInfo->HasUpdatedThumb())
566 514
       {
567  
-        pDlgAlbumInfo->SetAlbum(info.GetAlbum(), path);
568  
-        if (bShowInfo)
569  
-          pDlgAlbumInfo->DoModal();
570  
-
571  
-        CAlbum albumInfo = info.GetAlbum();
572  
-        albumInfo.idAlbum = album.idAlbum;
573  
-        if (pDlgAlbumInfo->HasUpdatedThumb())
574  
-          UpdateThumb(albumInfo, path);
575  
-
576  
-        if (pDlgAlbumInfo->NeedRefresh())
577  
-        {
578  
-          m_musicdatabase.DeleteAlbumInfo(albumInfo.idAlbum);
579  
-          ShowAlbumInfo(album, path, true, bShowInfo);
580  
-          return;
581  
-        }
  515
+        UpdateThumb(album, path);
582 516
       }
583 517
     }
584  
-    else
585  
-    {
586  
-      // failed 2 download album info
587  
-      CGUIDialogOK::ShowAndGetInput(185, 0, 500, 0);
588  
-    }
  518
+    break;
589 519
   }
590  
-
591  
-  if (m_dlgProgress && bShowInfo)
  520
+  if (m_dlgProgress)
592 521
     m_dlgProgress->Close();
593 522
 }
594 523
 
4  xbmc/music/windows/GUIWindowMusicBase.h
@@ -88,8 +88,8 @@ class CGUIWindowMusicBase : public CGUIMediaWindow
88 88
   bool FindAlbumInfo(const CStdString& strAlbum, const CStdString& strArtist, MUSIC_GRABBER::CMusicAlbumInfo& album, ALLOW_SELECTION allowSelection);
89 89
   bool FindArtistInfo(const CStdString& strArtist, MUSIC_GRABBER::CMusicArtistInfo& artist, ALLOW_SELECTION allowSelection);
90 90
 
91  
-  void ShowAlbumInfo(const CAlbum &album, const CStdString &strPath, bool bRefresh, bool bShowInfo = true);
92  
-  void ShowArtistInfo(const CArtist &artist, const CStdString &strPath, bool bRefresh, bool bShowInfo = true);
  91
+  void ShowAlbumInfo(const CAlbum& album, const CStdString& path, bool bShowInfo = true);
  92
+  void ShowArtistInfo(const CArtist& artist, const CStdString& path, bool bShowInfo = true);
93 93
   void ShowSongInfo(CFileItem* pItem);
94 94
   void UpdateThumb(const CAlbum &album, const CStdString &path);
95 95
 

0 notes on commit 5704b96

Please sign in to comment.
Something went wrong with that request. Please try again.