def set_components(self):
        """
        Sets the Components Model nodes.
        """

        node_flags = attributes_flags = int(Qt.ItemIsSelectable | Qt.ItemIsEnabled)

        root_node = umbra.ui.nodes.DefaultNode(name="InvisibleRootNode")

        paths = {}
        for path in self.__engine.components_manager.paths:
            basename = os.path.basename(path)
            if not paths.get(basename):
                paths[basename] = {}

            paths[basename].update(dict((name, component)
                                        for (name, component) in self.__engine.components_manager
                                        if basename == os.path.basename(os.path.dirname(component.directory))))

        for path, components in paths.iteritems():
            path_node = PathNode(name=path.title(),
                                 parent=root_node,
                                 node_flags=node_flags,
                                 attributes_flags=attributes_flags)

            for component in components.itervalues():
                if not component.interface:
                    continue

                component_node = ComponentNode(component,
                                               name=component.title,
                                               parent=path_node,
                                               node_flags=node_flags,
                                               attributes_flags=attributes_flags,
                                               activated=umbra.ui.nodes.GraphModelAttribute(name="activated",
                                                                                            flags=attributes_flags,
                                                                                            roles={
                                                                                            Qt.DisplayRole: foundations.strings.to_string(
                                                                                                component.interface.activated),
                                                                                            Qt.DecorationRole: os.path.join(
                                                                                                self.__ui_resources_directory,
                                                                                                component.interface.activated and
                                                                                                self.__ui_activated_image or self.__ui_deactivated_image)}))
                component_node.roles[Qt.DecorationRole] = os.path.join(self.__ui_resources_directory,
                                                                       "{0}{1}".format(component.category,
                                                                                       self.__ui_category_affixe))

        root_node.sort_children()

        self.__model.initialize_model(root_node)
        return True
def set_components ( self ) : node_flags = attributes_flags = int ( Qt . ItemIsSelectable | Qt . ItemIsEnabled ) root_node = umbra . ui . nodes . DefaultNode ( name = "InvisibleRootNode" ) paths = { } for path in self . __engine . components_manager . paths : basename = os . path . basename ( path ) if not paths . get ( basename ) : paths [ basename ] = { } paths [ basename ] . update ( dict ( ( name , component ) for ( name , component ) in self . __engine . components_manager if basename == os . path . basename ( os . path . dirname ( component . directory ) ) ) ) for path , components in paths . iteritems ( ) : path_node = PathNode ( name = path . title ( ) , parent = root_node , node_flags = node_flags , attributes_flags = attributes_flags ) for component in components . itervalues ( ) : if not component . interface : continue component_node = ComponentNode ( component , name = component . title , parent = path_node , node_flags = node_flags , attributes_flags = attributes_flags , activated = umbra . ui . nodes . GraphModelAttribute ( name = "activated" , flags = attributes_flags , roles = { Qt . DisplayRole : foundations . strings . to_string ( component . interface . activated ) , Qt . DecorationRole : os . path . join ( self . __ui_resources_directory , component . interface . activated and self . __ui_activated_image or self . __ui_deactivated_image ) } ) ) component_node . roles [ Qt . DecorationRole ] = os . path . join ( self . __ui_resources_directory , "{0}{1}" . format ( component . category , self . __ui_category_affixe ) ) root_node . sort_children ( ) self . __model . initialize_model ( root_node ) return True
Sets the Components Model nodes.