SetDocumentBodyCommand.h header
#include <ew/core/SetDocumentBodyCommand.h>
Namespace ew::core
SetDocumentBodyCommand class
class ew::core::SetDocumentBodyCommand
Command that replaces a document's body text (the Markdown that is its prose), optionally retagging the body's format alongside it. It exists so a programmatic rewrite of the body – notably re-pointing inline object links (ewriter://object/ URLs) when one entity is merged into another – is a single, undoable edit; the live editor keeps its own in-widget undo for typing. Undo restores the previous body and redo re-applies the new one.
Members
ew::core::document::SetDocumentBodyCommand::SetDocumentBodyCommand(Document &document, QString body)
Creates a command that sets document's body to body when applied, leaving the document's BodyFormat tag as it is – for a rewrite that changes the text without changing what kind of text it is, such as re-pointing links after an entity merge.
ew::core::document::SetDocumentBodyCommand::SetDocumentBodyCommand(Document &document, QString body, BodyFormat format)
Creates a command that sets document's body to body and its format tag to format when applied.
The two belong in one command because they describe each other: the tag is what ew::app::document::documentBodyMarkdown consults to decide whether a body needs converting, so a body and a tag that disagree make every export and embed read the prose wrongly. Setting them separately would also let undo restore one without the other (F-0070).
ew::core::document::SetDocumentBodyCommand::~SetDocumentBodyCommand() override
Destroys the command.
void ew::core::document::SetDocumentBodyCommand::apply() override
Records the document's current body and format, and applies the new ones.
void ew::core::document::SetDocumentBodyCommand::undo() override
Restores the previous body and format.
QString ew::core::document::SetDocumentBodyCommand::description() const override
Returns a short description for the undo/redo UI.