Skip to content

Commit

Permalink
changed: refactored CFileItemList::Stack() into StackFiles and StackF…
Browse files Browse the repository at this point in the history
…olders - Stack() now takes a bool to specify wether we want to stack all or just collapse folders (defaults to true)
  • Loading branch information
mkortstiege committed Aug 13, 2011
1 parent 56aeb68 commit e71ff83
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
15 changes: 13 additions & 2 deletions xbmc/FileItem.cpp
Expand Up @@ -1985,7 +1985,7 @@ void CFileItemList::RemoveExtensions()
m_items[i]->RemoveExtension();
}

void CFileItemList::Stack()
void CFileItemList::Stack(bool stackFiles /* = true */)
{
CSingleLock lock(m_lock);

Expand All @@ -1998,6 +1998,14 @@ void CFileItemList::Stack()
// items needs to be sorted for stuff below to work properly
Sort(SORT_METHOD_LABEL, SORT_ORDER_ASC);

if (stackFiles)
StackFiles();

StackFolders();
}

void CFileItemList::StackFolders()
{
// Precompile our REs
VECCREGEXP folderRegExps;
CRegExp folderRegExp(true);
Expand Down Expand Up @@ -2126,7 +2134,10 @@ void CFileItemList::Stack()
}
}
}
}

void CFileItemList::StackFiles()
{
// Precompile our REs
VECCREGEXP stackRegExps;
CRegExp tmpRegExp(true);
Expand All @@ -2145,7 +2156,7 @@ void CFileItemList::Stack()
}

// now stack the files, some of which may be from the previous stack iteration

This comment has been minimized.

Copy link
@jmarshallnz

jmarshallnz Aug 13, 2011

Contributor

note this comment - you've broken functionality here: folders must be stacked before files.

This comment has been minimized.

Copy link
@mkortstiege

mkortstiege Aug 13, 2011

Author Member

Argh. wil fix asap. thanks for the heads up.

i = 0;
int i = 0;
while (i < Size())
{
CFileItemPtr item1 = Get(i);
Expand Down
21 changes: 20 additions & 1 deletion xbmc/FileItem.h
Expand Up @@ -399,7 +399,14 @@ class CFileItemList : public CFileItem
void SetFastLookup(bool fastLookup);
bool Contains(const CStdString& fileName) const;
bool GetFastLookup() const { return m_fastLookup; };
void Stack();

/*! \brief stack a CFileItemList
By default we stack all items (files and folders) in a CFileItemList
\param stackFiles whether to stack all items or just collapse folders (defaults to true)
\sa StackFiles,StackFolders
*/
void Stack(bool stackFiles = true);

SORT_ORDER GetSortOrder() const { return m_sortOrder; }
SORT_METHOD GetSortMethod() const { return m_sortMethod; }
/*! \brief load a CFileItemList out of the cache
Expand Down Expand Up @@ -473,6 +480,18 @@ class CFileItemList : public CFileItem
void FillSortFields(FILEITEMFILLFUNC func);
CStdString GetDiscCacheFile(int windowID) const;

/*!
\brief stack files in a CFileItemList
\sa Stack
*/
void StackFiles();

/*!
\brief stack folders in a CFileItemList
\sa Stack
*/
void StackFolders();

VECFILEITEMS m_items;
MAPFILEITEMS m_map;
bool m_fastLookup;
Expand Down

0 comments on commit e71ff83

Please sign in to comment.