mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-23 07:16:15 +00:00
Added support for Virtual Structs.
This commit is contained in:
parent
15f6ed3c37
commit
df02d7f7f1
10 changed files with 117 additions and 0 deletions
|
@ -37,6 +37,7 @@ QObject( browser )
|
|||
connect( m_pvt, SIGNAL( arrayResized( const QString&, int ) ), this, SLOT( onArrayResized( const QString&, int ) ) );
|
||||
connect( m_pvt, SIGNAL( modified() ), this, SLOT( onModified() ) );
|
||||
connect( m_pvt, SIGNAL( valueChanged( const QString&, const QString& ) ), this, SLOT( onValueChanged( const QString&, const QString& ) ) );
|
||||
connect( m_pvt, SIGNAL( vstructChanged( const QString& ) ), this, SLOT( onVStructChanged( const QString& ) ) );
|
||||
}
|
||||
|
||||
BrowserCtrl::~BrowserCtrl()
|
||||
|
@ -78,6 +79,11 @@ void BrowserCtrl::onModified()
|
|||
Q_EMIT modified();
|
||||
}
|
||||
|
||||
void BrowserCtrl::onVStructChanged( const QString &name )
|
||||
{
|
||||
Q_EMIT vstructChanged( name );
|
||||
}
|
||||
|
||||
void BrowserCtrl::enableMgrConnections()
|
||||
{
|
||||
QtVariantPropertyManager *mgr = m_pvt->manager();
|
||||
|
|
|
@ -48,12 +48,14 @@ Q_SIGNALS:
|
|||
void arrayResized( const QString &name, int size );
|
||||
void modified();
|
||||
void valueChanged( const QString &key, const QString &value );
|
||||
void vstructChanged( const QString &name );
|
||||
|
||||
private Q_SLOTS:
|
||||
void onValueChanged( QtProperty *p, const QVariant &value );
|
||||
void onValueChanged( const QString &key, const QString &value );
|
||||
void onArrayResized( const QString &name, int size );
|
||||
void onModified();
|
||||
void onVStructChanged( const QString &name );
|
||||
|
||||
private:
|
||||
void enableMgrConnections();
|
||||
|
|
|
@ -180,6 +180,23 @@ void BrowserCtrlPvt::setupStruct( GeorgesQt::CFormItem *node )
|
|||
setupStruct( n );
|
||||
}
|
||||
|
||||
void BrowserCtrlPvt::setupVStruct( GeorgesQt::CFormItem *node )
|
||||
{
|
||||
NLGEORGES::UFormElm *n = getGeorgesNode( node );
|
||||
if( n == NULL )
|
||||
return;
|
||||
|
||||
m_currentNode.p = n;
|
||||
|
||||
NLGEORGES::CFormElmVirtualStruct *vs = static_cast< NLGEORGES::CFormElmVirtualStruct* >( n );
|
||||
|
||||
QtVariantProperty *p = mgr->addProperty( QVariant::String, "Dfn filename" );
|
||||
mgr->setValue( p, vs->DfnFilename.c_str() );
|
||||
m_browser->addProperty( p );
|
||||
|
||||
setupStruct( n );
|
||||
}
|
||||
|
||||
void BrowserCtrlPvt::setupArray( GeorgesQt::CFormItem *node )
|
||||
{
|
||||
NLGEORGES::UFormElm *n = getGeorgesNode( node );
|
||||
|
@ -239,6 +256,9 @@ void BrowserCtrlPvt::setupNode( GeorgesQt::CFormItem *node )
|
|||
if( node->isStruct() )
|
||||
setupStruct( node );
|
||||
else
|
||||
if( node->isVStruct() )
|
||||
setupVStruct( node );
|
||||
else
|
||||
if( node->isAtom() )
|
||||
setupAtom( node );
|
||||
|
||||
|
@ -266,6 +286,24 @@ void BrowserCtrlPvt::onStructValueChanged( QtProperty *p, const QVariant &value
|
|||
Q_EMIT valueChanged( key, value.toString() );
|
||||
}
|
||||
|
||||
void BrowserCtrlPvt::onVStructValueChanged( QtProperty *p, const QVariant &value )
|
||||
{
|
||||
if( p->propertyName() != "Dfn filename" )
|
||||
{
|
||||
onStructValueChanged( p, value );
|
||||
return;
|
||||
}
|
||||
|
||||
NLGEORGES::CFormElmVirtualStruct *vs = static_cast< NLGEORGES::CFormElmVirtualStruct* >( m_currentNode.p );
|
||||
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;
|
||||
|
@ -385,6 +423,9 @@ void BrowserCtrlPvt::onValueChanged( QtProperty *p, const QVariant &value )
|
|||
return;
|
||||
}
|
||||
|
||||
if( m_currentNode.p->isVirtualStruct() )
|
||||
onVStructValueChanged( p, value );
|
||||
else
|
||||
if( m_currentNode.p->isStruct() )
|
||||
onStructValueChanged( p, value );
|
||||
else
|
||||
|
|
|
@ -58,16 +58,19 @@ Q_SIGNALS:
|
|||
void arrayResized( const QString &name, int size );
|
||||
void modified();
|
||||
void valueChanged( const QString &key, const QString &value );
|
||||
void vstructChanged( const QString &name );
|
||||
|
||||
private:
|
||||
void setupStruct( NLGEORGES::UFormElm *node );
|
||||
void setupAtom( NLGEORGES::CFormElmStruct *st, int idx );
|
||||
|
||||
void setupStruct( GeorgesQt::CFormItem *node );
|
||||
void setupVStruct( GeorgesQt::CFormItem *node );
|
||||
void setupArray( GeorgesQt::CFormItem *node );
|
||||
void setupAtom( GeorgesQt::CFormItem *node );
|
||||
|
||||
void onStructValueChanged( QtProperty *p, const QVariant &value );
|
||||
void onVStructValueChanged( QtProperty *p, const QVariant &value );
|
||||
void onArrayValueChanged( QtProperty *p, const QVariant &value );
|
||||
void onAtomValueChanged( QtProperty *p, const QVariant &value );
|
||||
void createArray();
|
||||
|
|
|
@ -238,6 +238,13 @@ namespace GeorgesQt
|
|||
childItems.clear();
|
||||
}
|
||||
|
||||
void CFormItem::removeChild( int idx )
|
||||
{
|
||||
CFormItem *item = childItems[ idx ];
|
||||
childItems.removeAt( idx );
|
||||
delete item;
|
||||
}
|
||||
|
||||
CFormItem *CFormItem::add (TSub type, const char *name, uint structId, const char *formName, uint slot, NLGEORGES::UForm *formPtr, TType itemType )
|
||||
{
|
||||
CFormItem *newNode = new CFormItem();
|
||||
|
|
|
@ -87,6 +87,8 @@ namespace GeorgesQt
|
|||
|
||||
void clearChildren();
|
||||
|
||||
void removeChild( int idx );
|
||||
|
||||
bool rootItem() const{
|
||||
if( parentItem == NULL )
|
||||
return true;
|
||||
|
|
|
@ -90,6 +90,7 @@ namespace GeorgesQt
|
|||
|
||||
connect(m_browserCtrl, SIGNAL(modified()), this, SLOT(modifiedFile()));
|
||||
connect(m_browserCtrl, SIGNAL(valueChanged(const QString&,const QString&)), this, SLOT(onValueChanged(const QString&,const QString&)));
|
||||
connect(m_browserCtrl, SIGNAL(vstructChanged(const QString&)), this, SLOT( onVStructChanged(const QString&)));
|
||||
}
|
||||
|
||||
CGeorgesTreeViewDialog::~CGeorgesTreeViewDialog()
|
||||
|
@ -575,6 +576,21 @@ namespace GeorgesQt
|
|||
modifiedFile();
|
||||
}
|
||||
|
||||
void CGeorgesTreeViewDialog::onVStructChanged( const QString &name )
|
||||
{
|
||||
QModelIndex idx = m_ui.treeView->currentIndex();
|
||||
QModelIndex parent = idx.parent();
|
||||
int row = idx.row();
|
||||
|
||||
m_model->changeVStructDfn( idx );
|
||||
|
||||
idx = m_model->index( row, 0, parent );
|
||||
|
||||
m_ui.treeView->expandAll();
|
||||
m_ui.treeView->setCurrentIndex( idx );
|
||||
m_browserCtrl->clicked( idx );
|
||||
}
|
||||
|
||||
void CGeorgesTreeViewDialog::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
Q_EMIT closing();
|
||||
|
|
|
@ -101,6 +101,7 @@ namespace GeorgesQt
|
|||
void onAppendArray();
|
||||
void onDeleteArrayEntry();
|
||||
void onValueChanged( const QString &key, const QString &value );
|
||||
void onVStructChanged( const QString &name );
|
||||
void onRenameArrayEntry();
|
||||
|
||||
private:
|
||||
|
|
|
@ -45,6 +45,8 @@
|
|||
#include "georges_editor_form.h"
|
||||
#include "actions.h"
|
||||
|
||||
#include "georges.h"
|
||||
|
||||
using namespace NLGEORGES;
|
||||
|
||||
namespace GeorgesQt
|
||||
|
@ -691,6 +693,42 @@ void CGeorgesFormModel::renameArrayEntry( QModelIndex idx, const QString &name )
|
|||
item->setName( name.toUtf8().constData() );
|
||||
}
|
||||
|
||||
void CGeorgesFormModel::changeVStructDfn( QModelIndex idx )
|
||||
{
|
||||
CFormItem *item = static_cast< CFormItem* >( idx.internalPointer() );
|
||||
|
||||
QString vstruct = item->formName().c_str();
|
||||
|
||||
NLGEORGES::UFormElm *uelm = NULL;
|
||||
m_form->getRootNode().getNodeByName( &uelm, vstruct.toUtf8().constData() );
|
||||
|
||||
if( uelm == NULL )
|
||||
return;
|
||||
|
||||
NLGEORGES::CFormElmVirtualStruct *vs = static_cast< NLGEORGES::CFormElmVirtualStruct* >( uelm );
|
||||
|
||||
CGeorges g;
|
||||
NLGEORGES::UFormDfn *udfn = g.loadFormDfn( vs->DfnFilename );
|
||||
if( udfn == NULL )
|
||||
return;
|
||||
|
||||
NLGEORGES::CFormDfn *cdfn = static_cast< NLGEORGES::CFormDfn* >( udfn );
|
||||
vs->build( cdfn );
|
||||
|
||||
|
||||
beginResetModel();
|
||||
|
||||
CFormItem *parent = item->parent();
|
||||
int row = idx.row();
|
||||
QString name = item->name().c_str();
|
||||
QString formName = item->formName().c_str();
|
||||
parent->removeChild( row );
|
||||
|
||||
addItem( parent, vs, cdfn, name.toUtf8().constData(), row, formName.toUtf8().constData() );
|
||||
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
void CGeorgesFormModel::loadFormHeader()
|
||||
|
|
|
@ -83,6 +83,7 @@ namespace GeorgesQt
|
|||
void appendArray( QModelIndex idx );
|
||||
void deleteArrayEntry( QModelIndex idx );
|
||||
void renameArrayEntry( QModelIndex idx, const QString &name );
|
||||
void changeVStructDfn( QModelIndex idx );
|
||||
|
||||
private:
|
||||
void setupModelData();
|
||||
|
|
Loading…
Reference in a new issue