From c65afd1f36e925a4cb99a8cc86e0a3fea3907c3b Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Tue, 2 Sep 2014 23:25:47 +0200 Subject: [PATCH] Implemented definition editing. --- .../georges_editor/georges_typ_dialog.cpp | 20 +++++++++++++++++++ .../georges_editor/georges_typ_dialog.h | 2 ++ 2 files changed, 22 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 c3ea462ec..2f79697c4 100644 --- a/code/studio/src/plugins/georges_editor/georges_typ_dialog.cpp +++ b/code/studio/src/plugins/georges_editor/georges_typ_dialog.cpp @@ -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 ); 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 76d177b35..8cca31fe6 100644 --- a/code/studio/src/plugins/georges_editor/georges_typ_dialog.h +++ b/code/studio/src/plugins/georges_editor/georges_typ_dialog.h @@ -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 );