Beispiel #1
0
void SymbolTree::BuildTree(const wxFileName &fileName)
{
	// Clear the tree
	DeleteAllItems();
	m_items.clear();
	m_globalsNode = wxTreeItemId();
	m_prototypesNode = wxTreeItemId();
	m_macrosNode = wxTreeItemId();
	m_sortItems.clear();

	m_fileName = fileName;
	// Get the current tree
	m_tree = TagsManagerST::Get()->Load(m_fileName);
	if ( !m_tree ) {
		return;
	}

	// Add invisible root node
	wxTreeItemId root;
	root = AddRoot(fileName.GetFullName(), 15, 15);

	TreeWalker<wxString, TagEntry> walker(m_tree->GetRoot());

	// add three items here:
	// the globals node, the mcros and the prototype node
	m_globalsNode    = AppendItem(root, wxT("Global Functions and Variables"), 2, 2, new MyTreeItemData(wxT("Global Functions and Variables"), wxEmptyString));
	m_prototypesNode = AppendItem(root, wxT("Functions Prototypes"), 2, 2, new MyTreeItemData(wxT("Functions Prototypes"), wxEmptyString));
	m_macrosNode     = AppendItem(root, wxT("Macros"), 2, 2, new MyTreeItemData(wxT("Macros"), wxEmptyString));

	// Iterate over the tree and add items
	m_sortItems.clear();

	Freeze();
	for (; !walker.End(); walker++) {
		// Add the item to the tree
		TagNode* node = walker.GetNode();

		// Skip root node
		if (node->IsRoot())
			continue;

		// Add the node
		AddItem(node);
	}

	SortTree(m_sortItems);
	Thaw();

	//select the root node by default
	if (!(GetWindowStyleFlag() & wxTR_HIDE_ROOT)) {
		//root is visible, select it
		SelectItem(GetRootItem());
	}
}
Beispiel #2
0
void SymbolTree::BuildTree(const wxFileName &fileName, TagEntryPtrVector_t* tags /*NULL*/)
{
    TagEntryPtrVector_t newTags;
    if ( !tags ) {
        
        // Get the current database
        ITagsStoragePtr db = TagsManagerST::Get()->GetDatabase();
        if ( ! db ) {
            Clear();
            return;
        }
        // Load the new tags from the database
        db->SelectTagsByFile(fileName.GetFullPath(), newTags);
        // Compare the new tags with the old ones
        if ( TagsManagerST::Get()->AreTheSame(newTags, m_currentTags) )
            return;
            
        m_currentTags.clear();
        m_currentTags.insert(m_currentTags.end(), newTags.begin(), newTags.end());
        
    } else {
        
        m_currentTags.clear();
        m_currentTags.insert(m_currentTags.end(), tags->begin(), tags->end());
        
    }
    
    wxWindowUpdateLocker locker(this);
    Clear();
    m_fileName = fileName;
    
    // Convert them into tree
    m_tree = TagsManagerST::Get()->Load(m_fileName, &m_currentTags);
    if ( !m_tree ) {
        return;
    }

    // Add invisible root node
    wxTreeItemId root;
    root = AddRoot(fileName.GetFullName(), 15, 15);

    TreeWalker<wxString, TagEntry> walker(m_tree->GetRoot());

    // add three items here:
    // the globals node, the mcros and the prototype node
    m_globalsNode    = AppendItem(root, wxT("Global Functions and Variables"), 2, 2, new MyTreeItemData(wxT("Global Functions and Variables"), wxEmptyString));
    m_prototypesNode = AppendItem(root, wxT("Functions Prototypes"), 2, 2, new MyTreeItemData(wxT("Functions Prototypes"), wxEmptyString));
    m_macrosNode     = AppendItem(root, wxT("Macros"), 2, 2, new MyTreeItemData(wxT("Macros"), wxEmptyString));

    // Iterate over the tree and add items
    m_sortItems.clear();

    Freeze();
    for (; !walker.End(); walker++) {
        // Add the item to the tree
        TagNode* node = walker.GetNode();

        // Skip root node
        if (node->IsRoot())
            continue;

        // Add the node
        AddItem(node);
    }
    
    SortTree(m_sortItems);
    if ( ItemHasChildren(m_globalsNode) == false ) {
        Delete(m_globalsNode);
    }
    if ( ItemHasChildren(m_prototypesNode) == false ) {
        Delete(m_prototypesNode);
    }
    if ( ItemHasChildren(m_macrosNode) == false ) {
        Delete(m_macrosNode);
    }
    Thaw();

    //select the root node by default
    if (!(GetWindowStyleFlag() & wxTR_HIDE_ROOT)) {
        //root is visible, select it
        SelectItem(GetRootItem());
    }
}