Apply changes.
This commit is contained in:
parent
4dcbd2182d
commit
2b3cbe52a8
2 changed files with 52 additions and 2 deletions
|
@ -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:
|
private Q_SLOTS:
|
||||||
BrowserCtrlPvt *m_pvt;
|
void onValueChanged( QtProperty *p, const QVariant &value );
|
||||||
|
|
||||||
|
private:
|
||||||
|
void enableMgrConnections();
|
||||||
|
void disableMgrConnections();
|
||||||
|
|
||||||
|
|
||||||
|
BrowserCtrlPvt *m_pvt;
|
||||||
NLGEORGES::UForm *m_form;
|
NLGEORGES::UForm *m_form;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue