From 78c83d83b01052932c638471a02e3d94de268794 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 27 Jun 2014 00:24:31 +0200 Subject: [PATCH] The proper enum type is now determined by type not name. --- .../gui_editor/property_browser_ctrl.cpp | 23 +++++++++++++------ .../gui_editor/property_browser_ctrl.h | 1 + 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/code/studio/src/plugins/gui_editor/property_browser_ctrl.cpp b/code/studio/src/plugins/gui_editor/property_browser_ctrl.cpp index 3e25cbab8..7effe6765 100644 --- a/code/studio/src/plugins/gui_editor/property_browser_ctrl.cpp +++ b/code/studio/src/plugins/gui_editor/property_browser_ctrl.cpp @@ -296,8 +296,18 @@ namespace GUIEditor void CPropBrowserCtrl::onEnumPropertyChanged( QtProperty *prop, int value ) { QString propName = prop->propertyName(); + std::string n = propName.toUtf8().constData(); - if( propName == "button_type" ) + // Try to find the type for this property + std::map< std::string, std::string >::const_iterator itr = + nameToType.find( n ); + // Not found :( + if( itr == nameToType.end() ) + return; + std::string type = itr->second; + + + if( type == "button_type" ) { CInterfaceElement *e = CWidgetManager::getInstance()->getElementFromId( currentElement ); if( e == NULL ) @@ -311,7 +321,7 @@ namespace GUIEditor e->setProperty( propName.toUtf8().constData(), v ); } else - if( propName == "justification" ) + if( type == "text_justification" ) { CInterfaceElement *e = CWidgetManager::getInstance()->getElementFromId( currentElement ); if( e == NULL ) @@ -325,11 +335,7 @@ namespace GUIEditor e->setProperty( propName.toUtf8().constData(), v ); } else - if( ( propName == "posref" ) || - ( propName == "parentposref" ) || - ( propName == "text_posref" ) || - ( propName == "text_parent_posref" ) - ) + if( type == "posref" ) { CInterfaceElement *e = CWidgetManager::getInstance()->getElementFromId( currentElement ); if( e == NULL ) @@ -366,10 +372,13 @@ namespace GUIEditor return; SWidgetInfo &w = itr->second; + nameToType.clear(); + std::vector< SPropEntry >::const_iterator pItr; for( pItr = w.props.begin(); pItr != w.props.end(); ++pItr ) { const SPropEntry &prop = *pItr; + nameToType[ prop.propName ] = prop.propType; setupProperty( prop, element ); } diff --git a/code/studio/src/plugins/gui_editor/property_browser_ctrl.h b/code/studio/src/plugins/gui_editor/property_browser_ctrl.h index f8d839bd6..f53648f79 100644 --- a/code/studio/src/plugins/gui_editor/property_browser_ctrl.h +++ b/code/studio/src/plugins/gui_editor/property_browser_ctrl.h @@ -71,6 +71,7 @@ namespace GUIEditor std::string currentElement; std::map< std::string, SWidgetInfo > widgetInfo; + std::map< std::string, std::string > nameToType; }; }