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


C++ CFileItemList::Contains方法代码示例

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


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

示例1: GetDirectory

bool CGUIWindowMusicBase::GetDirectory(const CStdString &strDirectory, CFileItemList &items)
{
  items.SetThumbnailImage("");
  bool bResult = CGUIMediaWindow::GetDirectory(strDirectory,items);
  if (bResult)
    CMusicThumbLoader::FillThumb(items);

  // add in the "New Playlist" item if we're in the playlists folder
  if ((items.GetPath() == "special://musicplaylists/") && !items.Contains("newplaylist://"))
  {
    CFileItemPtr newPlaylist(new CFileItem(g_settings.GetUserDataItem("PartyMode.xsp"),false));
    newPlaylist->SetLabel(g_localizeStrings.Get(16035));
    newPlaylist->SetLabelPreformated(true);
    newPlaylist->m_bIsFolder = true;
    items.Add(newPlaylist);

    newPlaylist.reset(new CFileItem("newplaylist://", false));
    newPlaylist->SetLabel(g_localizeStrings.Get(525));
    newPlaylist->SetLabelPreformated(true);
    newPlaylist->SetSpecialSort(SortSpecialOnBottom);
    newPlaylist->SetCanQueue(false);
    items.Add(newPlaylist);

    newPlaylist.reset(new CFileItem("newsmartplaylist://music", false));
    newPlaylist->SetLabel(g_localizeStrings.Get(21437));
    newPlaylist->SetLabelPreformated(true);
    newPlaylist->SetSpecialSort(SortSpecialOnBottom);
    newPlaylist->SetCanQueue(false);
    items.Add(newPlaylist);
  }

  return bResult;
}
开发者ID:,项目名称:,代码行数:33,代码来源:

示例2: GetDirectory

bool CGUIWindowMusicBase::GetDirectory(const CStdString &strDirectory, CFileItemList &items)
{
  CStdString directory = strDirectory;

  // check if the path contains a filter and if so load it and
  // remove it from the path to get proper GUI view states etc
  CSmartPlaylist filterXsp;
  CMusicDbUrl musicUrl;
  if (musicUrl.FromString(strDirectory))
  {
    CVariant filter;
    if (musicUrl.GetOption("filter", filter))
    {
      // load the filter and if it's type does not match the
      // path's item type reset it
      if (filterXsp.LoadFromJson(filter.asString()) && !filterXsp.GetType().Equals(musicUrl.GetType().c_str()))
        filterXsp.Reset();

      // remove the "filter" option from the path
      musicUrl.AddOption("filter", "");
    }
    directory = musicUrl.ToString();
  }

  items.SetArt("thumb", "");
  bool bResult = CGUIMediaWindow::GetDirectory(directory, items);
  if (bResult)
    CMusicThumbLoader::FillThumb(items);

  // (re-)apply the previously retrieved filter
  // because it was reset in CGUIMediaWindow::GetDirectory()
  if (!filterXsp.IsEmpty())
    m_filter = filterXsp;

  // add in the "New Playlist" item if we're in the playlists folder
  if ((items.GetPath() == "special://musicplaylists/") && !items.Contains("newplaylist://"))
  {
    CFileItemPtr newPlaylist(new CFileItem(g_settings.GetUserDataItem("PartyMode.xsp"),false));
    newPlaylist->SetLabel(g_localizeStrings.Get(16035));
    newPlaylist->SetLabelPreformated(true);
    newPlaylist->m_bIsFolder = true;
    items.Add(newPlaylist);

    newPlaylist.reset(new CFileItem("newplaylist://", false));
    newPlaylist->SetLabel(g_localizeStrings.Get(525));
    newPlaylist->SetLabelPreformated(true);
    newPlaylist->SetSpecialSort(SortSpecialOnBottom);
    newPlaylist->SetCanQueue(false);
    items.Add(newPlaylist);

    newPlaylist.reset(new CFileItem("newsmartplaylist://music", false));
    newPlaylist->SetLabel(g_localizeStrings.Get(21437));
    newPlaylist->SetLabelPreformated(true);
    newPlaylist->SetSpecialSort(SortSpecialOnBottom);
    newPlaylist->SetCanQueue(false);
    items.Add(newPlaylist);
  }

  return bResult;
}
开发者ID:maheus,项目名称:xbmc,代码行数:60,代码来源:GUIWindowMusicBase.cpp

