예제 #1
0
    def toItem(self, animation):
        animIcon = get_config().get("PLUGIN", "defaultAnimationIcon")
        actorIcon = get_config().get("PLUGIN", "defaultActorIcon")

        item = None

        if animation.actorsCount() > 1:
            animItem = create_item(animation.name(), animIcon)
            item = animItem

            i = 1
            for actor, stages in animation.actors.items():
                actorItem = create_item("Actor " + str(i), actorIcon)
                self.addNestedChild(animItem, actorItem)
                i += 1

                j = 1
                for stage in stages:
                    self.addNestedChild(actorItem,
                                        stage.toItem("Stage " + str(j)))
                    j += 1
        else:
            for actor, stages in animation.actors.items():

                if len(stages) > 1:
                    animItem = create_item(animation.name(), animIcon)
                    item = animItem

                    for j, stage in enumerate(stages):
                        self.addNestedChild(
                            animItem, stage.toItem("Stage " + str(j + 1)))
                else:
                    for stage in stages:
                        item = stage.toItem()
        return item
예제 #2
0
    def action_insertParent(self):
        log.info("ACTION : Inserting parent")
        items = self.selectedItems()
        newParent = create_item("New Item")

        # We want the lowest parent (Meaning the parent the most close to the root)
        items_parent = []
        for item in items:
            if item in items_parent:
                items_parent.clear()

            item_parent = item.parent()
            if not item_parent:
                item_parent = self.invisibleRootItem()

            if not item_parent in items:
                items_parent.append((item_parent, item))

        parent, item = items_parent[0]

        index = parent.indexOfChild(item)
        parent.insertChild(index, newParent)

        for item in items:
            item_parent = item.parent()
            if not item_parent:
                item_parent = self.invisibleRootItem()

            item_index = item_parent.indexOfChild(item)
            child = item_parent.takeChild(item_index)
            newParent.addChild(child)
        return
예제 #3
0
    def toItem(self, name=""):
        if not name:
            name = self.name()

        item = create_item(name,
                           get_config().get("PLUGIN", "defaultStageIcon"),
                           self.id)

        return item
예제 #4
0
    def insertSet(self, item, index=-1):
        if index == -1:
            index = self.nextSetIndex(item)

        setIcon = get_config().get("PLUGIN", "defaultSetIcon")
        set = create_item("Set " + str(index + 1), setIcon, "", ITEM_TYPE.SET)
        item.insertChild(index, set)
        item.setText(6, str(int(item.text(6)) + 1))
        self.setNextSetIndex(item, index + 1)
        return set
예제 #5
0
    def addPackages(self, packages):

        for packageName, package in packages.items():

            packageIcon = get_config().get("PLUGIN", "defaultPackageIcon")
            packageItem = create_item(packageName, packageIcon)

            for moduleName, module in package.modules.items():

                moduleIcon = get_config().get("PLUGIN", "defaultFolderIcon")
                moduleItem = create_item(moduleName, moduleIcon)

                for animationName, animation in module.items():
                    item = self.toItem(animation)
                    if item:
                        self.addNestedChild(moduleItem, item)

                if moduleItem.childCount():
                    self.addNestedChild(packageItem, moduleItem)

            if packageItem.childCount():
                self.addNestedChild(self.invisibleRootItem(), packageItem)

        return
예제 #6
0
    def addXMLChild(self, parent, elt, animations):
        duplicateCounter = 0
        for child in elt:
            name = child.get("n")
            icon = child.get("i") or get_config().get("PLUGIN",
                                                      "defaultFolderIcon")
            id = child.get("id")
            if not id:
                id = ""

            if id in animations:
                duplicateCounter += 1
                log.info("Duplicate found : " + child.get("n"))
            else:
                item = create_item(name, icon, id)
                parent.addChild(item)
                duplicateCounter += self.addXMLChild(item, child, animations)
        return duplicateCounter