static inline void applyProperties(ModelNode &node, const QHash<PropertyName, QVariant> &propertyHash) { QHash<PropertyName, QVariant> auxiliaryData = node.auxiliaryData(); foreach (const PropertyName &propertyName, auxiliaryData.keys()) { if (node.hasAuxiliaryData(propertyName)) node.setAuxiliaryData(propertyName, QVariant()); } QHashIterator<PropertyName, QVariant> propertyIterator(propertyHash); while (propertyIterator.hasNext()) { propertyIterator.next(); const PropertyName propertyName = propertyIterator.key(); if (propertyName == "width" || propertyName == "height") { node.setAuxiliaryData(propertyIterator.key(), propertyIterator.value()); } else if (node.property(propertyIterator.key()).isDynamic() && node.property(propertyIterator.key()).dynamicTypeName() == "alias" && node.property(propertyIterator.key()).isBindingProperty()) { AbstractProperty targetProperty = node.bindingProperty(propertyIterator.key()).resolveToProperty(); if (targetProperty.isValid()) targetProperty.parentModelNode().setAuxiliaryData(targetProperty.name() + "@NodeInstance", propertyIterator.value()); } else { node.setAuxiliaryData(propertyIterator.key() + "@NodeInstance", propertyIterator.value()); } } }
static inline void backupPropertyAndRemove(ModelNode node, const QString &propertyName) { if (node.hasVariantProperty(propertyName)) { node.setAuxiliaryData(auxDataString + propertyName, node.variantProperty(propertyName).value()); node.removeProperty(propertyName); } if (node.hasBindingProperty(propertyName)) { node.setAuxiliaryData(auxDataString + propertyName, QmlItemNode(node).instanceValue(propertyName)); node.removeProperty(propertyName); } }
void NavigatorTreeModel::handleChangedItem(QStandardItem *item) { if (m_blockItemChangedSignal) return; uint nodeHash = item->data(Qt::UserRole).toUInt(); Q_ASSERT(nodeHash && containsNodeHash(nodeHash)); ModelNode node = nodeForHash(nodeHash); ItemRow itemRow = itemRowForNode(node); if (item == itemRow.idItem) { try { node.setId(item->text()); } catch (InvalidIdException &e) { QMessageBox::warning(0, tr("Invalid Id"), e.description()); item->setText(node.id()); } } else if (item == itemRow.visibilityItem) { bool invisible = (item->checkState() == Qt::Unchecked); node.setAuxiliaryData("invisible", invisible); propagateInvisible(node,isNodeInvisible(node)); } }