Implemented add and remove buttons.

This commit is contained in:
dfighter1985 2014-09-02 19:26:02 +02:00
parent bca9fd9347
commit a875e66696
3 changed files with 24 additions and 2 deletions

View file

@ -162,6 +162,10 @@ public:
NLMISC::CSmartPtr<CFormDfn> Parent; NLMISC::CSmartPtr<CFormDfn> Parent;
}; };
void addEntry( const std::string &name );
void removeEntry( uint idx );
// ** IO functions // ** IO functions
void write (xmlDocPtr root, const char *filename); void write (xmlDocPtr root, const char *filename);

View file

@ -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) void CFormDfn::write (xmlDocPtr doc, const char *filename)
{ {
// Save filename // Save filename

View file

@ -33,8 +33,8 @@ GeorgesDockWidget( parent )
{ {
m_ui.setupUi( this ); m_ui.setupUi( this );
m_ui.addButton->setEnabled( false ); //m_ui.addButton->setEnabled( false );
m_ui.removeButton->setEnabled( false ); //m_ui.removeButton->setEnabled( false );
m_pvt = new GeorgesDFNDialogPvt(); m_pvt = new GeorgesDFNDialogPvt();
m_pvt->ctrl->setBrowser( m_ui.browser ); m_pvt->ctrl->setBrowser( m_ui.browser );
@ -119,6 +119,7 @@ void GeorgesDFNDialog::onAddClicked()
} }
m_ui.list->addItem( name ); m_ui.list->addItem( name );
m_pvt->dfn->addEntry( name.toUtf8().constData() );
} }
void GeorgesDFNDialog::onRemoveClicked() void GeorgesDFNDialog::onRemoveClicked()
@ -129,6 +130,8 @@ void GeorgesDFNDialog::onRemoveClicked()
QListWidgetItem *item = m_ui.list->takeItem( row ); QListWidgetItem *item = m_ui.list->takeItem( row );
delete item; delete item;
m_pvt->dfn->removeEntry( row );
} }
void GeorgesDFNDialog::onCurrentRowChanged( int row ) void GeorgesDFNDialog::onCurrentRowChanged( int row )