From 3d6a9fb139f1dbf977a7f0f9d05913786c71ca65 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Tue, 2 Sep 2014 23:37:16 +0200 Subject: [PATCH] Implemented add button. --- .../georges_editor/georges_typ_dialog.cpp | 29 +++++++++++++++++++ 1 file changed, 29 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 2f79697c4..b64368535 100644 --- a/code/studio/src/plugins/georges_editor/georges_typ_dialog.cpp +++ b/code/studio/src/plugins/georges_editor/georges_typ_dialog.cpp @@ -1,6 +1,9 @@ #include "georges_typ_dialog.h" #include "georges.h" +#include +#include + class GeorgesTypDialogPvt { public: @@ -55,6 +58,32 @@ void GeorgesTypDialog::write() void GeorgesTypDialog::onAddClicked() { + QString label = QInputDialog::getText( this, + tr( "Adding new definition" ), + tr( "Please specify the label" ) ); + if( label.isEmpty() ) + return; + + QList< QTreeWidgetItem* > l = m_ui.tree->findItems( label, Qt::MatchExactly, 0 ); + if( !l.isEmpty() ) + { + QMessageBox::information( this, + tr( "Failed to add item" ), + tr( "You can't add an item with the same label more than once!" ) ); + return; + } + + QTreeWidgetItem *item = new QTreeWidgetItem(); + item->setFlags( Qt::ItemIsEditable | Qt::ItemIsEnabled ); + item->setText( 0, label ); + item->setText( 1, "" ); + m_ui.tree->addTopLevelItem( item ); + + NLGEORGES::CType::CDefinition def; + def.Label = label.toUtf8().constData(); + def.Value = ""; + m_pvt->typ->Definitions.push_back( def ); + } void GeorgesTypDialog::onRemoveClicked()