37 bool proceed_with_children(
true);
40 proceed_with_children = fun(item);
42 if (!item || !proceed_with_children)
58 if (
auto parent = item->
parent()) {
59 for (
auto child : parent->children()) {
67 return count > 1 ? result : -1;
76 return index >= 0 &&
static_cast<size_t>(index) < container.size()
77 ? container[
static_cast<size_t>(index)]
98 std::vector<std::string> result;
99 for (
const auto container : *item.
itemTags())
100 result.push_back(container->name());
106 std::vector<std::string> result;
109 result.push_back(tag);
115 std::vector<SessionItem*> result;
118 result.push_back(child);
124 std::vector<SessionItem*> result;
127 result.push_back(child);
133 auto parent = item ? item->
parent() :
nullptr;
136 auto tagrow = item->
tagRow();
137 return parent->getItem(tagrow.tag, tagrow.row + 1);
142 auto parent = item ? item->
parent() :
nullptr;
146 return parent->getItem(tagrow.tag, tagrow.row - 1);
153 return closest ? closest : item->
parent();
158 if (!item || !candidate)
162 if (parent == candidate)
165 parent = parent->
parent();
173 std::vector<SessionItem*> result;
174 std::copy_if(filtered.begin(), filtered.end(), std::back_inserter(result),
175 [](
auto x) { return x != nullptr; });
The main object representing an editable/displayable/serializable entity.
SessionItemTags * itemTags()
Returns pointer to internal collection of tag-registered items (non-const version).
TagRow tagRowOfItem(const SessionItem *item) const
Returns pair of tag and row corresponding to given item.
SessionItem * parent() const
Returns parent item. Will return nullptr if item doesn't have a parent.
std::vector< SessionItem * > children() const
Returns vector of children formed from all chidlren from all tags.
TagRow tagRow() const
Returns TagRow of this item under which it is accessible through its parent.
model_type modelType() const
Returns item's model type.
void iterate_if(const QModelIndex &index, const QAbstractItemModel *model, const std::function< bool(const QModelIndex &)> &fun)
Iterates through all model indices and calls user function.
void iterate(const QModelIndex &index, const QAbstractItemModel *model, const std::function< void(const QModelIndex &)> &fun)
Iterates through all model indices and calls user function.
MVVM_MODEL_EXPORT int CopyNumber(const SessionItem *item)
Returns copy number of given item in it's parent hierarchy.
C UniqueWithOrder(const C &container)
Returns copy of container with all duplicated elements filtered our. The order is preserved.
MVVM_MODEL_EXPORT SessionItem * FindNextSibling(SessionItem *item)
Returns next sibling with same tag.
MVVM_MODEL_EXPORT SessionItem * FindNextItemToSelect(SessionItem *item)
Finds next item to select Method is used in the context of next item selection after given item was d...
MVVM_MODEL_EXPORT std::vector< SessionItem * > SinglePropertyItems(const SessionItem &item)
Returns vector of children representing property items.
int IndexOfItem(It begin, It end, const T &item)
Returns index corresponding to the first occurance of the item in the container.
MVVM_MODEL_EXPORT void iterate(SessionItem *item, const std::function< void(SessionItem *)> &fun)
Iterates through item and all its children.
MVVM_MODEL_EXPORT int IndexOfChild(const SessionItem *parent, const SessionItem *child)
Returns index in children array corresponding to given child.
MVVM_MODEL_EXPORT std::vector< SessionItem * > UniqueItems(const std::vector< SessionItem * > &items)
Returns vector with duplicates and 'nullptr' filtered out.
MVVM_MODEL_EXPORT void iterate_if(const SessionItem *item, const std::function< bool(const SessionItem *)> &fun)
Iterates through all model indices and calls user function.
MVVM_MODEL_EXPORT std::vector< SessionItem * > TopLevelItems(const SessionItem &item)
Returns vector of children representing top level items.
MVVM_MODEL_EXPORT std::vector< std::string > RegisteredUniversalTags(const SessionItem &item)
Returns vector of strings containing all registered universal tags of the given item.
MVVM_MODEL_EXPORT bool HasTag(const SessionItem &item, const std::string &tag)
Returns true if given item has registered tag.
MVVM_MODEL_EXPORT std::vector< std::string > RegisteredTags(const SessionItem &item)
Returns vector of strings containing all registered tags of the given item.
MVVM_MODEL_EXPORT SessionItem * ChildAt(const SessionItem *parent, int index)
Returns child at given index of parent.
MVVM_MODEL_EXPORT bool IsItemAncestor(const SessionItem *item, const SessionItem *candidate)
Returns true if 'candidate' is one of ancestor of given item.
MVVM_MODEL_EXPORT SessionItem * FindPreviousSibling(SessionItem *item)
Returns previous sibling with same tag.
MVVM_MODEL_EXPORT bool IsSinglePropertyTag(const SessionItem &item, const std::string &tag)
Returns true if given item has registered tag, and it belongs to single property.
materialitems.h Collection of materials to populate MaterialModel.