void QtPropertyDataIntrospection::AddMember(const DAVA::IntrospectionMember *member, int hasAnyFlags, int hasNotAnyFlags)
{
	void *memberObject = member->Data(object);
	const DAVA::MetaInfo *memberMetaInfo = member->Type();
	const DAVA::IntrospectionInfo *memberIntrospection = memberMetaInfo->GetIntrospection(memberObject);
	bool isKeyedArchive = false;

	// keyed archive
	if(NULL != memberIntrospection && (memberIntrospection->Type() == DAVA::MetaInfo::Instance<DAVA::KeyedArchive>()))
	{
		QtPropertyDataDavaKeyedArcive *childData = new QtPropertyDataDavaKeyedArcive((DAVA::KeyedArchive *) memberObject);
		ChildAdd(member->Name(), childData);
	}
	// introspection
	else if(NULL != memberObject && NULL != memberIntrospection)
    {
		QtPropertyDataIntrospection *childData = new QtPropertyDataIntrospection(memberObject, memberIntrospection, hasAnyFlags, hasNotAnyFlags);
		ChildAdd(member->Name(), childData);
    }
	// any other value
    else
    {
		// pointer
        if(memberMetaInfo->IsPointer())
        {
			QString s;
            QtPropertyData* childData = new QtPropertyData(s.sprintf("[%p] Pointer", memberObject));
            childData->SetFlags(childData->GetFlags() | FLAG_IS_DISABLED);
            ChildAdd(member->Name(), childData);
        }
		// other value
        else
        {
			// collection
            if(member->Collection() && !isKeyedArchive)
            {
                QtPropertyDataIntroCollection *childCollection = new QtPropertyDataIntroCollection(memberObject, member->Collection(), hasAnyFlags, hasNotAnyFlags);
                ChildAdd(member->Name(), childCollection);
            }
			// variant
            else
            {
                QtPropertyDataDavaVariant *childData = new QtPropertyDataDavaVariant(member->Value(object));
                if(member->Flags() & DAVA::INTROSPECTION_EDITOR_READONLY)
                {
                    childData->SetFlags(childData->GetFlags() | FLAG_IS_NOT_EDITABLE);
                }
                
                ChildAdd(member->Name(), childData);
                childVariantMembers.insert(childData, member);
            }
        }
    }
}
Ejemplo n.º 2
0
Qt::ItemFlags QtPropertyModel::flags(const QModelIndex & index) const
{
	Qt::ItemFlags ret = 0;

	if(index.column() == 1)
	{
		QtPropertyData *data = itemFromIndex(index);
		if(NULL != data)
		{
			ret = Qt::ItemIsSelectable | data->GetFlags();
		}
	}
	else
	{
		ret = Qt::ItemIsSelectable | Qt::ItemIsEnabled;
	}

	return ret;
}
QtPropertyData * QtPropertyDataIntrospection::CreateMemberData(void *_object, const DAVA::InspMember *member, int hasAllFlags)
{
	void *memberObject = member->Data(_object);
	const DAVA::MetaInfo *memberMetaInfo = member->Type();
	const DAVA::InspInfo *memberIntrospection = memberMetaInfo->GetIntrospection(memberObject);
	bool isKeyedArchive = false;

	QtPropertyData * retData = NULL;
	// keyed archive
	if(NULL != memberIntrospection && (memberIntrospection->Type() == DAVA::MetaInfo::Instance<DAVA::KeyedArchive>()))
	{
		retData = new QtPropertyDataDavaKeyedArcive((DAVA::KeyedArchive *) memberObject);
	}
	// introspection
	else if(NULL != memberObject && NULL != memberIntrospection)
    {
		retData = new QtPropertyDataIntrospection(memberObject, memberIntrospection, hasAllFlags);
    }
	// any other value
    else
    {
		// pointer
        if(memberMetaInfo->IsPointer())
        {
			QString s;
            retData = new QtPropertyData(s.sprintf("[%p] Pointer", memberObject));
            retData->SetFlags(retData->GetFlags() | FLAG_IS_DISABLED);
        }
		// other value
        else
        {
			// collection
            if(member->Collection() && !isKeyedArchive)
            {
                retData = new QtPropertyDataInspColl(memberObject, member->Collection(), hasAllFlags);
            }
			// variant
            else
            {
                QtPropertyDataInspMember *childData = new QtPropertyDataInspMember(_object, member);
                if(!(member->Flags() & DAVA::I_EDIT))
                {
                    childData->SetFlags(childData->GetFlags() | FLAG_IS_NOT_EDITABLE);
                }
				else
				{
					// check if description has some predefines enum values
					const DAVA::InspDesc &desc = member->Desc();

					if(NULL != desc.enumMap)
					{
						for(size_t i = 0; i < desc.enumMap->GetCount(); ++i)
						{
							int v;
							if(desc.enumMap->GetValue(i, v))
							{
								childData->AddAllowedValue(DAVA::VariantType(v), desc.enumMap->ToString(v));
							}
						}
					}
				}
                
                retData = childData;
            }
        }
    }
	return retData;
}