bool Qtilities::Core::ObserverDotWriter::removeEdgeAttribute(Observer* parent, QObject* child, const QString& attribute) { if (!d->observer) return false; if (!parent || !child) return false; QList<QObject*> tree_items = d->observer->treeChildren(); if (parent == d->observer) { if (!tree_items.contains(child)) return false; } else { if (!tree_items.contains(parent) || !tree_items.contains(child)) return false; } // Get the specified MultiContext property: QString prop_name("qti.dot.edge." + attribute); QByteArray byteArray = prop_name.toAscii(); const char * char_name = byteArray.data(); MultiContextProperty property = ObjectManager::getMultiContextProperty(child,char_name); if (property.isValid()) { // Check if the property exists: if (!property.hasContext(parent->observerID())) return false; // Now remove the property related to the parent: property.removeContext(parent->observerID()); // Set the property again: if (property.contextMap().keys().count() == 0) child->setProperty(char_name,QVariant()); else ObjectManager::setMultiContextProperty(child,property); // Set the modification state of the object: IModificationNotifier* mod_iface = qobject_cast<IModificationNotifier*> (child); if (mod_iface) mod_iface->setModificationState(true,IModificationNotifier::NotifyListeners,true); return true; } return false; }
QHash<QByteArray,QString> Qtilities::Core::ObserverDotWriter::edgeAttributes(Observer* parent, QObject* child) const { if (!d->observer) return QHash<QByteArray,QString>(); if (!parent || !child) return QHash<QByteArray,QString>(); QList<QByteArray> property_names = child->dynamicPropertyNames(); QHash<QByteArray,QString> dot_properties; for (int i = 0; i < property_names.count(); i++) { QString prop_qstring_name = property_names.at(i); if (prop_qstring_name.startsWith("qti.dot.edge")) { // Get the property value: MultiContextProperty prop = ObjectManager::getMultiContextProperty(child,property_names.at(i)); if (prop.isValid()) { if (prop.hasContext(parent->observerID())) dot_properties[property_names.at(i)] = prop.value(parent->observerID()).toString(); } } } return dot_properties; }