本文整理汇总了C++中CFileItemPtr::IsParentFolder方法的典型用法代码示例。如果您正苦于以下问题:C++ CFileItemPtr::IsParentFolder方法的具体用法?C++ CFileItemPtr::IsParentFolder怎么用?C++ CFileItemPtr::IsParentFolder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFileItemPtr
的用法示例。
在下文中一共展示了CFileItemPtr::IsParentFolder方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetContextButtons
void CGUIWindowMusicBase::GetContextButtons(int itemNumber, CContextButtons &buttons)
{
CFileItemPtr item;
if (itemNumber >= 0 && itemNumber < m_vecItems->Size())
item = m_vecItems->Get(itemNumber);
if (item && !item->GetProperty("pluginreplacecontextitems").asBoolean())
{
if (item && !item->IsParentFolder())
{
if (item->CanQueue() && !item->IsAddonsPath())
{
buttons.Add(CONTEXT_BUTTON_QUEUE_ITEM, 13347); //queue
// allow a folder to be ad-hoc queued and played by the default player
if (item->m_bIsFolder || (item->IsPlayList() &&
!g_advancedSettings.m_playlistAsFolders))
{
buttons.Add(CONTEXT_BUTTON_PLAY_ITEM, 208); // Play
}
else
{ // check what players we have, if we have multiple display play with option
VECPLAYERCORES vecCores;
CPlayerCoreFactory::GetInstance().GetPlayers(*item, vecCores);
if (vecCores.size() >= 1)
buttons.Add(CONTEXT_BUTTON_PLAY_WITH, 15213); // Play With...
}
if (item->IsSmartPlayList())
{
buttons.Add(CONTEXT_BUTTON_PLAY_PARTYMODE, 15216); // Play in Partymode
}
if (item->IsSmartPlayList() || m_vecItems->IsSmartPlayList())
buttons.Add(CONTEXT_BUTTON_EDIT_SMART_PLAYLIST, 586);
else if (item->IsPlayList() || m_vecItems->IsPlayList())
buttons.Add(CONTEXT_BUTTON_EDIT, 586);
}
}
}
CGUIMediaWindow::GetContextButtons(itemNumber, buttons);
}
示例2: HasPlugins
bool CPluginDirectory::HasPlugins(const CStdString &type)
{
CStdString path = _P("U:\\plugins\\");
CUtil::AddFileToFolder(path, type, path);
CFileItemList items;
if (CDirectory::GetDirectory(path, items, "/", false))
{
for (int i = 0; i < items.Size(); i++)
{
CFileItemPtr item = items[i];
if (item->m_bIsFolder && !item->IsParentFolder() && !item->m_bIsShareOrDrive)
{
CStdString defaultPY;
CUtil::AddFileToFolder(item->m_strPath, "default.py", defaultPY);
if (XFILE::CFile::Exists(defaultPY))
return true;
}
}
}
return false;
}
示例3: GetDirectory
bool CGUIWindowScripts::GetDirectory(const CStdString& strDirectory, CFileItemList& items)
{
if (!CGUIMediaWindow::GetDirectory(strDirectory,items))
return false;
// flatten any folders
for (int i = 0; i < items.Size(); i++)
{
CFileItemPtr item = items[i];
if (item->m_bIsFolder && !item->IsParentFolder() && !item->m_bIsShareOrDrive && !item->GetLabel().Left(1).Equals("."))
{ // folder item - let's check for a default.py file, and flatten if we have one
CStdString defaultPY;
CUtil::AddFileToFolder(item->m_strPath, "default.py", defaultPY);
if (!CFile::Exists(defaultPY)) {
CUtil::AddFileToFolder(item->m_strPath, "Default.py", defaultPY);
if (!CFile::Exists(defaultPY)) {
CUtil::AddFileToFolder(item->m_strPath, "DEFAULT.PY", defaultPY);
}
}
if (CFile::Exists(defaultPY))
{ // yes, format the item up
item->m_strPath = defaultPY;
item->m_bIsFolder = false;
item->FillInDefaultIcon();
item->SetLabelPreformated(true);
}
}
if (item->GetLabel().Equals("autoexec.py") || (item->GetLabel().Left(1).Equals(".") && !item->IsParentFolder()))
{
items.Remove(i);
i--;
}
}
items.SetProgramThumbs();
return true;
}
示例4: GetContextButtons
void CGUIMediaWindow::GetContextButtons(int itemNumber, CContextButtons &buttons)
{
CFileItemPtr item = (itemNumber >= 0 && itemNumber < m_vecItems->Size()) ? m_vecItems->Get(itemNumber) : CFileItemPtr();
if (!item)
return;
// user added buttons
CStdString label;
CStdString action;
for (int i = CONTEXT_BUTTON_USER1; i <= CONTEXT_BUTTON_USER10; i++)
{
label.Format("contextmenulabel(%i)", i - CONTEXT_BUTTON_USER1);
if (item->GetProperty(label).empty())
break;
action.Format("contextmenuaction(%i)", i - CONTEXT_BUTTON_USER1);
if (item->GetProperty(action).empty())
break;
buttons.Add((CONTEXT_BUTTON)i, item->GetProperty(label).asString());
}
if (item->GetProperty("pluginreplacecontextitems").asBoolean())
return;
// TODO: FAVOURITES Conditions on masterlock and localisation
if (!item->IsParentFolder() && !item->GetPath().Equals("add") && !item->GetPath().Equals("newplaylist://") &&
!item->GetPath().Left(19).Equals("newsmartplaylist://") && !item->IsAddonsPath())
{
if (CFavourites::IsFavourite(item.get(), GetID()))
buttons.Add(CONTEXT_BUTTON_ADD_FAVOURITE, 14077); // Remove Favourite
else
buttons.Add(CONTEXT_BUTTON_ADD_FAVOURITE, 14076); // Add To Favourites;
}
}
示例5: 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())
//.........这里部分代码省略.........
示例6: OnPopupMenu
void CGUIWindowFileManager::OnPopupMenu(int list, int item, bool bContextDriven /* = true */)
{
if (list < 0 || list > 2) return ;
bool bDeselect = SelectItem(list, item);
// calculate the position for our menu
float posX = 200;
float posY = 100;
const CGUIControl *pList = GetControl(CONTROL_LEFT_LIST + list);
if (pList)
{
posX = pList->GetXPosition() + pList->GetWidth() / 2;
posY = pList->GetYPosition() + pList->GetHeight() / 2;
}
CFileItemPtr pItem = m_vecItems[list]->Get(item);
if (!pItem.get())
return;
if (m_Directory[list]->IsVirtualDirectoryRoot())
{
if (item < 0)
{ // TODO: We should add the option here for shares to be added if there aren't any
return ;
}
// and do the popup menu
if (CGUIDialogContextMenu::SourcesMenu("files", pItem, posX, posY))
{
m_rootDir.SetSources(g_settings.m_fileSources);
if (m_Directory[1 - list]->IsVirtualDirectoryRoot())
Refresh();
else
Refresh(list);
return ;
}
pItem->Select(false);
return ;
}
// popup the context menu
CGUIDialogContextMenu *pMenu = (CGUIDialogContextMenu *)m_gWindowManager.GetWindow(WINDOW_DIALOG_CONTEXT_MENU);
if (pMenu)
{
bool showEntry = false;
if (item >= m_vecItems[list]->Size()) item = -1;
if (item >= 0)
showEntry=(!pItem->IsParentFolder() || (pItem->IsParentFolder() && m_vecItems[list]->GetSelectedCount()>0));
// determine available players
VECPLAYERCORES vecCores;
CPlayerCoreFactory::GetPlayers(*pItem, vecCores);
// load our menu
pMenu->Initialize();
// add the needed buttons
int btn_SelectAll = pMenu->AddButton(188); // SelectAll
int btn_HandleFavourite; // Add/Remove Favourite
if (CFavourites::IsFavourite(pItem.get(), GetID()))
btn_HandleFavourite = pMenu->AddButton(14077);
else
btn_HandleFavourite = pMenu->AddButton(14076);
int btn_PlayUsing = pMenu->AddButton(15213); // Play Using ..
int btn_Rename = pMenu->AddButton(118); // Rename
int btn_Delete = pMenu->AddButton(117); // Delete
int btn_Copy = pMenu->AddButton(115); // Copy
int btn_Move = pMenu->AddButton(116); // Move
int btn_NewFolder = pMenu->AddButton(20309); // New Folder
int btn_Size = pMenu->AddButton(13393); // Calculate Size
int btn_Settings = pMenu->AddButton(5); // Settings
int btn_GoToRoot = pMenu->AddButton(20128); // Go To Root
int btn_Switch = pMenu->AddButton(523); // switch media
pMenu->EnableButton(btn_SelectAll, item >= 0);
pMenu->EnableButton(btn_HandleFavourite, item >=0 && !pItem->IsParentFolder());
pMenu->EnableButton(btn_PlayUsing, item >= 0 && vecCores.size() > 1);
pMenu->EnableButton(btn_Rename, item >= 0 && CanRename(list) && !pItem->IsParentFolder());
pMenu->EnableButton(btn_Delete, item >= 0 && CanDelete(list) && showEntry);
pMenu->EnableButton(btn_Copy, item >= 0 && CanCopy(list) && showEntry);
pMenu->EnableButton(btn_Move, item >= 0 && CanMove(list) && showEntry);
pMenu->EnableButton(btn_NewFolder, CanNewFolder(list));
pMenu->EnableButton(btn_Size, item >=0 && pItem->m_bIsFolder && !pItem->IsParentFolder());
// position it correctly
pMenu->OffsetPosition(posX, posY);
pMenu->DoModal();
int btnid = pMenu->GetButton();
if (btnid == btn_SelectAll)
{
OnSelectAll(list);
bDeselect=false;
}
if (btnid == btn_HandleFavourite)
{
CFavourites::AddOrRemove(pItem.get(), GetID());
return;
}
if (btnid == btn_PlayUsing)
{
VECPLAYERCORES vecCores;
//.........这里部分代码省略.........
示例7: Update
// \brief Set window to a specific directory
// \param strDirectory The directory to be displayed in list/thumb control
// This function calls OnPrepareFileItems() and OnFinalizeFileItems()
bool CGUIMediaWindow::Update(const CStdString &strDirectory)
{
// get selected item
int iItem = m_viewControl.GetSelectedItem();
CStdString strSelectedItem = "";
if (iItem >= 0 && iItem < m_vecItems->Size())
{
CFileItemPtr pItem = m_vecItems->Get(iItem);
if (!pItem->IsParentFolder())
{
GetDirectoryHistoryString(pItem.get(), strSelectedItem);
}
}
CStdString strOldDirectory = m_vecItems->m_strPath;
m_history.SetSelectedItem(strSelectedItem, strOldDirectory);
ClearFileItems();
m_vecItems->ClearProperties();
m_vecItems->SetThumbnailImage("");
if (!GetDirectory(strDirectory, *m_vecItems))
{
CLog::Log(LOGERROR,"CGUIMediaWindow::GetDirectory(%s) failed", strDirectory.c_str());
// if the directory is the same as the old directory, then we'll return
// false. Else, we assume we can get the previous directory
if (strDirectory.Equals(strOldDirectory))
return false;
// We assume, we can get the parent
// directory again, but we have to
// return false to be able to eg. show
// an error message.
CStdString strParentPath = m_history.GetParentPath();
m_history.RemoveParentPath();
Update(strParentPath);
return false;
}
// if we're getting the root source listing
// make sure the path history is clean
if (strDirectory.IsEmpty())
m_history.ClearPathHistory();
int iWindow = GetID();
bool bOkay = (iWindow == WINDOW_MUSIC_FILES || iWindow == WINDOW_VIDEO_FILES || iWindow == WINDOW_FILES || iWindow == WINDOW_PICTURES || iWindow == WINDOW_PROGRAMS);
if (strDirectory.IsEmpty() && bOkay && (m_vecItems->Size() == 0 || !m_guiState->DisableAddSourceButtons())) // add 'add source button'
{
CStdString strLabel = g_localizeStrings.Get(1026);
CFileItemPtr pItem(new CFileItem(strLabel));
pItem->m_strPath = "add";
pItem->SetThumbnailImage("DefaultAddSource.png");
pItem->SetLabel(strLabel);
pItem->SetLabelPreformated(true);
m_vecItems->Add(pItem);
}
m_iLastControl = GetFocusedControlID();
// Ask the derived class if it wants to load additional info
// for the fileitems like media info or additional
// filtering on the items, setting thumbs.
OnPrepareFileItems(*m_vecItems);
m_vecItems->FillInDefaultIcons();
m_guiState.reset(CGUIViewState::GetViewState(GetID(), *m_vecItems));
FormatAndSort(*m_vecItems);
// Ask the devived class if it wants to do custom list operations,
// eg. changing the label
OnFinalizeFileItems(*m_vecItems);
UpdateButtons();
m_viewControl.SetItems(*m_vecItems);
strSelectedItem = m_history.GetSelectedItem(m_vecItems->m_strPath);
bool bSelectedFound = false;
//int iSongInDirectory = -1;
for (int i = 0; i < m_vecItems->Size(); ++i)
{
CFileItemPtr pItem = m_vecItems->Get(i);
// Update selected item
if (!bSelectedFound)
{
CStdString strHistory;
GetDirectoryHistoryString(pItem.get(), strHistory);
if (strHistory == strSelectedItem)
{
m_viewControl.SetSelectedItem(i);
bSelectedFound = true;
}
}
}
//.........这里部分代码省略.........
示例8: GetContextButtons
void CGUIWindowVideoNav::GetContextButtons(int itemNumber, CContextButtons &buttons)
{
CFileItemPtr item;
if (itemNumber >= 0 && itemNumber < m_vecItems->Size())
item = m_vecItems->Get(itemNumber);
CGUIWindowVideoBase::GetContextButtons(itemNumber, buttons);
if (item && item->GetProperty("pluginreplacecontextitems").asBoolean())
return;
CVideoDatabaseDirectory dir;
NODE_TYPE node = dir.GetDirectoryChildType(m_vecItems->GetPath());
if (!item)
{
// nothing to do here
}
else if (m_vecItems->IsPath("sources://video/"))
{
// get the usual shares
CGUIDialogContextMenu::GetContextButtons("video", item, buttons);
// add scan button somewhere here
if (g_application.IsVideoScanning())
buttons.Add(CONTEXT_BUTTON_STOP_SCANNING, 13353); // Stop Scanning
if (!item->IsDVD() && item->GetPath() != "add" && !item->IsParentFolder() &&
(CProfilesManager::GetInstance().GetCurrentProfile().canWriteDatabases() || g_passwordManager.bMasterUser))
{
CVideoDatabase database;
database.Open();
ADDON::ScraperPtr info = database.GetScraperForPath(item->GetPath());
if (!item->IsLiveTV() && !item->IsPlugin() && !item->IsAddonsPath() && !URIUtils::IsUPnP(item->GetPath()))
{
if (info && info->Content() != CONTENT_NONE)
{
buttons.Add(CONTEXT_BUTTON_SET_CONTENT, 20442);
buttons.Add(CONTEXT_BUTTON_SCAN, 13349);
}
else
buttons.Add(CONTEXT_BUTTON_SET_CONTENT, 20333);
}
}
}
else
{
// are we in the playlists location?
bool inPlaylists = m_vecItems->IsPath(CUtil::VideoPlaylistsLocation()) ||
m_vecItems->IsPath("special://videoplaylists/");
if (item->HasVideoInfoTag() && !item->GetVideoInfoTag()->m_artist.empty())
{
CMusicDatabase database;
database.Open();
if (database.GetArtistByName(StringUtils::Join(item->GetVideoInfoTag()->m_artist, g_advancedSettings.m_videoItemSeparator)) > -1)
buttons.Add(CONTEXT_BUTTON_GO_TO_ARTIST, 20396);
}
if (item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_strAlbum.size() > 0)
{
CMusicDatabase database;
database.Open();
if (database.GetAlbumByName(item->GetVideoInfoTag()->m_strAlbum) > -1)
buttons.Add(CONTEXT_BUTTON_GO_TO_ALBUM, 20397);
}
if (item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_strAlbum.size() > 0 &&
item->GetVideoInfoTag()->m_artist.size() > 0 &&
item->GetVideoInfoTag()->m_strTitle.size() > 0)
{
CMusicDatabase database;
database.Open();
if (database.GetSongByArtistAndAlbumAndTitle(StringUtils::Join(item->GetVideoInfoTag()->m_artist, g_advancedSettings.m_videoItemSeparator),
item->GetVideoInfoTag()->m_strAlbum,
item->GetVideoInfoTag()->m_strTitle) > -1)
{
buttons.Add(CONTEXT_BUTTON_PLAY_OTHER, 20398);
}
}
if (!item->IsParentFolder())
{
ADDON::ScraperPtr info;
VIDEO::SScanSettings settings;
GetScraperForItem(item.get(), info, settings);
if (info && info->Content() == CONTENT_TVSHOWS)
buttons.Add(CONTEXT_BUTTON_INFO, item->m_bIsFolder ? 20351 : 20352);
else if (info && info->Content() == CONTENT_MUSICVIDEOS)
buttons.Add(CONTEXT_BUTTON_INFO,20393);
else if (info && info->Content() == CONTENT_MOVIES)
buttons.Add(CONTEXT_BUTTON_INFO, 13346);
// can we update the database?
if (CProfilesManager::GetInstance().GetCurrentProfile().canWriteDatabases() || g_passwordManager.bMasterUser)
{
if (!item->IsPlugin() && !item->IsScript() && !item->IsLiveTV() && !item->IsAddonsPath() &&
item->GetPath() != "sources://video/" &&
item->GetPath() != "special://videoplaylists/" &&
!StringUtils::StartsWith(item->GetPath(), "newsmartplaylist://") &&
!StringUtils::StartsWith(item->GetPath(), "newplaylist://") &&
!StringUtils::StartsWith(item->GetPath(), "newtag://"))
{
//.........这里部分代码省略.........
示例9: Update
bool CGUIWindowFileManager::Update(int iList, const std::string &strDirectory)
{
// get selected item
int iItem = GetSelectedItem(iList);
std::string strSelectedItem = "";
if (iItem >= 0 && iItem < (int)m_vecItems[iList]->Size())
{
CFileItemPtr pItem = m_vecItems[iList]->Get(iItem);
if (!pItem->IsParentFolder())
{
GetDirectoryHistoryString(pItem.get(), strSelectedItem);
m_history[iList].SetSelectedItem(strSelectedItem, m_Directory[iList]->GetPath());
}
}
std::string strOldDirectory=m_Directory[iList]->GetPath();
m_Directory[iList]->SetPath(strDirectory);
CFileItemList items;
if (!GetDirectory(iList, m_Directory[iList]->GetPath(), items))
{
if (strDirectory != strOldDirectory && GetDirectory(iList, strOldDirectory, items))
m_Directory[iList]->SetPath(strOldDirectory); // Fallback to old (previous) path)
else
Update(iList, ""); // Fallback to root
return false;
}
m_history[iList].SetSelectedItem(strSelectedItem, strOldDirectory);
ClearFileItems(iList);
m_vecItems[iList]->Append(items);
m_vecItems[iList]->SetPath(items.GetPath());
std::string strParentPath;
URIUtils::GetParentPath(strDirectory, strParentPath);
if (strDirectory.empty() && (m_vecItems[iList]->Size() == 0 || CSettings::GetInstance().GetBool(CSettings::SETTING_FILELISTS_SHOWADDSOURCEBUTTONS)))
{ // add 'add source button'
std::string strLabel = g_localizeStrings.Get(1026);
CFileItemPtr pItem(new CFileItem(strLabel));
pItem->SetPath("add");
pItem->SetIconImage("DefaultAddSource.png");
pItem->SetLabel(strLabel);
pItem->SetLabelPreformated(true);
pItem->m_bIsFolder = true;
pItem->SetSpecialSort(SortSpecialOnBottom);
m_vecItems[iList]->Add(pItem);
}
else if (items.IsEmpty() || CSettings::GetInstance().GetBool(CSettings::SETTING_FILELISTS_SHOWPARENTDIRITEMS))
{
CFileItemPtr pItem(new CFileItem(".."));
pItem->SetPath(m_rootDir.IsSource(strDirectory) ? "" : strParentPath);
pItem->m_bIsFolder = true;
pItem->m_bIsShareOrDrive = false;
m_vecItems[iList]->AddFront(pItem, 0);
}
m_strParentPath[iList] = (m_rootDir.IsSource(strDirectory) ? "" : strParentPath);
if (strDirectory.empty())
{
CFileItemPtr pItem(new CFileItem("special://profile/", true));
pItem->SetLabel(g_localizeStrings.Get(20070));
pItem->SetArt("thumb", "DefaultFolder.png");
pItem->SetLabelPreformated(true);
m_vecItems[iList]->Add(pItem);
}
// if we have a .tbn file, use itself as the thumb
for (int i = 0; i < (int)m_vecItems[iList]->Size(); i++)
{
CFileItemPtr pItem = m_vecItems[iList]->Get(i);
if (pItem->IsHD() &&
URIUtils::HasExtension(pItem->GetPath(), ".tbn"))
{
pItem->SetArt("thumb", pItem->GetPath());
}
}
m_vecItems[iList]->FillInDefaultIcons();
OnSort(iList);
UpdateButtons();
int item = 0;
strSelectedItem = m_history[iList].GetSelectedItem(m_Directory[iList]->GetPath());
for (int i = 0; i < m_vecItems[iList]->Size(); ++i)
{
CFileItemPtr pItem = m_vecItems[iList]->Get(i);
std::string strHistory;
GetDirectoryHistoryString(pItem.get(), strHistory);
if (strHistory == strSelectedItem)
{
item = i;
break;
}
}
UpdateControl(iList, item);
//.........这里部分代码省略.........
示例10: Update
// \brief Set window to a specific directory
// \param strDirectory The directory to be displayed in list/thumb control
// This function calls OnPrepareFileItems() and OnFinalizeFileItems()
bool CGUIMediaWindow::Update(const CStdString &strDirectory)
{
// TODO: OnInitWindow calls Update() before window path has been set properly.
if (strDirectory == "?")
return false;
// get selected item
int iItem = m_viewControl.GetSelectedItem();
CStdString strSelectedItem = "";
if (iItem >= 0 && iItem < m_vecItems->Size())
{
CFileItemPtr pItem = m_vecItems->Get(iItem);
if (!pItem->IsParentFolder())
{
GetDirectoryHistoryString(pItem.get(), strSelectedItem);
}
}
CStdString strOldDirectory = m_vecItems->GetPath();
m_history.SetSelectedItem(strSelectedItem, strOldDirectory);
CFileItemList items;
if (!GetDirectory(strDirectory, items))
{
CLog::Log(LOGERROR,"CGUIMediaWindow::GetDirectory(%s) failed", strDirectory.c_str());
// if the directory is the same as the old directory, then we'll return
// false. Else, we assume we can get the previous directory
if (strDirectory.Equals(strOldDirectory))
return false;
// We assume, we can get the parent
// directory again, but we have to
// return false to be able to eg. show
// an error message.
CStdString strParentPath = m_history.GetParentPath();
m_history.RemoveParentPath();
Update(strParentPath);
return false;
}
if (items.GetLabel().IsEmpty())
items.SetLabel(CUtil::GetTitleFromPath(items.GetPath(), true));
ClearFileItems();
m_vecItems->Copy(items);
// if we're getting the root source listing
// make sure the path history is clean
if (strDirectory.IsEmpty())
m_history.ClearPathHistory();
int iWindow = GetID();
int showLabel = 0;
if (strDirectory.IsEmpty() && (iWindow == WINDOW_MUSIC_FILES ||
iWindow == WINDOW_FILES ||
iWindow == WINDOW_PICTURES ||
iWindow == WINDOW_PROGRAMS))
showLabel = 1026;
if (strDirectory.Equals("sources://video/"))
showLabel = 999;
if (showLabel && (m_vecItems->Size() == 0 || !m_guiState->DisableAddSourceButtons())) // add 'add source button'
{
CStdString strLabel = g_localizeStrings.Get(showLabel);
CFileItemPtr pItem(new CFileItem(strLabel));
pItem->SetPath("add");
pItem->SetIconImage("DefaultAddSource.png");
pItem->SetLabel(strLabel);
pItem->SetLabelPreformated(true);
pItem->m_bIsFolder = true;
pItem->SetSpecialSort(SORT_ON_BOTTOM);
m_vecItems->Add(pItem);
}
m_iLastControl = GetFocusedControlID();
// Ask the derived class if it wants to load additional info
// for the fileitems like media info or additional
// filtering on the items, setting thumbs.
OnPrepareFileItems(*m_vecItems);
// The idea here is to ensure we have something to focus if our file list
// is empty. As such, this check MUST be last and ignore the hide parent
// fileitems settings.
if (m_vecItems->IsEmpty())
{
CFileItemPtr pItem(new CFileItem(".."));
pItem->SetPath(m_history.GetParentPath());
pItem->m_bIsFolder = true;
pItem->m_bIsShareOrDrive = false;
m_vecItems->AddFront(pItem, 0);
}
m_vecItems->FillInDefaultIcons();
m_guiState.reset(CGUIViewState::GetViewState(GetID(), *m_vecItems));
FormatAndSort(*m_vecItems);
//.........这里部分代码省略.........
示例11: GetContextButtons
void CGUIWindowMusicSongs::GetContextButtons(int itemNumber, CContextButtons &buttons)
{
CFileItemPtr item;
if (itemNumber >= 0 && itemNumber < m_vecItems->Size())
item = m_vecItems->Get(itemNumber);
if (item)
{
// are we in the playlists location?
bool inPlaylists = m_vecItems->GetPath().Equals(CUtil::MusicPlaylistsLocation()) ||
m_vecItems->GetPath().Equals("special://musicplaylists/");
if (m_vecItems->IsVirtualDirectoryRoot() || m_vecItems->GetPath() == "sources://music/")
{
// get the usual music shares, and anything for all media windows
CGUIDialogContextMenu::GetContextButtons("music", item, buttons);
#ifdef HAS_DVD_DRIVE
// enable Rip CD an audio disc
if (g_mediaManager.IsDiscInDrive() && item->IsCDDA())
{
// those cds can also include Audio Tracks: CDExtra and MixedMode!
CCdInfo *pCdInfo = g_mediaManager.GetCdInfo();
if (pCdInfo->IsAudio(1) || pCdInfo->IsCDExtra(1) || pCdInfo->IsMixedMode(1))
{
if (CJobManager::GetInstance().IsProcessing("cdrip"))
buttons.Add(CONTEXT_BUTTON_CANCEL_RIP_CD, 14100);
else
buttons.Add(CONTEXT_BUTTON_RIP_CD, 600);
}
}
#endif
CGUIMediaWindow::GetContextButtons(itemNumber, buttons);
}
else
{
CGUIWindowMusicBase::GetContextButtons(itemNumber, buttons);
if (item->GetProperty("pluginreplacecontextitems").asBoolean())
return;
if (!item->IsPlayList() && !item->IsPlugin() && !item->IsScript())
{
if (item->IsAudio())
buttons.Add(CONTEXT_BUTTON_SONG_INFO, 658); // Song Info
else if (!item->IsParentFolder() &&
!StringUtils::StartsWithNoCase(item->GetPath(), "new") && item->m_bIsFolder)
{
#if 0
if (m_musicdatabase.GetAlbumIdByPath(item->GetPath()) > -1)
#endif
buttons.Add(CONTEXT_BUTTON_INFO, 13351); // Album Info
}
}
#ifdef HAS_DVD_DRIVE
// enable Rip CD Audio or Track button if we have an audio disc
if (g_mediaManager.IsDiscInDrive() && m_vecItems->IsCDDA())
{
// those cds can also include Audio Tracks: CDExtra and MixedMode!
CCdInfo *pCdInfo = g_mediaManager.GetCdInfo();
if (pCdInfo->IsAudio(1) || pCdInfo->IsCDExtra(1) || pCdInfo->IsMixedMode(1))
buttons.Add(CONTEXT_BUTTON_RIP_TRACK, 610);
}
#endif
// enable CDDB lookup if the current dir is CDDA
if (g_mediaManager.IsDiscInDrive() && m_vecItems->IsCDDA() &&
(CProfilesManager::Get().GetCurrentProfile().canWriteDatabases() || g_passwordManager.bMasterUser))
{
buttons.Add(CONTEXT_BUTTON_CDDB, 16002);
}
if (!item->IsParentFolder() && !item->IsReadOnly())
{
// either we're at the playlist location or its been explicitly allowed
if (inPlaylists || CSettings::Get().GetBool("filelists.allowfiledeletion"))
{
buttons.Add(CONTEXT_BUTTON_DELETE, 117);
buttons.Add(CONTEXT_BUTTON_RENAME, 118);
}
}
}
// Add the scan button(s)
if (g_application.IsMusicScanning())
buttons.Add(CONTEXT_BUTTON_STOP_SCANNING, 13353); // Stop Scanning
else if (!inPlaylists && !m_vecItems->IsInternetStream() &&
!item->GetPath().Equals("add") && !item->IsParentFolder() &&
!item->IsPlugin() &&
!StringUtils::StartsWithNoCase(item->GetPath(), "addons://") &&
(CProfilesManager::Get().GetCurrentProfile().canWriteDatabases() || g_passwordManager.bMasterUser))
{
buttons.Add(CONTEXT_BUTTON_SCAN, 13352);
}
if (item->IsPlugin() || item->IsScript() || m_vecItems->IsPlugin())
buttons.Add(CONTEXT_BUTTON_PLUGIN_SETTINGS, 1045);
}
if (!m_vecItems->IsVirtualDirectoryRoot() && !m_vecItems->IsPlugin())
buttons.Add(CONTEXT_BUTTON_SWITCH_MEDIA, 523);
CGUIWindowMusicBase::GetNonContextButtons(buttons);
}
示例12: GetContextButtons
void CGUIWindowMusicNav::GetContextButtons(int itemNumber, CContextButtons &buttons)
{
CFileItemPtr item;
if (itemNumber >= 0 && itemNumber < m_vecItems->Size())
item = m_vecItems->Get(itemNumber);
if (item)
{
// are we in the playlists location?
bool inPlaylists = m_vecItems->IsPath(CUtil::MusicPlaylistsLocation()) ||
m_vecItems->IsPath("special://musicplaylists/");
if (m_vecItems->IsPath("sources://music/"))
{
// get the usual music shares, and anything for all media windows
CGUIDialogContextMenu::GetContextButtons("music", item, buttons);
#ifdef HAS_DVD_DRIVE
// enable Rip CD an audio disc
if (g_mediaManager.IsDiscInDrive() && item->IsCDDA())
{
// those cds can also include Audio Tracks: CDExtra and MixedMode!
MEDIA_DETECT::CCdInfo *pCdInfo = g_mediaManager.GetCdInfo();
if (pCdInfo->IsAudio(1) || pCdInfo->IsCDExtra(1) || pCdInfo->IsMixedMode(1))
{
if (CJobManager::GetInstance().IsProcessing("cdrip"))
buttons.Add(CONTEXT_BUTTON_CANCEL_RIP_CD, 14100);
else
buttons.Add(CONTEXT_BUTTON_RIP_CD, 600);
}
}
#endif
// Add the scan button(s)
if (g_application.IsMusicScanning())
buttons.Add(CONTEXT_BUTTON_STOP_SCANNING, 13353); // Stop Scanning
else if (!inPlaylists && !m_vecItems->IsInternetStream() &&
!item->IsPath("add") && !item->IsParentFolder() &&
!item->IsPlugin() &&
!StringUtils::StartsWithNoCase(item->GetPath(), "addons://") &&
(CProfilesManager::GetInstance().GetCurrentProfile().canWriteDatabases() || g_passwordManager.bMasterUser))
{
buttons.Add(CONTEXT_BUTTON_SCAN, 13352);
}
CGUIMediaWindow::GetContextButtons(itemNumber, buttons);
}
else
{
CGUIWindowMusicBase::GetContextButtons(itemNumber, buttons);
CMusicDatabaseDirectory dir;
// enable query all albums button only in album view
if (item->IsAlbum() && !dir.IsAllItem(item->GetPath()) &&
item->m_bIsFolder && !item->IsVideoDb() && !item->IsParentFolder() &&
!item->IsPlugin() && !StringUtils::StartsWithNoCase(item->GetPath(), "musicsearch://"))
{
buttons.Add(CONTEXT_BUTTON_INFO_ALL, 20059);
}
// enable query all artist button only in artist view
if (dir.IsArtistDir(item->GetPath()) && !dir.IsAllItem(item->GetPath()) &&
item->m_bIsFolder && !item->IsVideoDb())
{
ADDON::ScraperPtr info;
if(m_musicdatabase.GetScraperForPath(item->GetPath(), info, ADDON::ADDON_SCRAPER_ARTISTS))
{
if (info && info->Supports(CONTENT_ARTISTS))
buttons.Add(CONTEXT_BUTTON_INFO_ALL, 21884);
}
}
//Set default or clear default
NODE_TYPE nodetype = dir.GetDirectoryType(item->GetPath());
if (!item->IsParentFolder() && !inPlaylists &&
(nodetype == NODE_TYPE_ROOT ||
nodetype == NODE_TYPE_OVERVIEW ||
nodetype == NODE_TYPE_TOP100))
{
if (!item->IsPath(CSettings::GetInstance().GetString(CSettings::SETTING_MYMUSIC_DEFAULTLIBVIEW)))
buttons.Add(CONTEXT_BUTTON_SET_DEFAULT, 13335); // set default
if (!CSettings::GetInstance().GetString(CSettings::SETTING_MYMUSIC_DEFAULTLIBVIEW).empty())
buttons.Add(CONTEXT_BUTTON_CLEAR_DEFAULT, 13403); // clear default
}
NODE_TYPE childtype = dir.GetDirectoryChildType(item->GetPath());
if (childtype == NODE_TYPE_ALBUM ||
childtype == NODE_TYPE_ARTIST ||
nodetype == NODE_TYPE_GENRE ||
nodetype == NODE_TYPE_ALBUM ||
nodetype == NODE_TYPE_ALBUM_RECENTLY_ADDED ||
nodetype == NODE_TYPE_ALBUM_COMPILATIONS)
{
// we allow the user to set content for
// 1. general artist and album nodes
// 2. specific per genre
// 3. specific per artist
// 4. specific per album
buttons.Add(CONTEXT_BUTTON_SET_CONTENT, 20195);
}
if (item->HasMusicInfoTag() && !item->GetMusicInfoTag()->GetArtistString().empty())
{
CVideoDatabase database;
database.Open();
//.........这里部分代码省略.........
示例13: Update
void CGUIDialogFileBrowser::Update(const std::string &strDirectory)
{
const CURL pathToUrl(strDirectory);
if (m_browsingForImages && m_thumbLoader.IsLoading())
m_thumbLoader.StopThread();
// get selected item
int iItem = m_viewControl.GetSelectedItem();
std::string strSelectedItem;
if (iItem >= 0 && iItem < m_vecItems->Size())
{
CFileItemPtr pItem = (*m_vecItems)[iItem];
if (!pItem->IsParentFolder())
{
strSelectedItem = pItem->GetPath();
URIUtils::RemoveSlashAtEnd(strSelectedItem);
m_history.SetSelectedItem(strSelectedItem, m_Directory->GetPath().empty()?"empty":m_Directory->GetPath());
}
}
if (!m_singleList)
{
CFileItemList items;
std::string strParentPath;
if (!m_rootDir.GetDirectory(pathToUrl, items, m_useFileDirectories, false))
{
CLog::Log(LOGERROR,"CGUIDialogFileBrowser::GetDirectory(%s) failed", pathToUrl.GetRedacted().c_str());
// We assume, we can get the parent
// directory again
std::string strParentPath = m_history.GetParentPath();
m_history.RemoveParentPath();
Update(strParentPath);
return;
}
// check if current directory is a root share
if (!m_rootDir.IsSource(strDirectory))
{
if (URIUtils::GetParentPath(strDirectory, strParentPath))
{
CFileItemPtr pItem(new CFileItem(".."));
pItem->SetPath(strParentPath);
pItem->m_bIsFolder = true;
pItem->m_bIsShareOrDrive = false;
items.AddFront(pItem, 0);
}
}
else
{
// yes, this is the root of a share
// add parent path to the virtual directory
CFileItemPtr pItem(new CFileItem(".."));
pItem->SetPath("");
pItem->m_bIsShareOrDrive = false;
pItem->m_bIsFolder = true;
items.AddFront(pItem, 0);
strParentPath = "";
}
ClearFileItems();
m_vecItems->Copy(items);
m_Directory->SetPath(strDirectory);
m_strParentPath = strParentPath;
}
// if we're getting the root source listing
// make sure the path history is clean
if (strDirectory.empty())
m_history.ClearPathHistory();
// some evil stuff don't work with the '/' mask, e.g. shoutcast directory - make sure no files are in there
if (m_browsingForFolders)
{
for (int i=0;i<m_vecItems->Size();++i)
if (!(*m_vecItems)[i]->m_bIsFolder)
{
m_vecItems->Remove(i);
i--;
}
}
// No need to set thumbs
m_vecItems->FillInDefaultIcons();
OnSort();
if (m_Directory->GetPath().empty() && m_addNetworkShareEnabled &&
(CServiceBroker::GetSettingsComponent()->GetProfileManager()->GetMasterProfile().getLockMode() == LOCK_MODE_EVERYONE ||
CServiceBroker::GetSettingsComponent()->GetProfileManager()->IsMasterProfile() || g_passwordManager.bMasterUser))
{ // we are in the virtual directory - add the "Add Network Location" item
CFileItemPtr pItem(new CFileItem(g_localizeStrings.Get(1032)));
pItem->SetPath("net://");
pItem->m_bIsFolder = true;
m_vecItems->Add(pItem);
}
if (m_Directory->GetPath().empty() && !m_addSourceType.empty())
{
//.........这里部分代码省略.........
示例14: 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/(float)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;
}
示例15: Update
bool CGUIWindowFileManager::Update(int iList, const CStdString &strDirectory)
{
// get selected item
int iItem = GetSelectedItem(iList);
CStdString strSelectedItem = "";
if (iItem >= 0 && iItem < (int)m_vecItems[iList]->Size())
{
CFileItemPtr pItem = m_vecItems[iList]->Get(iItem);
if (!pItem->IsParentFolder())
{
GetDirectoryHistoryString(pItem.get(), strSelectedItem);
m_history[iList].SetSelectedItem(strSelectedItem, m_Directory[iList]->m_strPath);
}
}
CStdString strOldDirectory=m_Directory[iList]->m_strPath;
m_Directory[iList]->m_strPath = strDirectory;
CFileItemList items;
if (!GetDirectory(iList, m_Directory[iList]->m_strPath, items))
{
m_Directory[iList]->m_strPath = strOldDirectory;
return false;
}
m_history[iList].SetSelectedItem(strSelectedItem, strOldDirectory);
ClearFileItems(iList);
m_vecItems[iList]->Append(items);
m_vecItems[iList]->m_strPath = items.m_strPath;
if (strDirectory.IsEmpty() && (m_vecItems[iList]->Size() == 0 || !g_guiSettings.GetBool("filelists.disableaddsourcebuttons")))
{ // add 'add source button'
CStdString strLabel = g_localizeStrings.Get(1026);
CFileItemPtr pItem(new CFileItem(strLabel));
pItem->m_strPath = "add";
pItem->SetThumbnailImage("DefaultAddSource.png");
pItem->SetLabel(strLabel);
pItem->SetLabelPreformated(true);
m_vecItems[iList]->Add(pItem);
}
// if we have a .tbn file, use itself as the thumb
for (int i = 0; i < (int)m_vecItems[iList]->Size(); i++)
{
CFileItemPtr pItem = m_vecItems[iList]->Get(i);
CStdString strExtension;
CUtil::GetExtension(pItem->m_strPath, strExtension);
if (pItem->IsHD() && strExtension == ".tbn")
{
pItem->SetThumbnailImage(pItem->m_strPath);
}
}
m_vecItems[iList]->FillInDefaultIcons();
OnSort(iList);
UpdateButtons();
int item = 0;
strSelectedItem = m_history[iList].GetSelectedItem(m_Directory[iList]->m_strPath);
for (int i = 0; i < m_vecItems[iList]->Size(); ++i)
{
CFileItemPtr pItem = m_vecItems[iList]->Get(i);
CStdString strHistory;
GetDirectoryHistoryString(pItem.get(), strHistory);
if (strHistory == strSelectedItem)
{
item = i;
break;
}
}
UpdateControl(iList, item);
return true;
}