(self, saved)
return model
Load a preprocessor list from a dict.
Load a preprocessor list from a dict.
Load a preprocessor list from a dict .
def load(self, saved):
        """Load a preprocessor list from a dict."""
        preprocessors = saved.get("preprocessors", [])
        model = StandardItemModel()

        def dropMimeData(data, action, row, _column, _parent):
            if data.hasFormat("application/x-qwidget-ref") and \
                    action == Qt.CopyAction:
                qname = bytes(data.data("application/x-qwidget-ref")).decode()

                ppdef = self._qname2ppdef[qname]
                item = QStandardItem(ppdef.description.title)
                item.setData({}, ParametersRole)
                item.setData(ppdef.description.title, Qt.DisplayRole)
                item.setData(ppdef, DescriptionRole)
                self.preprocessormodel.insertRow(row, [item])
                return True
            else:
                return False

        model.dropMimeData = dropMimeData

        for qualname, params in preprocessors:
            pp_def = self._qname2ppdef[qualname]
            description = pp_def.description
            item = QStandardItem(description.title)
            if description.icon:
                icon = QIcon(description.icon)
            else:
                icon = QIcon()
            item.setIcon(icon)
            item.setToolTip(description.summary)
            item.setData(pp_def, DescriptionRole)
            item.setData(params, ParametersRole)

            model.appendRow(item)
        return model
def load ( self , saved ) : preprocessors = saved . get ( "preprocessors" , [ ] ) model = StandardItemModel ( ) def dropMimeData ( data , action , row , _column , _parent ) : if data . hasFormat ( "application/x-qwidget-ref" ) and action == Qt . CopyAction : qname = bytes ( data . data ( "application/x-qwidget-ref" ) ) . decode ( ) ppdef = self . _qname2ppdef [ qname ] item = QStandardItem ( ppdef . description . title ) item . setData ( { } , ParametersRole ) item . setData ( ppdef . description . title , Qt . DisplayRole ) item . setData ( ppdef , DescriptionRole ) self . preprocessormodel . insertRow ( row , [ item ] ) return True else : return False model . dropMimeData = dropMimeData for qualname , params in preprocessors : pp_def = self . _qname2ppdef [ qualname ] description = pp_def . description item = QStandardItem ( description . title ) if description . icon : icon = QIcon ( description . icon ) else : icon = QIcon ( ) item . setIcon ( icon ) item . setToolTip ( description . summary ) item . setData ( pp_def , DescriptionRole ) item . setData ( params , ParametersRole ) model . appendRow ( item ) return model