Skip to content
This repository
Browse code

CFileItem: extend Copy() with an optional "copyItems" parameter (true…

… by default) to be able to only copy the properties of a list without the items
  • Loading branch information...
commit 60592607838c528cdb1e574dd4d10258bcb4ce72 1 parent 9e7255f
Sascha Montellese authored February 25, 2013
13  xbmc/FileItem.cpp
@@ -1721,7 +1721,7 @@ void CFileItemList::Assign(const CFileItemList& itemlist, bool append)
1721 1721
   m_cacheToDisc = itemlist.m_cacheToDisc;
1722 1722
 }
1723 1723
 
1724  
-bool CFileItemList::Copy(const CFileItemList& items)
  1724
+bool CFileItemList::Copy(const CFileItemList& items, bool copyItems /* = true */)
1725 1725
 {
1726 1726
   // assign all CFileItem parts
1727 1727
   *(CFileItem*)this = *(CFileItem*)&items;
@@ -1736,11 +1736,14 @@ bool CFileItemList::Copy(const CFileItemList& items)
1736 1736
   m_sortOrder      = items.m_sortOrder;
1737 1737
   m_sortIgnoreFolders = items.m_sortIgnoreFolders;
1738 1738
 
1739  
-  // make a copy of each item
1740  
-  for (int i = 0; i < items.Size(); i++)
  1739
+  if (copyItems)
1741 1740
   {
1742  
-    CFileItemPtr newItem(new CFileItem(*items[i]));
1743  
-    Add(newItem);
  1741
+    // make a copy of each item
  1742
+    for (int i = 0; i < items.Size(); i++)
  1743
+    {
  1744
+      CFileItemPtr newItem(new CFileItem(*items[i]));
  1745
+      Add(newItem);
  1746
+    }
1744 1747
   }
1745 1748
 
1746 1749
   return true;
2  xbmc/FileItem.h
@@ -475,7 +475,7 @@ class CFileItemList : public CFileItem
475 475
   bool IsEmpty() const;
476 476
   void Append(const CFileItemList& itemlist);
477 477
   void Assign(const CFileItemList& itemlist, bool append = false);
478  
-  bool Copy  (const CFileItemList& item);
  478
+  bool Copy  (const CFileItemList& item, bool copyItems = true);
479 479
   void Reserve(int iCount);
480 480
   void Sort(SORT_METHOD sortMethod, SortOrder sortOrder);
481 481
   /* \brief Sorts the items based on the given sorting options

0 notes on commit 6059260

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