stratified_packager.gui.widgets

Reusable scope-editor widgets and field tables for the defaults GUI (SPEC §19).

Three scopes edit the same families of value: the plugin settings (concrete base values), the project variables and the per-layer variables. The project fields are inheritance-aware — an empty editor means “inherit the effective value from the next tier of the SPEC §5 chain”, with that inherited value shown as an inherit (= X) placeholder. The layer fields have no higher tier to inherit from (only their builtin default), so with inheriting=False the same editors present the unset state plainly instead: 2-state booleans as checkboxes (checked = true, unchecked = unset), a sentinel-labelled combo for the tri-state ones, and plain placeholders. Plugin-scope fields are concrete (the base of the chain, always a real value).

Three shared field tables (default_fields(), project_only_fields(), layer_fields()) drive every page, so the GUI stays in step with the parameter/variable schema. Editors are built programmatically from those tables; the host pages supply the .ui skeleton.

Module Attributes

OVERWRITE_MODE_LABELS

OVERWRITE_MODE combo labels keyed by SPEC §10 token.

PROJECT_INCLUSION_LABELS

PROJECT_INCLUSION combo labels keyed by SPEC §13 token.

WARM_START_MODE_LABELS

WARM_START_MODE combo labels keyed by SPEC §11 token.

MATCHING_METHOD_LABELS

Per-layer matching-method combo labels keyed by SPEC §4 token (auto is the sentinel, not a selectable option).

ScopeEditor

Any scope editor; all expose scope_value / set_scope_value / set_effective and are QWidget subclasses.

PROJECT_FIELD_STRATIFICATION_LAYER

Key of the stratification-layer project-only field (its project-variable suffix).

PROJECT_FIELD_STRATUM_NAME_EXPRESSION

Key of the stratum-name-expression project-only field (its project-variable suffix).

Functions

apply_overrides(target, values)

Write explicit values to target, removing keys whose value is None (inherit).

concrete_value(spec, editor)

Read a concrete editor's value as its stored string token.

default_fields()

Return the settings-backed default fields (the ✓ rows of SPEC §3, in table order).

inherit_placeholder(effective)

Format the placeholder shown by an empty (inheriting) editor.

layer_fields()

Return the per-layer variable fields (SPEC §4, in table order).

make_concrete_editor(spec[, parent])

Build the concrete editor for spec (plugin-settings scope).

make_override_editor(spec[, parent, ...])

Build the scope editor for spec (project or layer scope).

project_only_fields()

Return the project-only default fields (the SPEC §3 inputs with a variable but no setting).

set_concrete_value(spec, editor, value)

Set a concrete editor's value from its stored string token.

Classes

FieldKind(*values)

How a field's value is edited and coerced (SPEC §3/§4 value types).

FieldSpec(key, label, kind[, choices, ...])

One editable field on a defaults page (one §3 setting or §4 layer variable).

OverrideCheckBox([default_value, parent])

A default-aware 2-state boolean editor whose unset state mirrors the builtin default.

OverrideCheckableCombo(choices[, parent])

A checkable multi-select whose empty (nothing-checked) state means inherit.

OverrideComboBox(choices, *[, ...])

A combo whose "inherit" choice (or empty edit text) means inherit.

OverrideExpressionEdit([parent])

An expression line edit whose empty state means "unset" (project-only rows).

OverrideFieldsCombo(field_names[, parent])

A multi-select of the layer's field names whose value is a JSON list.

OverrideForm(fields, *[, inheriting])

A form of inheritance-aware editors for a set of fields (project/layer scope).

OverrideLayerCombo([parent])

A project-layer combo whose labeled empty row means "unset" (project-only rows).

OverrideLineEdit([parent])

A line edit whose empty state means "inherit".

OverridePredicateCombo(named[, parent])

Spatial-predicate editor: checkable named predicates + a validated DE-9IM free-text row.

OverrideSpinBox(max_value[, parent])

A range-bound integer spin box whose below-range value means "inherit".

class stratified_packager.gui.widgets.FieldKind(*values)[source]

How a field’s value is edited and coerced (SPEC §3/§4 value types).

BOOL = 'bool'

Boolean, stored as the tokens true / false.

ENUM = 'enum'

One of a fixed token set.

EXPRESSION = 'expression'

A QGIS expression string, edited with the expression-builder line edit (the project-only §3 fields; empty = unset).

FIELDS = 'fields'

