Пример #1
0
void AbstractItemEditor::resetProperty(QtProperty *property)
{
    if (m_propertyManager->resetFontSubProperty(property))
        return;

    if (m_propertyManager->resetIconSubProperty(property))
        return;

    BoolBlocker block(m_updatingBrowser);

    QtVariantProperty *prop = m_propertyManager->variantProperty(property);
    int role = m_propertyToRole.value(prop);
    if (role == ItemFlagsShadowRole)
        prop->setValue(qVariantFromValue((int)QListWidgetItem().flags()));
    else
        prop->setValue(QVariant(prop->valueType(), (void *)0));
    prop->setModified(false);

    setItemData(role, QVariant());
    if (role == Qt::DecorationPropertyRole)
        setItemData(Qt::DecorationRole, qVariantFromValue(QIcon()));
    if (role == Qt::DisplayPropertyRole)
        setItemData(Qt::EditRole, qVariantFromValue(QString()));
    if (role == Qt::ToolTipPropertyRole)
        setItemData(Qt::ToolTipRole, qVariantFromValue(QString()));
    if (role == Qt::StatusTipPropertyRole)
        setItemData(Qt::StatusTipRole, qVariantFromValue(QString()));
    if (role == Qt::WhatsThisPropertyRole)
        setItemData(Qt::WhatsThisRole, qVariantFromValue(QString()));
}
Пример #2
0
    void Inspector::setTargetProperty(const std::string &name, const rapidjson::Value &value)
    {
        auto it = name2property_.find(name);
        if(it == name2property_.end())
        {
            return;
        }

        QtVariantProperty *property = dynamic_cast<QtVariantProperty*>(it->second);
        if(property != nullptr)
        {
            int valueType = property->valueType();
            QVariant qvalue;
            json2tvalue(qvalue, value, valueType);

            QtVariantPropertyManager *propertyMgr = PropertyItemFactory::instance()->getPropertyMgr();
            propertyMgr->setValue(property, qvalue);
        }
    }