Ejemplo n.º 1
0
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;
}
Ejemplo n.º 2
0
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;
}
Ejemplo n.º 3
0
bool Qtilities::Core::MultiContextProperty::operator==(const MultiContextProperty& other) const {
    if (name != other.propertyNameString())
        return false;
    if (context_map != other.contextMap()) {
//        for (int i = 0; i < context_map.count(); ++i)
//            qDebug() << context_map.values().at(i).toString();
//        for (int i = 0; i < other.contextMap().count(); ++i)
//            qDebug() << other.contextMap().values().at(i).toString();

        return false;
    }
    if (is_reserved != other.isReserved())
        return false;
    if (is_removable != other.isRemovable())
        return false;
    if (read_only != other.isReadOnly())
        return false;
    if (supports_change_notifications != other.supportsChangeNotifications())
        return false;
    if (isExportable() != other.isExportable())
        return false;

    return true;
}
Ejemplo n.º 4
0
Qtilities::Core::MultiContextProperty::MultiContextProperty(const MultiContextProperty& property) : QtilitiesProperty(property){
    context_map = property.contextMap();
    last_change_context = property.lastChangedContext();
}