Skip to main content

BatchProcessingState

BatchProcessingState

State class for BatchProcessing_Widget. More…

#include <BatchProcessingState.hpp>

Inherits from EditorState, QObject

Public Classes

Name
struct LoadResult
Result of a load operation.

Public Signals

Name
void topLevelFolderChanged(QString const & folderPath)
Emitted when the top-level folder changes.
void jsonConfigChanged()
Emitted when the JSON configuration changes.
void loadCompleted(LoadResult const & result)
Emitted when a load operation completes.

Public Functions

Name
BatchProcessingState(EditorRegistry * registry, std::shared_ptr< DataManager > data_manager, QObject * parent =[nullptr])
Construct a new BatchProcessingState.
~BatchProcessingState() override =default
virtual QString getTypeName() const override
Get unique type name for this editor state.
virtual QString getDisplayName() const override
Get display name for UI.
virtual void setDisplayName(QString const & name) override
Set display name.
virtual std::string toJson() const override
Serialize state to JSON string.
virtual bool fromJson(std::string const & json) override
Restore state from JSON string.
QString topLevelFolder() const
Get the current top-level folder.
void setTopLevelFolder(QString const & folderPath)
Set the top-level folder.
QString jsonFilePath() const
Get the current JSON file path (if loaded from file).
void setJsonFilePath(QString const & filePath)
Set the JSON file path (when loading from file).
QString jsonContent() const
Get the current JSON configuration content.
void setJsonContent(QString const & content)
Set the JSON configuration content.
bool canLoad() const
Check if the current state is valid for loading.
LoadResult loadFolder(QString const & selectedSubfolder =QString())
Load data from the current folder using the current JSON configuration.

Additional inherited members

Public Signals inherited from EditorState

Name
void stateChanged()
Emitted when any state property changes.
void displayNameChanged(QString const & newName)
Emitted when display name changes.
void dirtyChanged(bool isDirty)
Emitted when dirty state changes.

Public Functions inherited from EditorState

Name
EditorState(QObject * parent =[nullptr])
Construct a new EditorState.
~EditorState() override =default
Virtual destructor.
QString getInstanceId() const
Get unique instance ID.
bool isDirty() const
Check if state has unsaved changes.
void markClean()
Mark state as clean (after save).

Protected Functions inherited from EditorState

Name
void markDirty()
Mark state as modified.
void setInstanceId(QString const & id)
Set instance ID (for deserialization).
QString generateInstanceId()
Generate a new unique instance ID.

Detailed Description

class BatchProcessingState;

State class for BatchProcessing_Widget.

BatchProcessingState encapsulates the batch processing widget’s state, including folder selection and JSON configuration.

Usage


auto state = std::make_shared<BatchProcessingState>(registry);

// Set folder and JSON content
state->setTopLevelFolder("/path/to/data");
state->setJsonContent(jsonString);

// Load data (uses EditorRegistry to access DataManager and emit signals)
auto result = state->loadFolder();
if (result.success) {
    qDebug() << "Loaded" << result.itemCount << "items";
}

Public Signals Documentation

signal topLevelFolderChanged

void topLevelFolderChanged(
    QString const & folderPath
)

Emitted when the top-level folder changes.

Parameters:

  • folderPath New folder path

signal jsonConfigChanged

void jsonConfigChanged()

Emitted when the JSON configuration changes.

signal loadCompleted

void loadCompleted(
    LoadResult const & result
)

Emitted when a load operation completes.

Parameters:

  • result The result of the load operation

Public Functions Documentation

function BatchProcessingState

explicit BatchProcessingState(
    EditorRegistry * registry,
    std::shared_ptr< DataManager > data_manager,
    QObject * parent =nullptr
)

Construct a new BatchProcessingState.

Parameters:

function ~BatchProcessingState

~BatchProcessingState() override =default

function getTypeName

inline virtual QString getTypeName() const override

Get unique type name for this editor state.

Return: Type name, e.g., “MediaWidget”, “DataViewerWidget”

Reimplements: EditorState::getTypeName

This is used for:

  • Factory registration
  • Serialization type field
  • Properties panel routing

function getDisplayName

virtual QString getDisplayName() const override

Get display name for UI.

Return: Display name, e.g., “Media Viewer 1”

Reimplements: EditorState::getDisplayName

This is the user-visible name shown in tabs, window titles, etc. It may be customized by the user.

function setDisplayName

virtual void setDisplayName(
    QString const & name
) override

Set display name.

Parameters:

  • name New display name

Reimplements: EditorState::setDisplayName

function toJson

virtual std::string toJson() const override

Serialize state to JSON string.

Return: JSON string representation of state

Reimplements: EditorState::toJson

Subclasses should use reflect-cpp for serialization: ```cpp

std::string toJson() const override { return rfl::json::write(_data); }



### function fromJson

```cpp
virtual bool fromJson(
    std::string const & json
) override

Restore state from JSON string.

Parameters:

  • json JSON string to parse

Return: true if parsing succeeded, false on error

Reimplements: EditorState::fromJson

Subclasses should use reflect-cpp for deserialization: ```cpp

bool fromJson(std::string const& json) override { auto result = rfl::json::read(json); if (result) { _data = *result; emit stateChanged(); return true; } return false; }



### function topLevelFolder

```cpp
QString topLevelFolder() const

Get the current top-level folder.

Return: Path to the top-level folder, or empty string if none selected

function setTopLevelFolder

void setTopLevelFolder(
    QString const & folderPath
)

Set the top-level folder.

Parameters:

  • folderPath Path to the folder

function jsonFilePath

QString jsonFilePath() const

Get the current JSON file path (if loaded from file).

Return: Path to the JSON file, or empty string if manually entered

function setJsonFilePath

void setJsonFilePath(
    QString const & filePath
)

Set the JSON file path (when loading from file).

Parameters:

  • filePath Path to the JSON file

function jsonContent

QString jsonContent() const

Get the current JSON configuration content.

Return: JSON content as string

function setJsonContent

void setJsonContent(
    QString const & content
)

Set the JSON configuration content.

Parameters:

  • content JSON content as string

function canLoad

bool canLoad() const

Check if the current state is valid for loading.

Return: true if a folder is selected and valid JSON content exists

function loadFolder

LoadResult loadFolder(
    QString const & selectedSubfolder =QString()
)

Load data from the current folder using the current JSON configuration.

Parameters:

  • selectedSubfolder Optional subfolder within the top-level folder

Return: LoadResult with success status and item count

This method:

  1. Resets the DataManager
  2. Loads data using loadDataFromJsonContentAndBroadcast utility
  3. Emits loadCompleted signal

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