Implemented definition editing.

This commit is contained in:
dfighter1985 2014-09-02 23:25:47 +02:00
parent 3336561d3f
commit c65afd1f36
2 changed files with 22 additions and 0 deletions

View file

@ -78,10 +78,29 @@ void GeorgesTypDialog::onRemoveClicked()
}
void GeorgesTypDialog::onItemChanged( QTreeWidgetItem *item, int column )
{
int i = 0;
for( i = 0; i < m_ui.tree->topLevelItemCount(); i++ )
{
if( item == m_ui.tree->topLevelItem( i ) )
break;
}
NLGEORGES::CType::CDefinition &def = m_pvt->typ->Definitions[ i ];
if( i == 0 )
def.Label = item->text( 0 ).toUtf8().constData();
else
def.Value = item->text( 1 ).toUtf8().constData();
}
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 ) ) );
}
void GeorgesTypDialog::log( const QString &msg )
@ -101,6 +120,7 @@ void GeorgesTypDialog::loadTyp()
NLGEORGES::CType::CDefinition &def = *itr;
QTreeWidgetItem *item = new QTreeWidgetItem();
item->setFlags( Qt::ItemIsEditable | Qt::ItemIsEnabled );
item->setText( 0, def.Label.c_str() );
item->setText( 1, def.Value.c_str() );
m_ui.tree->addTopLevelItem( item );

View file

@ -20,6 +20,8 @@ private Q_SLOTS:
void onAddClicked();
void onRemoveClicked();
void onItemChanged( QTreeWidgetItem *item, int column );
private:
void setupConnections();
void log( const QString &msg );