void SymbolTree::UpdateGuiItem(TagEntry& data, const wxString& key) { if (!m_tree) return; TagNode* node = m_tree->Find(key); if ( node ) { // Update the new data with the gui tree item id data.SetTreeItemId( node->GetData().GetTreeItemId() ); node->SetData(data); // Update Icon if needed int iconIndex = GetItemIconIndex(data.GetKind(), data.GetAccess()); int curIconIndex = -1; wxTreeItemId itemId = node->GetData().GetTreeItemId(); if (itemId.IsOk()) { curIconIndex = GetItemImage(itemId); if (curIconIndex != iconIndex ) { // Need to update the image as well SetItemImage(node->GetData().GetTreeItemId(), iconIndex); SetItemImage(node->GetData().GetTreeItemId(), iconIndex, wxTreeItemIcon_Selected); } // if(curIconIndex != iconIndex ) //update the linenumber and file MyTreeItemData *item_data = new MyTreeItemData(data.GetFile(), data.GetPattern()); wxTreeItemData *old_data = GetItemData(itemId); if (old_data) delete old_data; SetItemData(itemId, item_data); } } }
/// Util function to help us to build a tree from tags TagNode* TagTree::AddEntry(TagEntry& tag) { // If a node with thig tag already exist, we simply updating the // data wxString key(tag.Key()); TagNode* newNode = Find(key); if( newNode ) { if( tag.IsOk() ) newNode->SetData(tag); return newNode; } // To add an entry to the tree, we first must make sure // that all path to it exist wxString name = tag.GetPath(); StringTokenizer tok(name, wxT("::")); wxString parentPath; TagNode* node = GetRoot(); TagNode* lastFoundNode = GetRoot(); for(int i=0; i<tok.Count()-1; i++) { parentPath += tok[i]; // Try to find this node in the tree node = Find(parentPath); if( !node ) { // Node does not exist add it, we copy key values // from 'tag' TagEntry ee; ee.SetPath(parentPath); ee.SetName(tok[i]); node = AddChild(parentPath, ee, lastFoundNode); } lastFoundNode = node; if(i < tok.Count()-2) parentPath += _T("::"); } return AddChild(key, tag, node); }