spacr.qt.widgets.condition_annotation_dialog

Assign condition labels using metadata rules and stable multirow drag/drop.

Classes

ConditionAnnotationDialog

Edit, preview and safely apply labels to any loaded table.

ConditionBox

One named condition with explicit metadata rules and dropped source rows.

ConditionRowsModel

Expose source rows in immutable positional order and optional preview labels.

ConditionSourceTable

Drag selected proxy rows using their original source identities.

Module Contents

class spacr.qt.widgets.condition_annotation_dialog.ConditionAnnotationDialog(frame, source, parent=None, *, definition=None, threaded=True)[source]

Bases: PySide6.QtWidgets.QDialog

Edit, preview and safely apply labels to any loaded table.

Parameters:
  • frame – Original unannotated source frame.

  • source – Source context binding the definition to a file/table/schema.

  • parent – Owning screen.

  • definition – Existing annotation to reopen, or None for a new one.

  • threaded – Evaluate full-table patterns on a worker when true.

Build the sortable source table and an unbounded collection of boxes.

Parameters:
  • frame – Immutable source measurements and metadata.

  • source – Source context.

  • parent – Owning screen.

  • definition – Existing annotation definition to copy.

  • threaded – Use background preview evaluation.

accept()[source]

Apply only the current validated draft, leaving source rows untouched.

add_box(condition=None)[source]

Append another named condition without imposing a fixed count.

Parameters:

condition – Existing rule to edit, or None for a blank condition.

Returns:

Newly added ConditionBox.

configuration()[source]

Return a private reproducible copy of the current editor state.

refresh_preview()[source]

Check metadata rules and row labels in a background task.

Enable the Apply button after validation succeeds without conflicts.

reject()[source]

Discard draft edits and stop delivery of pending preview results.

remove_box(box)[source]

Remove a condition from this unsaved draft and recompute diagnostics.

Parameters:

box – ConditionBox being removed.

class spacr.qt.widgets.condition_annotation_dialog.ConditionBox(source_model, condition, parent=None)[source]

Bases: PySide6.QtWidgets.QFrame

One named condition with explicit metadata rules and dropped source rows.

Parameters:
  • source_model – Immutable source rows and token mapping.

  • condition – Condition definition copied into editable controls.

  • parent – Owning annotation dialog.

Place metadata column, include and exclude controls at the top.

Parameters:
  • source_model – Source data model.

  • condition – Initial condition definition.

  • parent – Owning widget.

Old recipe and API editing is preserved: entering a legacy regex explicitly switches to its editor rather than silently ignoring the expression.

add_mime_rows(mime)[source]

Accept only tokens from this exact source and keep earlier memberships.

Parameters:

mime – Drag MIME data generated by the source table.

Returns:

Whether the payload was accepted.

clear_manual_rows()[source]

Remove all manual memberships from this condition.

definition()[source]

Return the controls as a reproducible condition rule.

dragEnterEvent(event)[source]

Offer copy only for spaCR condition-row drags.

Parameters:

event – Qt drag-entry event.

dragMoveEvent(event)[source]

Allow moving a supported row drag within this box.

Parameters:

event – Qt drag-move event.

dropEvent(event)[source]

Resolve dropped rows by their source tokens, independent of sorting.

Parameters:

event – Qt drop event.

remove_selected_rows()[source]

Remove only selected manual memberships; regex rules remain visible.

class spacr.qt.widgets.condition_annotation_dialog.ConditionRowsModel(frame, parent=None)[source]

Bases: PySide6.QtCore.QAbstractTableModel

Expose source rows in immutable positional order and optional preview labels.

Parameters:
  • frame – Unmodified source frame.

  • parent – Owning widget.

Retain the source frame and its duplicate-safe row tokens.

Parameters:
  • frame – Source measurements and metadata.

  • parent – Owning object.

columnCount(parent=QModelIndex())[source]

Include all generated preview columns beside the source columns.

Parameters:

parent – Qt parent index.

data(index, role=Qt.DisplayRole)[source]

Read by source position, never by the DataFrame index label.

Parameters:
  • index – Source model cell.

  • role – Qt display or sorting role.

headerData(section, orientation, role=Qt.DisplayRole)[source]

Show all metadata column names and the working assignment preview.

Parameters:
  • section – Row or column position.

  • orientation – Header orientation.

  • role – Qt role.

rowCount(parent=QModelIndex())[source]

Count source rows; child indices have no rows.

Parameters:

parent – Qt parent index.

row_summary(token)[source]

Describe a manually assigned source row with its metadata values.

Parameters:

token – Stable row token from this source model.

Returns:

Source row number and a bounded metadata summary.

set_preview(values)[source]

Refresh assignment diagnostics without reordering source rows.

Parameters:

values – Ordered output-name/Series mapping, one label Series, or None.

class spacr.qt.widgets.condition_annotation_dialog.ConditionSourceTable[source]

Bases: PySide6.QtWidgets.QTableView

Drag selected proxy rows using their original source identities.

selection_mime()[source]

Encode the current multiselection with the full source fingerprint.

Returns:

Drag MIME data, or None when no rows are selected.

startDrag(supported_actions)[source]

Create one token per selected row after sorting/filtering.

Parameters:

supported_actions – Qt drag action flags.

Nested helpers

ConditionAnnotationDialog._load_schema.work()

Load a schema in a worker and apply it to a copy of the table.

spacr/qt/widgets/condition_annotation_dialog.py:983

ConditionAnnotationDialog._save_schema.work()

Save the schema in a worker; returns the path, rows and any error.

spacr/qt/widgets/condition_annotation_dialog.py:943

ConditionAnnotationDialog.refresh_preview.work()

Preview the draft in a worker and apply it to a copy of the table.

Failures travel through the generation-guarded result channel too, so a slow invalid draft cannot disable a newer valid preview.

spacr/qt/widgets/condition_annotation_dialog.py:1543