18 #include <QJsonObject>
24 if (!item || !item->
model())
29 while (current && current->
parent()) {
31 current = current->
parent();
39 for (
const auto& x : path) {
50 QJsonObject
object = converter->
to_json(source);
56 auto model = item->
model();
65 auto tagrow = item->
tagRow();
73 auto tagrow = item->
tagRow();
81 if (
auto stack = model.
undoStack(); stack)
87 if (
auto stack = model.
undoStack(); stack)
97 stack->beginMacro(macro_name);
Base class for all converters of SessionModel to/from json object.
virtual void from_json(const QJsonObject &, SessionModel &) const =0
virtual QJsonObject to_json(const SessionModel &) const =0
Supports navigation through SessionModel.
void prepend(PathElement element)
The main object representing an editable/displayable/serializable entity.
int itemCount(const std::string &tag) const
Returns number of items in given tag.
SessionItem * parent() const
Returns parent item. Will return nullptr if item doesn't have a parent.
SessionModel * model() const
Returns the model to which given item belongs to.
TagRow tagRow() const
Returns TagRow of this item under which it is accessible through its parent.
Main class to hold hierarchy of SessionItem objects.
void moveItem(SessionItem *item, SessionItem *new_parent, const TagRow &tagrow)
Move item from it's current parent to a new parent under given tag and row.
SessionItem * rootItem() const
Returns root item of the model.
UndoStackInterface * undoStack() const
Returns command stack to perform undo/redo.
void removeItem(SessionItem *parent, const TagRow &tagrow)
Removes given row from parent.
MVVM_MODEL_EXPORT void EndMacros(const SessionItem *item)
Finishes undo/redo macros.
MVVM_MODEL_EXPORT void MoveDown(SessionItem *item)
Moves item down (increments row of the item). Works on children belonging to single tag.
MVVM_MODEL_EXPORT void BeginMacros(const SessionItem *item, const std::string ¯o_name)
Begin undo/redo macros with given name.
MVVM_MODEL_EXPORT int IndexOfChild(const SessionItem *parent, const SessionItem *child)
Returns index in children array corresponding to given child.
MVVM_MODEL_EXPORT void MoveUp(SessionItem *item)
Moves item up (decrements row of the item). Works on children belonging to single tag.
MVVM_MODEL_EXPORT SessionItem * ItemFromPath(const SessionModel &moodel, const Path &path)
Returns item found in the model following given Path.
MVVM_MODEL_EXPORT void Undo(SessionModel &model)
Undo last model operation. If not undo/redo enabled, will do nothing.
MVVM_MODEL_EXPORT Path PathFromItem(const SessionItem *item)
Constructs path to find given item. Item must belong to a model.
MVVM_MODEL_EXPORT void Redo(SessionModel &model)
Redo model operation which was undone just before. If not undo/redo enabled, will do nothing.
MVVM_MODEL_EXPORT SessionItem * ChildAt(const SessionItem *parent, int index)
Returns child at given index of parent.
MVVM_MODEL_EXPORT void PopulateEmptyModel(const JsonModelConverterInterface *converter, const SessionModel &source, SessionModel &target)
Populate empty model with content of target model using provided converter.
MVVM_MODEL_EXPORT void DeleteItemFromModel(SessionItem *item)
Removes and deletes item from its model.
materialitems.h Collection of materials to populate MaterialModel.