Exemplo n.º 1
0
    def add_items(self, items):

        self.beginResetModel()

        # Collect the assets per look name (from the items of the AssetModel)
        look_subsets = defaultdict(list)
        for asset_item in items:
            asset = asset_item["asset"]
            for look in asset_item["loadedLooks"]:
                key = (look["name"], look["No."])
                look_subsets[key].append(asset)

        for (subset, num), assets in sorted(look_subsets.iteritems()):

            # Define nice label without "look" prefix for readability
            label = subset if not subset.startswith("look") else subset[4:]

            item_node = model.Node()
            item_node["label"] = label
            item_node["subset"] = subset
            item_node["No."] = num

            # Amount of matching assets for this look
            item_node["match"] = len(assets)

            # Store the assets that have this subset available
            item_node["assets"] = assets

            self.add_child(item_node)

        self.endResetModel()
Exemplo n.º 2
0
    def add_items(self, items):
        """
        Add items to model with needed data
        Args:
            items(list): collection of item data

        Returns:
            None
        """

        self.beginResetModel()

        subsets = defaultdict(list)
        for item in items:
            subsets[item["subset"]].append(item)

        for subset, assets in sorted(subsets.iteritems()):
            item_node = model.Node()
            count = len(assets)
            item_node["version"] = {
                asset["asset"]: asset["version"]
                for asset in assets
            }

            item_node["subset"] = subset
            item_node["match"] = count
            item_node["assets"] = [asset["asset"] for asset in assets]

            self.add_child(item_node)

        self.endResetModel()
Exemplo n.º 3
0
    def add_items(self, items):
        """Add items to model with needed data

        An item exists of:
            {
                "subset": 'name of subset',
                "asset": asset_document
            }

        Args:
            items(list): collection of item data

        Returns:
            None
        """

        self.beginResetModel()

        for item in items:

            node = model.Node(data={"icon": "cube"})
            node.update(item)

            self.add_child(node)

        self.endResetModel()
Exemplo n.º 4
0
    def add_items(self, items):
        """
        Add items to model with needed data
        Args:
            items(list): collection of item data

        Returns:
            None
        """

        self.beginResetModel()

        # Add the items sorted by label
        sorter = (lambda x: x["label"])

        for item in sorted(items, key=sorter):

            asset_item = model.Node()
            asset_item.update(item)
            asset_item["icon"] = "folder"

            # Add namespace children
            namespaces = item["namespaces"]
            for namespace in sorted(namespaces):
                child = model.Node()
                child.update(item)
                child.update({
                    "label": (namespace if namespace != ":"
                              else "(no namespace)"),
                    "subset": item["subsets"][namespace],
                    "namespace": namespace,
                    "looks": item["looks"],
                    "icon": "file-o"
                })
                asset_item.add_child(child)

            self.add_child(asset_item)

        self.endResetModel()
Exemplo n.º 5
0
    def add_items(self, items):
        """Add items to model with needed data

        An item exists of:
            {
                "subset": 'name of subset',
                "asset": asset_document
            }

        Args:
            items(list): collection of item data

        Returns:
            None
        """

        self.beginResetModel()

        # Collect the assets per look name (from the items of the AssetModel)
        look_subsets = defaultdict(list)
        for asset_item in items:
            asset = asset_item["asset"]
            for look in asset_item["looks"]:
                key = (look["name"], look["version"])
                look_subsets[key].append(asset)

        for (subset, version), assets in sorted(look_subsets.iteritems()):

            # Define nice label without "look" prefix for readability
            label = subset if not subset.startswith("look") else subset[4:]

            item_node = model.Node()
            item_node["label"] = label
            item_node["subset"] = subset
            item_node["version"] = str(version)

            # Amount of matching assets for this look
            item_node["match"] = len(assets)

            # Store the assets that have this subset available
            item_node["assets"] = assets

            self.add_child(item_node)

        self.endResetModel()
Exemplo n.º 6
0
    def add_items(self, items):
        """
        Add items to model with needed data
        Args:
            items(list): collection of item data

        Returns:
            None
        """

        self.beginResetModel()

        for item in items:
            item_node = model.Node()
            item_node.update(item)
            self.add_child(item_node)

        self.endResetModel()
Exemplo n.º 7
0
    def add_items(self, items):
        """
        Add items to model with needed data
        Args:
            items(list): collection of item data

        Returns:
            None
        """

        self.beginResetModel()

        # Add the items sorted by label
        sorter = lambda x: x["label"]

        for item in sorted(items, key=sorter):

            asset_item = model.Node(data={"icon": "scissors"})
            asset_item.update(item)

            self.add_child(asset_item)

        self.endResetModel()