def editorValue(self, editor): """ Returns the value from the editor for this widget. :param editor | <QWidget> || None :return <variant> value """ value, success = projexui.widgetValue(editor) if not success: return None return value
def validatePage(self): """ Validates the page against the scaffold information, setting the values along the way. """ widgets = self.propertyWidgetMap() failed = '' for prop, widget in widgets.items(): val, success = projexui.widgetValue(widget) if success: # ensure we have the required values if not val and not (prop.type == 'bool' and val is False): if prop.default: val = prop.default elif prop.required: msg = '{0} is a required value'.format(prop.label) failed = msg break # ensure the values match the required expression elif prop.regex and not re.match(prop.regex, nativestring(val)): msg = '{0} needs to be in the format {1}'.format( prop.label, prop.regex) failed = msg break prop.value = val else: msg = 'Failed to get a proper value for {0}'.format(prop.label) failed = msg break if failed: QtGui.QMessageBox.warning(None, 'Properties Failed', failed) return False return True
def validatePage(self): """ Validates the page against the scaffold information, setting the values along the way. """ widgets = self.propertyWidgetMap() failed = '' for prop, widget in widgets.items(): val, success = projexui.widgetValue(widget) if success: # ensure we have the required values if not val and not (prop.type == 'bool' and val is False): if prop.default: val = prop.default elif prop.required: msg = '{0} is a required value'.format(prop.label) failed = msg break # ensure the values match the required expression elif prop.regex and not re.match(prop.regex, nativestring(val)): msg = '{0} needs to be in the format {1}'.format(prop.label, prop.regex) failed = msg break prop.value = val else: msg = 'Failed to get a proper value for {0}'.format(prop.label) failed = msg break if failed: QtGui.QMessageBox.warning(None, 'Properties Failed', failed) return False return True
def save( self ): """ Saves the ui information to the data for this widget's data set. :return <bool> saved """ dataSet = self.dataSet() if ( not dataSet ): return True # lookup widgets based on the data set information for widget in self.findChildren(QWidget): prop = unwrapVariant(widget.property('dataName')) if prop is None: continue # update the data for the dataset value, success = projexui.widgetValue(widget) if not success: continue dataSet.setValue(prop, value) return self.plugin().save()
def saveValues(self): """ Generates a dictionary of values from the widgets in this editor that will be used to save the values on its record. :return {<str> columnName: <variant> value, ..} """ output = {} for widget in self.findChildren(QWidget): prop = widget.property('columnName') if not prop: continue columnName = str(unwrapVariant(prop, '')) if (not columnName): continue value, success = projexui.widgetValue(widget) if (not success): continue # convert from values to standard python values if (isinstance(value, QDateTime)): value = value.toPyDateTime() elif (isinstance(value, QDate)): value = value.toPyDate() elif (isinstance(value, QTime)): value = value.toPyTime() elif (type(value).__name__ == 'QString'): value = str(value) output[columnName] = value return output
def saveValues(self): """ Generates a dictionary of values from the widgets in this editor that will be used to save the values on its record. :return {<str> columnName: <variant> value, ..} """ output = {} for widget in self.findChildren(QWidget): prop = widget.property('columnName') if not prop: continue columnName = nativestring(unwrapVariant(prop, '')) if ( not columnName ): continue value, success = projexui.widgetValue(widget) if ( not success ): continue # convert from values to standard python values if ( isinstance(value, QDateTime) ): value = value.toPyDateTime() elif ( isinstance(value, QDate) ): value = value.toPyDate() elif ( isinstance(value, QTime) ): value = value.toPyTime() elif ( type(value).__name__ == 'QString' ): value = nativestring(value) output[columnName] = value return output