The proper enum type is now determined by type not name.

This commit is contained in:
dfighter1985 2014-06-27 00:24:31 +02:00
parent 3ac5ecc59b
commit c45f3547e5
2 changed files with 17 additions and 7 deletions

View file

@ -296,8 +296,18 @@ namespace GUIEditor
void CPropBrowserCtrl::onEnumPropertyChanged( QtProperty *prop, int value ) void CPropBrowserCtrl::onEnumPropertyChanged( QtProperty *prop, int value )
{ {
QString propName = prop->propertyName(); 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 ); CInterfaceElement *e = CWidgetManager::getInstance()->getElementFromId( currentElement );
if( e == NULL ) if( e == NULL )
@ -311,7 +321,7 @@ namespace GUIEditor
e->setProperty( propName.toUtf8().constData(), v ); e->setProperty( propName.toUtf8().constData(), v );
} }
else else
if( propName == "justification" ) if( type == "text_justification" )
{ {
CInterfaceElement *e = CWidgetManager::getInstance()->getElementFromId( currentElement ); CInterfaceElement *e = CWidgetManager::getInstance()->getElementFromId( currentElement );
if( e == NULL ) if( e == NULL )
@ -325,11 +335,7 @@ namespace GUIEditor
e->setProperty( propName.toUtf8().constData(), v ); e->setProperty( propName.toUtf8().constData(), v );
} }
else else
if( ( propName == "posref" ) || if( type == "posref" )
( propName == "parentposref" ) ||
( propName == "text_posref" ) ||
( propName == "text_parent_posref" )
)
{ {
CInterfaceElement *e = CWidgetManager::getInstance()->getElementFromId( currentElement ); CInterfaceElement *e = CWidgetManager::getInstance()->getElementFromId( currentElement );
if( e == NULL ) if( e == NULL )
@ -366,10 +372,13 @@ namespace GUIEditor
return; return;
SWidgetInfo &w = itr->second; SWidgetInfo &w = itr->second;
nameToType.clear();
std::vector< SPropEntry >::const_iterator pItr; std::vector< SPropEntry >::const_iterator pItr;
for( pItr = w.props.begin(); pItr != w.props.end(); ++pItr ) for( pItr = w.props.begin(); pItr != w.props.end(); ++pItr )
{ {
const SPropEntry &prop = *pItr; const SPropEntry &prop = *pItr;
nameToType[ prop.propName ] = prop.propType;
setupProperty( prop, element ); setupProperty( prop, element );
} }

View file

@ -71,6 +71,7 @@ namespace GUIEditor
std::string currentElement; std::string currentElement;
std::map< std::string, SWidgetInfo > widgetInfo; std::map< std::string, SWidgetInfo > widgetInfo;
std::map< std::string, std::string > nameToType;
}; };
} }