DocumentVariantOps.h header
#include <ew/app/DocumentVariantOps.h>
Namespace ew::app
VariantState struct
struct ew::app::VariantState
The three pieces of a document's variant state that change together when the writer creates or switches drafts: the parked alternate variants, the name of the active draft, and the live body. A caller applies these to a document as one undoable step (SetDocumentVariantsCommand).
Members
std::vector<ew::core::DocumentVariant> ew::app::VariantState::variants
The parked alternate drafts (every variant except the active one).
QString ew::app::VariantState::activeName
The name of the active draft (whose content is the body).
QString ew::app::VariantState::body
The live body content.
Functions
VariantState ew::app::addVariant(const std::vector< ew::core::DocumentVariant > &variants, const QString &activeName, const QString &body, const QString &newName, const QString &fallbackName)
Computes the state after creating a new variant newName from the current draft: the current draft (activeName, or fallbackName when empty) is parked and newName becomes the active draft, seeded with a copy of the current body so the writer can then diverge it. The body is unchanged (the copy stays live); only the active name and the parked list change.
VariantState ew::app::switchVariant(const std::vector< ew::core::DocumentVariant > &variants, const QString &activeName, const QString &body, int targetIndex, const QString &fallbackName)
Computes the state after switching the active draft to parked variant targetIndex: the current live draft (activeName, body) is parked into that slot and the target variant becomes live, so no draft is lost. activeName falls back to fallbackName when empty (the current draft had no name yet). Returns the state unchanged if targetIndex is out of range.