25 enum class Status { initial, after_execute, after_undo };
44 throw std::runtime_error(
"Invalid item.");
46 if (!receiver->
model())
47 throw std::runtime_error(
"Item doesn't have a model");
58 if (!
p_impl->can_execute())
59 throw std::runtime_error(
"Can't execute the command. Wrong order.");
63 p_impl->set_after_execute();
71 throw std::runtime_error(
"Can't undo the command. Wrong order.");
82 return p_impl->m_isObsolete;
101 p_impl->m_isObsolete = flag;
128 p_impl->m_result = command_result;
Abstract command interface to manipulate SessionItem in model context.
virtual void execute_command()=0
SessionItem * itemFromPath(const Path &path) const
std::string description() const
Returns command description.
void setDescription(const std::string &text)
Sets command description.
SessionModel * model() const
AbstractItemCommand(SessionItem *receiver)
void undo()
Undo command as it was before execution.
virtual void undo_command()=0
CommandResult result() const
void execute()
Execute command.
std::unique_ptr< AbstractItemCommandImpl > p_impl
void setResult(const CommandResult &command_result)
virtual ~AbstractItemCommand()
Path pathFromItem(SessionItem *item) const
bool isObsolete() const
Returns whether the command is obsolete (which means that it shouldn't be kept in the stack).
void setObsolete(bool flag)
Sets command obsolete flag.
Supports navigation through SessionModel.
The main object representing an editable/displayable/serializable entity.
SessionModel * model() const
Returns the model to which given item belongs to.
Main class to hold hierarchy of SessionItem objects.
MVVM_MODEL_EXPORT SessionItem * ItemFromPath(const SessionModel &moodel, const Path &path)
Returns item found in the model following given Path.
MVVM_MODEL_EXPORT Path PathFromItem(const SessionItem *item)
Constructs path to find given item. Item must belong to a model.
materialitems.h Collection of materials to populate MaterialModel.
std::variant< bool, ModelView::SessionItem * > CommandResult
Results of command execution.
AbstractItemCommandImpl(AbstractItemCommand *parent)
AbstractItemCommand * m_self