From 6e86da4c40b86e0491669c98a8df9652a210fa96 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Wed, 3 Sep 2014 16:08:13 +0200 Subject: [PATCH] Load type data into the property browser. --HG-- branch : dfighter-tools --- .../georges_editor/georges_typ_dialog.cpp | 10 +- .../georges_editor/typ_browser_ctrl.cpp | 100 ++++++++++++++++++ .../plugins/georges_editor/typ_browser_ctrl.h | 45 ++++++++ 3 files changed, 154 insertions(+), 1 deletion(-) diff --git a/code/studio/src/plugins/georges_editor/georges_typ_dialog.cpp b/code/studio/src/plugins/georges_editor/georges_typ_dialog.cpp index 4b042d8e0..539de4f96 100644 --- a/code/studio/src/plugins/georges_editor/georges_typ_dialog.cpp +++ b/code/studio/src/plugins/georges_editor/georges_typ_dialog.cpp @@ -1,5 +1,6 @@ #include "georges_typ_dialog.h" #include "georges.h" +#include "typ_browser_ctrl.h" #include #include @@ -14,16 +15,20 @@ public: GeorgesTypDialogPvt() { typ = NULL; + ctrl = new TypBrowserCtrl(); } ~GeorgesTypDialogPvt() { delete typ; typ = NULL; + delete ctrl; + ctrl = NULL; } NLGEORGES::CType *typ; + TypBrowserCtrl *ctrl; }; GeorgesTypDialog::GeorgesTypDialog( QWidget *parent ) : @@ -31,6 +36,8 @@ GeorgesDockWidget( parent ) { m_ui.setupUi( this ); m_pvt = new GeorgesTypDialogPvt(); + m_pvt->ctrl->setBrowser( m_ui.browser ); + setupConnections(); } @@ -195,6 +202,7 @@ void GeorgesTypDialog::loadTyp() ++itr; } - + m_pvt->ctrl->setTyp( m_pvt->typ ); + m_pvt->ctrl->load(); } diff --git a/code/studio/src/plugins/georges_editor/typ_browser_ctrl.cpp b/code/studio/src/plugins/georges_editor/typ_browser_ctrl.cpp index 002a89290..144156cfc 100644 --- a/code/studio/src/plugins/georges_editor/typ_browser_ctrl.cpp +++ b/code/studio/src/plugins/georges_editor/typ_browser_ctrl.cpp @@ -1 +1,101 @@ #include "typ_browser_ctrl.h" + +#include "3rdparty/qtpropertybrowser/qttreepropertybrowser.h" +#include "3rdparty/qtpropertybrowser/qtvariantproperty.h" +#include "3rdparty/qtpropertybrowser/qtpropertymanager.h" +#include "3rdparty/qtpropertybrowser/qteditorfactory.h" + +#include "nel/georges/type.h" + +TypBrowserCtrl::TypBrowserCtrl( QObject *parent ) : +QObject( parent ) +{ + m_typ = NULL; + + m_variantMgr = new QtVariantPropertyManager( this ); + m_variantFactory = new QtVariantEditorFactory( this ); + m_enumMgr = new QtEnumPropertyManager( this ); + m_enumFactory = new QtEnumEditorFactory( this ); +} + +TypBrowserCtrl::~TypBrowserCtrl() +{ + m_typ = NULL; + m_variantMgr = NULL; + m_variantFactory = NULL; + m_enumMgr = NULL; + m_enumFactory = NULL; +} + +void TypBrowserCtrl::load() +{ + m_browser->clear(); + m_browser->setFactoryForManager( m_variantMgr, m_variantFactory ); + m_browser->setFactoryForManager( m_enumMgr, m_enumFactory ); + + m_typ->Type; + m_typ->UIType; + + QtProperty *p = NULL; + + p = m_enumMgr->addProperty( "type" ); + QStringList l; + l.push_back( "UnsignedInt" ); + l.push_back( "SignedInt" ); + l.push_back( "Double" ); + l.push_back( "String" ); + l.push_back( "Color" ); + m_enumMgr->setEnumNames( p, l ); + m_enumMgr->setValue( p, m_typ->Type ); + m_browser->addProperty( p ); + + p = m_enumMgr->addProperty( "uitype" ); + l.clear(); + l.push_back( "Edit" ); + l.push_back( "EditSpin" ); + l.push_back( "NonEditableCombo" ); + l.push_back( "FileBrowser" ); + l.push_back( "BigEdit" ); + l.push_back( "ColorEdit" ); + l.push_back( "IconWidget" ); + m_enumMgr->setEnumNames( p, l ); + m_enumMgr->setValue( p, m_typ->UIType ); + m_browser->addProperty( p ); + + + QtVariantProperty *vp = NULL; + + vp = m_variantMgr->addProperty( QVariant::String, "default" ); + vp->setValue( m_typ->Default.c_str() ); + m_browser->addProperty( vp ); + + vp = m_variantMgr->addProperty( QVariant::String, "min" ); + vp->setValue( m_typ->Min.c_str() ); + m_browser->addProperty( vp ); + + vp = m_variantMgr->addProperty( QVariant::String, "Max" ); + vp->setValue( m_typ->Max.c_str() ); + m_browser->addProperty( vp ); + + vp = m_variantMgr->addProperty( QVariant::String, "increment" ); + vp->setValue( m_typ->Increment.c_str() ); + m_browser->addProperty( vp ); + + enableMgrConnections(); +} + +void TypBrowserCtrl::onVariantValueChanged( QtProperty *p, const QVariant &v ) +{ +} + +void TypBrowserCtrl::onEnumValueChanged( QtProperty *p, int v ) +{ +} + +void TypBrowserCtrl::enableMgrConnections() +{ + connect( m_variantMgr, SIGNAL( valueChanged( QtProperty*, const QVariant& ) ), this, SLOT( onVariantValueChanged( QtProperty*, const QVariant& ) ) ); + connect( m_enumMgr, SIGNAL( valueChanged( QtProperty*, int ) ), this, SLOT( onEnumValueChanged( QtProperty*, int ) ) ); +} + + diff --git a/code/studio/src/plugins/georges_editor/typ_browser_ctrl.h b/code/studio/src/plugins/georges_editor/typ_browser_ctrl.h index bf29e1cc8..d565152c4 100644 --- a/code/studio/src/plugins/georges_editor/typ_browser_ctrl.h +++ b/code/studio/src/plugins/georges_editor/typ_browser_ctrl.h @@ -1,3 +1,48 @@ #ifndef TYP_BROWSER_CTRL #define TYP_BROWSER_CTRL + +#include + +class QtVariantPropertyManager; +class QtVariantEditorFactory; +class QtTreePropertyBrowser; +class QtEnumPropertyManager; +class QtEnumEditorFactory; +class QVariant; +class QtProperty; + +namespace NLGEORGES +{ + class CType; +} + +class TypBrowserCtrl : public QObject +{ + Q_OBJECT +public: + TypBrowserCtrl( QObject *parent = NULL ); + ~TypBrowserCtrl(); + + void load(); + + void setTyp( NLGEORGES::CType *typ ){ m_typ = typ; } + void setBrowser( QtTreePropertyBrowser *browser ){ m_browser = browser; } + +private Q_SLOTS: + void onVariantValueChanged( QtProperty *p, const QVariant &v ); + void onEnumValueChanged( QtProperty *p, int v ); + +private: + void enableMgrConnections(); + + NLGEORGES::CType *m_typ; + QtTreePropertyBrowser *m_browser; + + QtVariantPropertyManager *m_variantMgr; + QtVariantEditorFactory *m_variantFactory; + QtEnumPropertyManager *m_enumMgr; + QtEnumEditorFactory *m_enumFactory; + +}; + #endif