Python PySide.QtGui.QTreeView() Examples

The following are 3 code examples of PySide.QtGui.QTreeView(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module PySide.QtGui , or try the search function .
Example #1
Source File: viewProviderProxy.py    From FreeCAD_assembly2 with GNU Lesser General Public License v2.1 4 votes vote down vote up
def repair_tree_view():
    from PySide import QtGui
    doc = FreeCAD.ActiveDocument
    matches = []
    def search_children_recursively( node ):
        for c in node.children():
            if isinstance(c,QtGui.QTreeView) and isinstance(c, QtGui.QTreeWidget):
                matches.append(c)
            search_children_recursively( c)
    search_children_recursively(QtGui.QApplication.activeWindow())
    for m in matches:
        tree_nodes =  get_treeview_nodes(m)
        def get_node_by_label( label ):
            if label in tree_nodes and len( tree_nodes[label] ) == 1:
                return tree_nodes[label][0]
            elif not obj.Label in tree_nodes:
                FreeCAD.Console.PrintWarning( "  repair_tree_view: skipping %s since no node with text(0) == %s\n" % ( label, label) )
            else:
                FreeCAD.Console.PrintWarning( "  repair_tree_view: skipping %s since multiple nodes matching label\n" % ( label, label) )
        if doc.Label in tree_nodes: #all the code up until now has geen to find the QtGui.QTreeView widget (except for the get_node_by_label function)
            #FreeCAD.Console.PrintMessage( tree_nodes )
            for imported_obj in doc.Objects:
                try: #allow use of assembly2 contraints also on non imported objects
                    if isinstance( imported_obj.ViewObject.Proxy, ImportedPartViewProviderProxy ):
                        #FreeCAD.Console.PrintMessage( 'checking claim children for %s\n' % imported_obj.Label )
                        if get_node_by_label( imported_obj.Label ):
                            node_imported_obj =  get_node_by_label( imported_obj.Label )
                            if not hasattr( imported_obj.ViewObject.Proxy, 'Object'):
                                imported_obj.ViewObject.Proxy.Object = imported_obj # proxy.attach not called properly
                                FreeCAD.Console.PrintMessage('repair_tree_view: %s.ViewObject.Proxy.Object = %s' % (imported_obj.Name, imported_obj.Name) )
                            for constraint_obj in imported_obj.ViewObject.Proxy.claimChildren():
                                #FreeCAD.Console.PrintMessage('  - %s\n' % constraint_obj.Label )
                                if get_node_by_label( constraint_obj.Label ):
                                    #FreeCAD.Console.PrintMessage('     (found treeview node)\n')
                                    node_constraint_obj = get_node_by_label( constraint_obj.Label )
                                    if id( node_constraint_obj.parent()) != id(node_imported_obj):
                                        FreeCAD.Console.PrintMessage("repair_tree_view: %s under %s and not %s, repairing\n" % (constraint_obj.Label, node_constraint_obj.parent().text(0),  imported_obj.Label ))
                                        wrong_parent = node_constraint_obj.parent()
                                        wrong_parent.removeChild( node_constraint_obj )
                                        node_imported_obj.addChild( node_constraint_obj )
                except:
                    # FreeCAD.Console.PrintWarning( "not repaired %s \n" % ( imported_obj.Label ) )
                    pass
            #break 
Example #2
Source File: version_updater_UI_pyside.py    From anima with MIT License 4 votes vote down vote up
def setupUi(self, Dialog):
        Dialog.setObjectName("Dialog")
        Dialog.setWindowModality(QtCore.Qt.ApplicationModal)
        Dialog.resize(1304, 753)
        self.verticalLayout = QtGui.QVBoxLayout(Dialog)
        self.verticalLayout.setObjectName("verticalLayout")
        self.label = QtGui.QLabel(Dialog)
        self.label.setObjectName("label")
        self.verticalLayout.addWidget(self.label)
        self.versions_treeView = QtGui.QTreeView(Dialog)
        self.versions_treeView.setObjectName("versions_treeView")
        self.verticalLayout.addWidget(self.versions_treeView)
        self.horizontalWidget = QtGui.QWidget(Dialog)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.horizontalWidget.sizePolicy().hasHeightForWidth())
        self.horizontalWidget.setSizePolicy(sizePolicy)
        self.horizontalWidget.setObjectName("horizontalWidget")
        self.horizontalLayout = QtGui.QHBoxLayout(self.horizontalWidget)
        self.horizontalLayout.setContentsMargins(0, 0, 0, 0)
        self.horizontalLayout.setObjectName("horizontalLayout")
        spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
        self.horizontalLayout.addItem(spacerItem)
        self.selectNone_pushButton = QtGui.QPushButton(self.horizontalWidget)
        self.selectNone_pushButton.setObjectName("selectNone_pushButton")
        self.horizontalLayout.addWidget(self.selectNone_pushButton)
        self.selectAll_pushButton = QtGui.QPushButton(self.horizontalWidget)
        self.selectAll_pushButton.setObjectName("selectAll_pushButton")
        self.horizontalLayout.addWidget(self.selectAll_pushButton)
        self.update_pushButton = QtGui.QPushButton(self.horizontalWidget)
        self.update_pushButton.setObjectName("update_pushButton")
        self.horizontalLayout.addWidget(self.update_pushButton)
        self.cancel_pushButton = QtGui.QPushButton(self.horizontalWidget)
        self.cancel_pushButton.setObjectName("cancel_pushButton")
        self.horizontalLayout.addWidget(self.cancel_pushButton)
        self.verticalLayout.addWidget(self.horizontalWidget)

        self.retranslateUi(Dialog)
        QtCore.QMetaObject.connectSlotsByName(Dialog) 
Example #3
Source File: treepanel.py    From LCInterlocking with GNU Lesser General Public License v2.1 4 votes vote down vote up
def __init__(self, title, obj_join = None): #none to be removed
        self.form = []
        self.obj_join = obj_join
        self.parts = self.obj_join.parts
        if hasattr(self.obj_join, "faces"):
            self.faces = self.obj_join.faces
        else:
            self.faces = PropertiesList()

        if title != "Crosspiece":
            self.partsList = PartsList(Part, self.parts)
        else:
            self.partsList = PartsList(CrossPartWidget, self.parts)
        self.tabsList = TabsList(self.faces)

        self.params_widget = None
        if self.params_widget:
            self.form.append(self.params_widget)
        self.hide_button = None
        self.show_button = None
        self.reset_transparency_button = None
        self.set_transparency_button = None
        self.active_document = self.obj_join.Document#FreeCAD.ActiveDocument
        self.tree_widget = QtGui.QWidget()
        self.tree_widget.setObjectName("TreePanel")
        self.tree_widget.setWindowTitle(title)
        self.tree_vbox = QtGui.QVBoxLayout(self.tree_widget)
        self.form.append(self.tree_widget)
        self.model = TreeModel()
        self.tree_view_widget = QtGui.QTreeView()
        self.tree_view_widget.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection)
        self.tree_view_widget.setModel(self.model)
        self.tree_view_widget.setFixedHeight(250)
        self.selection_model = None
        self.tab_type_box = None
        self.edited_items = []
        self.edit_items_layout = None
        self.init_tree_widget()
        self.preview_doc = None
        self.show_other_state_checkbox = None
        self.other_object_list = []
        self.save_initial_objects()

        for item in self.parts:
            self.model.append_part(item.name, item.label, bool(item.link_name))

        for item in self.faces:
            self.model.append_tab(item.freecad_obj_name, item.tab_name, item.face_name, bool(item.link_name))