Multi-select of the layer’s own field names, stored as a JSON list (SPEC §4).

INT = 'int'

Non-negative integer.

LAYER = 'layer'

A project vector layer, stored as its layer id (the project-only §3 fields).

MULTI_ENUM = 'multi_enum'

Any subset of a fixed token set, stored as comma-separated tokens.

PREDICATES = 'predicates'

Checkable named spatial predicates plus a validated free-text DE-9IM row (SPEC §4).

STRING = 'string'

Free text (also expressions and JSON lists).

class stratified_packager.gui.widgets.FieldSpec(key, label, kind, choices=(), labeled_choices=(), max_value=9, placeholder='', tristate=False, default_true=False)[source]

One editable field on a defaults page (one §3 setting or §4 layer variable).

Parameters:
__init__(key, label, kind, choices=(), labeled_choices=(), max_value=9, placeholder='', tristate=False, default_true=False)
Parameters:
choices: tuple[str, ...] = ()

Allowed tokens for FieldKind.ENUM.

default_true: bool = False

The builtin default of a 2-state FieldKind.BOOL field. Only consulted for a non-inheriting field rendered as an OverrideCheckBox: when True the checkbox renders inverted (checked by default = unset, unchecking = explicit false), so the sole meaningful override of a True-default variable stays expressible.

key: str

Storage key: always the bare variable/setting suffix (e.g. compression_level, exclude) — a valid StratifiedPackagerSettings attribute name for the ✓ inputs. The full stratified_packager_<key> variable name is variable.

kind: FieldKind

The field’s value kind.

label: str

Translated, user-facing label.

labeled_choices: tuple[tuple[str, str], ...] = ()

(label, token) pairs for FieldKind.MULTI_ENUM (label shown, token stored).

max_value: int = 9

Upper bound for FieldKind.INT editors (lower bound is always 0).

placeholder: str = ''

Plain placeholder shown for the unset state in non-inheriting (layer) scope, and the sentinel item’s label for a non-inheriting combo (e.g. auto). Ignored when the form is inheriting (the Project Properties page shows an inherit (= X) placeholder instead).

tristate: bool = False

Whether a FieldKind.BOOL field is genuinely tri-state (true/false/unset, like stage). In non-inheriting scope such a field renders as a sentinel-labelled combo rather than a 2-state checkbox, so the explicit false (force-off) state stays expressible.

property variable: str

The full project/layer variable name backing this field.

key is always the bare suffix (a settings attribute name for the ✓ inputs); this prepends the stratified_packager_ prefix in exactly one place, so a host never hand-builds the variable name.

Returns:

stratified_packager_<key>.

class stratified_packager.gui.widgets.OverrideCheckBox(default_value=False, parent=None)[source]

A default-aware 2-state boolean editor whose unset state mirrors the builtin default.

Used in non-inheriting (layer) scope, where a boolean variable has no higher tier to inherit from — only a builtin default that applies while the variable is unset. The box’s checked state mirrors the effective boolean, so an unset field rests on its default; an override is stored only when the box differs from that default. With a False default (the common case) that means checked = true and unchecked = unset; with a True default it inverts — checked = unset and unchecking = explicit false — keeping the sole meaningful override of a True-default variable expressible. Tri-state booleans (stage) use a sentinel combo instead, so all three of true/false/unset stay distinct.

Parameters:
  • default_value (bool)

  • parent (QWidget | None)

__init__(default_value=False, parent=None)[source]

Build the checkbox resting on its builtin default (so an unset field shows that state).

Parameters:
  • default_value (bool) – The field’s builtin default; the box starts in this state and reads back as unset whenever it matches it.

  • parent (QWidget | None) – Optional parent widget.

scope_value()[source]

Return the explicit override, or None (unset) when the box matches the default.

Return type:

str | None

Returns:

"true"/"false" when the box differs from the builtin default, else None.

set_effective(effective)[source]

No-op: a layer boolean has no inherited tier to surface.

Parameters:

effective (str) – Ignored.

Return type:

None

set_scope_value(value)[source]

Set the box from an explicit token, or rest it on the default when unset.

Parameters:

value (str | None) – A boolean token, or None/empty to rest on the builtin default.

Return type:

None

class stratified_packager.gui.widgets.OverrideCheckableCombo(choices, parent=None)[source]

A checkable multi-select whose empty (nothing-checked) state means inherit.

Parameters:
  • choices (Sequence[tuple[str, str]])

  • parent (QWidget | None)

