本文整理汇总了C++中CFileItemList::Clear方法的典型用法代码示例。如果您正苦于以下问题:C++ CFileItemList::Clear方法的具体用法?C++ CFileItemList::Clear怎么用?C++ CFileItemList::Clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFileItemList
的用法示例。
在下文中一共展示了CFileItemList::Clear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetScriptsAndPlugins
bool CAddonsDirectory::GetScriptsAndPlugins(const CStdString &content, CFileItemList &items)
{
items.Clear();
VECADDONS addons;
if (!GetScriptsAndPlugins(content, addons))
return false;
for (unsigned i=0; i<addons.size(); i++)
{
CFileItemPtr item(FileItemFromAddon(addons[i],
addons[i]->Type()==ADDON_PLUGIN?"plugin://":"script://",
addons[i]->Type() == ADDON_PLUGIN));
PluginPtr plugin = boost::dynamic_pointer_cast<CPluginSource>(addons[i]);
if (plugin->ProvidesSeveral())
{
CURL url = item->GetAsUrl();
CStdString opt;
opt.Format("?content_type=%s",content.c_str());
url.SetOptions(opt);
item->SetPath(url.Get());
}
items.Add(item);
}
items.Add(GetMoreItem(content));
items.SetContent("addons");
items.SetLabel(g_localizeStrings.Get(24001)); // Add-ons
return items.Size() > 0;
}
示例2: GetDirectory
bool CStackDirectory::GetDirectory(const CStdString& strPath, CFileItemList& items)
{
items.Clear();
// format is:
// stack://file1 , file2 , file3 , file4
// filenames with commas are double escaped (ie replaced with ,,), thus the " , " separator used.
//CStdString folder, file;
//URIUtils::Split(strPath, folder, file);
// split files on the single comma
CStdStringArray files;
StringUtils::SplitString(strPath, " , ", files);
if (files.empty())
return false; // error in path
// remove "stack://" from the folder
for (unsigned int i = 0; i < files.size(); i++)
{
CStdString file = files[i];
if (i == 0)
file = file.Mid(8);
// replace double comma's with single ones.
file.Replace(",,", ",");
CFileItemPtr item(new CFileItem(file));
//URIUtils::AddFileToFolder(folder, file, item->m_strPath);
item->m_strPath = file;
item->m_bIsFolder = false;
items.Add(item);
}
return true;
}
示例3: OnPrepareFileItems
void CGUIWindowPVRSearch::OnPrepareFileItems(CFileItemList &items)
{
items.Clear();
CFileItemPtr item(new CFileItem("pvr://guide/searchresults/search/", true));
item->SetLabel(g_localizeStrings.Get(19140));
item->SetLabelPreformated(true);
item->SetSpecialSort(SortSpecialOnTop);
items.Add(item);
if (m_bSearchConfirmed)
{
CGUIDialogProgress* dlgProgress = (CGUIDialogProgress*)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
if (dlgProgress)
{
dlgProgress->SetHeading(194);
dlgProgress->SetText(CVariant(m_searchfilter.m_strSearchTerm));
dlgProgress->StartModal();
dlgProgress->Progress();
}
// TODO should we limit the find similar search to the selected group?
g_EpgContainer.GetEPGSearch(items, m_searchfilter);
if (dlgProgress)
dlgProgress->Close();
if (items.IsEmpty())
{
CGUIDialogOK::ShowAndGetInput(194, 284, 0, 0);
m_bSearchConfirmed = false;
}
}
}
示例4: GetChilds
// Get the child fileitems of this node
bool CDirectoryNode::GetChilds(CFileItemList& items)
{
if (CanCache() && items.Load())
return true;
auto_ptr<CDirectoryNode> pNode(CDirectoryNode::CreateNode(GetChildType(), "", this));
bool bSuccess=false;
if (pNode.get())
{
pNode->m_options = m_options;
bSuccess=pNode->GetContent(items);
if (bSuccess)
{
AddQueuingFolder(items);
if (CanCache())
items.SetCacheToDisc(CFileItemList::CACHE_ALWAYS);
}
else
items.Clear();
pNode->RemoveParent();
}
return bSuccess;
}
示例5: GetDirectory
bool CGUIWindowMusicPlaylistEditor::GetDirectory(const std::string &strDirectory, CFileItemList &items)
{
items.Clear();
if (strDirectory.empty())
{ // root listing - list files:// and musicdb://
CFileItemPtr files(new CFileItem("files://", true));
files->SetLabel(g_localizeStrings.Get(744));
files->SetLabelPreformated(true);
files->m_bIsShareOrDrive = true;
items.Add(files);
CFileItemPtr db(new CFileItem("musicdb://", true));
db->SetLabel(g_localizeStrings.Get(14022));
db->SetLabelPreformated(true);
db->m_bIsShareOrDrive = true;
items.SetPath("");
items.Add(db);
return true;
}
if (!CGUIWindowMusicBase::GetDirectory(strDirectory, items))
return false;
// check for .CUE files here.
items.FilterCueItems();
return true;
}
示例6: DoWork
bool CTextureCleanupJob::DoWork()
{
CTextureDatabase db;
if (db.Open())
{
std::string path;
std::string fn;
std::string prevPath = "";
std::vector<std::string> pathContent;
XFILE::CSpecialProtocolDirectory thumbDir;
CFileItemList files;
int fileIdx = 0;
int totFileDel = 0;
int totDbDel = 0;
auto deleteFile = [&]()
{
std::string todel = files.Get(fileIdx)->GetPath();
CLog::Log(LOGDEBUG, "CTextureCleanupJob: deleting %s", todel.c_str());
XFILE::CFile::Delete(todel);
totFileDel++;
fileIdx++;
};
std::vector<std::pair<int, std::string>> urls = db.GetCachedTextureUrls();
for (const auto &url : urls)
{
std::string cachedurl = url.second;
URIUtils::Split(cachedurl, path, fn);
std::string cmpurl = "special://thumbnails/" + cachedurl;
if (path != prevPath)
{
while (fileIdx < files.Size())
deleteFile();
files.Clear();
thumbDir.GetDirectory(CURL("special://thumbnails/" + path), files);
files.Sort(SortByPath, SortOrderAscending);
prevPath = path;
fileIdx = 0;
}
while (fileIdx < files.Size() && files.Get(fileIdx)->GetPath() < cmpurl)
deleteFile();
if (fileIdx < files.Size() && files.Get(fileIdx)->GetPath() == cmpurl)
fileIdx++;
else
{
// No file for current entry; delete it
CLog::Log(LOGDEBUG, "CTextureCleanupJob: deleting from Db: %d / %s", url.first, cachedurl.c_str());
db.ClearCachedTexture(url.first, cachedurl);
totDbDel++;
}
}
while (fileIdx < files.Size())
deleteFile();
CLog::Log(LOGDEBUG, "CTextureCleanupJob: %d thumbnails deleted / %d db entries removed", totFileDel, totDbDel);
}
return true;
}
示例7: GetDirectory
bool CFavouritesDirectory::GetDirectory(const CURL& url, CFileItemList &items)
{
items.Clear();
if (url.IsProtocol("favourites"))
{
return Load(items); //load the default favourite files
}
return LoadFavourites(url.Get(), items); //directly load the given file
}
示例8: InitCache
void CDirectoryCache::InitCache(set<CStdString>& dirs)
{
set<CStdString>::iterator it;
for (it = dirs.begin(); it != dirs.end(); ++it)
{
const CStdString& strDir = *it;
CFileItemList items;
CDirectory::GetDirectory(strDir, items, "", DIR_FLAG_NO_FILE_DIRS);
items.Clear();
}
}
示例9: GetDirectory
bool CFavouritesDirectory::GetDirectory(const CStdString& strPath, CFileItemList &items)
{
items.Clear();
CURL url(strPath);
if (url.GetProtocol() == "favourites")
{
Load(items); //load the default favourite files
}
return LoadFavourites(strPath, items); //directly load the given file
}
示例10: GetDirectory
bool CWinLibraryDirectory::GetDirectory(const CURL &url, CFileItemList &items)
{
items.Clear();
auto folder = GetFolder(url);
if (!folder)
return false;
// We accept win-lib://library/path[/]
std::string path = url.Get();
URIUtils::AddSlashAtEnd(path); //be sure the dir ends with a slash
auto vectorView = Wait(folder->GetItemsAsync());
for (unsigned i = 0; i < vectorView->Size; i++)
{
IStorageItem^ item = vectorView->GetAt(i);
std::string itemName = FromW(std::wstring(item->Name->Data()));
CFileItemPtr pItem(new CFileItem(itemName));
pItem->m_bIsFolder = (item->Attributes & FileAttributes::Directory) == FileAttributes::Directory;
IStorageItemProperties^ storageItemProperties = dynamic_cast<IStorageItemProperties^>(item);
if (item != nullptr)
{
pItem->m_strTitle = FromW(storageItemProperties->DisplayName->Data());
}
if (pItem->m_bIsFolder)
pItem->SetPath(path + itemName + "/");
else
pItem->SetPath(path + itemName);
if (itemName.front() == '.')
pItem->SetProperty("file:hidden", true);
auto props = Wait(item->GetBasicPropertiesAsync());
ULARGE_INTEGER ularge = { 0 };
if (props->DateModified.UniversalTime > 0)
ularge.QuadPart = static_cast<uint64_t>(props->DateModified.UniversalTime);
FILETIME localTime =
{
ularge.LowPart,
ularge.HighPart
};
pItem->m_dateTime = localTime;
if (!pItem->m_bIsFolder)
pItem->m_dwSize = static_cast<int64_t>(props->Size);
items.Add(pItem);
}
return true;
}
示例11: GetDirectory
bool GetDirectory(CFileItemList& list)
{
/* if it was not finished or failed, return failure */
if(!m_result->m_event.WaitMSec(0) || !m_result->m_result)
{
list.Clear();
return false;
}
list.Copy(m_result->m_list);
return true;
}
示例12: PrunePackageCache
void CAddonInstaller::PrunePackageCache()
{
std::map<std::string,CFileItemList*> packs;
int64_t size = EnumeratePackageFolder(packs);
int64_t limit = (int64_t)g_advancedSettings.m_addonPackageFolderSize * 1024 * 1024;
if (size < limit)
return;
// Prune packages
// 1. Remove the largest packages, leaving at least 2 for each add-on
CFileItemList items;
CAddonDatabase db;
db.Open();
for (std::map<std::string,CFileItemList*>::const_iterator it = packs.begin(); it != packs.end(); ++it)
{
it->second->Sort(SortByLabel, SortOrderDescending);
for (int j = 2; j < it->second->Size(); j++)
items.Add(CFileItemPtr(new CFileItem(*it->second->Get(j))));
}
items.Sort(SortBySize, SortOrderDescending);
int i = 0;
while (size > limit && i < items.Size())
{
size -= items[i]->m_dwSize;
db.RemovePackage(items[i]->GetPath());
CFileUtils::DeleteItem(items[i++], true);
}
if (size > limit)
{
// 2. Remove the oldest packages (leaving least 1 for each add-on)
items.Clear();
for (std::map<std::string,CFileItemList*>::iterator it = packs.begin(); it != packs.end(); ++it)
{
if (it->second->Size() > 1)
items.Add(CFileItemPtr(new CFileItem(*it->second->Get(1))));
}
items.Sort(SortByDate, SortOrderAscending);
i = 0;
while (size > limit && i < items.Size())
{
size -= items[i]->m_dwSize;
db.RemovePackage(items[i]->GetPath());
CFileUtils::DeleteItem(items[i++],true);
}
}
// clean up our mess
for (std::map<std::string,CFileItemList*>::iterator it = packs.begin(); it != packs.end(); ++it)
delete it->second;
}
示例13: ShowPlaySelection
bool CGUIDialogSimpleMenu::ShowPlaySelection(CFileItem& item, const std::string& directory)
{
CFileItemList items;
if (!XFILE::CDirectory::GetDirectory(directory, items, XFILE::CDirectory::CHints(), true))
{
CLog::Log(LOGERROR, "CGUIWindowVideoBase::ShowPlaySelection - Failed to get play directory for %s", directory.c_str());
return true;
}
if (items.IsEmpty())
{
CLog::Log(LOGERROR, "CGUIWindowVideoBase::ShowPlaySelection - Failed to get any items %s", directory.c_str());
return true;
}
CGUIDialogSelect* dialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT);
while (true)
{
dialog->Reset();
dialog->SetHeading(CVariant{25006}); // Select playback item
dialog->SetItems(items);
dialog->SetUseDetails(true);
dialog->Open();
CFileItemPtr item_new = dialog->GetSelectedItem();
if (!item_new || dialog->GetSelectedLabel() < 0)
{
CLog::Log(LOGDEBUG, "CGUIWindowVideoBase::ShowPlaySelection - User aborted %s", directory.c_str());
break;
}
if (item_new->m_bIsFolder == false)
{
std::string original_path = item.GetPath();
item.Reset();
item = *item_new;
item.SetProperty("original_listitem_url", original_path);
return true;
}
items.Clear();
if (!XFILE::CDirectory::GetDirectory(item_new->GetPath(), items, XFILE::CDirectory::CHints(), true) || items.IsEmpty())
{
CLog::Log(LOGERROR, "CGUIWindowVideoBase::ShowPlaySelection - Failed to get any items %s", item_new->GetPath().c_str());
break;
}
}
return false;
}
示例14: GetViewChannelItems
void CGUIWindowPVRGuide::GetViewChannelItems(CFileItemList &items)
{
CPVRChannelPtr currentChannel(g_PVRManager.GetCurrentChannel());
items.Clear();
if (!currentChannel || g_PVRManager.GetCurrentEpg(items) == 0)
{
CFileItemPtr item;
item.reset(new CFileItem("pvr://guide/channel/empty.epg", false));
item->SetLabel(g_localizeStrings.Get(19028));
item->SetLabelPreformated(true);
items.Add(item);
}
}
示例15: GetViewNextItems
void CGUIWindowPVRGuide::GetViewNextItems(CFileItemList &items)
{
items.Clear();
int iEpgItems = GetChannelGroup()->GetEPGNext(items);
if (iEpgItems)
{
CFileItemPtr item;
item.reset(new CFileItem("pvr://guide/next/empty.epg", false));
item->SetLabel(g_localizeStrings.Get(19028));
item->SetLabelPreformated(true);
items.Add(item);
}
}