QtPropertyData* QtPropertyModel::itemFromIndex(const QModelIndex & index) const { QtPropertyData *ret = NULL; if(index.isValid() && index.model() == this) { QtPropertyData *parent = static_cast<QtPropertyData *>(index.internalPointer()); if(NULL != parent) { ret = parent->ChildGet(index.row()); } } return ret; }
void QtPropertyDataDavaVariant::MeSetFromChilds(const QString &lastChangedChildKey, QtPropertyData *lastChangedChildData) { switch(curVariantValue.type) { case DAVA::VariantType::TYPE_KEYED_ARCHIVE: { QtPropertyDataDavaVariant *childVariantData = (QtPropertyDataDavaVariant *) lastChangedChildData; DAVA::KeyedArchive *archive = curVariantValue.AsKeyedArchive(); if(NULL != archive && NULL != childVariantData) { archive->SetVariant(lastChangedChildKey.toStdString(), childVariantData->curVariantValue); } } break; case DAVA::VariantType::TYPE_MATRIX2: break; case DAVA::VariantType::TYPE_MATRIX3: break; case DAVA::VariantType::TYPE_MATRIX4: break; case DAVA::VariantType::TYPE_VECTOR2: { DAVA::Vector2 vec; vec.x = ChildGet("X")->GetValue().toFloat(); vec.y = ChildGet("Y")->GetValue().toFloat(); curVariantValue.SetVector2(vec); } break; case DAVA::VariantType::TYPE_VECTOR3: { DAVA::Vector3 vec; vec.x = ChildGet("X")->GetValue().toFloat(); vec.y = ChildGet("Y")->GetValue().toFloat(); vec.z = ChildGet("Z")->GetValue().toFloat(); curVariantValue.SetVector3(vec); } break; case DAVA::VariantType::TYPE_VECTOR4: { DAVA::Vector4 vec; vec.x = ChildGet("X")->GetValue().toFloat(); vec.y = ChildGet("Y")->GetValue().toFloat(); vec.z = ChildGet("Z")->GetValue().toFloat(); vec.w = ChildGet("W")->GetValue().toFloat(); curVariantValue.SetVector4(vec); } break; case DAVA::VariantType::TYPE_COLOR: { // DAVA::Color color; // color.r = ChildGet("R")->GetValue().toFloat(); // color.g = ChildGet("G")->GetValue().toFloat(); // color.b = ChildGet("B")->GetValue().toFloat(); // color.a = ChildGet("A")->GetValue().toFloat(); // curVariantValue.SetColor(color); } break; case DAVA::VariantType::TYPE_AABBOX3: { DAVA::AABBox3 box; QtPropertyData* min = ChildGet("min"); box.min.x = min->ChildGet("X")->GetValue().toFloat(); box.min.y = min->ChildGet("Y")->GetValue().toFloat(); box.min.z = min->ChildGet("Z")->GetValue().toFloat(); QtPropertyData* max = ChildGet("max"); box.max.x = max->ChildGet("X")->GetValue().toFloat(); box.max.y = max->ChildGet("Y")->GetValue().toFloat(); box.max.z = max->ChildGet("Z")->GetValue().toFloat(); curVariantValue.SetAABBox3(box); } break; } }
void QtPropertyDataDavaVariant::ChildsSetFromMe() { switch(curVariantValue.type) { case DAVA::VariantType::TYPE_KEYED_ARCHIVE: { // No way to change whole archive // so don't need to re-set childs } break; case DAVA::VariantType::TYPE_MATRIX2: break; case DAVA::VariantType::TYPE_MATRIX3: break; case DAVA::VariantType::TYPE_MATRIX4: break; case DAVA::VariantType::TYPE_VECTOR2: { DAVA::Vector2 vec = curVariantValue.AsVector2(); ChildGet("X")->SetValue(vec.x); ChildGet("Y")->SetValue(vec.y); } break; case DAVA::VariantType::TYPE_VECTOR3: { DAVA::Vector3 vec = curVariantValue.AsVector3(); ChildGet("X")->SetValue(vec.x); ChildGet("Y")->SetValue(vec.y); ChildGet("Z")->SetValue(vec.z); } break; case DAVA::VariantType::TYPE_VECTOR4: { DAVA::Vector4 vec = curVariantValue.AsVector4(); ChildGet("X")->SetValue(vec.x); ChildGet("Y")->SetValue(vec.y); ChildGet("Z")->SetValue(vec.z); ChildGet("W")->SetValue(vec.w); } break; case DAVA::VariantType::TYPE_COLOR: { // DAVA::Color color = curVariantValue.AsColor(); // ChildGet("R")->SetValue(color.r); // ChildGet("G")->SetValue(color.g); // ChildGet("B")->SetValue(color.b); // ChildGet("A")->SetValue(color.a); } break; case DAVA::VariantType::TYPE_AABBOX3: { DAVA::AABBox3 box = curVariantValue.AsAABBox3(); QtPropertyData* min = ChildGet("min"); min->SetValue(FromVector3(box.min)); min->ChildGet("X")->SetValue(box.min.x); min->ChildGet("Y")->SetValue(box.min.y); min->ChildGet("Z")->SetValue(box.min.z); QtPropertyData* max = ChildGet("max"); max->SetValue(FromVector3(box.max)); max->ChildGet("X")->SetValue(box.max.x); max->ChildGet("Y")->SetValue(box.max.y); max->ChildGet("Z")->SetValue(box.max.z); } break; } }