Skip to content
This repository
Browse code

Merge pull request #1969 from Montellese/set_grouping_fix

GroupUtils: fix URL options when grouping movies into sets
  • Loading branch information...
commit 31843b4682e684a4dd3c4d70e6692b3b011ebd36 2 parents b8a867f + a5bb217
davilla authored December 22, 2012
22  xbmc/utils/GroupUtils.cpp
@@ -25,6 +25,7 @@
25 25
 #include "FileItem.h"
26 26
 #include "utils/StringUtils.h"
27 27
 #include "utils/Variant.h"
  28
+#include "video/VideoDbUrl.h"
28 29
 #include "video/VideoInfoTag.h"
29 30
 #include "utils/URIUtils.h"
30 31
 #include "filesystem/MultiPathDirectory.h"
@@ -33,7 +34,7 @@ using namespace std;
33 34
 
34 35
 typedef map<int, set<CFileItemPtr> > SetMap;
35 36
 
36  
-bool GroupUtils::Group(GroupBy groupBy, const CFileItemList &items, CFileItemList &groupedItems, GroupAttribute groupAttributes /* = GroupAttributeNone */)
  37
+bool GroupUtils::Group(GroupBy groupBy, const std::string &baseDir, const CFileItemList &items, CFileItemList &groupedItems, GroupAttribute groupAttributes /* = GroupAttributeNone */)
37 38
 {
38 39
   if (items.Size() <= 0 || groupBy == GroupByNone)
39 40
     return false;
@@ -58,6 +59,10 @@ bool GroupUtils::Group(GroupBy groupBy, const CFileItemList &items, CFileItemLis
58 59
 
59 60
   if ((groupBy & GroupBySet) && setMap.size() > 0)
60 61
   {
  62
+    CVideoDbUrl itemsUrl;
  63
+    if (!itemsUrl.FromString(baseDir))
  64
+      return false;
  65
+
61 66
     for (SetMap::const_iterator set = setMap.begin(); set != setMap.end(); set++)
62 67
     {
63 68
       // only one item in the set, so just re-add it
@@ -70,7 +75,16 @@ bool GroupUtils::Group(GroupBy groupBy, const CFileItemList &items, CFileItemLis
70 75
       CFileItemPtr pItem(new CFileItem((*set->second.begin())->GetVideoInfoTag()->m_strSet));
71 76
       pItem->GetVideoInfoTag()->m_iDbId = set->first;
72 77
       pItem->GetVideoInfoTag()->m_type = "set";
73  
-      pItem->SetPath(StringUtils::Format("videodb://1/7/%ld/", set->first));
  78
+
  79
+      std::string basePath = StringUtils::Format("videodb://1/7/%ld/", set->first);
  80
+      CVideoDbUrl videoUrl;
  81
+      if (!videoUrl.FromString(basePath))
  82
+        pItem->SetPath(basePath);
  83
+      else
  84
+      {
  85
+        videoUrl.AddOptions(itemsUrl.GetOptionsString());
  86
+        pItem->SetPath(videoUrl.ToString());
  87
+      }
74 88
       pItem->m_bIsFolder = true;
75 89
 
76 90
       CVideoInfoTag* setInfo = pItem->GetVideoInfoTag();
@@ -132,9 +146,9 @@ bool GroupUtils::Group(GroupBy groupBy, const CFileItemList &items, CFileItemLis
132 146
   return true;
133 147
 }
134 148
 
135  
-bool GroupUtils::GroupAndSort(GroupBy groupBy, const CFileItemList &items, const SortDescription &sortDescription, CFileItemList &groupedItems, GroupAttribute groupAttributes /* = GroupAttributeNone */)
  149
+bool GroupUtils::GroupAndSort(GroupBy groupBy, const std::string &baseDir, const CFileItemList &items, const SortDescription &sortDescription, CFileItemList &groupedItems, GroupAttribute groupAttributes /* = GroupAttributeNone */)
136 150
 {
137  
-  if (!Group(groupBy, items, groupedItems, groupAttributes))
  151
+  if (!Group(groupBy, baseDir, items, groupedItems, groupAttributes))
138 152
     return false;
139 153
 
140 154
   groupedItems.Sort(sortDescription);
4  xbmc/utils/GroupUtils.h
@@ -37,6 +37,6 @@ typedef enum {
37 37
 class GroupUtils
38 38
 {
39 39
 public:
40  
-  static bool Group(GroupBy groupBy, const CFileItemList &items, CFileItemList &groupedItems, GroupAttribute groupAttributes = GroupAttributeNone);
41  
-  static bool GroupAndSort(GroupBy groupBy, const CFileItemList &items, const SortDescription &sortDescription, CFileItemList &groupedItems, GroupAttribute groupAttributes = GroupAttributeNone);
  40
+  static bool Group(GroupBy groupBy, const std::string &baseDir, const CFileItemList &items, CFileItemList &groupedItems, GroupAttribute groupAttributes = GroupAttributeNone);
  41
+  static bool GroupAndSort(GroupBy groupBy, const std::string &baseDir, const CFileItemList &items, const SortDescription &sortDescription, CFileItemList &groupedItems, GroupAttribute groupAttributes = GroupAttributeNone);
42 42
 };
2  xbmc/video/VideoDatabase.cpp
@@ -4954,7 +4954,7 @@ bool CVideoDatabase::GetSetsByWhere(const CStdString& strBaseDir, const Filter &
4954 4954
       return false;
4955 4955
 
4956 4956
     CFileItemList sets;
4957  
-    if (!GroupUtils::Group(GroupBySet, items, sets))
  4957
+    if (!GroupUtils::Group(GroupBySet, strBaseDir, items, sets))
4958 4958
       return false;
4959 4959
 
4960 4960
     items.ClearItems();
2  xbmc/video/windows/GUIWindowVideoBase.cpp
@@ -1884,7 +1884,7 @@ void CGUIWindowVideoBase::GetGroupedItems(CFileItemList &items)
1884 1884
       g_guiSettings.GetBool("videolibrary.groupmoviesets"))
1885 1885
   {
1886 1886
     CFileItemList groupedItems;
1887  
-    if (GroupUtils::Group(GroupBySet, items, groupedItems, GroupAttributeIgnoreSingleItems))
  1887
+    if (GroupUtils::Group(GroupBySet, m_strFilterPath, items, groupedItems, GroupAttributeIgnoreSingleItems))
1888 1888
     {
1889 1889
       items.ClearItems();
1890 1890
       items.Append(groupedItems);

0 notes on commit 31843b4

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