예제 #1
0
    /**
     * @brief Class::removeProperty
     * @param property
     * @return
     */
    int Class::removeProperty(const SharedProperty &property)
    {
        int pos = m_Properties.indexOf(property);
        if (pos != -1) {
            disconnect(property.get(), &Property::methodAdded, this, &Class::onOptionalMethodAdded);
            disconnect(property.get(), &Property::methodRemoved, this, &Class::onOptionalMethodRemoved);
            m_Properties.removeOne(property);
        }

        return pos;
    }
예제 #2
0
QHash<QByteArray,QString> Qtilities::Core::ObserverDotWriter::nodeAttributes(QObject* node) const {
    if (!d->observer)
        return QHash<QByteArray,QString>();

    if (!node)
        return QHash<QByteArray,QString>();

    QList<QByteArray> property_names = node->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.node")) {
            // Get the property value:
            SharedProperty prop = ObjectManager::getSharedProperty(node,property_names.at(i));
            if (prop.isValid())
                dot_properties[property_names.at(i)] = prop.value().toString();
        }
    }

    return dot_properties;
}
예제 #3
0
bool Qtilities::Core::SharedProperty::operator==(const SharedProperty& other) const {
    if (name != other.propertyNameString())
        return false;
    if (property_value != other.value())
        return false;
    if (is_reserved != other.isReserved())
        return false;
    if (read_only != other.isReadOnly())
        return false;
    if (is_removable != other.isRemovable())
        return false;
    if (supports_change_notifications != other.supportsChangeNotifications())
        return false;
    if (isExportable() != other.isExportable())
        return false;

    return true;
}
예제 #4
0
Qtilities::Core::SharedProperty::SharedProperty(const SharedProperty& shared_property) : QtilitiesProperty(shared_property) {
    property_value = shared_property.value();
}
예제 #5
0
    /**
     * @brief Class::fromJson
     * @param src
     * @param errorList
     */
    void Class::fromJson(const QJsonObject &src, QStringList &errorList)
    {
        Type::fromJson(src, errorList);

        utility::checkAndSet(src, "Kind", errorList, [&src, this](){
            m_Kind = static_cast<Kind>(src["Kind"].toInt());
        });
        utility::checkAndSet(src, "Final status", errorList, [&src, this](){
            m_FinalStatus = src["Final status"].toBool();
        });

        m_Parents.clear();
        utility::checkAndSet(src, "Parents", errorList, [&src, &errorList, this](){
            Parent p;
            QJsonObject o;
            if (src["Parents"].isArray()) {
                for (auto &&value : src["Parents"].toArray()) {
                    o = value.toObject();
                    utility::checkAndSet(o, "Id", errorList, [&o, &p, this](){
                        p.first = o["Id"].toString();
                    });
                    utility::checkAndSet(o, "Section", errorList, [&o, &p, this](){
                        p.second = static_cast<Section>(o["Section"].toInt());
                    });
                    m_Parents.append(p);
                }
            } else {
                errorList << "Error: \"Parents\" is not array";
            }
        });

        m_Methods.clear();
        utility::checkAndSet(src, "Methods", errorList, [&src, &errorList, this](){
            if (src["Methods"].isArray()) {
                SharedMethod method;
                QJsonObject obj;
                for (auto &&value : src["Methods"].toArray()) {
                    obj = value.toObject();
                    utility::checkAndSet(obj, "Type", errorList,
                                         [&obj, &errorList, &method, this](){
                        method = utility::makeMethod(static_cast<ClassMethodType>(obj["Type"].toInt()));
                        method->fromJson(obj, errorList);
                        m_Methods << method;
                    });
                }
            } else {
                errorList << "Error: \"Methods\" is not array";
            }
        });

        m_Fields.clear();
        utility::checkAndSet(src, "Fields", errorList, [&src, &errorList, this](){
            if (src["Fields"].isArray()) {
                SharedField field;
                for (auto &&value : src["Fields"].toArray()) {
                    field = std::make_shared<Field>();
                    field->fromJson(value.toObject(), errorList);
                    m_Fields << field;
                }
            } else {
                errorList << "Error: \"Fields\" is not array";
            }
        });

        m_Properties.clear();
        utility::checkAndSet(src, "Properties", errorList, [&src, &errorList, this](){
            if (src["Properties"].isArray()) {
                SharedProperty property;
                for (auto &&value : src["Properties"].toArray()) {
                    property = std::make_shared<Property>();
                    property->fromJson(value.toObject(), errorList);
                    m_Properties << property;
                }
            } else {
                errorList << "Error: \"Properties\" is not array";
            }
        });
    }