Skip to main content

StateManagement::WorkspaceManager

StateManagement::WorkspaceManager

#include <WorkspaceManager.hpp>

Inherits from QObject

Public Signals

Name
void workspaceSaved(QString path)
Emitted after a successful save.
void workspacePathChanged(QString path)
Emitted when the current workspace path changes.
void dirtyChanged(bool has_unsaved)
Emitted when the dirty flag changes.

Public Functions

Name
WorkspaceManager(QString const & config_dir, QObject * parent =[nullptr])
Construct WorkspaceManager.
~WorkspaceManager() override
void setEditorRegistry(EditorRegistry * registry)
void setZoneManager(ZoneManager * zone_manager)
void setDockStateCaptureCallback(std::function< std::string()> callback)
Set a callback to capture ADS dock state for layout persistence.
bool saveWorkspace(QString const & file_path)
Save the current session to a workspace file.
std::optional< WorkspaceData > readWorkspace(QString const & file_path) const
Load a workspace file and return its data.
void markRestored(QString const & file_path)
Mark the workspace as successfully restored.
void recordDataLoad(DataLoadEntry entry)
Record a data-loading operation for workspace provenance.
void recordJsonConfigLoad(QString const & config_file_path)
Record that a JSON config file was loaded.
void recordVideoLoad(QString const & video_path)
Record that a video was loaded.
void recordImagesLoad(QString const & images_dir)
Record that an image directory was loaded.
void clearDataLoads()
Clear all data load entries (e.g., before restoring a workspace).
std::vector< DataLoadEntry > const & dataLoads() const
Get the current list of data load entries.
void recordAppliedPipeline(std::string const & pipeline_json)
Record that a transform pipeline was applied (JSON string).
void clearAppliedPipelines()
Clear all recorded pipelines.
std::vector< std::string > const & appliedPipelines() const
Get the list of applied pipeline JSON strings.
void recordTableDefinition(std::string const & table_json)
Record that a table definition was created (JSON string).
void clearTableDefinitions()
Clear all recorded table definitions.
std::vector< std::string > const & tableDefinitions() const
Get the list of table definition JSON strings.
void enableAutoSave(int interval_ms =kDefaultAutoSaveIntervalMs)
Enable periodic auto-save to the recovery file.
void disableAutoSave()
Disable auto-save.
bool isAutoSaveEnabled() const
bool hasRecoveryFile() const
std::optional< WorkspaceData > readRecoveryFile() const
Read the recovery file and return its data.
void deleteRecoveryFile()
Delete the recovery file (after successful restore or user decline).
QString currentWorkspacePath() const
bool hasUnsavedChanges() const
void markDirty()
Mark the workspace as having unsaved changes.
void markClean()
Mark the workspace as clean (matches the last save).
QString recoveryFilePath() const

Public Attributes

Name
char const * kWorkspaceExtension
File extension for workspace files (including dot).
int kDefaultAutoSaveIntervalMs
Default auto-save interval in milliseconds (30 seconds).

Public Signals Documentation

signal workspaceSaved

void workspaceSaved(
    QString path
)

Emitted after a successful save.

signal workspacePathChanged

void workspacePathChanged(
    QString path
)

Emitted when the current workspace path changes.

signal dirtyChanged

void dirtyChanged(
    bool has_unsaved
)

Emitted when the dirty flag changes.

Public Functions Documentation

function WorkspaceManager

explicit WorkspaceManager(
    QString const & config_dir,
    QObject * parent =nullptr
)

Construct WorkspaceManager.

Parameters:

  • config_dir Application config directory (recovery file lives here)
  • parent Parent QObject

function ~WorkspaceManager

~WorkspaceManager() override

function setEditorRegistry

void setEditorRegistry(
    EditorRegistry * registry
)

function setZoneManager

void setZoneManager(
    ZoneManager * zone_manager
)

function setDockStateCaptureCallback

void setDockStateCaptureCallback(
    std::function< std::string()> callback
)

Set a callback to capture ADS dock state for layout persistence.

