Full Documentation

Modules

datadriveninputmask

class datadriveninputmask.DataDrivenInputMask(iface)[source]

Main class for the QGIS plugin

initGui()[source]

Add menu and menu items.

initializeLayer()[source]

Create the mask for the active layer

showInputForm()[source]

Show the mask for the first selected feature in the active layer

unload()[source]

Remove the plugin menu item and icon

ddattribute

Each DdAttribute corresponds to an input widget in the mask or each input widget is based on exactly one DdAttribute.

General rules:

  1. every field has an input widget suitable for its type
  2. no ARRAY typees are supported
  3. supported types are: int4, int8, float, date, boolean, char, varchar, text
  4. foreign keys are represented as comboboxes and are only supported if based on one field (exactly one fk field in the table references exactly one pk field in the referenced table)
  5. the table referenced by a foreign key should have at least one field wit a notNull constraint apart from the primary key. This field will be used as display field in the combobox
  6. if a varchar field is present in a table referenced by a foreign key it is used as display field in the combobox, if there are several the one defined earlier is used
  7. if no varchar field is present any char field is used
  8. if no varchar or char fields are available the pk field is used for display
  9. table inheritance is not covered
  10. if a table’s pk is a fk to another table’s pk the other table’s mask is shown in a second tab
class ddattribute.DdAttribute(table, type, notNull, name, comment, label, min=None, max=None)[source]

abstract super class for all DdAttributes

getLabel()[source]
isTypeChar()[source]
isTypeFloat()[source]
isTypeInt()[source]
setMinMax(min, max)[source]
class ddattribute.DdFkLayerAttribute(table, type, notNull, name, comment, attNum, isPK, default, hasDefault, queryForCbx, label=None)[source]

a DdAttribute for field in a QGIS layer that represents a foreign key

class ddattribute.DdLayerAttribute(table, type, notNull, name, comment, attNum, isPK, isFK, default, hasDefault, length, label=None, min=None, max=None)[source]

a DdAttribute for a field in a QGIS layer

class ddattribute.DdN2mAttribute(relationTable, relatedTable, subType, comment, label, relationFeatureIdField, relationRelatedIdField, relatedIdField, relatedDisplayField, fieldList=[])[source]

a DdAttribute for a n2m relation, subtype can be list, tree or table relationTable and relatedTable are DdTable objects

buildDeleteStatement(relationSchema, relationTable, relationFeatureIdField)[source]
buildDisplayStatement(relationSchema, relationTable, relatedSchema, relatedTable, relationFeatureIdField, relatedIdField, relatedDisplayField, relationRelatedIdField, fieldList)[source]
buildInsertStatement(relationSchema, relationTable, relationFeatureIdField, relationRelatedIdField, fieldList)[source]
setDeleteStatement(deleteStatement=None)[source]
setDisplayStatement(displayStatement=None)[source]
setInsertStatement(insertStatement=None)[source]
class ddattribute.DdPushButtonAttribute(comment, label)[source]

a DdAttribute that draws a pushButton in the mask. the button must be implemented as subclass of ddui.DdPushButton

class ddattribute.DdTable(oid=None, schemaName='None', tableName='None', comment='', title=None)[source]

holds all information for a DB table relation

class ddattribute.DdTableAttribute(relationTable, comment, label, relationFeatureIdField, attributes, maxRows, showParents)[source]

a DdAttribute for a relationTable

buildSubsetString(relationFeatureIdField)[source]
setSubsetString(subsetString=None)[source]

ddui

Classes that make up or steer the DataDrivenUI

class ddui.DataDrivenUi(iface)[source]

Bases: object

Creates the DataDrivenUi

When subclassing this class, you want to rewrite createUi and use DdManager’s setUi method to apply your custom ui to the layer

createUi(thisTable, db, skip=[], labels={}, fieldOrder=[], minMax={}, showParents=True, showChildren=True)[source]

