Load type data into the property browser.
--HG-- branch : dfighter-tools
This commit is contained in:
parent
6cd4d756db
commit
6e86da4c40
3 changed files with 154 additions and 1 deletions
code/studio/src/plugins/georges_editor
|
@ -1,5 +1,6 @@
|
|||
#include "georges_typ_dialog.h"
|
||||
#include "georges.h"
|
||||
#include "typ_browser_ctrl.h"
|
||||
|
||||
#include <QInputDialog>
|
||||
#include <QMessageBox>
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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 ) ) );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,3 +1,48 @@
|
|||
#ifndef TYP_BROWSER_CTRL
|
||||
#define TYP_BROWSER_CTRL
|
||||
|
||||
#include <QObject>
|
||||
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue