From c2738ecf733cf157ad8f1b7f2890cd85a248dce8 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Wed, 3 Sep 2014 16:26:52 +0200 Subject: [PATCH] Mark the typ dialog modified after a modification. --- .../georges_editor/georges_typ_dialog.cpp | 6 +++ .../georges_editor/georges_typ_dialog.h | 1 + .../georges_editor/typ_browser_ctrl.cpp | 49 +++++++++++++++++++ .../plugins/georges_editor/typ_browser_ctrl.h | 3 ++ 4 files changed, 59 insertions(+) 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 539de4f96..f6f470288 100644 --- a/code/studio/src/plugins/georges_editor/georges_typ_dialog.cpp +++ b/code/studio/src/plugins/georges_editor/georges_typ_dialog.cpp @@ -169,12 +169,18 @@ void GeorgesTypDialog::onModified() Q_EMIT modified(); } +void GeorgesTypDialog::onModified( const QString &k, const QString &v ) +{ + onModified(); +} + void GeorgesTypDialog::setupConnections() { connect( m_ui.addButton, SIGNAL( clicked( bool ) ), this, SLOT( onAddClicked() ) ); connect( m_ui.removeButton, SIGNAL( clicked( bool ) ), this, SLOT( onRemoveClicked() ) ); connect( m_ui.tree, SIGNAL( itemChanged( QTreeWidgetItem*, int ) ), this, SLOT( onItemChanged( QTreeWidgetItem*, int ) ) ); + connect( m_pvt->ctrl, SIGNAL( modified( const QString&, const QString& ) ), this, SLOT( onModified( const QString&, const QString& ) ) ); } void GeorgesTypDialog::log( const QString &msg ) diff --git a/code/studio/src/plugins/georges_editor/georges_typ_dialog.h b/code/studio/src/plugins/georges_editor/georges_typ_dialog.h index ac203b8f6..cba5d4a41 100644 --- a/code/studio/src/plugins/georges_editor/georges_typ_dialog.h +++ b/code/studio/src/plugins/georges_editor/georges_typ_dialog.h @@ -25,6 +25,7 @@ private Q_SLOTS: void onItemChanged( QTreeWidgetItem *item, int column ); void onModified(); + void onModified( const QString &k, const QString &v ); private: void setupConnections(); 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 49d5e75fa..12f921c5f 100644 --- a/code/studio/src/plugins/georges_editor/typ_browser_ctrl.cpp +++ b/code/studio/src/plugins/georges_editor/typ_browser_ctrl.cpp @@ -7,6 +7,43 @@ #include "nel/georges/type.h" +namespace +{ + QString typeToString( int v ) + { + QString s; + + switch( v ) + { + case NLGEORGES::UType::UnsignedInt: s = "UnsignedInt"; break; + case NLGEORGES::UType::SignedInt: s = "SignedInt"; break; + case NLGEORGES::UType::Double: s = "Double"; break; + case NLGEORGES::UType::String: s = "String"; break; + case NLGEORGES::UType::Color: s = "Color"; break; + } + + return s; + } + + QString uitypeToString( int v ) + { + QString s; + + switch( v ) + { + case NLGEORGES::CType::Edit: s = "Edit"; break; + case NLGEORGES::CType::EditSpin: s = "EditSpin"; break; + case NLGEORGES::CType::NonEditableCombo: s = "NonEditableCombo"; break; + case NLGEORGES::CType::FileBrowser: s = "FileBrowser"; break; + case NLGEORGES::CType::BigEdit: s = "BigEdit"; break; + case NLGEORGES::CType::ColorEdit: s = "ColorEdit"; break; + case NLGEORGES::CType::IconWidget: s = "IconWidget"; break; + } + + return s; + } +} + TypBrowserCtrl::TypBrowserCtrl( QObject *parent ) : QObject( parent ) { @@ -106,20 +143,32 @@ void TypBrowserCtrl::onVariantValueChanged( QtProperty *p, const QVariant &v ) { m_typ->Increment = v.toString().toUtf8().constData(); } + else + return; + + Q_EMIT modified( n, v.toString().toUtf8().constData() ); } void TypBrowserCtrl::onEnumValueChanged( QtProperty *p, int v ) { QString n = p->propertyName(); + QString value; + if( n == "type" ) { m_typ->Type = NLGEORGES::UType::TType( v ); + value = typeToString( v ); } else if( n == "uitype" ) { m_typ->UIType = NLGEORGES::CType::TUI( v ); + value = uitypeToString( v ); } + else + return; + + Q_EMIT modified( n, value ); } void TypBrowserCtrl::enableMgrConnections() 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 d565152c4..f1d361604 100644 --- a/code/studio/src/plugins/georges_editor/typ_browser_ctrl.h +++ b/code/studio/src/plugins/georges_editor/typ_browser_ctrl.h @@ -28,6 +28,9 @@ public: void setTyp( NLGEORGES::CType *typ ){ m_typ = typ; } void setBrowser( QtTreePropertyBrowser *browser ){ m_browser = browser; } +Q_SIGNALS: + void modified( const QString &k, const QString &v ); + private Q_SLOTS: void onVariantValueChanged( QtProperty *p, const QVariant &v ); void onEnumValueChanged( QtProperty *p, int v );