__init__(choices, parent=None)[source]

Build the checkable combo with choices (all unchecked = inherit).

Parameters:
  • choices (Sequence[tuple[str, str]]) – (label, token) pairs in display order.

  • parent (QWidget | None) – Optional parent widget.

scope_value()[source]

Return the checked tokens as CSV, or None when nothing is checked.

Return type:

str | None

Returns:

Comma-separated checked tokens, or None to inherit.

set_effective(effective)[source]

Show the inherited effective value as the no-selection placeholder.

A full selection (every category, the common default) collapses to all so the placeholder stays short; partial selections show their tokens verbatim.

Parameters:

effective (str) – The inherited effective value (comma-separated tokens).

Return type:

None

set_scope_value(value)[source]

Check the items named by value (or clear all to inherit).

Parameters:

value (str | None) – Comma-separated tokens, or None/empty to inherit.

Return type:

None

class stratified_packager.gui.widgets.OverrideComboBox(choices, *, sentinel_label=None, parent=None)[source]

A combo whose “inherit” choice (or empty edit text) means inherit.

Parameters:
  • choices (Sequence[tuple[str, str]])

  • sentinel_label (str | None)

  • parent (QWidget | None)

__init__(choices, *, sentinel_label=None, parent=None)[source]

Build the combo with an unset affordance plus choices.

Parameters:
  • choices (Sequence[tuple[str, str]]) – (label, token) pairs in display order.

  • sentinel_label (str | None) – Fixed label for the unset/sentinel item (data None), used by non-inheriting (layer) scope, e.g. auto. When None the item shows the inheriting inherit (= X) placeholder instead (set via set_effective()).

  • parent (QWidget | None) – Optional parent widget.

scope_value()[source]

Return the selected token, or None when inheriting.

Return type:

str | None

Returns:

The token, or None if the inherit choice is active.

set_effective(effective)[source]

Show the inherited effective value (placeholder, or the unset item’s label).

A combo built with a fixed sentinel_label (non-inheriting scope) keeps that label.

Parameters:

effective (str) – The inherited effective value, stringified.

Return type:

None

set_scope_value(value)[source]

Select the item matching value (or the inherit state).

Parameters:

value (str | None) – The token to select, or None/empty to inherit.

Return type:

None

class stratified_packager.gui.widgets.OverrideExpressionEdit(parent=None)[source]

An expression line edit whose empty state means “unset” (project-only rows).

Parameters:

parent (QWidget | None)

__init__(parent=None)[source]

Initialize the editor.

Parameters:

parent (QWidget | None) – Optional parent widget.

scope_value()[source]

Return the explicit expression, or None when the field is unset.

Return type:

str | None

Returns:

The trimmed expression, or None if empty.

set_context_layer(layer)[source]

Give the expression builder layer’s fields as context (a non-vector layer clears it).

Parameters:

layer (QgsMapLayer | None) – The layer to take fields from, or None to clear.

Return type:

None

set_effective(effective)[source]

No-op: a project-only field has no plugin-setting tier to surface.

The builtin fallback (feature id) is already stated in the field label.

Parameters:

effective (str) – Ignored.

Return type:

None

set_scope_value(value)[source]

Set the explicit expression (or clear it to unset).

Parameters:

value (str | None) – The expression to show, or None/empty to unset.

Return type:

None

class stratified_packager.gui.widgets.OverrideFieldsCombo(field_names, parent=None)[source]

A multi-select of the layer’s field names whose value is a JSON list.

Like OverrideCheckableCombo (nothing checked = inherit) but the checked names are serialised as a JSON list rather than CSV, because field names may contain commas and the matching engine reads excluded_fields as JSON. The only inheritable value is the builtin [] (exclude nothing), so the empty state simply reads inherit.

Parameters:
  • field_names (Sequence[str])

  • parent (QWidget | None)

__init__(field_names, parent=None)[source]

Build the combo with one checkable item per field name (all unchecked = inherit).

Parameters:
  • field_names (Sequence[str]) – The layer’s field names, in display order.

  • parent (QWidget | None) – Optional parent widget.

scope_value()[source]

Return the checked field names as a JSON list, or None when nothing is checked.

Return type:

str | None

Returns:

A JSON array of the checked names, or None to inherit.

set_effective(effective)[source]

Show the inherited (always-empty) state as the no-selection placeholder.

Parameters:

effective (str) – The inherited effective value (the builtin []); unused beyond yielding the plain inherit placeholder.

