Apply changes.

--HG--
branch : gsoc2014-dfighter
hg/feature/cdb-packed
dfighter1985 10 years ago
parent 1b7b081c60
commit aa95cc3c4b

@ -34,6 +34,7 @@ public:
{ {
mgr = new QtVariantPropertyManager(); mgr = new QtVariantPropertyManager();
factory = new QtVariantEditorFactory(); factory = new QtVariantEditorFactory();
m_currentNode = NULL;
} }
~BrowserCtrlPvt() ~BrowserCtrlPvt()
@ -74,12 +75,14 @@ public:
setupElement( elm ); setupElement( elm );
} }
m_currentNode = st;
m_browser->setFactoryForManager( mgr, factory ); m_browser->setFactoryForManager( mgr, factory );
} }
void clear() void clear()
{ {
m_browser->clear(); m_browser->clear();
m_currentNode = NULL;
} }
void setBrowser( QtTreePropertyBrowser *browser ) void setBrowser( QtTreePropertyBrowser *browser )
@ -87,10 +90,25 @@ public:
m_browser = browser; m_browser = browser;
} }
void onValueChanged( QtProperty *p, const QVariant &value )
{
if( m_currentNode == NULL )
return;
std::string k = p->propertyName().toUtf8().constData();
std::string v = value.toString().toUtf8().constData();
m_currentNode->setValueByName( v.c_str(), k.c_str() );
}
QtVariantPropertyManager* manager() const{ return mgr; }
private: private:
QtVariantPropertyManager *mgr; QtVariantPropertyManager *mgr;
QtVariantEditorFactory *factory; QtVariantEditorFactory *factory;
QtTreePropertyBrowser *m_browser; QtTreePropertyBrowser *m_browser;
NLGEORGES::UFormElm *m_currentNode;
}; };
BrowserCtrl::BrowserCtrl( QtTreePropertyBrowser *browser ) : BrowserCtrl::BrowserCtrl( QtTreePropertyBrowser *browser ) :
@ -108,6 +126,7 @@ BrowserCtrl::~BrowserCtrl()
void BrowserCtrl::clicked( const QModelIndex &idx ) void BrowserCtrl::clicked( const QModelIndex &idx )
{ {
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() );
@ -126,5 +145,28 @@ void BrowserCtrl::clicked( const QModelIndex &idx )
NLGEORGES::CFormElmStruct *st = static_cast< NLGEORGES::CFormElmStruct* >( node ); NLGEORGES::CFormElmStruct *st = static_cast< NLGEORGES::CFormElmStruct* >( node );
m_pvt->setupForm( st ); m_pvt->setupForm( st );
enableMgrConnections();
}
void BrowserCtrl::onValueChanged( QtProperty *p, const QVariant &value )
{
m_pvt->onValueChanged( p, value );
}
void BrowserCtrl::enableMgrConnections()
{
QtVariantPropertyManager *mgr = m_pvt->manager();
connect( mgr, SIGNAL( valueChanged( QtProperty*, const QVariant & ) ),
this, SLOT( onValueChanged( QtProperty*, const QVariant & ) ) );
}
void BrowserCtrl::disableMgrConnections()
{
QtVariantPropertyManager *mgr = m_pvt->manager();
disconnect( mgr, SIGNAL( valueChanged( QtProperty*, const QVariant & ) ),
this, SLOT( onValueChanged( QtProperty*, const QVariant & ) ) );
} }

@ -10,6 +10,8 @@ namespace NLGEORGES
class QtTreePropertyBrowser; class QtTreePropertyBrowser;
class QModelIndex; class QModelIndex;
class QVariant;
class QtProperty;
class BrowserCtrlPvt; class BrowserCtrlPvt;
@ -24,9 +26,15 @@ public:
public Q_SLOTS: public Q_SLOTS:
void clicked( const QModelIndex &idx ); void clicked( const QModelIndex &idx );
private Q_SLOTS:
void onValueChanged( QtProperty *p, const QVariant &value );
private: private:
BrowserCtrlPvt *m_pvt; void enableMgrConnections();
void disableMgrConnections();
BrowserCtrlPvt *m_pvt;
NLGEORGES::UForm *m_form; NLGEORGES::UForm *m_form;
}; };

Loading…
Cancel
Save