SetEntityOwnFieldsCommand.h header
#include <ew/core/SetEntityOwnFieldsCommand.h>
Namespace ew::core
SetEntityOwnFieldsCommand class
class ew::core::SetEntityOwnFieldsCommand
Command that replaces the field definitions an entity holds ITSELF, as one undoable step.
Takes the whole list rather than one field, because every operation on it is a replacement of the whole: adding, removing and reordering all come out as "these are the properties now". The alternative – an add command, a remove command and a move command, each with its own undo – is three ways to get the list wrong instead of one way to get it right, and the list is short enough that copying it costs nothing.
Undo restores the previous list exactly, including its ORDER, because order is what the writer sees: the properties appear on the entity's page in the order this list holds them.
It never touches VALUES. An entity's values are keyed independently of its definitions, so removing a definition hides a value rather than deleting it, and putting the definition back brings the value with it. That is deliberate – a property removed by accident must not take a paragraph of worldbuilding with it – and it is the same rule the migration follows.
Members
ew::core::entity::SetEntityOwnFieldsCommand::SetEntityOwnFieldsCommand(Entity &entity, std::vector< taxonomy::FieldDefinition > ownFields)
Creates a command that gives entity exactly ownFields when applied.
ew::core::entity::SetEntityOwnFieldsCommand::~SetEntityOwnFieldsCommand() override
Destroys the command.
void ew::core::entity::SetEntityOwnFieldsCommand::apply() override
Records the entity's current own fields and applies the new list.
void ew::core::entity::SetEntityOwnFieldsCommand::undo() override
Restores the previous list, in its original order.
QString ew::core::entity::SetEntityOwnFieldsCommand::description() const override
Returns a short description for the undo/redo UI.