示例3: IsFavourite

bool CFavouritesDirectory::IsFavourite(CFileItem *item, int contextWindow)
{
  CFileItemList items;
  if (!Load(items)) return false;

  return items.Contains(GetExecutePath(*item, contextWindow));
}
开发者ID:sandalsoft,项目名称:mrmc,代码行数:7,代码来源:FavouritesDirectory.cpp

示例4: GetTvShowFolders

/**
 * \brief Gets a list of folders for recorded TV shows
 */
bool CMythDirectory::GetTvShowFolders(const CStdString& base, CFileItemList &items)
{
  cmyth_proglist_t list = m_session->GetAllRecordedPrograms();
  if (!list)
  {
    CLog::Log(LOGERROR, "%s - unable to get list of recordings", __FUNCTION__);
    return false;
  }

  int count = m_dll->proglist_get_count(list);
  for (int i = 0; i < count; i++)
  {
    cmyth_proginfo_t program = m_dll->proglist_get_item(list, i);
    if (program)
    {
      if (!IsVisible(program))
      {
        m_dll->ref_release(program);
        continue;
      }

      if (!IsTvShow(program))
      {
        m_dll->ref_release(program);
        continue;
      }

      CStdString title = GetValue(m_dll->proginfo_title(program));
      CStdString path = base + "/" + title + "/";

      /*
       * Only add each TV show once. If the TV show is already in the list, update the date for the
       * folder to be the date of the last recorded TV show as the programs are returned in the
       * order they were recorded.
       */
      if (items.Contains(path))
      {
        CFileItemPtr item = items.Get(path);
        item->m_dateTime = GetValue(m_dll->proginfo_rec_start(program));
      }
      else
      {
        CFileItemPtr item(new CFileItem(path, true));
        item->m_dateTime = GetValue(m_dll->proginfo_rec_start(program));
        item->SetLabel(title);
        items.Add(item);
      }
      m_dll->ref_release(program);
    }

  }

  if (g_guiSettings.GetBool("filelists.ignorethewhensorting"))
    items.AddSortMethod(SORT_METHOD_LABEL_IGNORE_THE, 551 /* Name */, LABEL_MASKS("", "", "%L", "%J"));
  else
    items.AddSortMethod(SORT_METHOD_LABEL, 551 /* Name */, LABEL_MASKS("", "", "%L", "%J"));
  items.AddSortMethod(SORT_METHOD_DATE, 552 /* Date */, LABEL_MASKS("", "", "%L", "%J"));

  return true;
}
开发者ID:AaronDnz,项目名称:xbmc,代码行数:63,代码来源:MythDirectory.cpp

示例5: GetDirectory

// Android apk directory i/o. Depends on libzip
// Basically the same format as zip.
// We might want to refactor CZipDirectory someday...
//////////////////////////////////////////////////////////////////////
bool CAPKDirectory::GetDirectory(const CURL& url, CFileItemList &items)
{
    // uses a <fully qualified path>/filename.apk/...
    std::string path = url.GetFileName();
    std::string host = url.GetHostName();
    URIUtils::AddSlashAtEnd(path);

    int zip_flags = 0, zip_error = 0;
    struct zip *zip_archive;
    zip_archive = zip_open(host.c_str(), zip_flags, &zip_error);
    if (!zip_archive || zip_error)
    {
        CLog::Log(LOGERROR, "CAPKDirectory::GetDirectory: Unable to open archive : '%s'",
                  host.c_str());
        return false;
    }

    std::string test_name;
    int numFiles = zip_get_num_files(zip_archive);
    for (int zip_index = 0; zip_index < numFiles; zip_index++)
    {
        test_name = zip_get_name(zip_archive, zip_index, zip_flags);

        // check for non matching path.
        if (!StringUtils::StartsWith(test_name, path))
            continue;

        // libzip does not index folders, only filenames. We search for a /,
        // add it if it's not in our list already, and hope that no one has
        // any "file/name.exe" files in a zip.

        size_t dir_marker = test_name.find('/', path.size() + 1);
        if (dir_marker != std::string::npos)
        {
            // return items relative to path
            test_name=test_name.substr(0, dir_marker);

            if (items.Contains(host + "/" + test_name))
                continue;
        }

        struct zip_stat sb;
        zip_stat_init(&sb);
        if (zip_stat_index(zip_archive, zip_index, zip_flags, &sb) != -1)
        {
            g_charsetConverter.unknownToUTF8(test_name);
            CFileItemPtr pItem(new CFileItem(test_name));
            pItem->m_dwSize    = sb.size;
            pItem->m_dateTime  = sb.mtime;
            pItem->m_bIsFolder = dir_marker > 0 ;
            pItem->SetPath(host + "/" + test_name);
            pItem->SetLabel(test_name.substr(path.size()));
            items.Add(pItem);
        }
    }
    zip_close(zip_archive);

    return true;
}
开发者ID:Hooksdena36,项目名称:xbmc,代码行数:63,代码来源:APKDirectory.cpp