Return type:

None

set_scope_value(value)[source]

Check the items named by the JSON list in value (or clear all to inherit).

A name no longer present in the layer is silently dropped (the combo can only represent current fields).

Parameters:

value (str | None) – A JSON list of field names, or None/empty to inherit.

Return type:

None

class stratified_packager.gui.widgets.OverrideForm(fields, *, inheriting=True)[source]

A form of inheritance-aware editors for a set of fields (project/layer scope).

Builds one labelled editor per FieldSpec into a caller-supplied QFormLayout, then loads/dumps the explicit values keyed by field key. Used by the Project Properties page and the per-layer page so the inherit-vs-override behaviour lives in one place.

Parameters:
__init__(fields, *, inheriting=True)[source]

Initialize the form for fields (call build() to create the editors).

Parameters:
  • fields (Sequence[FieldSpec]) – The fields to edit, in display order.

  • inheriting (bool) – Whether the fields inherit from a higher tier (project scope) or fall back only to their builtin defaults (layer scope); forwarded to every editor.

build(form_layout, parent=None, field_names=())[source]

Create the editors and add them as labelled rows to form_layout.

Parameters:
  • form_layout (QFormLayout) – The layout to populate (one row per field).

  • parent (QObject | None) – Optional parent for the editors.

  • field_names (Sequence[str]) – The host layer’s field names, forwarded to any FieldKind.FIELDS editor; ignored for every other kind.

Return type:

None

dump()[source]

Read the explicit value of every field, keyed by its bare FieldSpec.key.

Return type:

dict[str, str | None]

Returns:

{field key: explicit value or None} (None means inherit).

dump_variables()[source]

Read the explicit value of every field, keyed by its full variable name.

The single place the stratified_packager_ prefix is applied on write, so a host never hand-builds variable names from dump() keys.

Return type:

dict[str, str | None]

Returns:

{stratified_packager_<key>: explicit value or None} (None = inherit).

editor(key)[source]

Return one field’s editor (e.g. to wire cross-field signals).

Parameters:

key (str) – The field key.

Return type:

OverrideLineEdit | OverrideComboBox | OverrideCheckBox | OverrideCheckableCombo | OverrideFieldsCombo | OverridePredicateCombo | OverrideSpinBox | OverrideExpressionEdit | OverrideLayerCombo

Returns:

The field’s scope editor.

Raises:

KeyError – If key is not a field of this form.

load(current, effective)[source]

Populate the editors from the current explicit values and inherited values.

Parameters:
  • current (Mapping[str, str | None]) – Explicit values per field key (missing/None = unset).

  • effective (Mapping[str, str]) – Inherited effective value per field key (for the placeholder); unused in non-inheriting scope, where the placeholder is fixed at build time.

Return type:

None

set_enabled(key, *, enabled)[source]

Enable or disable one field’s editor (e.g. gate an inapplicable field).

Parameters:
  • key (str) – The field key.

  • enabled (bool) – Whether the editor accepts edits.

Raises:

KeyError – If key is not a field of this form.

Return type:

None

set_value(key, value)[source]

Set one field’s explicit value (or clear it to inherit).

Parameters:
  • key (str) – The field key.

  • value (str | None) – The explicit value, or None to inherit.

Raises:

KeyError – If key is not a field of this form.

Return type:

None

_editors: dict[str, OverrideLineEdit | OverrideComboBox | OverrideCheckBox | OverrideCheckableCombo | OverrideFieldsCombo | OverridePredicateCombo | OverrideSpinBox | OverrideExpressionEdit | OverrideLayerCombo]
fields: tuple[FieldSpec, ...]
class stratified_packager.gui.widgets.OverrideLayerCombo(parent=None)[source]

A project-layer combo whose labeled empty row means “unset” (project-only rows).

Stores the selected layer’s id — the format the runtime resolver feeds to mapLayer() (SPEC §5). The filter admits geometryless tables, matching STRATIFICATION_LAYER’s TypeVector (SPEC §3). A stale/unknown id loads as unset, so applying the page clears it (fail-fast).

Parameters:

parent (QWidget | None)

__init__(parent=None)[source]

Initialize the combo (vector layers incl. geometryless tables, empty row first).

Parameters:

parent (QWidget | None) – Optional parent widget.

scope_value()[source]

Return the selected layer’s id, or None when the empty row is selected.

Return type:

str | None

Returns:

The layer id, or None.

set_effective(effective)[source]

No-op: a project-only field has no plugin-setting tier to surface.

Parameters:

effective (str) – Ignored.

Return type:

None

set_scope_value(value)[source]

Select the layer with id value, or the empty row when unset/unknown.

Parameters:

value (str | None) – The layer id, or None/empty to unset.

Return type:

None

class stratified_packager.gui.widgets.OverrideLineEdit(parent=None)[source]

A line edit whose empty state means “inherit”.

Parameters:

parent (QWidget | None)

__init__(parent=None)[source]

Initialize the editor.

Parameters:

parent (QWidget | None) – Optional parent widget.

scope_value()[source]

Return the explicit value, or None when the field inherits.

Return type:

str | None

Returns:

The trimmed text, or None if empty.

set_effective(effective)[source]

Show the inherited effective value as the placeholder.

Parameters:

effective (str) – The inherited effective value, stringified.

Return type:

None

set_scope_value(value)[source]

Set the explicit value (or clear it to inherit).

Parameters:

value (str | None) – The value to show, or None/empty to inherit.

Return type:

None

class stratified_packager.gui.widgets.OverridePredicateCombo(named, parent=None)[source]

Spatial-predicate editor: checkable named predicates + a validated DE-9IM free-text row.

The named predicates (SPEC §4) are checkable items; the last, non-checkable popup row hosts a line edit for one or more comma-separated DE-9IM patterns, validated live against DE9IM_PATTERN. The empty state (nothing checked, blank text) means inherit. The value read and written is the comma-joined token list the matching engine parses.

Parameters:
  • named (Sequence[str])

  • parent (QWidget | None)

__init__(named, parent=None)[source]

Build the combo with the named predicates and the DE-9IM row.

Parameters:
  • named (Sequence[str]) – The named-predicate tokens, in display order.

  • parent (QWidget | None) – Optional parent widget.

_on_de9im_changed(text)[source]

Validate the DE-9IM row live, flagging invalid patterns with a red border.

Parameters:

text (str) – The current DE-9IM row text.

Return type:

None

_refresh_display()[source]

Mirror the checked names and DE-9IM patterns into the collapsed display bar.

Return type:

None

de9im_row_width_hint()[source]

Return the pixel width needed to show the DE-9IM popup row’s full placeholder.

Return type:

int

Returns:

Width of the DE-9IM: label plus the DE-9IM pattern(s)… placeholder plus popup chrome, so the column (hence the popup) shows the placeholder in full.

scope_value()[source]

Return the checked named predicates plus DE-9IM patterns as CSV, or None.

Return type:

str | None

Returns:

Comma-joined tokens, or None when nothing is checked and the DE-9IM row is blank (inherit).

set_effective(effective)[source]

Show the inherited effective value as the no-selection placeholder.

Parameters:

effective (str) – The inherited effective value, stringified.

Return type:

None

set_placeholder(text)[source]

Set the no-selection placeholder text verbatim (non-inheriting scope).

Parameters:

text (str) – The placeholder to show when nothing is checked.

Return type:

None

set_scope_value(value)[source]

Check the named tokens in value and route the remaining tokens to the DE-9IM row.

Parameters:

value (str | None) – Comma-separated tokens, or None/empty to inherit.

Return type:

None

_DE9IM_ROW_PADDING: ClassVar[int] = 48

Pixels for the popup row’s checkbox indent, item margins and the combo arrow/frame.

_default_text: str
_named: tuple[str, ...]
de9im_invalid: bool

Whether the DE-9IM row holds an invalid pattern (advisory; the run-start validation is authoritative).

class stratified_packager.gui.widgets.OverrideSpinBox(max_value, parent=None)[source]

A range-bound integer spin box whose below-range value means “inherit”.

Parameters:
  • max_value (int)

  • parent (QWidget | None)

__init__(max_value, parent=None)[source]

Build the spin box over 0..max_value with a below-range inherit sentinel.

The minimum is -1 (one step below the valid range); resting there shows the inherit placeholder via setSpecialValueText() and reads back as inherit. The valid override range stays 0..max_value.

Parameters:
  • max_value (int) – The inclusive upper bound (lower bound is always 0).

  • parent (QWidget | None) – Optional parent widget.

scope_value()[source]

Return the explicit value, or None when the field inherits.

Return type:

str | None

Returns:

The value as a string, or None when below the valid range.

set_effective(effective)[source]

Show the inherited effective value as the inherit-sentinel label.

Parameters:

effective (str) – The inherited effective value, stringified.

Return type:

None

set_scope_value(value)[source]

Set the explicit value (or rest on the inherit sentinel).

Parameters:

value (str | None) – The value to show, or None/empty to inherit.

Return type:

None

stratified_packager.gui.widgets._checkable_csv(combo)[source]

Read a checkable combo’s checked tokens as a comma-separated string (item order).

Parameters:

combo (QgsCheckableComboBox) – The checkable combo.

Return type:

str

Returns:

The checked tokens joined by , (empty when nothing is checked).

stratified_packager.gui.widgets._default_field(key, label, kind)[source]

Build one settings-backed field from its parameter-table facts.

Parameters:
  • key (str) – The settings attribute name (the parameter id lowercased).

  • label (str) – The translated label.

  • kind (_Kind) – The parameter’s coercion kind, mapped to the matching editor kind.

Return type:

FieldSpec

Returns:

The field spec.

stratified_packager.gui.widgets._populate_checkable(combo, choices)[source]

Add (label, token) items (initially unchecked) to a checkable combo.

Parameters:
Return type:

None

stratified_packager.gui.widgets._set_checkable_csv(combo, csv)[source]

Check exactly the items whose token appears in csv, unchecking the rest.

Parameters:
Return type:

None

stratified_packager.gui.widgets._unexpected_editor(spec, editor)[source]

Build the message for an editor that does not match its field kind.

Parameters:
  • spec (FieldSpec) – The field whose editor was wrong.

  • editor (QWidget) – The mismatched editor.

Return type:

str

Returns:

A diagnostic message.

stratified_packager.gui.widgets.apply_overrides(target, values)[source]

Write explicit values to target, removing keys whose value is None (inherit).

Shared by every defaults page so the write-back rule lives in one place.

Parameters:
Return type:

None

stratified_packager.gui.widgets.concrete_value(spec, editor)[source]

Read a concrete editor’s value as its stored string token.

Parameters:
Return type:

str

Returns:

The value as a string token (true/false for booleans).

Raises:

TypeError – If editor is not the widget type spec implies.

stratified_packager.gui.widgets.default_fields()[source]

Return the settings-backed default fields (the ✓ rows of SPEC §3, in table order).

Derived from the parameter table: each key is the attribute name on StratifiedPackagerSettings (the input id lowercased) and the suffix of the matching stratified_packager_<x> project variable; the label is the input’s canonical translated label. A new settings-backed input therefore appears on the Options and Project pages without touching this module.

Return type:

tuple[FieldSpec, ...]

Returns:

The default fields in display order.

stratified_packager.gui.widgets.inherit_placeholder(effective)[source]

Format the placeholder shown by an empty (inheriting) editor.

Parameters:

effective (str) – The inherited effective value, already stringified.

Return type:

str

Returns:

e.g. inherit (= true); just inherit when effective is empty.

stratified_packager.gui.widgets.layer_fields()[source]

Return the per-layer variable fields (SPEC §4, in table order).

Derived from LAYER_VAR_SPECS: keys, labels and order come from the table; only the presentation (editor kind, choices, placeholders) is decided here. Each key is the layer variable’s bare suffix (as with default_fields()); the full stratified_packager_<x> name is FieldSpec.variable. These variables have no project/plugin tier to inherit from, so the pages build them with inheriting=False (make_override_editor()): the FieldSpec.placeholder is the plain unset affordance, auto doubling as the sentinel-item label for the tri-state fields.

Return type:

tuple[FieldSpec, ...]

Returns:

The layer-variable fields in display order.

stratified_packager.gui.widgets.make_concrete_editor(spec, parent=None)[source]

Build the concrete editor for spec (plugin-settings scope).

Parameters:
  • spec (FieldSpec) – The field to edit.

  • parent (QWidget | None) – Optional parent widget.

Return type:

QWidget

Returns:

A plain QCheckBox / QSpinBox / QComboBox / QLineEdit.

stratified_packager.gui.widgets.make_override_editor(spec, parent=None, field_names=(), *, inheriting=True)[source]

Build the scope editor for spec (project or layer scope).

With inheriting=True (project scope) the editor surfaces the next-tier value as an inherit (= X) placeholder. With inheriting=False (layer scope, no tier to inherit from) it presents the unset state plainly: a OverrideCheckBox for a 2-state boolean, a sentinel_label combo for a tri-state boolean or enum, and the field’s FieldSpec.placeholder for the text/predicate editors.

