QAction factory. All items created belong to the calling instance, i.e. created QAction parent is self.
425817
def _create_action(
            self,
            icon_name: Optional[str],
            title: str,
            slot_function: Callable[[None], None],
            tool_tip: Optional[str]=None)-> QAction:
        
        action = QAction(title, self)
        if icon_name:
            action.setIcon(QIcon.fromTheme(icon_name))
        action.triggered.connect(slot_function)
        if tool_tip:
            action.setToolTip(tool_tip)
        return action
178585
def _create_action(factory_self, action_model, resource_name,
                       service_context, is_load=False):
        
        # Create the action in in this closure but before the ``do_action``
        # method below is invoked, which allows instances of the resource
        # to share the ServiceAction instance.
        action = AIOServiceAction(
            action_model, factory=factory_self,
            service_context=service_context
        )

        # A resource's ``load`` method is special because it sets
        # values on the resource instead of returning the response.
        if is_load:
            # We need a new method here because we want access to the
            # instance via ``self``.
            async def do_action(self, *args, **kwargs):
                # response = action(self, *args, **kwargs)
                response = await action.async_call(self, *args, **kwargs)
                self.meta.data = response

            # Create the docstring for the load/reload mehtods.
            lazy_docstring = docstring.LoadReloadDocstring(
                action_name=action_model.name,
                resource_name=resource_name,
                event_emitter=factory_self._emitter,
                load_model=action_model,
                service_model=service_context.service_model,
                include_signature=False
            )
        else:
            # We need a new method here because we want access to the
            # instance via ``self``.
            async def do_action(self, *args, **kwargs):
                response = await action.async_call(self, *args, **kwargs)

                if hasattr(self, 'load'):
                    # Clear cached data. It will be reloaded the next
                    # time that an attribute is accessed.
                    # TODO: Make this configurable in the future?
                    self.meta.data = None

                return response

            lazy_docstring = docstring.ActionDocstring(
                resource_name=resource_name,
                event_emitter=factory_self._emitter,
                action_model=action_model,
                service_model=service_context.service_model,
                include_signature=False
            )

        do_action.__name__ = str(action_model.name)
        do_action.__doc__ = lazy_docstring
        return do_action
1236285
def instantiate(self, **extra_args):
        
        input_block = self.input_block.instantiate()
        backbone = self.backbone.instantiate(**extra_args)

        return QModel(input_block, backbone, extra_args['action_space'])
860297
def instantiate(self, **extra_args):
        
        input_block = self.input_block.instantiate()
        backbone = self.backbone.instantiate(**extra_args)

        return QDuelingModel(input_block, backbone, extra_args['action_space'])
1062265
def create_for_object(self, parent_object, slot, role='m', title=None):
        
        from .db import Placeholder
        parent_attrs = get_parent_lookup_kwargs(parent_object)
        obj = self.create(
            slot=slot,
            role=role or Placeholder.MAIN,
            title=title or slot.title().replace('_', ' '),
            **parent_attrs
        )
        obj.parent = parent_object  # fill the reverse cache
        return obj
1172268
def add_parent(sender, instance, **kwargs):
    
    if not kwargs['created']:
        return
    for att in ['task', 'context']:
        parent = getattr(instance, att).item_id
        child = instance.item_id
        ItemRelation.objects.get_or_create(
            parent_id=parent,
            child_id=child,
            visible=True,
        )
956892
def create_action_from_dict(name, spec, base_class=ActionsAction, metaclass=type, pop_keys=False):
    
    actions = load_grouped_actions(spec, pop_keys=pop_keys)
    attrs = {"actions": actions, "name": name}
    if "as" in spec:
        attrs["as_"] = spec["as"]
        if pop_keys:
            del spec["as"]
    for k in ("requires", "methods", "defaults", "default_option"):
        if k in spec:
            attrs[k] = spec[k]
            if pop_keys:
                del spec[k]
    return metaclass(name, (base_class,), attrs)
