radioviz.services.save_services
Module for handling save operations in the application.
This module provides infrastructure for managing save operations for various savable objects. It includes the core classes and functions needed to implement save functionality with support for multiple formats and user interaction through dialog boxes.
The main components are:
SaveSpecfor defining save specificationsSavableprotocol for objects that can be savedSaveCoordinatorfor coordinating save operations
Functions
|
Normalize the save path based on selected suffix. |
Classes
|
Protocol for objects that can be saved. |
|
Coordinator for managing save operations. |
|
Specification for a save operation. |
- class radioviz.services.save_services.Savable(*args, **kwargs)[source]
Bases:
ProtocolProtocol for objects that can be saved.
Defines the interface that objects must implement to be savable.
- can_save() bool[source]
Check if the object can be saved.
- Returns:
True if object can be saved, False otherwise
- Return type:
bool
- can_save_as() bool[source]
Check if the object can be saved as a different file.
- Returns:
True if object can be saved as, False otherwise
- Return type:
bool
- current_path() Path | str[source]
Get the current file path.
- Returns:
Current file path or string representation
- Return type:
Path or str
- class radioviz.services.save_services.SaveCoordinator(parent: QWidget | None = None)[source]
Bases:
QObjectCoordinator for managing save operations.
Handles the coordination of save operations including choosing between multiple formats and managing user interactions.
Initialize the save coordinator.
- Parameters:
parent (QObject or None) – Parent QObject
- _ask_user_for_format(specs: list[SaveSpec], parent: QWidget | None) SaveSpec | None[source]
Ask user to select a format for saving.
- _choose_and_save(savable: Savable, specs: list[SaveSpec], parent_widget: QWidget | None) None[source]
Choose format and save the object.
- _choose_and_save_as(savable: Savable, specs: list[SaveSpec], parent_widget: QWidget | None) None[source]
Choose format and save as the object.
- _normalize_save_path(path: Path, selected_filter: str, spec: SaveSpec) Path[source]
Normalize the save path based on selected filter.
- Parameters:
path (Path) – Original path
selected_filter (str) – Selected file filter
spec (
SaveSpec) – Save specification
- Returns:
Normalized path
- Return type:
Path
- _save_as_with_spec(savable: Savable, spec: SaveSpec, parent_widget: QWidget | None) None[source]
Save as using the specified save specification.
- _save_with_spec(savable: Savable, spec: SaveSpec) None[source]
Save using the specified save specification.