Appending, resizing arrays, deleting array members should now create the proper new nodes.

This commit is contained in:
dfighter1985 2014-09-05 19:41:51 +02:00
parent dab557b6c9
commit 2019691cd0
2 changed files with 37 additions and 6 deletions

View file

@ -478,6 +478,31 @@ CFormItem *CGeorgesFormModel::addAtom(CFormItem *parent, NLGEORGES::CFormElm *el
} }
CFormItem *CGeorgesFormModel::addItem(CFormItem *parent, NLGEORGES::CFormElm *elm, NLGEORGES::CFormDfn *dfn, const char *name, uint id, const char *formName)
{
CFormItem *item = NULL;
if( elm->isAtom() )
item = addAtom(parent, elm, dfn, name, id, formName );
else
if( elm->isStruct() || elm->isVirtualStruct() )
{
NLGEORGES::CFormElmStruct *st = static_cast< NLGEORGES::CFormElmStruct* >( elm );
if( st->isVirtualStruct() )
item = addStruct(parent, st, st->FormDfn, name, id, formName, 0, true);
else
item = addStruct(parent, st, st->FormDfn, name, id, formName, 0, false);
}
else
if( elm->isArray() )
{
NLGEORGES::CFormElmArray *arr = static_cast< NLGEORGES::CFormElmArray* >( elm );
item = addArray(parent, arr, arr->FormDfn, name, id, formName, 0 );
}
return item;
}
void CGeorgesFormModel::arrayResized( const QString &name, int size ) void CGeorgesFormModel::arrayResized( const QString &name, int size )
{ {
CFormItem *item = m_rootItem->findItem( name ); CFormItem *item = m_rootItem->findItem( name );
@ -512,8 +537,9 @@ void CGeorgesFormModel::arrayResized( const QString &name, int size )
else else
n = e.Name.c_str(); n = e.Name.c_str();
NLGEORGES::CFormElmStruct *s = static_cast< NLGEORGES::CFormElmStruct* >( e.Element ); NLGEORGES::UFormDfn *udfn = e.Element->getStructDfn();
addStruct( item, s, s->FormDfn, n.toUtf8().constData(), i, formName.toUtf8().constData(), 0 ); NLGEORGES::CFormDfn *cdfn = static_cast< NLGEORGES::CFormDfn* >( udfn );
addItem( item, e.Element, cdfn, n.toUtf8().constData(), i, formName.toUtf8().constData() );
} }
if( celm->Elements.size() == 0 ) if( celm->Elements.size() == 0 )
@ -585,8 +611,8 @@ void CGeorgesFormModel::appendArray( QModelIndex idx )
std::string formName; std::string formName;
node->getFormName( formName ); node->getFormName( formName );
NLGEORGES::CFormElmStruct *st = static_cast< NLGEORGES::CFormElmStruct* >( node ); NLGEORGES::CFormDfn *cdfn = const_cast< NLGEORGES::CFormDfn* >( nodeDfn );
addStruct( item, st, st->FormDfn, name.c_str(), s, formName.c_str(), 0 ); addItem( item, node, cdfn, name.c_str(), s, formName.c_str() );
} }
void CGeorgesFormModel::deleteArrayEntry( QModelIndex idx ) void CGeorgesFormModel::deleteArrayEntry( QModelIndex idx )
@ -628,8 +654,11 @@ void CGeorgesFormModel::deleteArrayEntry( QModelIndex idx )
else else
n = e.Name.c_str(); n = e.Name.c_str();
NLGEORGES::CFormElmStruct *st = static_cast< NLGEORGES::CFormElmStruct* >( e.Element ); NLGEORGES::UFormDfn *udfn = e.Element->getStructDfn();
addStruct( item, st, st->FormDfn, n.toUtf8().constData(), i, formName.toUtf8().constData(), 0 ); NLGEORGES::CFormDfn *cdfn = static_cast< NLGEORGES::CFormDfn* >( udfn );
addItem( item, e.Element, cdfn, n.toUtf8().constData(), i, formName.toUtf8().constData() );
//NLGEORGES::CFormElmStruct *st = static_cast< NLGEORGES::CFormElmStruct* >( e.Element );
//addStruct( item, st, st->FormDfn, n.toUtf8().constData(), i, formName.toUtf8().constData(), 0 );
} }
Q_EMIT endResetModel(); Q_EMIT endResetModel();

View file

@ -72,6 +72,8 @@ namespace GeorgesQt
CFormItem *addAtom(CFormItem *parent, NLGEORGES::CFormElm *elm, NLGEORGES::CFormDfn *dfn, const char *name, uint id, const char *formName); CFormItem *addAtom(CFormItem *parent, NLGEORGES::CFormElm *elm, NLGEORGES::CFormDfn *dfn, const char *name, uint id, const char *formName);
CFormItem *addItem(CFormItem *parent, NLGEORGES::CFormElm *elm, NLGEORGES::CFormDfn *dfn, const char *name, uint id, const char *formName);
void emitDataChanged(const QModelIndex &index) void emitDataChanged(const QModelIndex &index)
{ {
Q_EMIT dataChanged(index, index); Q_EMIT dataChanged(index, index);