예제 #1
0
    def insertProperties(self, parent, data, parentData, subtitle):
        """
        Recursively add property Items to the tree
        """
        """
        Parent is the parent node
        
        Data is the property data for this node
        
        parentData is the dictionary containing Data
        
        Subtitle is the name of the parent node, if the parent node
        was a Lua table like 'anchor_point' as opposed to a value
        like 'x'.
        """

        for p in PropertyIter(subtitle):

            if not data.has_key(p):
                continue

            name, value, isSimple = dataToModel(p, data[p])

            # The value of this property... editable
            valueNode = TrickplayElement()

            # Reference to the UI Element data
            valueNode.setTPJSON(parentData)

            # The name of this property... not editable
            nameNode = valueNode.partner()
            nameNode.setData(name, Qt.DisplayRole)
            nameNode.setFlags(nameNode.flags() ^ Qt.ItemIsEditable)

            if subtitle:
                valueNode.setData(subtitle, Qt.Subtitle)
            else:
                valueNode.setData('', Qt.Subtitle)

            # A simple value, like int or string
            if isSimple:
                valueNode.setData(value, Qt.DisplayRole)
                parent.appendRow([nameNode, valueNode])

            # A dictionary value
            else:
                summary = summarize(value, p)
                valueNode.setData(summary, Qt.DisplayRole)
                valueNode.setFlags(Qt.NoItemFlags)
                parent.appendRow([nameNode, valueNode])
                self.insertProperties(nameNode, value, data, p)

            if name in NOT_EDITABLE or (subtitle and subtitle in NOT_EDITABLE):
                valueNode.setFlags(Qt.NoItemFlags)
예제 #2
0
    def insertElement(self, parent, data, parentData, screen):
        """
        Recursively add UI Elements to the tree
        """
        """
        Parent is the parent node
        
        Data is the property data for this node
        ParentData is a reference to the dictionary containing data
        """

        value = data["name"]
        title = data["type"]
        gid = data['gid']

        if "Texture" == title:
            title = "Image"

        # Set the name node to gid + name
        if '' != value:
            gs = str(gid)
            l = len(gs)
            value = gs + ' ' * 2 * (6 - l) + value
        else:
            value = str(gid)

        node = TrickplayElement(title)
        self.node = node
        node.setTPJSON(data)
        node.setTPParent(parentData)
        node.setFlags(node.flags() ^ Qt.ItemIsEditable)

        # Add a checkbox for everything but screen
        if not screen:

            node.setCheckable(True)

            checkState = Qt.Unchecked
            if data['is_visible']:
                checkState = Qt.Checked

            node.setCheckState(checkState)

        # Screen has no is_visible property because changing it
        # causes problems with key presses in the app
        else:
            del (data['is_visible'])

        partner = node.partner()
        partner.setFlags(partner.flags() ^ Qt.ItemIsEditable)
        partner.setData(value, Qt.DisplayRole)

        parent.appendRow([node, partner])

        # Recurse through children
        try:
            children = data['children']
            for i in range(len(children) - 1, -1, -1):
                self.insertElement(node, children[i], data, False)

        # Element has no children
        except KeyError:
            pass
예제 #3
0
    def insertProperties(self, parent, data, parentData, subtitle):
        """
        Recursively add property Items to the tree
        """

        """
        Parent is the parent node
        
        Data is the property data for this node
        
        parentData is the dictionary containing Data
        
        Subtitle is the name of the parent node, if the parent node
        was a Lua table like 'anchor_point' as opposed to a value
        like 'x'.
        """
        
        for p in PropertyIter(subtitle):
            
            if not data.has_key(p):
                continue
            
            name, value, isSimple = dataToModel(p, data[p])
            
            # The value of this property... editable
            valueNode = TrickplayElement()
            
            # Reference to the UI Element data
            valueNode.setTPJSON(parentData)
            
            # The name of this property... not editable
            nameNode = valueNode.partner()
            nameNode.setData(name, Qt.DisplayRole)
            nameNode.setFlags(nameNode.flags() ^ Qt.ItemIsEditable)
            
            if subtitle:
                valueNode.setData(subtitle, Qt.Subtitle)
            else:
                valueNode.setData('', Qt.Subtitle)
            
            # A simple value, like int or string
            if isSimple:
                valueNode.setData(value, Qt.DisplayRole)
                parent.appendRow([nameNode, valueNode])
            
            # A dictionary value
            else:
                summary = summarize(value, p)
                valueNode.setData(summary, Qt.DisplayRole)
                valueNode.setFlags(Qt.NoItemFlags)
                parent.appendRow([nameNode, valueNode])
                self.insertProperties(nameNode, value, data, p)
                
            if name in NOT_EDITABLE or (subtitle and subtitle in NOT_EDITABLE):
                valueNode.setFlags(Qt.NoItemFlags)
예제 #4
0
    def insertElement(self, parent, data, parentData, screen):
        """
        Recursively add UI Elements to the tree
        """

        """
        Parent is the parent node
        
        Data is the property data for this node
        ParentData is a reference to the dictionary containing data
        """
        
        value = data["name"]
        title = data["type"]
        gid = data['gid']
        
        if "Texture" == title:
            title = "Image"
            
        # Set the name node to gid + name
        if '' != value:   
            gs = str(gid)
            l = len(gs)
            value =  gs + ' ' * 2 * (6 - l) + value 
        else:    
            value = str(gid)
        
        node = TrickplayElement(title)
        self.node = node
        node.setTPJSON(data)
        node.setTPParent(parentData)
        node.setFlags(node.flags() ^ Qt.ItemIsEditable)

        # Add a checkbox for everything but screen
        if not screen:
            
            node.setCheckable(True)
            
            checkState = Qt.Unchecked
            if data['is_visible']:
                checkState = Qt.Checked
            
            node.setCheckState(checkState)
        
        # Screen has no is_visible property because changing it
        # causes problems with key presses in the app
        else:    
            del(data['is_visible'])
        
        partner = node.partner()
        partner.setFlags(partner.flags() ^ Qt.ItemIsEditable)
        partner.setData(value, Qt.DisplayRole)
        
        parent.appendRow([node, partner])
        
        # Recurse through children
        try:
            children = data['children']
            for i in range(len(children)-1, -1, -1):
                self.insertElement(node, children[i], data, False)
        
        # Element has no children
        except KeyError:
            pass