MoveDocumentCommand.h header

#include <ew/core/MoveDocumentCommand.h>

Namespace ew::core

MoveDocumentCommand class

class ew::core::MoveDocumentCommand

Command that moves a document within the manuscript tree: it becomes a child of a new parent (a null id makes it top-level) and is inserted at a target position among that parent's children. Affected siblings are renumbered so their sort indices stay contiguous. A move that would place a document inside its own subtree is rejected and applied as a no-op. Undo restores the parent and position of every document the move touched.

Members

ew::core::MoveDocumentCommand::MoveDocumentCommand(Project &project, ContentId documentId, ContentId newParentId, int targetIndex)

Creates a command that, when applied, moves documentId under newParentId at targetIndex (clamped to the destination sibling count) within project.

ew::core::MoveDocumentCommand::~MoveDocumentCommand() override

Destroys the command.

void ew::core::MoveDocumentCommand::apply() override

Applies the move, recording the previous placement of every touched document.

void ew::core::MoveDocumentCommand::undo() override

Restores the parent and position of every document the move touched.

QString ew::core::MoveDocumentCommand::description() const override

Returns a short description for the undo/redo UI.

Placement struct

struct ew::core::Placement

The parent and position a document had before the move, captured for undo.

Members

ContentId ew::core::MoveDocumentCommand::Placement::parentId

The parent the document had before the move.

int ew::core::MoveDocumentCommand::Placement::sortIndex

The document's position among its siblings before the move.