コード例 #1
0
CStdString CGUIBaseContainer::GetDescription() const
{
    CStdString strLabel;
    int item = GetSelectedItem();
    if (item >= 0 && item < (int)m_items.size())
    {
        CGUIListItemPtr pItem = m_items[item];
        if (pItem->m_bIsFolder)
            strLabel.Format("[%s]", pItem->GetLabel().c_str());
        else
            strLabel = pItem->GetLabel();
    }
    return strLabel;
}
コード例 #2
0
void CGUIBaseContainer::OnJumpLetter(char letter)
{
    if (m_matchTimer.GetElapsedMilliseconds() < letter_match_timeout)
        m_match.push_back(letter);
    else
        m_match.Format("%c", letter);

    m_matchTimer.StartZero();

    // we can't jump through letters if we have none
    if (0 == m_letterOffsets.size())
        return;

    // find the current letter we're focused on
    unsigned int offset = CorrectOffset(GetOffset(), GetCursor());
    for (unsigned int i = (offset + 1) % m_items.size(); i != offset; i = (i+1) % m_items.size())
    {
        CGUIListItemPtr item = m_items[i];
        if (0 == strnicmp(SortUtils::RemoveArticles(item->GetLabel()).c_str(), m_match.c_str(), m_match.size()))
        {
            SelectItem(i);
            return;
        }
    }
    // no match found - repeat with a single letter
    if (m_match.size() > 1)
    {
        m_match.clear();
        OnJumpLetter(letter);
    }
}
コード例 #3
0
void CGUIBaseContainer::OnJumpLetter(char letter, bool skip /*=false*/)
{
  if (m_matchTimer.GetElapsedMilliseconds() < letter_match_timeout)
    m_match.push_back(letter);
  else
    m_match = StringUtils::Format("%c", letter);

  m_matchTimer.StartZero();

  // we can't jump through letters if we have none
  if (0 == m_letterOffsets.size())
    return;

  // find the current letter we're focused on
  unsigned int offset = CorrectOffset(GetOffset(), GetCursor());
  unsigned int i      = (offset + ((skip) ? 1 : 0)) % m_items.size();
  do
  {
    CGUIListItemPtr item = m_items[i];
    std::string label = item->GetLabel();
    if (CSettings::Get().GetBool("filelists.ignorethewhensorting"))
      label = SortUtils::RemoveArticles(label);
    if (0 == strnicmp(label.c_str(), m_match.c_str(), m_match.size()))
    {
      SelectItem(i);
      return;
    }
    i = (i+1) % m_items.size();
  } while (i != offset);
  // no match found - repeat with a single letter
  if (m_match.size() > 1)
  {
    m_match.clear();
    OnJumpLetter(letter, true);
  }
}