46 QVector<SessionItem*>::const_iterator it;
111 return m_children.indexOf(child);
119 if (child->modelType() == type)
129 QVector<SessionItem*> result;
131 if (child->modelType() == model_type)
132 result.append(child);
161 return m_tags->registerTag(
name, min, max, modelTypes);
202 const QString tagName = tag.isEmpty() ?
defaultTag() : tag;
204 if (!
m_tags->isValid(tagName))
207 if (
m_tags->childCount(tagName) == 0)
210 if (row < 0 || row >=
m_tags->childCount(tagName))
223 const QString tagName = tag.isEmpty() ?
defaultTag() : tag;
224 if (!
m_tags->isValid(tagName))
225 return QVector<SessionItem*>();
236 ASSERT(!
item->parentItem());
238 const QString tagName = tag.isEmpty() ?
defaultTag() : tag;
239 ASSERT(
m_tags->isValid(tagName,
item->modelType()));
241 int index =
m_tags->insertIndexFromTagRow(tagName, row);
251 m_tags->addChild(tagName);
260 const QString tagName = tag.isEmpty() ?
defaultTag() : tag;
261 ASSERT(
m_tags->isValid(tagName));
262 ASSERT(!
m_tags->isSingleItemTag(tagName));
272 m_tags->removeChild(tagName);
283 property->setDisplayName(
name);
286 property->setValue(variant);
322 return item<GroupItem>(groupTag)->setCurrentType(
modelType);
329 return item<GroupItem>(groupName)->currentItem();
408 if (hasModelType<PropertyItem>() || hasModelType<GroupItem>())
419 return result + QString::number(
index);
511 m_mapper = std::make_unique<ModelMapper>();
554 child->setModel(
model);
561 if (!
flags.isValid())
564 return flags.toInt();
586 QString model_type =
item->modelType();
589 QString child_type = p_child_item->modelType();
590 if (p_child_item ==
item)
592 if (child_type == model_type && !p_child_item->isTag(
P_NAME))
Defines namespace GUI::Model::ItemFactory.
Defines class PropertyItem.
Defines class SessionFlags.
Defines class SessionItemData.
Defines class SessionModel.
Defines namespace GUI::Util::Variant.
Defines info for GroupProperty, i.e. collection of model types, their labels and the name of default ...
static constexpr auto M_TYPE
static constexpr auto M_TYPE
Handles all data roles for SessionItem.
Base class for a GUI data item.
bool isTag(const QString &name) const
Returns true if tag is available.
void setParentAndModel(SessionItem *parent, SessionModel *model)
QString itemName() const
Get item name, return display name if no name is set.
void setItemName(const QString &name)
Set item name, add property if necessary.
virtual ~SessionItem()
Destructor deletes all its children and request parent to delete this item.
T & groupItem(const QString &groupName) const
SessionItem * addProperty(const QString &name, const QVariant &variant)
Add new property item and register new tag. name is the tag name and the display name....
SessionItem & setDecimals(int n)
QVector< QString > acceptableDefaultItemTypes() const
Returns vector of acceptable default tag types.
SessionItem * getGroupItem(const QString &groupName) const
Access subitem of group item.
bool registerTag(const QString &name, int min=0, int max=-1, QStringList modelTypes={})
Add new tag to this item with given name, min, max and types. max = -1 -> unlimited,...
QVector< SessionItem * > getItems(const QString &tag="") const
Returns vector of all items of given tag.
SessionItem(const QString &modelType)
Constructs new item with given model type. The type must be defined.
std::unique_ptr< SessionItemData > m_properties
int numberOfChildren() const
Returns total number of children.
void insertChild(int row, SessionItem *item, const QString &tag="")
Insert item into given tag into given row.
QString displayName() const
Get display name of item, append index if ambigue.
QVariant value() const
Get value.
QVector< int > getRoles() const
Returns vector of all present roles.
bool setValue(QVariant value)
Set value, ensure that variant types match.
int rowOfChild(SessionItem *child) const
Returns row index of given child.
const SessionItemTags * sessionItemTags() const
int getCopyNumberOfChild(const SessionItem *item) const
internal
QVariant getItemValue(const QString &tag) const
Directly access value of item under given tag.
void setItemValue(const QString &tag, const QVariant &variant) const
Directly set value of item under given tag.
bool acceptsAsDefaultItem(const QString &item_name) const
Returns true if model type can be added to default tag.
QVector< SessionItem * > m_children
void setDisplayName(const QString &display_name)
Set display name.
QString defaultTag() const
Get default tag.
ModelMapper * mapper()
Returns the current model mapper of this item. Creates new one if necessary.
virtual void deserializeBinaryData(const QByteArray &data)
void setDefaultTag(const QString &tag)
Set default tag.
SessionItem * takeRow(int row)
Removes row from item and returns the item.
SessionModel * model() const
Returns model of this item.
SessionItem * takeItem(int row, const QString &tag)
Remove item from given row from given tag.
T * item(const QString &tag) const
virtual QByteArray serializeBinaryData() const
static constexpr auto P_NAME
SessionItem * parentItem() const
Returns parent of this item.
SessionItem * addGroupProperty(const QString &groupTag, const GroupInfo &groupInfo)
QVector< T * > items(const QString &tag="") const
SessionItem * setGroupProperty(const QString &groupTag, const QString &modelType) const
Set the current type of group item.
virtual bool allowWritingChildToXml(SessionItem *child) const
QVariant roleProperty(int role) const
Returns corresponding variant under given role, invalid variant when role is not present.
int parentRow()
Returns the index of the given item within its parent. Returns -1 when no parent is set.
void emitDataChanged(int role=Qt::DisplayRole)
Notify model about data changes.
void setEditable(bool enabled)
virtual void writeNonSessionItems(QXmlStreamWriter *writer) const
std::unique_ptr< SessionItemTags > m_tags
QVector< SessionItem * > children() const
Returns vector of all children.
RealLimits limits() const
SessionItem * childAt(int row) const
Returns the child at the given row.
SessionItem & setToolTip(const QString &tooltip)
static bool isItemNamePropertyName(const QString &name)
QVector< T * > childrenOfType() const
QString modelType() const
Get model type.
QString tagFromItem(const SessionItem *item) const
Returns the tag name of given item when existing.
void setEnabled(bool enabled)
Flags accessors.
bool setRoleProperty(int role, const QVariant &value)
Set the contained role property to the given value. See also setTranslatorForRolePropertySetter.
QModelIndex index() const
Returns model index of this item.
std::unique_ptr< ModelMapper > m_mapper
SessionItem * getItem(const QString &tag="", int row=0) const
Returns item in given row of given tag.
void setModel(SessionModel *model)
bool hasChildren() const
Indicates whether this SessionItem has any child items.
virtual void readNonSessionItems(QXmlStreamReader *reader)
SessionItem * getChildOfType(const QString &type) const
Returns the first child of the given type.
SessionItem & setLimits(const RealLimits &value)
void childDeleted(SessionItem *child)
void changeFlags(bool enabled, int flag)
internal
Base class for a GUI data collection. A collection is e.g. all real data (RealDataModel)....
QModelIndex indexOfItem(SessionItem *item) const
SessionItem * CreateItem(const QString &model_name, SessionItem *parent=nullptr)
create SessionItem of specific type and parent
QString const & name(EShape k)
bool CompatibleVariantTypes(const QVariant &oldValue, const QVariant &newValue)
Returns true if variants has compatible types.