From c51b5198450505806847fe300ba5ed347040c166 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Tue, 2 Sep 2014 19:26:02 +0200 Subject: [PATCH] Implemented add and remove buttons. --HG-- branch : dfighter-tools --- code/nel/include/nel/georges/form_dfn.h | 4 ++++ code/nel/src/georges/form_dfn.cpp | 15 +++++++++++++++ .../plugins/georges_editor/georges_dfn_dialog.cpp | 7 +++++-- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/code/nel/include/nel/georges/form_dfn.h b/code/nel/include/nel/georges/form_dfn.h index fe6fb473a..a93dcbe48 100644 --- a/code/nel/include/nel/georges/form_dfn.h +++ b/code/nel/include/nel/georges/form_dfn.h @@ -162,6 +162,10 @@ public: NLMISC::CSmartPtr Parent; }; + void addEntry( const std::string &name ); + + void removeEntry( uint idx ); + // ** IO functions void write (xmlDocPtr root, const char *filename); diff --git a/code/nel/src/georges/form_dfn.cpp b/code/nel/src/georges/form_dfn.cpp index fa748535a..d4a16bb50 100644 --- a/code/nel/src/georges/form_dfn.cpp +++ b/code/nel/src/georges/form_dfn.cpp @@ -41,6 +41,21 @@ void warning (bool exception, const char *format, ... ); // *************************************************************************** +void CFormDfn::addEntry( const std::string &name ) +{ + CEntry entry; + entry.setName( name.c_str() ); + Entries.push_back( entry ); +} + +void CFormDfn::removeEntry( uint idx ) +{ + std::vector< CEntry >::iterator itr = Entries.begin() + idx; + Entries.erase( itr ); +} + +// *************************************************************************** + void CFormDfn::write (xmlDocPtr doc, const char *filename) { // Save filename diff --git a/code/studio/src/plugins/georges_editor/georges_dfn_dialog.cpp b/code/studio/src/plugins/georges_editor/georges_dfn_dialog.cpp index ef9abecf7..89af2d4ea 100644 --- a/code/studio/src/plugins/georges_editor/georges_dfn_dialog.cpp +++ b/code/studio/src/plugins/georges_editor/georges_dfn_dialog.cpp @@ -33,8 +33,8 @@ GeorgesDockWidget( parent ) { m_ui.setupUi( this ); - m_ui.addButton->setEnabled( false ); - m_ui.removeButton->setEnabled( false ); + //m_ui.addButton->setEnabled( false ); + //m_ui.removeButton->setEnabled( false ); m_pvt = new GeorgesDFNDialogPvt(); m_pvt->ctrl->setBrowser( m_ui.browser ); @@ -119,6 +119,7 @@ void GeorgesDFNDialog::onAddClicked() } m_ui.list->addItem( name ); + m_pvt->dfn->addEntry( name.toUtf8().constData() ); } void GeorgesDFNDialog::onRemoveClicked() @@ -129,6 +130,8 @@ void GeorgesDFNDialog::onRemoveClicked() QListWidgetItem *item = m_ui.list->takeItem( row ); delete item; + + m_pvt->dfn->removeEntry( row ); } void GeorgesDFNDialog::onCurrentRowChanged( int row )