From ca910cf17afef20227272ccede616b3ea3dd3bfe Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 5 Sep 2014 20:28:43 +0200 Subject: [PATCH] Added support for manipulating atoms. --- code/nel/include/nel/georges/form_elm.h | 1 + code/nel/src/georges/form_elm.cpp | 7 ++++ .../georges_editor/browser_ctrl_pvt.cpp | 38 +++++++++++++++++++ .../plugins/georges_editor/browser_ctrl_pvt.h | 2 + 4 files changed, 48 insertions(+) diff --git a/code/nel/include/nel/georges/form_elm.h b/code/nel/include/nel/georges/form_elm.h index 5453717a2..48118b7d8 100644 --- a/code/nel/include/nel/georges/form_elm.h +++ b/code/nel/include/nel/georges/form_elm.h @@ -454,6 +454,7 @@ public: // Set the value, the elt been used void setValue (const char *value); + std::string getValue() const; private: // The value diff --git a/code/nel/src/georges/form_elm.cpp b/code/nel/src/georges/form_elm.cpp index 518782342..03d39967a 100644 --- a/code/nel/src/georges/form_elm.cpp +++ b/code/nel/src/georges/form_elm.cpp @@ -3056,6 +3056,13 @@ void CFormElmAtom::setValue (const char *value) // *************************************************************************** +std::string CFormElmAtom::getValue() const +{ + return Value; +} + +// *************************************************************************** + void CFormElmAtom::getFormName (std::string &result, const CFormElm *child) const { // Must be NULL diff --git a/code/studio/src/plugins/georges_editor/browser_ctrl_pvt.cpp b/code/studio/src/plugins/georges_editor/browser_ctrl_pvt.cpp index fe8a60b28..0b5b464a3 100644 --- a/code/studio/src/plugins/georges_editor/browser_ctrl_pvt.cpp +++ b/code/studio/src/plugins/georges_editor/browser_ctrl_pvt.cpp @@ -146,6 +146,29 @@ void BrowserCtrlPvt::setupArray( GeorgesQt::CFormItem *node ) m_browser->addProperty( p ); } +void BrowserCtrlPvt::setupAtom( GeorgesQt::CFormItem *node ) +{ + NLGEORGES::UFormElm *n = getGeorgesNode( node ); + + if( n == NULL ) + return; + + NLGEORGES::CFormElmAtom *atom = static_cast< NLGEORGES::CFormElmAtom* >( n ); + std::string v = atom->getValue(); + + const NLGEORGES::CType *t = atom->getType(); + QVariant::Type tt = QVariant::String; + if( t != NULL ) + { + tt = getValueType( t ); + } + + QtVariantProperty *p = mgr->addProperty( tt, "value" ); + p->setValue( v.c_str() ); + m_browser->addProperty( p ); + + m_currentNode.p = n; +} void BrowserCtrlPvt::setupNode( GeorgesQt::CFormItem *node ) { @@ -159,6 +182,9 @@ void BrowserCtrlPvt::setupNode( GeorgesQt::CFormItem *node ) else if( node->isStruct() ) setupStruct( node ); + else + if( node->isAtom() ) + setupAtom( node ); m_browser->setFactoryForManager( mgr, factory ); } @@ -283,6 +309,15 @@ void BrowserCtrlPvt::onArrayValueChanged( QtProperty *p, const QVariant &value ) m_currentNode.p = NULL; } +void BrowserCtrlPvt::onAtomValueChanged( QtProperty *p, const QVariant &value ) +{ + NLGEORGES::CFormElmAtom *atom = static_cast< NLGEORGES::CFormElmAtom* >( m_currentNode.p ); + atom->setValue( value.toString().toUtf8() ); + + Q_EMIT modified(); + Q_EMIT valueChanged( m_currentNode.name, value.toString() ); +} + void BrowserCtrlPvt::onValueChanged( QtProperty *p, const QVariant &value ) { if( m_currentNode.p == NULL ) @@ -299,6 +334,9 @@ void BrowserCtrlPvt::onValueChanged( QtProperty *p, const QVariant &value ) else if( m_currentNode.p->isArray() ) onArrayValueChanged( p, value ); + else + if( m_currentNode.p->isAtom() ) + onAtomValueChanged( p, value ); } diff --git a/code/studio/src/plugins/georges_editor/browser_ctrl_pvt.h b/code/studio/src/plugins/georges_editor/browser_ctrl_pvt.h index bebb65c3e..bcdf773a4 100644 --- a/code/studio/src/plugins/georges_editor/browser_ctrl_pvt.h +++ b/code/studio/src/plugins/georges_editor/browser_ctrl_pvt.h @@ -65,9 +65,11 @@ private: void setupStruct( GeorgesQt::CFormItem *node ); void setupArray( GeorgesQt::CFormItem *node ); + void setupAtom( GeorgesQt::CFormItem *node ); void onStructValueChanged( QtProperty *p, const QVariant &value ); void onArrayValueChanged( QtProperty *p, const QVariant &value ); + void onAtomValueChanged( QtProperty *p, const QVariant &value ); void createArray(); QtVariantPropertyManager *mgr;