creates a default ui for this table (DdTable instance) skip is an array with field names to not show labels is a dict with entries: “fieldname”: “label” fieldOrder is an array containing the field names in the order they should be shown minMax is a dict with entries: “fieldname”: [min, max] (use for numerical fields only!

getAttributes(thisTable, db, labels, minMax)[source]

query the DB and create DdAttributes

getForeignKeys(thisTable, db)[source]

querys this table’s foreign keys and returns a dict attnum: [QString: Type of the lookup field, QString: sql to query lookup values, QString: Name of the value field in the lookup table, QString: Comment on lookup table]

getN2mAttributes(db, thisTable, attName, attNum, labels, showChildren)[source]

find those tables (n2mtable) where our pk is a fk

getParent(thisTable, db)[source]

deprecated

getParents(thisTable, db)[source]

query the DB to get a table’s parents if any A table has a parent if its primary key is defined on one field only and is at the same time a foreign key to another table’s primary key. Thus there is a 1:1 relationship between the two.

isSupportedType(typ)[source]
class ddui.DdCheckBox(attribute)[source]

Bases: ddui.DdLineEdit

input widget (QCheckBox) for a boolean field

checkInput()[source]
createInputWidget(parent)[source]
getFeatureValue(layer, feature, db)[source]

returns a boolean representing the value in this field for this feature

getValue()[source]
setValue(thisValue)[source]
stateChanged(newState)[source]

slot if this QCheckBox’ state has changed

class ddui.DdComboBox(attribute)[source]

Bases: ddui.DdLineEdit

input widget (QComboBox) for a foreign key

createInputWidget(parent)[source]
fill(db)[source]

fill the QComboBox with values according to the attribute from the db

getFeatureValue(layer, feature, db)[source]

returns a value representing the value in this field for this feature

getValue()[source]
setValue(thisValue)[source]
setupUi(parent, db)[source]
class ddui.DdDateEdit(attribute)[source]

Bases: ddui.DdLineEdit

input widget (QDateEdit) for a date field

createInputWidget(parent)[source]
getFeatureValue(layer, feature, db)[source]

returns a QDate representing the value in this field for this feature

getValue()[source]
setValue(thisValue)[source]
class ddui.DdDialogWidget[source]

Bases: ddui.DdWidget

This is the mask ui

addFormWidget(ddFormWidget)[source]

add this DdFormWidget to the ui

checkInput()[source]
discard()[source]
initialize(layer, feature, db)[source]
save(layer, feature, db)[source]
setupUi(DataDrivenInputMask, db)[source]
class ddui.DdFormHelper(thisDialog, layerId, featureId)[source]
class ddui.DdFormWidget(ddTable, hasToolBox=False, layer=None)[source]

Bases: ddui.DdWidget

DdForms are the content of DdDialog, each DdDialog needs at least one DdForm (tab) class arranges its input widgets either in a QToolBox or int the DdDialogWidget’s current tab

addInputWidget(ddInputWidget)[source]

insert this DdInputWidget into this DdForm

checkInput()[source]
discard()[source]
initialize(layer, feature, db)[source]
save(layer, feature, db)[source]
setupUi(parent, db)[source]
class ddui.DdInputWidget(ddAttribute)[source]

Bases: ddui.DdWidget

abstract super class for any input widget, corresponds to a DdAttribute

createLabel(parent)[source]

creates a QLabel object

getLabel()[source]

returns the label for this DdInputWidget

getMaxValueFromTable(schemaName, tableName, db)[source]

querys schema.table in db to get the highest occuring values for this DdInputWidget’s attribute

registerChange(thisValue)[source]

slot to be called when user changes the input

class ddui.DdLineEdit(attribute)[source]

Bases: ddui.DdInputWidget

abstract class for all Input Widgets that can be represented in one line, creates a QLineEdit as default InputWidget, adds it together with a QCheckBox (to store null values) and a label to a QFormLayout.

checkInput()[source]
chkStateChanged(newState)[source]

slot: disables the input widget if the null checkbox is checked and vice versa

createInputWidget(parent)[source]
getFeatureValue(layer, feature, db)[source]

returns a QString representing the value in this field for this feature; if the value is null, None is returned, if it is a new feature the default value is returned.

getFieldIndex(layer)[source]

return the field index for this DdInputWidget’s attribute’s name in this layer

getValue()[source]
initialize(layer, feature, db)[source]
manageChk(thisValue)[source]

check/uncheck the null checkbox depending on the value and the attribute’s notNull property

save(layer, feature, db)[source]
setValue(thisValue)[source]

sets thisValue into the input widget

setupUi(parent, db)[source]

setup the label and add the inputWidget to parents formLayout

class ddui.DdLineEditChar(attribute)[source]

Bases: ddui.DdLineEdit

input widget (QLineEdit) for a char or varchar

checkInput()[source]
class ddui.DdLineEditDouble(attribute)[source]

Bases: ddui.DdLineEdit

input widget (QLineEdit) for a DoubleValue

getValue()[source]
setValidator()[source]

sets an appropriate QValidator for the QLineEdit if this DdInputWidget’s attribute has min/max values validator is set to them

setValue(thisValue)[source]
setupUi(parent, db)[source]
class ddui.DdLineEditInt(attribute)[source]

Bases: ddui.DdLineEdit

input widget (QLineEdit) for an IntegerValue

getFeatureValue(layer, feature, db)[source]
initialize(layer, feature, db)[source]
setValidator()[source]

sets an appropriate QValidator for the QLineEdit if this DdInputWidget’s attribute has min/max values validator is set to them

class ddui.DdManager(iface)[source]

Bases: object

DdManager manages all masks in the current project

addAction(layer, actionName=PyQt4.QtCore.QString(u'showDdForm'))[source]

api method to add an action to the layer with a self defined name

editingStarted()[source]
editingStopped()[source]
findPostgresLayer(db, ddTable)[source]
initLayer(layer, skip=[], labels={}, fieldOrder=[], minMax={}, showParents=True, createAction=True)[source]

api method initLayer: initialize the layer with a data-driven input mask Returns a Boolean stating the success of the initialization

loadPostGISLayer(db, ddTable, displayName=None, geomColumn=PyQt4.QtCore.QString(u''), whereClause=None, keyColumn=None)[source]
quit()[source]
removeAction(layer, actionName)[source]

api method to remove an action from the layer

setDb(layer, db)[source]

api method to set the db for a layer

setUi(layer, ui)[source]

api method to exchange the default ui with a custom ui

showDdForm(fid)[source]
showFeatureForm(layer, feature)[source]

api method showFeatureForm: show the data-driven input mask for a layer and a feature returns 1 if user clicked OK, 0 if CANCEL

class ddui.DdN2mListWidget(attribute)[source]

Bases: ddui.DdN2mWidget

input widget (clickable QListWidget) for simple n2m relations

createInputWidget(parent)[source]
initialize(layer, feature, db)[source]
registerChange(thisItem)[source]
save(layer, feature, db)[source]
class ddui.DdN2mTableWidget(attribute)[source]

Bases: ddui.DdN2mWidget

a input widget for n-to-m relations with more than one field in the relation table The input widget consists of a QTableWidget and an add (+) and a remove (-) button

add()[source]

slot to be called when the user clicks on the add button

appendRow(thisFeature)[source]

add a new row to the QTableWidget

createFeature(fid=None)[source]

create a new QgsFeature for the relation table with this fid

createInputWidget(parent)[source]
discard()[source]
doubleClick(thisRow, thisColumn)[source]

slot to be called when the user double clicks on the QTableWidget

fillRow(thisRow, thisFeature)[source]

fill thisRow with values from thisFeature

initialize(layer, feature, db)[source]
remove()[source]

slot to be called when the user clicks on the remove button

save(layer, feature, db)[source]
selectionChanged()[source]

slot to be called when the QTableWidget’s selection has changed

setupUi(parent, db)[source]
class ddui.DdN2mTreeWidget(attribute)[source]

Bases: ddui.DdN2mWidget

input widget (clickable QTreeWidget) for n2m relations with more than one additional field in the related table

createInputWidget(parent)[source]
initialize(layer, feature, db)[source]
registerChange(selfthisItem, thisColumn)[source]
save(layer, feature, db)[source]
class ddui.DdN2mWidget(attribute)[source]

Bases: ddui.DdInputWidget

abstract class for any n-to-m relation

setupUi(parent, db)[source]
class ddui.DdPushButton(attribute)[source]

Bases: ddui.DdInputWidget

abstract class, needs subclassing

clicked()[source]
initialize(layer, feature, db)[source]

must be implemented in child class

save(layer, feature, db)[source]

must be implemented in child class

setupUi(parent, db)[source]
class ddui.DdTextEdit(attribute)[source]

Bases: ddui.DdLineEdit

input widget (QTextEdit) for a text field

createInputWidget(parent)[source]
getValue()[source]
registerChange()[source]
setValue(thisValue)[source]
class ddui.DdWidget[source]

Bases: object

abstract base class of all ui-widgets

checkInput()[source]

check if input is valid returns True if not implemented in child class

discard()[source]

discards the input

initialize(layer, feature, db)[source]

initialize this widget for feature in layer must be implemented in child classes

save(layer, feature, db)[source]

saves the input must be implemented in child classes

setupUi(parent, db)[source]

create the ui must be implemented in child classes

class ddui.QInt64Validator(parent=None)[source]

Bases: PyQt4.QtGui.QValidator

a QValidator for int64 values

validate(input, pos)[source]
ddui.ddFormInit(dialog, layerId, featureId)[source]
ddui.ddFormInit1(dialog, layerId, featureId)[source]

dddialog

class dddialog.DdDialog(ddManager, ui, layer, feature, db, parent=None)[source]

Each mask is a DdDialog instance, thus a child of QDialog

accept()[source]
initialize()[source]
reject()[source]
setTitle()[source]

dderror

Error classes

class dderror.DbError(query)[source]

error querying the DB

class dderror.DdError(value)[source]

General error

exception dderror.FatalError(value)[source]

Table Of Contents

Previous topic

API Documentation

This Page