示例6: GetTvShowFolders

/**
 * \brief Gets a list of folders for recorded TV shows
 */
bool CCMythDirectory::GetTvShowFolders(const CStdString& base, CFileItemList &items)
{
  cmyth_conn_t control = m_session->GetControl();
  if(!control)
    return false;

  cmyth_proglist_t list = m_dll->proglist_get_all_recorded(control);
  if(!list)
  {
    CLog::Log(LOGERROR, "%s - unable to get list of recordings", __FUNCTION__);
    return false;
  }

  int count = m_dll->proglist_get_count(list);
  for(int i=0; i<count; i++)
  {
    cmyth_proginfo_t program = m_dll->proglist_get_item(list, i);
    if(program)
    {
      if(GetValue(m_dll->proginfo_recgroup(program)).Equals("LiveTV"))
      {
        m_dll->ref_release(program);
        continue;
      }

      if (!IsTvShow(program))
      {
        m_dll->ref_release(program);
        continue;
      }

      CStdString title = GetValue(m_dll->proginfo_title(program));

      // Only add each TV show once
      if (items.Contains(base + "/" + title + "/"))
      {
        m_dll->ref_release(program);
        continue;
      }

      CFileItemPtr item(new CFileItem(base + "/" + title + "/", true));
      item->SetLabel(title);
      item->SetLabelPreformated(true);

      items.Add(item);
      m_dll->ref_release(program);
    }

  }

    // Sort by name only. Labels are preformated.
    if (g_guiSettings.GetBool("filelists.ignorethewhensorting"))
      items.AddSortMethod(SORT_METHOD_LABEL_IGNORE_THE, 551 /* Name */, LABEL_MASKS("%L", "", "%L", ""));
    else
      items.AddSortMethod(SORT_METHOD_LABEL, 551 /* Name */, LABEL_MASKS("%L", "", "%L", ""));

  m_dll->ref_release(list);
  return true;
}
开发者ID:Kr0nZ,项目名称:boxee,代码行数:62,代码来源:CMythDirectory.cpp

示例7: GetDirectory

