mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-10 17:29:10 +00:00
Added support for adding atoms and virtual structs in the treeview.
This commit is contained in:
parent
4483b0301f
commit
dab557b6c9
5 changed files with 72 additions and 12 deletions
|
@ -146,6 +146,7 @@ void BrowserCtrlPvt::setupArray( GeorgesQt::CFormItem *node )
|
||||||
m_browser->addProperty( p );
|
m_browser->addProperty( p );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BrowserCtrlPvt::setupNode( GeorgesQt::CFormItem *node )
|
void BrowserCtrlPvt::setupNode( GeorgesQt::CFormItem *node )
|
||||||
{
|
{
|
||||||
m_currentNode.clear();
|
m_currentNode.clear();
|
||||||
|
@ -156,6 +157,7 @@ void BrowserCtrlPvt::setupNode( GeorgesQt::CFormItem *node )
|
||||||
if( node->isArray() )
|
if( node->isArray() )
|
||||||
setupArray( node );
|
setupArray( node );
|
||||||
else
|
else
|
||||||
|
if( node->isStruct() )
|
||||||
setupStruct( node );
|
setupStruct( node );
|
||||||
|
|
||||||
m_browser->setFactoryForManager( mgr, factory );
|
m_browser->setFactoryForManager( mgr, factory );
|
||||||
|
|
|
@ -40,7 +40,7 @@ namespace GeorgesQt
|
||||||
_StructId = 0;
|
_StructId = 0;
|
||||||
_Slot = 0;
|
_Slot = 0;
|
||||||
_Type = Null;
|
_Type = Null;
|
||||||
_Array = false;
|
_TType = TYPE_ATOM;
|
||||||
}
|
}
|
||||||
|
|
||||||
CFormItem::~CFormItem()
|
CFormItem::~CFormItem()
|
||||||
|
@ -113,7 +113,10 @@ namespace GeorgesQt
|
||||||
|
|
||||||
bool CFormItem::isArray()
|
bool CFormItem::isArray()
|
||||||
{
|
{
|
||||||
return _Array;
|
if( _TType == TYPE_ARRAY )
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CFormItem::isArrayMember()
|
bool CFormItem::isArrayMember()
|
||||||
|
@ -124,6 +127,30 @@ namespace GeorgesQt
|
||||||
return parentItem->isArray();
|
return parentItem->isArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CFormItem::isStruct()
|
||||||
|
{
|
||||||
|
if( _TType == TYPE_STRUCT )
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CFormItem::isVStruct()
|
||||||
|
{
|
||||||
|
if( _TType == TYPE_VSTRUCT )
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CFormItem::isAtom()
|
||||||
|
{
|
||||||
|
if( _TType == TYPE_ATOM )
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
QIcon CFormItem::getItemImage(CFormItem *rootItem)
|
QIcon CFormItem::getItemImage(CFormItem *rootItem)
|
||||||
{
|
{
|
||||||
if(_Type == CFormItem::Null)
|
if(_Type == CFormItem::Null)
|
||||||
|
@ -211,7 +238,7 @@ namespace GeorgesQt
|
||||||
childItems.clear();
|
childItems.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
CFormItem *CFormItem::add (TSub type, const char *name, uint structId, const char *formName, uint slot, NLGEORGES::UForm *formPtr, bool isArray)
|
CFormItem *CFormItem::add (TSub type, const char *name, uint structId, const char *formName, uint slot, NLGEORGES::UForm *formPtr, TType itemType )
|
||||||
{
|
{
|
||||||
CFormItem *newNode = new CFormItem();
|
CFormItem *newNode = new CFormItem();
|
||||||
newNode->_Type = type;
|
newNode->_Type = type;
|
||||||
|
@ -221,7 +248,7 @@ namespace GeorgesQt
|
||||||
newNode->_FormName = formName;
|
newNode->_FormName = formName;
|
||||||
newNode->_Slot = slot;
|
newNode->_Slot = slot;
|
||||||
newNode->m_form = formPtr;
|
newNode->m_form = formPtr;
|
||||||
newNode->_Array = isArray;
|
newNode->_TType = itemType;
|
||||||
|
|
||||||
appendChild(newNode);
|
appendChild(newNode);
|
||||||
return newNode;
|
return newNode;
|
||||||
|
|
|
@ -41,12 +41,20 @@ namespace GeorgesQt
|
||||||
Form, // This node is a form
|
Form, // This node is a form
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum TType
|
||||||
|
{
|
||||||
|
TYPE_ARRAY,
|
||||||
|
TYPE_STRUCT,
|
||||||
|
TYPE_VSTRUCT,
|
||||||
|
TYPE_ATOM
|
||||||
|
};
|
||||||
|
|
||||||
CFormItem();
|
CFormItem();
|
||||||
~CFormItem();
|
~CFormItem();
|
||||||
|
|
||||||
void appendChild(CFormItem *child);
|
void appendChild(CFormItem *child);
|
||||||
|
|
||||||
CFormItem *add (TSub type, const char *name, uint structId, const char *formName, uint slot, NLGEORGES::UForm *formPtr, bool isArray );
|
CFormItem *add (TSub type, const char *name, uint structId, const char *formName, uint slot, NLGEORGES::UForm *formPtr, TType itemType );
|
||||||
|
|
||||||
CFormItem *child(int row);
|
CFormItem *child(int row);
|
||||||
int childCount() const;
|
int childCount() const;
|
||||||
|
@ -69,6 +77,9 @@ namespace GeorgesQt
|
||||||
bool isEditable(int column);
|
bool isEditable(int column);
|
||||||
bool isArray();
|
bool isArray();
|
||||||
bool isArrayMember();
|
bool isArrayMember();
|
||||||
|
bool isStruct();
|
||||||
|
bool isVStruct();
|
||||||
|
bool isAtom();
|
||||||
|
|
||||||
QIcon getItemImage(CFormItem *rootItem);
|
QIcon getItemImage(CFormItem *rootItem);
|
||||||
|
|
||||||
|
@ -95,7 +106,7 @@ namespace GeorgesQt
|
||||||
std::string _FormName;
|
std::string _FormName;
|
||||||
TSub _Type;
|
TSub _Type;
|
||||||
uint _Slot;
|
uint _Slot;
|
||||||
bool _Array;
|
TType _TType;
|
||||||
|
|
||||||
}; // CFormItem
|
}; // CFormItem
|
||||||
|
|
||||||
|
|
|
@ -277,13 +277,20 @@ namespace GeorgesQt
|
||||||
const char *name,
|
const char *name,
|
||||||
uint structId,
|
uint structId,
|
||||||
const char *formName,
|
const char *formName,
|
||||||
uint slot)
|
uint slot,
|
||||||
|
bool isVirtual)
|
||||||
{
|
{
|
||||||
// The form pointer
|
// The form pointer
|
||||||
NLGEORGES::CForm *formPtr = static_cast<NLGEORGES::CForm*>(m_form);
|
NLGEORGES::CForm *formPtr = static_cast<NLGEORGES::CForm*>(m_form);
|
||||||
|
|
||||||
// Add the new node
|
// Add the new node
|
||||||
CFormItem *newNode = parent->add(CFormItem::Form, name, structId, formName, slot, m_form, false);
|
CFormItem::TType ttype;
|
||||||
|
if( isVirtual )
|
||||||
|
ttype = CFormItem::TYPE_VSTRUCT;
|
||||||
|
else
|
||||||
|
ttype = CFormItem::TYPE_STRUCT;
|
||||||
|
|
||||||
|
CFormItem *newNode = parent->add(CFormItem::Form, name, structId, formName, slot, m_form, ttype );
|
||||||
|
|
||||||
// Can be NULL in virtual DFN
|
// Can be NULL in virtual DFN
|
||||||
if (parentDfn)
|
if (parentDfn)
|
||||||
|
@ -367,7 +374,10 @@ namespace GeorgesQt
|
||||||
NLGEORGES::CFormDfn *tmpDfn = vStruct ?
|
NLGEORGES::CFormDfn *tmpDfn = vStruct ?
|
||||||
((NLGEORGES::CFormDfn*)vStruct->FormDfn) : entry.getDfnPtr();
|
((NLGEORGES::CFormDfn*)vStruct->FormDfn) : entry.getDfnPtr();
|
||||||
// Add the new struct
|
// Add the new struct
|
||||||
addStruct (newNode, nextForm, tmpDfn, entry.getName().c_str(), elm, entryName.c_str(), slot);
|
if( entry.getType() == NLGEORGES::UFormDfn::EntryVirtualDfn )
|
||||||
|
addStruct (newNode, nextForm, tmpDfn, entry.getName().c_str(), elm, entryName.c_str(), slot, true);
|
||||||
|
else
|
||||||
|
addStruct (newNode, nextForm, tmpDfn, entry.getName().c_str(), elm, entryName.c_str(), slot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Array of type ?
|
// Array of type ?
|
||||||
|
@ -418,7 +428,7 @@ CFormItem *CGeorgesFormModel::addArray(CFormItem *parent,
|
||||||
uint slot)
|
uint slot)
|
||||||
{
|
{
|
||||||
// Add the new node
|
// Add the new node
|
||||||
CFormItem *newNode = parent->add (CFormItem::Form, name, structId, formName, slot, m_form, true);
|
CFormItem *newNode = parent->add (CFormItem::Form, name, structId, formName, slot, m_form, CFormItem::TYPE_ARRAY );
|
||||||
|
|
||||||
// The array exist
|
// The array exist
|
||||||
if (array)
|
if (array)
|
||||||
|
@ -451,7 +461,7 @@ CFormItem *CGeorgesFormModel::addArray(CFormItem *parent,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NLGEORGES::CFormElmArray *elmPtr = array->Elements[elm].Element ? static_cast<NLGEORGES::CFormElmArray*>(array->Elements[elm].Element) : NULL;
|
NLGEORGES::CFormElmArray *elmPtr = array->Elements[elm].Element ? static_cast<NLGEORGES::CFormElmArray*>(array->Elements[elm].Element) : NULL;
|
||||||
newNode->add (CFormItem::Form, formArrayName, elm, formArrayElmName, slot, m_form, false);
|
addAtom( newNode, elmPtr, rootDfn, formArrayName, elm, formArrayElmName );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -460,6 +470,14 @@ CFormItem *CGeorgesFormModel::addArray(CFormItem *parent,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
CFormItem *CGeorgesFormModel::addAtom(CFormItem *parent, NLGEORGES::CFormElm *elm, NLGEORGES::CFormDfn *dfn, const char *name, uint id, const char *formName)
|
||||||
|
{
|
||||||
|
CFormItem *item = parent->add( CFormItem::Form, name, id, formName, 0, m_form, CFormItem::TYPE_ATOM );
|
||||||
|
|
||||||
|
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 );
|
||||||
|
|
|
@ -65,11 +65,13 @@ namespace GeorgesQt
|
||||||
NLGEORGES::UFormElm *getRootForm() { return m_rootElm; }
|
NLGEORGES::UFormElm *getRootForm() { return m_rootElm; }
|
||||||
|
|
||||||
CFormItem *addStruct (CFormItem *parent, NLGEORGES::CFormElmStruct *_struct, NLGEORGES::CFormDfn *parentDfn,
|
CFormItem *addStruct (CFormItem *parent, NLGEORGES::CFormElmStruct *_struct, NLGEORGES::CFormDfn *parentDfn,
|
||||||
const char *name, uint structId, const char *formName, uint slot);
|
const char *name, uint structId, const char *formName, uint slot, bool isVirtual = false );
|
||||||
|
|
||||||
CFormItem *addArray(CFormItem *parent, NLGEORGES::CFormElmArray *array, NLGEORGES::CFormDfn *rootDfn,
|
CFormItem *addArray(CFormItem *parent, NLGEORGES::CFormElmArray *array, NLGEORGES::CFormDfn *rootDfn,
|
||||||
const char *name, uint structId, const char *formName, uint slot);
|
const char *name, uint structId, const char *formName, uint slot);
|
||||||
|
|
||||||
|
CFormItem *addAtom(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);
|
||||||
|
|
Loading…
Reference in a new issue