AutosaveController.h header

#include <ew/app/AutosaveController.h>

Namespace ew::app

AutosaveController class

class ew::app::AutosaveController

Periodically saves a Workspace whenever it has unsaved changes and a save location, so work is not lost between manual saves. The UI creates one per open workspace, calls start(), and reacts to saved()/saveFailed() for status feedback. A tick with nothing to save (clean, or no location yet) is a silent no-op.

Members

ew::app::AutosaveController::AutosaveController(Workspace &workspace, QObject *parent=nullptr)

Creates a controller that autosaves workspace (not owned; it must outlive this controller). Autosaving does not run until start() is called.

std::chrono::milliseconds ew::app::AutosaveController::interval() const

The delay between autosave checks (default 30 seconds).

void ew::app::AutosaveController::setInterval(std::chrono::milliseconds interval)

Sets the delay between autosave checks.

bool ew::app::AutosaveController::isActive() const

Returns true while periodic autosaving is running.

void ew::app::AutosaveController::start()

Starts periodic autosave checks.

void ew::app::AutosaveController::stop()

Stops periodic autosave checks.

void ew::app::AutosaveController::saveNow()

Saves immediately if the workspace has unsaved changes and a location; otherwise does nothing. Emits saved() or saveFailed() when a save is attempted.

void ew::app::AutosaveController::aboutToSave()

Emitted at the start of a save attempt, before the modified/location check, so the owner can flush pending state into the workspace first – e.g. commit the text editor's current document, whose prose edits are written directly and must land before isModified() is tested.

void ew::app::AutosaveController::saved()

Emitted after the workspace is successfully autosaved.

void ew::app::AutosaveController::saveFailed(const QString &message)

Emitted when an autosave attempt fails, carrying a human-readable message.