Esempio n. 1
0
void EC_DynamicComponent::AddQVariantAttribute(const QString &name, AttributeChange::Type change)
{
    //Check if the attribute has already been created.
    if(!ContainsAttribute(name))
    {
        Attribute<QVariant> *attribute = new Attribute<QVariant>(this, name.toStdString().c_str());
        EmitAttributeChanged(attribute, change);
        emit AttributeAdded(attribute);
    }
    else
        LogWarning("Failed to add a new QVariant in name of " + name.toStdString() + ", cause there already is an attribute in that name.");
}
Esempio n. 2
0
void EC_DynamicComponent::AddQVariantAttribute(const QString &id, AttributeChange::Type change)
{
    LogWarning("EC_DynamicComponent::AddQVariantAttribute is deprecated and will be removed. Use CreateAttribute(\"QVariant\",...) instead.");
    //Check if the attribute has already been created.
    if(!ContainsAttribute(id))
    {
        Attribute<QVariant> *attribute = new Attribute<QVariant>(this, id.toStdString().c_str());
        EmitAttributeChanged(attribute, change);
        emit AttributeAdded(attribute);
    }
    else
        LogWarning("Failed to add a new QVariant with ID " + id + ", because there already is an attribute with that ID.");
}
Esempio n. 3
0
IAttribute *EC_DynamicComponent::CreateAttribute(const QString &typeName, const QString &id, AttributeChange::Type change)
{
    if (ContainsAttribute(id))
        return IComponent::AttributeById(id);

    IAttribute *attribute = SceneAPI::CreateAttribute(typeName, id);
    if (!attribute)
    {
        LogError("Failed to create new attribute of type \"" + typeName + "\" with ID \"" + id + "\" to dynamic component \"" + Name() + "\".");
        return 0;
    }

    IComponent::AddAttribute(attribute);

    Scene* scene = ParentScene();
    if (scene)
        scene->EmitAttributeAdded(this, attribute, change);

    emit AttributeAdded(attribute);
    EmitAttributeChanged(attribute, change);
    return attribute;
}
Esempio n. 4
0
IAttribute *EC_DynamicComponent::CreateAttribute(const QString &typeName, const QString &name, AttributeChange::Type change)
{
    if(ContainsAttribute(name))
        return IComponent::GetAttribute(name);

    IAttribute *attribute = framework_->GetComponentManager()->CreateAttribute(this, typeName.toStdString(), name.toStdString());
    if(!attribute)
    {
        LogError("Failed to create new attribute:" + name + " in dynamic component:" + Name());
        return 0;
    }

    // Trigger scenemanager signal
    Scene::SceneManager* scene = GetParentScene();
    if (scene)
        scene->EmitAttributeAdded(this, attribute, change);
    
    // Trigger internal signal
    emit AttributeAdded(attribute);
    EmitAttributeChanged(attribute, change);
    return attribute;
}