stratified_packager.processing.provider
The plugin’s Processing provider and its GUI-only default-refresh hookups (SPEC §5).
Classes
Registers the plugin's single algorithm and keeps its dynamic defaults fresh. |
- class stratified_packager.processing.provider.StratifiedPackagerProvider[source]
Registers the plugin’s single algorithm and keeps its dynamic defaults fresh.
The default values shown in the Processing dialog are computed in
algorithm.StratifiedPackagerAlgorithm.initAlgorithm()from the active project’s variables, the plugin settings and the layerexcludeflags (SPEC §5). To keep that prefill in step with edits to the project,connect_project_signals()wires the relevantQgsProjectsignals torefreshAlgorithms()(which rebuilds every algorithm instance). Those hookups are made only from a GUI session: connecting them headless and refreshing from them mid-run segfaultsqgis_process(SPEC §5), soconnect_project_signals()is called frominitGui()and never frominitProcessing().- _connect_layers(layers)[source]
Connect each layer’s
customPropertyChangedto the refresh scheduler.- Parameters:
layers (
Iterable[QgsMapLayer]) – Layers to start tracking (already-tracked ids are skipped).- Return type:
- _on_layer_property_changed(key)[source]
Schedule a refresh when a layer-variable custom property changes (SPEC §5).
setLayerVariablefirescustomPropertyChangedtwice (keysvariableNamesandvariableValues); the 0 ms timer debounces them, and filtering on those keys avoids spurious refreshes from unrelated custom-property writes (e.g. styles).
- _on_layers_added(layers)[source]
Track newly added layers and schedule a refresh (SPEC §5).
- Parameters:
layers (
Iterable[QgsMapLayer]) – The layers QGIS just added to the project.- Return type:
- _on_layers_will_be_removed(layers)[source]
Stop tracking layers about to be removed and schedule a refresh (SPEC §5).
Tolerates both overloads of
layersWillBeRemoved(layer ids or layer objects).- Parameters:
layers (Iterable[QgsMapLayer | str]) – The layers (or their ids) QGIS is about to remove.
- Return type:
None
- _refresh_algorithms()[source]
Rebuild the provider’s algorithms so dialog defaults pick up project edits.
- Return type:
- _schedule_refresh()[source]
Restart the single-shot timer, coalescing a burst of signals into one refresh.
Connected to argument-bearing signals too (e.g.
readProject); PyQt drops the extra payloads when the slot takes none.- Return type:
- connect_project_signals()[source]
Wire project edits to a coalesced algorithm refresh (SPEC §5).
Idempotent. Call from
initGuionly — never headless (SPEC §5). Connects the project’sreadProject/cleared/customVariablesChangedandlayersAdded/layersWillBeRemovedsignals, plus every current layer’scustomPropertyChanged, each routed through a single-shot 0 ms timer so the burst of signals QGIS emits while loading a project collapses into one refresh (SPEC §5).- Return type:
- disconnect_project_signals()[source]
Reverse
connect_project_signals()(called fromunload).Disconnects the project-level and per-layer connections, then stops and disposes the coalescing timer, leaving the provider safe to re-register.
- Return type:
- icon()[source]
Icon used for the provider inside the Processing toolbox.
- Return type:
- Returns:
provider icon
- name()[source]
Human-friendly provider name, used to describe the provider within the GUI.
- Return type:
- Returns:
provider name
- _layer_connections: dict[str, QMetaObject.Connection]
Per-layer
customPropertyChangedconnection tokens, keyed by layer id.
- _project_connections: list[QMetaObject.Connection]
Tokens of the project-level signal connections, for tidy disconnection.
- _refresh_timer: QTimer | None
Single-shot coalescing timer; created lazily by
connect_project_signals().