24 : QObject(parent), m_materialModel(nullptr), m_sampleModel(nullptr)
56 sampleItem->setItemValue(tag, new_property.
variant());
59 sampleItem->setItemValue(tag, undefined.
variant());
67 const QModelIndex&,
const QVector<int>&)
70 if (
auto materialItem =
78 if (property.identifier() == materialItem->identifier()) {
80 sampleItem->setItemValue(tag, new_property.
variant());
96 QStringList identifiersToDelete;
97 for (
int i_row = first; i_row <= last; ++i_row) {
100 identifiersToDelete.push_back(material->identifier());
109 if (identifiersToDelete.contains(property.identifier())) {
111 sampleItem->setItemValue(tag, undefined.
variant());
122 QVector<SessionItem*> result;
124 if (index.column() != 0)
128 if (materialRelated.contains(item->modelType()))
129 result.push_back(item);
#define ASSERT(condition)
Defines class MaterialItemUtils.
Defines class MaterialModel.
Defines MaterialPropertyController class.
Defines ModelPath namespace.
Defines ModelUtils namespace.
Defines class SampleModel.
The ExternalProperty class defines custom QVariant property to carry the text, color and an identifie...
MaterialItem * materialFromIdentifier(const QString &identifier)
SampleModel * m_sampleModel
void setModels(MaterialModel *materialModel, SampleModel *sampleModel)
QVector< SessionItem * > relatedSampleItems()
Returns vector of SessionItems having MaterialProperty on board.
void onMaterialDataChanged(const QModelIndex &topLeft, const QModelIndex &, const QVector< int > &)
On MaterialItem change: updates corresponding MaterialProperty in sample items.
MaterialModel * m_materialModel
MaterialPropertyController(QObject *parent=nullptr)
void onMaterialRowsAboutToBeRemoved(const QModelIndex &parent, int first, int last)
On MaterialItem removal: updates corresponding MaterialProperty in sample items.
void onMaterialModelLoad()
Special case when original MaterialModel was fully rebuild from MaterialEditor.
Main model to hold sample items.
SessionItem * itemForIndex(const QModelIndex &index) const
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const
QString materialTag(const SessionItem &item)
Returns material tag for given item. Returns empty string, if item doesn't have materials.
QStringList materialRelatedModelTypes()
Returns list of model types which contains registered MaterialProperty.
ExternalProperty materialProperty(const SessionItem &materialItem)
Constructs material property corresponding to given material.
const SessionItem * ancestor(const SessionItem *item, const QString &requiredModelType)
Returns ancestor of given modelType for given item.
void iterate(const QModelIndex &index, const QAbstractItemModel *model, const std::function< void(const QModelIndex &)> &fun)
Iterates through all model indices and calls user function.