Fixed bug: Setting property value string did not update children of composed parent (ported from wxPG SVN trunk)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@55606 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -399,7 +399,8 @@ enum wxPG_SETVALUE_FLAGS
|
|||||||
{
|
{
|
||||||
wxPG_SETVAL_REFRESH_EDITOR = 0x0001,
|
wxPG_SETVAL_REFRESH_EDITOR = 0x0001,
|
||||||
wxPG_SETVAL_AGGREGATED = 0x0002,
|
wxPG_SETVAL_AGGREGATED = 0x0002,
|
||||||
wxPG_SETVAL_FROM_PARENT = 0x0004
|
wxPG_SETVAL_FROM_PARENT = 0x0004,
|
||||||
|
wxPG_SETVAL_BY_USER = 0x0008 // Set if value changed by user
|
||||||
};
|
};
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
@@ -875,6 +875,31 @@ bool FormMain::RunTests( bool fullTest, bool interactive )
|
|||||||
pgman->SetPropertyValue(wxT("IntProperty"),wxLL(-80000000000));
|
pgman->SetPropertyValue(wxT("IntProperty"),wxLL(-80000000000));
|
||||||
if ( pgman->GetPropertyValueAsLongLong(wxT("IntProperty")) != wxLL(-80000000000) )
|
if ( pgman->GetPropertyValueAsLongLong(wxT("IntProperty")) != wxLL(-80000000000) )
|
||||||
RT_FAILURE();
|
RT_FAILURE();
|
||||||
|
|
||||||
|
// Make sure children of composite parent get updated as well
|
||||||
|
// Original string value: "Lamborghini Diablo SV; 5707; [300; 3.9; 8.6] 300000"
|
||||||
|
|
||||||
|
// This updates children as well
|
||||||
|
wxString nvs = "Lamborghini Diablo XYZ; 5707; [100; 3.9; 8.6] 3000002";
|
||||||
|
pgman->SetPropertyValue(wxT("Car"), nvs);
|
||||||
|
|
||||||
|
if ( pgman->GetPropertyValueAsString(wxT("Car.Model")) != "Lamborghini Diablo XYZ" )
|
||||||
|
{
|
||||||
|
wxLogDebug("Did not match: Car.Model=%s", pgman->GetPropertyValueAsString(wxT("Car.Model")).c_str());
|
||||||
|
RT_FAILURE();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( pgman->GetPropertyValueAsInt(wxT("Car.Speeds.Max. Speed (mph)")) != 100 )
|
||||||
|
{
|
||||||
|
wxLogDebug("Did not match: Car.Speeds.Max. Speed (mph)=%s", pgman->GetPropertyValueAsString(wxT("Car.Speeds.Max. Speed (mph)")).c_str());
|
||||||
|
RT_FAILURE();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( pgman->GetPropertyValueAsInt(wxT("Car.Price ($)")) != 3000002 )
|
||||||
|
{
|
||||||
|
wxLogDebug("Did not match: Car.Price ($)=%s", pgman->GetPropertyValueAsString(wxT("Car.Price ($)")).c_str());
|
||||||
|
RT_FAILURE();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@@ -892,12 +892,22 @@ void wxPGProperty::SetValue( wxVariant value, wxVariant* pList, int flags )
|
|||||||
{
|
{
|
||||||
if ( !value.IsNull() )
|
if ( !value.IsNull() )
|
||||||
{
|
{
|
||||||
|
wxVariant tempListVariant;
|
||||||
|
|
||||||
SetCommonValue(-1);
|
SetCommonValue(-1);
|
||||||
// List variants are reserved a special purpose
|
// List variants are reserved a special purpose
|
||||||
// as intermediate containers for child values
|
// as intermediate containers for child values
|
||||||
// of properties with children.
|
// of properties with children.
|
||||||
if ( wxPGIsVariantType(value, list) )
|
if ( wxPGIsVariantType(value, list) )
|
||||||
{
|
{
|
||||||
|
//
|
||||||
|
// However, situation is different for composed string properties
|
||||||
|
if ( HasFlag(wxPG_PROP_COMPOSED_VALUE) )
|
||||||
|
{
|
||||||
|
tempListVariant = value;
|
||||||
|
pList = &tempListVariant;
|
||||||
|
}
|
||||||
|
|
||||||
wxVariant newValue;
|
wxVariant newValue;
|
||||||
AdaptListToValue(value, &newValue);
|
AdaptListToValue(value, &newValue);
|
||||||
value = newValue;
|
value = newValue;
|
||||||
@@ -942,15 +952,13 @@ void wxPGProperty::SetValue( wxVariant value, wxVariant* pList, int flags )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( !wxPG_VARIANT_EQ(child->GetValue(), childValue) )
|
else if ( !wxPG_VARIANT_EQ(child->GetValue(), childValue) )
|
||||||
// This flag is not normally set when setting value programmatically.
|
|
||||||
// However, this loop is usually only executed when called from
|
|
||||||
// DoPropertyChanged, which should set this flag.
|
|
||||||
{
|
{
|
||||||
// For aggregate properties, we will trust RefreshChildren()
|
// For aggregate properties, we will trust RefreshChildren()
|
||||||
// to update child values.
|
// to update child values.
|
||||||
if ( !HasFlag(wxPG_PROP_AGGREGATE) )
|
if ( !HasFlag(wxPG_PROP_AGGREGATE) )
|
||||||
child->SetValue(childValue, NULL, flags|wxPG_SETVAL_FROM_PARENT);
|
child->SetValue(childValue, NULL, flags|wxPG_SETVAL_FROM_PARENT);
|
||||||
child->SetFlag(wxPG_PROP_MODIFIED);
|
if ( flags & wxPG_SETVAL_BY_USER )
|
||||||
|
child->SetFlag(wxPG_PROP_MODIFIED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
@@ -966,7 +974,7 @@ void wxPGProperty::SetValue( wxVariant value, wxVariant* pList, int flags )
|
|||||||
UpdateParentValues();
|
UpdateParentValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( pList )
|
if ( flags & wxPG_SETVAL_BY_USER )
|
||||||
SetFlag(wxPG_PROP_MODIFIED);
|
SetFlag(wxPG_PROP_MODIFIED);
|
||||||
|
|
||||||
if ( HasFlag(wxPG_PROP_AGGREGATE) )
|
if ( HasFlag(wxPG_PROP_AGGREGATE) )
|
||||||
|
@@ -3076,7 +3076,7 @@ bool wxPropertyGrid::DoPropertyChanged( wxPGProperty* p, unsigned int selFlags )
|
|||||||
topPaintedProperty = topPaintedProperty->GetParent();
|
topPaintedProperty = topPaintedProperty->GetParent();
|
||||||
}
|
}
|
||||||
|
|
||||||
changedProperty->SetValue(value, &m_chgInfo_valueList);
|
changedProperty->SetValue(value, &m_chgInfo_valueList, wxPG_SETVAL_BY_USER);
|
||||||
|
|
||||||
// Set as Modified (not if dragging just began)
|
// Set as Modified (not if dragging just began)
|
||||||
if ( !(p->m_flags & wxPG_PROP_MODIFIED) )
|
if ( !(p->m_flags & wxPG_PROP_MODIFIED) )
|
||||||
|
Reference in New Issue
Block a user