mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-27 09:16:18 +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 );
|
||||
}
|
||||
|
||||
|
||||
void BrowserCtrlPvt::setupNode( GeorgesQt::CFormItem *node )
|
||||
{
|
||||
m_currentNode.clear();
|
||||
|
@ -156,6 +157,7 @@ void BrowserCtrlPvt::setupNode( GeorgesQt::CFormItem *node )
|
|||
if( node->isArray() )
|
||||
setupArray( node );
|
||||
else
|
||||
if( node->isStruct() )
|
||||
setupStruct( node );
|
||||
|
||||
m_browser->setFactoryForManager( mgr, factory );
|
||||
|
|
|
@ -40,7 +40,7 @@ namespace GeorgesQt
|
|||
_StructId = 0;
|
||||
_Slot = 0;
|
||||
_Type = Null;
|
||||
_Array = false;
|
||||
_TType = TYPE_ATOM;
|
||||
}
|
||||
|
||||
CFormItem::~CFormItem()
|
||||
|
@ -113,7 +113,10 @@ namespace GeorgesQt
|
|||
|
||||
bool CFormItem::isArray()
|
||||
{
|
||||
return _Array;
|
||||
if( _TType == TYPE_ARRAY )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CFormItem::isArrayMember()
|
||||
|
@ -124,6 +127,30 @@ namespace GeorgesQt
|
|||
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)
|
||||
{
|
||||
if(_Type == CFormItem::Null)
|
||||
|
@ -211,7 +238,7 @@ namespace GeorgesQt
|
|||
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();
|
||||
newNode->_Type = type;
|
||||
|
@ -221,7 +248,7 @@ namespace GeorgesQt
|
|||
newNode->_FormName = formName;
|
||||
newNode->_Slot = slot;
|
||||
newNode->m_form = formPtr;
|
||||
newNode->_Array = isArray;
|
||||
newNode->_TType = itemType;
|
||||
|
||||
appendChild(newNode);
|
||||
return newNode;
|
||||
|
|
|
@ -41,12 +41,20 @@ namespace GeorgesQt
|
|||
Form, // This node is a form
|
||||
};
|
||||
|
||||
enum TType
|
||||
{
|
||||
TYPE_ARRAY,
|
||||
TYPE_STRUCT,
|
||||
TYPE_VSTRUCT,
|
||||
TYPE_ATOM
|
||||
};
|
||||
|
||||
CFormItem();
|
||||
~CFormItem();
|
||||
|
||||
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);
|
||||
int childCount() const;
|
||||
|
@ -69,6 +77,9 @@ namespace GeorgesQt
|
|||
bool isEditable(int column);
|
||||
bool isArray();
|
||||
bool isArrayMember();
|
||||
bool isStruct();
|
||||
bool isVStruct();
|
||||
bool isAtom();
|
||||
|
||||
QIcon getItemImage(CFormItem *rootItem);
|
||||
|
||||
|
@ -95,7 +106,7 @@ namespace GeorgesQt
|
|||
std::string _FormName;
|
||||
TSub _Type;
|
||||
uint _Slot;
|
||||
bool _Array;
|
||||
TType _TType;
|
||||
|
||||
}; // CFormItem
|
||||
|
||||
|
|
|
@ -277,13 +277,20 @@ namespace GeorgesQt
|
|||
const char *name,
|
||||
uint structId,
|
||||
const char *formName,
|
||||
uint slot)
|
||||
uint slot,
|
||||
bool isVirtual)
|
||||
{
|
||||
// The form pointer
|
||||
NLGEORGES::CForm *formPtr = static_cast<NLGEORGES::CForm*>(m_form);
|
||||
|
||||
// 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
|
||||
if (parentDfn)
|
||||
|
@ -367,6 +374,9 @@ namespace GeorgesQt
|
|||
NLGEORGES::CFormDfn *tmpDfn = vStruct ?
|
||||
((NLGEORGES::CFormDfn*)vStruct->FormDfn) : entry.getDfnPtr();
|
||||
// Add the new struct
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -418,7 +428,7 @@ CFormItem *CGeorgesFormModel::addArray(CFormItem *parent,
|
|||
uint slot)
|
||||
{
|
||||
// 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
|
||||
if (array)
|
||||
|
@ -451,7 +461,7 @@ CFormItem *CGeorgesFormModel::addArray(CFormItem *parent,
|
|||
else
|
||||
{
|
||||
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 )
|
||||
{
|
||||
CFormItem *item = m_rootItem->findItem( name );
|
||||
|
|
|
@ -65,11 +65,13 @@ namespace GeorgesQt
|
|||
NLGEORGES::UFormElm *getRootForm() { return m_rootElm; }
|
||||
|
||||
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,
|
||||
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)
|
||||
{
|
||||
Q_EMIT dataChanged(index, index);
|
||||
|
|
Loading…
Reference in a new issue