本文整理汇总了C++中CFileItemList::SetSortIgnoreFolders方法的典型用法代码示例。如果您正苦于以下问题:C++ CFileItemList::SetSortIgnoreFolders方法的具体用法?C++ CFileItemList::SetSortIgnoreFolders怎么用?C++ CFileItemList::SetSortIgnoreFolders使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFileItemList
的用法示例。
在下文中一共展示了CFileItemList::SetSortIgnoreFolders方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadVideoInfo
void CGUIWindowVideoNav::LoadVideoInfo(CFileItemList &items, CVideoDatabase &database, bool allowReplaceLabels)
{
//! @todo this could possibly be threaded as per the music info loading,
//! we could also cache the info
if (!items.GetContent().empty() && !items.IsPlugin())
return; // don't load for listings that have content set and weren't created from plugins
std::string content = items.GetContent();
// determine content only if it isn't set
if (content.empty())
{
content = database.GetContentForPath(items.GetPath());
items.SetContent((content.empty() && !items.IsPlugin()) ? "files" : content);
}
/*
If we have a matching item in the library, so we can assign the metadata to it. In addition, we can choose
* whether the item is stacked down (eg in the case of folders representing a single item)
* whether or not we assign the library's labels to the item, or leave the item as is.
As certain users (read: certain developers) don't want either of these to occur, we compromise by stacking
items down only if stacking is available and enabled.
Similarly, we assign the "clean" library labels to the item only if the "Replace filenames with library titles"
setting is enabled.
*/
const bool stackItems = items.GetProperty("isstacked").asBoolean() || (StackingAvailable(items) && CServiceBroker::GetSettings().GetBool(CSettings::SETTING_MYVIDEOS_STACKVIDEOS));
const bool replaceLabels = allowReplaceLabels && CServiceBroker::GetSettings().GetBool(CSettings::SETTING_MYVIDEOS_REPLACELABELS);
CFileItemList dbItems;
/* NOTE: In the future when GetItemsForPath returns all items regardless of whether they're "in the library"
we won't need the fetchedPlayCounts code, and can "simply" do this directly on absence of content. */
bool fetchedPlayCounts = false;
if (!content.empty())
{
database.GetItemsForPath(content, items.GetPath(), dbItems);
dbItems.SetFastLookup(true);
}
for (int i = 0; i < items.Size(); i++)
{
CFileItemPtr pItem = items[i];
CFileItemPtr match;
if (!content.empty()) /* optical media will be stacked down, so it's path won't match the base path */
{
std::string pathToMatch = pItem->IsOpticalMediaFile() ? pItem->GetLocalMetadataPath() : pItem->GetPath();
if (URIUtils::IsMultiPath(pathToMatch))
pathToMatch = CMultiPathDirectory::GetFirstPath(pathToMatch);
match = dbItems.Get(pathToMatch);
}
if (match)
{
pItem->UpdateInfo(*match, replaceLabels);
if (stackItems)
{
if (match->m_bIsFolder)
pItem->SetPath(match->GetVideoInfoTag()->m_strPath);
else
pItem->SetPath(match->GetVideoInfoTag()->m_strFileNameAndPath);
// if we switch from a file to a folder item it means we really shouldn't be sorting files and
// folders separately
if (pItem->m_bIsFolder != match->m_bIsFolder)
{
items.SetSortIgnoreFolders(true);
pItem->m_bIsFolder = match->m_bIsFolder;
}
}
}
else
{
/* NOTE: Currently we GetPlayCounts on our items regardless of whether content is set
as if content is set, GetItemsForPaths doesn't return anything not in the content tables.
This code can be removed once the content tables are always filled */
if (!pItem->m_bIsFolder && !fetchedPlayCounts)
{
database.GetPlayCounts(items.GetPath(), items);
fetchedPlayCounts = true;
}
// set the watched overlay
if (pItem->IsVideo())
pItem->SetOverlayImage(CGUIListItem::ICON_OVERLAY_UNWATCHED, pItem->HasVideoInfoTag() && pItem->GetVideoInfoTag()->GetPlayCount() > 0);
}
}
}
示例2: GetDirectory
bool CSmartPlaylistDirectory::GetDirectory(const CSmartPlaylist &playlist, CFileItemList& items, const std::string &strBaseDir /* = "" */, bool filter /* = false */)
{
bool success = false, success2 = false;
std::vector<std::string> virtualFolders;
SortDescription sorting;
sorting.limitEnd = playlist.GetLimit();
sorting.sortBy = playlist.GetOrder();
sorting.sortOrder = playlist.GetOrderAscending() ? SortOrderAscending : SortOrderDescending;
sorting.sortAttributes = playlist.GetOrderAttributes();
if (CSettings::Get().GetBool("filelists.ignorethewhensorting"))
sorting.sortAttributes = (SortAttribute)(sorting.sortAttributes | SortAttributeIgnoreArticle);
items.SetSortIgnoreFolders((sorting.sortAttributes & SortAttributeIgnoreFolders) == SortAttributeIgnoreFolders);
std::string option = !filter ? "xsp" : "filter";
const std::string& group = playlist.GetGroup();
bool isGrouped = !group.empty() && !StringUtils::EqualsNoCase(group, "none") && !playlist.IsGroupMixed();
// get all virtual folders and add them to the item list
playlist.GetVirtualFolders(virtualFolders);
for (std::vector<std::string>::const_iterator virtualFolder = virtualFolders.begin(); virtualFolder != virtualFolders.end(); virtualFolder++)
{
CFileItemPtr pItem = CFileItemPtr(new CFileItem(*virtualFolder, true));
IFileDirectory *dir = CFileDirectoryFactory::Create(pItem->GetURL(), pItem.get());
if (dir != NULL)
{
pItem->SetSpecialSort(SortSpecialOnTop);
items.Add(pItem);
delete dir;
}
}
if (playlist.GetType() == "movies" ||
playlist.GetType() == "tvshows" ||
playlist.GetType() == "episodes")
{
CVideoDatabase db;
if (db.Open())
{
MediaType mediaType = MediaTypes::FromString(playlist.GetType());
std::string baseDir = strBaseDir;
if (strBaseDir.empty())
{
if (mediaType == MediaTypeTvShow || mediaType == MediaTypeEpisode)
baseDir = "videodb://tvshows/";
else if (mediaType == MediaTypeMovie)
baseDir = "videodb://movies/";
else
return false;
if (!isGrouped)
baseDir += "titles";
else
baseDir += group;
URIUtils::AddSlashAtEnd(baseDir);
if (mediaType == MediaTypeEpisode)
baseDir += "-1/-1/";
}
CVideoDbUrl videoUrl;
if (!videoUrl.FromString(baseDir))
return false;
// store the smartplaylist as JSON in the URL as well
std::string xsp;
if (!playlist.IsEmpty(filter))
{
if (!playlist.SaveAsJson(xsp, !filter))
return false;
}
if (!xsp.empty())
videoUrl.AddOption(option, xsp);
else
videoUrl.RemoveOption(option);
CDatabase::Filter dbfilter;
success = db.GetItems(videoUrl.ToString(), items, dbfilter, sorting);
db.Close();
// if we retrieve a list of episodes and we didn't receive
// a pre-defined base path, we need to fix it
if (strBaseDir.empty() && mediaType == MediaTypeEpisode && !isGrouped)
videoUrl.AppendPath("-1/-1/");
items.SetProperty(PROPERTY_PATH_DB, videoUrl.ToString());
}
}
else if (playlist.IsMusicType() || playlist.GetType().empty())
{
CMusicDatabase db;
if (db.Open())
{
CSmartPlaylist plist(playlist);
if (playlist.GetType() == "mixed" || playlist.GetType().empty())
plist.SetType("songs");
MediaType mediaType = MediaTypes::FromString(plist.GetType());
//.........这里部分代码省略.........