The treemodel module#

This module implements TreeModel, which inherits from QAbstractItemModel and provides a model for a tree structure.

This can be used for debugging the tree using a Qt gui. See also the debug module.

class TreeModel(tree, parent=None)[source]#

Bases: QAbstractItemModel

TreeModel implements QAbstractItemModel to show a parce tree in Qt widgets such as a QTreeView.

CONTEXT_FLAGS = <PyQt5.QtCore.Qt.ItemFlags object>#
TOKEN_FLAGS = <PyQt5.QtCore.Qt.ItemFlags object>#
CONTEXT_FORMAT = '{name} at {pos} ({count})'#
TOKEN_FORMAT = '{action} {text} at {pos} {group}'#
CONTEXT_TOOLTIP = 'Context: {name}\nPos: {pos} - {end} (length: {length})\nChild count: {count}\nParent: {parent}\nParent-index: {index}'#
TOKEN_TOOLTIP = 'Token: {text}\nPos: {pos} - {end} (length: {length})\nAction: {action}\nGroup: {group}\nParent: {parent}\nParent-index: {index}'#
connect_builder(builder)[source]#

Connect to the started and finished signals of a TreeBuilder.

disconnect_builder(builder)[source]#

Disconnect from the started and finished signals of a TreeBuilder.

connect_debugging_builder(builder)[source]#

Connect to all the signals of a debugging tree builder.

(See the debug module).

disconnect_debugging_builder(builder)[source]#

Disconnect from all the signals of a debugging tree builder.

(See the debug module).

TreeModel.index(self, int, int, parent: QModelIndex = QModelIndex()) -> QModelIndex[source]
parent(self, QModelIndex) QModelIndex[source]#
parent(self) QObject
columnCount(self, parent: QModelIndex = QModelIndex()) int[source]#
rowCount(self, parent: QModelIndex = QModelIndex()) int[source]#
data(self, QModelIndex, role: int = Qt.ItemDataRole.DisplayRole) Any[source]#
flags(self, QModelIndex) Qt.ItemFlags[source]#
headerData(column, orientation, role)[source]#

Reimplemented to not show the root element’s repr while busy.

root()[source]#

Return the tree’s root element.

get_model_index(node)[source]#

Return a QModelIndex for the specified node (Context or Token).

get_node(index)[source]#

Return the node (Context or Token) for the specified QModelIndex.

slot_build_started()[source]#

Called when tree builder starts.

slot_build_finished()[source]#

Called when tree builder has finished.

slot_begin_remove_rows(node, first, last)[source]#
slot_end_remove_rows()[source]#
slot_begin_insert_rows(node, first, last)[source]#
slot_end_insert_rows()[source]#
slot_change_position(node, first, last)[source]#
slot_change_root_lexicon()[source]#
static node_dict(node)[source]#

Return a dictionary with information about the node.

classmethod node_tooltip(node)[source]#

Return text for a tooltip for the node.

classmethod node_repr(node)[source]#

Return short text to decribe the node for a tree view.