]> git.saurik.com Git - wxWidgets.git/commitdiff
Fixed bug: Setting property value string did not update children of composed parent...
authorJaakko Salli <jaakko.salli@dnainternet.net>
Sun, 14 Sep 2008 16:20:48 +0000 (16:20 +0000)
committerJaakko Salli <jaakko.salli@dnainternet.net>
Sun, 14 Sep 2008 16:20:48 +0000 (16:20 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@55606 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/propgrid/propgriddefs.h
samples/propgrid/tests.cpp
src/propgrid/property.cpp
src/propgrid/propgrid.cpp

index 1d3d12e68cd33c9e2b2d7908a042fd970fb76aad..44fb26e76449f84a34b56193026f2dc025b8a649 100644 (file)
@@ -399,7 +399,8 @@ enum wxPG_SETVALUE_FLAGS
 {
     wxPG_SETVAL_REFRESH_EDITOR      = 0x0001,
     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
 };
 
 // -----------------------------------------------------------------------
index c5db4a6739a30021ddc16f5520b4c0129e3b41c9..8e32907ee4a2960f5df3df0f9b07bcb2ed1719e2 100644 (file)
@@ -875,6 +875,31 @@ bool FormMain::RunTests( bool fullTest, bool interactive )
         pgman->SetPropertyValue(wxT("IntProperty"),wxLL(-80000000000));
         if ( pgman->GetPropertyValueAsLongLong(wxT("IntProperty")) != wxLL(-80000000000) )
             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();
+        }
     }
 
     {
index 7137863f7b066c9e2f0275ba3f56834a53dbb27b..b8a691dbde8270b4478d9a3efa92871ffc53c288 100644 (file)
@@ -892,12 +892,22 @@ void wxPGProperty::SetValue( wxVariant value, wxVariant* pList, int flags )
 {
     if ( !value.IsNull() )
     {
+        wxVariant tempListVariant;
+
         SetCommonValue(-1);
         // List variants are reserved a special purpose
         // as intermediate containers for child values
         // of properties with children.
         if ( wxPGIsVariantType(value, list) )
         {
+            //
+            // However, situation is different for composed string properties
+            if ( HasFlag(wxPG_PROP_COMPOSED_VALUE) )
+            {
+                tempListVariant = value;
+                pList = &tempListVariant;
+            }
+
             wxVariant newValue;
             AdaptListToValue(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) )
-                        // 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()
                         // to update child values.
                         if ( !HasFlag(wxPG_PROP_AGGREGATE) )
                             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++;
@@ -966,7 +974,7 @@ void wxPGProperty::SetValue( wxVariant value, wxVariant* pList, int flags )
                 UpdateParentValues();
         }
 
-        if ( pList )
+        if ( flags & wxPG_SETVAL_BY_USER )
             SetFlag(wxPG_PROP_MODIFIED);
 
         if ( HasFlag(wxPG_PROP_AGGREGATE) )
index 4575d4e49fa1fcaee5737d8ec2cbd26d420d4162..892e2e5d0f7d39a316ab99ecef69b2af9635f067 100644 (file)
@@ -3076,7 +3076,7 @@ bool wxPropertyGrid::DoPropertyChanged( wxPGProperty* p, unsigned int selFlags )
         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)
     if ( !(p->m_flags & wxPG_PROP_MODIFIED) )