6.79. umbra.ui.models

models.py

Platform:
Windows, Linux, Mac Os X.
Description:
Defines the Application Models classes.

Others:

6.79.1. Module Attributes

umbra.ui.models.LOGGER

6.79.2. Classes

class umbra.ui.models.GraphModel(parent=None, rootNode=None, horizontalHeaders=None, verticalHeaders=None, defaultNode=None)[source]

Bases: PyQt4.QtCore.QAbstractItemModel

Defines a QAbstractItemModel subclass providing a graph model.
The Model provided by this object is very generic and abstract making it compatible with major Qt Views ( QListView, QTreeView, QTableView, QComboBox ).

Initializes the class.

Parameters:
  • parent (QObject) – Object parent.
  • rootNode (AbstractCompositeNode or GraphModelNode) – Root node.
  • horizontalHeaders (OrderedDict) – Headers.
  • verticalHeaders (OrderedDict) – Headers.
  • defaultNode (AbstractCompositeNode or GraphModelNode) – Default node.
rootNode[source]

Property for self.__rootNode attribute.

Returns:self.__rootNode.
Return type:AbstractCompositeNode or GraphModelNode
horizontalHeaders[source]

Property for self.__horizontalHeaders attribute.

Returns:self.__horizontalHeaders.
Return type:OrderedDict
verticalHeaders[source]

Property for self.__verticalHeaders attribute.

Returns:self.__verticalHeaders.
Return type:OrderedDict
defaultNode[source]

Property for self.__defaultNode attribute.

Returns:self.__defaultNode.
Return type:AbstractCompositeNode or GraphModelNode
rowCount(parent=<PyQt4.QtCore.QModelIndex object at 0x10b640938>)[source]

Reimplements the QAbstractItemModel.rowCount() method.

Parameters:parent (AbstractCompositeNode or GraphModelNode) – Parent node.
Returns:Row count.
Return type:int
columnCount(parent=<PyQt4.QtCore.QModelIndex object at 0x10b640a28>)[source]

Reimplements the QAbstractItemModel.columnCount() method.

Parameters:parent (AbstractCompositeNode or GraphModelNode) – Parent node.
Returns:Column count.
Return type:int
data(index, role=0)[source]

Reimplements the QAbstractItemModel.data() method.

Parameters:
  • index (QModelIndex) – Index.
  • role (int) – Role.
Returns:

Data.

Return type:

QVariant

setData(index, value, role=2)[source]

Reimplements the QAbstractItemModel.setData() method.

Parameters:
  • index (QModelIndex) – Index.
  • value (QVariant) – Value.
  • role (int) – Role.
Returns:

Method success.

Return type:

bool

headerData(section, orientation, role=0)[source]

Reimplements the QAbstractItemModel.headerData() method.

Parameters:
  • section (int) – Section.
  • orientation – Orientation. ( Qt.Orientation )
  • role (int) – Role.
Returns:

Header data.

Return type:

QVariant

flags(index)[source]

Reimplements the QAbstractItemModel.flags() method.

Parameters:index (QModelIndex) – Index.
Returns:Flags. ( Qt.ItemFlags )
parent(index)[source]

Reimplements the QAbstractItemModel.parent() method.

Parameters:index (QModelIndex) – Index.
Returns:Parent.
Return type:QModelIndex
index(row, column=0, parent=<PyQt4.QtCore.QModelIndex object at 0x10b640d70>)[source]

Reimplements the QAbstractItemModel.index() method.

Parameters:
  • row (int) – Row.
  • column (int) – Column.
  • parent (QModelIndex) – Parent.
Returns:

Index.

Return type:

QModelIndex

sort(column, order=0)[source]

Reimplements the QAbstractItemModel.sort() method.

Parameters:
  • column (int) – Column.
  • order – Order. ( Qt.SortOrder )
insertRows(row, count, parent=<PyQt4.QtCore.QModelIndex object at 0x10b640ed8>)[source]

Reimplements the QAbstractItemModel.insertRows() method.

Parameters:
  • row (int) – Row.
  • count (int) – Count.
  • parent (QModelIndex) – Parent.
Returns:

Method success.

Return type:

bool

removeRows(row, count, parent=<PyQt4.QtCore.QModelIndex object at 0x10b641050>)[source]

Reimplements the QAbstractItemModel.removeRows() method.

Parameters:
  • row (int) – Row.
  • count (int) – Count.
  • parent (QModelIndex) – Parent.
Returns:

Method success.

Return type:

bool

movesRows(fromParent, fromFirstRow, fromLastRow, toParent, toRow)[source]

Moves given rows from parent to parent row.

mimeTypes()[source]

Reimplements the QAbstractItemModel.mimeTypes() method.

Returns:Mime types.
Return type:QStringList
mimeData(indexes)[source]

Reimplements the QAbstractItemModel.mimeData() method.

Parameters:indexes (QModelIndexList) – Indexes.
Returns:MimeData.
Return type:QMimeData
clear()[source]

Clears the Model.

Returns:Method success.
Return type:bool
hasNodes()[source]

Returns if Model has nodes.

Returns:Has children.
Return type:bool
getNode(index)[source]

Returns the Node at given index.

Parameters:index (QModelIndex) – Index.
Returns:Node.
Return type:AbstractCompositeNode or GraphModelNode
getAttribute(node, column)[source]

Returns the given Node attribute associated to the given column.

Parameters:
  • node (AbstractCompositeNode or GraphModelNode) – Node.
  • column (int) – Column.
Returns:

Attribute.

Return type:

Attribute

getNodeIndex(node)[source]

Returns given Node index.

Parameters:node (AbstractCompositeNode or GraphModelNode) – Node.
Returns:Index.
Return type:QModelIndex
getAttributeIndex(node, column)[source]

Returns given Node attribute index at given column.

Parameters:
  • node (AbstractCompositeNode or GraphModelNode) – Node.
  • column (int) – Attribute column.
Returns:

Index.

Return type:

QModelIndex

findChildren(pattern=u'.*', flags=0)[source]

Finds the children matching the given patten.

Parameters:
  • pattern (unicode) – Matching pattern.
  • flags (int) – Matching regex flags.
Returns:

Matching children.

Return type:

list

findFamily(pattern=u'.*', flags=0, node=None)[source]

Returns the Nodes from given family.

Parameters:
  • pattern (unicode) – Matching pattern.
  • flags (int) – Matching regex flags.
  • node (AbstractNode or AbstractCompositeNode or GraphModelNode) – Node to start walking from.
Returns:

Family nodes.

Return type:

list

findNode(attribute)[source]

Returns the Node with given attribute.

Parameters:attribute (GraphModelAttribute) – Attribute.
Returns:Node.
Return type:GraphModelNode
findModel(object)[source]

Returns the model(s) associated with given object.

Parameters:object (GraphModelNode or GraphModelAttribute) – Node / Attribute.
Returns:Model(s).
Return type:list
enableModelTriggers(state)[source]

Enables Model Nodes and attributes triggers.

Parameters:state (bool) – Inform model state.
Returns:Method success.
Return type:bool
nodeChanged(node)[source]

Calls QAbstractItemModel.dataChanged() with given Node index.

Parameters:node (AbstractCompositeNode or GraphModelNode) – Node.
Returns:Method success.
Return type:bool
attributeChanged(node, column)[source]

Calls QAbstractItemModel.dataChanged() with given Node attribute index.

Parameters:
  • node (AbstractCompositeNode or GraphModelNode) – Node.
  • column (int) – Attribute column.
Returns:

Method success.

Return type:

bool