status_t VariablesView::_ApplyViewStateDescendentNodeInfos(VariablesViewState* viewState, void* parent, TreeTablePath& path) { int32 childCount = fVariableTableModel->CountChildren(parent); for (int32 i = 0; i < childCount; i++) { ModelNode* node = (ModelNode*)fVariableTableModel->ChildAt(parent, i); if (!path.AddComponent(i)) return B_NO_MEMORY; // apply the node's info, if any const VariablesViewNodeInfo* nodeInfo = viewState->GetNodeInfo( node->GetVariable()->ID(), node->GetPath()); if (nodeInfo != NULL) { fVariableTable->SetNodeExpanded(path, nodeInfo->IsNodeExpanded()); // recurse status_t error = _ApplyViewStateDescendentNodeInfos(viewState, node, path); if (error != B_OK) return error; } path.RemoveLastComponent(); } return B_OK; }
status_t VariablesView::_AddViewStateDescendentNodeInfos(VariablesViewState* viewState, void* parent, TreeTablePath& path) const { int32 childCount = fVariableTableModel->CountChildren(parent); for (int32 i = 0; i < childCount; i++) { ModelNode* node = (ModelNode*)fVariableTableModel->ChildAt(parent, i); if (!path.AddComponent(i)) return B_NO_MEMORY; // add the node's info VariablesViewNodeInfo nodeInfo; nodeInfo.SetNodeExpanded(fVariableTable->IsNodeExpanded(path)); status_t error = viewState->SetNodeInfo(node->GetVariable()->ID(), node->GetPath(), nodeInfo); if (error != B_OK) return error; // recurse error = _AddViewStateDescendentNodeInfos(viewState, node, path); if (error != B_OK) return error; path.RemoveLastComponent(); } return B_OK; }
void VariablesView::VariableTableModel::NotifyNodeChanged(ModelNode* node) { if (!node->IsHidden()) { TreeTablePath treePath; if (_GetTreePath(node, treePath)) { int32 index = treePath.RemoveLastComponent(); NotifyNodesChanged(treePath, index, 1); } } }