From c8c28a8d908b7f19e6721a0fb49a90e9bca582bb Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Wed, 10 Sep 2014 19:14:26 +0200 Subject: [PATCH] Allow editing of the comment section, and save comments when saving. --- .../src/plugins/georges_editor/georges_dfn_dialog.cpp | 8 ++++++++ .../src/plugins/georges_editor/georges_dfn_dialog.h | 1 + .../src/plugins/georges_editor/georges_dfn_dialog.ui | 2 +- .../plugins/georges_editor/georges_treeview_dialog.cpp | 8 ++++++++ .../src/plugins/georges_editor/georges_treeview_dialog.h | 1 + .../src/plugins/georges_editor/georges_treeview_form.ui | 6 +++++- .../src/plugins/georges_editor/georges_typ_dialog.cpp | 8 ++++++++ .../src/plugins/georges_editor/georges_typ_dialog.h | 1 + .../src/plugins/georges_editor/georges_typ_dialog.ui | 6 +++++- 9 files changed, 38 insertions(+), 3 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 30fa38c7d..c7244273e 100644 --- a/code/studio/src/plugins/georges_editor/georges_dfn_dialog.cpp +++ b/code/studio/src/plugins/georges_editor/georges_dfn_dialog.cpp @@ -82,6 +82,8 @@ bool GeorgesDFNDialog::load( const QString &fileName ) m_fileName = fileName; + connect(m_ui.commentsEdit, SIGNAL(textChanged()), this, SLOT(onCommentsEdited())); + return true; } @@ -91,6 +93,7 @@ void GeorgesDFNDialog::write() setWindowTitle( windowTitle().remove( "*" ) ); m_pvt->dfn->Header.Log = m_ui.logEdit->toPlainText().toUtf8().constData(); + m_pvt->dfn->Header.Comments = m_ui.commentsEdit->toPlainText().toUtf8().constData(); NLMISC::COFile file; if( !file.open( m_fileName.toUtf8().constData(), false, true, false ) ) @@ -178,6 +181,11 @@ void GeorgesDFNDialog::onValueChanged( const QString &key, const QString &value } } +void GeorgesDFNDialog::onCommentsEdited() +{ + onModified(); +} + void GeorgesDFNDialog::loadDfn() { m_pvt->ctrl->setDFN( m_pvt->dfn ); 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 7757779fe..edb67144c 100644 --- a/code/studio/src/plugins/georges_editor/georges_dfn_dialog.h +++ b/code/studio/src/plugins/georges_editor/georges_dfn_dialog.h @@ -44,6 +44,7 @@ private Q_SLOTS: void onCurrentRowChanged( int row ); void onValueChanged( const QString& key, const QString &value ); + void onCommentsEdited(); private: void loadDfn(); diff --git a/code/studio/src/plugins/georges_editor/georges_dfn_dialog.ui b/code/studio/src/plugins/georges_editor/georges_dfn_dialog.ui index 3cbdb7419..70b5bd265 100644 --- a/code/studio/src/plugins/georges_editor/georges_dfn_dialog.ui +++ b/code/studio/src/plugins/georges_editor/georges_dfn_dialog.ui @@ -98,7 +98,7 @@ - Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + Qt::TextEditorInteraction diff --git a/code/studio/src/plugins/georges_editor/georges_treeview_dialog.cpp b/code/studio/src/plugins/georges_editor/georges_treeview_dialog.cpp index 297769b6c..62d5ac653 100644 --- a/code/studio/src/plugins/georges_editor/georges_treeview_dialog.cpp +++ b/code/studio/src/plugins/georges_editor/georges_treeview_dialog.cpp @@ -323,6 +323,8 @@ namespace GeorgesQt QFileInfo info( fileName ); setWindowTitle( info.fileName() ); + connect(m_ui.commentEdit, SIGNAL(textChanged()), this, SLOT(onCommentsEdited())); + return true; } @@ -330,6 +332,7 @@ namespace GeorgesQt { NLGEORGES::CForm *form = static_cast< NLGEORGES::CForm* >( m_form ); form->Header.Log = m_ui.logEdit->toPlainText().toUtf8().constData(); + form->Header.Comments = m_ui.commentEdit->toPlainText().toUtf8().constData(); NLMISC::COFile file; std::string s = m_fileName.toUtf8().constData(); @@ -591,6 +594,11 @@ namespace GeorgesQt m_browserCtrl->clicked( idx ); } + void CGeorgesTreeViewDialog::onCommentsEdited() + { + modifiedFile(); + } + void CGeorgesTreeViewDialog::closeEvent(QCloseEvent *event) { Q_EMIT closing(); diff --git a/code/studio/src/plugins/georges_editor/georges_treeview_dialog.h b/code/studio/src/plugins/georges_editor/georges_treeview_dialog.h index 4595cc289..87c64ead9 100644 --- a/code/studio/src/plugins/georges_editor/georges_treeview_dialog.h +++ b/code/studio/src/plugins/georges_editor/georges_treeview_dialog.h @@ -103,6 +103,7 @@ namespace GeorgesQt void onValueChanged( const QString &key, const QString &value ); void onVStructChanged( const QString &name ); void onRenameArrayEntry(); + void onCommentsEdited(); private: void log( const QString &msg ); diff --git a/code/studio/src/plugins/georges_editor/georges_treeview_form.ui b/code/studio/src/plugins/georges_editor/georges_treeview_form.ui index 42d9afcf9..43d50e103 100644 --- a/code/studio/src/plugins/georges_editor/georges_treeview_form.ui +++ b/code/studio/src/plugins/georges_editor/georges_treeview_form.ui @@ -112,7 +112,11 @@ - + + + Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + 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 d042c6d33..ab4cc0472 100644 --- a/code/studio/src/plugins/georges_editor/georges_typ_dialog.cpp +++ b/code/studio/src/plugins/georges_editor/georges_typ_dialog.cpp @@ -82,6 +82,8 @@ bool GeorgesTypDialog::load( const QString &fileName ) QFileInfo info( fileName ); setWindowTitle( info.fileName() ); + connect( m_ui.commentEdit, SIGNAL( textChanged() ), this, SLOT( onCommentsEdited() ) ); + return true; } @@ -96,6 +98,7 @@ void GeorgesTypDialog::write() xml.init( &file ); m_pvt->typ->Header.Log = m_ui.logEdit->toPlainText().toUtf8().constData(); + m_pvt->typ->Header.Comments = m_ui.commentEdit->toPlainText().toUtf8().constData(); m_pvt->typ->write( xml.getDocument() ); xml.flush(); @@ -227,6 +230,11 @@ void GeorgesTypDialog::onModified( const QString &k, const QString &v ) onModified(); } +void GeorgesTypDialog::onCommentsEdited() +{ + onModified(); +} + void GeorgesTypDialog::setupConnections() { connect( m_ui.addButton, SIGNAL( clicked( bool ) ), this, SLOT( onAddClicked() ) ); 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 6aa7f27f9..5a6c09e61 100644 --- a/code/studio/src/plugins/georges_editor/georges_typ_dialog.h +++ b/code/studio/src/plugins/georges_editor/georges_typ_dialog.h @@ -45,6 +45,7 @@ private Q_SLOTS: void onItemChanged( QTreeWidgetItem *item, int column ); void onModified(); void onModified( const QString &k, const QString &v ); + void onCommentsEdited(); private: void setupConnections(); diff --git a/code/studio/src/plugins/georges_editor/georges_typ_dialog.ui b/code/studio/src/plugins/georges_editor/georges_typ_dialog.ui index 6cd080579..8978fa13b 100644 --- a/code/studio/src/plugins/georges_editor/georges_typ_dialog.ui +++ b/code/studio/src/plugins/georges_editor/georges_typ_dialog.ui @@ -118,7 +118,11 @@ - + + + Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + +