EditorLib::OperationContext
EditorLib::OperationContext
Manages transient data flow connections between widgets.
#include <OperationContext.hpp>
Inherits from QObject
Public Slots
| Name | |
|---|---|
| void | onSelectionChanged() Handle selection changes from SelectionContext. |
| void | onEditorUnregistered(EditorInstanceId const & instance_id) Handle editor unregistration. |
Public Signals
| Name | |
|---|---|
| void | operationRequested(EditorLib::PendingOperation const & op) Emitted when an operation is requested. |
| void | operationDelivered(EditorLib::PendingOperation const & op, EditorLib::OperationResult const & result) Emitted when a result is delivered. |
| void | operationClosed(EditorLib::OperationId const & id, EditorLib::OperationCloseReason reason) Emitted when an operation closes (with or without delivery). |
| void | pendingOperationChanged(EditorLib::EditorTypeId const & producer_type) Emitted when the pending operation for a producer changes. |
Public Functions
| Name | |
|---|---|
| OperationContext(EditorRegistry * registry, QObject * parent =[nullptr]) Construct an OperationContext. |
|
| ~OperationContext() override | |
| std::optional< PendingOperation > | requestOperation(EditorInstanceId requester, const EditorTypeId & producer_type, OperationRequestOptions options ={}) Request output from a producer widget type. |
| std::optional< PendingOperation > | pendingOperationFor(EditorTypeId const & producer_type) const Check if there’s a pending operation for a producer type. |
| std::optional< EditorInstanceId > | requesterFor(EditorTypeId const & producer_type) const Get the requester for a pending operation. |
| bool | deliverResult(EditorTypeId const & producer_type, const OperationResult & result) Deliver a result for a pending operation. |
| void | closeOperation(OperationId const & id, OperationCloseReason reason =OperationCloseReason::Explicit) Explicitly close an operation by ID. |
| void | closeOperationsFor(EditorTypeId const & producer_type, OperationCloseReason reason) Close any pending operation for a producer type. |
| void | closeOperationsFrom(EditorInstanceId const & requester, OperationCloseReason reason) Close any pending operations from a requester. |
| bool | hasOperation(OperationId const & id) const Check if an operation is currently pending. |
| std::optional< PendingOperation > | operation(OperationId const & id) const Get an operation by ID. |
| size_t | pendingCount() const Get the number of pending operations. |
Public Slots Documentation
slot onSelectionChanged
void onSelectionChanged()Handle selection changes from SelectionContext.
Closes operations that have close_on_selection_change set.
slot onEditorUnregistered
void onEditorUnregistered(
EditorInstanceId const & instance_id
)Handle editor unregistration.
Parameters:
- instance_id The unregistered editor’s ID
Closes operations involving the unregistered editor.
Public Signals Documentation
signal operationRequested
void operationRequested(
EditorLib::PendingOperation const & op
)Emitted when an operation is requested.
Parameters:
- op The requested operation
EditorRegistry listens to this to open/focus producer widgets.
signal operationDelivered
void operationDelivered(
EditorLib::PendingOperation const & op,
EditorLib::OperationResult const & result
)Emitted when a result is delivered.
Parameters:
- op The operation that was fulfilled
- result The delivered data
Consumers connect to this to receive results.
signal operationClosed
void operationClosed(
EditorLib::OperationId const & id,
EditorLib::OperationCloseReason reason
)Emitted when an operation closes (with or without delivery).
Parameters:
- id The operation ID
- reason Why the operation closed
signal pendingOperationChanged
void pendingOperationChanged(
EditorLib::EditorTypeId const & producer_type
)Emitted when the pending operation for a producer changes.
Parameters:
- producer_type The producer type whose pending operation changed
Producers connect to update their UI (show target indicator).
Public Functions Documentation
function OperationContext
explicit OperationContext(
EditorRegistry * registry,
QObject * parent =nullptr
)Construct an OperationContext.
Parameters:
- registry The EditorRegistry (for widget lookup, may be nullptr for tests)
- parent Parent QObject
function ~OperationContext
~OperationContext() overridefunction requestOperation
std::optional< PendingOperation > requestOperation(
EditorInstanceId requester,
const EditorTypeId & producer_type,
OperationRequestOptions options ={}
)Request output from a producer widget type.
Parameters:
- requester Who is making the request
- producer_type What type of widget should produce the output
- options Request options (channel, close behavior)
Return: The pending operation, or nullopt if request failed
If no instance of producer_type exists and it’s allowed to be created, one will be created and focused.
If there’s already a pending operation for this producer_type, the old one is closed with reason Superseded.
function pendingOperationFor
std::optional< PendingOperation > pendingOperationFor(
EditorTypeId const & producer_type
) constCheck if there’s a pending operation for a producer type.
Parameters:
- producer_type The producer type to check
Return: The pending operation if one exists
Producers call this in their “apply” handlers to know whether to route output to a requester vs. normal behavior.
function requesterFor
std::optional< EditorInstanceId > requesterFor(
EditorTypeId const & producer_type
) constGet the requester for a pending operation.
Parameters:
- producer_type The producer type to check
Return: The requester’s instance ID if there’s a pending operation
Useful for UI display (showing who will receive the output).
function deliverResult
bool deliverResult(
EditorTypeId const & producer_type,
const OperationResult & result
)Deliver a result for a pending operation.
Parameters:
- producer_type The producing widget’s type
- result The result data
Return: true if there was a pending operation and result was delivered
Called by the producer when it has output ready. Emits operationDelivered signal.
function closeOperation
void closeOperation(
OperationId const & id,
OperationCloseReason reason =OperationCloseReason::Explicit
)Explicitly close an operation by ID.
Parameters:
- id The operation to close
- reason Why the operation is being closed
function closeOperationsFor
void closeOperationsFor(
EditorTypeId const & producer_type,
OperationCloseReason reason
)Close any pending operation for a producer type.
Parameters:
- producer_type The producer type
- reason Why the operation is being closed
function closeOperationsFrom
void closeOperationsFrom(
EditorInstanceId const & requester,
OperationCloseReason reason
)Close any pending operations from a requester.
Parameters:
- requester The requester’s instance ID
- reason Why the operation is being closed
Called when a requester widget is being destroyed.
function hasOperation
bool hasOperation(
OperationId const & id
) constCheck if an operation is currently pending.
Parameters:
- id The operation ID to check
Return: true if the operation exists and is pending
function operation
std::optional< PendingOperation > operation(
OperationId const & id
) constGet an operation by ID.
Parameters:
- id The operation ID
Return: The operation if it exists
function pendingCount
size_t pendingCount() constGet the number of pending operations.
Updated on 2026-11-13 at 20:25:42 +0000