commands
commands
Attributes
Classes
InsertChild(model, parent_path, row, key, value)
Bases: QUndoCommand
Add a dict key or list item.
Initialize the command.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
JsonTreeModel
|
The model to edit. |
required |
parent_path
|
ModelPath
|
ModelPath of the container node. |
required |
row
|
int
|
Position to insert at. |
required |
key
|
str | int
|
Dict key or list index of the new child. |
required |
value
|
JsonValue
|
The child's value. |
required |
Source code in src/json_config_qt/tree/commands.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | |
Methods:
redo()
Insert the child.
Source code in src/json_config_qt/tree/commands.py
64 65 66 | |
undo()
Remove the inserted child.
Source code in src/json_config_qt/tree/commands.py
68 69 70 | |
RemoveChild(model, path)
Bases: QUndoCommand
Remove a dict key or list item.
Initialize the command.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
JsonTreeModel
|
The model to edit. |
required |
path
|
ModelPath
|
ModelPath of the node to remove. |
required |
Source code in src/json_config_qt/tree/commands.py
76 77 78 79 80 81 82 83 84 85 86 87 88 | |
Methods:
redo()
Remove the child.
Source code in src/json_config_qt/tree/commands.py
90 91 92 | |
undo()
Re-insert the removed child at its original position.
Source code in src/json_config_qt/tree/commands.py
94 95 96 | |
SetValue(model, path, value)
Bases: QUndoCommand
Replace the value at a path (also used to change a node's type).
Initialize the command.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
JsonTreeModel
|
The model to edit. |
required |
path
|
ModelPath
|
ModelPath of the node to replace. |
required |
value
|
JsonValue
|
The new value. |
required |
Source code in src/json_config_qt/tree/commands.py
14 15 16 17 18 19 20 21 22 23 24 25 26 | |
Methods:
redo()
Apply the new value.
Source code in src/json_config_qt/tree/commands.py
28 29 30 | |
undo()
Restore the previous value.
Source code in src/json_config_qt/tree/commands.py
32 33 34 | |