From 83cc99bede06dacde03a434ade7dd63c9bf5d732 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Wed, 3 Sep 2014 19:37:49 +0200 Subject: [PATCH] Added support for new DFN document creation. --- .../georges_editor/georges_dfn_dialog.cpp | 50 +++++++++++++------ .../georges_editor/georges_dfn_dialog.h | 2 + .../georges_editor/georges_editor_form.cpp | 11 ++++ 3 files changed, 47 insertions(+), 16 deletions(-) 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 6ec7c80d2..d7d329dac 100644 --- a/code/studio/src/plugins/georges_editor/georges_dfn_dialog.cpp +++ b/code/studio/src/plugins/georges_editor/georges_dfn_dialog.cpp @@ -77,22 +77,8 @@ bool GeorgesDFNDialog::load( const QString &fileName ) NLGEORGES::CFormDfn *cdfn = static_cast< NLGEORGES::CFormDfn* >( udfn ); m_pvt->dfn = cdfn; - m_pvt->ctrl->setDFN( cdfn ); - - uint c = m_pvt->dfn->getNumEntry(); - for( uint i = 0; i < c; i++ ) - { - NLGEORGES::CFormDfn::CEntry &entry = m_pvt->dfn->getEntry( i ); - m_ui.list->addItem( entry.getName().c_str() ); - } - - if( c > 0 ) - { - m_ui.list->setCurrentRow( 0 ); - } - - m_ui.commentsEdit->setPlainText( cdfn->getComment().c_str() ); - m_ui.logEdit->setPlainText( cdfn->Header.Log.c_str() ); + + loadDfn(); m_fileName = fileName; @@ -119,6 +105,18 @@ void GeorgesDFNDialog::write() file.close(); } +void GeorgesDFNDialog::newDocument( const QString &fileName ) +{ + m_fileName = fileName; + QFileInfo info( fileName ); + setWindowTitle( info.fileName() + "*" ); + setModified( true ); + + m_pvt->dfn = new NLGEORGES::CFormDfn(); + + loadDfn(); +} + void GeorgesDFNDialog::onAddClicked() { QString name = QInputDialog::getText( this, @@ -178,6 +176,26 @@ void GeorgesDFNDialog::onValueChanged( const QString &key, const QString &value } } +void GeorgesDFNDialog::loadDfn() +{ + m_pvt->ctrl->setDFN( m_pvt->dfn ); + + uint c = m_pvt->dfn->getNumEntry(); + for( uint i = 0; i < c; i++ ) + { + NLGEORGES::CFormDfn::CEntry &entry = m_pvt->dfn->getEntry( i ); + m_ui.list->addItem( entry.getName().c_str() ); + } + + if( c > 0 ) + { + m_ui.list->setCurrentRow( 0 ); + } + + m_ui.commentsEdit->setPlainText( m_pvt->dfn->getComment().c_str() ); + m_ui.logEdit->setPlainText( m_pvt->dfn->Header.Log.c_str() ); +} + void GeorgesDFNDialog::onModified() { if( !isModified() ) diff --git a/code/studio/src/plugins/georges_editor/georges_dfn_dialog.h b/code/studio/src/plugins/georges_editor/georges_dfn_dialog.h index 19268b17d..2d6dc4113 100644 --- a/code/studio/src/plugins/georges_editor/georges_dfn_dialog.h +++ b/code/studio/src/plugins/georges_editor/georges_dfn_dialog.h @@ -33,6 +33,7 @@ public: bool load( const QString &fileName ); void write(); + void newDocument( const QString &fileName ); Q_SIGNALS: void modified(); @@ -45,6 +46,7 @@ private Q_SLOTS: void onValueChanged( const QString& key, const QString &value ); private: + void loadDfn(); void onModified(); void log( const QString &msg ); void setupConnections(); diff --git a/code/studio/src/plugins/georges_editor/georges_editor_form.cpp b/code/studio/src/plugins/georges_editor/georges_editor_form.cpp index b68e48dd4..cb4069818 100644 --- a/code/studio/src/plugins/georges_editor/georges_editor_form.cpp +++ b/code/studio/src/plugins/georges_editor/georges_editor_form.cpp @@ -158,6 +158,17 @@ namespace GeorgesQt void GeorgesEditorForm::newDfn() { + QString fileName = QFileDialog::getSaveFileName( this, + tr( "New Definition" ), + "", + "Definition files (*.dfn)" ); + if( fileName.isEmpty() ) + return; + + GeorgesDFNDialog *d = new GeorgesDFNDialog(); + d->newDocument( fileName ); + addGeorgesWidget( d ); + setModified(); } void GeorgesEditorForm::newForm()