void SystemsSettingsEditor::ShowDialog()
{
	QPushButton * sender = dynamic_cast<QPushButton *>(QObject::sender());
	DVASSERT(sender);

	QtPropertyDataDavaVariant* propertyToChange = buttonsMap[sender].property;
	STATE_FLAGS_MAP* propFlagsMap = buttonsMap[sender].flagsMap;

	DVASSERT(propertyToChange);
	DVASSERT(propFlagsMap);
	uint32 oldValue  = ResolveMapToUint(*propFlagsMap);
	SettingsStateDialog dialog(propFlagsMap,this);
	dialog.exec();
	
	if(dialog.result() != QDialog::Accepted )
	{
		return;
	}
	uint32 newValue = ResolveMapToUint(*propFlagsMap);
	if(newValue == oldValue)
	{
		return;
	}
	
	propertyToChange->AddAllowedValue(DAVA::VariantType((int32)newValue), ResolveMapToString(*propFlagsMap).c_str());
	propertyToChange->SetVariantValue(DAVA::VariantType((int32)newValue));
	propertyToChange->SetValue(QVariant((int32)newValue));
	
}
void QtPropertyDataIntrospection::ChildChanged(const QString &key, QtPropertyData *data)
{
	QtPropertyDataDavaVariant *dataVariant = (QtPropertyDataDavaVariant *) data;

	if(childVariantMembers.contains(dataVariant))
	{
		const DAVA::IntrospectionMember *member = childVariantMembers[dataVariant];
		member->SetValue(object, dataVariant->GetVariantValue());
	}
}
예제 #3
0
void QtPropertyDataDavaKeyedArcive::ChildChanged(const QString &key, QtPropertyData *data)
{
    if(NULL != curArchive)
    {
        QtPropertyDataDavaVariant *variantData = dynamic_cast<QtPropertyDataDavaVariant *>(data);
        if(NULL != variantData)
        {
            curArchive->SetVariant(key.toStdString(), variantData->GetVariantValue());
        }
    }
}
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);
            }
        }
    }
}
void SystemsSettingsEditor::RestoreInitialSettings()
{
	for (DAVA::List<PropertyInfo>::iterator it= propertiesMap.begin(); it != propertiesMap.end(); ++it)
	{
		QtPropertyDataDavaVariant* property = it->property;
		STATE_FLAGS_MAP *  map = it->flagsMap;
		if(NULL != map)
		{
			InitMapWithFlag(map, it->defaultValue.toInt());
		}
		this->model()->blockSignals(true);
		property->SetValue(it->defaultValue);
		this->model()->blockSignals(false);
	}
}
void QtPropertyDataIntrospection::ChildNeedUpdate()
{
	QMapIterator<QtPropertyDataDavaVariant*, const DAVA::IntrospectionMember *> i = QMapIterator<QtPropertyDataDavaVariant*, const DAVA::IntrospectionMember *>(childVariantMembers);

	while(i.hasNext())
	{
		i.next();

		QtPropertyDataDavaVariant *childData = i.key();
		DAVA::VariantType childCurValue = i.value()->Value(object);

		if(childCurValue != childData->GetVariantValue())
		{
			childData->SetVariantValue(childCurValue);
		}

	}
}