Skip to content
This repository
Browse code

Merge pull request #2194 from Montellese/chooseart_all_artwork

show all existing artwork types for a specific media type in the "Choose art" dialog
  • Loading branch information...
commit 9c1e76361dfea0825afaa68fc599ec64165fd646 2 parents 686dd32 + 11c9ed3
Sascha Montellese authored March 07, 2013
27  xbmc/video/VideoDatabase.cpp
@@ -3731,6 +3731,33 @@ bool CVideoDatabase::GetTvShowSeasonArt(int showId, map<int, map<string, string>
3731 3731
   return false;
3732 3732
 }
3733 3733
 
  3734
+bool CVideoDatabase::GetArtTypes(const std::string &mediaType, std::vector<std::string> &artTypes)
  3735
+{
  3736
+  try
  3737
+  {
  3738
+    if (NULL == m_pDB.get()) return false;
  3739
+    if (NULL == m_pDS.get()) return false;
  3740
+
  3741
+    CStdString sql = PrepareSQL("SELECT DISTINCT type FROM art WHERE media_type='%s'", mediaType.c_str());
  3742
+    int numRows = RunQuery(sql);
  3743
+    if (numRows <= 0)
  3744
+      return numRows == 0;
  3745
+
  3746
+    while (!m_pDS->eof())
  3747
+    {
  3748
+      artTypes.push_back(m_pDS->fv(0).get_asString());
  3749
+      m_pDS->next();
  3750
+    }
  3751
+    m_pDS->close();
  3752
+    return true;
  3753
+  }
  3754
+  catch (...)
  3755
+  {
  3756
+    CLog::Log(LOGERROR, "%s(%s) failed", __FUNCTION__, mediaType.c_str());
  3757
+  }
  3758
+  return false;
  3759
+}
  3760
+
3734 3761
 /// \brief GetStackTimes() obtains any saved video times for the stacked file
3735 3762
 /// \retval Returns true if the stack times exist, false otherwise.
3736 3763
 bool CVideoDatabase::GetStackTimes(const CStdString &filePath, vector<int> &times)
1  xbmc/video/VideoDatabase.h
@@ -682,6 +682,7 @@ class CVideoDatabase : public CDatabase
682 682
   bool GetArtForItem(int mediaId, const std::string &mediaType, std::map<std::string, std::string> &art);
683 683
   std::string GetArtForItem(int mediaId, const std::string &mediaType, const std::string &artType);
684 684
   bool GetTvShowSeasonArt(int mediaId, std::map<int, std::map<std::string, std::string> > &seasonArt);
  685
+  bool GetArtTypes(const std::string &mediaType, std::vector<std::string> &artTypes);
685 686
 
686 687
   int AddTag(const std::string &tag);
687 688
   void AddTagToItem(int idItem, int idTag, const std::string &type);
9  xbmc/video/dialogs/GUIDialogVideoInfo.cpp
@@ -620,6 +620,15 @@ string CGUIDialogVideoInfo::ChooseArtType(const CFileItem &videoItem, map<string
620 620
       artTypes.push_back(i->first);
621 621
   }
622 622
 
  623
+  // add any art types that exist for other media items of the same type
  624
+  vector<string> dbArtTypes;
  625
+  db.GetArtTypes(videoItem.GetVideoInfoTag()->m_type, dbArtTypes);
  626
+  for (vector<string>::const_iterator it = dbArtTypes.begin(); it != dbArtTypes.end(); it++)
  627
+  {
  628
+    if (find(artTypes.begin(), artTypes.end(), *it) == artTypes.end())
  629
+      artTypes.push_back(*it);
  630
+  }
  631
+
623 632
   for (vector<string>::const_iterator i = artTypes.begin(); i != artTypes.end(); ++i)
624 633
   {
625 634
     string type = *i;

0 notes on commit 9c1e763

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