mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-28 01:56:24 +00:00
Shown properties can now be edited.
This commit is contained in:
parent
a8b1a0eca3
commit
4dcbd2182d
1 changed files with 67 additions and 26 deletions
|
@ -7,6 +7,26 @@
|
||||||
|
|
||||||
#include "formitem.h"
|
#include "formitem.h"
|
||||||
|
|
||||||
|
QVariant::Type getValueType( const NLGEORGES::UType *typ )
|
||||||
|
{
|
||||||
|
QVariant::Type t = QVariant::String;
|
||||||
|
|
||||||
|
NLGEORGES::UType::TType ttyp = NLGEORGES::UType::String;
|
||||||
|
if( typ != NULL )
|
||||||
|
ttyp = typ->getType();
|
||||||
|
|
||||||
|
switch( ttyp )
|
||||||
|
{
|
||||||
|
case NLGEORGES::UType::UnsignedInt: t = QVariant::UInt; break;
|
||||||
|
case NLGEORGES::UType::SignedInt: t = QVariant::Int; break;
|
||||||
|
case NLGEORGES::UType::Double: t = QVariant::Double; break;
|
||||||
|
case NLGEORGES::UType::Color: t = QVariant::Color; break;
|
||||||
|
case NLGEORGES::UType::String: t = QVariant::String; break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
class BrowserCtrlPvt
|
class BrowserCtrlPvt
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -22,8 +42,52 @@ public:
|
||||||
mgr = NULL;
|
mgr = NULL;
|
||||||
delete factory;
|
delete factory;
|
||||||
factory = NULL;
|
factory = NULL;
|
||||||
|
m_browser = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setupElement( NLGEORGES::CFormElmStruct::CFormElmStructElm &elm )
|
||||||
|
{
|
||||||
|
QString key = elm.Name.c_str();
|
||||||
|
QString value = "";
|
||||||
|
QVariant::Type t = QVariant::String;
|
||||||
|
|
||||||
|
if( elm.Element != NULL )
|
||||||
|
{
|
||||||
|
t = getValueType( elm.Element->getType() );
|
||||||
|
|
||||||
|
NLGEORGES::CFormElmAtom *atom = static_cast< NLGEORGES::CFormElmAtom* >( elm.Element );
|
||||||
|
std::string v;
|
||||||
|
atom->getValue( v, NLGEORGES::UFormElm::NoEval );
|
||||||
|
value = v.c_str();
|
||||||
|
}
|
||||||
|
|
||||||
|
QtVariantProperty *p = mgr->addProperty( t, key );
|
||||||
|
p->setValue( value );
|
||||||
|
m_browser->addProperty( p );
|
||||||
|
}
|
||||||
|
|
||||||
|
void setupForm( NLGEORGES::CFormElmStruct *st )
|
||||||
|
{
|
||||||
|
for( int i = 0; i < st->Elements.size(); i++ )
|
||||||
|
{
|
||||||
|
NLGEORGES::CFormElmStruct::CFormElmStructElm &elm = st->Elements[ i ];
|
||||||
|
setupElement( elm );
|
||||||
|
}
|
||||||
|
|
||||||
|
m_browser->setFactoryForManager( mgr, factory );
|
||||||
|
}
|
||||||
|
|
||||||
|
void clear()
|
||||||
|
{
|
||||||
|
m_browser->clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void setBrowser( QtTreePropertyBrowser *browser )
|
||||||
|
{
|
||||||
|
m_browser = browser;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
QtVariantPropertyManager *mgr;
|
QtVariantPropertyManager *mgr;
|
||||||
QtVariantEditorFactory *factory;
|
QtVariantEditorFactory *factory;
|
||||||
QtTreePropertyBrowser *m_browser;
|
QtTreePropertyBrowser *m_browser;
|
||||||
|
@ -33,7 +97,7 @@ BrowserCtrl::BrowserCtrl( QtTreePropertyBrowser *browser ) :
|
||||||
QObject( browser )
|
QObject( browser )
|
||||||
{
|
{
|
||||||
m_pvt = new BrowserCtrlPvt();
|
m_pvt = new BrowserCtrlPvt();
|
||||||
m_pvt->m_browser = browser;
|
m_pvt->setBrowser( browser );
|
||||||
}
|
}
|
||||||
|
|
||||||
BrowserCtrl::~BrowserCtrl()
|
BrowserCtrl::~BrowserCtrl()
|
||||||
|
@ -44,7 +108,7 @@ BrowserCtrl::~BrowserCtrl()
|
||||||
|
|
||||||
void BrowserCtrl::clicked( const QModelIndex &idx )
|
void BrowserCtrl::clicked( const QModelIndex &idx )
|
||||||
{
|
{
|
||||||
m_pvt->m_browser->clear();
|
m_pvt->clear();
|
||||||
|
|
||||||
GeorgesQt::CFormItem *item = static_cast< GeorgesQt::CFormItem* >( idx.internalPointer() );
|
GeorgesQt::CFormItem *item = static_cast< GeorgesQt::CFormItem* >( idx.internalPointer() );
|
||||||
NLGEORGES::UFormElm &root = m_form->getRootNode();
|
NLGEORGES::UFormElm &root = m_form->getRootNode();
|
||||||
|
@ -60,30 +124,7 @@ void BrowserCtrl::clicked( const QModelIndex &idx )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
NLGEORGES::CFormElmStruct *st = static_cast< NLGEORGES::CFormElmStruct* >( node );
|
NLGEORGES::CFormElmStruct *st = static_cast< NLGEORGES::CFormElmStruct* >( node );
|
||||||
for( int i = 0; i < st->Elements.size(); i++ )
|
m_pvt->setupForm( st );
|
||||||
{
|
|
||||||
NLGEORGES::CFormElmStruct::CFormElmStructElm &elm = st->Elements[ i ];
|
|
||||||
|
|
||||||
QString key = elm.Name.c_str();
|
|
||||||
QString value = "";
|
|
||||||
|
|
||||||
if( elm.Element != NULL )
|
|
||||||
{
|
|
||||||
const NLGEORGES::UType *typ = elm.Element->getType();
|
|
||||||
NLGEORGES::UType::TType ttyp = NLGEORGES::UType::String;
|
|
||||||
if( typ != NULL )
|
|
||||||
ttyp = typ->getType();
|
|
||||||
|
|
||||||
NLGEORGES::CFormElmAtom *atom = static_cast< NLGEORGES::CFormElmAtom* >( elm.Element );
|
|
||||||
std::string v;
|
|
||||||
atom->getValue( v, NLGEORGES::UFormElm::NoEval );
|
|
||||||
value = v.c_str();
|
|
||||||
}
|
|
||||||
|
|
||||||
QtVariantProperty *p = m_pvt->mgr->addProperty( QVariant::String, key );
|
|
||||||
p->setValue( value );
|
|
||||||
m_pvt->m_browser->addProperty( p );
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue