本文整理汇总了C++中CGUIListItem::IsFileItem方法的典型用法代码示例。如果您正苦于以下问题:C++ CGUIListItem::IsFileItem方法的具体用法?C++ CGUIListItem::IsFileItem怎么用?C++ CGUIListItem::IsFileItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGUIListItem
的用法示例。
在下文中一共展示了CGUIListItem::IsFileItem方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdateListProvider
void CGUIBaseContainer::UpdateListProvider(bool forceRefresh /* = false */)
{
if (m_listProvider)
{
if (m_listProvider->Update(forceRefresh))
{
// save the current item
int currentItem = GetSelectedItem();
CGUIListItem *current = (currentItem >= 0 && currentItem < (int)m_items.size()) ? m_items[currentItem].get() : NULL;
const std::string prevSelectedPath((current && current->IsFileItem()) ? static_cast<CFileItem *>(current)->GetPath() : "");
Reset();
m_listProvider->Fetch(m_items);
SetPageControlRange();
// update the newly selected item
bool found = false;
// first, try to re-identify selected item by comparing item pointers, though it is not guaranteed that item instances got not recreated on update.
for (int i = 0; i < (int)m_items.size(); i++)
{
if (m_items[i].get() == current)
{
found = true;
if (i != currentItem)
{
SelectItem(i);
break;
}
}
}
if (!found && !prevSelectedPath.empty())
{
// as fallback, try to re-identify selected item by comparing item paths.
for (int i = 0; i < static_cast<int>(m_items.size()); i++)
{
const CGUIListItemPtr c(m_items[i]);
if (c->IsFileItem())
{
const std::string &selectedPath = static_cast<CFileItem *>(c.get())->GetPath();
if (selectedPath == prevSelectedPath)
{
found = true;
if (i != currentItem)
{
SelectItem(i);
break;
}
}
}
}
}
if (!found && currentItem >= (int)m_items.size())
SelectItem(m_items.size()-1);
SetInvalid();
}
// always update the scroll by letter, as the list provider may have altered labels
// while not actually changing the list items.
UpdateScrollByLetter();
}
}