SetDocumentVariantsCommand.h header
#include <ew/core/SetDocumentVariantsCommand.h>
Namespace ew::core
SetDocumentVariantsCommand class
class ew::core::SetDocumentVariantsCommand
Command that sets a document's alternate-variant state as one undoable step: the parallel alternate drafts, the name of the active variant, and the live body. Switching between variants swaps the live body with a stored alternative, so the three must change together; creating, renaming, or deleting a variant leaves the body unchanged (pass the current body). Undo restores the previous state and redo re-applies the new one. This owns the wholesale body swap of a variant switch (a structural change), separate from the editor's own incremental text undo.
Members
ew::core::SetDocumentVariantsCommand::SetDocumentVariantsCommand(Document &document, std::vector< DocumentVariant > variants, QString activeVariantName, QString body)
Creates a command that, when applied, sets document's variants to variants, its active variant name to activeVariantName, and its body to body.
ew::core::SetDocumentVariantsCommand::~SetDocumentVariantsCommand() override
Destroys the command.
void ew::core::SetDocumentVariantsCommand::apply() override
Records the document's current variant state and body, then applies the new ones.
void ew::core::SetDocumentVariantsCommand::undo() override
Restores the previous variant state and body.
QString ew::core::SetDocumentVariantsCommand::description() const override
Returns a short description for the undo/redo UI.