|
RTC Toolkit 6.1.0-pre1
|
An implementation of a Qt model object to handle repositories accessible via RepositoryControl, i.e. More...
Public Member Functions | |
| __init__ (self, RepositoryControl repo, QPalette tree_view_palette, *args, **kwargs) | |
| get_repo_control (self) | |
| Return the repository control object this model was constructed with. | |
| bool | has_pending_requests (self) |
| Returns True if there are any pending asynchronous requests started by the fetchMore or commit methods. | |
| Node | index_to_node (self, QModelIndex index) |
| Fetch the internal tree node corresponding to the model index, or the root node if the index is invalid. | |
| QModelIndex | index_from_datapoint_path (self, DataPointPath path) |
| Returns the index that holds the given datapoint path, otherwise an invalid index if the path cannot be found. | |
| int | rowCount (self, QModelIndex parent=QModelIndex()) |
| Returns the number of children for a given parent. | |
| int | columnCount (self, QModelIndex parent=QModelIndex()) |
| Returns the number of data columns each child has for a given parent. | |
| QModelIndex | index (self, int row, int column, QModelIndex parent=QModelIndex()) |
| Creates a child model index for a given row and column of the indicated parent. | |
| QModelIndex | parent (self, QModelIndex index) |
| Return the model index of the corresponding parent tree node for the given model index. | |
| bool | hasChildren (self, QModelIndex parent=QModelIndex()) |
| Returns True if the parent tree node has any children, otherwise False. | |
| Qt.ItemFlags | flags (self, QModelIndex index) |
| Returns the flags applicable for a particular tree node's model index. | |
| data (self, QModelIndex index, int role=Qt.DisplayRole) | |
| Return the appropriately interpreted data from the model for a given role. | |
| bool | setData (self, QModelIndex index, value, int role=Qt.EditRole) |
| When data is updated using the EditRole, the underlying node object is updated and we return True. | |
| headerData (self, int column, Qt.Orientation orientation, int role=Qt.DisplayRole) | |
| Returns the header string for display for a specific column. | |
| bool | setHeaderData (self, int column, Qt.Orientation orientation, value, int role=Qt.EditRole) |
| Allows to change the header string for a particular column. | |
| bool | insertRow (self, int position, QModelIndex parent=QModelIndex(), bool is_leaf=False, data_type=RtcString) |
| Insert a single row at the given position under the parent index of the tree. | |
| bool | insertRows (self, int position, int rows, QModelIndex parent=QModelIndex(), bool is_leaf=False, data_type=RtcString) |
| Inserts multiple rows at the given position under the parent index of the tree. | |
| bool | removeRow (self, int row, QModelIndex parent=QModelIndex()) |
| Removes a single row from the tree. | |
| bool | removeRows (self, int position, int rows, QModelIndex parent=QModelIndex()) |
| Removes one or more rows from an initial position. | |
| Qt.DropActions | supportedDropActions (self) |
| Returns the drop actions supported by this model. | |
| list | mimeTypes (self) |
| Returns the MIME types supported by this model for drag and drop. | |
| bool | dropMimeData (self, QMimeData data, Qt.DropAction action, int row, int column, QModelIndex parent) |
| Handles data provided by a drag and drop action for the tree model. | |
| bool | canFetchMore (self, QModelIndex parent) |
| Returns True if there is more data to be fetched for the given parent tree node, i.e. | |
| fetchMore (self, QModelIndex parent) | |
| Retrieves additional data for the given parent tree node in an asynchronous manner. | |
| commit (self) | |
| Method to trigger asynchronous committing of all cached data. | |
| create_symlink (self, DataPointPath path, DataPointPath symlink_target) | |
| Create a new symlink at the given path and link it to the target node. | |
| set[DataPointPath] | get_existing_paths (self) |
| Returns set of paths that are already present within tree model. | |
| cancel_pending_requests (self) | |
| Cancel all pending fetch and commit requests. | |
Static Public Attributes | |
| SignalInstance | new_cached_values = Signal() |
| Signal indicating that the model has been modified and contains new cached values, i.e. | |
| SignalInstance | commit_complete = Signal(object) |
| Signal indicating that a commit request has completed. | |
Protected Member Functions | |
| QModelIndex | _node_to_index (self, Node node, int column=0) |
| Construct a model index for the given internal tree node. | |
| _on_fetch_more_finished (self, asyncio.Task task, DataPointPath dp_path) | |
| Handle completion of a fetch-more task, log any errors, and remove the corresponding path from the pending fetch requests. | |
| _on_commit_changes_finished (self, asyncio.Task task) | |
| Handle completion of a commit task, emit its result or error, and remove the task from the pending commit requests. | |
| _fetch_more (self, Node parent) | |
| Fetch more data for the given node. | |
| bool | _fetch_children (self, Node parent) |
| Fetch and add the child nodes for the given parent, updating their state and restoring the previous node index if the fetch fails. | |
| bool | _fetch_metadata (self, set[Node] nodes) |
| Fetch metadata for stale tree nodes and update them accordingly. | |
| bool | _fetch_value (self, Node parent) |
| Fetch values for the given parent and its children, resolving symlinks to their linked nodes when necessary, and update the corresponding nodes. | |
| list[Any] | _get_leaf_paths (self, DataPointPath parent_path) |
| Fetch and return all leaf node paths below the given parent path. | |
| _commit_changes (self) | |
| Commit all pending changes to the repository and update the local node states based on the result. | |
| _invoke_rows_refresh (self, QModelIndex|list[QModelIndex] indexes, roles=None) | |
| Refresh all columns for the given model rows by emitting dataChanged. | |
| TreeNode | _create_tree_node_cascade (self, DataPointPath path, data_type=RtcString) |
| Create all missing TreeNodes along the path from the root to the given leaf. | |
| _get_repo (self) | |
Static Protected Member Functions | |
| _iter_paths (DataPointPath path) | |
| Iterate over all possible node paths from the root to the given leaf path. | |
Protected Attributes | |
| _repo_control = repo | |
| _tree_view_palette = tree_view_palette | |
| _logger = CiiLogManager.get_logger(__name__) | |
| _headers = list(self._default_headers) | |
| _root_node = TreeNode(DataPointPath("/")) | |
| dict | _nodes_by_path = {} |
| set[DataPointPath] | _soft_deleted_nodes = set() |
| dict[DataPointPath, asyncio.Task] | _pending_fetch_requests = dict() |
| set[asyncio.Task] | _pending_commit_requests = set() |
Static Protected Attributes | |
| tuple | _default_headers |
| dict | _conversion_function_map_display_role |
| dict | _conversion_function_map_edit_role_read |
| dict | _conversion_function_map_edit_role_write |
An implementation of a Qt model object to handle repositories accessible via RepositoryControl, i.e.
implementing RepositoryIf.
Data is lazy loaded and cached such that only the parts of the data that GUI view widgets actually request is fetched.
| gui.repository_model.RepositoryModel.__init__ | ( | self, | |
| RepositoryControl | repo, | ||
| QPalette | tree_view_palette, | ||
| * | args, | ||
| ** | kwargs ) |
|
protected |
Commit all pending changes to the repository and update the local node states based on the result.
|
protected |
Create all missing TreeNodes along the path from the root to the given leaf.
|
protected |
Fetch and add the child nodes for the given parent, updating their state and restoring the previous node index if the fetch fails.
Returns True if fetch succeeded.
|
protected |
Fetch metadata for stale tree nodes and update them accordingly.
Converts nodes to symlinks when symlink metadata is detected. Returns True if fetch fully or partially succeeded.
|
protected |
Fetch more data for the given node.
If the node is root, the initial fetch (including children and metadata) will be done. Otherwise, only value is fetched.
|
protected |
Fetch values for the given parent and its children, resolving symlinks to their linked nodes when necessary, and update the corresponding nodes.
Returns True if fetch fully or partially succeeded.
|
protected |
Fetch and return all leaf node paths below the given parent path.
|
protected |
|
protected |
Refresh all columns for the given model rows by emitting dataChanged.
|
staticprotected |
Iterate over all possible node paths from the root to the given leaf path.
|
protected |
Construct a model index for the given internal tree node.
If the node refers to the root node then an invalid index is returned.
|
protected |
Handle completion of a commit task, emit its result or error, and remove the task from the pending commit requests.
|
protected |
Handle completion of a fetch-more task, log any errors, and remove the corresponding path from the pending fetch requests.
| gui.repository_model.RepositoryModel.cancel_pending_requests | ( | self | ) |
Cancel all pending fetch and commit requests.
| bool gui.repository_model.RepositoryModel.canFetchMore | ( | self, | |
| QModelIndex | parent ) |
Returns True if there is more data to be fetched for the given parent tree node, i.e.
the node or one of its children is marked as stale.
| int gui.repository_model.RepositoryModel.columnCount | ( | self, | |
| QModelIndex | parent = QModelIndex() ) |
Returns the number of data columns each child has for a given parent.
By convention the parent's index column value should be zero.
| gui.repository_model.RepositoryModel.commit | ( | self | ) |
Method to trigger asynchronous committing of all cached data.
Once the commit has completed the commit_complete signal is sent. In case of an error the signal is sent with an exception object indicating the error. Otherwise, None is sent to indicate success.
| gui.repository_model.RepositoryModel.create_symlink | ( | self, | |
| DataPointPath | path, | ||
| DataPointPath | symlink_target ) |
Create a new symlink at the given path and link it to the target node.
The new symlink is marked as cached and emits a new_cached_values signal.
| gui.repository_model.RepositoryModel.data | ( | self, | |
| QModelIndex | index, | ||
| int | role = Qt.DisplayRole ) |
Return the appropriately interpreted data from the model for a given role.
In the case of the EditRole the following is returned for the various columns: "Datapoint Path" - The datapoint short name, i.e. not the full path. "Value" - The datapoint value as a common Python type mapping to standard Qt edit widgets. "Type" - The type class identifying the datapoint type. Similarly, for the UserRole we return the following: "Datapoint Path" - The full path as a DataPointPath object. "Value" - The underlying datapoint value, i.e. not converted to a common Python type. "Type" - The type class identifying the datapoint type.
| bool gui.repository_model.RepositoryModel.dropMimeData | ( | self, | |
| QMimeData | data, | ||
| Qt.DropAction | action, | ||
| int | row, | ||
| int | column, | ||
| QModelIndex | parent ) |
Handles data provided by a drag and drop action for the tree model.
Currently just defaults to QAbstractItemModel.
| gui.repository_model.RepositoryModel.fetchMore | ( | self, | |
| QModelIndex | parent ) |
Retrieves additional data for the given parent tree node in an asynchronous manner.
Completion of the requests is further handled in the various slot methods that will be signaled by the RepositoryControl object to indicate completion.
The method attempts to progress as much as possible if errors occur. However, this may arise in inconsistencies between the internal cached data and the actual repository state. The user may want to simply reset the model in that case.
| Qt.ItemFlags gui.repository_model.RepositoryModel.flags | ( | self, | |
| QModelIndex | index ) |
Returns the flags applicable for a particular tree node's model index.
| set[DataPointPath] gui.repository_model.RepositoryModel.get_existing_paths | ( | self | ) |
Returns set of paths that are already present within tree model.
| gui.repository_model.RepositoryModel.get_repo_control | ( | self | ) |
Return the repository control object this model was constructed with.
| bool gui.repository_model.RepositoryModel.has_pending_requests | ( | self | ) |
Returns True if there are any pending asynchronous requests started by the fetchMore or commit methods.
Otherwise, False is returned if there are no pending requests.
| bool gui.repository_model.RepositoryModel.hasChildren | ( | self, | |
| QModelIndex | parent = QModelIndex() ) |
Returns True if the parent tree node has any children, otherwise False.
By convention the parent's index column value should be zero.
| gui.repository_model.RepositoryModel.headerData | ( | self, | |
| int | column, | ||
| Qt.Orientation | orientation, | ||
| int | role = Qt.DisplayRole ) |
Returns the header string for display for a specific column.
Only the horizontal headers are supported. 'None' is returned for all unsupported columns, orientations and roles.
| QModelIndex gui.repository_model.RepositoryModel.index | ( | self, | |
| int | row, | ||
| int | column, | ||
| QModelIndex | parent = QModelIndex() ) |
Creates a child model index for a given row and column of the indicated parent.
By convention the parent's index column value should be zero.
| row | Corresponds to the child number within the list of the parent's children. |
| column | The column or data field being referred to for the child. |
| parent | The parent tree node's model index. |
| QModelIndex gui.repository_model.RepositoryModel.index_from_datapoint_path | ( | self, | |
| DataPointPath | path ) |
Returns the index that holds the given datapoint path, otherwise an invalid index if the path cannot be found.
| Node gui.repository_model.RepositoryModel.index_to_node | ( | self, | |
| QModelIndex | index ) |
Fetch the internal tree node corresponding to the model index, or the root node if the index is invalid.
| bool gui.repository_model.RepositoryModel.insertRow | ( | self, | |
| int | position, | ||
| QModelIndex | parent = QModelIndex(), | ||
| bool | is_leaf = False, | ||
| data_type = RtcString ) |
Insert a single row at the given position under the parent index of the tree.
If parent index is invalid the row is inserted under the root of the tree.
| bool gui.repository_model.RepositoryModel.insertRows | ( | self, | |
| int | position, | ||
| int | rows, | ||
| QModelIndex | parent = QModelIndex(), | ||
| bool | is_leaf = False, | ||
| data_type = RtcString ) |
Inserts multiple rows at the given position under the parent index of the tree.
If parent index is invalid the rows are inserted under the root of the tree.
| list gui.repository_model.RepositoryModel.mimeTypes | ( | self | ) |
Returns the MIME types supported by this model for drag and drop.
Currently just defaults to QAbstractItemModel.
| QModelIndex gui.repository_model.RepositoryModel.parent | ( | self, | |
| QModelIndex | index ) |
Return the model index of the corresponding parent tree node for the given model index.
| bool gui.repository_model.RepositoryModel.removeRow | ( | self, | |
| int | row, | ||
| QModelIndex | parent = QModelIndex() ) |
Removes a single row from the tree.
| bool gui.repository_model.RepositoryModel.removeRows | ( | self, | |
| int | position, | ||
| int | rows, | ||
| QModelIndex | parent = QModelIndex() ) |
Removes one or more rows from an initial position.
The removed rows correspond to the tree node children of the parent tree node indicated by the parent model index.
If removing the last child of a parent node leaves the parent folder empty, the parent node is automatically removed as well. Removing a parent node also recursively removes its entire subtree.
| int gui.repository_model.RepositoryModel.rowCount | ( | self, | |
| QModelIndex | parent = QModelIndex() ) |
Returns the number of children for a given parent.
By convention the parent's index column value should be zero.
| bool gui.repository_model.RepositoryModel.setData | ( | self, | |
| QModelIndex | index, | ||
| value, | |||
| int | role = Qt.EditRole ) |
When data is updated using the EditRole, the underlying node object is updated and we return True.
If the column corresponding to the datapoint's name is being edited then the node and all child nodes are appropriately renamed. If the node cannot be updated for the given index and role then False is returned.
| bool gui.repository_model.RepositoryModel.setHeaderData | ( | self, | |
| int | column, | ||
| Qt.Orientation | orientation, | ||
| value, | |||
| int | role = Qt.EditRole ) |
Allows to change the header string for a particular column.
Only the horizontal orientation is supported for the EditRole.
| Qt.DropActions gui.repository_model.RepositoryModel.supportedDropActions | ( | self | ) |
Returns the drop actions supported by this model.
Currently just defaults to QAbstractItemModel.
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
static |
Signal indicating that a commit request has completed.
The received arguments is either None to indicate a successful completion or a list of exception objects indicating failure.
|
static |
Signal indicating that the model has been modified and contains new cached values, i.e.
one can call the commit method to write these back to the repository.