예제 #1
0
    def addnodeButtonClicked(self):
        """
        If the addnode button is clicked, copy the currently selected node and insert it back into the tree.
        """

        #Don't do anything if there's nothing to do
        if self.analyzerConfig is None or len(
                self.analyzerConfig.selectedItems()) == 0:
            return

        selecteditems = self.analyzerConfig.selectedItems()
        copiedvalues = {}
        #print selecteditems[0].parent()
        TreeWidgetTools.recursive_tree_widget_to_dict_helper(
            selecteditems[0], copiedvalues)
        #Pull original keys out of copiedvalues so the changes don't interfere with the loop
        tempkeylist = tuple(copiedvalues.keys())
        for key in tempkeylist:
            copiedvalues['COPY OF ' + key] = copiedvalues[key]
            del copiedvalues[key]

        #if the parent is None, that means we're copying a rootish-level item.  Use the invisible root to add to
        virtualparent = selecteditems[0].parent() if selecteditems[0].parent(
        ) is not None else self.analyzerConfig.invisibleRootItem()

        #add the copied dictionary to the tree
        TreeWidgetTools.recursive_generate_tree_widget_helper(
            copiedvalues, virtualparent)
예제 #2
0
 def addnodeButtonClicked(self):
     """
     If the addnode button is clicked, copy the currently selected node and insert it back into the tree.
     """
     
     #Don't do anything if there's nothing to do
     if self.analyzerConfig is None or len(self.analyzerConfig.selectedItems())==0:
         return
     
     selecteditems=self.analyzerConfig.selectedItems()
     copiedvalues={}
     #print selecteditems[0].parent()
     TreeWidgetTools.recursive_tree_widget_to_dict_helper(selecteditems[0],copiedvalues)
     #Pull original keys out of copiedvalues so the changes don't interfere with the loop
     tempkeylist=tuple(copiedvalues.keys())
     for key in tempkeylist:
         copiedvalues['COPY OF '+key]=copiedvalues[key]
         del copiedvalues[key]
     
     #if the parent is None, that means we're copying a rootish-level item.  Use the invisible root to add to
     virtualparent=selecteditems[0].parent() if selecteditems[0].parent() is not None else self.analyzerConfig.invisibleRootItem()
     
     #add the copied dictionary to the tree
     TreeWidgetTools.recursive_generate_tree_widget_helper(copiedvalues,virtualparent)