本文整理汇总了C++中CFileItemList::Size方法的典型用法代码示例。如果您正苦于以下问题:C++ CFileItemList::Size方法的具体用法?C++ CFileItemList::Size怎么用?C++ CFileItemList::Size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFileItemList
的用法示例。
在下文中一共展示了CFileItemList::Size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnUpdate
void CGUIDialogAddonInfo::OnUpdate()
{
if (!m_localAddon)
return;
CAddonDatabase database;
if (!database.Open())
return;
std::vector<std::pair<AddonVersion, std::string>> versions;
if (!database.GetAvailableVersions(m_localAddon->ID(), versions))
return;
CFileItemList items;
if (XFILE::CDirectory::GetDirectory("special://home/addons/packages/", items, ".zip", DIR_FLAG_NO_FILE_DIRS))
{
for (int i = 0; i < items.Size(); ++i)
{
std::string packageId;
std::string versionString;
if (AddonVersion::SplitFileName(packageId, versionString, items[i]->GetLabel()))
{
if (packageId == m_localAddon->ID())
{
std::string hash;
std::string path(items[i]->GetPath());
if (database.GetPackageHash(m_localAddon->ID(), items[i]->GetPath(), hash))
{
std::string md5 = CUtil::GetFileMD5(path);
if (md5 == hash)
versions.push_back(std::make_pair(AddonVersion(versionString), LOCAL_CACHE));
}
}
}
}
}
auto* dialog = static_cast<CGUIDialogSelect*>(g_windowManager.GetWindow(WINDOW_DIALOG_SELECT));
dialog->Reset();
dialog->SetHeading(CVariant{21338});
dialog->SetUseDetails(true);
std::stable_sort(versions.begin(), versions.end(), CompareVersion);
for (const auto& versionInfo : versions)
{
CFileItem item(StringUtils::Format(g_localizeStrings.Get(21339).c_str(), versionInfo.first.asString().c_str()));
if (versionInfo.first == m_localAddon->Version())
item.Select(true);
AddonPtr repo;
if (versionInfo.second == LOCAL_CACHE)
{
item.SetProperty("Addon.Summary", g_localizeStrings.Get(24095));
item.SetIconImage("DefaultAddonRepository.png");
dialog->Add(item);
}
else if (CAddonMgr::GetInstance().GetAddon(versionInfo.second, repo, ADDON_REPOSITORY))
{
item.SetProperty("Addon.Summary", repo->Name());
item.SetIconImage(repo->Icon());
dialog->Add(item);
}
}
dialog->Open();
if (dialog->IsConfirmed())
{
Close();
auto selected = versions.at(dialog->GetSelectedLabel());
//add or remove from blacklist to toggle auto updating. if downgrading
//turn off, if upgrading to latest turn it back on
if (selected.first < m_localAddon->Version())
database.BlacklistAddon(m_localAddon->ID());
if (selected.first == versions.at(0).first)
database.RemoveAddonFromBlacklist(m_localAddon->ID());
if (selected.second == LOCAL_CACHE)
CAddonInstaller::GetInstance().InstallFromZip(StringUtils::Format("special://home/addons/packages/%s-%s.zip",
m_localAddon->ID().c_str(), selected.first.asString().c_str()));
else
CAddonInstaller::GetInstance().Install(m_addon->ID(), selected.first, selected.second);
}
}
示例2: DoScan
bool CMusicInfoScanner::DoScan(const CStdString& strDirectory)
{
if (m_handle)
m_handle->SetText(Prettify(strDirectory));
/*
* remove this path from the list we're processing. This must be done prior to
* the check for file or folder exclusion to prevent an infinite while loop
* in Process().
*/
set<CStdString>::iterator it = m_pathsToScan.find(strDirectory);
if (it != m_pathsToScan.end())
m_pathsToScan.erase(it);
// Discard all excluded files defined by m_musicExcludeRegExps
CStdStringArray regexps = g_advancedSettings.m_audioExcludeFromScanRegExps;
if (CUtil::ExcludeFileOrFolder(strDirectory, regexps))
return true;
// load subfolder
CFileItemList items;
CDirectory::GetDirectory(strDirectory, items, g_settings.m_musicExtensions + "|.jpg|.tbn|.lrc|.cdg");
// sort and get the path hash. Note that we don't filter .cue sheet items here as we want
// to detect changes in the .cue sheet as well. The .cue sheet items only need filtering
// if we have a changed hash.
items.Sort(SORT_METHOD_LABEL, SortOrderAscending);
CStdString hash;
GetPathHash(items, hash);
// check whether we need to rescan or not
CStdString dbHash;
if ((m_flags & SCAN_RESCAN) || !m_musicDatabase.GetPathHash(strDirectory, dbHash) || dbHash != hash)
{ // path has changed - rescan
if (dbHash.IsEmpty())
CLog::Log(LOGDEBUG, "%s Scanning dir '%s' as not in the database", __FUNCTION__, strDirectory.c_str());
else
CLog::Log(LOGDEBUG, "%s Rescanning dir '%s' due to change", __FUNCTION__, strDirectory.c_str());
// filter items in the sub dir (for .cue sheet support)
items.FilterCueItems();
items.Sort(SORT_METHOD_LABEL, SortOrderAscending);
// and then scan in the new information
if (RetrieveMusicInfo(items, strDirectory) > 0)
{
if (m_handle)
OnDirectoryScanned(strDirectory);
}
// save information about this folder
m_musicDatabase.SetPathHash(strDirectory, hash);
}
else
{ // path is the same - no need to rescan
CLog::Log(LOGDEBUG, "%s Skipping dir '%s' due to no change", __FUNCTION__, strDirectory.c_str());
m_currentItem += CountFiles(items, false); // false for non-recursive
// updated the dialog with our progress
if (m_handle)
{
if (m_itemCount>0)
m_handle->SetPercentage(m_currentItem/(double)m_itemCount*100);
OnDirectoryScanned(strDirectory);
}
}
// now scan the subfolders
for (int i = 0; i < items.Size(); ++i)
{
CFileItemPtr pItem = items[i];
if (m_bStop)
break;
// if we have a directory item (non-playlist) we then recurse into that folder
if (pItem->m_bIsFolder && !pItem->IsParentFolder() && !pItem->IsPlayList())
{
CStdString strPath=pItem->GetPath();
if (!DoScan(strPath))
{
m_bStop = true;
}
}
}
return !m_bStop;
}
示例3: GetBroadcasts
JSONRPC_STATUS CPVROperations::GetBroadcasts(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result)
{
if (!g_PVRManager.IsStarted())
return FailedToExecute;
CPVRChannelGroupsContainer *channelGroupContainer = g_PVRManager.ChannelGroups();
if (channelGroupContainer == NULL)
return FailedToExecute;
CPVRChannelPtr channel = channelGroupContainer->GetChannelById((int)parameterObject["channelid"].asInteger());
if (channel == NULL)
return InvalidParams;
CEpg *channelEpg = channel->GetEPG();
if (channelEpg == NULL)
return InternalError;
CFileItemList programFull;
channelEpg->Get(programFull);
HandleFileItemList("broadcastid", false, "broadcasts", programFull, parameterObject, result, programFull.Size(), true);
return OK;
}
示例4: ChangeRecordingsPlayCount
bool CPVRRecordings::ChangeRecordingsPlayCount(const CFileItemPtr &item, int count)
{
bool bResult = false;
if (m_database.IsOpen())
{
bResult = true;
CLog::Log(LOGDEBUG, "CPVRRecordings - %s - item path %s", __FUNCTION__, item->GetPath().c_str());
CFileItemList items;
if (item->m_bIsFolder)
{
XFILE::CDirectory::GetDirectory(item->GetPath(), items);
}
else
items.Add(item);
CLog::Log(LOGDEBUG, "CPVRRecordings - %s - will set watched for %d items", __FUNCTION__, items.Size());
for (int i=0;i<items.Size();++i)
{
CLog::Log(LOGDEBUG, "CPVRRecordings - %s - setting watched for item %d", __FUNCTION__, i);
CFileItemPtr pItem=items[i];
if (pItem->m_bIsFolder)
{
CLog::Log(LOGDEBUG, "CPVRRecordings - %s - path %s is a folder, will call recursively", __FUNCTION__, pItem->GetPath().c_str());
if (pItem->GetLabel() != "..")
{
ChangeRecordingsPlayCount(pItem, count);
}
continue;
}
if (!pItem->HasPVRRecordingInfoTag())
continue;
const CPVRRecordingPtr recording = pItem->GetPVRRecordingInfoTag();
if (recording)
{
if (count == INCREMENT_PLAY_COUNT)
recording->IncrementPlayCount();
else
recording->SetPlayCount(count);
// Clear resume bookmark
if (recording->m_playCount > 0)
{
m_database.ClearBookMarksOfFile(pItem->GetPath(), CBookmark::RESUME);
recording->SetLastPlayedPosition(0);
}
if (count == INCREMENT_PLAY_COUNT)
m_database.IncrementPlayCount(*pItem);
else
m_database.SetPlayCount(*pItem, count);
}
}
g_PVRManager.PublishEvent(RecordingsInvalidated);
}
return bResult;
}
示例5: AddQueuingFolder
// Add an "* All ..." folder to the CFileItemList
// depending on the child node
void CDirectoryNode::AddQueuingFolder(CFileItemList& items) const
{
CFileItemPtr pItem;
CMusicDbUrl musicUrl;
if (!musicUrl.FromString(BuildPath()))
return;
// always hide "all" items
if (g_advancedSettings.m_bMusicLibraryHideAllItems)
return;
// no need for "all" item when only one item
if (items.GetObjectCount() <= 1)
return;
switch (GetChildType())
{
// Have no queuing folder
case NODE_TYPE_ROOT:
case NODE_TYPE_OVERVIEW:
case NODE_TYPE_TOP100:
break;
/* no need for all genres
case NODE_TYPE_GENRE:
pItem.reset(new CFileItem(g_localizeStrings.Get(15105))); // "All Genres"
musicUrl.AppendPath("-1/");
pItem->SetPath(musicUrl.ToString());
break;
*/
case NODE_TYPE_ARTIST:
if (GetType() == NODE_TYPE_OVERVIEW) return;
pItem.reset(new CFileItem(g_localizeStrings.Get(15103))); // "All Artists"
musicUrl.AppendPath("-1/");
pItem->SetPath(musicUrl.ToString());
break;
// All album related nodes
case NODE_TYPE_ALBUM:
if (GetType() == NODE_TYPE_OVERVIEW) return;
case NODE_TYPE_ALBUM_RECENTLY_PLAYED:
case NODE_TYPE_ALBUM_RECENTLY_ADDED:
case NODE_TYPE_ALBUM_COMPILATIONS:
case NODE_TYPE_ALBUM_TOP100:
case NODE_TYPE_YEAR_ALBUM:
pItem.reset(new CFileItem(g_localizeStrings.Get(15102))); // "All Albums"
musicUrl.AppendPath("-1/");
pItem->SetPath(musicUrl.ToString());
break;
// All song related nodes
/* case NODE_TYPE_ALBUM_RECENTLY_PLAYED_SONGS:
case NODE_TYPE_ALBUM_RECENTLY_ADDED_SONGS:
case NODE_TYPE_ALBUM_COMPILATIONS_SONGS:
case NODE_TYPE_ALBUM_TOP100_SONGS:
case NODE_TYPE_SONG_TOP100:
case NODE_TYPE_SONG:
pItem = new CFileItem(g_localizeStrings.Get(15104)); // "All Songs"
musicUrl.AppendPath("-1/");
pItem->SetPath(musicUrl.ToString());
break;*/
default:
break;
}
if (pItem)
{
pItem->m_bIsFolder = true;
pItem->SetSpecialSort(g_advancedSettings.m_bMusicLibraryAllItemsOnBottom ? SortSpecialOnBottom : SortSpecialOnTop);
pItem->SetCanQueue(false);
pItem->SetLabelPreformated(true);
if (g_advancedSettings.m_bMusicLibraryAllItemsOnBottom)
items.Add(pItem);
else
items.AddFront(pItem, (items.Size() > 0 && items[0]->IsParentFolder()) ? 1 : 0);
}
}
示例6: OnClick
// \brief With this function you can react on a users click in the list/thumb panel.
// It returns true, if the click is handled.
// This function calls OnPlayMedia()
bool CGUIMediaWindow::OnClick(int iItem)
{
if ( iItem < 0 || iItem >= (int)m_vecItems->Size() ) return true;
CFileItemPtr pItem = m_vecItems->Get(iItem);
if (pItem->IsParentFolder())
{
GoParentFolder();
return true;
}
else if (pItem->m_bIsFolder)
{
if ( pItem->m_bIsShareOrDrive )
{
const CStdString& strLockType=m_guiState->GetLockType();
ASSERT(g_settings.m_vecProfiles.size() > 0);
if (g_settings.m_vecProfiles[0].getLockMode() != LOCK_MODE_EVERYONE)
if (!strLockType.IsEmpty() && !g_passwordManager.IsItemUnlocked(pItem.get(), strLockType))
return true;
if (!HaveDiscOrConnection(pItem->m_strPath, pItem->m_iDriveType))
return true;
}
// check for the partymode playlist items - they may not exist yet
if ((pItem->m_strPath == g_settings.GetUserDataItem("PartyMode.xsp")) ||
(pItem->m_strPath == g_settings.GetUserDataItem("PartyMode-Video.xsp")))
{
// party mode playlist item - if it doesn't exist, prompt for user to define it
if (!XFILE::CFile::Exists(pItem->m_strPath))
{
m_vecItems->RemoveDiscCache();
if (CGUIDialogSmartPlaylistEditor::EditPlaylist(pItem->m_strPath))
Update(m_vecItems->m_strPath);
return true;
}
}
// remove the directory cache if the folder is not normally cached
CFileItemList items(pItem->m_strPath);
if (!items.AlwaysCache())
items.RemoveDiscCache();
CFileItem directory(*pItem);
if (!Update(directory.m_strPath))
ShowShareErrorMessage(&directory);
return true;
}
else if (pItem->IsPlugin() && pItem->GetProperty("isplayable") != "true")
{
return DIRECTORY::CPluginDirectory::RunScriptWithParams(pItem->m_strPath);
}
else
{
m_iSelectedItem = m_viewControl.GetSelectedItem();
if (pItem->m_strPath == "newplaylist://")
{
m_vecItems->RemoveDiscCache();
g_windowManager.ActivateWindow(WINDOW_MUSIC_PLAYLIST_EDITOR,"newplaylist://");
return true;
}
else if (pItem->m_strPath.Left(19).Equals("newsmartplaylist://"))
{
m_vecItems->RemoveDiscCache();
if (CGUIDialogSmartPlaylistEditor::NewPlaylist(pItem->m_strPath.Mid(19)))
Update(m_vecItems->m_strPath);
return true;
}
#ifndef _BOXEE_
if (m_guiState.get() && m_guiState->AutoPlayNextItem() && !g_partyModeManager.IsEnabled() && !pItem->IsPlayList())
{
// TODO: music videos!
if (pItem->m_strPath == "add" && pItem->GetLabel() == g_localizeStrings.Get(1026) && m_guiState->GetPlaylist() == PLAYLIST_MUSIC) // 'add source button' in empty root
{
if (CGUIDialogMediaSource::ShowAndAddMediaSource("music"))
{
Update("");
return true;
}
return false;
}
//play and add current directory to temporary playlist
int iPlaylist=m_guiState->GetPlaylist();
if (iPlaylist != PLAYLIST_NONE)
{
g_playlistPlayer.ClearPlaylist(iPlaylist);
g_playlistPlayer.Reset();
int songToPlay = 0;
CFileItemList queueItems;
for ( int i = 0; i < m_vecItems->Size(); i++ )
{
CFileItemPtr item = m_vecItems->Get(i);
if (item->m_bIsFolder)
//.........这里部分代码省略.........
示例7: OnInfo
void CGUIWindowMusicBase::OnInfo(CFileItem *pItem, bool bShowInfo)
{
if (pItem->m_bIsFolder && pItem->IsParentFolder())
return;
if (pItem->IsVideoDb())
{
OnContextButton(m_viewControl.GetSelectedItem(), CONTEXT_BUTTON_INFO); // nasty but it is the same item i promise :)
return;
}
CStdString strPath = pItem->m_strPath;
// Try to find an album to lookup from the current item
CAlbum album;
CArtist artist;
bool foundAlbum = false;
album.idAlbum = -1;
if (pItem->IsMusicDb())
{
CQueryParams params;
CDirectoryNode::GetDatabaseInfo(pItem->m_strPath, params);
if (params.GetAlbumId() == -1)
{
artist.idArtist = params.GetArtistId();
artist.strArtist = pItem->GetMusicInfoTag()->GetArtist();
}
else
{
// show dialog box indicating we're searching the album name
if (m_dlgProgress && bShowInfo)
{
m_dlgProgress->SetHeading(185);
m_dlgProgress->SetLine(0, 501);
m_dlgProgress->SetLine(1, "");
m_dlgProgress->SetLine(2, "");
m_dlgProgress->StartModal();
m_dlgProgress->Progress();
if (m_dlgProgress->IsCanceled())
return;
}
album.idAlbum = params.GetAlbumId();
album.strAlbum = pItem->GetMusicInfoTag()->GetAlbum();
album.strArtist = pItem->GetMusicInfoTag()->GetArtist();
// we're going to need it's path as well (we assume that there's only one) - this is for
// assigning thumbs to folders, and obtaining the local folder.jpg
m_musicdatabase.GetAlbumPath(album.idAlbum, strPath);
}
}
else
{ // lookup is done on a folder - find the albums in the folder
CFileItemList items;
GetDirectory(strPath, items);
// check the first song we find in the folder, and grab it's album info
for (int i = 0; i < items.Size() && !foundAlbum; i++)
{
CFileItem* pItem = items[i];
pItem->LoadMusicTag();
if (pItem->HasMusicInfoTag() && pItem->GetMusicInfoTag()->Loaded() &&
!pItem->GetMusicInfoTag()->GetAlbum().IsEmpty())
{
// great, have a song - use it.
CSong song(*pItem->GetMusicInfoTag());
// this function won't be needed if/when the tag has idSong information
if (!m_musicdatabase.GetAlbumFromSong(song, album))
{ // album isn't in the database - construct it from the tag info we have
CMusicInfoTag *tag = pItem->GetMusicInfoTag();
album.strAlbum = tag->GetAlbum();
album.strArtist = tag->GetAlbumArtist().IsEmpty() ? tag->GetArtist() : tag->GetAlbumArtist();
album.idAlbum = -1; // the -1 indicates it's not in the database
}
foundAlbum = true;
}
}
if (!foundAlbum)
{
CLog::Log(LOGINFO, "%s called on a folder containing no songs with tag info - nothing can be done", __FUNCTION__);
if (m_dlgProgress && bShowInfo) m_dlgProgress->Close();
}
}
if (m_dlgProgress && bShowInfo) m_dlgProgress->Close();
if (album.idAlbum == -1 && foundAlbum == false)
ShowArtistInfo(artist, pItem->m_strPath, false, bShowInfo);
else
ShowAlbumInfo(album, strPath, false, bShowInfo);
}
示例8: GetDirectory
//.........这里部分代码省略.........
if (search.IsEmpty() && !GetKeyboardInput(16017, search))
return false;
items.SetProperty("reponame",g_localizeStrings.Get(283));
items.SetLabel(g_localizeStrings.Get(283));
CAddonDatabase database;
database.Open();
database.Search(search, addons);
GenerateListing(path, addons, items, true);
path.SetFileName(search);
items.SetPath(path.Get());
return true;
}
else
{
reposAsFolders = false;
AddonPtr addon;
CAddonMgr::Get().GetAddon(path.GetHostName(),addon);
if (!addon)
return false;
// ensure our repos are up to date
CAddonInstaller::Get().UpdateRepos(false, true);
CAddonDatabase database;
database.Open();
database.GetRepository(addon->ID(),addons);
items.SetProperty("reponame",addon->Name());
items.SetLabel(addon->Name());
}
if (path.GetFileName().IsEmpty())
{
if (!path.GetHostName().Equals("repos"))
{
for (int i=ADDON_UNKNOWN+1;i<ADDON_VIZ_LIBRARY;++i)
{
for (unsigned int j=0;j<addons.size();++j)
{
if (addons[j]->IsType((TYPE)i))
{
CFileItemPtr item(new CFileItem(TranslateType((TYPE)i,true)));
item->SetPath(URIUtils::AddFileToFolder(strPath,TranslateType((TYPE)i,false)));
item->m_bIsFolder = true;
CStdString thumb = GetIcon((TYPE)i);
if (!thumb.IsEmpty() && g_TextureManager.HasTexture(thumb))
item->SetThumbnailImage(thumb);
items.Add(item);
break;
}
}
}
items.SetPath(strPath);
return true;
}
}
else
{
TYPE type = TranslateType(path.GetFileName());
items.SetProperty("addoncategory",TranslateType(type, true));
items.SetLabel(TranslateType(type, true));
items.SetPath(strPath);
// FIXME: Categorisation of addons needs adding here
for (unsigned int j=0;j<addons.size();++j)
{
if (!addons[j]->IsType(type))
addons.erase(addons.begin()+j--);
}
}
items.SetPath(strPath);
GenerateListing(path, addons, items, reposAsFolders);
// check for available updates
if (path.GetHostName().Equals("enabled"))
{
CAddonDatabase database;
database.Open();
for (int i=0;i<items.Size();++i)
{
AddonPtr addon2;
database.GetAddon(items[i]->GetProperty("Addon.ID").asString(),addon2);
if (addon2 && addon2->Version() > AddonVersion(items[i]->GetProperty("Addon.Version").asString())
&& !database.IsAddonBlacklisted(addon2->ID(),addon2->Version().c_str()))
{
items[i]->SetProperty("Addon.Status",g_localizeStrings.Get(24068));
items[i]->SetProperty("Addon.UpdateAvail", true);
}
}
}
if (path.GetHostName().Equals("repos") && items.Size() > 1)
{
CFileItemPtr item(new CFileItem("addons://all/",true));
item->SetLabel(g_localizeStrings.Get(24032));
items.Add(item);
}
return true;
}
示例9: OnBrowse
//.........这里部分代码省略.........
else if (m_rule.m_field == FieldStudio)
{
videodatabase.GetStudiosNav(basePath + "studios/", items, type);
iLabel = 572;
}
else if (m_rule.m_field == FieldWriter)
{
videodatabase.GetWritersNav(basePath, items, type);
iLabel = 20417;
}
else if (m_rule.m_field == FieldTvShowTitle ||
(m_type == "tvshows" && m_rule.m_field == FieldTitle))
{
videodatabase.GetTvShowsNav(basePath + "titles/", items);
iLabel = 20343;
}
else if (m_rule.m_field == FieldTitle)
{
if (m_type == "songs" || m_type == "mixed")
{
database.GetSongsNav("musicdb://songs/", items, -1, -1, -1);
iLabel = 134;
}
if (m_type == "movies")
{
videodatabase.GetMoviesNav(basePath + "titles/", items);
iLabel = 20342;
}
if (m_type == "episodes")
{
videodatabase.GetEpisodesNav(basePath + "titles/-1/-1/", items);
// we need to replace the db label (<season>x<episode> <title>) with the title only
CLabelFormatter format("%T", "");
for (int i = 0; i < items.Size(); i++)
format.FormatLabel(items[i].get());
iLabel = 20360;
}
if (m_type == "musicvideos" || m_type == "mixed")
{
videodatabase.GetMusicVideosNav(basePath + "titles/", items);
iLabel = 20389;
}
}
else if (m_rule.m_field == FieldPlaylist || m_rule.m_field == FieldVirtualFolder)
{
// 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
if (CSmartPlaylist::IsVideoType(m_type))
XFILE::CDirectory::GetDirectory("special://videoplaylists/", items, ".xsp", XFILE::DIR_FLAG_NO_FILE_DIRS);
if (CSmartPlaylist::IsMusicType(m_type))
{
CFileItemList items2;
XFILE::CDirectory::GetDirectory("special://musicplaylists/", items2, ".xsp", XFILE::DIR_FLAG_NO_FILE_DIRS);
items.Append(items2);
}
for (int i = 0; i < items.Size(); i++)
{
CFileItemPtr item = items[i];
CSmartPlaylist playlist;
// don't list unloadable smartplaylists or any referencable smartplaylists
// which do not match the type of the current smartplaylist
if (!playlist.Load(item->GetPath()) ||
示例10: UpdateVideo
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;
videodatabase.Open();
if (videodatabase.GetRecentlyAddedMoviesNav("videodb://4/", items, NUM_ITEMS))
{
for (; i < items.Size(); ++i)
{
CFileItemPtr item = items.Get(i);
CStdString value;
CStdString strRating;
value.Format("%i", i + 1);
strRating.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()->m_strRuntime);
home->SetProperty("LatestMovie." + value + ".Path" , item->GetVideoInfoTag()->m_strFileNameAndPath);
home->SetProperty("LatestMovie." + value + ".Trailer" , item->GetVideoInfoTag()->m_strTrailer);
if (!item->HasThumbnail())
m_thumbLoader.LoadItem(item.get());
home->SetProperty("LatestMovie." + value + ".Thumb" , item->GetThumbnailImage());
home->SetProperty("LatestMovie." + value + ".Fanart" , item->GetProperty("fanart_image"));
}
}
for (; i < NUM_ITEMS; ++i)
{
CStdString value;
value.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;
if (videodatabase.GetRecentlyAddedEpisodesNav("videodb://5/", 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;
CStdString EpisodeNo;
CStdString value;
CStdString strRating;
EpisodeNo.Format("s%02de%02d", EpisodeSeason, EpisodeNumber);
value.Format("%i", i + 1);
strRating.Format("%.1f", item->GetVideoInfoTag()->m_fRating);
CFileItem show(item->GetVideoInfoTag()->m_strShowPath, true);
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->HasThumbnail())
m_thumbLoader.LoadItem(item.get());
std::string seasonThumb;
if (item->GetVideoInfoTag()->m_iIdSeason > 0)
seasonThumb = videodatabase.GetArtForItem(item->GetVideoInfoTag()->m_iIdSeason, "season", "thumb");
home->SetProperty("LatestEpisode." + value + ".Thumb" , item->GetThumbnailImage());
home->SetProperty("LatestEpisode." + value + ".ShowThumb" , item->GetProperty("tvshowthumb"));
home->SetProperty("LatestEpisode." + value + ".SeasonThumb" , seasonThumb);
home->SetProperty("LatestEpisode." + value + ".Fanart" , item->GetProperty("fanart_image"));
}
}
for (; i < NUM_ITEMS; ++i)
{
CStdString value;
value.Format("%i", i + 1);
//.........这里部分代码省略.........
示例11: OnClick
bool CGUIControlListSetting::OnClick()
{
if (m_pButton == NULL)
return false;
CGUIDialogSelect *dialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT);
if (dialog == NULL)
return false;
CFileItemList options;
if (!GetItems(m_pSetting, options) || options.Size() <= 1)
return false;
const CSettingControlList *control = static_cast<const CSettingControlList*>(m_pSetting->GetControl());
dialog->Reset();
dialog->SetHeading(g_localizeStrings.Get(m_pSetting->GetLabel()));
dialog->SetItems(&options);
dialog->SetMultiSelection(control->CanMultiSelect());
dialog->DoModal();
if (!dialog->IsConfirmed())
return false;
const CFileItemList &items = dialog->GetSelectedItems();
std::vector<CVariant> values;
for (int index = 0; index < items.Size(); index++)
{
const CFileItemPtr item = items[index];
if (item == NULL || !item->HasProperty("value"))
return false;
values.push_back(item->GetProperty("value"));
}
bool ret = false;
switch (m_pSetting->GetType())
{
case SettingTypeInteger:
if (values.size() > 1)
return false;
ret = ((CSettingInt *)m_pSetting)->SetValue((int)values.at(0).asInteger());
break;
case SettingTypeString:
if (values.size() > 1)
return false;
ret = ((CSettingString *)m_pSetting)->SetValue(values.at(0).asString());
break;
case SettingTypeList:
ret = CSettings::Get().SetList(m_pSetting->GetId(), values);
break;
default:
break;
}
if (ret)
Update();
return ret;
}
示例12: UpdateMusic
bool CRecentlyAddedJob::UpdateMusic()
{
CGUIWindow* home = g_windowManager.GetWindow(WINDOW_HOME);
if ( home == NULL )
return false;
CLog::Log(LOGDEBUG, "CRecentlyAddedJob::UpdateMusic() - Running RecentlyAdded home screen update");
int i = 0;
CFileItemList musicItems;
CMusicDatabase musicdatabase;
CMusicThumbLoader loader;
musicdatabase.Open();
if (musicdatabase.GetRecentlyAddedAlbumSongs("musicdb://", musicItems, NUM_ITEMS))
{
long idAlbum = -1;
CStdString strAlbumThumb;
CStdString strAlbumFanart;
for (; i < musicItems.Size(); ++i)
{
CFileItemPtr item = musicItems.Get(i);
CStdString value;
value.Format("%i", i + 1);
CStdString strRating;
CStdString strAlbum = item->GetMusicInfoTag()->GetAlbum();
CStdString strArtist = StringUtils::Join(item->GetMusicInfoTag()->GetArtist(), g_advancedSettings.m_musicItemSeparator);
if (idAlbum != item->GetMusicInfoTag()->GetAlbumId())
{
strAlbumThumb.clear();
strAlbumFanart.clear();
idAlbum = item->GetMusicInfoTag()->GetAlbumId();
if (loader.LoadItem(item.get()))
{
strAlbumThumb = item->GetThumbnailImage();
strAlbumFanart = item->GetProperty("fanart_image").asString();
}
}
strRating.Format("%c", item->GetMusicInfoTag()->GetRating());
home->SetProperty("LatestSong." + value + ".Title" , item->GetMusicInfoTag()->GetTitle());
home->SetProperty("LatestSong." + value + ".Year" , item->GetMusicInfoTag()->GetYear());
home->SetProperty("LatestSong." + value + ".Artist" , strArtist);
home->SetProperty("LatestSong." + value + ".Album" , strAlbum);
home->SetProperty("LatestSong." + value + ".Rating" , strRating);
home->SetProperty("LatestSong." + value + ".Path" , item->GetMusicInfoTag()->GetURL());
home->SetProperty("LatestSong." + value + ".Thumb" , strAlbumThumb);
home->SetProperty("LatestSong." + value + ".Fanart" , strAlbumFanart);
}
}
for (; i < NUM_ITEMS; ++i)
{
CStdString value;
value.Format("%i", i + 1);
home->SetProperty("LatestSong." + value + ".Title" , "");
home->SetProperty("LatestSong." + value + ".Year" , "");
home->SetProperty("LatestSong." + value + ".Artist" , "");
home->SetProperty("LatestSong." + value + ".Album" , "");
home->SetProperty("LatestSong." + value + ".Rating" , "");
home->SetProperty("LatestSong." + value + ".Path" , "");
home->SetProperty("LatestSong." + value + ".Thumb" , "");
home->SetProperty("LatestSong." + value + ".Fanart" , "");
}
i = 0;
VECALBUMS albums;
if (musicdatabase.GetRecentlyAddedAlbums(albums, NUM_ITEMS))
{
for (; i < (int)albums.size(); ++i)
{
CStdString value;
CStdString strPath;
CStdString strThumb;
CStdString strFanart;
CStdString strDBpath;
CStdString strSQLAlbum;
CAlbum& album=albums[i];
value.Format("%i", i + 1);
strThumb = musicdatabase.GetArtForItem(album.idAlbum, "album", "thumb");
strFanart = musicdatabase.GetArtistArtForItem(album.idAlbum, "album", "fanart");
strDBpath.Format("musicdb://3/%i/", album.idAlbum);
strSQLAlbum.Format("idAlbum=%i", album.idAlbum);
CStdString strArtist = musicdatabase.GetSingleValue("albumview", "strArtists", strSQLAlbum);
home->SetProperty("LatestAlbum." + value + ".Title" , album.strAlbum);
home->SetProperty("LatestAlbum." + value + ".Year" , album.iYear);
home->SetProperty("LatestAlbum." + value + ".Artist" , strArtist);
home->SetProperty("LatestAlbum." + value + ".Rating" , album.iRating);
home->SetProperty("LatestAlbum." + value + ".Path" , strDBpath);
home->SetProperty("LatestAlbum." + value + ".Thumb" , strThumb);
home->SetProperty("LatestAlbum." + value + ".Fanart" , strFanart);
//.........这里部分代码省略.........
示例13: SynchronizeFolderAndDatabase
//
// Synchronize function will sync the file system with two different tables at the database
// - video_files||audio_files - the fileScanner wont add files to those table, just can delete from it.
// the resolver is the only thread that add files to those tables.
// - unresolved_video_files||unresolved_audio_files - delete and add files from and to the tables.
void CFileScanner::SynchronizeFolderAndDatabase(const CStdString& strPath, const CStdString& strShareType, const CStdString& strSharePath, CFileItemList &folderItems)
{
CLog::Log(LOGDEBUG,"CFileScanner::SynchronizeFolderAndDatabase, sync folder %s with database (filescanner)", strPath.c_str());
int iFolderId = 0;
bool bMarkAsNewFolder = false;
bool updateFolderStatus = false;
std::map<std::string, BOXEE::BXMetadata*> dbResolvedItems;
std::map<std::string, BOXEE::BXMetadata*>::iterator db_resolved_it;
std::map<std::string, BOXEE::BXMetadata*> dbUnResolvedItems;
std::map<std::string, BOXEE::BXMetadata*>::iterator db_unresolved_it;
// if the folder doesnt exist then we should create a new db folder
CStdString folderType = (strShareType == "music") ? "musicFolder" : "videoFolder";
iFolderId = m_MDE->GetMediaFolderId(strPath.c_str(), folderType.c_str());
if (iFolderId == 0)
{
iFolderId = m_MDE->AddMediaFolder(strPath.c_str(), folderType.c_str(), BoxeeUtils::GetModTime(strPath));
bMarkAsNewFolder = true;
}
CLog::Log(LOGDEBUG,"CFileScanner::SynchronizeFolderAndDatabase, folder %s id %d (filescanner)",strPath.c_str(), iFolderId);
if (strShareType == "music")
{
m_MDE->GetAudiosByFolder(dbResolvedItems, strPath.c_str());
m_MDE->GetUnresolvedAudioFilesByFolder(dbUnResolvedItems, iFolderId);
}
else if (strShareType == "video")
{
m_MDE->GetVideosByFolder(dbResolvedItems, strPath.c_str(), true );
m_MDE->GetUnresolvedVideoFilesByFolder(dbUnResolvedItems, iFolderId);
}
else
{
CLog::Log(LOGDEBUG,"CFileScanner::SynchronizeFolderAndDatabase, not music or video share - skip (filescanner)");
return;
}
// Go over all folder items
int i =0;
while (m_currentShareValid && i < folderItems.Size() && (!dbResolvedItems.empty() || !dbUnResolvedItems.empty()))
{
db_resolved_it = dbResolvedItems.find(folderItems[i]->m_strPath);
db_unresolved_it = dbUnResolvedItems.find(folderItems[i]->m_strPath);
bool bRemoveFromFolderItems = false;
// the item was found in the both resolved_filles table and folder,
// so we shouldn't add or remove it from the data base
// we will only modify the ResolvedItems since we can just delete
// from those tables and not add to it
if (db_resolved_it != dbResolvedItems.end())
{
// check also if the video file still fits for size limitation then
if ((strShareType != "video") || folderItems[i]->m_bIsFolder || folderItems[i]->GetSize() >= g_guiSettings.GetInt("myvideos.videosize") * 1024 * 1024)
{
delete db_resolved_it->second;
dbResolvedItems.erase(db_resolved_it);
}
else
{
CLog::Log(LOGDEBUG,"CFileScanner::SynchronizeFolderAndDatabase file %s doesn't fit size limitation %lld - remove from the data base (filescanner)",folderItems[i]->m_strPath.c_str(),folderItems[i]->GetSize());
}
bRemoveFromFolderItems = true;
}
else
{
CLog::Log(LOGDEBUG,"CFileScanner::SynchronizeFolderAndDatabase, file %s wasn't found in video_files (filescanner)", folderItems[i]->m_strPath.c_str());
}
// the item was found in the both data base and folder,
// so we shouldn't add or remove it from the data base
if (db_unresolved_it != dbUnResolvedItems.end())
{
// check also if the file still fits for size limitation then
if ((strShareType != "video") || folderItems[i]->m_bIsFolder || folderItems[i]->GetSize() >= g_guiSettings.GetInt("myvideos.videosize") * 1024 * 1024)
{
delete db_unresolved_it->second;
dbUnResolvedItems.erase(db_unresolved_it);
}
else
{
CLog::Log(LOGDEBUG,"CFileScanner::SynchronizeFolderAndDatabase file %s doesn't fit size limitation - remove from the data base (filescanner)",folderItems[i]->m_strPath.c_str());
}
bRemoveFromFolderItems = true;
}
else
{
CLog::Log(LOGDEBUG,"CFileScanner::SynchronizeFolderAndDatabase, file %s wasn't found in unresolved_video_files (filescanner)", folderItems[i]->m_strPath.c_str());
}
if (bRemoveFromFolderItems)
//.........这里部分代码省略.........
示例14: Load
bool CButtonTranslator::Load()
{
translatorMap.clear();
//directories to search for keymaps
//they're applied in this order,
//so keymaps in profile/keymaps/
//override e.g. system/keymaps
static const char* DIRS_TO_CHECK[] = {
"special://xbmc/system/keymaps/",
"special://masterprofile/keymaps/",
"special://profile/keymaps/"
};
bool success = false;
for(unsigned int dirIndex = 0; dirIndex < sizeof(DIRS_TO_CHECK)/sizeof(DIRS_TO_CHECK[0]); ++dirIndex) {
if( XFILE::CDirectory::Exists(DIRS_TO_CHECK[dirIndex]) )
{
CFileItemList files;
XFILE::CDirectory::GetDirectory(DIRS_TO_CHECK[dirIndex], files, "*.xml");
//sort the list for filesystem based prioties, e.g. 01-keymap.xml, 02-keymap-overrides.xml
files.Sort(SORT_METHOD_FILE, SORT_ORDER_ASC);
for(int fileIndex = 0; fileIndex<files.Size(); ++fileIndex)
success |= LoadKeymap(files[fileIndex]->m_strPath);
}
}
if (!success)
{
CLog::Log(LOGERROR, "Error loading keymaps from: %s or %s or %s", DIRS_TO_CHECK[0], DIRS_TO_CHECK[1], DIRS_TO_CHECK[2]);
return false;
}
#if defined(HAS_LIRC) || defined(HAS_IRSERVERSUITE)
#ifdef _LINUX
#define REMOTEMAP "Lircmap.xml"
#else
#define REMOTEMAP "IRSSmap.xml"
#endif
CStdString lircmapPath;
URIUtils::AddFileToFolder("special://xbmc/system/", REMOTEMAP, lircmapPath);
lircRemotesMap.clear();
if(CFile::Exists(lircmapPath))
success |= LoadLircMap(lircmapPath);
else
CLog::Log(LOGDEBUG, "CButtonTranslator::Load - no system %s found, skipping", REMOTEMAP);
lircmapPath = g_settings.GetUserDataItem(REMOTEMAP);
if(CFile::Exists(lircmapPath))
success |= LoadLircMap(lircmapPath);
else
CLog::Log(LOGDEBUG, "CButtonTranslator::Load - no userdata %s found, skipping", REMOTEMAP);
if (!success)
CLog::Log(LOGERROR, "CButtonTranslator::Load - unable to load remote map %s", REMOTEMAP);
// don't return false - it is to only indicate a fatal error (which this is not)
#endif
// Done!
return true;
}
示例15: GetWithoutUserDetails
CStdString CURI::GetWithoutUserDetails() const
{
CStdString strURL;
if (m_strProtocol.Equals("stack"))
{
CFileItemList items;
CStdString strURL2;
strURL2 = Get();
DIRECTORY::CStackDirectory dir;
dir.GetDirectory(strURL2,items);
vector<CStdString> newItems;
for (int i=0;i<items.Size();++i)
{
CURI url(items[i]->m_strPath);
items[i]->m_strPath = url.GetWithoutUserDetails();
newItems.push_back(items[i]->m_strPath);
}
dir.ConstructStackPath(newItems,strURL);
return strURL;
}
unsigned int sizeneed = m_strProtocol.length()
+ m_strDomain.length()
+ m_strHostName.length()
+ m_strFileName.length()
+ m_strOptions.length()
+ m_strProtocolOptions.length()
+ 10;
strURL.reserve(sizeneed);
if (m_strProtocol == "")
return m_strFileName;
strURL = m_strProtocol;
strURL += "://";
if (m_strHostName != "")
{
if (m_strProtocol.Equals("rar") || m_strProtocol.Equals("zip"))
strURL += CURI(m_strHostName).GetWithoutUserDetails();
else
strURL += m_strHostName;
if ( HasPort() )
{
CStdString strPort;
strPort.Format("%i", m_iPort);
strURL += ":";
strURL += strPort;
}
strURL += "/";
}
strURL += m_strFileName;
if( m_strOptions.length() > 0 )
strURL += m_strOptions;
if( m_strProtocolOptions.length() > 0 )
strURL += "|"+m_strProtocolOptions;
return strURL;
}