本文整理汇总了C++中CFileItemPtr::IsPath方法的典型用法代码示例。如果您正苦于以下问题:C++ CFileItemPtr::IsPath方法的具体用法?C++ CFileItemPtr::IsPath怎么用?C++ CFileItemPtr::IsPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFileItemPtr
的用法示例。
在下文中一共展示了CFileItemPtr::IsPath方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnClick
bool CGUIWindowAddonBrowser::OnClick(int iItem, const std::string &player)
{
CFileItemPtr item = m_vecItems->Get(iItem);
if (item->GetPath() == "addons://install/")
{
using namespace KODI::MESSAGING::HELPERS;
if (!CServiceBroker::GetSettings().GetBool(CSettings::SETTING_ADDONS_ALLOW_UNKNOWN_SOURCES))
{
if (ShowYesNoDialogText(13106, 36617, 186, 10004) == DialogResponse::YES)
g_windowManager.ActivateWindow(WINDOW_SETTINGS_SYSTEM, CSettings::SETTING_ADDONS_ALLOW_UNKNOWN_SOURCES);
}
else
{
// pop up filebrowser to grab an installed folder
VECSOURCES shares = *CMediaSourceSettings::GetInstance().GetSources("files");
g_mediaManager.GetLocalDrives(shares);
g_mediaManager.GetNetworkLocations(shares);
std::string path;
if (CGUIDialogFileBrowser::ShowAndGetFile(shares, "*.zip", g_localizeStrings.Get(24041), path))
{
CAddonInstaller::GetInstance().InstallFromZip(path);
}
}
return true;
}
if (item->GetPath() == "addons://update_all/")
{
UpdateAddons updater;
CGUIDialogBusy::Wait(&updater);
return true;
}
if (!item->m_bIsFolder)
{
// cancel a downloading job
if (item->HasProperty("Addon.Downloading"))
{
if (CGUIDialogYesNo::ShowAndGetInput(CVariant{24000}, item->GetProperty("Addon.Name"), CVariant{24066}, CVariant{""}))
{
if (CAddonInstaller::GetInstance().Cancel(item->GetProperty("Addon.ID").asString()))
Refresh();
}
return true;
}
CGUIDialogAddonInfo::ShowForItem(item);
return true;
}
if (item->IsPath("addons://search/"))
{
Update(item->GetPath());
return true;
}
return CGUIMediaWindow::OnClick(iItem, player);
}
示例2: Contains
bool CFileItemList::Contains(const std::string& fileName) const
{
CSingleLock lock(m_lock);
if (m_fastLookup)
return m_map.find(fileName) != m_map.end();
// slow method...
for (unsigned int i = 0; i < m_items.size(); i++)
{
const CFileItemPtr pItem = m_items[i];
if (pItem->IsPath(fileName))
return true;
}
return false;
}
示例3: OnClick
bool CGUIWindowAddonBrowser::OnClick(int iItem)
{
CFileItemPtr item = m_vecItems->Get(iItem);
if (item->GetPath() == "addons://install/")
{
// pop up filebrowser to grab an installed folder
VECSOURCES shares = *CMediaSourceSettings::Get().GetSources("files");
g_mediaManager.GetLocalDrives(shares);
g_mediaManager.GetNetworkLocations(shares);
CStdString path;
if (CGUIDialogFileBrowser::ShowAndGetFile(shares, "*.zip", g_localizeStrings.Get(24041), path))
CAddonInstaller::Get().InstallFromZip(path);
return true;
}
if (item->GetPath() == "addons://update_all/")
{
// fire off a threaded update of all addons
UpdateAddons updater;
if (CGUIDialogBusy::Wait(&updater))
return Update("addons://downloading/");
return true;
}
if (!item->m_bIsFolder)
{
// cancel a downloading job
if (item->HasProperty("Addon.Downloading"))
{
if (CGUIDialogYesNo::ShowAndGetInput(g_localizeStrings.Get(24000),
item->GetProperty("Addon.Name").asString(),
g_localizeStrings.Get(24066),""))
{
if (CAddonInstaller::Get().Cancel(item->GetProperty("Addon.ID").asString()))
Refresh();
}
return true;
}
CGUIDialogAddonInfo::ShowForItem(item);
return true;
}
if (item->IsPath("addons://search/"))
return Update(item->GetPath());
return CGUIMediaWindow::OnClick(iItem);
}
示例4: OnContextButton
bool CGUIWindowAddonBrowser::OnContextButton(int itemNumber,
CONTEXT_BUTTON button)
{
CFileItemPtr pItem = m_vecItems->Get(itemNumber);
if (pItem->IsPath("addons://enabled/"))
{
if (button == CONTEXT_BUTTON_SCAN)
{
CAddonMgr::Get().FindAddons();
return true;
}
}
AddonPtr addon;
if (!CAddonMgr::Get().GetAddon(pItem->GetProperty("Addon.ID").asString(), addon, ADDON_UNKNOWN, false)) // allow disabled addons
return false;
if (button == CONTEXT_BUTTON_SETTINGS)
return CGUIDialogAddonSettings::ShowAndGetInput(addon);
if (button == CONTEXT_BUTTON_REFRESH)
{
CAddonDatabase database;
database.Open();
database.DeleteRepository(addon->ID());
button = CONTEXT_BUTTON_SCAN;
}
if (button == CONTEXT_BUTTON_SCAN)
{
RepositoryPtr repo = boost::dynamic_pointer_cast<CRepository>(addon);
CAddonInstaller::Get().UpdateRepos(true);
return true;
}
if (button == CONTEXT_BUTTON_INFO)
{
CGUIDialogAddonInfo::ShowForItem(pItem);
return true;
}
return CGUIMediaWindow::OnContextButton(itemNumber, button);
}
示例5: OnSort
void CGUIWindowFileManager::OnSort(int iList)
{
using namespace KODI::PLATFORM::FILESYSTEM;
// always sort the list by label in ascending order
for (int i = 0; i < m_vecItems[iList]->Size(); i++)
{
CFileItemPtr pItem = m_vecItems[iList]->Get(i);
if (pItem->m_bIsFolder && (!pItem->m_dwSize || pItem->IsPath("add")))
pItem->SetLabel2("");
else
pItem->SetFileSizeLabel();
// Set free space on disc
if (pItem->m_bIsShareOrDrive)
{
if (pItem->IsHD())
{
std::error_code ec;
auto freeSpace = space(pItem->GetPath(), ec);
if (ec.value() == 0)
{
pItem->m_dwSize = freeSpace.free;
pItem->SetFileSizeLabel();
}
}
else if (pItem->IsDVD() && g_mediaManager.IsDiscInDrive())
{
std::error_code ec;
auto freeSpace = space(pItem->GetPath(), ec);
if (ec.value() == 0)
{
pItem->m_dwSize = freeSpace.capacity;
pItem->SetFileSizeLabel();
}
}
} // if (pItem->m_bIsShareOrDrive)
}
m_vecItems[iList]->Sort(SortByLabel, SortOrderAscending);
}
示例6: GetContextButtons
void CGUIWindowAddonBrowser::GetContextButtons(int itemNumber,
CContextButtons& buttons)
{
CFileItemPtr pItem = m_vecItems->Get(itemNumber);
if (!pItem->IsPath("addons://enabled/"))
buttons.Add(CONTEXT_BUTTON_SCAN,24034);
AddonPtr addon;
if (!CAddonMgr::Get().GetAddon(pItem->GetProperty("Addon.ID").asString(), addon, ADDON_UNKNOWN, false)) // allow disabled addons
return;
if (addon->Type() == ADDON_REPOSITORY && pItem->m_bIsFolder)
{
buttons.Add(CONTEXT_BUTTON_SCAN,24034);
buttons.Add(CONTEXT_BUTTON_REFRESH,24035);
}
buttons.Add(CONTEXT_BUTTON_INFO,24003);
if (addon->HasSettings())
buttons.Add(CONTEXT_BUTTON_SETTINGS,24020);
}
示例7: Get
const CFileItemPtr CFileItemList::Get(const std::string& strPath) const
{
CSingleLock lock(m_lock);
if (m_fastLookup)
{
map<std::string, CFileItemPtr>::const_iterator it=m_map.find(strPath);
if (it != m_map.end())
return it->second;
return CFileItemPtr();
}
// slow method...
for (unsigned int i = 0; i < m_items.size(); i++)
{
CFileItemPtr pItem = m_items[i];
if (pItem->IsPath(strPath))
return pItem;
}
return CFileItemPtr();
}
示例8: OnSort
void CGUIWindowFileManager::OnSort(int iList)
{
// always sort the list by label in ascending order
for (int i = 0; i < m_vecItems[iList]->Size(); i++)
{
CFileItemPtr pItem = m_vecItems[iList]->Get(i);
if (pItem->m_bIsFolder && (!pItem->m_dwSize || pItem->IsPath("add")))
pItem->SetLabel2("");
else
pItem->SetFileSizeLabel();
// Set free space on disc
if (pItem->m_bIsShareOrDrive)
{
if (pItem->IsHD())
{
ULARGE_INTEGER ulBytesFree;
if (GetDiskFreeSpaceEx(pItem->GetPath().c_str(), &ulBytesFree, NULL, NULL))
{
pItem->m_dwSize = ulBytesFree.QuadPart;
pItem->SetFileSizeLabel();
}
}
else if (pItem->IsDVD() && g_mediaManager.IsDiscInDrive())
{
ULARGE_INTEGER ulBytesTotal;
if (GetDiskFreeSpaceEx(pItem->GetPath().c_str(), NULL, &ulBytesTotal, NULL))
{
pItem->m_dwSize = ulBytesTotal.QuadPart;
pItem->SetFileSizeLabel();
}
}
} // if (pItem->m_bIsShareOrDrive)
}
m_vecItems[iList]->Sort(SortByLabel, SortOrderAscending);
}
示例9: OnClick
bool CGUIWindowAddonBrowser::OnClick(int iItem, const std::string &player)
{
CFileItemPtr item = m_vecItems->Get(iItem);
if (item->GetPath() == "addons://install/")
{
InstallFromZip();
return true;
}
if (item->GetPath() == "addons://update_all/")
{
UpdateAddons updater;
CGUIDialogBusy::Wait(&updater, 100, true);
return true;
}
if (!item->m_bIsFolder)
{
// cancel a downloading job
if (item->HasProperty("Addon.Downloading"))
{
if (CGUIDialogYesNo::ShowAndGetInput(CVariant{24000}, item->GetProperty("Addon.Name"), CVariant{24066}, CVariant{""}))
{
if (CAddonInstaller::GetInstance().Cancel(item->GetProperty("Addon.ID").asString()))
Refresh();
}
return true;
}
CGUIDialogAddonInfo::ShowForItem(item);
return true;
}
if (item->IsPath("addons://search/"))
{
Update(item->GetPath());
return true;
}
return CGUIMediaWindow::OnClick(iItem, player);
}
示例10: OnContextButton
//.........这里部分代码省略.........
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:
{
std::string strPath;
CVideoDatabase database;
database.Open();
strPath = StringUtils::Format("videodb://musicvideos/artists/%i/",
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_RENAME:
CGUIDialogVideoInfo::UpdateVideoItemTitle(item);
CUtil::DeleteVideoDatabaseDirectoryCache();
Refresh();
return true;
case CONTEXT_BUTTON_DELETE:
if (item->IsPlayList() || item->IsSmartPlayList())
{
item->m_bIsFolder = false;
CFileUtils::DeleteItem(item);
}
else
{
CGUIDialogVideoInfo::DeleteVideoItemFromDatabase(item);
CUtil::DeleteVideoDatabaseDirectoryCache();
}
Refresh();
return true;
case CONTEXT_BUTTON_SET_CONTENT:
{
ADDON::ScraperPtr scraper;
std::string path(item->GetPath());
CQueryParams params;
CDirectoryNode::GetDatabaseInfo(item->GetPath(), params);
CONTENT_TYPE content = CONTENT_ALBUMS;
if (params.GetAlbumId() != -1)
path = StringUtils::Format("musicdb://albums/%li/",params.GetAlbumId());
else if (params.GetArtistId() != -1)
{
path = StringUtils::Format("musicdb://artists/%li/",params.GetArtistId());
content = CONTENT_ARTISTS;
}
if (m_vecItems->IsPath("musicdb://genres/") || item->IsPath("musicdb://artists/"))
{
content = CONTENT_ARTISTS;
}
if (!m_musicdatabase.GetScraperForPath(path, scraper, ADDON::ScraperTypeFromContent(content)))
{
ADDON::AddonPtr defaultScraper;
if (ADDON::CAddonMgr::Get().GetDefault(ADDON::ScraperTypeFromContent(content), defaultScraper))
{
scraper = std::dynamic_pointer_cast<ADDON::CScraper>(defaultScraper->Clone());
}
}
if (CGUIDialogContentSettings::Show(scraper, content))
{
m_musicdatabase.SetScraperForPath(path,scraper);
if (CGUIDialogYesNo::ShowAndGetInput(20442,20443,20444,20022))
{
OnInfoAll(itemNumber,true,true);
}
}
return true;
}
default:
break;
}
return CGUIWindowMusicBase::OnContextButton(itemNumber, button);
}
示例11: GetContextButtons
void CGUIWindowMusicNav::GetContextButtons(int itemNumber, CContextButtons &buttons)
{
CGUIWindowMusicBase::GetContextButtons(itemNumber, buttons);
CFileItemPtr item;
if (itemNumber >= 0 && itemNumber < m_vecItems->Size())
item = m_vecItems->Get(itemNumber);
if (item && !StringUtils::StartsWithNoCase(item->GetPath(), "addons://more/"))
{
// are we in the playlists location?
bool inPlaylists = m_vecItems->IsPath(CUtil::MusicPlaylistsLocation()) ||
m_vecItems->IsPath("special://musicplaylists/");
CMusicDatabaseDirectory dir;
// enable music info button on an album or on a song.
if (item->IsAudio() && !item->IsPlayList() && !item->IsSmartPlayList() &&
!item->m_bIsFolder)
{
buttons.Add(CONTEXT_BUTTON_SONG_INFO, 658);
}
else if (item->IsVideoDb())
{
if (!item->m_bIsFolder) // music video
buttons.Add(CONTEXT_BUTTON_INFO, 20393);
if (StringUtils::StartsWithNoCase(item->GetPath(), "videodb://musicvideos/artists/") && item->m_bIsFolder)
{
long idArtist = m_musicdatabase.GetArtistByName(m_vecItems->Get(itemNumber)->GetLabel());
if (idArtist > - 1)
buttons.Add(CONTEXT_BUTTON_INFO,21891);
}
}
else if (!inPlaylists && (dir.HasAlbumInfo(item->GetPath())||
dir.IsArtistDir(item->GetPath()) ) &&
!dir.IsAllItem(item->GetPath()) && !item->IsParentFolder() &&
!item->IsPlugin() && !item->IsScript() &&
!StringUtils::StartsWithNoCase(item->GetPath(), "musicsearch://"))
{
if (dir.IsArtistDir(item->GetPath()))
buttons.Add(CONTEXT_BUTTON_INFO, 21891);
else
buttons.Add(CONTEXT_BUTTON_INFO, 13351);
}
// enable query all albums button only in album view
if (dir.HasAlbumInfo(item->GetPath()) && !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 album view
if (dir.IsArtistDir(item->GetPath()) && !dir.IsAllItem(item->GetPath()) &&
item->m_bIsFolder && !item->IsVideoDb())
{
ADDON::ScraperPtr info;
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::Get().GetString("mymusic.defaultlibview")))
buttons.Add(CONTEXT_BUTTON_SET_DEFAULT, 13335); // set default
if (!CSettings::Get().GetString("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()->GetArtist().size() > 0)
{
CVideoDatabase database;
database.Open();
if (database.GetMatchingMusicVideo(StringUtils::Join(item->GetMusicInfoTag()->GetArtist(), g_advancedSettings.m_musicItemSeparator)) > -1)
buttons.Add(CONTEXT_BUTTON_GO_TO_ARTIST, 20400);
}
if (item->HasMusicInfoTag() && item->GetMusicInfoTag()->GetArtist().size() > 0 &&
item->GetMusicInfoTag()->GetAlbum().size() > 0 &&
item->GetMusicInfoTag()->GetTitle().size() > 0)
{
CVideoDatabase database;
//.........这里部分代码省略.........
示例12: 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 (!m_vecItems->IsPlugin() && (item->IsPlugin() || item->IsScript()))
buttons.Add(CONTEXT_BUTTON_INFO,24003); // Add-on info
if (item->CanQueue() && !item->IsAddonsPath() && !item->IsScript())
{
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);
}
// Add the scan button(s)
if (g_application.IsMusicScanning())
buttons.Add(CONTEXT_BUTTON_STOP_SCANNING, 13353); // Stop Scanning
else if (!m_vecItems->IsMusicDb() && !m_vecItems->IsInternetStream() &&
!item->IsPath("add") && !item->IsParentFolder() &&
!item->IsPlugin() && !item->IsMusicDb() &&
!item->IsLibraryFolder() &&
!StringUtils::StartsWithNoCase(item->GetPath(), "addons://") &&
(CProfilesManager::GetInstance().GetCurrentProfile().canWriteDatabases() || g_passwordManager.bMasterUser))
{
buttons.Add(CONTEXT_BUTTON_SCAN, 13352);
}
#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!
MEDIA_DETECT::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::GetInstance().GetCurrentProfile().canWriteDatabases() || g_passwordManager.bMasterUser))
{
buttons.Add(CONTEXT_BUTTON_CDDB, 16002);
}
}
CGUIMediaWindow::GetContextButtons(itemNumber, buttons);
}
示例13: 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();
//.........这里部分代码省略.........
示例14: 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->IsPath(CUtil::MusicPlaylistsLocation()) ||
m_vecItems->IsPath("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 (m_musicdatabase.GetAlbumIdByPath(item->GetPath()) > -1)
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(CSettings::SETTING_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->IsPath("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);
CContextMenuManager::Get().AddVisibleItems(item, buttons);
}