38 auto all_selected = selection_model->selectedItems();
39 auto selected = all_selected.empty() ? nullptr : all_selected.back();
41 return {selected->parent(), selected->tagRow().next()};
42 return {root_item(),
TagRow{}};
49 return selection_model->viewModel()->sessionItemFromIndex(QModelIndex());
53 LayerEditorActions::LayerEditorActions(QObject* parent)
60 p_impl->sample_model = model;
70 auto [parent, tagrow] =
p_impl->locateInsertPlace();
71 auto new_item =
p_impl->sample_model->insertItem<
LayerItem>(parent, tagrow);
72 p_impl->selection_model->selectItem(new_item);
80 auto [parent, tagrow] =
p_impl->locateInsertPlace();
84 p_impl->selection_model->selectItem(multilayer);
92 auto items =
p_impl->selection_model->selectedItems();
96 std::vector<ModelView::SessionItem*> new_selection;
97 for (
auto to_clone : items)
98 new_selection.push_back(
p_impl->sample_model->copyItem(to_clone, to_clone->parent(),
99 to_clone->tagRow().next()));
101 p_impl->selection_model->selectItems(new_selection);
106 auto items =
p_impl->selection_model->selectedItems();
113 for (
auto item : items)
115 if (next_to_select) {
116 p_impl->selection_model->selectItem(next_to_select);
117 }
else if (prev_to_select) {
118 p_impl->selection_model->selectItem(prev_to_select);
124 auto selected =
p_impl->selection_model->selectedItems();
126 for (
auto item : selected)
129 p_impl->selection_model->selectItems(selected);
134 auto selected =
p_impl->selection_model->selectedItems();
136 for (
auto item : selected)
139 p_impl->selection_model->selectItems(selected);
144 p_impl->selection_model = selection_model;
The main object representing an editable/displayable/serializable entity.
Aggregate to hold (tag, row) information for SessionModel.
void onAddLayer()
Adds layer after selected item. If more than one item is selected, adds after the last one.
void setSelectionModel(LayerSelectionModel *selection_model)
std::unique_ptr< LayerEditorActionsImpl > p_impl
void setModel(SampleModel *model)
Layer with name, thickness and reference to material.
Custom selection model for layer view model (AbstractViewModel).
Multi layer capable of holding layers and other multi-layers.
Model to hold layers and multi-layers.
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 SessionItem * FindNextSibling(SessionItem *item)
Returns next sibling with same tag.
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 * FindPreviousSibling(SessionItem *item)
Returns previous sibling with same tag.
MVVM_MODEL_EXPORT void DeleteItemFromModel(SessionItem *item)
Removes and deletes item from its model.
materialitems.h Collection of materials to populate MaterialModel.
Based on Qt example "codeeditor" Copyright (C) 2016 The Qt Company Ltd.
ModelView::SessionItem * root_item()
Returns a multi layer playing the role of invisible root item.
std::pair< SessionItem *, TagRow > locateInsertPlace()
Finds parent and tagrow to insert new item.