本文整理汇总了C++中CFileItemList::Append方法的典型用法代码示例。如果您正苦于以下问题:C++ CFileItemList::Append方法的具体用法?C++ CFileItemList::Append怎么用?C++ CFileItemList::Append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFileItemList
的用法示例。
在下文中一共展示了CFileItemList::Append方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetDirectory
bool CGUIWindowEventLog::GetDirectory(const std::string &strDirectory, CFileItemList &items)
{
bool result = CGUIMediaWindow::GetDirectory(strDirectory, items);
EventLevel currentLevel = CViewStateSettings::GetInstance().GetEventLevel();
bool showHigherLevels = CViewStateSettings::GetInstance().ShowHigherEventLevels();
CFileItemList filteredItems(items.GetPath());
for (int i = 0; i < items.Size(); i++)
{
CFileItemPtr item = items.Get(i);
if (item->IsParentFolder())
{
filteredItems.Add(item);
continue;
}
if (!item->HasProperty(PROPERTY_EVENT_LEVEL))
continue;
EventLevel level = CEventLog::GetInstance().EventLevelFromString(item->GetProperty(PROPERTY_EVENT_LEVEL).asString());
if (level == currentLevel ||
(level > currentLevel && showHigherLevels))
filteredItems.Add(item);
}
items.ClearItems();
items.Append(filteredItems);
return result;
}
示例2: LoadMediaItems
void CGUIWindowBoxeeMediaMain::LoadMediaItems()
{
Cleanup();
LoadMediaItems(m_listMediaItems);
LoadAppItems(m_listApps);
m_listMediaItemsSmall.Append(m_listMediaItems);
m_listAppsSmall.Append(m_listApps);
CLog::Log(LOGDEBUG,"%s - loaded %d media items and %d applications", __FUNCTION__, m_listMediaItems.Size(), m_listApps.Size());
int i;
for (i=0; i<m_listMediaItems.Size(); i++)
{
CGUIMessage winmsg(GUI_MSG_LABEL_ADD, GetID(), MEDIA_ITEMS_LIST, 0, 0, m_listMediaItems[i]);
OnMessage(winmsg);
CGUIMessage winmsg2(GUI_MSG_LABEL_ADD, GetID(), MEDIA_ITEMS_LIST_SMALL, 0, 0, m_listMediaItemsSmall[i]);
OnMessage(winmsg2);
}
for (i=0; i<m_listApps.Size(); i++)
{
CGUIMessage winmsg(GUI_MSG_LABEL_ADD, GetID(), APPS_ITEMS_LIST, 0, 0, m_listApps[i]);
OnMessage(winmsg);
CGUIMessage winmsg2(GUI_MSG_LABEL_ADD, GetID(), APPS_ITEMS_LIST_SMALL, 0, 0, m_listAppsSmall[i]);
OnMessage(winmsg2);
}
// Load thumbnails for the items
CLog::Log(LOGDEBUG,"Loading thumbnail for %d items", m_listMediaItems.Size());
m_listMediaItems.FillInDefaultIcons();
m_Loader = GetLoader();
CFileItemList *pList = new CFileItemList;
pList->Append(m_listMediaItems);
pList->Append(m_listApps);
m_Loader->SetObserver(this);
m_Loader->Load(*pList);
}
示例3: localGetShares
// advanced shares enumeration function
// if this function is failed, simple 'localGetNetworkResources()' can be used
static bool localGetShares(const std::wstring& serverNameToScan, const std::string& urlPrefixForItems, CFileItemList& items)
{
assert(serverNameToScan.compare(0, 2, L"\\\\", 2) == 0); // 'serverNameToScan' must be in form '\\ServerName'
assert(serverNameToScan.length() > 2);
assert(urlPrefixForItems.compare(0, 6, "smb://", 6) == 0); // 'urlPrefixForItems' must be in form 'smb://[user[:pass]@]ServerName/'
assert(urlPrefixForItems.length() > 7);
assert(urlPrefixForItems.back() == '/');
CFileItemList locItems; // store items locally until last one is successfully loaded
NET_API_STATUS enumResult;
DWORD hEnumResume = 0;
bool errorFlag = false;
do
{
SHARE_INFO_1* shareInfos = NULL;
DWORD count, totalCount;
enumResult = NetShareEnum((LPWSTR)serverNameToScan.c_str(), 1, (LPBYTE*)&shareInfos, MAX_PREFERRED_LENGTH, &count, &totalCount, &hEnumResume);
if (enumResult == NERR_Success || enumResult == ERROR_MORE_DATA)
{
for (unsigned int i = 0; i < count && !errorFlag; i++)
{
SHARE_INFO_1& curShare = shareInfos[i];
if ((curShare.shi1_type & STYPE_MASK) == STYPE_DISKTREE)
{
std::string shareNameUtf8;
if (curShare.shi1_netname && curShare.shi1_netname[0] &&
g_charsetConverter.wToUTF8(curShare.shi1_netname, shareNameUtf8, true) && !shareNameUtf8.empty())
{
CFileItemPtr pItem(new CFileItem(shareNameUtf8));
pItem->SetPath(urlPrefixForItems + shareNameUtf8 + '/');
pItem->m_bIsFolder = true;
if ((curShare.shi1_type & STYPE_SPECIAL) != 0 || shareNameUtf8.back() == '$')
pItem->SetProperty("file:hidden", true);
items.Add(pItem);
}
else
errorFlag = true;
}
}
NetApiBufferFree(shareInfos);
}
} while (!errorFlag && enumResult == ERROR_MORE_DATA);
if (enumResult != NERR_Success || errorFlag)
return false; // do not touch 'items' with partial result, allow fallback to another shares enumeration method
items.Append(locItems); // all shares loaded, store result
return true;
}
示例4: GetFilteredItems
bool CGUIMediaWindow::GetFilteredItems(const CStdString &filter, CFileItemList &items)
{
CStdString trimmedFilter(filter);
trimmedFilter.TrimLeft().ToLower();
if (trimmedFilter.IsEmpty())
return true;
CFileItemList filteredItems;
bool numericMatch = StringUtils::IsNaturalNumber(trimmedFilter);
for (int i = 0; i < items.Size(); i++)
{
CFileItemPtr item = items.Get(i);
if (item->IsParentFolder())
{
filteredItems.Add(item);
continue;
}
// TODO: Need to update this to get all labels, ideally out of the displayed info (ie from m_layout and m_focusedLayout)
// though that isn't practical. Perhaps a better idea would be to just grab the info that we should filter on based on
// where we are in the library tree.
// Another idea is tying the filter string to the current level of the tree, so that going deeper disables the filter,
// but it's re-enabled on the way back out.
CStdString match;
/* if (item->GetFocusedLayout())
match = item->GetFocusedLayout()->GetAllText();
else if (item->GetLayout())
match = item->GetLayout()->GetAllText();
else*/
match = item->GetLabel(); // Filter label only for now
if (numericMatch)
StringUtils::WordToDigits(match);
size_t pos = StringUtils::FindWords(match.c_str(), trimmedFilter.c_str());
if (pos != CStdString::npos)
filteredItems.Add(item);
}
items.ClearItems();
items.Append(filteredItems);
return (items.GetObjectCount() > 0);
}
示例5: GetDirectory
bool CSmartPlaylistDirectory::GetDirectory(const CStdString& strPath, CFileItemList& items)
{
// Load in the SmartPlaylist and get the WHERE query
CSmartPlaylist playlist;
if (!playlist.Load(strPath))
return false;
bool success = false, success2 = false;
if (playlist.GetType().Equals("music") || playlist.GetType().Equals("mixed") || playlist.GetType().IsEmpty())
{
CMusicDatabase db;
db.Open();
CStdString type=playlist.GetType();
if (type.IsEmpty())
type = "music";
if (playlist.GetType().Equals("mixed"))
playlist.SetType("music");
CStdString whereOrder = playlist.GetWhereClause() + " " + playlist.GetOrderClause();
success = db.GetSongsByWhere("", whereOrder, items);
db.Close();
playlist.SetType(type);
}
if (playlist.GetType().Equals("video") || playlist.GetType().Equals("mixed"))
{
CVideoDatabase db;
db.Open();
CStdString type=playlist.GetType();
if (playlist.GetType().Equals("mixed"))
playlist.SetType("video");
CStdString whereOrder = playlist.GetWhereClause() + " " + playlist.GetOrderClause();
CFileItemList items2;
success2 = db.GetMusicVideosByWhere("videodb://3/2/", whereOrder, items2);
db.Close();
items.Append(items2);
playlist.SetType(type);
}
if (playlist.GetType().Equals("mixed"))
return success || success2;
else if (playlist.GetType().Equals("video"))
return success2;
else
return success;
}
示例6: SettingOptionsFontsFiller
void GUIFontManager::SettingOptionsFontsFiller(const CSetting *setting, std::vector< std::pair<std::string, std::string> > &list, std::string ¤t, void *data)
{
CFileItemList items;
CFileItemList items2;
// find TTF fonts
XFILE::CDirectory::GetDirectory("special://home/media/Fonts/", items2);
if (XFILE::CDirectory::GetDirectory("special://xbmc/media/Fonts/", items))
{
items.Append(items2);
for (int i = 0; i < items.Size(); ++i)
{
CFileItemPtr pItem = items[i];
if (!pItem->m_bIsFolder
&& URIUtils::HasExtension(pItem->GetLabel(), ".ttf"))
{
list.push_back(make_pair(pItem->GetLabel(), pItem->GetLabel()));
}
}
}
}
示例7: OnFilterItems
void CGUIMediaWindow::OnFilterItems(const CStdString &filter)
{
CStdString currentItem;
int item = m_viewControl.GetSelectedItem();
if (item >= 0)
currentItem = m_vecItems->Get(item)->GetPath();
m_viewControl.Clear();
CFileItemList items;
items.Append(*m_unfilteredItems);
if (GetFilteredItems(filter, items))
{
m_vecItems->ClearItems();
m_vecItems->Append(items);
SetProperty("filter", filter);
}
// and update our view control + buttons
m_viewControl.SetItems(*m_vecItems);
m_viewControl.SetSelectedItem(currentItem);
UpdateButtons();
}
示例8: RunDisc
//.........这里部分代码省略.........
&& (bypassSettings || CSettings::Get().GetBool("dvds.autorun")))
{
CFileItemList items;
CDirectory::GetDirectory(pItem->GetPath(), items, strExt);
if (items.Size())
{
items.Sort(SortByLabel, SortOrderAscending);
g_playlistPlayer.ClearPlaylist(PLAYLIST_VIDEO);
g_playlistPlayer.Add(PLAYLIST_VIDEO, items);
g_playlistPlayer.SetCurrentPlaylist(PLAYLIST_VIDEO);
g_playlistPlayer.Play(0);
return true;
}
}
/* Probably want this if/when we add some automedia action dialog...
else if (pItem->GetPath().Find("PICTURES") != -1 && bAllowPictures
&& (bypassSettings))
{
bPlaying = true;
CStdString strExec = StringUtils::Format("XBMC.RecursiveSlideShow(%s)", pItem->GetPath().c_str());
CBuiltins::Execute(strExec);
return true;
}
*/
}
}
}
// check video first
if (!nAddedToPlaylist && !bPlaying && (bypassSettings || CSettings::Get().GetBool("dvds.autorun")))
{
// stack video files
CFileItemList tempItems;
tempItems.Append(vecItems);
if (CSettings::Get().GetBool("myvideos.stackvideos"))
tempItems.Stack();
CFileItemList itemlist;
for (int i = 0; i < tempItems.Size(); i++)
{
CFileItemPtr pItem = tempItems[i];
if (!pItem->m_bIsFolder && pItem->IsVideo())
{
bPlaying = true;
if (pItem->IsStack())
{
// TODO: remove this once the app/player is capable of handling stacks immediately
CStackDirectory dir;
CFileItemList items;
dir.GetDirectory(pItem->GetPath(), items);
itemlist.Append(items);
}
else
itemlist.Add(pItem);
}
}
if (itemlist.Size())
{
if (!bAllowVideo)
{
if (!bypassSettings)
return false;
if (g_windowManager.GetActiveWindow() != WINDOW_VIDEO_FILES)
if (!g_passwordManager.IsMasterLockUnlocked(true))
return false;
示例9: OnBrowse
void CGUIDialogSmartPlaylistRule::OnBrowse()
{
CFileItemList items;
CMusicDatabase database;
database.Open();
CVideoDatabase videodatabase;
videodatabase.Open();
std::string basePath;
if (CSmartPlaylist::IsMusicType(m_type))
basePath = "musicdb://";
else
basePath = "videodb://";
VIDEODB_CONTENT_TYPE type = VIDEODB_CONTENT_MOVIES;
if (m_type == "movies")
basePath += "movies/";
else if (m_type == "tvshows")
{
type = VIDEODB_CONTENT_TVSHOWS;
basePath += "tvshows/";
}
else if (m_type == "musicvideos")
{
type = VIDEODB_CONTENT_MUSICVIDEOS;
basePath += "musicvideos/";
}
else if (m_type == "episodes")
{
if (m_rule.m_field == FieldGenre || m_rule.m_field == FieldYear ||
m_rule.m_field == FieldStudio)
type = VIDEODB_CONTENT_TVSHOWS;
else
type = VIDEODB_CONTENT_EPISODES;
basePath += "tvshows/";
}
int iLabel = 0;
if (m_rule.m_field == FieldGenre)
{
if (m_type == "tvshows" ||
m_type == "episodes" ||
m_type == "movies")
videodatabase.GetGenresNav(basePath + "genres/", items, type);
else if (m_type == "songs" ||
m_type == "albums" ||
m_type == "artists" ||
m_type == "mixed")
database.GetGenresNav("musicdb://genres/",items);
if (m_type == "musicvideos" ||
m_type == "mixed")
{
CFileItemList items2;
videodatabase.GetGenresNav("videodb://musicvideos/genres/",items2,VIDEODB_CONTENT_MUSICVIDEOS);
items.Append(items2);
}
iLabel = 515;
}
else if (m_rule.m_field == FieldCountry)
{
videodatabase.GetCountriesNav(basePath, items, type);
iLabel = 574;
}
else if (m_rule.m_field == FieldArtist || m_rule.m_field == FieldAlbumArtist)
{
if (CSmartPlaylist::IsMusicType(m_type))
database.GetArtistsNav("musicdb://artists/", items, m_rule.m_field == FieldAlbumArtist, -1);
if (m_type == "musicvideos" ||
m_type == "mixed")
{
CFileItemList items2;
videodatabase.GetMusicVideoArtistsByName("", items2);
items.Append(items2);
}
iLabel = 557;
}
else if (m_rule.m_field == FieldAlbum)
{
if (CSmartPlaylist::IsMusicType(m_type))
database.GetAlbumsNav("musicdb://albums/", items);
if (m_type == "musicvideos" ||
m_type == "mixed")
{
CFileItemList items2;
videodatabase.GetMusicVideoAlbumsByName("", items2);
items.Append(items2);
}
iLabel = 558;
}
else if (m_rule.m_field == FieldActor)
{
videodatabase.GetActorsNav(basePath + "actors/",items,type);
iLabel = 20337;
}
else if (m_rule.m_field == FieldYear)
{
if (CSmartPlaylist::IsMusicType(m_type))
database.GetYearsNav("musicdb://years/", items);
if (CSmartPlaylist::IsVideoType(m_type))
{
//.........这里部分代码省略.........
示例10: GetDirectory
bool CSmartPlaylistDirectory::GetDirectory(const CStdString& strPath, CFileItemList& items)
{
// Load in the SmartPlaylist and get the WHERE query
CSmartPlaylist playlist;
if (!playlist.Load(strPath))
return false;
bool success = false, success2 = false;
if (playlist.GetType().Equals("tvshows"))
{
CVideoDatabase db;
db.Open();
CStdString whereOrder = playlist.GetWhereClause(db) + " " + playlist.GetOrderClause(db);
success = db.GetTvShowsByWhere("videodb://2/2/", whereOrder, items);
items.SetContent("tvshows");
db.Close();
}
else if (playlist.GetType().Equals("episodes"))
{
CVideoDatabase db;
db.Open();
CStdString whereOrder = playlist.GetWhereClause(db) + " " + playlist.GetOrderClause(db);
success = db.GetEpisodesByWhere("videodb://2/2/", whereOrder, items);
items.SetContent("episodes");
db.Close();
}
else if (playlist.GetType().Equals("movies"))
{
CVideoDatabase db;
db.Open();
success = db.GetMoviesByWhere("videodb://1/2/", playlist.GetWhereClause(db), playlist.GetOrderClause(db), items, true);
items.SetContent("movies");
db.Close();
}
else if (playlist.GetType().Equals("albums"))
{
CMusicDatabase db;
db.Open();
success = db.GetAlbumsByWhere("musicdb://3/", playlist.GetWhereClause(db), playlist.GetOrderClause(db), items);
items.SetContent("albums");
db.Close();
}
if (playlist.GetType().Equals("songs") || playlist.GetType().Equals("mixed") || playlist.GetType().IsEmpty())
{
CMusicDatabase db;
db.Open();
CStdString type=playlist.GetType();
if (type.IsEmpty())
type = "songs";
if (playlist.GetType().Equals("mixed"))
playlist.SetType("songs");
CStdString whereOrder = playlist.GetWhereClause(db) + " " + playlist.GetOrderClause(db);
success = db.GetSongsByWhere("", whereOrder, items);
items.SetContent("songs");
db.Close();
playlist.SetType(type);
}
if (playlist.GetType().Equals("musicvideos") || playlist.GetType().Equals("mixed"))
{
CVideoDatabase db;
db.Open();
CStdString type=playlist.GetType();
if (playlist.GetType().Equals("mixed"))
playlist.SetType("musicvideos");
CStdString whereOrder = playlist.GetWhereClause(db) + " " + playlist.GetOrderClause(db);
CFileItemList items2;
success2 = db.GetMusicVideosByWhere("videodb://3/2/", whereOrder, items2, false); // TODO: SMARTPLAYLISTS Don't check locks???
db.Close();
items.Append(items2);
if (items2.Size())
items.SetContent("musicvideos");
playlist.SetType(type);
}
// go through and set the playlist order
for (int i = 0; i < items.Size(); i++)
{
CFileItemPtr item = items[i];
item->m_iprogramCount = i; // hack for playlist order
}
if (playlist.GetType().Equals("mixed"))
return success || success2;
else if (playlist.GetType().Equals("musicvideos"))
return success2;
else
return success;
}
示例11: OnBrowse
void CGUIDialogSmartPlaylistRule::OnBrowse()
{
CFileItemList items;
CMusicDatabase database;
database.Open();
CVideoDatabase videodatabase;
videodatabase.Open();
VIDEODB_CONTENT_TYPE type = VIDEODB_CONTENT_MOVIES;
if (m_type.Equals("tvshows"))
type = VIDEODB_CONTENT_TVSHOWS;
else if (m_type.Equals("musicvideos"))
type = VIDEODB_CONTENT_MUSICVIDEOS;
else if (m_type.Equals("episodes"))
type = VIDEODB_CONTENT_EPISODES;
int iLabel = 0;
if (m_rule.m_field == CSmartPlaylistRule::FIELD_GENRE)
{
if (m_type.Equals("tvshows") || m_type.Equals("episodes") || m_type.Equals("movies"))
videodatabase.GetGenresNav("videodb://2/1/",items,type);
else if (m_type.Equals("songs") || m_type.Equals("albums") || m_type.Equals("mixed"))
database.GetGenresNav("musicdb://4/",items);
if (m_type.Equals("musicvideos") || m_type.Equals("mixed"))
{
CFileItemList items2;
videodatabase.GetGenresNav("videodb://3/1/",items2,VIDEODB_CONTENT_MUSICVIDEOS);
items.Append(items2);
}
iLabel = 515;
}
else if (m_rule.m_field == CSmartPlaylistRule::FIELD_COUNTRY)
{
videodatabase.GetCountriesNav("videodb://2/1/",items,type);
iLabel = 574;
}
else if (m_rule.m_field == CSmartPlaylistRule::FIELD_ARTIST || m_rule.m_field == CSmartPlaylistRule::FIELD_ALBUMARTIST)
{
if (m_type.Equals("songs") || m_type.Equals("mixed") || m_type.Equals("albums"))
database.GetArtistsNav("musicdb://5/",items,-1,m_rule.m_field == CSmartPlaylistRule::FIELD_ALBUMARTIST);
if (m_type.Equals("musicvideos") || m_type.Equals("mixed"))
{
CFileItemList items2;
videodatabase.GetMusicVideoArtistsByName("",items2);
items.Append(items2);
}
iLabel = 557;
}
else if (m_rule.m_field == CSmartPlaylistRule::FIELD_ALBUM)
{
if (m_type.Equals("songs") || m_type.Equals("mixed") || m_type.Equals("albums"))
database.GetAlbumsNav("musicdb://6/",items,-1,-1,-1,-1);
if (m_type.Equals("musicvideos") || m_type.Equals("mixed"))
{
CFileItemList items2;
videodatabase.GetMusicVideoAlbumsByName("",items2);
items.Append(items2);
}
iLabel = 558;
}
else if (m_rule.m_field == CSmartPlaylistRule::FIELD_ACTOR)
{
videodatabase.GetActorsNav("",items,type);
iLabel = 20337;
}
else if (m_rule.m_field == CSmartPlaylistRule::FIELD_DIRECTOR)
{
videodatabase.GetDirectorsNav("",items,type);
iLabel = 20339;
}
else if (m_rule.m_field == CSmartPlaylistRule::FIELD_STUDIO)
{
videodatabase.GetStudiosNav("",items,type);
iLabel = 572;
}
else if (m_rule.m_field == CSmartPlaylistRule::FIELD_WRITER)
{
videodatabase.GetWritersNav("",items,type);
iLabel = 20417;
}
else if (m_rule.m_field == CSmartPlaylistRule::FIELD_TVSHOWTITLE)
{
videodatabase.GetTvShowsNav("",items);
iLabel = 20343;
}
else if (m_rule.m_field == CSmartPlaylistRule::FIELD_PLAYLIST)
{
// use filebrowser to grab another smart playlist
// Note: This can cause infinite loops (playlist that refers to the same playlist) but I don't
// think there's any decent way to deal with this, as the infinite loop may be an arbitrary
// number of playlists deep, eg playlist1 -> playlist2 -> playlist3 ... -> playlistn -> playlist1
CStdString path = "special://videoplaylists/";
if (m_type.Equals("songs") || m_type.Equals("albums"))
path = "special://musicplaylists/";
XFILE::CDirectory::GetDirectory(path, items, ".xsp",false,false,XFILE::DIR_CACHE_ONCE,true,true);
iLabel = 559;
}
else if (m_rule.m_field == CSmartPlaylistRule::FIELD_PATH)
{
//.........这里部分代码省略.........
示例12: GetDirectory
bool CMultiPathDirectory::GetDirectory(const CURL& url, CFileItemList &items)
{
CLog::Log(LOGDEBUG,"CMultiPathDirectory::GetDirectory(%s)", url.GetRedacted().c_str());
std::vector<std::string> vecPaths;
if (!GetPaths(url, 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 = g_windowManager.GetWindow<CGUIDialogProgress>(WINDOW_DIALOG_PROGRESS);
if (dlgProgress)
{
dlgProgress->SetHeading(CVariant{15310});
dlgProgress->SetLine(0, CVariant{15311});
dlgProgress->SetLine(1, CVariant{""});
dlgProgress->SetLine(2, CVariant{""});
dlgProgress->Open();
dlgProgress->ShowProgressBar(true);
dlgProgress->SetProgressMax((int)vecPaths.size()*2);
dlgProgress->Progress();
}
}
if (dlgProgress)
{
CURL url(vecPaths[i]);
dlgProgress->SetLine(1, CVariant{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;
}
示例13: 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());
//.........这里部分代码省略.........
示例14: RunDisc
//.........这里部分代码省略.........
CFileItemList items;
CDirectory::GetDirectory(pItem->GetPath(), items, strExt);
if (items.Size())
{
items.Sort(SORT_METHOD_LABEL, SortOrderAscending);
g_playlistPlayer.ClearPlaylist(PLAYLIST_VIDEO);
g_playlistPlayer.Add(PLAYLIST_VIDEO, items);
g_playlistPlayer.SetCurrentPlaylist(PLAYLIST_VIDEO);
g_playlistPlayer.Play(0);
bPlaying = true;
return true;
}
}
/* Probably want this if/when we add some automedia action dialog...
else if (pItem->GetPath().Find("PICTURES") != -1 && bAllowPictures
&& (bypassSettings))
{
bPlaying = true;
CStdString strExec;
strExec.Format("XBMC.RecursiveSlideShow(%s)", pItem->GetPath().c_str());
CBuiltins::Execute(strExec);
return true;
}
*/
}
}
}
// check video first
if (!nAddedToPlaylist && !bPlaying && (bypassSettings || g_guiSettings.GetBool("dvds.autorun")))
{
// stack video files
CFileItemList tempItems;
tempItems.Append(vecItems);
if (g_settings.m_videoStacking)
tempItems.Stack();
CFileItemList itemlist;
for (int i = 0; i < tempItems.Size(); i++)
{
CFileItemPtr pItem = tempItems[i];
if (!pItem->m_bIsFolder && pItem->IsVideo())
{
bPlaying = true;
if (pItem->IsStack())
{
// TODO: remove this once the app/player is capable of handling stacks immediately
CStackDirectory dir;
CFileItemList items;
dir.GetDirectory(pItem->GetPath(), items);
itemlist.Append(items);
}
else
itemlist.Add(pItem);
}
}
if (itemlist.Size())
{
if (!bAllowVideo)
{
if (!bypassSettings)
return false;
if (g_windowManager.GetActiveWindow() != WINDOW_VIDEO_FILES)
if (!g_passwordManager.IsMasterLockUnlocked(true))
return false;
示例15: GetDirectory
//.........这里部分代码省略.........
if (!videoUrl.FromString(strBaseDir) || !playlist.SaveAsJson(xsp, false))
return false;
// store the smartplaylist as JSON in the URL as well
videoUrl.AddOption("xsp", xsp);
CDatabase::Filter filter;
success = db.GetSortedVideos(mediaType, videoUrl.ToString(), sorting, items, filter, true);
db.Close();
}
}
else if (playlist.GetType().Equals("albums"))
{
CMusicDatabase db;
if (db.Open())
{
CMusicDbUrl musicUrl;
CStdString xsp;
if (!musicUrl.FromString("musicdb://3/") || !playlist.SaveAsJson(xsp, false))
return false;
// store the smartplaylist as JSON in the URL as well
musicUrl.AddOption("xsp", xsp);
CDatabase::Filter filter;
success = db.GetAlbumsByWhere(musicUrl.ToString(), filter, items, sorting);
items.SetContent("albums");
db.Close();
}
}
if (playlist.GetType().Equals("songs") || playlist.GetType().Equals("mixed") || playlist.GetType().IsEmpty())
{
CMusicDatabase db;
if (db.Open())
{
CSmartPlaylist songPlaylist(playlist);
if (playlist.GetType().IsEmpty() || playlist.GetType().Equals("mixed"))
songPlaylist.SetType("songs");
CMusicDbUrl musicUrl;
CStdString xsp;
if (!musicUrl.FromString("musicdb://4/") || !songPlaylist.SaveAsJson(xsp, false))
return false;
// store the smartplaylist as JSON in the URL as well
musicUrl.AddOption("xsp", xsp);
CDatabase::Filter filter;
success = db.GetSongsByWhere(musicUrl.ToString(), filter, items, sorting);
items.SetContent("songs");
db.Close();
}
}
if (playlist.GetType().Equals("musicvideos") || playlist.GetType().Equals("mixed"))
{
CVideoDatabase db;
if (db.Open())
{
CSmartPlaylist mvidPlaylist(playlist);
if (playlist.GetType().Equals("mixed"))
mvidPlaylist.SetType("musicvideos");
CVideoDbUrl videoUrl;
CStdString xsp;
if (!videoUrl.FromString("videodb://3/2/") || !mvidPlaylist.SaveAsJson(xsp, false))
return false;
// store the smartplaylist as JSON in the URL as well
videoUrl.AddOption("xsp", xsp);
CFileItemList items2;
success2 = db.GetSortedVideos(MediaTypeMusicVideo, videoUrl.ToString(), sorting, items2);
db.Close();
items.Append(items2);
if (items2.Size())
{
if (items.Size() > items2.Size())
items.SetContent("mixed");
else
items.SetContent("musicvideos");
}
}
}
items.SetLabel(playlist.GetName());
// go through and set the playlist order
for (int i = 0; i < items.Size(); i++)
{
CFileItemPtr item = items[i];
item->m_iprogramCount = i; // hack for playlist order
}
if (playlist.GetType().Equals("mixed"))
return success || success2;
else if (playlist.GetType().Equals("musicvideos"))
return success2;
else
return success;
}