The callback should return a base64-encoded string of the ADS CDockManager::saveState() QByteArray. This avoids coupling WorkspaceManager to the ADS library.

function saveWorkspace

bool saveWorkspace(
    QString const & file_path
)

Save the current session to a workspace file.

Parameters:

  • file_path Absolute path to the workspace file

Return: true on success

Captures editor states, zone layout, and data load entries. Updates the current workspace path and clears the dirty flag.

function readWorkspace

std::optional< WorkspaceData > readWorkspace(
    QString const & file_path
) const

Load a workspace file and return its data.

Parameters:

  • file_path Path to the workspace file

Return: WorkspaceData on success, std::nullopt on failure

Parses the workspace file and returns the data. The caller (MainWindow) is responsible for orchestrating the actual restore (data reload, state restore, widget recreation, layout application).

function markRestored

void markRestored(
    QString const & file_path
)

Mark the workspace as successfully restored.

Parameters:

  • file_path The path of the workspace that was restored

Sets the current path and clears dirty state after a successful restore orchestrated by the caller.

function recordDataLoad

void recordDataLoad(
    DataLoadEntry entry
)

Record a data-loading operation for workspace provenance.

function recordJsonConfigLoad

void recordJsonConfigLoad(
    QString const & config_file_path
)

Record that a JSON config file was loaded.

function recordVideoLoad

void recordVideoLoad(
    QString const & video_path
)

Record that a video was loaded.

function recordImagesLoad

void recordImagesLoad(
    QString const & images_dir
)

Record that an image directory was loaded.

function clearDataLoads

void clearDataLoads()

Clear all data load entries (e.g., before restoring a workspace).

function dataLoads

std::vector< DataLoadEntry > const & dataLoads() const

Get the current list of data load entries.

function recordAppliedPipeline

void recordAppliedPipeline(
    std::string const & pipeline_json
)

Record that a transform pipeline was applied (JSON string).

function clearAppliedPipelines

void clearAppliedPipelines()

Clear all recorded pipelines.

function appliedPipelines

std::vector< std::string > const & appliedPipelines() const

Get the list of applied pipeline JSON strings.

function recordTableDefinition

void recordTableDefinition(
    std::string const & table_json
)

Record that a table definition was created (JSON string).

function clearTableDefinitions

void clearTableDefinitions()

Clear all recorded table definitions.

function tableDefinitions

std::vector< std::string > const & tableDefinitions() const

Get the list of table definition JSON strings.

function enableAutoSave

void enableAutoSave(
    int interval_ms =kDefaultAutoSaveIntervalMs
)

Enable periodic auto-save to the recovery file.

Parameters:

  • interval_ms Interval in milliseconds (default 30 s)

function disableAutoSave

void disableAutoSave()

Disable auto-save.

function isAutoSaveEnabled

bool isAutoSaveEnabled() const

Return: true if auto-save is currently enabled

function hasRecoveryFile

bool hasRecoveryFile() const

Return: true if a recovery file exists from a previous crash

function readRecoveryFile

std::optional< WorkspaceData > readRecoveryFile() const

Read the recovery file and return its data.

function deleteRecoveryFile

void deleteRecoveryFile()

Delete the recovery file (after successful restore or user decline).

function currentWorkspacePath

QString currentWorkspacePath() const

Return: Path of the currently open workspace (empty if none)

function hasUnsavedChanges

bool hasUnsavedChanges() const

Return: true if the session has unsaved changes

function markDirty

void markDirty()

Mark the workspace as having unsaved changes.

function markClean

void markClean()

Mark the workspace as clean (matches the last save).

function recoveryFilePath

QString recoveryFilePath() const

Return: Absolute path to the recovery file

Public Attributes Documentation

variable kWorkspaceExtension

static char const  * kWorkspaceExtension = ".wtb";

File extension for workspace files (including dot).

variable kDefaultAutoSaveIntervalMs

static int kDefaultAutoSaveIntervalMs = 30000;

Default auto-save interval in milliseconds (30 seconds).


Updated on 2026-11-13 at 20:25:41 +0000