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

showSearchForm()

Show the search form for the active layer

unload()[source]

Remove the plugin menu item and icon

ddmanager

Class that steers the DataDrivenUI

class ddmanager.DdManager(iface)[source]

DdManager manages all masks in the current project

addAction(layer, actionName=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]
getGroupIndex(groupName)[source]

Find the index for groupName in the legend

initLayer(layer, skip=[], labels={}, fieldOrder=[], fieldGroups={}, minMax={}, searchFields=[], showParents=True, createAction=True, db=None, inputMask=True, searchMask=True, inputUi=None, searchUi=None, helpText='')[source]

api method initLayer: initialize this layer with a data-driven input mask Returns a Boolean stating the success of the initialization Paramters: - layer [QgsVectorLayer] - skip [array [string]]: field names to not show - labels [dict] with entries: “fieldname”: “label” - fieldOrder [array[string]]: containing the field names in the order they should be shown - fieldGroups [dict] with entries: fieldName: [tabTitle, tabTooltip] for each group a tab is created and the fields from fieldName onwards (refers to fieldOrder) are grouped in this tab; tabTooltip is optional - minMax [dict] with entries: “fieldname”: [min, max] (use for numerical fields only! - searchFields [array[string]] with fields to be shown in the search form, if empty all fields are shown - showParents [Boolean] show tabs for 1-to-1 relations (parents) - createAction [Boolean]: add an action to the layer’s list of actions - db [QtSql.QSqlDatabase] - inputMask [Boolean]: create a data-edit mask - searchMask [Boolean]: create a data-search mask - inputUi [ddui.DdDialogWidget]: apply this inputUi - searchUi [ddui.DdDialogWidget]: apply this as search ui - helpText [string] help text for this mask, may be html formatted

isAccessible(db, ddTable)

check if user has right to access this table

loadPostGISLayer(db, ddTable, displayName=None, geomColumn=None, whereClause=None, keyColumn=None, intoDdGroup=True)[source]
makeDdTable(layer, db=None)

make a DdTable object from the passed in layer, returns None, if layer is not suitable

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, showParents=True)[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

showQueryError(query, withSql=False)
showSearchForm(layer)[source]

api method showSearchForm: show the data-driven search mask for a layer returns 1 if user clicked OK, 0 if CANCEL

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

debug(msg)
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]
buildSubsetString(relationFeatureIdField)
setDeleteStatement(deleteStatement=None)[source]
setDisplayStatement(displayStatement=None)[source]
setInsertStatement(insertStatement=None)[source]
setSubsetString(subsetString=None)
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=[], fieldGroups={}, minMax={}, searchFields=[], showParents=True, showChildren=True, inputMask=True, searchMask=True, helpText='')[source]

creates default uis for this table (DdTable instance) showChildren [Boolean]: show tabs for 1-to-1 relations (children) see ddmanager.initLayer for other parameters

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: [str: Type of the lookup field, str: sql to query lookup values, str: Name of the value field in the lookup table, str: 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]
search(layer)
setHelpText(helpText)
setupUi(ddDialog, 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). The class arranges its input widgets either in a QToolBox or in the DdDialogWidget’s current tab

addInputWidget(ddInputWidget)[source]

insert this DdInputWidget into this DdForm

checkInput()[source]
close()
discard()[source]
initialize(layer, feature, db)[source]
save(layer, feature, db)[source]
search(layer)
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 str 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 if available.

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]
search(layer)

create search sql-string

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.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]
search(layer)
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

createInputWidget(parent)[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

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 TreeWidget is initialized directly from the DB

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

Bases: ddui.DdInputWidget

abstract class for any n-to-m relation

createFeature(fid=None)

create a new QgsFeature for the relation table with this fid

discard()
initializeLayer(layer, feature, db, doShowParents=False, withMask=False)
save(layer, feature, db)
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

debug(msg)
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

search(layer)

creates search string 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]
helpRequested()
initialize()[source]
reject()[source]
setTitle()[source]
class dddialog.DdSearchDialog(ddManager, ui, layer, db, parent=None)

Each searchDialog is a child of QDialog

accept()
initialize()
reject()
setTitle()

dderror

Error classes

class dderror.DbError(query, fatal=True)[source]

error querying the DB

class dderror.DdError(value, fatal=False)[source]

General error

exception dderror.FatalError(value)[source]

Table Of Contents

Previous topic

API Documentation

This Page