bool CGUIWindowMusicBase::GetDirectory(const std::string &strDirectory, CFileItemList &items)
{
    items.ClearArt();
    bool bResult = CGUIMediaWindow::GetDirectory(strDirectory, items);
    if (bResult)
    {
        CMusicThumbLoader loader;
        loader.FillThumb(items);
    }

    CQueryParams params;
    CDirectoryNode::GetDatabaseInfo(items.GetPath(), params);

    if (params.GetAlbumId())
    {
        map<string, string> artistArt;
        if (m_musicdatabase.GetArtistArtForItem(params.GetAlbumId(), MediaTypeAlbum, artistArt))
            items.AppendArt(artistArt, MediaTypeArtist);

        map<string, string> albumArt;
        if (m_musicdatabase.GetArtForItem(params.GetAlbumId(), MediaTypeAlbum, albumArt))
            items.AppendArt(albumArt, MediaTypeAlbum);
    }

    // add in the "New Playlist" item if we're in the playlists folder
    if ((items.GetPath() == "special://musicplaylists/") && !items.Contains("newplaylist://"))
    {
        CFileItemPtr newPlaylist(new CFileItem(CProfilesManager::GetInstance().GetUserDataItem("PartyMode.xsp"),false));
        newPlaylist->SetLabel(g_localizeStrings.Get(16035));
        newPlaylist->SetLabelPreformated(true);
        newPlaylist->m_bIsFolder = true;
        items.Add(newPlaylist);

        newPlaylist.reset(new CFileItem("newplaylist://", false));
        newPlaylist->SetLabel(g_localizeStrings.Get(525));
        newPlaylist->SetLabelPreformated(true);
        newPlaylist->SetSpecialSort(SortSpecialOnBottom);
        newPlaylist->SetCanQueue(false);
        items.Add(newPlaylist);

        newPlaylist.reset(new CFileItem("newsmartplaylist://music", false));
        newPlaylist->SetLabel(g_localizeStrings.Get(21437));
        newPlaylist->SetLabelPreformated(true);
        newPlaylist->SetSpecialSort(SortSpecialOnBottom);
        newPlaylist->SetCanQueue(false);
        items.Add(newPlaylist);
    }

    return bResult;
}
开发者ID:nihalsunthankar,项目名称:xbmc,代码行数:50,代码来源:GUIWindowMusicBase.cpp

示例8: GetFileDetails

JSONRPC_STATUS CFileOperations::GetFileDetails(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)
{
  CStdString file = parameterObject["file"].asString();
  if (!CFile::Exists(file))
    return InvalidParams;

  if (!CFileUtils::RemoteAccessAllowed(file))
    return InvalidParams;

  CStdString path;
  URIUtils::GetDirectory(file, path);

  CFileItemList items;
  if (path.empty() || !CDirectory::GetDirectory(path, items) || !items.Contains(file))
    return InvalidParams;

  CFileItemPtr item = items.Get(file);
  if (!URIUtils::IsUPnP(file))
    FillFileItem(item, item, parameterObject["media"].asString(), parameterObject);

  // Check if the "properties" list exists
  // and make sure it contains the "file"
  // field
  CVariant param = parameterObject;
  if (!param.isMember("properties"))
    param["properties"] = CVariant(CVariant::VariantTypeArray);

  bool hasFileField = false;
  for (CVariant::const_iterator_array itr = param["properties"].begin_array(); itr != param["properties"].end_array(); itr++)
  {
    if (itr->asString().compare("file") == 0)
    {
      hasFileField = true;
      break;
    }
  }

  if (!hasFileField)
    param["properties"].append("file");
  param["properties"].append("filetype");

  HandleFileItem("id", true, "filedetails", item, parameterObject, param["properties"], result, false);
  return OK;
}
开发者ID:cpaowner,项目名称:xbmc,代码行数:44,代码来源:FileOperations.cpp

示例9: LoadFromFile

static bool LoadFromFile(const std::string& strPath, CFileItemList& items)
{
  CXBMCTinyXML doc;
  if (!doc.LoadFile(strPath))
  {
    CLog::Log(LOGERROR, "Unable to load %s (row %i column %i)", strPath.c_str(), doc.Row(), doc.Column());
    return false;
  }
  TiXmlElement *root = doc.RootElement();
  if (!root || strcmp(root->Value(), "favourites"))
  {
    CLog::Log(LOGERROR, "Favourites.xml doesn't contain the <favourites> root element");
    return false;
  }

  TiXmlElement *favourite = root->FirstChildElement("favourite");
  while (favourite)
  {
    // format:
    // <favourite name="Cool Video" thumb="foo.jpg">PlayMedia(c:\videos\cool_video.avi)</favourite>
    // <favourite name="My Album" thumb="bar.tbn">ActivateWindow(MyMusic,c:\music\my album)</favourite>
    // <favourite name="Apple Movie Trailers" thumb="path_to_thumb.png">RunScript(special://xbmc/scripts/apple movie trailers/default.py)</favourite>
    const char *name = favourite->Attribute("name");
    const char *thumb = favourite->Attribute("thumb");
    if (name && favourite->FirstChild())
    {
      CURL url;
      url.SetProtocol("favourites");
      url.SetHostName(CURL::Encode(favourite->FirstChild()->Value()));
      const std::string favURL(url.Get());
      if (!items.Contains(favURL))
      {
        const CFileItemPtr item(std::make_shared<CFileItem>(name));
        item->SetPath(favURL);
        if (thumb)
          item->SetArt("thumb", thumb);
        items.Add(item);
      }
    }
    favourite = favourite->NextSiblingElement("favourite");
  }
  return true;
}
开发者ID:anaconda,项目名称:xbmc,代码行数:43,代码来源:FavouritesService.cpp