Parameters:
  • spec (FieldSpec) – The field to edit.

  • parent (QWidget | None) – Optional parent widget.

  • field_names (Sequence[str]) – The host layer’s field names, used to populate a FieldKind.FIELDS editor; ignored for every other kind.

  • inheriting (bool) – Whether the field inherits from a higher tier (project scope) or falls back only to its builtin default (layer scope). The project-only FieldKind.EXPRESSION / FieldKind.LAYER kinds ignore it (no tier below them either way).

Return type:

ScopeEditor

Returns:

An OverrideLineEdit, OverrideComboBox, OverrideCheckBox, OverrideCheckableCombo, OverrideFieldsCombo, OverridePredicateCombo, OverrideSpinBox, OverrideExpressionEdit or OverrideLayerCombo.

stratified_packager.gui.widgets.project_only_fields()[source]

Return the project-only default fields (the SPEC §3 inputs with a variable but no setting).

These inputs hold project-dependent values (a layer id, an expression over that layer’s fields), so they have no global plugin-setting tier: the Project Properties page is their only defaults surface. Each key is the input’s project-variable suffix (the SPEC §5 variable_name rule).

Return type:

tuple[FieldSpec, ...]

Returns:

The project-only fields in SPEC §3 declaration order.

stratified_packager.gui.widgets.set_concrete_value(spec, editor, value)[source]

Set a concrete editor’s value from its stored string token.

Parameters:
Raises:

TypeError – If editor is not the widget type spec implies.

Return type:

None

stratified_packager.gui.widgets.MATCHING_METHOD_LABELS: Final[dict[str, str]] = {'attribute': qgis.PyQt.QtCore.QCoreApplication.translate, 'spatial': qgis.PyQt.QtCore.QCoreApplication.translate, 'whole_export': qgis.PyQt.QtCore.QCoreApplication.translate}

Per-layer matching-method combo labels keyed by SPEC §4 token (auto is the sentinel, not a selectable option).

stratified_packager.gui.widgets.OVERWRITE_MODE_LABELS: Final[dict[str, str]] = {'error': qgis.PyQt.QtCore.QCoreApplication.translate, 'overwrite': qgis.PyQt.QtCore.QCoreApplication.translate, 'skip-existing': qgis.PyQt.QtCore.QCoreApplication.translate}

OVERWRITE_MODE combo labels keyed by SPEC §10 token.

stratified_packager.gui.widgets.PROJECT_FIELD_STRATIFICATION_LAYER: Final = 'stratification_layer'

Key of the stratification-layer project-only field (its project-variable suffix).

stratified_packager.gui.widgets.PROJECT_FIELD_STRATUM_NAME_EXPRESSION: Final = 'stratum_name_expression'

Key of the stratum-name-expression project-only field (its project-variable suffix).

stratified_packager.gui.widgets.PROJECT_INCLUSION_LABELS: Final[dict[str, str]] = {'gpkg': qgis.PyQt.QtCore.QCoreApplication.translate, 'none': qgis.PyQt.QtCore.QCoreApplication.translate, 'qgz': qgis.PyQt.QtCore.QCoreApplication.translate}

PROJECT_INCLUSION combo labels keyed by SPEC §13 token.

stratified_packager.gui.widgets.ScopeEditor = stratified_packager.gui.widgets.OverrideLineEdit | stratified_packager.gui.widgets.OverrideComboBox | stratified_packager.gui.widgets.OverrideCheckBox | stratified_packager.gui.widgets.OverrideCheckableCombo | stratified_packager.gui.widgets.OverrideFieldsCombo | stratified_packager.gui.widgets.OverridePredicateCombo | stratified_packager.gui.widgets.OverrideSpinBox | stratified_packager.gui.widgets.OverrideExpressionEdit | stratified_packager.gui.widgets.OverrideLayerCombo

Any scope editor; all expose scope_value / set_scope_value / set_effective and are QWidget subclasses.

stratified_packager.gui.widgets.WARM_START_MODE_LABELS: Final[dict[str, str]] = {'off': qgis.PyQt.QtCore.QCoreApplication.translate, 'update': qgis.PyQt.QtCore.QCoreApplication.translate, 'use': qgis.PyQt.QtCore.QCoreApplication.translate}

WARM_START_MODE combo labels keyed by SPEC §11 token.