|
|
@ -24,17 +24,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
#include "nel/georges/form.h"
|
|
|
|
#include "nel/georges/form.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "filepath_property_manager.h"
|
|
|
|
namespace
|
|
|
|
namespace
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
const unsigned int FILEBROWSER = 9000000;
|
|
|
|
|
|
|
|
|
|
|
|
QVariant::Type getValueType( const NLGEORGES::UType *typ )
|
|
|
|
QVariant::Type getValueType( const NLGEORGES::UType *typ )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QVariant::Type t = QVariant::String;
|
|
|
|
QVariant::Type t = QVariant::String;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool file = false;
|
|
|
|
|
|
|
|
|
|
|
|
NLGEORGES::UType::TType ttyp = NLGEORGES::UType::String;
|
|
|
|
NLGEORGES::UType::TType ttyp = NLGEORGES::UType::String;
|
|
|
|
if( typ != NULL )
|
|
|
|
if( typ != NULL )
|
|
|
|
|
|
|
|
{
|
|
|
|
ttyp = typ->getType();
|
|
|
|
ttyp = typ->getType();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const NLGEORGES::CType *ctyp = static_cast< const NLGEORGES::CType* >( typ );
|
|
|
|
|
|
|
|
if(ctyp->UIType == NLGEORGES::CType::FileBrowser )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
file = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( file )
|
|
|
|
|
|
|
|
return QVariant::Type( FILEBROWSER );
|
|
|
|
|
|
|
|
|
|
|
|
switch( ttyp )
|
|
|
|
switch( ttyp )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
case NLGEORGES::UType::UnsignedInt: t = QVariant::UInt; break;
|
|
|
|
case NLGEORGES::UType::UnsignedInt: t = QVariant::UInt; break;
|
|
|
@ -47,12 +62,111 @@ namespace
|
|
|
|
return t;
|
|
|
|
return t;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QVariant::Type getValueTypeFromDfn( NLGEORGES::CFormElmStruct *st, int idx )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
NLGEORGES::CFormDfn *cdfn = st->FormDfn;
|
|
|
|
|
|
|
|
NLGEORGES::CFormDfn::CEntry entry = cdfn->getEntry( idx );
|
|
|
|
|
|
|
|
return getValueType( entry.getTypePtr() );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QVariant::Type getValueTypeFromDfn( NLGEORGES::CFormElmAtom *atom )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
QVariant::Type t = QVariant::String;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NLGEORGES::CFormElm *cparent = static_cast< NLGEORGES::CFormElm* >( atom->getParent() );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( cparent->isArray() )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
NLGEORGES::CFormElmStruct *aparent = static_cast< NLGEORGES::CFormElmStruct* >( cparent->getParent() );
|
|
|
|
|
|
|
|
NLGEORGES::CFormDfn *cdfn = static_cast< NLGEORGES::CFormDfn* >( aparent->getStructDfn() );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int idx = -1;
|
|
|
|
|
|
|
|
for( idx = 0; idx < aparent->Elements.size(); idx++ )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if( aparent->Elements[ idx ].Element == cparent )
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NLGEORGES::CFormDfn::CEntry entry = cdfn->getEntry( idx );
|
|
|
|
|
|
|
|
return getValueType( entry.getTypePtr() );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
if( cparent->isStruct() )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
NLGEORGES::CFormElmStruct *sparent = static_cast< NLGEORGES::CFormElmStruct* >( cparent );
|
|
|
|
|
|
|
|
NLGEORGES::CFormDfn *cdfn = static_cast< NLGEORGES::CFormDfn* >( cparent->getStructDfn() );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int idx = -1;
|
|
|
|
|
|
|
|
for( idx = 0; idx < sparent->Elements.size(); idx++ )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if( sparent->Elements[ idx ].Element == atom )
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NLGEORGES::CFormDfn::CEntry entry = cdfn->getEntry( idx );
|
|
|
|
|
|
|
|
return getValueType( entry.getTypePtr() );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return t;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NLGEORGES::UFormElm* getGeorgesNode( GeorgesQt::CFormItem *item )
|
|
|
|
NLGEORGES::UFormElm* getGeorgesNode( GeorgesQt::CFormItem *item )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
NLGEORGES::UFormElm *n = NULL;
|
|
|
|
NLGEORGES::UFormElm *n = NULL;
|
|
|
|
item->form()->getRootNode().getNodeByName( &n, item->formName().c_str() );
|
|
|
|
item->form()->getRootNode().getNodeByName( &n, item->formName().c_str() );
|
|
|
|
return n;
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Get the data from a string, and pack it into a QVariant properly
|
|
|
|
|
|
|
|
// Needed for some special values, like color
|
|
|
|
|
|
|
|
// which are represented differently in Nel and Qt
|
|
|
|
|
|
|
|
QVariant stringToVariant( const QString &value, QVariant::Type type )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
QVariant v;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( type == QVariant::Color )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
QStringList l = value.split( ',' );
|
|
|
|
|
|
|
|
if( l.size() != 3 )
|
|
|
|
|
|
|
|
v = "";
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
QColor c;
|
|
|
|
|
|
|
|
c.setRed( l[ 0 ].toInt() );
|
|
|
|
|
|
|
|
c.setGreen( l[ 1 ].toInt() );
|
|
|
|
|
|
|
|
c.setBlue( l[ 2 ].toInt() );
|
|
|
|
|
|
|
|
v = c;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
v = value;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return v;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// The inverse function of stringToVariant
|
|
|
|
|
|
|
|
// Unpacks the data from a QVariant properly
|
|
|
|
|
|
|
|
QString variantToString( const QVariant &value )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
QString v;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( value.type() == QVariant::Color )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
QColor c = value.value< QColor >();
|
|
|
|
|
|
|
|
v += QString::number( c.red() );
|
|
|
|
|
|
|
|
v += ',';
|
|
|
|
|
|
|
|
v += QString::number( c.green() );
|
|
|
|
|
|
|
|
v += ',';
|
|
|
|
|
|
|
|
v += QString::number( c.blue() );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
v = value.toString();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return v;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -61,6 +175,8 @@ QObject( parent )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mgr = new QtVariantPropertyManager();
|
|
|
|
mgr = new QtVariantPropertyManager();
|
|
|
|
factory = new QtVariantEditorFactory();
|
|
|
|
factory = new QtVariantEditorFactory();
|
|
|
|
|
|
|
|
m_fileMgr = new FileManager( this );
|
|
|
|
|
|
|
|
m_fileFactory = new FileEditFactory( this );
|
|
|
|
m_rootNode = NULL;
|
|
|
|
m_rootNode = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -70,30 +186,71 @@ BrowserCtrlPvt::~BrowserCtrlPvt()
|
|
|
|
mgr = NULL;
|
|
|
|
mgr = NULL;
|
|
|
|
delete factory;
|
|
|
|
delete factory;
|
|
|
|
factory = NULL;
|
|
|
|
factory = NULL;
|
|
|
|
|
|
|
|
m_fileMgr = NULL;
|
|
|
|
|
|
|
|
m_fileFactory = NULL;
|
|
|
|
m_browser = NULL;
|
|
|
|
m_browser = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BrowserCtrlPvt::setupAtom( NLGEORGES::CFormElmStruct::CFormElmStructElm &elm )
|
|
|
|
NLGEORGES::UFormElm* BrowserCtrlPvt::getNode( const QString &name )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
NLGEORGES::UFormElm *node = NULL;
|
|
|
|
|
|
|
|
m_rootNode->getNodeByName( &node, name.toUtf8().constData(), NULL, true );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return node;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NLGEORGES::UFormElm* BrowserCtrlPvt::getCurrentNode()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return getNode( m_currentNode.name );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void BrowserCtrlPvt::setupAtom( NLGEORGES::CFormElmStruct *st, int idx )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
NLGEORGES::CFormElmStruct::CFormElmStructElm &elm = st->Elements[ idx ];
|
|
|
|
|
|
|
|
if( ( elm.Element != NULL ) && !elm.Element->isAtom() )
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( elm.Element == NULL )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
NLGEORGES::CFormDfn::CEntry &entry = st->FormDfn->getEntry( idx );
|
|
|
|
|
|
|
|
if( entry.getArrayFlag() )
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( entry.getType() == NLGEORGES::UFormDfn::EntryVirtualDfn )
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QString key = elm.Name.c_str();
|
|
|
|
QString key = elm.Name.c_str();
|
|
|
|
QString value = "";
|
|
|
|
QString value = "";
|
|
|
|
QVariant::Type t = QVariant::String;
|
|
|
|
QVariant::Type t = QVariant::String;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// If the atom exists, get the value from it
|
|
|
|
|
|
|
|
// Otherwise just get the type so we can set up the proper editor
|
|
|
|
if( elm.Element != NULL )
|
|
|
|
if( elm.Element != NULL )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
// Check if there's a type, if not get it from the Dfn
|
|
|
|
|
|
|
|
const NLGEORGES::CType *type = elm.Element->getType();
|
|
|
|
|
|
|
|
if( type != NULL )
|
|
|
|
t = getValueType( elm.Element->getType() );
|
|
|
|
t = getValueType( elm.Element->getType() );
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
t = getValueTypeFromDfn( st, idx );
|
|
|
|
|
|
|
|
|
|
|
|
std::string formName;
|
|
|
|
std::string formName;
|
|
|
|
elm.Element->getFormName( formName, NULL );
|
|
|
|
elm.Element->getFormName( formName, NULL );
|
|
|
|
|
|
|
|
|
|
|
|
std::string v;
|
|
|
|
std::string v;
|
|
|
|
m_rootNode->getValueByName( v, formName.c_str(), NLGEORGES::UFormElm::NoEval, NULL, 0 );
|
|
|
|
m_rootNode->getValueByName( v, formName.c_str(), NLGEORGES::UFormElm::NoEval, NULL, 0 );
|
|
|
|
value = v.c_str();
|
|
|
|
value = stringToVariant( v.c_str(), t ).toString();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
t = getValueTypeFromDfn( st, idx );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QtVariantProperty *p = mgr->addProperty( t, key );
|
|
|
|
if( t == QVariant::Type( FILEBROWSER ) )
|
|
|
|
p->setValue( value );
|
|
|
|
addFileProperty( key, value );
|
|
|
|
m_browser->addProperty( p );
|
|
|
|
else
|
|
|
|
|
|
|
|
addVariantProperty( t, key, value );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BrowserCtrlPvt::setupStruct( NLGEORGES::UFormElm *node )
|
|
|
|
void BrowserCtrlPvt::setupStruct( NLGEORGES::UFormElm *node )
|
|
|
@ -102,18 +259,7 @@ void BrowserCtrlPvt::setupStruct( NLGEORGES::UFormElm *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 ];
|
|
|
|
setupAtom( st, i );
|
|
|
|
if( ( elm.Element != NULL ) && !elm.Element->isAtom() )
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( elm.Element == NULL )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
NLGEORGES::CFormDfn::CEntry &entry = st->FormDfn->getEntry( i );
|
|
|
|
|
|
|
|
if( entry.getArrayFlag() )
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setupAtom( elm );
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -123,9 +269,22 @@ void BrowserCtrlPvt::setupStruct( GeorgesQt::CFormItem *node )
|
|
|
|
if( n == NULL )
|
|
|
|
if( n == NULL )
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
m_currentNode.p = n;
|
|
|
|
setupStruct( n );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void BrowserCtrlPvt::setupVStruct( GeorgesQt::CFormItem *node )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
NLGEORGES::UFormElm *n = getGeorgesNode( node );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QtProperty *p = NULL;
|
|
|
|
|
|
|
|
p = addFileProperty( "Dfn filename", "" );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( n != NULL )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
NLGEORGES::CFormElmVirtualStruct *vs = static_cast< NLGEORGES::CFormElmVirtualStruct* >( n );
|
|
|
|
|
|
|
|
m_fileMgr->setValue( p, vs->DfnFilename.c_str() );
|
|
|
|
setupStruct( n );
|
|
|
|
setupStruct( n );
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BrowserCtrlPvt::setupArray( GeorgesQt::CFormItem *node )
|
|
|
|
void BrowserCtrlPvt::setupArray( GeorgesQt::CFormItem *node )
|
|
|
@ -137,28 +296,61 @@ void BrowserCtrlPvt::setupArray( GeorgesQt::CFormItem *node )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
NLGEORGES::CFormElmArray *arr = static_cast< NLGEORGES::CFormElmArray* >( n );
|
|
|
|
NLGEORGES::CFormElmArray *arr = static_cast< NLGEORGES::CFormElmArray* >( n );
|
|
|
|
arr->getArraySize( size );
|
|
|
|
arr->getArraySize( size );
|
|
|
|
m_currentNode.p = n;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QString key = QObject::tr( "Array size" );
|
|
|
|
QString key = QObject::tr( "Array size" );
|
|
|
|
QtVariantProperty *p = mgr->addProperty( QVariant::Int, key );
|
|
|
|
QtVariantProperty *p = addVariantProperty( QVariant::Int, key, size );
|
|
|
|
p->setValue( size );
|
|
|
|
}
|
|
|
|
m_browser->addProperty( p );
|
|
|
|
|
|
|
|
|
|
|
|
void BrowserCtrlPvt::setupAtom( GeorgesQt::CFormItem *node )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
NLGEORGES::UFormElm *n = getGeorgesNode( node );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( n == NULL )
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NLGEORGES::CFormElmAtom *atom = static_cast< NLGEORGES::CFormElmAtom* >( n );
|
|
|
|
|
|
|
|
std::string v = atom->getValue();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const NLGEORGES::CType *t = atom->getType();
|
|
|
|
|
|
|
|
QVariant::Type tt = QVariant::String;
|
|
|
|
|
|
|
|
if( t != NULL )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
tt = getValueType( t );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
tt = getValueTypeFromDfn( atom );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( tt == QVariant::Type( FILEBROWSER ) )
|
|
|
|
|
|
|
|
addFileProperty( "value", v.c_str() );
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
addVariantProperty( tt, "value", v.c_str() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BrowserCtrlPvt::setupNode( GeorgesQt::CFormItem *node )
|
|
|
|
void BrowserCtrlPvt::setupNode( GeorgesQt::CFormItem *node )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
m_currentNode.clear();
|
|
|
|
m_currentNode.clear();
|
|
|
|
m_currentNode.name = node->formName().c_str();
|
|
|
|
m_currentNode.name = node->formName().c_str();
|
|
|
|
|
|
|
|
m_currentNode.type = node->type();
|
|
|
|
|
|
|
|
|
|
|
|
m_rootNode = dynamic_cast< NLGEORGES::CFormElm* >( &(node->form()->getRootNode()) );
|
|
|
|
m_rootNode = dynamic_cast< NLGEORGES::CFormElm* >( &(node->form()->getRootNode()) );
|
|
|
|
|
|
|
|
|
|
|
|
if( node->isArray() )
|
|
|
|
if( node->isArray() )
|
|
|
|
setupArray( node );
|
|
|
|
setupArray( node );
|
|
|
|
else
|
|
|
|
else
|
|
|
|
|
|
|
|
if( node->isStruct() )
|
|
|
|
setupStruct( node );
|
|
|
|
setupStruct( node );
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
if( node->isVStruct() )
|
|
|
|
|
|
|
|
setupVStruct( node );
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
if( node->isAtom() )
|
|
|
|
|
|
|
|
setupAtom( node );
|
|
|
|
|
|
|
|
|
|
|
|
m_browser->setFactoryForManager( mgr, factory );
|
|
|
|
m_browser->setFactoryForManager( mgr, factory );
|
|
|
|
|
|
|
|
m_browser->setFactoryForManager( m_fileMgr, m_fileFactory );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BrowserCtrlPvt::clear()
|
|
|
|
void BrowserCtrlPvt::clear()
|
|
|
@ -171,10 +363,13 @@ void BrowserCtrlPvt::clear()
|
|
|
|
void BrowserCtrlPvt::onStructValueChanged( QtProperty *p, const QVariant &value )
|
|
|
|
void BrowserCtrlPvt::onStructValueChanged( QtProperty *p, const QVariant &value )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
std::string k = p->propertyName().toUtf8().constData();
|
|
|
|
std::string k = p->propertyName().toUtf8().constData();
|
|
|
|
std::string v = value.toString().toUtf8().constData();
|
|
|
|
std::string v;
|
|
|
|
|
|
|
|
v = variantToString( value ).toUtf8().constData();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NLGEORGES::UFormElm *node = getCurrentNode();
|
|
|
|
|
|
|
|
|
|
|
|
bool created = false;
|
|
|
|
bool created = false;
|
|
|
|
m_currentNode.p->setValueByName( v.c_str(), k.c_str(), &created );
|
|
|
|
node->setValueByName( v.c_str(), k.c_str(), &created );
|
|
|
|
|
|
|
|
|
|
|
|
QString key = m_currentNode.name + "." + p->propertyName();
|
|
|
|
QString key = m_currentNode.name + "." + p->propertyName();
|
|
|
|
|
|
|
|
|
|
|
@ -182,8 +377,17 @@ void BrowserCtrlPvt::onStructValueChanged( QtProperty *p, const QVariant &value
|
|
|
|
Q_EMIT valueChanged( key, value.toString() );
|
|
|
|
Q_EMIT valueChanged( key, value.toString() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BrowserCtrlPvt::createArray()
|
|
|
|
void BrowserCtrlPvt::onVStructValueChanged( QtProperty *p, const QVariant &value )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
if( p->propertyName() != "Dfn filename" )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
onStructValueChanged( p, value );
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NLGEORGES::CFormElmVirtualStruct *vs = static_cast< NLGEORGES::CFormElmVirtualStruct* >( getCurrentNode() );
|
|
|
|
|
|
|
|
if( vs == NULL )
|
|
|
|
|
|
|
|
{
|
|
|
|
const NLGEORGES::CFormDfn *parentDfn;
|
|
|
|
const NLGEORGES::CFormDfn *parentDfn;
|
|
|
|
const NLGEORGES::CFormDfn *nodeDfn;
|
|
|
|
const NLGEORGES::CFormDfn *nodeDfn;
|
|
|
|
uint indexDfn;
|
|
|
|
uint indexDfn;
|
|
|
@ -198,7 +402,33 @@ void BrowserCtrlPvt::createArray()
|
|
|
|
if( !created )
|
|
|
|
if( !created )
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
m_currentNode.p = node;
|
|
|
|
vs = static_cast< NLGEORGES::CFormElmVirtualStruct* >( node );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vs->DfnFilename = value.toString().toUtf8().constData();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QString key = m_currentNode.name + "." + p->propertyName();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Q_EMIT modified();
|
|
|
|
|
|
|
|
Q_EMIT valueChanged( key, value.toString() );
|
|
|
|
|
|
|
|
Q_EMIT vstructChanged( m_currentNode.name );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void BrowserCtrlPvt::createArray()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
const NLGEORGES::CFormDfn *parentDfn;
|
|
|
|
|
|
|
|
const NLGEORGES::CFormDfn *nodeDfn;
|
|
|
|
|
|
|
|
uint indexDfn;
|
|
|
|
|
|
|
|
const NLGEORGES::CType *type;
|
|
|
|
|
|
|
|
NLGEORGES::UFormDfn::TEntryType entryType;
|
|
|
|
|
|
|
|
NLGEORGES::CFormElm *node;
|
|
|
|
|
|
|
|
bool created;
|
|
|
|
|
|
|
|
bool isArray;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m_rootNode->createNodeByName( m_currentNode.name.toUtf8().constData(), &parentDfn, indexDfn, &nodeDfn, &type, &node, entryType, isArray, created );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( !created )
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
NLGEORGES::CFormElmArray *arr = dynamic_cast< NLGEORGES::CFormElmArray* >( node );
|
|
|
|
NLGEORGES::CFormElmArray *arr = dynamic_cast< NLGEORGES::CFormElmArray* >( node );
|
|
|
|
QString idx = "[0]";
|
|
|
|
QString idx = "[0]";
|
|
|
@ -219,7 +449,10 @@ void BrowserCtrlPvt::onArrayValueChanged( QtProperty *p, const QVariant &value )
|
|
|
|
if( newSize < 0 )
|
|
|
|
if( newSize < 0 )
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
if( m_currentNode.p == NULL )
|
|
|
|
|
|
|
|
|
|
|
|
NLGEORGES::UFormElm *node = getCurrentNode();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( node == NULL )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if( newSize != 1 )
|
|
|
|
if( newSize != 1 )
|
|
|
|
return;
|
|
|
|
return;
|
|
|
@ -227,7 +460,7 @@ void BrowserCtrlPvt::onArrayValueChanged( QtProperty *p, const QVariant &value )
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NLGEORGES::CFormElmArray *arr = static_cast< NLGEORGES::CFormElmArray* >( m_currentNode.p );
|
|
|
|
NLGEORGES::CFormElmArray *arr = static_cast< NLGEORGES::CFormElmArray* >( node );
|
|
|
|
std::string formName;
|
|
|
|
std::string formName;
|
|
|
|
arr->getFormName( formName, NULL );
|
|
|
|
arr->getFormName( formName, NULL );
|
|
|
|
|
|
|
|
|
|
|
@ -276,27 +509,87 @@ void BrowserCtrlPvt::onArrayValueChanged( QtProperty *p, const QVariant &value )
|
|
|
|
QString name = formName.c_str();
|
|
|
|
QString name = formName.c_str();
|
|
|
|
Q_EMIT arrayResized( name, newSize );
|
|
|
|
Q_EMIT arrayResized( name, newSize );
|
|
|
|
Q_EMIT modified();
|
|
|
|
Q_EMIT modified();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if( newSize == 0 )
|
|
|
|
void BrowserCtrlPvt::onAtomValueChanged( QtProperty *p, const QVariant &value )
|
|
|
|
m_currentNode.p = NULL;
|
|
|
|
{
|
|
|
|
|
|
|
|
NLGEORGES::CFormElmAtom *atom = static_cast< NLGEORGES::CFormElmAtom* >( getCurrentNode() );
|
|
|
|
|
|
|
|
atom->setValue( value.toString().toUtf8() );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Q_EMIT modified();
|
|
|
|
|
|
|
|
Q_EMIT valueChanged( m_currentNode.name, value.toString() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BrowserCtrlPvt::onValueChanged( QtProperty *p, const QVariant &value )
|
|
|
|
void BrowserCtrlPvt::onValueChanged( QtProperty *p, const QVariant &value )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if( m_currentNode.p == NULL )
|
|
|
|
if( m_currentNode.type == GeorgesQt::CFormItem::TYPE_VSTRUCT )
|
|
|
|
{
|
|
|
|
onVStructValueChanged( p, value );
|
|
|
|
if( m_currentNode.name.isEmpty() )
|
|
|
|
else
|
|
|
|
return;
|
|
|
|
if( m_currentNode.type == GeorgesQt::CFormItem::TYPE_STRUCT )
|
|
|
|
|
|
|
|
onStructValueChanged( p, value );
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
if( m_currentNode.type == GeorgesQt::CFormItem::TYPE_ARRAY )
|
|
|
|
onArrayValueChanged( p, value );
|
|
|
|
onArrayValueChanged( p, value );
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
if( m_currentNode.type == GeorgesQt::CFormItem::TYPE_ATOM )
|
|
|
|
|
|
|
|
onAtomValueChanged( p, value );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void BrowserCtrlPvt::onFileValueChanged( QtProperty *p, const QString &value )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
QString v = value;
|
|
|
|
|
|
|
|
QFileInfo info( value );
|
|
|
|
|
|
|
|
if( !info.exists() )
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( m_currentNode.p->isStruct() )
|
|
|
|
v = info.fileName();
|
|
|
|
onStructValueChanged( p, value );
|
|
|
|
blockSignals( true );
|
|
|
|
|
|
|
|
m_fileMgr->setValue( p, v );
|
|
|
|
|
|
|
|
blockSignals( false );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( m_currentNode.type == GeorgesQt::CFormItem::TYPE_VSTRUCT )
|
|
|
|
|
|
|
|
onVStructValueChanged( p, v );
|
|
|
|
else
|
|
|
|
else
|
|
|
|
if( m_currentNode.p->isArray() )
|
|
|
|
if( m_currentNode.type == GeorgesQt::CFormItem::TYPE_STRUCT )
|
|
|
|
onArrayValueChanged( p, value );
|
|
|
|
onStructValueChanged( p, v );
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
if( m_currentNode.type == GeorgesQt::CFormItem::TYPE_ATOM )
|
|
|
|
|
|
|
|
onAtomValueChanged( p, v );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QtVariantProperty* BrowserCtrlPvt::addVariantProperty( QVariant::Type type, const QString &key, const QVariant &value )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
QtVariantProperty *p = mgr->addProperty( type, key );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Remove the color sub-properties, so they don't get triggered on value change
|
|
|
|
|
|
|
|
if( type == QVariant::Color )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
QList< QtProperty* > sp = p->subProperties();
|
|
|
|
|
|
|
|
QListIterator< QtProperty* > itr( sp );
|
|
|
|
|
|
|
|
while( itr.hasNext() )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
QtProperty *prop = itr.next();
|
|
|
|
|
|
|
|
p->removeSubProperty( prop );
|
|
|
|
|
|
|
|
delete prop;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
sp.clear();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
p->setValue( value );
|
|
|
|
|
|
|
|
m_browser->addProperty( p );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return p;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QtProperty* BrowserCtrlPvt::addFileProperty( const QString &key, const QString &value )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
QtProperty *p = m_fileMgr->addProperty( key );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m_fileMgr->setValue( p, value );
|
|
|
|
|
|
|
|
m_browser->addProperty( p );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return p;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|