cute_mongo_forms.column.base¶
base.py : Basic column classes
- Copyright: 2017-2018 Sampsa Riikonen
- Authors : Sampsa Riikonen
- Date : 2018
- Version : 0.1
This file is part of the cute_mongo_forms library
License: LGPLv3+ (see the COPYING.LESSER file)
Functions
dictionaryCheck(definitions, dic) |
Checks that dictionary has certain values, according to definitions |
main() |
|
noCheck(obj) |
|
objectCheck(definitions, obj) |
Checks that object has certain attributes, according to definitions |
parameterInitCheck(definitions, parameters, obj) |
Checks that parameters are consistent with a definition |
test1() |
|
test2() |
|
typeCheck(obj, typ) |
Check type of obj, for example: typeCheck(x,int) |
Classes
CheckBoxColumn(**kwargs) |
A column having a Qt checkbox and true/false value. |
Column(**kwargs) |
Mother class for columns. |
ComboBoxColumn(**kwargs) |
A Column that can have a finite number of different values. |
ForeignKeyColumn(**kwargs) |
A column that is a foreign key, referenced by another collection. |
LineEditColumn(**kwargs) |
Derived from Column. |
ListEditColumn(**kwargs) |
A Column that is a list. |
-
class
cute_mongo_forms.column.base.CheckBoxColumn(**kwargs)[source]¶ A column having a Qt checkbox and true/false value.
-
class
cute_mongo_forms.column.base.Column(**kwargs)[source]¶ Mother class for columns. Derive your own column class from this. The column class encapsulates a particular QWidget and restrictions on the QWidget (through Qt input masks) of the accepted values. The Row class uses Columns to read/set their values from/to a key-value document.
Parameters at instantiation:
Parameters: key_name – The key to be used in the key/value pair of the document database
-
class
cute_mongo_forms.column.base.ComboBoxColumn(**kwargs)[source]¶ A Column that can have a finite number of different values. The possible values are defined in a specific collection that is given as a parameter (let’s call this “foreign collection”). The element in the QtWidget form corresponding to this column is a drop-down list (e.g. a QComboBox).
The collection schema looks like this:
principal collection foreign collection -------------------- ------------------ _id +---> _id key1 | label key2 --------+ key2 -------------------- ------------------
Parameters at instantiation:
Parameters: - collection – Foreign collection that has all possible values for the drop-down list
- key_name – Key in the principal collection whose values correspond to keys in the foreign collection (in that example above key_name = key2)
- label_name – Name of the drop-down list in the form widget
- foreign_label_name – Name of the key in the foreign collection for a value shown in the pricipal collection. Default: “label”
- foreign_key_name – Name of the foreign key in the foreign collection. Default: “_id”
-
class
cute_mongo_forms.column.base.ForeignKeyColumn(**kwargs)[source]¶ A column that is a foreign key, referenced by another collection. Does not create any visible widget into forms. Basically, creates a key-value pair in the collection Row schema. Does not know anything about mapping the key to a foreign table.
Parameters at instantiation:
Parameters: - key_name – name of the key
- collection – the “foreign” collection
- foreign_key_name – the key in the foreign collection (default: “_id”)
-
class
cute_mongo_forms.column.base.LabelColumn(**kwargs)[source]¶ Column that does not create a key-value pair. No data here, just a label
TODO: experimental, dont use
-
class
cute_mongo_forms.column.base.LineEditColumn(**kwargs)[source]¶ Derived from Column. Unrestricted input text.
-
class
cute_mongo_forms.column.base.ListEditColumn(**kwargs)[source]¶ A Column that is a list. Possible values for the list element are defined in a specific collection that is given as a parameter (let’s call this “foreign collection”). The element in the QtWidget form corresponding to this column is a QListWidget. The GUI user can enable/check several values. All these values are saved into the list.
The collection schema looks like this:
principal collection foreign collection -------------------- ------------------ _id +---> _id key1 | label key2: a list --------+ key2 -------------------- ------------------
Parameters at instantiation:
Parameters: - collection – Foreign collection that has all possible values present in the list
- key_name – Key in the principal collection whose values correspond to keys in the foreign collection (in that example above key_name = key2)
- label_name – Name of the list in the form widget
- foreign_label_name – Name of the key in the foreign collection for a value shown in the pricipal collection. Default: “label”
- foreign_key_name – Name of the foreign key in the foreign collection. Default: “_id”