当前位置: 首页>>代码示例>>C++>>正文


C++ CFileItemPtr::GetPath方法代码示例

本文整理汇总了C++中CFileItemPtr::GetPath方法的典型用法代码示例。如果您正苦于以下问题:C++ CFileItemPtr::GetPath方法的具体用法?C++ CFileItemPtr::GetPath怎么用?C++ CFileItemPtr::GetPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CFileItemPtr的用法示例。


在下文中一共展示了CFileItemPtr::GetPath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: DoScan

bool CMusicInfoScanner::DoScan(const CStdString& strDirectory)
{
  if (m_handle)
    m_handle->SetText(Prettify(strDirectory));

  std::set<std::string>::const_iterator it = m_seenPaths.find(strDirectory);
  if (it != m_seenPaths.end())
    return true;

  m_seenPaths.insert(strDirectory);

  // Discard all excluded files defined by m_musicExcludeRegExps
  vector<string> regexps = g_advancedSettings.m_audioExcludeFromScanRegExps;
  if (CUtil::ExcludeFileOrFolder(strDirectory, regexps))
    return true;

  // load subfolder
  CFileItemList items;
  CDirectory::GetDirectory(strDirectory, items, g_advancedSettings.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(SortByLabel, 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.empty())
      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(SortByLabel, SortOrderAscending);

    // and then scan in the new information
    if (RetrieveMusicInfo(strDirectory, items) > 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;
}
开发者ID:Avbrella,项目名称:xbmc,代码行数:84,代码来源:MusicInfoScanner.cpp

示例2: OnSettingAction

void CPeripherals::OnSettingAction(const CSetting *setting)
{
  if (setting == nullptr)
    return;

  const std::string &settingId = setting->GetId();
  if (settingId == CSettings::SETTING_INPUT_PERIPHERALS)
  {
    CGUIDialogSelect* pDialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT);

    CFileItemList items;
    GetDirectory("peripherals://all/", items);

    int iPos = -1;
    do
    {
      pDialog->Reset();
      pDialog->SetHeading(CVariant{35000});
      pDialog->SetUseDetails(true);
      pDialog->SetItems(items);
      pDialog->SetSelected(iPos);
      pDialog->Open();

      iPos = pDialog->IsConfirmed() ? pDialog->GetSelectedItem() : -1;

      if (iPos >= 0)
      {
        CFileItemPtr pItem = items.Get(iPos);

        // show an error if the peripheral doesn't have any settings
        PeripheralPtr peripheral = GetByPath(pItem->GetPath());
        if (!peripheral || peripheral->GetSettings().empty())
        {
          CGUIDialogOK::ShowAndGetInput(CVariant{35000}, CVariant{35004});
          continue;
        }

        CGUIDialogPeripheralSettings *pSettingsDialog = (CGUIDialogPeripheralSettings *)g_windowManager.GetWindow(WINDOW_DIALOG_PERIPHERAL_SETTINGS);
        if (pItem && pSettingsDialog)
        {
          // pass peripheral item properties to settings dialog so skin authors
          // can use it to show more detailed information about the device
          pSettingsDialog->SetProperty("vendor", pItem->GetProperty("vendor"));
          pSettingsDialog->SetProperty("product", pItem->GetProperty("product"));
          pSettingsDialog->SetProperty("bus", pItem->GetProperty("bus"));
          pSettingsDialog->SetProperty("location", pItem->GetProperty("location"));
          pSettingsDialog->SetProperty("class", pItem->GetProperty("class"));
          pSettingsDialog->SetProperty("version", pItem->GetProperty("version"));

          // open settings dialog
          pSettingsDialog->SetFileItem(pItem.get());
          pSettingsDialog->Open();
        }
      }
    } while (pDialog->IsConfirmed());
  }
  else if (settingId == CSettings::SETTING_INPUT_CONTROLLERCONFIG)
    g_windowManager.ActivateWindow(WINDOW_DIALOG_GAME_CONTROLLERS);
  else if (settingId == CSettings::SETTING_INPUT_TESTRUMBLE)
    TestFeature(FEATURE_RUMBLE);
}
开发者ID:IchabodFletchman,项目名称:xbmc,代码行数:61,代码来源:Peripherals.cpp

示例3: Run

void CBackgroundInfoLoader::Run()
{
  try
  {
    if (!m_vecItems.empty())
    {
      OnLoaderStart();

      // Stage 1: All "fast" stuff we have already cached
      for (std::vector<CFileItemPtr>::const_iterator iter = m_vecItems.begin(); iter != m_vecItems.end(); ++iter)
      {
        CFileItemPtr pItem = *iter;

        // Ask the callback if we should abort
        if ((m_pProgressCallback && m_pProgressCallback->Abort()) || m_bStop)
          break;

        try
        {
          if (LoadItemCached(pItem.get()) && m_pObserver)
            m_pObserver->OnItemLoaded(pItem.get());
        }
        catch (...)
        {
          CLog::Log(LOGERROR, "CBackgroundInfoLoader::LoadItemCached - Unhandled exception for item %s", CURL::GetRedacted(pItem->GetPath()).c_str());
        }
      }

      // Stage 2: All "slow" stuff that we need to lookup
      for (std::vector<CFileItemPtr>::const_iterator iter = m_vecItems.begin(); iter != m_vecItems.end(); ++iter)
      {
        CFileItemPtr pItem = *iter;

        // Ask the callback if we should abort
        if ((m_pProgressCallback && m_pProgressCallback->Abort()) || m_bStop)
          break;

        try
        {
          if (LoadItemLookup(pItem.get()) && m_pObserver)
            m_pObserver->OnItemLoaded(pItem.get());
        }
        catch (...)
        {
          CLog::Log(LOGERROR, "CBackgroundInfoLoader::LoadItemLookup - Unhandled exception for item %s", CURL::GetRedacted(pItem->GetPath()).c_str());
        }
      }
    }

    OnLoaderFinish();
    m_bIsLoading = false;
  }
  catch (...)
  {
    m_bIsLoading = false;
    CLog::Log(LOGERROR, "%s - Unhandled exception", __FUNCTION__);
  }
}
开发者ID:0xheart0,项目名称:xbmc,代码行数:58,代码来源:BackgroundInfoLoader.cpp

示例4: AddItemToPlayList

/// \brief Add unique file and folders and its subfolders to playlist
/// \param pItem The file item to add
void CGUIWindowMusicBase::AddItemToPlayList(const CFileItemPtr &pItem, CFileItemList &queuedItems)
{
  if (!pItem->CanQueue() || pItem->IsRAR() || pItem->IsZIP() || pItem->IsParentFolder()) // no zip/rar enques thank you!
    return;

  // fast lookup is needed here
  queuedItems.SetFastLookup(true);

  if (pItem->IsMusicDb() && pItem->m_bIsFolder && !pItem->IsParentFolder())
  { // we have a music database folder, just grab the "all" item underneath it
    CMusicDatabaseDirectory dir;
    if (!dir.ContainsSongs(pItem->GetPath()))
    { // grab the ALL item in this category
      // Genres will still require 2 lookups, and queuing the entire Genre folder
      // will require 3 lookups (genre, artist, album)
      CFileItemPtr item(new CFileItem(pItem->GetPath() + "-1/", true));
      item->SetCanQueue(true); // workaround for CanQueue() check above
      AddItemToPlayList(item, queuedItems);
      return;
    }
  }
  if (pItem->m_bIsFolder || (g_windowManager.GetActiveWindow() == WINDOW_MUSIC_NAV && pItem->IsPlayList()))
  {
    // Check if we add a locked share
    if ( pItem->m_bIsShareOrDrive )
    {
      CFileItem item = *pItem;
      if ( !g_passwordManager.IsItemUnlocked( &item, "music" ) )
        return ;
    }

    // recursive
    CFileItemList items;
    GetDirectory(pItem->GetPath(), items);
    //OnRetrieveMusicInfo(items);
    FormatAndSort(items);
    SetupFanart(items);
    for (int i = 0; i < items.Size(); ++i)
      AddItemToPlayList(items[i], queuedItems);
  }
  else
  {
    if (pItem->IsPlayList())
    {
      auto_ptr<CPlayList> pPlayList (CPlayListFactory::Create(*pItem));
      if (pPlayList.get())
      {
        // load it
        if (!pPlayList->Load(pItem->GetPath()))
        {
          CGUIDialogOK::ShowAndGetInput(6, 0, 477, 0);
          return; //hmmm unable to load playlist?
        }

        CPlayList playlist = *pPlayList;
        for (int i = 0; i < (int)playlist.size(); ++i)
        {
          AddItemToPlayList(playlist[i], queuedItems);
        }
        return;
      }
    }
    else if(pItem->IsInternetStream())
    { // just queue the internet stream, it will be expanded on play
      queuedItems.Add(pItem);
    }
    else if (pItem->IsPlugin() && pItem->GetProperty("isplayable") == "true")
    {
      // python files can be played
      queuedItems.Add(pItem);
    }
    else if (!pItem->IsNFO() && pItem->IsAudio())
    {
      CFileItemPtr itemCheck = queuedItems.Get(pItem->GetPath());
      if (!itemCheck || itemCheck->m_lStartOffset != pItem->m_lStartOffset)
      { // add item
        CFileItemPtr item(new CFileItem(*pItem));
        m_musicdatabase.SetPropertiesForFileItem(*item);
        queuedItems.Add(item);
      }
    }
  }
}
开发者ID:AWilco,项目名称:xbmc,代码行数:85,代码来源:GUIWindowMusicBase.cpp

示例5: OnContextButton

bool CGUIDialogContextMenu::OnContextButton(const std::string &type, const CFileItemPtr& item, CONTEXT_BUTTON button)
{
  // Add Source doesn't require a valid share
  if (button == CONTEXT_BUTTON_ADD_SOURCE)
  {
    if (CProfilesManager::Get().IsMasterProfile())
    {
      if (!g_passwordManager.IsMasterLockUnlocked(true))
        return false;
    }
    else if (!CProfilesManager::Get().GetCurrentProfile().canWriteSources() && !g_passwordManager.IsProfileLockUnlocked())
      return false;

    return CGUIDialogMediaSource::ShowAndAddMediaSource(type);
  }

  // buttons that are available on both sources and autosourced items
  if (!item) return false;

  switch (button)
  {
  case CONTEXT_BUTTON_EJECT_DRIVE:
    return g_mediaManager.Eject(item->GetPath());

#ifdef HAS_DVD_DRIVE
  case CONTEXT_BUTTON_PLAY_DISC:
    return MEDIA_DETECT::CAutorun::PlayDisc(item->GetPath(), true, true); // restart

  case CONTEXT_BUTTON_RESUME_DISC:
    return MEDIA_DETECT::CAutorun::PlayDisc(item->GetPath(), true, false); // resume

  case CONTEXT_BUTTON_EJECT_DISC:
    g_mediaManager.ToggleTray(g_mediaManager.TranslateDevicePath(item->GetPath())[0]);
#endif
    return true;
  default:
    break;
  }

  // the rest of the operations require a valid share
  CMediaSource *share = GetShare(type, item.get());
  if (!share) return false;
  switch (button)
  {
  case CONTEXT_BUTTON_EDIT_SOURCE:
    if (CProfilesManager::Get().IsMasterProfile())
    {
      if (!g_passwordManager.IsMasterLockUnlocked(true))
        return false;
    }
    else if (!g_passwordManager.IsProfileLockUnlocked())
      return false;

    return CGUIDialogMediaSource::ShowAndEditMediaSource(type, *share);

  case CONTEXT_BUTTON_REMOVE_SOURCE:
  {
    if (CProfilesManager::Get().IsMasterProfile())
    {
      if (!g_passwordManager.IsMasterLockUnlocked(true))
        return false;
    }
    else
    {
      if (!CProfilesManager::Get().GetCurrentProfile().canWriteSources() && !g_passwordManager.IsMasterLockUnlocked(false))
        return false;
      if (CProfilesManager::Get().GetCurrentProfile().canWriteSources() && !g_passwordManager.IsProfileLockUnlocked())
        return false;
    }
    // prompt user if they want to really delete the source
    if (!CGUIDialogYesNo::ShowAndGetInput(CVariant{751}, CVariant{750}))
      return false;

    // check default before we delete, as deletion will kill the share object
    std::string defaultSource(GetDefaultShareNameByType(type));
    if (!defaultSource.empty())
    {
      if (share->strName == defaultSource)
        ClearDefault(type);
    }
    CMediaSourceSettings::Get().DeleteSource(type, share->strName, share->strPath);
    return true;
  }
  case CONTEXT_BUTTON_SET_DEFAULT:
    if (CProfilesManager::Get().GetCurrentProfile().canWriteSources() && !g_passwordManager.IsProfileLockUnlocked())
      return false;
    else if (!g_passwordManager.IsMasterLockUnlocked(true))
      return false;

    // make share default
    SetDefault(type, share->strName);
    return true;

  case CONTEXT_BUTTON_CLEAR_DEFAULT:
    if (CProfilesManager::Get().GetCurrentProfile().canWriteSources() && !g_passwordManager.IsProfileLockUnlocked())
      return false;
    else if (!g_passwordManager.IsMasterLockUnlocked(true))
      return false;
    // remove share default
    ClearDefault(type);
//.........这里部分代码省略.........
开发者ID:gellis12,项目名称:xbmc,代码行数:101,代码来源:GUIDialogContextMenu.cpp

示例6: GetContextButtons

void CGUIWindowMusicBase::GetContextButtons(int itemNumber, CContextButtons &buttons)
{
  CFileItemPtr item;
  if (itemNumber >= 0 && itemNumber < m_vecItems->Size())
    item = m_vecItems->Get(itemNumber);

  if (item)
  {
    if (item && !item->IsParentFolder())
    {
      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
          std::vector<std::string> players;
          CPlayerCoreFactory::GetInstance().GetPlayers(*item, players);
          if (players.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);
      }
      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);
}
开发者ID:jtrensberger,项目名称:xbmc,代码行数:67,代码来源:GUIWindowMusicBase.cpp

示例7: OnContextButton

bool CGUIWindowMusicBase::OnContextButton(int itemNumber, CONTEXT_BUTTON button)
{
  CFileItemPtr item;
  if (itemNumber >= 0 && itemNumber < m_vecItems->Size())
    item = m_vecItems->Get(itemNumber);

  if (CGUIDialogContextMenu::OnContextButton("music", item, button))
  {
    if (button == CONTEXT_BUTTON_REMOVE_SOURCE)
      OnRemoveSource(itemNumber);

    Update(m_vecItems->GetPath());
    return true;
  }

  switch (button)
  {
  case CONTEXT_BUTTON_QUEUE_ITEM:
    OnQueueItem(itemNumber);
    return true;

  case CONTEXT_BUTTON_INFO:
    OnItemInfo(itemNumber);
    return true;

  case CONTEXT_BUTTON_EDIT:
    {
      std::string playlist = item->IsPlayList() ? item->GetPath() : m_vecItems->GetPath(); // save path as activatewindow will destroy our items
      g_windowManager.ActivateWindow(WINDOW_MUSIC_PLAYLIST_EDITOR, playlist);
      // need to update
      m_vecItems->RemoveDiscCache(GetID());
      return true;
    }

  case CONTEXT_BUTTON_EDIT_SMART_PLAYLIST:
    {
      std::string playlist = item->IsSmartPlayList() ? item->GetPath() : m_vecItems->GetPath(); // save path as activatewindow will destroy our items
      if (CGUIDialogSmartPlaylistEditor::EditPlaylist(playlist, "music"))
        Refresh(true); // need to update
      return true;
    }

  case CONTEXT_BUTTON_PLAY_ITEM:
    PlayItem(itemNumber);
    return true;

  case CONTEXT_BUTTON_PLAY_WITH:
    {
      std::vector<std::string> players;
      CPlayerCoreFactory::GetInstance().GetPlayers(*item, players);
      std::string player = CPlayerCoreFactory::GetInstance().SelectPlayerDialog(players);
      if (!player.empty())
        OnClick(itemNumber, player);
      return true;
    }

  case CONTEXT_BUTTON_PLAY_PARTYMODE:
    g_partyModeManager.Enable(PARTYMODECONTEXT_MUSIC, item->GetPath());
    return true;

  case CONTEXT_BUTTON_ACTIVE_ADSP_SETTINGS:
    g_windowManager.ActivateWindow(WINDOW_DIALOG_AUDIO_DSP_OSD_SETTINGS);
    return true;

  case CONTEXT_BUTTON_RIP_CD:
    OnRipCD();
    return true;

#ifdef HAS_CDDA_RIPPER
  case CONTEXT_BUTTON_CANCEL_RIP_CD:
    CCDDARipper::GetInstance().CancelJobs();
    return true;
#endif

  case CONTEXT_BUTTON_RIP_TRACK:
    OnRipTrack(itemNumber);
    return true;

  case CONTEXT_BUTTON_SCAN:
    OnScan(itemNumber);
    return true;

  case CONTEXT_BUTTON_CDDB:
    if (m_musicdatabase.LookupCDDBInfo(true))
      Refresh();
    return true;

  default:
    break;
  }

  return CGUIMediaWindow::OnContextButton(itemNumber, button);
}
开发者ID:jtrensberger,项目名称:xbmc,代码行数:93,代码来源:GUIWindowMusicBase.cpp

示例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->GetPath().Equals("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::Get().GetCurrentProfile().canWriteDatabases() || g_passwordManager.bMasterUser))
        {
            CVideoDatabase database;
            database.Open();
            ADDON::ScraperPtr info = database.GetScraperForPath(item->GetPath());

            if (!g_application.IsVideoScanning())
            {
                if (!item->IsLiveTV() && !item->IsPlugin() && !item->IsAddonsPath() && !URIUtils::IsUPnP(item->GetPath()))
                {
                    if (info && info->Content() != CONTENT_NONE)
                        buttons.Add(CONTEXT_BUTTON_SET_CONTENT, 20442);
                    else
                        buttons.Add(CONTEXT_BUTTON_SET_CONTENT, 20333);
                }
            }

            if (info && !g_application.IsVideoScanning())
                buttons.Add(CONTEXT_BUTTON_SCAN, 13349);
        }
    }
    else
    {
        // are we in the playlists location?
        bool inPlaylists = m_vecItems->GetPath().Equals(CUtil::VideoPlaylistsLocation()) ||
                           m_vecItems->GetPath().Equals("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::Get().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://") &&
//.........这里部分代码省略.........
开发者ID:Rubber1Duck,项目名称:xbmc,代码行数:101,代码来源:GUIWindowVideoNav.cpp

示例9: OnContextButton

bool CGUIWindowVideoNav::OnContextButton(int itemNumber, CONTEXT_BUTTON button)
{
    CFileItemPtr item;
    if (itemNumber >= 0 && itemNumber < m_vecItems->Size())
        item = m_vecItems->Get(itemNumber);
    if (CGUIDialogContextMenu::OnContextButton("video", item, button))
    {
        //TODO should we search DB for entries from plugins?
        if (button == CONTEXT_BUTTON_REMOVE_SOURCE && !item->IsPlugin()
                && !item->IsLiveTV() &&!item->IsRSS() && !URIUtils::IsUPnP(item->GetPath()))
        {
            OnUnAssignContent(item->GetPath(),20375,20340,20341);
        }
        Refresh();
        return true;
    }
    switch (button)
    {
    case CONTEXT_BUTTON_EDIT:
    {
        CONTEXT_BUTTON ret = (CONTEXT_BUTTON)CGUIDialogVideoInfo::ManageVideoItem(item);
        if (ret >= 0)
        {
            if (ret == CONTEXT_BUTTON_MARK_WATCHED)
                m_viewControl.SetSelectedItem(itemNumber + 1);

            Refresh(true);
        }
        return true;
    }

    case CONTEXT_BUTTON_SET_SEASON_ART:
    case CONTEXT_BUTTON_SET_ACTOR_THUMB:
    case CONTEXT_BUTTON_SET_ARTIST_THUMB:
    {
        std::string type = "season";
        if (button == CONTEXT_BUTTON_SET_ACTOR_THUMB)
            type = "actor";
        else if (button == CONTEXT_BUTTON_SET_ARTIST_THUMB)
            type = "artist";

        bool result = CGUIDialogVideoInfo::ManageVideoItemArtwork(m_vecItems->Get(itemNumber), type);
        Refresh();

        return result;
    }
    case CONTEXT_BUTTON_GO_TO_ARTIST:
    {
        CStdString strPath;
        CMusicDatabase database;
        database.Open();
        strPath = StringUtils::Format("musicdb://artists/%ld/",
                                      database.GetArtistByName(StringUtils::Join(m_vecItems->Get(itemNumber)->GetVideoInfoTag()->m_artist, g_advancedSettings.m_videoItemSeparator)));
        g_windowManager.ActivateWindow(WINDOW_MUSIC_NAV,strPath);
        return true;
    }
    case CONTEXT_BUTTON_GO_TO_ALBUM:
    {
        CStdString strPath;
        CMusicDatabase database;
        database.Open();
        strPath = StringUtils::Format("musicdb://albums/%ld/",
                                      database.GetAlbumByName(m_vecItems->Get(itemNumber)->GetVideoInfoTag()->m_strAlbum));
        g_windowManager.ActivateWindow(WINDOW_MUSIC_NAV,strPath);
        return true;
    }
    case CONTEXT_BUTTON_PLAY_OTHER:
    {
        CMusicDatabase database;
        database.Open();
        CSong song;
        if (database.GetSong(database.GetSongByArtistAndAlbumAndTitle(StringUtils::Join(m_vecItems->Get(itemNumber)->GetVideoInfoTag()->m_artist, g_advancedSettings.m_videoItemSeparator),m_vecItems->Get(itemNumber)->GetVideoInfoTag()->m_strAlbum,
                             m_vecItems->Get(itemNumber)->GetVideoInfoTag()->m_strTitle),
                             song))
        {
            CApplicationMessenger::Get().PlayFile(song);
        }
        return true;
    }

    default:
        break;

    }
    return CGUIWindowVideoBase::OnContextButton(itemNumber, button);
}
开发者ID:Rubber1Duck,项目名称:xbmc,代码行数:86,代码来源:GUIWindowVideoNav.cpp

示例10: OnDeleteItem

void CGUIWindowVideoNav::OnDeleteItem(CFileItemPtr pItem)
{
    if (m_vecItems->IsParentFolder())
        return;

    if (!m_vecItems->IsVideoDb() && !pItem->IsVideoDb())
    {
        if (!pItem->GetPath().Equals("newsmartplaylist://video") &&
                !pItem->GetPath().Equals("special://videoplaylists/") &&
                !pItem->GetPath().Equals("sources://video/") &&
                !StringUtils::StartsWithNoCase(pItem->GetPath(), "newtag://"))
            CGUIWindowVideoBase::OnDeleteItem(pItem);
    }
    else if (StringUtils::StartsWithNoCase(pItem->GetPath(), "videodb://movies/sets/") &&
             pItem->GetPath().size() > 22 && pItem->m_bIsFolder)
    {
        CGUIDialogYesNo* pDialog = (CGUIDialogYesNo*)g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO);
        pDialog->SetHeading(432);
        CStdString strLabel = StringUtils::Format(g_localizeStrings.Get(433),pItem->GetLabel().c_str());
        pDialog->SetLine(1, strLabel);
        pDialog->SetLine(2, "");;
        pDialog->DoModal();
        if (pDialog->IsConfirmed())
        {
            CFileItemList items;
            CDirectory::GetDirectory(pItem->GetPath(),items,"",DIR_FLAG_NO_FILE_DIRS);
            for (int i=0; i<items.Size(); ++i)
                OnDeleteItem(items[i]);

            CVideoDatabaseDirectory dir;
            CQueryParams params;
            dir.GetQueryParams(pItem->GetPath(),params);
            m_database.DeleteSet(params.GetSetId());
        }
    }
    else if (m_vecItems->GetContent() == "tags" && pItem->m_bIsFolder)
    {
        CGUIDialogYesNo* pDialog = (CGUIDialogYesNo*)g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO);
        pDialog->SetHeading(432);
        CStdString strLabel = StringUtils::Format(g_localizeStrings.Get(433), pItem->GetLabel().c_str());
        pDialog->SetLine(1, strLabel);
        pDialog->SetLine(2, "");
        pDialog->DoModal();
        if (pDialog->IsConfirmed())
        {
            CVideoDatabaseDirectory dir;
            CQueryParams params;
            dir.GetQueryParams(pItem->GetPath(), params);
            m_database.DeleteTag(params.GetTagId(), (VIDEODB_CONTENT_TYPE)params.GetContentType());
        }
    }
    else if (m_vecItems->GetPath().Equals(CUtil::VideoPlaylistsLocation()) ||
             m_vecItems->GetPath().Equals("special://videoplaylists/"))
    {
        pItem->m_bIsFolder = false;
        CFileUtils::DeleteItem(pItem);
    }
    else
    {
        if (!CGUIDialogVideoInfo::DeleteVideoItem(pItem))
            return;
    }

    CUtil::DeleteVideoDatabaseDirectoryCache();
}
开发者ID:Rubber1Duck,项目名称:xbmc,代码行数:65,代码来源:GUIWindowVideoNav.cpp

示例11: LoadVideoInfo

void CGUIWindowVideoNav::LoadVideoInfo(CFileItemList &items, CVideoDatabase &database, bool allowReplaceLabels)
{
    // TODO: this could possibly be threaded as per the music info loading,
    //       we could also cache the info
    if (!items.GetContent().empty() && !items.IsPlugin())
        return; // don't load for listings that have content set and weren't created from plugins

    CStdString content = items.GetContent();
    // determine content only if it isn't set
    if (content.empty())
    {
        content = database.GetContentForPath(items.GetPath());
        items.SetContent(content.empty() ? "files" : content);
    }

    /*
      If we have a matching item in the library, so we can assign the metadata to it. In addition, we can choose
      * whether the item is stacked down (eg in the case of folders representing a single item)
      * whether or not we assign the library's labels to the item, or leave the item as is.

      As certain users (read: certain developers) don't want either of these to occur, we compromise by stacking
      items down only if stacking is available and enabled.

      Similarly, we assign the "clean" library labels to the item only if the "Replace filenames with library titles"
      setting is enabled.
      */
    const bool stackItems    = items.GetProperty("isstacked").asBoolean() || (StackingAvailable(items) && CSettings::Get().GetBool("myvideos.stackvideos"));
    const bool replaceLabels = allowReplaceLabels && CSettings::Get().GetBool("myvideos.replacelabels");

    CFileItemList dbItems;
    /* NOTE: In the future when GetItemsForPath returns all items regardless of whether they're "in the library"
             we won't need the fetchedPlayCounts code, and can "simply" do this directly on absense of content. */
    bool fetchedPlayCounts = false;
    if (!content.empty())
    {
        database.GetItemsForPath(content, items.GetPath(), dbItems);
        dbItems.SetFastLookup(true);
    }

    for (int i = 0; i < items.Size(); i++)
    {
        CFileItemPtr pItem = items[i];
        CFileItemPtr match;
        if (!content.empty()) /* optical media will be stacked down, so it's path won't match the base path */
            match = dbItems.Get(pItem->IsOpticalMediaFile() ? pItem->GetLocalMetadataPath() : pItem->GetPath());
        if (match)
        {
            pItem->UpdateInfo(*match, replaceLabels);

            if (stackItems)
            {
                if (match->m_bIsFolder)
                    pItem->SetPath(match->GetVideoInfoTag()->m_strPath);
                else
                    pItem->SetPath(match->GetVideoInfoTag()->m_strFileNameAndPath);
                // if we switch from a file to a folder item it means we really shouldn't be sorting files and
                // folders separately
                if (pItem->m_bIsFolder != match->m_bIsFolder)
                {
                    items.SetSortIgnoreFolders(true);
                    pItem->m_bIsFolder = match->m_bIsFolder;
                }
            }
        }
        else
        {
            /* NOTE: Currently we GetPlayCounts on our items regardless of whether content is set
                      as if content is set, GetItemsForPaths doesn't return anything not in the content tables.
                      This code can be removed once the content tables are always filled */
            if (!pItem->m_bIsFolder && !fetchedPlayCounts)
            {
                database.GetPlayCounts(items.GetPath(), items);
                fetchedPlayCounts = true;
            }

            // preferably use some information from PVR info tag if available
            if (pItem->HasPVRRecordingInfoTag())
                pItem->GetPVRRecordingInfoTag()->CopyClientInfo(pItem->GetVideoInfoTag());

            // set the watched overlay
            if (pItem->IsVideo())
                pItem->SetOverlayImage(CGUIListItem::ICON_OVERLAY_UNWATCHED, pItem->HasVideoInfoTag() && pItem->GetVideoInfoTag()->m_playCount > 0);
        }
    }
}
开发者ID:Rubber1Duck,项目名称:xbmc,代码行数:85,代码来源:GUIWindowVideoNav.cpp

示例12: OnClick

bool CGUIWindowVideoNav::OnClick(int iItem)
{
    CFileItemPtr item = m_vecItems->Get(iItem);
    if (!item->m_bIsFolder && item->IsVideoDb() && !item->Exists())
    {
        CLog::Log(LOGDEBUG, "%s called on '%s' but file doesn't exist", __FUNCTION__, item->GetPath().c_str());
        if (!CGUIDialogVideoInfo::DeleteVideoItemFromDatabase(item, true))
            return true;

        // update list
        Refresh(true);
        m_viewControl.SetSelectedItem(iItem);
        return true;
    }
    else if (StringUtils::StartsWithNoCase(item->GetPath(), "newtag://"))
    {
        // dont allow update while scanning
        if (g_application.IsVideoScanning())
        {
            CGUIDialogOK::ShowAndGetInput(257, 0, 14057, 0);
            return true;
        }

        //Get the new title
        CStdString strTag;
        if (!CGUIKeyboardFactory::ShowAndGetInput(strTag, g_localizeStrings.Get(20462), false))
            return true;

        CVideoDatabase videodb;
        if (!videodb.Open())
            return true;

        // get the media type and convert from plural to singular (by removing the trailing "s")
        CStdString mediaType = item->GetPath().substr(9);
        mediaType = mediaType.substr(0, mediaType.size() - 1);
        CStdString localizedType = CGUIDialogVideoInfo::GetLocalizedVideoType(mediaType);
        if (localizedType.empty())
            return true;

        if (!videodb.GetSingleValue("tag", "tag.idTag", videodb.PrepareSQL("tag.strTag = '%s' AND tag.idTag IN (SELECT taglinks.idTag FROM taglinks WHERE taglinks.media_type = '%s')", strTag.c_str(), mediaType.c_str())).empty())
        {
            CStdString strError = StringUtils::Format(g_localizeStrings.Get(20463), strTag.c_str());
            CGUIDialogOK::ShowAndGetInput(20462, "", strError, "");
            return true;
        }

        int idTag = videodb.AddTag(strTag);
        CFileItemList items;
        CStdString strLabel = StringUtils::Format(g_localizeStrings.Get(20464), localizedType.c_str());
        if (CGUIDialogVideoInfo::GetItemsForTag(strLabel, mediaType, items, idTag))
        {
            for (int index = 0; index < items.Size(); index++)
            {
                if (!items[index]->HasVideoInfoTag() || items[index]->GetVideoInfoTag()->m_iDbId <= 0)
                    continue;

                videodb.AddTagToItem(items[index]->GetVideoInfoTag()->m_iDbId, idTag, mediaType);
            }
        }

        Refresh(true);
        return true;
    }

    return CGUIWindowVideoBase::OnClick(iItem);
}
开发者ID:Rubber1Duck,项目名称:xbmc,代码行数:66,代码来源:GUIWindowVideoNav.cpp

示例13: Run

void CBackgroundInfoLoader::Run()
{
    try
    {
        if (m_vecItems.size() > 0)
        {
            OnLoaderStart();

            for (std::vector<CFileItemPtr>::const_iterator iter = m_vecItems.begin(); iter != m_vecItems.end(); ++iter)
            {
                CFileItemPtr pItem = *iter;

                // Ask the callback if we should abort
                if ((m_pProgressCallback && m_pProgressCallback->Abort()) || m_bStop)
                    break;

                try
                {
                    if (LoadItem(pItem.get()) && m_pObserver)
                        m_pObserver->OnItemLoaded(pItem.get());
                }
                catch (...)
                {
                    CLog::Log(LOGERROR, "CBackgroundInfoLoader::LoadItem - Unhandled exception for item %s", CURL::GetRedacted(pItem->GetPath()).c_str());
                }
            }
        }

        OnLoaderFinish();
        m_bIsLoading = false;
    }
    catch (...)
    {
        m_bIsLoading = false;
        CLog::Log(LOGERROR, "%s - Unhandled exception", __FUNCTION__);
    }
}
开发者ID:MrMC,项目名称:mrmc,代码行数:37,代码来源:BackgroundInfoLoader.cpp

示例14: PlayItem

void CGUIWindowMusicBase::PlayItem(int iItem)
{
  // restrictions should be placed in the appropiate window code
  // only call the base code if the item passes since this clears
  // the current playlist

  const CFileItemPtr pItem = m_vecItems->Get(iItem);
#ifdef HAS_DVD_DRIVE
  if (pItem->IsDVD())
  {
    MEDIA_DETECT::CAutorun::PlayDiscAskResume(pItem->GetPath());
    return;
  }
#endif

  // if its a folder, build a playlist
  if ((pItem->m_bIsFolder && !pItem->IsPlugin()) || (g_windowManager.GetActiveWindow() == WINDOW_MUSIC_NAV && pItem->IsPlayList()))
  {
    // make a copy so that we can alter the queue state
    CFileItemPtr item(new CFileItem(*m_vecItems->Get(iItem)));

    //  Allow queuing of unqueueable items
    //  when we try to queue them directly
    if (!item->CanQueue())
      item->SetCanQueue(true);

    // skip ".."
    if (item->IsParentFolder())
      return;

    CFileItemList queuedItems;
    AddItemToPlayList(item, queuedItems);
    if (g_partyModeManager.IsEnabled())
    {
      g_partyModeManager.AddUserSongs(queuedItems, true);
      return;
    }

    /*
    std::string strPlayListDirectory = m_vecItems->GetPath();
    URIUtils::RemoveSlashAtEnd(strPlayListDirectory);
    */

    g_playlistPlayer.ClearPlaylist(PLAYLIST_MUSIC);
    g_playlistPlayer.Reset();
    g_playlistPlayer.Add(PLAYLIST_MUSIC, queuedItems);
    g_playlistPlayer.SetCurrentPlaylist(PLAYLIST_MUSIC);

    // play!
    g_playlistPlayer.Play();
  }
  else if (pItem->IsPlayList())
  {
    // load the playlist the old way
    LoadPlayList(pItem->GetPath());
  }
  else
  {
    // just a single item, play it
    //! @todo Add music-specific code for single playback of an item here (See OnClick in MediaWindow, and OnPlayMedia below)
    OnClick(iItem);
  }
}
开发者ID:jtrensberger,项目名称:xbmc,代码行数:63,代码来源:GUIWindowMusicBase.cpp

示例15: OnBrowse


//.........这里部分代码省略.........
    }
    else if (m_type.Equals("episodes"))
    {
      videodatabase.GetEpisodesNav(basePath + "2/-1/-1/", items);
      // we need to replace the db label (<season>x<episode> <title>) with the title only
      CLabelFormatter format("%T", "");
      for (int i = 0; i < items.Size(); i++)
        format.FormatLabel(items[i].get());
      iLabel = 20360;
    }
    else if (m_type.Equals("musicvideos"))
    {
      videodatabase.GetMusicVideosNav(basePath + "2/", items);
      iLabel = 20389;
    }
    else
      assert(false);
  }
  else if (m_rule.m_field == FieldPlaylist)
  {
    // use filebrowser to grab another smart playlist

    // Note: This can cause infinite loops (playlist that refers to the same playlist) but I don't
    //       think there's any decent way to deal with this, as the infinite loop may be an arbitrary
    //       number of playlists deep, eg playlist1 -> playlist2 -> playlist3 ... -> playlistn -> playlist1
    CStdString path = "special://videoplaylists/";
    if (m_type.Equals("songs") || m_type.Equals("albums") || m_type.Equals("artists"))
      path = "special://musicplaylists/";
    XFILE::CDirectory::GetDirectory(path, items, ".xsp", XFILE::DIR_FLAG_NO_FILE_DIRS);
    for (int i = 0; i < items.Size(); i++)
    {
      CFileItemPtr item = items[i];
      CSmartPlaylist playlist;
      if (playlist.OpenAndReadName(item->GetPath()))
        item->SetLabel(playlist.GetName());
    }
    iLabel = 559;
  }
  else if (m_rule.m_field == FieldPath)
  {
    VECSOURCES sources;
    if (m_type == "songs" || m_type == "mixed")
      sources = *g_settings.GetSourcesFromType("music");
    if (m_type != "songs")
    {
      VECSOURCES sources2 = *g_settings.GetSourcesFromType("video");
      sources.insert(sources.end(),sources2.begin(),sources2.end());
    }
    g_mediaManager.GetLocalDrives(sources);
    
    CStdString path = m_rule.GetParameter();
    CGUIDialogFileBrowser::ShowAndGetDirectory(sources, g_localizeStrings.Get(657), path, false);
    if (m_rule.m_parameter.size() > 0)
      m_rule.m_parameter.clear();
    if (!path.empty())
      m_rule.m_parameter.push_back(path);

    UpdateButtons();
    return;
  }
  else if (m_rule.m_field == FieldSet)
  {
    videodatabase.GetSetsNav("videodb://1/7/", items, VIDEODB_CONTENT_MOVIES);
    iLabel = 20434;
  }
  else if (m_rule.m_field == FieldTag)
开发者ID:AFFLUENTSOCIETY,项目名称:SPMC,代码行数:67,代码来源:GUIDialogSmartPlaylistRule.cpp


注:本文中的CFileItemPtr::GetPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。