示例10: LoadFavourites

bool CFavourites::LoadFavourites(CStdString& strPath, CFileItemList& items)
{
  TiXmlDocument doc;
  if (!doc.LoadFile(strPath))
  {
    CLog::Log(LOGERROR, "Unable to load %s (row %i column %i)", strPath.c_str(), doc.Row(), doc.Column());
    return false;
  }
  TiXmlElement *root = doc.RootElement();
  if (!root || strcmp(root->Value(), "favourites"))
  {
    CLog::Log(LOGERROR, "Favourites.xml doesn't contain the <favourites> root element");
    return false;
  }

  TiXmlElement *favourite = root->FirstChildElement("favourite");
  while (favourite)
  {
    // format:
    // <favourite name="Cool Video" thumb="foo.jpg">PlayMedia(c:\videos\cool_video.avi)</favourite>
    // <favourite name="My Album" thumb="bar.tbn">ActivateWindow(MyMusic,c:\music\my album)</favourite>
    // <favourite name="Apple Movie Trailers" thumb="path_to_thumb.png">RunScript(special://xbmc/scripts/apple movie trailers/default.py)</favourite>
    const char *name = favourite->Attribute("name");
    const char *thumb = favourite->Attribute("thumb");
    if (name && favourite->FirstChild())
    {
      if(!items.Contains(favourite->FirstChild()->Value()))
      {
        CFileItemPtr item(new CFileItem(name));
        item->m_strPath = favourite->FirstChild()->Value();
        if (thumb) item->SetThumbnailImage(thumb);
        items.Add(item);
      }
    }
    favourite = favourite->NextSiblingElement("favourite");
  }
  return true;
}
开发者ID:Bobbin007,项目名称:xbmc,代码行数:38,代码来源:Favourites.cpp

示例11: SelectAddonID

