本文整理汇总了C++中CServerPath::SegmentCount方法的典型用法代码示例。如果您正苦于以下问题:C++ CServerPath::SegmentCount方法的具体用法?C++ CServerPath::SegmentCount怎么用?C++ CServerPath::SegmentCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CServerPath
的用法示例。
在下文中一共展示了CServerPath::SegmentCount方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MakeParent
wxTreeItemId CRemoteTreeView::MakeParent(CServerPath path, bool select)
{
std::vector<wxString> pieces;
pieces.reserve(path.SegmentCount() + 1);
while (path.HasParent()) {
pieces.push_back(path.GetLastSegment());
path = path.GetParent();
}
wxASSERT(!path.GetPath().empty());
pieces.push_back(path.GetPath());
const wxTreeItemId root = GetRootItem();
wxTreeItemId parent = root;
for (std::vector<wxString>::const_reverse_iterator iter = pieces.rbegin(); iter != pieces.rend(); ++iter) {
if (iter != pieces.rbegin())
path.AddSegment(*iter);
wxTreeItemIdValue cookie;
wxTreeItemId child = GetFirstChild(parent, cookie);
if (child && GetItemText(child).empty()) {
Delete(child);
child = wxTreeItemId();
if (parent != root)
ListExpand(parent);
}
for (child = GetFirstChild(parent, cookie); child; child = GetNextSibling(child)) {
const wxString& text = GetItemText(child);
if (text == *iter)
break;
}
if (!child) {
CDirectoryListing listing;
if (m_pState->m_pEngine->CacheLookup(path, listing) == FZ_REPLY_OK) {
child = AppendItem(parent, *iter, 0, 2, path.HasParent() ? 0 : new CItemData(path));
SetItemImages(child, false);
}
else {
child = AppendItem(parent, *iter, 1, 3, path.HasParent() ? 0 : new CItemData(path));
SetItemImages(child, true);
}
SortChildren(parent);
auto nextIter = iter;
++nextIter;
if (nextIter != pieces.rend())
DisplayItem(child, listing);
}
if (select && iter != pieces.rbegin()) {
#ifndef __WXMSW__
// Prevent CalculatePositions from being called
wxGenericTreeItem *anchor = m_anchor;
m_anchor = 0;
#endif
Expand(parent);
#ifndef __WXMSW__
m_anchor = anchor;
#endif
}
parent = child;
}
return parent;
}