mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-12-04 17:24:47 +00:00
Added support for Virtual Structs.
This commit is contained in:
parent
9554a827ca
commit
ee76b77160
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( arrayResized( const QString&, int ) ), this, SLOT( onArrayResized( const QString&, int ) ) );
|
||||||
connect( m_pvt, SIGNAL( modified() ), this, SLOT( onModified() ) );
|
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( 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()
|
BrowserCtrl::~BrowserCtrl()
|
||||||
|
@ -78,6 +79,11 @@ void BrowserCtrl::onModified()
|
||||||
Q_EMIT modified();
|
Q_EMIT modified();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BrowserCtrl::onVStructChanged( const QString &name )
|
||||||
|
{
|
||||||
|
Q_EMIT vstructChanged( name );
|
||||||
|
}
|
||||||
|
|
||||||
void BrowserCtrl::enableMgrConnections()
|
void BrowserCtrl::enableMgrConnections()
|
||||||
{
|
{
|
||||||
QtVariantPropertyManager *mgr = m_pvt->manager();
|
QtVariantPropertyManager *mgr = m_pvt->manager();
|
||||||
|
|
|
@ -48,12 +48,14 @@ Q_SIGNALS:
|
||||||
void arrayResized( const QString &name, int size );
|
void arrayResized( const QString &name, int size );
|
||||||
void modified();
|
void modified();
|
||||||
void valueChanged( const QString &key, const QString &value );
|
void valueChanged( const QString &key, const QString &value );
|
||||||
|
void vstructChanged( const QString &name );
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void onValueChanged( QtProperty *p, const QVariant &value );
|
void onValueChanged( QtProperty *p, const QVariant &value );
|
||||||
void onValueChanged( const QString &key, const QString &value );
|
void onValueChanged( const QString &key, const QString &value );
|
||||||
void onArrayResized( const QString &name, int size );
|
void onArrayResized( const QString &name, int size );
|
||||||
void onModified();
|
void onModified();
|
||||||
|
void onVStructChanged( const QString &name );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void enableMgrConnections();
|
void enableMgrConnections();
|
||||||
|
|
|
@ -180,6 +180,23 @@ void BrowserCtrlPvt::setupStruct( GeorgesQt::CFormItem *node )
|
||||||
setupStruct( n );
|
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 )
|
void BrowserCtrlPvt::setupArray( GeorgesQt::CFormItem *node )
|
||||||
{
|
{
|
||||||
NLGEORGES::UFormElm *n = getGeorgesNode( node );
|
NLGEORGES::UFormElm *n = getGeorgesNode( node );
|
||||||
|
@ -239,6 +256,9 @@ void BrowserCtrlPvt::setupNode( GeorgesQt::CFormItem *node )
|
||||||
if( node->isStruct() )
|
if( node->isStruct() )
|
||||||
setupStruct( node );
|
setupStruct( node );
|
||||||
else
|
else
|
||||||
|
if( node->isVStruct() )
|
||||||
|
setupVStruct( node );
|
||||||
|
else
|
||||||
if( node->isAtom() )
|
if( node->isAtom() )
|
||||||
setupAtom( node );
|
setupAtom( node );
|
||||||
|
|
||||||
|
@ -266,6 +286,24 @@ void BrowserCtrlPvt::onStructValueChanged( QtProperty *p, const QVariant &value
|
||||||
Q_EMIT valueChanged( key, value.toString() );
|
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()
|
void BrowserCtrlPvt::createArray()
|
||||||
{
|
{
|
||||||
const NLGEORGES::CFormDfn *parentDfn;
|
const NLGEORGES::CFormDfn *parentDfn;
|
||||||
|
@ -385,6 +423,9 @@ void BrowserCtrlPvt::onValueChanged( QtProperty *p, const QVariant &value )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( m_currentNode.p->isVirtualStruct() )
|
||||||
|
onVStructValueChanged( p, value );
|
||||||
|
else
|
||||||
if( m_currentNode.p->isStruct() )
|
if( m_currentNode.p->isStruct() )
|
||||||
onStructValueChanged( p, value );
|
onStructValueChanged( p, value );
|
||||||
else
|
else
|
||||||
|
|
|
@ -58,16 +58,19 @@ Q_SIGNALS:
|
||||||
void arrayResized( const QString &name, int size );
|
void arrayResized( const QString &name, int size );
|
||||||
void modified();
|
void modified();
|
||||||
void valueChanged( const QString &key, const QString &value );
|
void valueChanged( const QString &key, const QString &value );
|
||||||
|
void vstructChanged( const QString &name );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setupStruct( NLGEORGES::UFormElm *node );
|
void setupStruct( NLGEORGES::UFormElm *node );
|
||||||
void setupAtom( NLGEORGES::CFormElmStruct *st, int idx );
|
void setupAtom( NLGEORGES::CFormElmStruct *st, int idx );
|
||||||
|
|
||||||
void setupStruct( GeorgesQt::CFormItem *node );
|
void setupStruct( GeorgesQt::CFormItem *node );
|
||||||
|
void setupVStruct( GeorgesQt::CFormItem *node );
|
||||||
void setupArray( GeorgesQt::CFormItem *node );
|
void setupArray( GeorgesQt::CFormItem *node );
|
||||||
void setupAtom( GeorgesQt::CFormItem *node );
|
void setupAtom( GeorgesQt::CFormItem *node );
|
||||||
|
|
||||||
void onStructValueChanged( QtProperty *p, const QVariant &value );
|
void onStructValueChanged( QtProperty *p, const QVariant &value );
|
||||||
|
void onVStructValueChanged( QtProperty *p, const QVariant &value );
|
||||||
void onArrayValueChanged( QtProperty *p, const QVariant &value );
|
void onArrayValueChanged( QtProperty *p, const QVariant &value );
|
||||||
void onAtomValueChanged( QtProperty *p, const QVariant &value );
|
void onAtomValueChanged( QtProperty *p, const QVariant &value );
|
||||||
void createArray();
|
void createArray();
|
||||||
|
|
|
@ -238,6 +238,13 @@ namespace GeorgesQt
|
||||||
childItems.clear();
|
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 *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();
|
||||||
|
|
|
@ -87,6 +87,8 @@ namespace GeorgesQt
|
||||||
|
|
||||||
void clearChildren();
|
void clearChildren();
|
||||||
|
|
||||||
|
void removeChild( int idx );
|
||||||
|
|
||||||
bool rootItem() const{
|
bool rootItem() const{
|
||||||
if( parentItem == NULL )
|
if( parentItem == NULL )
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -90,6 +90,7 @@ namespace GeorgesQt
|
||||||
|
|
||||||
connect(m_browserCtrl, SIGNAL(modified()), this, SLOT(modifiedFile()));
|
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(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()
|
CGeorgesTreeViewDialog::~CGeorgesTreeViewDialog()
|
||||||
|
@ -575,6 +576,21 @@ namespace GeorgesQt
|
||||||
modifiedFile();
|
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)
|
void CGeorgesTreeViewDialog::closeEvent(QCloseEvent *event)
|
||||||
{
|
{
|
||||||
Q_EMIT closing();
|
Q_EMIT closing();
|
||||||
|
|
|
@ -101,6 +101,7 @@ namespace GeorgesQt
|
||||||
void onAppendArray();
|
void onAppendArray();
|
||||||
void onDeleteArrayEntry();
|
void onDeleteArrayEntry();
|
||||||
void onValueChanged( const QString &key, const QString &value );
|
void onValueChanged( const QString &key, const QString &value );
|
||||||
|
void onVStructChanged( const QString &name );
|
||||||
void onRenameArrayEntry();
|
void onRenameArrayEntry();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -45,6 +45,8 @@
|
||||||
#include "georges_editor_form.h"
|
#include "georges_editor_form.h"
|
||||||
#include "actions.h"
|
#include "actions.h"
|
||||||
|
|
||||||
|
#include "georges.h"
|
||||||
|
|
||||||
using namespace NLGEORGES;
|
using namespace NLGEORGES;
|
||||||
|
|
||||||
namespace GeorgesQt
|
namespace GeorgesQt
|
||||||
|
@ -691,6 +693,42 @@ void CGeorgesFormModel::renameArrayEntry( QModelIndex idx, const QString &name )
|
||||||
item->setName( name.toUtf8().constData() );
|
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()
|
void CGeorgesFormModel::loadFormHeader()
|
||||||
|
|
|
@ -83,6 +83,7 @@ namespace GeorgesQt
|
||||||
void appendArray( QModelIndex idx );
|
void appendArray( QModelIndex idx );
|
||||||
void deleteArrayEntry( QModelIndex idx );
|
void deleteArrayEntry( QModelIndex idx );
|
||||||
void renameArrayEntry( QModelIndex idx, const QString &name );
|
void renameArrayEntry( QModelIndex idx, const QString &name );
|
||||||
|
void changeVStructDfn( QModelIndex idx );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setupModelData();
|
void setupModelData();
|
||||||
|
|
Loading…
Reference in a new issue