int CGUIWindowAddonBrowser::SelectAddonID(const std::vector<ADDON::TYPE> &types, std::vector<std::string> &addonIDs, bool showNone /* = false */, bool showDetails /* = true */, bool multipleSelection /* = true */, bool showInstalled /* = true */, bool showInstallable /* = false */, bool showMore /* = true */)
{
  // if we shouldn't show neither installed nor installable addons the list will be empty
  if (!showInstalled && !showInstallable)
    return -1;

  // can't show the "Get More" button if we already show installable addons
  if (showInstallable)
    showMore = false;

  CGUIDialogSelect *dialog = g_windowManager.GetWindow<CGUIDialogSelect>();
  if (!dialog)
    return -1;

  // get rid of any invalid addon types
  std::vector<ADDON::TYPE> validTypes(types.size());
  std::copy_if(types.begin(), types.end(), validTypes.begin(), [](ADDON::TYPE type) { return type != ADDON_UNKNOWN; });

  if (validTypes.empty())
    return -1;

  // get all addons to show
  VECADDONS addons;
  if (showInstalled)
  {
    for (std::vector<ADDON::TYPE>::const_iterator type = validTypes.begin(); type != validTypes.end(); ++type)
    {
      VECADDONS typeAddons;
      if (*type == ADDON_AUDIO)
        CAddonsDirectory::GetScriptsAndPlugins("audio", typeAddons);
      else if (*type == ADDON_EXECUTABLE)
        CAddonsDirectory::GetScriptsAndPlugins("executable", typeAddons);
      else if (*type == ADDON_IMAGE)
        CAddonsDirectory::GetScriptsAndPlugins("image", typeAddons);
      else if (*type == ADDON_VIDEO)
        CAddonsDirectory::GetScriptsAndPlugins("video", typeAddons);
      else if (*type == ADDON_GAME)
        CAddonsDirectory::GetScriptsAndPlugins("game", typeAddons);
      else
        CAddonMgr::GetInstance().GetAddons(typeAddons, *type);

      addons.insert(addons.end(), typeAddons.begin(), typeAddons.end());
    }
  }

  if (showInstallable || showMore)
  {
    VECADDONS installableAddons;
    if (CAddonMgr::GetInstance().GetInstallableAddons(installableAddons))
    {
      for (ADDON::IVECADDONS addon = installableAddons.begin(); addon != installableAddons.end();)
      {
        AddonPtr pAddon = *addon;
        
        // check if the addon matches one of the provided addon types
        bool matchesType = false;
        for (std::vector<ADDON::TYPE>::const_iterator type = validTypes.begin(); type != validTypes.end(); ++type)
        {
          if (pAddon->IsType(*type))
          {
            matchesType = true;
            break;
          }
        }

        if (matchesType)
        {
          ++addon;
          continue;
        }

        addon = installableAddons.erase(addon);
      }

      if (showInstallable)
        addons.insert(addons.end(), installableAddons.begin(), installableAddons.end());
      else if (showMore)
        showMore = !installableAddons.empty();
    }
  }

  if (addons.empty() && !showNone)
    return -1;

  // turn the addons into items
  std::map<std::string, AddonPtr> addonMap;
  CFileItemList items;
  for (ADDON::IVECADDONS addon = addons.begin(); addon != addons.end(); ++addon)
  {
    CFileItemPtr item(CAddonsDirectory::FileItemFromAddon(*addon, (*addon)->ID()));
    item->SetLabel2((*addon)->Summary());
    if (!items.Contains(item->GetPath()))
    {
      items.Add(item);
      addonMap.insert(std::make_pair(item->GetPath(), *addon));
    }
  }

  if (items.IsEmpty() && !showNone)
    return -1;
//.........这里部分代码省略.........
开发者ID:LS80,项目名称:xbmc,代码行数:101,代码来源:GUIWindowAddonBrowser.cpp

示例12: GetDirectory

bool CZipDirectory::GetDirectory(const CStdString& strPathOrig, CFileItemList& items)
{
    CStdString strPath;

    /* if this isn't a proper archive path, assume it's the path to a archive file */
    if( !strPathOrig.Left(6).Equals("zip://") )
        URIUtils::CreateArchivePath(strPath, "zip", strPathOrig, "");
    else
        strPath = strPathOrig;

    CURL url(strPath);

    CStdString strArchive = url.GetHostName();
    CStdString strOptions = url.GetOptions();
    CStdString strPathInZip = url.GetFileName();

    url.SetOptions(""); // delete options to have a clean path to add stuff too
    url.SetFileName(""); // delete filename too as our names later will contain it

    CStdString strSlashPath = url.Get();

    CStdString strBuffer;

    // the RAR code depends on things having a "/" at the end of the path
    URIUtils::AddSlashAtEnd(strSlashPath);

    vector<SZipEntry> entries;
    // turn on fast lookups
    bool bWasFast(items.GetFastLookup());
    items.SetFastLookup(true);
    if (!g_ZipManager.GetZipList(strPath,entries))
        return false;

    vector<CStdString> baseTokens;
    if (!strPathInZip.IsEmpty())
        CUtil::Tokenize(strPathInZip,baseTokens,"/");

    for (vector<SZipEntry>::iterator ze=entries.begin(); ze!=entries.end(); ++ze)
    {
        CStdString strEntryName(ze->name);
        strEntryName.Replace('\\','/');
        if (strEntryName == strPathInZip) // skip the listed dir
            continue;

        vector<CStdString> pathTokens;
        CUtil::Tokenize(strEntryName,pathTokens,"/");
        if (pathTokens.size() < baseTokens.size()+1)
            continue;

        bool bAdd=true;
        strEntryName = "";
        for ( unsigned int i=0; i<baseTokens.size(); ++i )
        {
            if (pathTokens[i] != baseTokens[i])
            {
                bAdd = false;
                break;
            }
            strEntryName += pathTokens[i] + "/";
        }
        if (!bAdd)
            continue;

        strEntryName += pathTokens[baseTokens.size()];
        char c=ze->name[strEntryName.size()];
        if (c == '/' || c == '\\')
            strEntryName += '/';
        bool bIsFolder = false;
        if (strEntryName[strEntryName.size()-1] != '/') // this is a file
        {
            strBuffer = strSlashPath + strEntryName + strOptions;
        }
        else
        {   // this is new folder. add if not already added
            bIsFolder = true;
            strBuffer = strSlashPath + strEntryName + strOptions;
            if (items.Contains(strBuffer)) // already added
                continue;
        }

        CFileItemPtr pFileItem(new CFileItem);

        if (g_charsetConverter.isValidUtf8(pathTokens[baseTokens.size()]))
            g_charsetConverter.utf8ToStringCharset(pathTokens[baseTokens.size()]);

        pFileItem->SetLabel(pathTokens[baseTokens.size()]);
        if (bIsFolder)
        {
            pFileItem->m_dwSize = 0;
            URIUtils::AddSlashAtEnd(strBuffer);
        }
        else
            pFileItem->m_dwSize = ze->usize;
        pFileItem->SetPath(strBuffer);
        pFileItem->m_bIsFolder = bIsFolder;
        pFileItem->m_idepth = ze->method;
        items.Add(pFileItem);
    }
    items.SetFastLookup(bWasFast);
    return true;
//.........这里部分代码省略.........
开发者ID:jdembski,项目名称:xbmc,代码行数:101,代码来源:ZipDirectory.cpp

示例13: GetDirectory

bool CGUIWindowMusicBase::GetDirectory(const std::string &strDirectory, CFileItemList &items)
{
  items.ClearArt();
  bool bResult = CGUIMediaWindow::GetDirectory(strDirectory, items);
  if (bResult)
  {
    // We always want to expand disc images in music windows.
    CDirectory::FilterFileDirectories(items, ".iso", true);

    CMusicThumbLoader loader;
    loader.FillThumb(items);

    CQueryParams params;
    CDirectoryNode::GetDatabaseInfo(items.GetPath(), params);

    if (params.GetAlbumId() > 0)
    {
      std::map<std::string, std::string> artistArt;
      if (m_musicdatabase.GetArtistArtForItem(params.GetAlbumId(), MediaTypeAlbum, artistArt))
        items.AppendArt(artistArt, MediaTypeArtist);

      std::map<std::string, std::string> albumArt;
      if (m_musicdatabase.GetArtForItem(params.GetAlbumId(), MediaTypeAlbum, albumArt))
        items.AppendArt(albumArt, MediaTypeAlbum);
    }
    if (params.GetArtistId() > 0)
    {
      std::map<std::string, std::string> artistArt;
      if (m_musicdatabase.GetArtForItem(params.GetArtistId(), "artist", artistArt))
        items.AppendArt(artistArt, MediaTypeArtist);
    }

    // add in the "New Playlist" item if we're in the playlists folder
    if ((items.GetPath() == "special://musicplaylists/") && !items.Contains("newplaylist://"))
    {
      CFileItemPtr newPlaylist(new CFileItem(CProfilesManager::GetInstance().GetUserDataItem("PartyMode.xsp"),false));
      newPlaylist->SetLabel(g_localizeStrings.Get(16035));
      newPlaylist->SetLabelPreformatted(true);
      newPlaylist->SetIconImage("DefaultPartyMode.png");
      newPlaylist->m_bIsFolder = true;
      items.Add(newPlaylist);

      newPlaylist.reset(new CFileItem("newplaylist://", false));
      newPlaylist->SetLabel(g_localizeStrings.Get(525));
      newPlaylist->SetIconImage("DefaultAddSource.png");
      newPlaylist->SetLabelPreformatted(true);
      newPlaylist->SetSpecialSort(SortSpecialOnBottom);
      newPlaylist->SetCanQueue(false);
      items.Add(newPlaylist);

      newPlaylist.reset(new CFileItem("newsmartplaylist://music", false));
      newPlaylist->SetLabel(g_localizeStrings.Get(21437));
      newPlaylist->SetIconImage("DefaultAddSource.png");
      newPlaylist->SetLabelPreformatted(true);
      newPlaylist->SetSpecialSort(SortSpecialOnBottom);
      newPlaylist->SetCanQueue(false);
      items.Add(newPlaylist);
    }

    // check for .CUE files here.
    items.FilterCueItems();

    std::string label;
    if (items.GetLabel().empty() && m_rootDir.IsSource(items.GetPath(), CMediaSourceSettings::GetInstance().GetSources("music"), &label))
      items.SetLabel(label);
  }

  return bResult;
}
开发者ID:Razzeee,项目名称:xbmc,代码行数:69,代码来源:GUIWindowMusicBase.cpp

示例14: SelectAddonID

int CGUIWindowAddonBrowser::SelectAddonID(const vector<ADDON::TYPE> &types, CStdStringArray &addonIDs, bool showNone /*= false*/, bool multipleSelection /*= true*/)
{
  CGUIDialogSelect *dialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT);
  if (!dialog)
    return 0;

  CFileItemList items;
  CStdString heading;
  int iTypes = 0;
  for (vector<ADDON::TYPE>::const_iterator it = types.begin(); it != types.end(); ++it)
  {
    if (*it == ADDON_UNKNOWN)
      continue;
    ADDON::VECADDONS addons;
    iTypes++;
    if (*it == ADDON_AUDIO)
      CAddonsDirectory::GetScriptsAndPlugins("audio",addons);
    else if (*it == ADDON_EXECUTABLE)
      CAddonsDirectory::GetScriptsAndPlugins("executable",addons);
    else if (*it == ADDON_IMAGE)
      CAddonsDirectory::GetScriptsAndPlugins("image",addons);
    else if (*it == ADDON_VIDEO)
      CAddonsDirectory::GetScriptsAndPlugins("video",addons);
    else
      CAddonMgr::Get().GetAddons(*it, addons);
    for (ADDON::IVECADDONS it2 = addons.begin() ; it2 != addons.end() ; ++it2)
    {
      CFileItemPtr item(CAddonsDirectory::FileItemFromAddon(*it2, ""));
      if (!items.Contains(item->GetPath()))
        items.Add(item);
    }

    if (!heading.IsEmpty())
      heading += ", ";
    heading += TranslateType(*it, true);
  }

  if (iTypes == 0)
    return 0;

  dialog->SetHeading(heading);
  dialog->Reset();
  dialog->SetUseDetails(true);
  if (multipleSelection)
    showNone = false;
  if (multipleSelection || iTypes > 1)
    dialog->EnableButton(true, 186);
  else
    dialog->EnableButton(true, 21452);
  if (showNone)
  {
    CFileItemPtr item(new CFileItem("", false));
    item->SetLabel(g_localizeStrings.Get(231));
    item->SetLabel2(g_localizeStrings.Get(24040));
    item->SetIconImage("DefaultAddonNone.png");
    item->SetSpecialSort(SortSpecialOnTop);
    items.Add(item);
  }
  items.Sort(SORT_METHOD_LABEL, SortOrderAscending);

  if (addonIDs.size() > 0)
  {
    for (CStdStringArray::const_iterator it = addonIDs.begin(); it != addonIDs.end() ; it++)
    {
      CFileItemPtr item = items.Get(*it);
      if (item)
        item->Select(true);
    }
  }
  dialog->SetItems(&items);
  dialog->SetMultiSelection(multipleSelection);
  dialog->DoModal();
  if (!multipleSelection && iTypes == 1 && dialog->IsButtonPressed())
  { // switch to the addons browser.
    vector<CStdString> params;
    params.push_back("addons://all/"+TranslateType(types[0],false)+"/");
    params.push_back("return");
    g_windowManager.ActivateWindow(WINDOW_ADDON_BROWSER, params);
    return 2;
  }
  if (!dialog->IsConfirmed())
    return 0;
  addonIDs.clear();
  const CFileItemList& list = dialog->GetSelectedItems();
  for (int i = 0 ; i < list.Size() ; i++)
    addonIDs.push_back(list.Get(i)->GetPath());
  return 1;
}
开发者ID:cpaowner,项目名称:xbmc,代码行数:88,代码来源:GUIWindowAddonBrowser.cpp


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