commit
d232939294
@ -1,77 +1,77 @@
|
|||||||
#include "browser_ctrl.h"
|
#include "browser_ctrl.h"
|
||||||
#include "3rdparty/qtpropertybrowser/qttreepropertybrowser.h"
|
#include "3rdparty/qtpropertybrowser/qttreepropertybrowser.h"
|
||||||
#include "3rdparty/qtpropertybrowser/qtvariantproperty.h"
|
#include "3rdparty/qtpropertybrowser/qtvariantproperty.h"
|
||||||
#include <QModelIndex>
|
#include <QModelIndex>
|
||||||
|
|
||||||
#include "nel/georges/form.h"
|
#include "nel/georges/form.h"
|
||||||
|
|
||||||
#include "formitem.h"
|
#include "formitem.h"
|
||||||
|
|
||||||
#include "browser_ctrl_pvt.h"
|
#include "browser_ctrl_pvt.h"
|
||||||
|
|
||||||
BrowserCtrl::BrowserCtrl( QtTreePropertyBrowser *browser ) :
|
BrowserCtrl::BrowserCtrl( QtTreePropertyBrowser *browser ) :
|
||||||
QObject( browser )
|
QObject( browser )
|
||||||
{
|
{
|
||||||
m_pvt = new BrowserCtrlPvt();
|
m_pvt = new BrowserCtrlPvt();
|
||||||
m_pvt->setBrowser( browser );
|
m_pvt->setBrowser( 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& ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
BrowserCtrl::~BrowserCtrl()
|
BrowserCtrl::~BrowserCtrl()
|
||||||
{
|
{
|
||||||
delete m_pvt;
|
delete m_pvt;
|
||||||
m_pvt = NULL;
|
m_pvt = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserCtrl::clicked( const QModelIndex &idx )
|
void BrowserCtrl::clicked( const QModelIndex &idx )
|
||||||
{
|
{
|
||||||
disableMgrConnections();
|
disableMgrConnections();
|
||||||
m_pvt->clear();
|
m_pvt->clear();
|
||||||
|
|
||||||
GeorgesQt::CFormItem *item = static_cast< GeorgesQt::CFormItem* >( idx.internalPointer() );
|
GeorgesQt::CFormItem *item = static_cast< GeorgesQt::CFormItem* >( idx.internalPointer() );
|
||||||
|
|
||||||
m_pvt->setupNode( item );
|
m_pvt->setupNode( item );
|
||||||
|
|
||||||
enableMgrConnections();
|
enableMgrConnections();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserCtrl::onValueChanged( QtProperty *p, const QVariant &value )
|
void BrowserCtrl::onValueChanged( QtProperty *p, const QVariant &value )
|
||||||
{
|
{
|
||||||
m_pvt->onValueChanged( p, value );
|
m_pvt->onValueChanged( p, value );
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserCtrl::onValueChanged( const QString &key, const QString &value )
|
void BrowserCtrl::onValueChanged( const QString &key, const QString &value )
|
||||||
{
|
{
|
||||||
Q_EMIT valueChanged( key, value );
|
Q_EMIT valueChanged( key, value );
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserCtrl::onArrayResized( const QString &name, int size )
|
void BrowserCtrl::onArrayResized( const QString &name, int size )
|
||||||
{
|
{
|
||||||
Q_EMIT arrayResized( name, size );
|
Q_EMIT arrayResized( name, size );
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserCtrl::onModified()
|
void BrowserCtrl::onModified()
|
||||||
{
|
{
|
||||||
Q_EMIT modified();
|
Q_EMIT modified();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserCtrl::enableMgrConnections()
|
void BrowserCtrl::enableMgrConnections()
|
||||||
{
|
{
|
||||||
QtVariantPropertyManager *mgr = m_pvt->manager();
|
QtVariantPropertyManager *mgr = m_pvt->manager();
|
||||||
|
|
||||||
connect( mgr, SIGNAL( valueChanged( QtProperty*, const QVariant & ) ),
|
connect( mgr, SIGNAL( valueChanged( QtProperty*, const QVariant & ) ),
|
||||||
this, SLOT( onValueChanged( QtProperty*, const QVariant & ) ) );
|
this, SLOT( onValueChanged( QtProperty*, const QVariant & ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserCtrl::disableMgrConnections()
|
void BrowserCtrl::disableMgrConnections()
|
||||||
{
|
{
|
||||||
QtVariantPropertyManager *mgr = m_pvt->manager();
|
QtVariantPropertyManager *mgr = m_pvt->manager();
|
||||||
|
|
||||||
disconnect( mgr, SIGNAL( valueChanged( QtProperty*, const QVariant & ) ),
|
disconnect( mgr, SIGNAL( valueChanged( QtProperty*, const QVariant & ) ),
|
||||||
this, SLOT( onValueChanged( QtProperty*, const QVariant & ) ) );
|
this, SLOT( onValueChanged( QtProperty*, const QVariant & ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,284 +1,284 @@
|
|||||||
#include "browser_ctrl_pvt.h"
|
#include "browser_ctrl_pvt.h"
|
||||||
#include "3rdparty/qtpropertybrowser/qttreepropertybrowser.h"
|
#include "3rdparty/qtpropertybrowser/qttreepropertybrowser.h"
|
||||||
#include "3rdparty/qtpropertybrowser/qtvariantproperty.h"
|
#include "3rdparty/qtpropertybrowser/qtvariantproperty.h"
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include "formitem.h"
|
#include "formitem.h"
|
||||||
|
|
||||||
#include "nel/georges/form.h"
|
#include "nel/georges/form.h"
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
||||||
QVariant::Type getValueType( const NLGEORGES::UType *typ )
|
QVariant::Type getValueType( const NLGEORGES::UType *typ )
|
||||||
{
|
{
|
||||||
QVariant::Type t = QVariant::String;
|
QVariant::Type t = QVariant::String;
|
||||||
|
|
||||||
NLGEORGES::UType::TType ttyp = NLGEORGES::UType::String;
|
NLGEORGES::UType::TType ttyp = NLGEORGES::UType::String;
|
||||||
if( typ != NULL )
|
if( typ != NULL )
|
||||||
ttyp = typ->getType();
|
ttyp = typ->getType();
|
||||||
|
|
||||||
switch( ttyp )
|
switch( ttyp )
|
||||||
{
|
{
|
||||||
case NLGEORGES::UType::UnsignedInt: t = QVariant::UInt; break;
|
case NLGEORGES::UType::UnsignedInt: t = QVariant::UInt; break;
|
||||||
case NLGEORGES::UType::SignedInt: t = QVariant::Int; break;
|
case NLGEORGES::UType::SignedInt: t = QVariant::Int; break;
|
||||||
case NLGEORGES::UType::Double: t = QVariant::Double; break;
|
case NLGEORGES::UType::Double: t = QVariant::Double; break;
|
||||||
case NLGEORGES::UType::Color: t = QVariant::Color; break;
|
case NLGEORGES::UType::Color: t = QVariant::Color; break;
|
||||||
case NLGEORGES::UType::String: t = QVariant::String; break;
|
case NLGEORGES::UType::String: t = QVariant::String; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
NLGEORGES::UFormElm* getGeorgesNode( GeorgesQt::CFormItem *item )
|
NLGEORGES::UFormElm* getGeorgesNode( GeorgesQt::CFormItem *item )
|
||||||
{
|
{
|
||||||
NLGEORGES::UFormElm *n = NULL;
|
NLGEORGES::UFormElm *n = NULL;
|
||||||
item->form()->getRootNode().getNodeByName( &n, item->formName().c_str() );
|
item->form()->getRootNode().getNodeByName( &n, item->formName().c_str() );
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BrowserCtrlPvt::BrowserCtrlPvt( QObject *parent ) :
|
BrowserCtrlPvt::BrowserCtrlPvt( QObject *parent ) :
|
||||||
QObject( parent )
|
QObject( parent )
|
||||||
{
|
{
|
||||||
mgr = new QtVariantPropertyManager();
|
mgr = new QtVariantPropertyManager();
|
||||||
factory = new QtVariantEditorFactory();
|
factory = new QtVariantEditorFactory();
|
||||||
m_rootNode = NULL;
|
m_rootNode = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
BrowserCtrlPvt::~BrowserCtrlPvt()
|
BrowserCtrlPvt::~BrowserCtrlPvt()
|
||||||
{
|
{
|
||||||
delete mgr;
|
delete mgr;
|
||||||
mgr = NULL;
|
mgr = NULL;
|
||||||
delete factory;
|
delete factory;
|
||||||
factory = NULL;
|
factory = NULL;
|
||||||
m_browser = NULL;
|
m_browser = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserCtrlPvt::setupAtom( NLGEORGES::CFormElmStruct::CFormElmStructElm &elm )
|
void BrowserCtrlPvt::setupAtom( NLGEORGES::CFormElmStruct::CFormElmStructElm &elm )
|
||||||
{
|
{
|
||||||
QString key = elm.Name.c_str();
|
QString key = elm.Name.c_str();
|
||||||
QString value = "";
|
QString value = "";
|
||||||
QVariant::Type t = QVariant::String;
|
QVariant::Type t = QVariant::String;
|
||||||
|
|
||||||
if( elm.Element != NULL )
|
if( elm.Element != NULL )
|
||||||
{
|
{
|
||||||
t = getValueType( elm.Element->getType() );
|
t = getValueType( elm.Element->getType() );
|
||||||
|
|
||||||
std::string formName;
|
std::string formName;
|
||||||
elm.Element->getFormName( formName, NULL );
|
elm.Element->getFormName( formName, NULL );
|
||||||
|
|
||||||
std::string v;
|
std::string v;
|
||||||
m_rootNode->getValueByName( v, formName.c_str(), NLGEORGES::UFormElm::NoEval, NULL, 0 );
|
m_rootNode->getValueByName( v, formName.c_str(), NLGEORGES::UFormElm::NoEval, NULL, 0 );
|
||||||
value = v.c_str();
|
value = v.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
QtVariantProperty *p = mgr->addProperty( t, key );
|
QtVariantProperty *p = mgr->addProperty( t, key );
|
||||||
p->setValue( value );
|
p->setValue( value );
|
||||||
m_browser->addProperty( p );
|
m_browser->addProperty( p );
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserCtrlPvt::setupStruct( NLGEORGES::UFormElm *node )
|
void BrowserCtrlPvt::setupStruct( NLGEORGES::UFormElm *node )
|
||||||
{
|
{
|
||||||
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++ )
|
for( int i = 0; i < st->Elements.size(); i++ )
|
||||||
{
|
{
|
||||||
NLGEORGES::CFormElmStruct::CFormElmStructElm &elm = st->Elements[ i ];
|
NLGEORGES::CFormElmStruct::CFormElmStructElm &elm = st->Elements[ i ];
|
||||||
if( ( elm.Element != NULL ) && !elm.Element->isAtom() )
|
if( ( elm.Element != NULL ) && !elm.Element->isAtom() )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if( elm.Element == NULL )
|
if( elm.Element == NULL )
|
||||||
{
|
{
|
||||||
NLGEORGES::CFormDfn::CEntry &entry = st->FormDfn->getEntry( i );
|
NLGEORGES::CFormDfn::CEntry &entry = st->FormDfn->getEntry( i );
|
||||||
if( entry.getArrayFlag() )
|
if( entry.getArrayFlag() )
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
setupAtom( elm );
|
setupAtom( elm );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserCtrlPvt::setupStruct( GeorgesQt::CFormItem *node )
|
void BrowserCtrlPvt::setupStruct( GeorgesQt::CFormItem *node )
|
||||||
{
|
{
|
||||||
NLGEORGES::UFormElm *n = getGeorgesNode( node );
|
NLGEORGES::UFormElm *n = getGeorgesNode( node );
|
||||||
if( n == NULL )
|
if( n == NULL )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_currentNode.p = n;
|
m_currentNode.p = n;
|
||||||
|
|
||||||
setupStruct( n );
|
setupStruct( n );
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserCtrlPvt::setupArray( GeorgesQt::CFormItem *node )
|
void BrowserCtrlPvt::setupArray( GeorgesQt::CFormItem *node )
|
||||||
{
|
{
|
||||||
NLGEORGES::UFormElm *n = getGeorgesNode( node );
|
NLGEORGES::UFormElm *n = getGeorgesNode( node );
|
||||||
uint size = 0;
|
uint size = 0;
|
||||||
|
|
||||||
if( n != NULL )
|
if( n != NULL )
|
||||||
{
|
{
|
||||||
NLGEORGES::CFormElmArray *arr = static_cast< NLGEORGES::CFormElmArray* >( n );
|
NLGEORGES::CFormElmArray *arr = static_cast< NLGEORGES::CFormElmArray* >( n );
|
||||||
arr->getArraySize( size );
|
arr->getArraySize( size );
|
||||||
m_currentNode.p = n;
|
m_currentNode.p = n;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString key = QObject::tr( "Array size" );
|
QString key = QObject::tr( "Array size" );
|
||||||
QtVariantProperty *p = mgr->addProperty( QVariant::Int, key );
|
QtVariantProperty *p = mgr->addProperty( QVariant::Int, key );
|
||||||
p->setValue( size );
|
p->setValue( size );
|
||||||
m_browser->addProperty( p );
|
m_browser->addProperty( p );
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserCtrlPvt::setupNode( GeorgesQt::CFormItem *node )
|
void BrowserCtrlPvt::setupNode( GeorgesQt::CFormItem *node )
|
||||||
{
|
{
|
||||||
m_currentNode.clear();
|
m_currentNode.clear();
|
||||||
m_currentNode.name = node->formName().c_str();
|
m_currentNode.name = node->formName().c_str();
|
||||||
|
|
||||||
m_rootNode = dynamic_cast< NLGEORGES::CFormElm* >( &(node->form()->getRootNode()) );
|
m_rootNode = dynamic_cast< NLGEORGES::CFormElm* >( &(node->form()->getRootNode()) );
|
||||||
|
|
||||||
if( node->isArray() )
|
if( node->isArray() )
|
||||||
setupArray( node );
|
setupArray( node );
|
||||||
else
|
else
|
||||||
setupStruct( node );
|
setupStruct( node );
|
||||||
|
|
||||||
m_browser->setFactoryForManager( mgr, factory );
|
m_browser->setFactoryForManager( mgr, factory );
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserCtrlPvt::clear()
|
void BrowserCtrlPvt::clear()
|
||||||
{
|
{
|
||||||
m_browser->clear();
|
m_browser->clear();
|
||||||
m_currentNode.clear();
|
m_currentNode.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BrowserCtrlPvt::onStructValueChanged( QtProperty *p, const QVariant &value )
|
void BrowserCtrlPvt::onStructValueChanged( QtProperty *p, const QVariant &value )
|
||||||
{
|
{
|
||||||
std::string k = p->propertyName().toUtf8().constData();
|
std::string k = p->propertyName().toUtf8().constData();
|
||||||
std::string v = value.toString().toUtf8().constData();
|
std::string v = value.toString().toUtf8().constData();
|
||||||
|
|
||||||
bool created = false;
|
bool created = false;
|
||||||
m_currentNode.p->setValueByName( v.c_str(), k.c_str(), &created );
|
m_currentNode.p->setValueByName( v.c_str(), k.c_str(), &created );
|
||||||
|
|
||||||
QString key = m_currentNode.name + "." + p->propertyName();
|
QString key = m_currentNode.name + "." + p->propertyName();
|
||||||
|
|
||||||
Q_EMIT modified();
|
Q_EMIT modified();
|
||||||
Q_EMIT valueChanged( key, value.toString() );
|
Q_EMIT valueChanged( key, value.toString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserCtrlPvt::createArray()
|
void BrowserCtrlPvt::createArray()
|
||||||
{
|
{
|
||||||
const NLGEORGES::CFormDfn *parentDfn;
|
const NLGEORGES::CFormDfn *parentDfn;
|
||||||
const NLGEORGES::CFormDfn *nodeDfn;
|
const NLGEORGES::CFormDfn *nodeDfn;
|
||||||
uint indexDfn;
|
uint indexDfn;
|
||||||
const NLGEORGES::CType *type;
|
const NLGEORGES::CType *type;
|
||||||
NLGEORGES::UFormDfn::TEntryType entryType;
|
NLGEORGES::UFormDfn::TEntryType entryType;
|
||||||
NLGEORGES::CFormElm *node;
|
NLGEORGES::CFormElm *node;
|
||||||
bool created;
|
bool created;
|
||||||
bool isArray;
|
bool isArray;
|
||||||
|
|
||||||
m_rootNode->createNodeByName( m_currentNode.name.toUtf8().constData(), &parentDfn, indexDfn, &nodeDfn, &type, &node, entryType, isArray, created );
|
m_rootNode->createNodeByName( m_currentNode.name.toUtf8().constData(), &parentDfn, indexDfn, &nodeDfn, &type, &node, entryType, isArray, created );
|
||||||
|
|
||||||
if( !created )
|
if( !created )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_currentNode.p = node;
|
m_currentNode.p = node;
|
||||||
|
|
||||||
NLGEORGES::CFormElmArray *arr = dynamic_cast< NLGEORGES::CFormElmArray* >( node );
|
NLGEORGES::CFormElmArray *arr = dynamic_cast< NLGEORGES::CFormElmArray* >( node );
|
||||||
QString idx = "[0]";
|
QString idx = "[0]";
|
||||||
arr->createNodeByName( idx.toUtf8().constData(), &parentDfn, indexDfn, &nodeDfn, &type, &node, entryType, isArray, created );
|
arr->createNodeByName( idx.toUtf8().constData(), &parentDfn, indexDfn, &nodeDfn, &type, &node, entryType, isArray, created );
|
||||||
|
|
||||||
std::string formName;
|
std::string formName;
|
||||||
arr->getFormName( formName, NULL );
|
arr->getFormName( formName, NULL );
|
||||||
|
|
||||||
Q_EMIT arrayResized( formName.c_str(), 1 );
|
Q_EMIT arrayResized( formName.c_str(), 1 );
|
||||||
Q_EMIT modified();
|
Q_EMIT modified();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserCtrlPvt::onArrayValueChanged( QtProperty *p, const QVariant &value )
|
void BrowserCtrlPvt::onArrayValueChanged( QtProperty *p, const QVariant &value )
|
||||||
{
|
{
|
||||||
// Newsize checks hacked in, because setting unsigned value type in QVariant crashes the property browser!
|
// Newsize checks hacked in, because setting unsigned value type in QVariant crashes the property browser!
|
||||||
int newSize = value.toInt();
|
int newSize = value.toInt();
|
||||||
if( newSize < 0 )
|
if( newSize < 0 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if( m_currentNode.p == NULL )
|
if( m_currentNode.p == NULL )
|
||||||
{
|
{
|
||||||
if( newSize != 1 )
|
if( newSize != 1 )
|
||||||
return;
|
return;
|
||||||
createArray();
|
createArray();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
NLGEORGES::CFormElmArray *arr = static_cast< NLGEORGES::CFormElmArray* >( m_currentNode.p );
|
NLGEORGES::CFormElmArray *arr = static_cast< NLGEORGES::CFormElmArray* >( m_currentNode.p );
|
||||||
std::string formName;
|
std::string formName;
|
||||||
arr->getFormName( formName, NULL );
|
arr->getFormName( formName, NULL );
|
||||||
|
|
||||||
int oldSize = arr->Elements.size();
|
int oldSize = arr->Elements.size();
|
||||||
|
|
||||||
if( newSize == oldSize )
|
if( newSize == oldSize )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if( newSize < oldSize )
|
if( newSize < oldSize )
|
||||||
{
|
{
|
||||||
for( int i = newSize; i < oldSize; i++ )
|
for( int i = newSize; i < oldSize; i++ )
|
||||||
{
|
{
|
||||||
delete arr->Elements[ i ].Element;
|
delete arr->Elements[ i ].Element;
|
||||||
}
|
}
|
||||||
|
|
||||||
arr->Elements.resize( newSize );
|
arr->Elements.resize( newSize );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
arr->Elements.resize( newSize );
|
arr->Elements.resize( newSize );
|
||||||
|
|
||||||
|
|
||||||
const NLGEORGES::CFormDfn *parentDfn;
|
const NLGEORGES::CFormDfn *parentDfn;
|
||||||
const NLGEORGES::CFormDfn *nodeDfn;
|
const NLGEORGES::CFormDfn *nodeDfn;
|
||||||
uint indexDfn;
|
uint indexDfn;
|
||||||
const NLGEORGES::CType *type;
|
const NLGEORGES::CType *type;
|
||||||
NLGEORGES::UFormDfn::TEntryType entryType;
|
NLGEORGES::UFormDfn::TEntryType entryType;
|
||||||
NLGEORGES::CFormElm *node;
|
NLGEORGES::CFormElm *node;
|
||||||
bool created;
|
bool created;
|
||||||
bool isArray;
|
bool isArray;
|
||||||
|
|
||||||
QString idx;
|
QString idx;
|
||||||
|
|
||||||
for( int i = oldSize; i < newSize; i++ )
|
for( int i = oldSize; i < newSize; i++ )
|
||||||
{
|
{
|
||||||
idx.clear();
|
idx.clear();
|
||||||
idx += "[";
|
idx += "[";
|
||||||
idx += QString::number( i );
|
idx += QString::number( i );
|
||||||
idx += "]";
|
idx += "]";
|
||||||
|
|
||||||
bool b;
|
bool b;
|
||||||
b = arr->createNodeByName( idx.toUtf8().constData(), &parentDfn, indexDfn, &nodeDfn, &type, &node, entryType, isArray, created );
|
b = arr->createNodeByName( idx.toUtf8().constData(), &parentDfn, indexDfn, &nodeDfn, &type, &node, entryType, isArray, created );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString name = formName.c_str();
|
QString name = formName.c_str();
|
||||||
Q_EMIT arrayResized( name, newSize );
|
Q_EMIT arrayResized( name, newSize );
|
||||||
Q_EMIT modified();
|
Q_EMIT modified();
|
||||||
|
|
||||||
if( newSize == 0 )
|
if( newSize == 0 )
|
||||||
m_currentNode.p = NULL;
|
m_currentNode.p = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserCtrlPvt::onValueChanged( QtProperty *p, const QVariant &value )
|
void BrowserCtrlPvt::onValueChanged( QtProperty *p, const QVariant &value )
|
||||||
{
|
{
|
||||||
if( m_currentNode.p == NULL )
|
if( m_currentNode.p == NULL )
|
||||||
{
|
{
|
||||||
if( m_currentNode.name.isEmpty() )
|
if( m_currentNode.name.isEmpty() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
onArrayValueChanged( p, value );
|
onArrayValueChanged( p, value );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( m_currentNode.p->isStruct() )
|
if( m_currentNode.p->isStruct() )
|
||||||
onStructValueChanged( p, value );
|
onStructValueChanged( p, value );
|
||||||
else
|
else
|
||||||
if( m_currentNode.p->isArray() )
|
if( m_currentNode.p->isArray() )
|
||||||
onArrayValueChanged( p, value );
|
onArrayValueChanged( p, value );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,78 +1,78 @@
|
|||||||
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||||
// Copyright (C) 2010 Winch Gate Property Limited
|
// Copyright (C) 2010 Winch Gate Property Limited
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU Affero General Public License as
|
// it under the terms of the GNU Affero General Public License as
|
||||||
// published by the Free Software Foundation, either version 3 of the
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
// License, or (at your option) any later version.
|
// License, or (at your option) any later version.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU Affero General Public License for more details.
|
// GNU Affero General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU Affero General Public License
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
// Project includes
|
// Project includes
|
||||||
#include "tile_editor_plugin.h"
|
#include "tile_editor_plugin.h"
|
||||||
#include "tile_editor_main_window.h"
|
#include "tile_editor_main_window.h"
|
||||||
#include "../core/icore.h"
|
#include "../core/icore.h"
|
||||||
#include "../core/menu_manager.h"
|
#include "../core/menu_manager.h"
|
||||||
#include "../core/core_constants.h"
|
#include "../core/core_constants.h"
|
||||||
|
|
||||||
// Qt includes
|
// Qt includes
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
#include <QtGui/QMessageBox>
|
#include <QtGui/QMessageBox>
|
||||||
#include <QtGui/QMainWindow>
|
#include <QtGui/QMainWindow>
|
||||||
#include <QtGui/QMenu>
|
#include <QtGui/QMenu>
|
||||||
#include <QtGui/QAction>
|
#include <QtGui/QAction>
|
||||||
#include <QtGui/QMenuBar>
|
#include <QtGui/QMenuBar>
|
||||||
|
|
||||||
// NeL includes
|
// NeL includes
|
||||||
#include "nel/misc/debug.h"
|
#include "nel/misc/debug.h"
|
||||||
|
|
||||||
using namespace TileEditorPluginQt;
|
using namespace TileEditorPluginQt;
|
||||||
|
|
||||||
TileEditorPlugin::~TileEditorPlugin()
|
TileEditorPlugin::~TileEditorPlugin()
|
||||||
{
|
{
|
||||||
Q_FOREACH(QObject *obj, m_autoReleaseObjects)
|
Q_FOREACH(QObject *obj, m_autoReleaseObjects)
|
||||||
{
|
{
|
||||||
m_plugMan->removeObject(obj);
|
m_plugMan->removeObject(obj);
|
||||||
}
|
}
|
||||||
qDeleteAll(m_autoReleaseObjects);
|
qDeleteAll(m_autoReleaseObjects);
|
||||||
m_autoReleaseObjects.clear();
|
m_autoReleaseObjects.clear();
|
||||||
|
|
||||||
delete m_LibContext;
|
delete m_LibContext;
|
||||||
m_LibContext = NULL;
|
m_LibContext = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TileEditorPlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString)
|
bool TileEditorPlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString)
|
||||||
{
|
{
|
||||||
Q_UNUSED(errorString);
|
Q_UNUSED(errorString);
|
||||||
m_plugMan = pluginManager;
|
m_plugMan = pluginManager;
|
||||||
addAutoReleasedObject(new TileEditorContext());
|
addAutoReleasedObject(new TileEditorContext());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TileEditorPlugin::extensionsInitialized()
|
void TileEditorPlugin::extensionsInitialized()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void TileEditorPlugin::setNelContext(NLMISC::INelContext *nelContext)
|
void TileEditorPlugin::setNelContext(NLMISC::INelContext *nelContext)
|
||||||
{
|
{
|
||||||
#ifdef NL_OS_WINDOWS
|
#ifdef NL_OS_WINDOWS
|
||||||
// Ensure that a context doesn't exist yet.
|
// Ensure that a context doesn't exist yet.
|
||||||
// This only applies to platforms without PIC, e.g. Windows.
|
// This only applies to platforms without PIC, e.g. Windows.
|
||||||
nlassert(!NLMISC::INelContext::isContextInitialised());
|
nlassert(!NLMISC::INelContext::isContextInitialised());
|
||||||
#endif // NL_OS_WINDOWS
|
#endif // NL_OS_WINDOWS
|
||||||
m_LibContext = new NLMISC::CLibraryContext(*nelContext);
|
m_LibContext = new NLMISC::CLibraryContext(*nelContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TileEditorPlugin::addAutoReleasedObject(QObject *obj)
|
void TileEditorPlugin::addAutoReleasedObject(QObject *obj)
|
||||||
{
|
{
|
||||||
m_plugMan->addObject(obj);
|
m_plugMan->addObject(obj);
|
||||||
m_autoReleaseObjects.prepend(obj);
|
m_autoReleaseObjects.prepend(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_EXPORT_PLUGIN(TileEditorPlugin)
|
Q_EXPORT_PLUGIN(TileEditorPlugin)
|
||||||
|
Loading…
Reference in New Issue