void RestoreTreeState(wxTreeCtrl* tree, const wxTreeItemId& parent, wxArrayString& nodePaths) { if (!parent.IsOk() || !tree) return; if (nodePaths.GetCount() == 0) { tree->Collapse(parent); return; } for (unsigned int i = 0; i < nodePaths.GetCount(); ++i) DoExpandRememberedNode(tree, parent, nodePaths[i]); nodePaths.Clear(); }
void DoExpandRememberedNode(wxTreeCtrl* tree, const wxTreeItemId& parent, const wxString& path) { if (!path.IsEmpty()) { //Manager::Get()->GetLogManager()->Log(mltDevDebug, path); wxString tmpPath; tmpPath = path; wxString folder; int pos = tmpPath.Find(_T('/')); while (pos == 0) { tmpPath = tmpPath.Right(tmpPath.Length() - pos - 1); pos = tmpPath.Find(_T('/')); } if (pos < 0) // no '/' { folder = tmpPath; tmpPath.Clear(); } else { folder = tmpPath.Left(pos); tmpPath = tmpPath.Right(tmpPath.Length() - pos - 1); } //Manager::Get()->GetLogManager()->Log(mltDevDebug, "%s, %s", folder.c_str(), tmpPath.c_str()); wxTreeItemIdValue cookie = nullptr; wxTreeItemId child = tree->GetFirstChild(parent, cookie); while (child.IsOk()) { wxString itemText = tree->GetItemText(child); if (itemText.Matches(folder)) { tree->Expand(child); DoExpandRememberedNode(tree, child, tmpPath); break; } child = tree->GetNextChild(parent, cookie); } } }