editor_widget
editor_widget
Attributes
NO_PARENT = '(none — root layer)'
module-attribute
Classes
ConfigEditorWidget(config, parent=None)
Bases: QWidget
Tree editor for the layers of a LayeredConfig.
The widget has no menus; hosts can place its public actions (save_action,
save_all_action, new_layer_action, undo_action, redo_action,
expand_all_action, collapse_all_action) wherever they like. Shortcuts
only apply while the editor has focus.
Attributes:
| Name | Type | Description |
|---|---|---|
saved |
Signal
|
Emitted with the layer name after a layer is saved. |
Initialize the editor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
LayeredConfig
|
The config whose layers are edited. |
required |
parent
|
QWidget | None
|
Parent widget. |
None
|
Source code in src/json_config_qt/editor_widget.py
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | |
Attributes
document = LayerDocument(config, self)
instance-attribute
proxy = FilterProxy(self)
instance-attribute
saved = QtCore.Signal(str)
class-attribute
instance-attribute
Methods:
add_key(parent)
Ask for a key name and type, then add it to a dict node.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent
|
JsonNode
|
The dict node to add the key to. |
required |
Source code in src/json_config_qt/editor_widget.py
370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 | |
append_item(parent)
Ask for a type, then append a default item to a list node.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent
|
JsonNode
|
The list node to append to. |
required |
Source code in src/json_config_qt/editor_widget.py
390 391 392 393 394 395 396 397 398 399 400 401 | |
change_type(node, kind)
Replace a node's value with the default value of another type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node
|
JsonNode
|
The node to convert. |
required |
kind
|
Kind
|
The new type. |
required |
Source code in src/json_config_qt/editor_widget.py
403 404 405 406 407 408 409 410 411 412 | |
confirm_discard()
Ask what to do with unsaved layers; return False if the user cancels.
Source code in src/json_config_qt/editor_widget.py
308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 | |
prompt_new_layer()
Ask for a new layer's details and register it on the config.
Source code in src/json_config_qt/editor_widget.py
254 255 256 257 258 259 260 261 262 | |
save_all()
Save all layers with unsaved edits, showing an error dialog on failure.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if everything was saved. |
Source code in src/json_config_qt/editor_widget.py
284 285 286 287 288 289 290 | |
save_current()
Save the current layer, showing an error dialog on failure.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the layer was saved. |
Source code in src/json_config_qt/editor_widget.py
275 276 277 278 279 280 281 282 | |
NewLayerDialog(layers, current, parent=None)
Bases: QDialog
Ask for the name, parent layer and file of a new layer.
Initialize the dialog.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layers
|
list[str]
|
Existing layer names offered as parent. |
required |
current
|
str | None
|
Layer preselected as parent. |
required |
parent
|
QWidget | None
|
Parent widget. |
None
|
Source code in src/json_config_qt/editor_widget.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | |
Methods:
values()
Return the entered values.
Returns:
| Type | Description |
|---|---|
tuple[str, str | None, Path | None]
|
tuple[str, str | None, pathlib.Path | None]: Layer name, parent layer name (None for a root layer) and file path (None if left empty). |
Source code in src/json_config_qt/editor_widget.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 | |