本文整理汇总了C++中CFileItemList类的典型用法代码示例。如果您正苦于以下问题:C++ CFileItemList类的具体用法?C++ CFileItemList怎么用?C++ CFileItemList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CFileItemList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MergeItems
void CMultiPathDirectory::MergeItems(CFileItemList &items)
{
CLog::Log(LOGDEBUG, "CMultiPathDirectory::MergeItems, items = %i", (int)items.Size());
unsigned int time = XbmcThreads::SystemClockMillis();
if (items.Size() == 0)
return;
// sort items by label
// folders are before files in this sort method
items.Sort(SORT_METHOD_LABEL, SortOrderAscending);
int i = 0;
// if first item in the sorted list is a file, just abort
if (!items.Get(i)->m_bIsFolder)
return;
while (i + 1 < items.Size())
{
// there are no more folders left, so exit the loop
CFileItemPtr pItem1 = items.Get(i);
if (!pItem1->m_bIsFolder)
break;
vector<int> stack;
stack.push_back(i);
CLog::Log(LOGDEBUG,"Testing path: [%03i] %s", i, pItem1->GetPath().c_str());
int j = i + 1;
do
{
CFileItemPtr pItem2 = items.Get(j);
if (!pItem2->GetLabel().Equals(pItem1->GetLabel()))
break;
// ignore any filefolders which may coincidently have
// the same label as a true folder
if (!pItem2->IsFileFolder())
{
stack.push_back(j);
CLog::Log(LOGDEBUG," Adding path: [%03i] %s", j, pItem2->GetPath().c_str());
}
j++;
}
while (j < items.Size());
// do we have anything to combine?
if (stack.size() > 1)
{
// we have a multipath so remove the items and add the new item
CStdString newPath = ConstructMultiPath(items, stack);
for (unsigned int k = stack.size() - 1; k > 0; --k)
items.Remove(stack[k]);
pItem1->SetPath(newPath);
CLog::Log(LOGDEBUG," New path: %s", pItem1->GetPath().c_str());
}
i++;
}
CLog::Log(LOGDEBUG,
"CMultiPathDirectory::MergeItems, items = %i, took %d ms",
items.Size(), XbmcThreads::SystemClockMillis() - time);
}
示例2: Update
void CGUIDialogFileBrowser::Update(const CStdString &strDirectory)
{
if (m_browsingForImages && m_thumbLoader.IsLoading())
m_thumbLoader.StopThread();
// get selected item
int iItem = m_viewControl.GetSelectedItem();
CStdString strSelectedItem = "";
if (iItem >= 0 && iItem < m_vecItems->Size())
{
CFileItemPtr pItem = (*m_vecItems)[iItem];
if (!pItem->IsParentFolder())
{
strSelectedItem = pItem->GetPath();
URIUtils::RemoveSlashAtEnd(strSelectedItem);
m_history.SetSelectedItem(strSelectedItem, m_Directory->GetPath().IsEmpty()?"empty":m_Directory->GetPath());
}
}
if (!m_singleList)
{
CFileItemList items;
CStdString strParentPath;
if (!m_rootDir.GetDirectory(strDirectory, items,m_useFileDirectories))
{
CLog::Log(LOGERROR,"CGUIDialogFileBrowser::GetDirectory(%s) failed", CURL::GetRedacted(strDirectory).c_str());
// We assume, we can get the parent
// directory again
CStdString strParentPath = m_history.GetParentPath();
m_history.RemoveParentPath();
Update(strParentPath);
return;
}
// check if current directory is a root share
if (!m_rootDir.IsSource(strDirectory))
{
if (URIUtils::GetParentPath(strDirectory, strParentPath))
{
CFileItemPtr pItem(new CFileItem(".."));
pItem->SetPath(strParentPath);
pItem->m_bIsFolder = true;
pItem->m_bIsShareOrDrive = false;
items.AddFront(pItem, 0);
}
}
else
{
// yes, this is the root of a share
// add parent path to the virtual directory
CFileItemPtr pItem(new CFileItem(".."));
pItem->SetPath("");
pItem->m_bIsShareOrDrive = false;
pItem->m_bIsFolder = true;
items.AddFront(pItem, 0);
strParentPath = "";
}
ClearFileItems();
m_vecItems->Copy(items);
m_Directory->SetPath(strDirectory);
m_strParentPath = strParentPath;
}
// if we're getting the root source listing
// make sure the path history is clean
if (strDirectory.IsEmpty())
m_history.ClearPathHistory();
// some evil stuff don't work with the '/' mask, e.g. shoutcast directory - make sure no files are in there
if (m_browsingForFolders)
{
for (int i=0;i<m_vecItems->Size();++i)
if (!(*m_vecItems)[i]->m_bIsFolder)
{
m_vecItems->Remove(i);
i--;
}
}
// No need to set thumbs
m_vecItems->FillInDefaultIcons();
OnSort();
if (m_Directory->GetPath().IsEmpty() && m_addNetworkShareEnabled &&
(CProfilesManager::Get().GetMasterProfile().getLockMode() == LOCK_MODE_EVERYONE ||
CProfilesManager::Get().IsMasterProfile() || g_passwordManager.bMasterUser))
{ // we are in the virtual directory - add the "Add Network Location" item
CFileItemPtr pItem(new CFileItem(g_localizeStrings.Get(1032)));
pItem->SetPath("net://");
pItem->m_bIsFolder = true;
m_vecItems->Add(pItem);
}
if (m_Directory->GetPath().IsEmpty() && !m_addSourceType.IsEmpty())
{
CFileItemPtr pItem(new CFileItem(g_localizeStrings.Get(21359)));
pItem->SetPath("source://");
//.........这里部分代码省略.........
示例3: validTypes
int CGUIWindowAddonBrowser::SelectAddonID(const vector<ADDON::TYPE> &types, vector<string> &addonIDs, bool showNone /* = false */, bool showDetails /* = true */, bool multipleSelection /* = true */, bool showInstalled /* = true */, bool showInstallable /* = false */, bool showMore /* = true */)
{
// if we shouldn't show neither installed nor installable addons the list will be empty
if (!showInstalled && !showInstallable)
return 0;
// can't show the "Get More" button if we already show installable addons
if (showInstallable)
showMore = false;
CGUIDialogSelect *dialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT);
if (!dialog)
return 0;
// get rid of any invalid addon types
vector<ADDON::TYPE> validTypes(types.size());
std::copy_if(types.begin(), types.end(), validTypes.begin(), [](ADDON::TYPE type) { return type != ADDON_UNKNOWN; });
if (validTypes.empty())
return 0;
// get all addons to show
VECADDONS addons;
if (showInstalled)
{
for (vector<ADDON::TYPE>::const_iterator type = validTypes.begin(); type != validTypes.end(); ++type)
{
VECADDONS typeAddons;
if (*type == ADDON_AUDIO)
CAddonsDirectory::GetScriptsAndPlugins("audio", typeAddons);
else if (*type == ADDON_EXECUTABLE)
CAddonsDirectory::GetScriptsAndPlugins("executable", typeAddons);
else if (*type == ADDON_IMAGE)
CAddonsDirectory::GetScriptsAndPlugins("image", typeAddons);
else if (*type == ADDON_VIDEO)
CAddonsDirectory::GetScriptsAndPlugins("video", typeAddons);
else
CAddonMgr::Get().GetAddons(*type, typeAddons);
addons.insert(addons.end(), typeAddons.begin(), typeAddons.end());
}
}
if (showInstallable || showMore)
{
VECADDONS installableAddons;
CAddonDatabase database;
if (database.Open() && database.GetAddons(installableAddons))
{
for (ADDON::IVECADDONS addon = installableAddons.begin(); addon != installableAddons.end();)
{
AddonPtr pAddon = *addon;
// check if the addon matches one of the provided addon types
bool matchesType = false;
for (vector<ADDON::TYPE>::const_iterator type = validTypes.begin(); type != validTypes.end(); ++type)
{
if (pAddon->IsType(*type))
{
matchesType = true;
break;
}
}
// only show addons that match one of the provided addon types and that aren't disabled
if (matchesType && !CAddonMgr::Get().IsAddonDisabled(pAddon->ID()))
{
// check if the addon is installed
bool isInstalled = CAddonMgr::Get().IsAddonInstalled(pAddon->ID());
// check if the addon is installed or can be installed
if ((showInstallable || showMore) && !isInstalled && CAddonMgr::Get().CanAddonBeInstalled(pAddon))
{
++addon;
continue;
}
}
addon = installableAddons.erase(addon);
}
if (showInstallable)
addons.insert(addons.end(), installableAddons.begin(), installableAddons.end());
else if (showMore)
showMore = !installableAddons.empty();
}
}
if (addons.empty() && !showNone)
return 0;
// turn the addons into items
std::map<std::string, AddonPtr> addonMap;
CFileItemList items;
for (ADDON::IVECADDONS addon = addons.begin(); addon != addons.end(); ++addon)
{
CFileItemPtr item(CAddonsDirectory::FileItemFromAddon(*addon, (*addon)->ID()));
if (!items.Contains(item->GetPath()))
{
items.Add(item);
//.........这里部分代码省略.........
示例4: OnGetFanart
// Allow user to select a Fanart
void CGUIDialogVideoInfo::OnGetFanart()
{
CFileItemList items;
CFileItem item(*m_movieItem->GetVideoInfoTag());
if (item.HasProperty("fanart_image"))
{
CFileItemPtr itemCurrent(new CFileItem("fanart://Current",false));
itemCurrent->SetThumbnailImage(item.GetProperty("fanart_image").asString());
itemCurrent->SetLabel(g_localizeStrings.Get(20440));
items.Add(itemCurrent);
}
// ensure the fanart is unpacked
m_movieItem->GetVideoInfoTag()->m_fanart.Unpack();
// Grab the thumbnails from the web
for (unsigned int i = 0; i < m_movieItem->GetVideoInfoTag()->m_fanart.GetNumFanarts(); i++)
{
CStdString strItemPath;
strItemPath.Format("fanart://Remote%i",i);
CFileItemPtr item(new CFileItem(strItemPath, false));
CStdString thumb = m_movieItem->GetVideoInfoTag()->m_fanart.GetPreviewURL(i);
item->SetThumbnailImage(CTextureCache::GetWrappedThumbURL(thumb));
item->SetIconImage("DefaultPicture.png");
item->SetLabel(g_localizeStrings.Get(20441));
// TODO: Do we need to clear the cached image?
// CTextureCache::Get().ClearCachedImage(thumb);
items.Add(item);
}
CStdString strLocal = item.GetLocalFanart();
if (!strLocal.IsEmpty())
{
CFileItemPtr itemLocal(new CFileItem("fanart://Local",false));
itemLocal->SetThumbnailImage(strLocal);
itemLocal->SetLabel(g_localizeStrings.Get(20438));
// TODO: Do we need to clear the cached image?
CTextureCache::Get().ClearCachedImage(strLocal);
items.Add(itemLocal);
}
else
{
CFileItemPtr itemNone(new CFileItem("fanart://None", false));
itemNone->SetIconImage("DefaultVideo.png");
itemNone->SetLabel(g_localizeStrings.Get(20439));
items.Add(itemNone);
}
CStdString result;
VECSOURCES sources(g_settings.m_videoSources);
g_mediaManager.GetLocalDrives(sources);
bool flip=false;
if (!CGUIDialogFileBrowser::ShowAndGetImage(items, sources, g_localizeStrings.Get(20437), result, &flip, 20445) || result.Equals("fanart://Current"))
return; // user cancelled
if (result.Equals("fanart://Local"))
result = strLocal;
if (result.Left(15) == "fanart://Remote")
{
int iFanart = atoi(result.Mid(15).c_str());
// set new primary fanart, and update our database accordingly
m_movieItem->GetVideoInfoTag()->m_fanart.SetPrimaryFanart(iFanart);
CVideoDatabase db;
if (db.Open())
{
db.UpdateFanart(*m_movieItem, (VIDEODB_CONTENT_TYPE)m_movieItem->GetVideoContentType());
db.Close();
}
result = m_movieItem->GetVideoInfoTag()->m_fanart.GetImageURL();
}
else if (result.Equals("fanart://None") || !CFile::Exists(result))
result.clear();
// set the fanart image
if (flip && !result.IsEmpty())
result = CTextureCache::GetWrappedImageURL(result, "", "flipped");
CVideoDatabase db;
if (db.Open())
{
db.SetArtForItem(m_movieItem->GetVideoInfoTag()->m_iDbId, m_movieItem->GetVideoInfoTag()->m_type, "fanart", result);
db.Close();
}
CUtil::DeleteVideoDatabaseDirectoryCache(); // to get them new thumbs to show
if (!result.IsEmpty())
m_movieItem->SetProperty("fanart_image", result);
else
m_movieItem->ClearProperty("fanart_image");
m_hasUpdatedThumb = true;
// Update our screen
Update();
}
示例5: defined
bool CRecentlyAddedJob::UpdateVideo()
{
CGUIWindow* home = g_windowManager.GetWindow(WINDOW_HOME);
if ( home == NULL )
return false;
CLog::Log(LOGDEBUG, "CRecentlyAddedJob::UpdateVideos() - Running RecentlyAdded home screen update");
int i = 0;
CFileItemList items;
CVideoDatabase videodatabase;
std::string path;
CVideoThumbLoader loader;
loader.OnLoaderStart();
path = g_advancedSettings.m_recentlyAddedMoviePath;
if (g_advancedSettings.m_iVideoLibraryRecentlyAddedUnseen)
{
CVideoDbUrl url;
url.FromString(path);
url.AddOption("filter", "{\"type\":\"movies\", \"rules\":[{\"field\":\"playcount\", \"operator\":\"is\", \"value\":\"0\"}]}");
path = url.ToString();
}
videodatabase.Open();
if (videodatabase.GetRecentlyAddedMoviesNav(path, items, NUM_ITEMS))
{
for (; i < items.Size(); ++i)
{
CFileItemPtr item = items.Get(i);
std::string value = StringUtils::Format("%i", i + 1);
std::string strRating = StringUtils::Format("%.1f", item->GetVideoInfoTag()->m_fRating);
home->SetProperty("LatestMovie." + value + ".Title" , item->GetLabel());
home->SetProperty("LatestMovie." + value + ".Rating" , strRating);
home->SetProperty("LatestMovie." + value + ".Year" , item->GetVideoInfoTag()->m_iYear);
home->SetProperty("LatestMovie." + value + ".Plot" , item->GetVideoInfoTag()->m_strPlot);
home->SetProperty("LatestMovie." + value + ".RunningTime" , item->GetVideoInfoTag()->GetDuration() / 60);
home->SetProperty("LatestMovie." + value + ".Path" , item->GetVideoInfoTag()->m_strFileNameAndPath);
home->SetProperty("LatestMovie." + value + ".Trailer" , item->GetVideoInfoTag()->m_strTrailer);
if (!item->HasArt("thumb"))
loader.LoadItem(item.get());
home->SetProperty("LatestMovie." + value + ".Thumb" , item->GetArt("thumb"));
home->SetProperty("LatestMovie." + value + ".Fanart" , item->GetArt("fanart"));
}
}
for (; i < NUM_ITEMS; ++i)
{
std::string value = StringUtils::Format("%i", i + 1);
home->SetProperty("LatestMovie." + value + ".Title" , "");
home->SetProperty("LatestMovie." + value + ".Thumb" , "");
home->SetProperty("LatestMovie." + value + ".Rating" , "");
home->SetProperty("LatestMovie." + value + ".Year" , "");
home->SetProperty("LatestMovie." + value + ".Plot" , "");
home->SetProperty("LatestMovie." + value + ".RunningTime" , "");
home->SetProperty("LatestMovie." + value + ".Path" , "");
home->SetProperty("LatestMovie." + value + ".Trailer" , "");
home->SetProperty("LatestMovie." + value + ".Fanart" , "");
}
i = 0;
CFileItemList TVShowItems;
path = g_advancedSettings.m_recentlyAddedEpisodePath;
if (g_advancedSettings.m_iVideoLibraryRecentlyAddedUnseen)
{
CVideoDbUrl url;
url.FromString(path);
url.AddOption("filter", "{\"type\":\"episodes\", \"rules\":[{\"field\":\"playcount\", \"operator\":\"is\", \"value\":\"0\"}]}");
path = url.ToString();
}
if (videodatabase.GetRecentlyAddedEpisodesNav(path, TVShowItems, NUM_ITEMS))
{
for (; i < TVShowItems.Size(); ++i)
{
CFileItemPtr item = TVShowItems.Get(i);
int EpisodeSeason = item->GetVideoInfoTag()->m_iSeason;
int EpisodeNumber = item->GetVideoInfoTag()->m_iEpisode;
std::string EpisodeNo = StringUtils::Format("s%02de%02d", EpisodeSeason, EpisodeNumber);
std::string value = StringUtils::Format("%i", i + 1);
std::string strRating = StringUtils::Format("%.1f", item->GetVideoInfoTag()->m_fRating);
home->SetProperty("LatestEpisode." + value + ".ShowTitle" , item->GetVideoInfoTag()->m_strShowTitle);
home->SetProperty("LatestEpisode." + value + ".EpisodeTitle" , item->GetVideoInfoTag()->m_strTitle);
home->SetProperty("LatestEpisode." + value + ".Rating" , strRating);
home->SetProperty("LatestEpisode." + value + ".Plot" , item->GetVideoInfoTag()->m_strPlot);
home->SetProperty("LatestEpisode." + value + ".EpisodeNo" , EpisodeNo);
home->SetProperty("LatestEpisode." + value + ".EpisodeSeason" , EpisodeSeason);
home->SetProperty("LatestEpisode." + value + ".EpisodeNumber" , EpisodeNumber);
home->SetProperty("LatestEpisode." + value + ".Path" , item->GetVideoInfoTag()->m_strFileNameAndPath);
if (!item->HasArt("thumb"))
loader.LoadItem(item.get());
std::string seasonThumb;
if (item->GetVideoInfoTag()->m_iIdSeason > 0)
//.........这里部分代码省略.........
示例6: switch
//.........这里部分代码省略.........
g_application.InhibitIdleShutdown(pMsg->param1 != 0);
}
break;
case TMSG_ACTIVATESCREENSAVER:
{
g_application.ActivateScreenSaver();
}
break;
case TMSG_MEDIA_PLAY:
{
// first check if we were called from the PlayFile() function
if (pMsg->lpVoid && pMsg->param2 == 0)
{
CFileItem *item = (CFileItem *)pMsg->lpVoid;
g_application.PlayFile(*item, pMsg->param1 != 0);
delete item;
return;
}
// restore to previous window if needed
if (g_windowManager.GetActiveWindow() == WINDOW_SLIDESHOW ||
g_windowManager.GetActiveWindow() == WINDOW_FULLSCREEN_VIDEO ||
g_windowManager.GetActiveWindow() == WINDOW_VISUALISATION)
g_windowManager.PreviousWindow();
g_application.ResetScreenSaver();
g_application.WakeUpScreenSaverAndDPMS();
//g_application.StopPlaying();
// play file
if(pMsg->lpVoid)
{
CFileItemList *list = (CFileItemList *)pMsg->lpVoid;
if (list->Size() > 0)
{
int playlist = PLAYLIST_MUSIC;
for (int i = 0; i < list->Size(); i++)
{
if ((*list)[i]->IsVideo())
{
playlist = PLAYLIST_VIDEO;
break;
}
}
g_playlistPlayer.ClearPlaylist(playlist);
g_playlistPlayer.SetCurrentPlaylist(playlist);
//For single item lists try PlayMedia. This covers some more cases where a playlist is not appropriate
//It will fall through to PlayFile
if (list->Size() == 1 && !(*list)[0]->IsPlayList())
g_application.PlayMedia(*((*list)[0]), playlist);
else
{
// Handle "shuffled" option if present
if (list->HasProperty("shuffled") && list->GetProperty("shuffled").isBoolean())
g_playlistPlayer.SetShuffle(playlist, list->GetProperty("shuffled").asBoolean(), false);
// Handle "repeat" option if present
if (list->HasProperty("repeat") && list->GetProperty("repeat").isInteger())
g_playlistPlayer.SetRepeat(playlist, (PLAYLIST::REPEAT_STATE)list->GetProperty("repeat").asInteger(), false);
g_playlistPlayer.Add(playlist, (*list));
g_playlistPlayer.Play(pMsg->param1);
}
}
示例7: InitFromUrl
bool CRarFile::Open(const CURL& url)
{
InitFromUrl(url);
CFileItemList items;
g_RarManager.GetFilesInRar(items,m_strRarPath,false);
int i;
for (i=0;i<items.Size();++i)
{
if (items[i]->GetLabel() == m_strPathInRar)
break;
}
if (i<items.Size())
{
if (items[i]->m_idepth == 0x30) // stored
{
if (!OpenInArchive())
return false;
m_iFileSize = items[i]->m_dwSize;
m_bOpen = true;
// perform 'noidx' check
CFileInfo* pFile = g_RarManager.GetFileInRar(m_strRarPath,m_strPathInRar);
if (pFile)
{
if (pFile->m_iIsSeekable == -1)
{
if (Seek(-1,SEEK_END) == -1)
{
m_bSeekable = false;
pFile->m_iIsSeekable = 0;
}
}
else
m_bSeekable = (pFile->m_iIsSeekable == 1);
}
return true;
}
else
{
CFileInfo* info = g_RarManager.GetFileInRar(m_strRarPath,m_strPathInRar);
if ((!info || !CFile::Exists(info->m_strCachedPath)) && m_bFileOptions & EXFILE_NOCACHE)
return false;
m_bUseFile = true;
CStdString strPathInCache;
if (!g_RarManager.CacheRarredFile(strPathInCache, m_strRarPath, m_strPathInRar,
EXFILE_AUTODELETE | m_bFileOptions, m_strCacheDir,
items[i]->m_dwSize))
{
CLog::Log(LOGERROR,"filerar::open failed to cache file %s",m_strPathInRar.c_str());
return false;
}
if (!m_File.Open( strPathInCache ))
{
CLog::Log(LOGERROR,"filerar::open failed to open file in cache: %s",strPathInCache.c_str());
return false;
}
m_bOpen = true;
return true;
}
}
return false;
}
示例8: Add
void CPlayList::Add(CFileItemList& items)
{
for (int i = 0; i < (int)items.Size(); i++)
Add(items[i]);
}
示例9: GetDirectory
bool CGUIWindowMusicNav::GetDirectory(const CStdString &strDirectory, CFileItemList &items)
{
if (m_bDisplayEmptyDatabaseMessage)
return true;
if (strDirectory.empty())
AddSearchFolder();
bool bResult = CGUIWindowMusicBase::GetDirectory(strDirectory, items);
if (bResult)
{
if (items.IsPlayList())
OnRetrieveMusicInfo(items);
}
// update our content in the info manager
if (StringUtils::StartsWithNoCase(strDirectory, "videodb://"))
{
CVideoDatabaseDirectory dir;
VIDEODATABASEDIRECTORY::NODE_TYPE node = dir.GetDirectoryChildType(strDirectory);
if (node == VIDEODATABASEDIRECTORY::NODE_TYPE_TITLE_MUSICVIDEOS ||
node == VIDEODATABASEDIRECTORY::NODE_TYPE_RECENTLY_ADDED_MUSICVIDEOS)
items.SetContent("musicvideos");
else if (node == VIDEODATABASEDIRECTORY::NODE_TYPE_GENRE)
items.SetContent("genres");
else if (node == VIDEODATABASEDIRECTORY::NODE_TYPE_COUNTRY)
items.SetContent("countries");
else if (node == VIDEODATABASEDIRECTORY::NODE_TYPE_ACTOR)
items.SetContent("artists");
else if (node == VIDEODATABASEDIRECTORY::NODE_TYPE_DIRECTOR)
items.SetContent("directors");
else if (node == VIDEODATABASEDIRECTORY::NODE_TYPE_STUDIO)
items.SetContent("studios");
else if (node == VIDEODATABASEDIRECTORY::NODE_TYPE_YEAR)
items.SetContent("years");
else if (node == VIDEODATABASEDIRECTORY::NODE_TYPE_MUSICVIDEOS_ALBUM)
items.SetContent("albums");
else if (node == VIDEODATABASEDIRECTORY::NODE_TYPE_TAGS)
items.SetContent("tags");
}
else if (StringUtils::StartsWithNoCase(strDirectory, "musicdb://"))
{
CMusicDatabaseDirectory dir;
NODE_TYPE node = dir.GetDirectoryChildType(strDirectory);
if (node == NODE_TYPE_ALBUM ||
node == NODE_TYPE_ALBUM_RECENTLY_ADDED ||
node == NODE_TYPE_ALBUM_RECENTLY_PLAYED ||
node == NODE_TYPE_ALBUM_TOP100 ||
node == NODE_TYPE_ALBUM_COMPILATIONS ||
node == NODE_TYPE_YEAR_ALBUM)
items.SetContent("albums");
else if (node == NODE_TYPE_ARTIST)
items.SetContent("artists");
else if (node == NODE_TYPE_SONG ||
node == NODE_TYPE_SONG_TOP100 ||
node == NODE_TYPE_SINGLES ||
node == NODE_TYPE_ALBUM_RECENTLY_ADDED_SONGS ||
node == NODE_TYPE_ALBUM_RECENTLY_PLAYED_SONGS ||
node == NODE_TYPE_ALBUM_COMPILATIONS_SONGS ||
node == NODE_TYPE_ALBUM_TOP100_SONGS ||
node == NODE_TYPE_YEAR_SONG)
items.SetContent("songs");
else if (node == NODE_TYPE_GENRE)
items.SetContent("genres");
else if (node == NODE_TYPE_YEAR)
items.SetContent("years");
}
else if (strDirectory.Equals("special://musicplaylists/"))
items.SetContent("playlists");
else if (strDirectory.Equals("plugin://music/"))
items.SetContent("plugins");
else if (items.IsPlayList())
items.SetContent("songs");
return bResult;
}
示例10: GetNode
bool CLibraryDirectory::GetDirectory(const CStdString& strPath, CFileItemList &items)
{
CStdString libNode = GetNode(strPath);
if (libNode.IsEmpty())
return false;
if (URIUtils::HasExtension(libNode, ".xml"))
{ // a filter node
TiXmlElement *node = LoadXML(libNode);
if (node)
{
CStdString type = node->Attribute("type");
if (type == "filter")
{
CSmartPlaylist playlist;
CStdString type, label;
XMLUtils::GetString(node, "content", type);
if (type.IsEmpty())
{
CLog::Log(LOGERROR, "<content> tag must not be empty for type=\"filter\" node '%s'", libNode.c_str());
return false;
}
if (XMLUtils::GetString(node, "label", label))
label = CGUIControlFactory::FilterLabel(label);
playlist.SetType(type);
playlist.SetName(label);
if (playlist.LoadFromXML(node) &&
CSmartPlaylistDirectory::GetDirectory(playlist, items))
{
items.SetProperty("library.filter", "true");
return true;
}
}
}
return false;
}
// just a plain node - read the folder for XML nodes and other folders
CFileItemList nodes;
if (!CDirectory::GetDirectory(libNode, nodes, ".xml", DIR_FLAG_NO_FILE_DIRS))
return false;
// iterate over our nodes
for (int i = 0; i < nodes.Size(); i++)
{
const TiXmlElement *node = NULL;
CStdString xml = nodes[i]->GetPath();
if (nodes[i]->m_bIsFolder)
node = LoadXML(URIUtils::AddFileToFolder(xml, "index.xml"));
else
{
node = LoadXML(xml);
if (node && URIUtils::GetFileName(xml).Equals("index.xml"))
{ // set the label on our items
CStdString label;
if (XMLUtils::GetString(node, "label", label))
label = CGUIControlFactory::FilterLabel(label);
items.SetLabel(label);
continue;
}
}
if (node)
{
CStdString label, icon;
if (XMLUtils::GetString(node, "label", label))
label = CGUIControlFactory::FilterLabel(label);
XMLUtils::GetString(node, "icon", icon);
CStdString type = node->Attribute("type");
int order = 0;
node->Attribute("order", &order);
CFileItemPtr item;
if (type == "folder")
{ // folder type - grab our path
CStdString path;
XMLUtils::GetPath(node, "path", path);
if (path.IsEmpty())
{
CLog::Log(LOGERROR, "<path> tag must be not be empty for type=\"folder\" node '%s'", xml.c_str());
continue;
}
item.reset(new CFileItem(path, true));
}
else
{ // virtual folder or filter
URIUtils::RemoveSlashAtEnd(xml);
CStdString folder = URIUtils::GetFileName(xml);
item.reset(new CFileItem(URIUtils::AddFileToFolder(strPath, folder), true));
}
item->SetLabel(label);
if (!icon.IsEmpty() && g_TextureManager.HasTexture(icon))
item->SetIconImage(icon);
item->m_iprogramCount = order;
items.Add(item);
}
}
items.Sort(SortByPlaylistOrder, SortOrderAscending);
return true;
}
示例11: GetSelectedItem
bool CGUIWindowFileManager::Update(int iList, const CStdString &strDirectory)
{
// get selected item
int iItem = GetSelectedItem(iList);
CStdString strSelectedItem = "";
if (iItem >= 0 && iItem < (int)m_vecItems[iList]->Size())
{
CFileItemPtr pItem = m_vecItems[iList]->Get(iItem);
if (!pItem->IsParentFolder())
{
GetDirectoryHistoryString(pItem.get(), strSelectedItem);
m_history[iList].SetSelectedItem(strSelectedItem, m_Directory[iList]->GetPath());
}
}
CStdString strOldDirectory=m_Directory[iList]->GetPath();
m_Directory[iList]->SetPath(strDirectory);
CFileItemList items;
if (!GetDirectory(iList, m_Directory[iList]->GetPath(), items))
{
m_Directory[iList]->SetPath(strOldDirectory);
return false;
}
m_history[iList].SetSelectedItem(strSelectedItem, strOldDirectory);
ClearFileItems(iList);
m_vecItems[iList]->Append(items);
m_vecItems[iList]->SetPath(items.GetPath());
CStdString strParentPath;
URIUtils::GetParentPath(strDirectory, strParentPath);
if (strDirectory.IsEmpty() && (m_vecItems[iList]->Size() == 0 || g_guiSettings.GetBool("filelists.showaddsourcebuttons")))
{ // add 'add source button'
CStdString strLabel = g_localizeStrings.Get(1026);
CFileItemPtr pItem(new CFileItem(strLabel));
pItem->SetPath("add");
pItem->SetIconImage("DefaultAddSource.png");
pItem->SetLabel(strLabel);
pItem->SetLabelPreformated(true);
pItem->m_bIsFolder = true;
pItem->SetSpecialSort(SortSpecialOnBottom);
m_vecItems[iList]->Add(pItem);
}
else if (items.IsEmpty() || g_guiSettings.GetBool("filelists.showparentdiritems"))
{
CFileItemPtr pItem(new CFileItem(".."));
pItem->SetPath(m_rootDir.IsSource(strDirectory) ? "" : strParentPath);
pItem->m_bIsFolder = true;
pItem->m_bIsShareOrDrive = false;
m_vecItems[iList]->AddFront(pItem, 0);
}
m_strParentPath[iList] = (m_rootDir.IsSource(strDirectory) ? "" : strParentPath);
if (strDirectory.IsEmpty())
{
CFileItemPtr pItem(new CFileItem("special://profile/", true));
pItem->SetLabel(g_localizeStrings.Get(20070));
pItem->SetThumbnailImage("DefaultFolder.png");
pItem->SetLabelPreformated(true);
m_vecItems[iList]->Add(pItem);
}
// if we have a .tbn file, use itself as the thumb
for (int i = 0; i < (int)m_vecItems[iList]->Size(); i++)
{
CFileItemPtr pItem = m_vecItems[iList]->Get(i);
CStdString strExtension;
URIUtils::GetExtension(pItem->GetPath(), strExtension);
if (pItem->IsHD() && strExtension == ".tbn")
{
pItem->SetThumbnailImage(pItem->GetPath());
}
}
m_vecItems[iList]->FillInDefaultIcons();
OnSort(iList);
UpdateButtons();
int item = 0;
strSelectedItem = m_history[iList].GetSelectedItem(m_Directory[iList]->GetPath());
for (int i = 0; i < m_vecItems[iList]->Size(); ++i)
{
CFileItemPtr pItem = m_vecItems[iList]->Get(i);
CStdString strHistory;
GetDirectoryHistoryString(pItem.get(), strHistory);
if (strHistory == strSelectedItem)
{
item = i;
break;
}
}
UpdateControl(iList, item);
return true;
}
示例12: GetSlideShowContents
void CGUIWindowSlideShow::GetSlideShowContents(CFileItemList &list)
{
for (int index = 0; index < m_slides->Size(); index++)
list.Add(CFileItemPtr(new CFileItem(*m_slides->Get(index))));
}
示例13: switch
//.........这里部分代码省略.........
#endif
}
break;
case TMSG_INHIBITIDLESHUTDOWN:
{
g_application.InhibitIdleShutdown((bool)pMsg->dwParam1);
}
break;
case TMSG_MEDIA_PLAY:
{
// first check if we were called from the PlayFile() function
if (pMsg->lpVoid && pMsg->dwParam2 == 0)
{
CFileItem *item = (CFileItem *)pMsg->lpVoid;
g_application.PlayFile(*item, pMsg->dwParam1 != 0);
delete item;
return;
}
// restore to previous window if needed
if (g_windowManager.GetActiveWindow() == WINDOW_SLIDESHOW ||
g_windowManager.GetActiveWindow() == WINDOW_FULLSCREEN_VIDEO ||
g_windowManager.GetActiveWindow() == WINDOW_VISUALISATION)
g_windowManager.PreviousWindow();
g_application.ResetScreenSaver();
g_application.WakeUpScreenSaverAndDPMS();
//g_application.StopPlaying();
// play file
if(pMsg->lpVoid)
{
CFileItemList *list = (CFileItemList *)pMsg->lpVoid;
if (list->Size() > 0)
{
int playlist = PLAYLIST_MUSIC;
for (int i = 0; i < list->Size(); i++)
{
if ((*list)[i]->IsVideo())
{
playlist = PLAYLIST_VIDEO;
break;
}
}
g_playlistPlayer.ClearPlaylist(playlist);
g_playlistPlayer.SetCurrentPlaylist(playlist);
//For single item lists try PlayMedia. This covers some more cases where a playlist is not appropriate
//It will fall through to PlayFile
if (list->Size() == 1 && !(*list)[0]->IsPlayList())
g_application.PlayMedia(*((*list)[0]), playlist);
else
{
// Handle "shuffled" option if present
if (list->HasProperty("shuffled") && list->GetProperty("shuffled").isBoolean())
g_playlistPlayer.SetShuffle(playlist, list->GetProperty("shuffled").asBoolean(), false);
// Handle "repeat" option if present
if (list->HasProperty("repeat") && list->GetProperty("repeat").isInteger())
g_playlistPlayer.SetRepeat(playlist, (PLAYLIST::REPEAT_STATE)list->GetProperty("repeat").asInteger(), false);
g_playlistPlayer.Add(playlist, (*list));
g_playlistPlayer.Play(pMsg->dwParam1);
}
}
示例14: progressTime
bool CMultiPathDirectory::GetDirectory(const CStdString& strPath, CFileItemList &items)
{
CLog::Log(LOGDEBUG,"CMultiPathDirectory::GetDirectory(%s)", strPath.c_str());
vector<CStdString> vecPaths;
if (!GetPaths(strPath, vecPaths))
return false;
XbmcThreads::EndTime progressTime(3000); // 3 seconds before showing progress bar
CGUIDialogProgress* dlgProgress = NULL;
unsigned int iFailures = 0;
for (unsigned int i = 0; i < vecPaths.size(); ++i)
{
// show the progress dialog if we have passed our time limit
if (progressTime.IsTimePast() && !dlgProgress)
{
dlgProgress = (CGUIDialogProgress *)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
if (dlgProgress)
{
dlgProgress->SetHeading(15310);
dlgProgress->SetLine(0, 15311);
dlgProgress->SetLine(1, "");
dlgProgress->SetLine(2, "");
dlgProgress->StartModal();
dlgProgress->ShowProgressBar(true);
dlgProgress->SetProgressMax((int)vecPaths.size()*2);
dlgProgress->Progress();
}
}
if (dlgProgress)
{
CURL url(vecPaths[i]);
dlgProgress->SetLine(1, url.GetWithoutUserDetails());
dlgProgress->SetProgressAdvance();
dlgProgress->Progress();
}
CFileItemList tempItems;
CLog::Log(LOGDEBUG,"Getting Directory (%s)", vecPaths[i].c_str());
if (CDirectory::GetDirectory(vecPaths[i], tempItems, m_strFileMask, m_flags))
items.Append(tempItems);
else
{
CLog::Log(LOGERROR,"Error Getting Directory (%s)", vecPaths[i].c_str());
iFailures++;
}
if (dlgProgress)
{
dlgProgress->SetProgressAdvance();
dlgProgress->Progress();
}
}
if (dlgProgress)
dlgProgress->Close();
if (iFailures == vecPaths.size())
return false;
// merge like-named folders into a sub multipath:// style url
MergeItems(items);
return true;
}
示例15: switch
JSONRPC_STATUS CPlayerOperations::Open(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result)
{
CVariant optionShuffled = parameterObject["options"]["shuffled"];
CVariant optionRepeat = parameterObject["options"]["repeat"];
CVariant optionResume = parameterObject["options"]["resume"];
if (parameterObject["item"].isObject() && parameterObject["item"].isMember("playlistid"))
{
int playlistid = (int)parameterObject["item"]["playlistid"].asInteger();
if (playlistid < PLAYLIST_PICTURE)
{
// Apply the "shuffled" option if available
if (optionShuffled.isBoolean())
g_playlistPlayer.SetShuffle(playlistid, optionShuffled.asBoolean(), false);
// Apply the "repeat" option if available
if (!optionRepeat.isNull())
g_playlistPlayer.SetRepeat(playlistid, (REPEAT_STATE)ParseRepeatState(optionRepeat), false);
}
switch (playlistid)
{
case PLAYLIST_MUSIC:
case PLAYLIST_VIDEO:
CApplicationMessenger::Get().MediaPlay(playlistid, (int)parameterObject["item"]["position"].asInteger());
OnPlaylistChanged();
break;
case PLAYLIST_PICTURE:
return StartSlideshow("", false, optionShuffled.isBoolean() && optionShuffled.asBoolean());
break;
}
return ACK;
}
else if (parameterObject["item"].isObject() && parameterObject["item"].isMember("path"))
{
bool random = (optionShuffled.isBoolean() && optionShuffled.asBoolean()) ||
(!optionShuffled.isBoolean() && parameterObject["item"]["random"].asBoolean());
return StartSlideshow(parameterObject["item"]["path"].asString(), parameterObject["item"]["recursive"].asBoolean(), random);
}
else if (parameterObject["item"].isObject() && parameterObject["item"].isMember("partymode"))
{
if (g_partyModeManager.IsEnabled())
g_partyModeManager.Disable();
CApplicationMessenger::Get().ExecBuiltIn("playercontrol(partymode(" + parameterObject["item"]["partymode"].asString() + "))");
return ACK;
}
else if (parameterObject["item"].isObject() && parameterObject["item"].isMember("channelid"))
{
if (!g_PVRManager.IsStarted())
return FailedToExecute;
CPVRChannelGroupsContainer *channelGroupContainer = g_PVRChannelGroups;
if (channelGroupContainer == NULL)
return FailedToExecute;
CPVRChannelPtr channel = channelGroupContainer->GetChannelById((int)parameterObject["item"]["channelid"].asInteger());
if (channel == NULL)
return InvalidParams;
CApplicationMessenger::Get().PlayFile(CFileItem(*channel.get()));
return ACK;
}
else
{
CFileItemList list;
if (FillFileItemList(parameterObject["item"], list) && list.Size() > 0)
{
bool slideshow = true;
for (int index = 0; index < list.Size(); index++)
{
if (!list[index]->IsPicture())
{
slideshow = false;
break;
}
}
if (slideshow)
{
CGUIWindowSlideShow *slideshow = (CGUIWindowSlideShow*)g_windowManager.GetWindow(WINDOW_SLIDESHOW);
if (!slideshow)
return FailedToExecute;
SendSlideshowAction(ACTION_STOP);
slideshow->Reset();
for (int index = 0; index < list.Size(); index++)
slideshow->Add(list[index].get());
return StartSlideshow("", false, optionShuffled.isBoolean() && optionShuffled.asBoolean());
}
else
{
// Handle "shuffled" option
if (optionShuffled.isBoolean())
list.SetProperty("shuffled", optionShuffled);
// Handle "repeat" option
if (!optionRepeat.isNull())
list.SetProperty("repeat", ParseRepeatState(optionRepeat));
//.........这里部分代码省略.........