Handle selected arrays too ( show size, changing it isn't implemented yet ).
This commit is contained in:
parent
3cd0f3fd7c
commit
d5651ae591
1 changed files with 52 additions and 15 deletions
|
@ -70,18 +70,45 @@ public:
|
||||||
m_browser->addProperty( p );
|
m_browser->addProperty( p );
|
||||||
}
|
}
|
||||||
|
|
||||||
void setupStruct( NLGEORGES::CFormElmStruct *st )
|
void setupArray( NLGEORGES::UFormElm *node )
|
||||||
{
|
{
|
||||||
|
NLGEORGES::CFormElmArray *arr = static_cast< NLGEORGES::CFormElmArray* >( node );
|
||||||
|
uint size = 0;
|
||||||
|
arr->getArraySize( size );
|
||||||
|
|
||||||
|
std::string name;
|
||||||
|
arr->getFormName( name, NULL );
|
||||||
|
QString key = name.c_str();
|
||||||
|
key = key.mid( 1 );
|
||||||
|
|
||||||
|
QtVariantProperty *p = mgr->addProperty( QVariant::Int, key );
|
||||||
|
p->setValue( size );
|
||||||
|
m_browser->addProperty( p );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void setupStruct( NLGEORGES::UFormElm *node )
|
||||||
|
{
|
||||||
|
NLGEORGES::CFormElmStruct *st = static_cast< NLGEORGES::CFormElmStruct* >( node );
|
||||||
|
|
||||||
for( int i = 0; i < st->Elements.size(); i++ )
|
for( int i = 0; i < st->Elements.size(); i++ )
|
||||||
{
|
{
|
||||||
NLGEORGES::CFormElmStruct::CFormElmStructElm &elm = st->Elements[ i ];
|
NLGEORGES::CFormElmStruct::CFormElmStructElm &elm = st->Elements[ i ];
|
||||||
if( ( elm.Element != NULL ) && !elm.Element->isAtom() )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
setupAtom( elm );
|
setupAtom( elm );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
m_currentNode = st;
|
void setupNode( NLGEORGES::UFormElm *node )
|
||||||
|
{
|
||||||
|
if( node->isStruct() )
|
||||||
|
setupStruct( node );
|
||||||
|
else
|
||||||
|
if( node->isArray() )
|
||||||
|
setupArray( node );
|
||||||
|
else
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_currentNode = node;
|
||||||
m_browser->setFactoryForManager( mgr, factory );
|
m_browser->setFactoryForManager( mgr, factory );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,11 +123,8 @@ public:
|
||||||
m_browser = browser;
|
m_browser = browser;
|
||||||
}
|
}
|
||||||
|
|
||||||
void onValueChanged( QtProperty *p, const QVariant &value )
|
void onStructValueChanged( QtProperty *p, const QVariant &value )
|
||||||
{
|
{
|
||||||
if( m_currentNode == NULL )
|
|
||||||
return;
|
|
||||||
|
|
||||||
std::string k = p->propertyName().toUtf8().constData();
|
std::string k = p->propertyName().toUtf8().constData();
|
||||||
std::string v = value.toString().toUtf8().constData();
|
std::string v = value.toString().toUtf8().constData();
|
||||||
|
|
||||||
|
@ -108,6 +132,23 @@ public:
|
||||||
m_currentNode->setValueByName( v.c_str(), k.c_str(), &created );
|
m_currentNode->setValueByName( v.c_str(), k.c_str(), &created );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void onArrayValueChanged( QtProperty *p, const QVariant &value )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void onValueChanged( QtProperty *p, const QVariant &value )
|
||||||
|
{
|
||||||
|
if( m_currentNode == NULL )
|
||||||
|
return;
|
||||||
|
|
||||||
|
if( m_currentNode->isStruct() )
|
||||||
|
onStructValueChanged( p, value );
|
||||||
|
else
|
||||||
|
if( m_currentNode->isArray() )
|
||||||
|
onArrayValueChanged( p, value );
|
||||||
|
}
|
||||||
|
|
||||||
QtVariantPropertyManager* manager() const{ return mgr; }
|
QtVariantPropertyManager* manager() const{ return mgr; }
|
||||||
|
|
||||||
void setRootNode( NLGEORGES::CFormElm *root ){ m_rootNode = root; }
|
void setRootNode( NLGEORGES::CFormElm *root ){ m_rootNode = root; }
|
||||||
|
@ -151,11 +192,7 @@ void BrowserCtrl::clicked( const QModelIndex &idx )
|
||||||
if( !b || ( node == NULL ) )
|
if( !b || ( node == NULL ) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if( !node->isStruct() )
|
m_pvt->setupNode( node );
|
||||||
return;
|
|
||||||
|
|
||||||
NLGEORGES::CFormElmStruct *st = static_cast< NLGEORGES::CFormElmStruct* >( node );
|
|
||||||
m_pvt->setupStruct( st );
|
|
||||||
|
|
||||||
enableMgrConnections();
|
enableMgrConnections();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue