def createEditor( self, parent, option, index ): """ Aca se crean los widgets para edición """ if index.column() == CANTIDAD: spinbox = QSpinBox( parent ) spinbox.setRange( 1, 1000 ) spinbox.setSingleStep( 1 ) spinbox.setAlignment( Qt.AlignRight | Qt.AlignVCenter ) return spinbox elif index.column() == DESCRIPCION : # if index.data() != "": # self.prods.items.append( [ index.model().data( index.model().index( index.row(), 0 ) ) , index.data().toString()] ) self.proxymodel.setSourceModel( self.prods ) model = index.model() current = model.index( index.row(), IDARTICULO ).data() self.proxymodel.setFilterRegExp( self.filter( model, current ) ) sp = super( EntradaCompraDelegate, self ).createEditor( parent, option, index ) return sp elif index.column() == TOTALPROD: return None elif index.column() in ( PRECIO, PRECIOD ): spinbox = QDoubleSpinBox( parent ) spinbox.setRange( 0, 10000 ) spinbox.setDecimals( 4 ) spinbox.setSingleStep( 1 ) spinbox.setAlignment( Qt.AlignRight | Qt.AlignVCenter ) return spinbox else: return super( EntradaCompraDelegate, self ).createEditor( parent, option, index )
def createEditor( self, parent, options, index, ): setting = index.model().data(index, Qt.UserRole) if setting.valuetype == Setting.FOLDER: return FileDirectorySelector(parent) elif setting.valuetype == Setting.FILE: return FileDirectorySelector(parent, True) elif setting.valuetype == Setting.SELECTION: combo = QComboBox(parent) combo.addItems(setting.options) return combo else: value = self.convertValue(index.model().data(index, Qt.EditRole)) if isinstance(value, (int, long)): spnBox = QSpinBox(parent) spnBox.setRange(-999999999, 999999999) return spnBox elif isinstance(value, float): spnBox = QDoubleSpinBox(parent) spnBox.setRange(-999999999.999999, 999999999.999999) spnBox.setDecimals(6) return spnBox elif isinstance(value, (str, unicode)): return QLineEdit(parent)
def __get_widget_for_primitive_types(self, key, value): """ return right widget and connect the value with config_manager :param key: :param value: :return: """ if key in self.dropdownboxes.keys(): atomic_widget = self._create_dropdownbox(key,value) self.config.add_handler(key, atomic_widget) elif key in self.radiobuttons.keys(): atomic_widget = self._create_radiobutton(key,value) self.config.add_handler(key, atomic_widget) elif type(value) is int: atomic_widget = QSpinBox() atomic_widget.setRange(-100000, 100000) self.config.add_handler(key, atomic_widget) elif type(value) is float: atomic_widget = QDoubleSpinBox() atomic_widget.setDecimals(6) atomic_widget.setMaximum(1000000000) self.config.add_handler(key, atomic_widget) elif type(value) is str: atomic_widget = QLineEdit() self.config.add_handler(key, atomic_widget) elif type(value) is bool: atomic_widget = QCheckBox() self.config.add_handler(key, atomic_widget) else: return None return atomic_widget
def createEditor(self, parent, option, index): if index.column() == CANTIDAD: max_items = index.model().lines[index.row()].existencia if max_items < 1: return None spinbox = QSpinBox(parent) spinbox.setRange(1, max_items) spinbox.setSingleStep(1) spinbox.setAlignment(Qt.AlignRight | Qt.AlignVCenter) return spinbox elif index.column() == DESCRIPCION: if self.articles.rowCount() > 0: self.proxymodel.setSourceModel(self.articles) model = index.model() current = model.index(index.row(), IDARTICULOEX).data() self.proxymodel.setFilterRegExp(self.filter(model, current)) sp = super(FacturaDelegate, self).createEditor(parent, option, index) # sp.setColumnHidden( IDBODEGAEX ) # sp.setColumnHidden( IDARTICULOEX ) return sp elif index.column() == TOTALPROD: return None elif index.column() == PRECIO: spinbox = QDoubleSpinBox(parent) spinbox.setRange(0.0001, 10000) spinbox.setDecimals(4) spinbox.setSingleStep(1) spinbox.setAlignment(Qt.AlignRight | Qt.AlignVCenter) return spinbox else: super(FacturaDelegate, self).createEditor(parent, option, index)
def createEditor( self, parent, option, index ): if index.column() == CANTIDAD: max_items = index.model().lines[index.row()].existencia if max_items < 1 : return None spinbox = QSpinBox( parent ) spinbox.setRange( 0, max_items ) spinbox.setSingleStep( 1 ) spinbox.setAlignment( Qt.AlignRight | Qt.AlignVCenter ) return spinbox elif index.column() == DESCRIPCION : if self.articles.rowCount() > 0: self.proxymodel.setSourceModel( self.articles ) model = index.model() current = model.index( index.row(), IDARTICULOEX ).data() self.proxymodel.setFilterRegExp( self.filter( model , current ) ) sp = super( FacturaDelegate, self ).createEditor( parent, option, index ) #sp.setColumnHidden( IDBODEGAEX ) #sp.setColumnHidden( IDARTICULOEX ) return sp elif index.column() == TOTALPROD: return None elif index.column() == PRECIO: spinbox = QDoubleSpinBox( parent ) spinbox.setRange( 0.0001, 10000 ) spinbox.setDecimals( 4 ) spinbox.setSingleStep( 1 ) spinbox.setAlignment( Qt.AlignRight | Qt.AlignVCenter ) return spinbox else: super( FacturaDelegate, self ).createEditor( parent, option, index )
def createEditor( self, parent, option, index ): if index.column() == CANTIDAD: spinbox = QSpinBox( parent ) spinbox.setRange( 1, 1000 ) spinbox.setSingleStep( 1 ) spinbox.setAlignment( Qt.AlignRight | Qt.AlignVCenter ) return spinbox elif index .column() == COSTOUNIT: spinbox = QDoubleSpinBox( parent ) spinbox.setRange( 0.0001, 100000 ) spinbox.setDecimals( 4 ) spinbox.setSingleStep( 1 ) spinbox.setAlignment( Qt.AlignRight | Qt.AlignVCenter ) return spinbox elif index.column() in ( IDARTICULO, ARTICULO ): self.proxymodel.setSourceModel( self.prods ) current = index.model().data( index.model().index( index.row(), IDARTICULO ) ) self.proxymodel.setFilterRegExp( self.filter( index.model(), current ) ) sp = super( LiquidacionDelegate, self ).createEditor( parent, option, index ) sp.setColumnHidden( IDARTICULO ) sp.setMinimumWidth( 600 ) return sp else: super( LiquidacionDelegate, self ).createEditor( parent, option, index )
def createEditor(self, parent, options, index): value = self.convertValue(index.model().data(index, Qt.EditRole)) if isinstance(value, (int, long)): spnBox = QSpinBox(parent) spnBox.setRange(-999999999, 999999999) return spnBox elif isinstance(value, float): spnBox = QDoubleSpinBox(parent) spnBox.setRange(-999999999.999999, 999999999.999999) spnBox.setDecimals(6) return spnBox elif isinstance(value, (str, unicode)): if os.path.isdir(value): return FileDirectorySelector(parent) elif os.path.isfile(value): return FileDirectorySelector(parent, True) else: return FileDirectorySelector(parent, True)
def createEditor( self, parent, options, index, ): value = self.convertValue(index.model().data(index, Qt.EditRole)) if isinstance(value, (int, long)): spnBox = QSpinBox(parent) spnBox.setRange(-999999999, 999999999) return spnBox elif isinstance(value, float): spnBox = QDoubleSpinBox(parent) spnBox.setRange(-999999999.999999, 999999999.999999) spnBox.setDecimals(6) return spnBox elif isinstance(value, (str, unicode)): valuetype = self.convertValue(index.model().data(index, Qt.UserRole)) if valuetype == Setting.FOLDER: return FileDirectorySelector(parent) else: return FileDirectorySelector(parent, True)