1080296
def after_create(record)
      if record.riaction_log_event?(@event_name) && !record.class.riactionless?
        Resque.enqueue(::Riaction::EventPerformer, @event_name, record.class.base_class.to_s, record.id)
      end
    end
910631
def parent(self, index):
        

        if not index.isValid():
            return QModelIndex()

        node = self.get_node(index)
        parent_node = node.parent
        if not parent_node:
            return QModelIndex()

        if parent_node == self.__root_node:
            return QModelIndex()

        row = parent_node.row()
        return self.createIndex(row, 0, parent_node) if row is not None else QModelIndex()
959695
def get_action(self, parent, undo_stack: QUndoStack, sel_range, groups,
                   view: int) -> QUndoCommand:
        
        raise NotImplementedError("Abstract Method.")
1325839
def parent(self, parent):
        
        self._parent = parent
        self.graph.add(
            (self.asNode(), RDF_NAMESPACES.CAPITAINS.parent, parent.asNode())
        )
        parent._add_member(self)
862470
def setup_actions(self):
        
        self.actionOpen.triggered.connect(self.on_open)
        self.actionNew.triggered.connect(self.on_new)
        self.actionSave.triggered.connect(self.on_save)
        self.actionSave_as.triggered.connect(self.on_save_as)
        self.actionQuit.triggered.connect(QtWidgets.QApplication.instance().quit)
        self.tabWidget.current_changed.connect(
            self.on_current_tab_changed)
        self.actionAbout.triggered.connect(self.on_about)
723906
def _ancestors_or_self(
            self, qname: Union[QualName, bool] = None) -> List[InstanceNode]:
        """"""
        res = [] if qname and self.qual_name != qname else [self]
        return res + self.up()._ancestors(qname)
1063082
def createActionItem( self, key ):
        
        action = self._actions.get(key)
        if ( not action ):
            text = 'Missing Action: %s' % key
            item = QTreeWidgetItem([text])
            ico = projexui.resources.find('img/log/warning.png')
            item.setIcon(0, QIcon(ico))
        else:
            item = QTreeWidgetItem([nativestring(action.text()).replace('&', '')])
            item.setIcon(0, action.icon())
        
        item.setSizeHint(0, QSize(120, 20))
        item.setData(0, Qt.UserRole, wrapVariant(key))
        
        flags = item.flags()
        flags ^= Qt.ItemIsDropEnabled
        item.setFlags(flags)
        
        return item
409709
def create(backbone: ModelFactory, input_block: typing.Optional[ModelFactory]=None):
    
    if input_block is None:
        input_block = IdentityFactory()

    return QStochasticPolicyModelFactory(input_block=input_block, backbone=backbone)
689161
def addAction( self, action ):
        
        if not isinstance(action, QAction):
            action_name = nativestring(action)
            action = QAction(action_name, self)
            action.setObjectName(action_name)
        
        action.setCheckable(True)
        
        if ( not self._actionGroup ):
            self._actionGroup = QActionGroup(self)
            action.setChecked(True)
            
        self._actionGroup.addAction(action)
        self.reset()
        return action
370425
def createOpenAsMenu(self, parent=None):
        
        openAsMenu = QtWidgets.QMenu(parent=parent)
        openAsMenu.setTitle("Open Item As")

        registry = globalRtiRegistry()
        for rtiRegItem in registry.items:
            #rtiRegItem.tryImportClass()
            def createTrigger():
                """Function to create a closure with the regItem"""
                _rtiRegItem = rtiRegItem # keep reference in closure
                return lambda: self.reloadFileOfCurrentItem(_rtiRegItem)

            action = QtWidgets.QAction("{}".format(rtiRegItem.name), self,
                enabled=bool(rtiRegItem.successfullyImported is not False),
                triggered=createTrigger())
            openAsMenu.addAction(action)

        return openAsMenu