本文整理汇总了C++中CFileItemPtr::GetLabel方法的典型用法代码示例。如果您正苦于以下问题:C++ CFileItemPtr::GetLabel方法的具体用法?C++ CFileItemPtr::GetLabel怎么用?C++ CFileItemPtr::GetLabel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFileItemPtr
的用法示例。
在下文中一共展示了CFileItemPtr::GetLabel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ResolveURL
void CPlayListM3U::Save(const std::string& strFileName) const
{
if (!m_vecItems.size())
return;
std::string strPlaylist = CUtil::MakeLegalPath(strFileName);
CFile file;
if (!file.OpenForWrite(strPlaylist,true))
{
CLog::Log(LOGERROR, "Could not save M3U playlist: [%s]", strPlaylist.c_str());
return;
}
std::string strLine = StringUtils::Format("%s\n",M3U_START_MARKER);
if (file.Write(strLine.c_str(), strLine.size()) != static_cast<ssize_t>(strLine.size()))
return; // error
for (int i = 0; i < (int)m_vecItems.size(); ++i)
{
CFileItemPtr item = m_vecItems[i];
std::string strDescription=item->GetLabel();
g_charsetConverter.utf8ToStringCharset(strDescription);
strLine = StringUtils::Format( "%s:%i,%s\n", M3U_INFO_MARKER, item->GetMusicInfoTag()->GetDuration() / 1000, strDescription.c_str() );
if (file.Write(strLine.c_str(), strLine.size()) != static_cast<ssize_t>(strLine.size()))
return; // error
if (item->m_lStartOffset != 0 || item->m_lEndOffset != 0)
{
strLine = StringUtils::Format("%s:%i,%i\n", M3U_OFFSET_MARKER, item->m_lStartOffset, item->m_lEndOffset);
file.Write(strLine.c_str(),strLine.size());
}
std::string strFileName = ResolveURL(item);
g_charsetConverter.utf8ToStringCharset(strFileName);
strLine = StringUtils::Format("%s\n",strFileName.c_str());
if (file.Write(strLine.c_str(), strLine.size()) != static_cast<ssize_t>(strLine.size()))
return; // error
}
file.Close();
}
示例2: OnPlayMedia
bool CGUIWindowMusicBase::OnPlayMedia(int iItem)
{
CFileItemPtr pItem = m_vecItems->Get(iItem);
if (pItem->m_strPath == "add" && pItem->GetLabel() == g_localizeStrings.Get(1026)) // 'add source button' in empty root
{
if (CGUIDialogMediaSource::ShowAndAddMediaSource("music"))
{
Update("");
return true;
}
return false;
}
// party mode
#ifndef _BOXEE_
if (g_partyModeManager.IsEnabled() && !pItem->IsLastFM())
{
CPlayList playlistTemp;
playlistTemp.Add(pItem);
g_partyModeManager.AddUserSongs(playlistTemp, true);
return true;
}
else
#endif
if (!pItem->IsPlayList() && !pItem->IsInternetStream())
{ // single music file - if we get here then we have autoplaynextitem turned off, but we
// still want to use the playlist player in order to handle more queued items following etc.
g_playlistPlayer.Reset();
g_playlistPlayer.ClearPlaylist(PLAYLIST_MUSIC);
g_playlistPlayer.Add(PLAYLIST_MUSIC, pItem);
g_playlistPlayer.SetCurrentPlaylist(PLAYLIST_MUSIC);
g_playlistPlayer.Play();
return true;
}
return CGUIMediaWindow::OnPlayMedia(iItem);
}
示例3: GetContextButtons
void CGUIWindowPVRSearch::GetContextButtons(int itemNumber, CContextButtons &buttons) const
{
if (itemNumber < 0 || itemNumber >= m_parent->m_vecItems->Size())
return;
CFileItemPtr pItem = m_parent->m_vecItems->Get(itemNumber);
if (pItem->GetLabel() != g_localizeStrings.Get(19027))
{
if (pItem->GetEPGInfoTag()->EndAsLocalTime() > CDateTime::GetCurrentDateTime())
{
if (!pItem->GetEPGInfoTag()->HasTimer())
{
if (pItem->GetEPGInfoTag()->StartAsLocalTime() < CDateTime::GetCurrentDateTime())
buttons.Add(CONTEXT_BUTTON_START_RECORD, 264); /* RECORD programme */
else
buttons.Add(CONTEXT_BUTTON_START_RECORD, 19061); /* Create a Timer */
}
else
{
if (pItem->GetEPGInfoTag()->StartAsLocalTime() < CDateTime::GetCurrentDateTime())
buttons.Add(CONTEXT_BUTTON_STOP_RECORD, 19059); /* Stop recording */
else
buttons.Add(CONTEXT_BUTTON_STOP_RECORD, 19060); /* Delete Timer */
}
}
buttons.Add(CONTEXT_BUTTON_INFO, 19047); /* Epg info button */
buttons.Add(CONTEXT_BUTTON_SORTBY_CHANNEL, 19062); /* Sort by channel */
buttons.Add(CONTEXT_BUTTON_SORTBY_NAME, 103); /* Sort by Name */
buttons.Add(CONTEXT_BUTTON_SORTBY_DATE, 104); /* Sort by Date */
buttons.Add(CONTEXT_BUTTON_CLEAR, 19232); /* Clear search results */
if (pItem->GetEPGInfoTag()->HasPVRChannel() &&
g_PVRClients->HasMenuHooks(pItem->GetEPGInfoTag()->ChannelTag()->ClientID()))
buttons.Add(CONTEXT_BUTTON_MENU_HOOKS, 19195); /* PVR client specific action */
}
}
示例4: FillFileItemList
bool CFileItemHandler::FillFileItemList(const CVariant ¶meterObject, CFileItemList &list)
{
CAudioLibrary::FillFileItemList(parameterObject, list);
CVideoLibrary::FillFileItemList(parameterObject, list);
CFileOperations::FillFileItemList(parameterObject, list);
CStdString file = parameterObject["file"].asString();
if (!file.empty() && (URIUtils::IsURL(file) || (CFile::Exists(file) && !CDirectory::Exists(file))))
{
bool added = false;
for (int index = 0; index < list.Size(); index++)
{
if (list[index]->GetPath() == file)
{
added = true;
break;
}
}
if (!added)
{
CFileItemPtr item = CFileItemPtr(new CFileItem(file, false));
if (item->IsPicture())
{
CPictureInfoTag picture;
picture.Load(item->GetPath());
*item->GetPictureInfoTag() = picture;
}
if (item->GetLabel().IsEmpty())
item->SetLabel(CUtil::GetTitleFromPath(file, false));
list.Add(item);
}
}
return (list.Size() > 0);
}
示例5: OnContextButton
bool CGUIWindowPrograms::OnContextButton(int itemNumber, CONTEXT_BUTTON button)
{
CFileItemPtr item = (itemNumber >= 0 && itemNumber < m_vecItems->Size()) ? m_vecItems->Get(itemNumber) : CFileItemPtr();
if (item && m_vecItems->IsVirtualDirectoryRoot())
{
if (CGUIDialogContextMenu::OnContextButton("programs", item, button))
{
Update("");
return true;
}
}
switch (button)
{
case CONTEXT_BUTTON_RENAME:
{
CStdString strDescription;
CShortcut cut;
if (item->IsShortCut())
{
cut.Create(item->GetPath());
strDescription = cut.m_strLabel;
}
else
strDescription = item->GetLabel();
if (CGUIDialogKeyboard::ShowAndGetInput(strDescription, g_localizeStrings.Get(16008), false))
{
if (item->IsShortCut())
{
cut.m_strLabel = strDescription;
cut.Save(item->GetPath());
}
else
{
// SetXBEDescription will truncate to 40 characters.
//CUtil::SetXBEDescription(item->GetPath(),strDescription);
//m_database.SetDescription(item->GetPath(),strDescription);
}
Update(m_vecItems->GetPath());
}
return true;
}
case CONTEXT_BUTTON_GOTO_ROOT:
Update("");
return true;
case CONTEXT_BUTTON_LAUNCH:
OnClick(itemNumber);
return true;
case CONTEXT_BUTTON_INFO:
OnInfo(itemNumber);
return true;
default:
break;
}
return CGUIMediaWindow::OnContextButton(itemNumber, button);
}
示例6: 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;
CVideoThumbLoader loader;
loader.Initialize();
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()->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)
{
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->HasArt("thumb"))
loader.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->GetArt("thumb"));
home->SetProperty("LatestEpisode." + value + ".ShowThumb" , item->GetArt("tvshow.thumb"));
home->SetProperty("LatestEpisode." + value + ".SeasonThumb" , seasonThumb);
home->SetProperty("LatestEpisode." + value + ".Fanart" , item->GetArt("fanart"));
}
}
for (; i < NUM_ITEMS; ++i)
{
//.........这里部分代码省略.........
示例7: 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;
}
// 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();
m_gWindowManager.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;
}
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)
continue;
if (!item->IsPlayList() && !item->IsZIP() && !item->IsRAR())
queueItems.Add(item);
if (item == pItem)
{ // item that was clicked
songToPlay = queueItems.Size() - 1;
}
}
g_playlistPlayer.Add(iPlaylist, queueItems);
// Save current window and directory to know where the selected item was
if (m_guiState.get())
//.........这里部分代码省略.........
示例8: OnClick
void CGUIWindowFileManager::OnClick(int iList, int iItem)
{
if ( iList < 0 || iList >= 2) return ;
if ( iItem < 0 || iItem >= m_vecItems[iList]->Size() ) return ;
CFileItemPtr pItem = m_vecItems[iList]->Get(iItem);
if (pItem->GetPath() == "add" && pItem->GetLabel() == g_localizeStrings.Get(1026)) // 'add source button' in empty root
{
if (CGUIDialogMediaSource::ShowAndAddMediaSource("files"))
{
m_rootDir.SetSources(*CMediaSourceSettings::Get().GetSources("files"));
Update(0,m_Directory[0]->GetPath());
Update(1,m_Directory[1]->GetPath());
}
return;
}
if (!pItem->m_bIsFolder && pItem->IsFileFolder(EFILEFOLDER_MASK_ALL))
{
XFILE::IFileDirectory *pFileDirectory = NULL;
pFileDirectory = XFILE::CFileDirectoryFactory::Create(pItem->GetURL(), pItem.get(), "");
if(pFileDirectory)
pItem->m_bIsFolder = true;
else if(pItem->m_bIsFolder)
pItem->m_bIsFolder = false;
delete pFileDirectory;
}
if (pItem->m_bIsFolder)
{
// save path + drive type because of the possible refresh
CStdString strPath = pItem->GetPath();
int iDriveType = pItem->m_iDriveType;
if ( pItem->m_bIsShareOrDrive )
{
if ( !g_passwordManager.IsItemUnlocked( pItem.get(), "files" ) )
{
Refresh();
return ;
}
if ( !HaveDiscOrConnection( strPath, iDriveType ) )
return ;
}
if (!Update(iList, strPath))
ShowShareErrorMessage(pItem.get());
}
else if (pItem->IsZIP() || pItem->IsCBZ()) // mount zip archive
{
CURL pathToUrl = URIUtils::CreateArchivePath("zip", pItem->GetURL(), "");
Update(iList, pathToUrl.Get());
}
else if (pItem->IsRAR() || pItem->IsCBR())
{
CURL pathToUrl = URIUtils::CreateArchivePath("rar", pItem->GetURL(), "");
Update(iList, pathToUrl.Get());
}
else
{
OnStart(pItem.get());
return ;
}
// UpdateButtons();
}
示例9: Process
void CEdenVideoArtUpdater::Process()
{
// grab all movies...
CVideoDatabase db;
if (!db.Open())
return;
CFileItemList items;
CGUIDialogExtendedProgressBar* dialog =
(CGUIDialogExtendedProgressBar*)g_windowManager.GetWindow(WINDOW_DIALOG_EXT_PROGRESS);
CGUIDialogProgressBarHandle *handle = dialog->GetHandle(g_localizeStrings.Get(314));
handle->SetTitle(g_localizeStrings.Get(12349));
// movies
db.GetMoviesByWhere("videodb://movies/titles/", CDatabase::Filter(), items);
for (int i = 0; i < items.Size(); i++)
{
CFileItemPtr item = items[i];
handle->SetProgress(i, items.Size());
handle->SetText(StringUtils::Format(g_localizeStrings.Get(12350).c_str(), item->GetLabel().c_str()));
string cachedThumb = GetCachedVideoThumb(*item);
string cachedFanart = GetCachedFanart(*item);
item->SetPath(item->GetVideoInfoTag()->m_strFileNameAndPath);
item->GetVideoInfoTag()->m_fanart.Unpack();
item->GetVideoInfoTag()->m_strPictureURL.Parse();
map<string, string> artwork;
if (!db.GetArtForItem(item->GetVideoInfoTag()->m_iDbId, item->GetVideoInfoTag()->m_type, artwork)
|| (artwork.size() == 1 && artwork.find("thumb") != artwork.end()))
{
CStdString art = CVideoInfoScanner::GetImage(item.get(), true, item->GetVideoInfoTag()->m_basePath != item->GetPath(), "thumb");
std::string type;
if (CacheTexture(art, cachedThumb, item->GetLabel(), type))
artwork.insert(make_pair(type, art));
art = CVideoInfoScanner::GetFanart(item.get(), true);
if (CacheTexture(art, cachedFanart, item->GetLabel()))
artwork.insert(make_pair("fanart", art));
if (artwork.empty())
artwork.insert(make_pair("thumb", ""));
db.SetArtForItem(item->GetVideoInfoTag()->m_iDbId, item->GetVideoInfoTag()->m_type, artwork);
}
}
items.Clear();
// music videos
db.GetMusicVideosNav("videodb://musicvideos/titles/", items, false);
for (int i = 0; i < items.Size(); i++)
{
CFileItemPtr item = items[i];
handle->SetProgress(i, items.Size());
handle->SetText(StringUtils::Format(g_localizeStrings.Get(12350).c_str(), item->GetLabel().c_str()));
string cachedThumb = GetCachedVideoThumb(*item);
string cachedFanart = GetCachedFanart(*item);
item->SetPath(item->GetVideoInfoTag()->m_strFileNameAndPath);
item->GetVideoInfoTag()->m_fanart.Unpack();
item->GetVideoInfoTag()->m_strPictureURL.Parse();
map<string, string> artwork;
if (!db.GetArtForItem(item->GetVideoInfoTag()->m_iDbId, item->GetVideoInfoTag()->m_type, artwork)
|| (artwork.size() == 1 && artwork.find("thumb") != artwork.end()))
{
CStdString art = CVideoInfoScanner::GetImage(item.get(), true, item->GetVideoInfoTag()->m_basePath != item->GetPath(), "thumb");
std::string type;
if (CacheTexture(art, cachedThumb, item->GetLabel(), type))
artwork.insert(make_pair(type, art));
art = CVideoInfoScanner::GetFanart(item.get(), true);
if (CacheTexture(art, cachedFanart, item->GetLabel()))
artwork.insert(make_pair("fanart", art));
if (artwork.empty())
artwork.insert(make_pair("thumb", ""));
db.SetArtForItem(item->GetVideoInfoTag()->m_iDbId, item->GetVideoInfoTag()->m_type, artwork);
}
}
items.Clear();
// tvshows
// count the number of episodes
db.GetTvShowsNav("videodb://tvshows/titles/", items);
for (int i = 0; i < items.Size(); i++)
{
CFileItemPtr item = items[i];
handle->SetText(StringUtils::Format(g_localizeStrings.Get(12350).c_str(), item->GetLabel().c_str()));
string cachedThumb = GetCachedVideoThumb(*item);
string cachedFanart = GetCachedFanart(*item);
item->SetPath(item->GetVideoInfoTag()->m_strPath);
item->GetVideoInfoTag()->m_fanart.Unpack();
item->GetVideoInfoTag()->m_strPictureURL.Parse();
map<string, string> artwork;
if (!db.GetArtForItem(item->GetVideoInfoTag()->m_iDbId, item->GetVideoInfoTag()->m_type, artwork)
|| (artwork.size() == 1 && artwork.find("thumb") != artwork.end()))
//.........这里部分代码省略.........
示例10: OnDeleteItem
void CGUIWindowVideoNav::OnDeleteItem(CFileItemPtr pItem)
{
if (m_vecItems->IsParentFolder())
return;
if (m_vecItems->m_strPath.Equals("special://videoplaylists/"))
{
if (!pItem->m_strPath.Equals("newsmartplaylist://video"))
CGUIWindowVideoBase::OnDeleteItem(pItem);
}
else if (pItem->m_strPath.Left(14).Equals("videodb://1/7/") &&
pItem->m_strPath.size() > 14 && pItem->m_bIsFolder)
{
CGUIDialogYesNo* pDialog = (CGUIDialogYesNo*)g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO);
pDialog->SetLine(0, g_localizeStrings.Get(432));
CStdString strLabel;
strLabel.Format(g_localizeStrings.Get(433),pItem->GetLabel());
pDialog->SetLine(1, strLabel);
pDialog->SetLine(2, "");;
pDialog->DoModal();
if (pDialog->IsConfirmed())
{
CFileItemList items;
CDirectory::GetDirectory(pItem->m_strPath,items,"",false,false,DIR_CACHE_ONCE,true,true);
for (int i=0;i<items.Size();++i)
OnDeleteItem(items[i]);
CVideoDatabaseDirectory dir;
CQueryParams params;
dir.GetQueryParams(pItem->m_strPath,params);
m_database.DeleteSet(params.GetSetId());
}
}
else
{
if (!DeleteItem(pItem.get()))
return;
CStdString strDeletePath;
if (pItem->m_bIsFolder)
strDeletePath=pItem->GetVideoInfoTag()->m_strPath;
else
strDeletePath=pItem->GetVideoInfoTag()->m_strFileNameAndPath;
if (CUtil::GetFileName(strDeletePath).Equals("VIDEO_TS.IFO"))
{
CUtil::GetDirectory(strDeletePath.Mid(0),strDeletePath);
if (strDeletePath.Right(9).Equals("VIDEO_TS/"))
{
CUtil::RemoveSlashAtEnd(strDeletePath);
CUtil::GetDirectory(strDeletePath.Mid(0),strDeletePath);
}
}
if (CUtil::HasSlashAtEnd(strDeletePath))
pItem->m_bIsFolder=true;
if (g_guiSettings.GetBool("filelists.allowfiledeletion") &&
CUtil::SupportsFileOperations(strDeletePath))
{
pItem->m_strPath = strDeletePath;
CGUIWindowVideoBase::OnDeleteItem(pItem);
}
}
CUtil::DeleteVideoDatabaseDirectoryCache();
DisplayEmptyDatabaseMessage(!m_database.HasContent());
}
示例11: OnContextButton
bool CGUIWindowMusicNav::OnContextButton(int itemNumber, CONTEXT_BUTTON button)
{
CFileItemPtr item;
if (itemNumber >= 0 && itemNumber < m_vecItems->Size())
item = m_vecItems->Get(itemNumber);
switch (button)
{
case CONTEXT_BUTTON_INFO:
{
if (!item->IsVideoDb())
return CGUIWindowMusicBase::OnContextButton(itemNumber,button);
// music videos - artists
if (StringUtils::StartsWithNoCase(item->GetPath(), "videodb://musicvideos/artists/"))
{
long idArtist = m_musicdatabase.GetArtistByName(item->GetLabel());
if (idArtist == -1)
return false;
std::string path = StringUtils::Format("musicdb://artists/%ld/", idArtist);
CArtist artist;
m_musicdatabase.GetArtist(idArtist, artist, false);
*item = CFileItem(artist);
item->SetPath(path);
CGUIWindowMusicBase::OnContextButton(itemNumber,button);
Refresh();
m_viewControl.SetSelectedItem(itemNumber);
return true;
}
// music videos - albums
if (StringUtils::StartsWithNoCase(item->GetPath(), "videodb://musicvideos/albums/"))
{
long idAlbum = m_musicdatabase.GetAlbumByName(item->GetLabel());
if (idAlbum == -1)
return false;
std::string path = StringUtils::Format("musicdb://albums/%ld/", idAlbum);
CAlbum album;
m_musicdatabase.GetAlbum(idAlbum, album, false);
*item = CFileItem(path,album);
item->SetPath(path);
CGUIWindowMusicBase::OnContextButton(itemNumber,button);
Refresh();
m_viewControl.SetSelectedItem(itemNumber);
return true;
}
if (item->HasVideoInfoTag() && !item->GetVideoInfoTag()->m_strTitle.empty())
{
CGUIDialogVideoInfo::ShowFor(*item);
Refresh();
}
return true;
}
case CONTEXT_BUTTON_INFO_ALL:
OnItemInfoAll(itemNumber);
return true;
case CONTEXT_BUTTON_SET_DEFAULT:
CSettings::GetInstance().SetString(CSettings::SETTING_MYMUSIC_DEFAULTLIBVIEW, GetQuickpathName(item->GetPath()));
CSettings::GetInstance().Save();
return true;
case CONTEXT_BUTTON_CLEAR_DEFAULT:
CSettings::GetInstance().SetString(CSettings::SETTING_MYMUSIC_DEFAULTLIBVIEW, "");
CSettings::GetInstance().Save();
return true;
case CONTEXT_BUTTON_GO_TO_ARTIST:
{
std::string strPath;
CVideoDatabase database;
database.Open();
strPath = StringUtils::Format("videodb://musicvideos/artists/%i/",
database.GetMatchingMusicVideo(item->GetMusicInfoTag()->GetArtistString()));
g_windowManager.ActivateWindow(WINDOW_VIDEO_NAV,strPath);
return true;
}
case CONTEXT_BUTTON_PLAY_OTHER:
{
CVideoDatabase database;
database.Open();
CVideoInfoTag details;
database.GetMusicVideoInfo("", details, database.GetMatchingMusicVideo(item->GetMusicInfoTag()->GetArtistString(), item->GetMusicInfoTag()->GetAlbum(), item->GetMusicInfoTag()->GetTitle()));
CApplicationMessenger::GetInstance().PostMsg(TMSG_MEDIA_PLAY, 0, 0, static_cast<void*>(new CFileItem(details)));
return true;
}
case CONTEXT_BUTTON_RENAME:
if (!item->IsVideoDb() && !item->IsReadOnly())
OnRenameItem(itemNumber);
CGUIDialogVideoInfo::UpdateVideoItemTitle(item);
CUtil::DeleteVideoDatabaseDirectoryCache();
Refresh();
return true;
case CONTEXT_BUTTON_DELETE:
//.........这里部分代码省略.........
示例12: GetDirectory
//.........这里部分代码省略.........
}
// Get the fanart.
const char* fanart = root->Attribute("art");
string strFanart;
if (fanart && strlen(fanart) > 0)
strFanart = ProcessUrl(strPath, fanart, false);
// Walk the parsed tree.
string strFileLabel = "%N - %T";
string strDirLabel = "%B";
string strSecondDirLabel = "%Y";
Parse(m_url, root, items, strFileLabel, strDirLabel, strSecondDirLabel);
// Set the window titles
const char* title1 = root->Attribute("title1");
const char* title2 = root->Attribute("title2");
if (title1 && strlen(title1) > 0)
items.SetFirstTitle(title1);
if (title2 && strlen(title2) > 0)
items.SetSecondTitle(title2);
// Set fanart on items if they don't have their own.
for (int i=0; i<items.Size(); i++)
{
CFileItemPtr pItem = items[i];
if (strFanart.size() > 0 && pItem->GetQuickFanart().size() == 0)
pItem->SetQuickFanart(strFanart);
// Make sure sort label is lower case.
string sortLabel = pItem->GetLabel();
boost::to_lower(sortLabel);
pItem->SetSortLabel(sortLabel);
}
// Set fanart on directory.
if (strFanart.size() > 0)
items.SetQuickFanart(strFanart);
// Set the view mode.
const char* viewmode = root->Attribute("viewmode");
if (viewmode && strlen(viewmode) > 0)
{
CGUIViewState* viewState = CGUIViewState::GetViewState(0, items);
viewState->SaveViewAsControl(atoi(viewmode));
}
// Override labels.
const char* fileLabel = root->Attribute("filelabel");
if (fileLabel && strlen(fileLabel) > 0)
strFileLabel = fileLabel;
const char* dirLabel = root->Attribute("dirlabel");
if (dirLabel && strlen(dirLabel) > 0)
strDirLabel = dirLabel;
// Add the sort method.
items.AddSortMethod(SORT_METHOD_NONE, 552, LABEL_MASKS(strFileLabel, "%D", strDirLabel, strSecondDirLabel));
// Set the content label.
const char* content = root->Attribute("content");
if (content && strlen(content) > 0)
{
示例13: OnContextButton
bool CGUIWindowMusicNav::OnContextButton(int itemNumber, CONTEXT_BUTTON button)
{
CFileItemPtr item;
if (itemNumber >= 0 && itemNumber < m_vecItems->Size())
item = m_vecItems->Get(itemNumber);
switch (button)
{
case CONTEXT_BUTTON_INFO:
{
if (!item->IsVideoDb())
return CGUIWindowMusicBase::OnContextButton(itemNumber,button);
// music videos - artists
if (StringUtils::StartsWithNoCase(item->GetPath(), "videodb://musicvideos/artists/"))
{
long idArtist = m_musicdatabase.GetArtistByName(item->GetLabel());
if (idArtist == -1)
return false;
CStdString path = StringUtils::Format("musicdb://artists/%ld/", idArtist);
CArtist artist;
m_musicdatabase.GetArtistInfo(idArtist,artist,false);
*item = CFileItem(artist);
item->SetPath(path);
CGUIWindowMusicBase::OnContextButton(itemNumber,button);
Refresh();
m_viewControl.SetSelectedItem(itemNumber);
return true;
}
// music videos - albums
if (StringUtils::StartsWithNoCase(item->GetPath(), "videodb://musicvideos/albums/"))
{
long idAlbum = m_musicdatabase.GetAlbumByName(item->GetLabel());
if (idAlbum == -1)
return false;
CStdString path = StringUtils::Format("musicdb://albums/%ld/", idAlbum);
CAlbum album;
m_musicdatabase.GetAlbumInfo(idAlbum,album,NULL);
*item = CFileItem(path,album);
item->SetPath(path);
CGUIWindowMusicBase::OnContextButton(itemNumber,button);
Refresh();
m_viewControl.SetSelectedItem(itemNumber);
return true;
}
if (item->HasVideoInfoTag() && !item->GetVideoInfoTag()->m_strTitle.empty())
{
CGUIWindowVideoNav* pWindow = (CGUIWindowVideoNav*)g_windowManager.GetWindow(WINDOW_VIDEO_NAV);
if (pWindow)
{
ADDON::ScraperPtr info;
pWindow->OnInfo(item.get(),info);
Refresh();
}
}
return true;
}
case CONTEXT_BUTTON_INFO_ALL:
OnInfoAll(itemNumber);
return true;
case CONTEXT_BUTTON_SET_DEFAULT:
CSettings::Get().SetString("mymusic.defaultlibview", GetQuickpathName(item->GetPath()));
CSettings::Get().Save();
return true;
case CONTEXT_BUTTON_CLEAR_DEFAULT:
CSettings::Get().SetString("mymusic.defaultlibview", "");
CSettings::Get().Save();
return true;
case CONTEXT_BUTTON_GO_TO_ARTIST:
{
CStdString strPath;
CVideoDatabase database;
database.Open();
strPath = StringUtils::Format("videodb://musicvideos/artists/%ld/",
database.GetMatchingMusicVideo(StringUtils::Join(item->GetMusicInfoTag()->GetArtist(), g_advancedSettings.m_musicItemSeparator)));
g_windowManager.ActivateWindow(WINDOW_VIDEO_NAV,strPath);
return true;
}
case CONTEXT_BUTTON_PLAY_OTHER:
{
CVideoDatabase database;
database.Open();
CVideoInfoTag details;
database.GetMusicVideoInfo("",details,database.GetMatchingMusicVideo(StringUtils::Join(item->GetMusicInfoTag()->GetArtist(), g_advancedSettings.m_musicItemSeparator),item->GetMusicInfoTag()->GetAlbum(),item->GetMusicInfoTag()->GetTitle()));
CApplicationMessenger::Get().PlayFile(CFileItem(details));
return true;
}
case CONTEXT_BUTTON_MARK_WATCHED:
CGUIDialogVideoInfo::MarkWatched(item, true);
CUtil::DeleteVideoDatabaseDirectoryCache();
Refresh();
return true;
//.........这里部分代码省略.........
示例14: OnDownloadComplete
void CGUIDialogSubtitles::OnDownloadComplete(const CFileItemList *items, const std::string &language)
{
if (items->IsEmpty())
{
CFileItemPtr service = GetService();
if (service)
CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Error, service->GetLabel(), g_localizeStrings.Get(24113));
UpdateStatus(SEARCH_COMPLETE);
return;
}
CStdString strFileName;
CStdString strDestPath;
#if 0
// TODO: Code to download all subtitles for all stack items in one run
if (g_application.CurrentFileItem().IsStack())
{
for (int i = 0; i < items->Size(); i++)
{
// check for all stack items and match to given subs, item [0] == CD1, item [1] == CD2
// CLog::Log(LOGDEBUG, "Stack Subs [%s} Found", vecItems[i]->GetLabel().c_str());
}
}
#endif
// Get (unstacked) path
const CStdString &strCurrentFile = g_application.CurrentUnstackedItem().GetPath();
if (StringUtils::StartsWith(strCurrentFile, "http://"))
{
strFileName = "TemporarySubs";
strDestPath = "special://temp/";
}
else
{
strFileName = URIUtils::GetFileName(strCurrentFile);
if (CSettings::Get().GetBool("subtitles.savetomoviefolder"))
{
strDestPath = URIUtils::GetDirectory(strCurrentFile);
if (!CUtil::SupportsWriteFileOperations(strDestPath))
strDestPath.clear();
}
if (strDestPath.empty())
{
if (CSpecialProtocol::TranslatePath("special://subtitles").empty())
strDestPath = "special://temp";
else
strDestPath = "special://subtitles";
}
}
// Extract the language and appropriate extension
CStdString strSubLang;
g_LangCodeExpander.ConvertToTwoCharCode(strSubLang, language);
CStdString strUrl = items->Get(0)->GetPath();
CStdString strSubExt = URIUtils::GetExtension(strUrl);
// construct subtitle path
URIUtils::RemoveExtension(strFileName);
CStdString strSubName = StringUtils::Format("%s.%s%s", strFileName.c_str(), strSubLang.c_str(), strSubExt.c_str());
CStdString strSubPath = URIUtils::AddFileToFolder(strDestPath, strSubName);
// and copy the file across
CFile::Cache(strUrl, strSubPath);
// for ".sub" subtitles we check if ".idx" counterpart exists and copy that as well
if (strSubExt.Equals(".sub"))
{
strUrl = URIUtils::ReplaceExtension(strUrl, ".idx");
if(CFile::Exists(strUrl))
{
CStdString strSubNameIdx = StringUtils::Format("%s.%s.idx", strFileName.c_str(), strSubLang.c_str());
strSubPath = URIUtils::AddFileToFolder(strDestPath, strSubNameIdx);
CFile::Cache(strUrl, strSubPath);
}
}
SetSubtitles(strSubPath);
// Close the window
Close();
}
示例15: Announce
//.........这里部分代码省略.........
CVideoDatabase videodatabase;
if (videodatabase.Open())
{
if (videodatabase.LoadVideoInfo(item->GetPath(), *item->GetVideoInfoTag()))
id = item->GetVideoInfoTag()->m_iDbId;
videodatabase.Close();
}
}
if (!item->GetVideoInfoTag()->m_type.empty())
type = item->GetVideoInfoTag()->m_type;
else
CVideoDatabase::VideoContentTypeToString((VIDEODB_CONTENT_TYPE)item->GetVideoContentType(), type);
if (id <= 0)
{
// TODO: Can be removed once this is properly handled when starting playback of a file
item->SetProperty(LOOKUP_PROPERTY, false);
object["item"]["title"] = item->GetVideoInfoTag()->m_strTitle;
switch (item->GetVideoContentType())
{
case VIDEODB_CONTENT_MOVIES:
if (item->GetVideoInfoTag()->m_iYear > 0)
object["item"]["year"] = item->GetVideoInfoTag()->m_iYear;
break;
case VIDEODB_CONTENT_EPISODES:
if (item->GetVideoInfoTag()->m_iEpisode >= 0)
object["item"]["episode"] = item->GetVideoInfoTag()->m_iEpisode;
if (item->GetVideoInfoTag()->m_iSeason >= 0)
object["item"]["season"] = item->GetVideoInfoTag()->m_iSeason;
if (!item->GetVideoInfoTag()->m_strShowTitle.empty())
object["item"]["showtitle"] = item->GetVideoInfoTag()->m_strShowTitle;
break;
case VIDEODB_CONTENT_MUSICVIDEOS:
if (!item->GetVideoInfoTag()->m_strAlbum.empty())
object["item"]["album"] = item->GetVideoInfoTag()->m_strAlbum;
if (!item->GetVideoInfoTag()->m_artist.empty())
object["item"]["artist"] = StringUtils::Join(item->GetVideoInfoTag()->m_artist, " / ");
break;
}
}
}
else if (item->HasMusicInfoTag())
{
id = item->GetMusicInfoTag()->GetDatabaseId();
type = "song";
// TODO: Can be removed once this is properly handled when starting playback of a file
if (id <= 0 && !item->GetPath().empty() &&
(!item->HasProperty(LOOKUP_PROPERTY) || item->GetProperty(LOOKUP_PROPERTY).asBoolean()))
{
CMusicDatabase musicdatabase;
if (musicdatabase.Open())
{
CSong song;
if (musicdatabase.GetSongByFileName(item->GetPath(), song, item->m_lStartOffset))
{
item->GetMusicInfoTag()->SetSong(song);
id = item->GetMusicInfoTag()->GetDatabaseId();
}
musicdatabase.Close();
}
}
if (id <= 0)
{
// TODO: Can be removed once this is properly handled when starting playback of a file
item->SetProperty(LOOKUP_PROPERTY, false);
CStdString title = item->GetMusicInfoTag()->GetTitle();
if (title.IsEmpty())
title = item->GetLabel();
object["item"]["title"] = title;
if (item->GetMusicInfoTag()->GetTrackNumber() > 0)
object["item"]["track"] = item->GetMusicInfoTag()->GetTrackNumber();
if (!item->GetMusicInfoTag()->GetAlbum().empty())
object["item"]["album"] = item->GetMusicInfoTag()->GetAlbum();
if (!item->GetMusicInfoTag()->GetArtist().empty())
object["item"]["artist"] = item->GetMusicInfoTag()->GetArtist();
}
}
else if (item->HasPictureInfoTag())
{
type = "picture";
object["item"]["file"] = item->GetPath();
}
else
type = "unknown";
object["item"]["type"] = type;
if (id > 0)
object["item"]["id"] = id;
Announce(flag, sender, message, object);
}