Skip to main content

DataImportWidgetState

DataImportWidgetState

State class for DataImport_Widget. More…

#include <DataImportWidgetState.hpp>

Inherits from EditorState, QObject

Public Signals

Name
void selectedImportTypeChanged(QString const & type)
Emitted when selected import type changes.
void lastUsedDirectoryChanged(QString const & dir)
Emitted when last used directory changes.
void formatPreferenceChanged(QString const & data_type, QString const & format)
Emitted when a format preference changes.

Public Functions

Name
DataImportWidgetState(QObject * parent =[nullptr])
Construct a new DataImportWidgetState.
~DataImportWidgetState() override =default
virtual QString getTypeName() const override
Get type name for factory registration.
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.
virtual bool fromJson(std::string const & json) override
Restore state from JSON.
void setSelectedImportType(QString const & type)
Set the selected import data type.
QString selectedImportType() const
Get the selected import data type.
void setLastUsedDirectory(QString const & dir)
Set the last used directory.
QString lastUsedDirectory() const
Get the last used directory.
void setFormatPreference(QString const & data_type, QString const & format)
Set format preference for a data type.
QString formatPreference(QString const & data_type) const
Get format preference for a data type.

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 DataImportWidgetState;

State class for DataImport_Widget.

DataImportWidgetState conforms to the EditorState architecture and supports the passive awareness pattern for responding to data focus changes.

Usage


// Create state (typically done in widget constructor)
auto state = std::make_shared<DataImportWidgetState>();
workspace_manager->registerState(state);

// Connect to type changes
connect(state.get(), &DataImportWidgetState::selectedImportTypeChanged,
        this, &DataImport_Widget::onImportTypeChanged);

// Respond to data focus (from DataFocusAware::onDataFocusChanged)
void onDataFocusChanged(SelectedDataKey const& key, QString const& type) {
    state->setSelectedImportType(type);
}

Public Signals Documentation

signal selectedImportTypeChanged

void selectedImportTypeChanged(
    QString const & type
)

Emitted when selected import type changes.

Parameters:

  • type New import type

signal lastUsedDirectoryChanged

void lastUsedDirectoryChanged(
    QString const & dir
)

Emitted when last used directory changes.

Parameters:

  • dir New directory path

signal formatPreferenceChanged

void formatPreferenceChanged(
    QString const & data_type,
    QString const & format
)

Emitted when a format preference changes.

Parameters:

  • data_type Data type that was updated
  • format New format preference

Public Functions Documentation

function DataImportWidgetState

explicit DataImportWidgetState(
    QObject * parent =nullptr
)

Construct a new DataImportWidgetState.

Parameters:

  • parent Parent QObject (typically nullptr, managed by WorkspaceManager)

function ~DataImportWidgetState

~DataImportWidgetState() override =default

function getTypeName

inline virtual QString getTypeName() const override

Get type name for factory registration.

Return: “DataImportWidget”

Reimplements: EditorState::getTypeName

function getDisplayName

virtual QString getDisplayName() const override

Get display name for UI.

Return: User-visible display name

Reimplements: EditorState::getDisplayName

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.

Return: JSON string

Reimplements: EditorState::toJson

function fromJson

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

Restore state from JSON.

Parameters:

  • json JSON string

Return: true if successful

Reimplements: EditorState::fromJson

function setSelectedImportType

void setSelectedImportType(
    QString const & type
)

Set the selected import data type.

Parameters:

  • type Data type string

This determines which loader widget is displayed in the stacked widget. Typical values: “LineData”, “MaskData”, “PointData”, “AnalogTimeSeries”, etc.

function selectedImportType

QString selectedImportType() const

Get the selected import data type.

Return: Currently selected data type

function setLastUsedDirectory

void setLastUsedDirectory(
    QString const & dir
)

Set the last used directory.

Parameters:

  • dir Directory path

Used to remember the user’s preferred directory for file dialogs.

function lastUsedDirectory

QString lastUsedDirectory() const

Get the last used directory.

Return: Last used directory path

function setFormatPreference

void setFormatPreference(
    QString const & data_type,
    QString const & format
)

Set format preference for a data type.

Parameters:

  • data_type Data type (e.g., “LineData”)
  • format Format string (e.g., “CSV”, “HDF5”, “Binary”)

Remembers the user’s preferred format for each data type. For example, if user usually imports LineData as CSV, store that preference.

function formatPreference

QString formatPreference(
    QString const & data_type
) const

Get format preference for a data type.

Parameters:

  • data_type Data type

Return: Preferred format, or empty string if not set


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