ReparentCategoryToEntityCommand.h header

#include <ew/core/ReparentCategoryToEntityCommand.h>

Namespace ew::core

ReparentCategoryToEntityCommand class

class ew::core::ReparentCategoryToEntityCommand

Command that hangs a category from an ENTITY, as one undoable step.

What makes Kingdom(category) -> Vaertis(entity) -> Cities(category) reachable from the app: the cities of one kingdom are a category, but they belong to that kingdom rather than to kingdoms in general.

Separate from ReparentCategoryCommand, which moves a category under another CATEGORY, for a reason beyond symmetry: this one needs the whole content graph. A category's entity parent can only be checked for a loop by climbing through entities, and only Project can do that – while Taxonomy, which the category-to-category command takes, cannot follow an entity parent at all. Keeping them apart also leaves that command's behaviour untouched.

Refuses the move when it would make a cycle – when the target entity already hangs, however indirectly, beneath the category being moved. A loop here is not a cosmetic problem: every consumer that asks what properties an entity has would walk it.

Members

ew::core::taxonomy::ReparentCategoryToEntityCommand::ReparentCategoryToEntityCommand(ew::core::project::Project &project, ew::core::foundation::CategoryId categoryId, ew::core::foundation::ContentId entityId)

Creates a command that hangs categoryId from entityId when applied.

ew::core::taxonomy::ReparentCategoryToEntityCommand::~ReparentCategoryToEntityCommand() override

Destroys the command.

void ew::core::taxonomy::ReparentCategoryToEntityCommand::apply() override

Records the category's whole previous parentage and hangs it from the entity. Does nothing when either id is unknown, or when the move would make a cycle.

void ew::core::taxonomy::ReparentCategoryToEntityCommand::undo() override

Restores the previous parentage, whichever kind of parent it had.

bool ew::core::taxonomy::ReparentCategoryToEntityCommand::moved() const

Whether the move actually happened, for a caller that wants to report a refusal.

QString ew::core::taxonomy::ReparentCategoryToEntityCommand::description() const override

Returns a short description for the undo/redo UI.