From b21b19c90c55defc47fc5d82140cd37ef1ca553f Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Wed, 3 Sep 2014 19:28:01 +0200 Subject: [PATCH] Added support for new typ document creation. --- .../georges_editor/georges_editor_form.cpp | 54 ++++++++++++------- .../georges_editor/georges_editor_form.h | 2 + .../georges_editor/georges_typ_dialog.cpp | 12 +++++ .../georges_editor/georges_typ_dialog.h | 1 + 4 files changed, 50 insertions(+), 19 deletions(-) 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 3bcbb91dc..b68e48dd4 100644 --- a/code/studio/src/plugins/georges_editor/georges_editor_form.cpp +++ b/code/studio/src/plugins/georges_editor/georges_editor_form.cpp @@ -142,6 +142,18 @@ namespace GeorgesQt void GeorgesEditorForm::newTyp() { + QString fileName = QFileDialog::getSaveFileName( this, + tr( "New Type" ), + "", + "Type files (*.typ)" ); + if( fileName.isEmpty() ) + return; + + + GeorgesTypDialog *d = new GeorgesTypDialog(); + d->newDocument( fileName ); + addGeorgesWidget( d ); + setModified(); } void GeorgesEditorForm::newDfn() @@ -190,6 +202,28 @@ namespace GeorgesQt settings->sync(); } + void GeorgesEditorForm::addGeorgesWidget( GeorgesDockWidget *w ) + { + w->setUndoStack(UndoStack); + m_lastActiveDock = w; + m_dockedWidgets.append(w); + + connect(m_dockedWidgets.last(), SIGNAL(closing()), this, SLOT(closingTreeView())); + connect(m_dockedWidgets.last(), SIGNAL(visibilityChanged(bool)), m_dockedWidgets.last(), SLOT(checkVisibility(bool))); + + // If there is more than one form open - tabify the new form. If this is the first form open add it to the dock. + if(m_dockedWidgets.size() > 1) + { + m_mainDock->tabifyDockWidget(m_dockedWidgets.at(m_dockedWidgets.size() - 2), m_dockedWidgets.last()); + } + else + { + m_mainDock->addDockWidget(Qt::RightDockWidgetArea, m_dockedWidgets.last()); + } + + w->raise(); + } + void GeorgesEditorForm::settingsChanged() { QSettings *settings = Core::ICore::instance()->settings(); @@ -255,25 +289,7 @@ namespace GeorgesQt return; } - w->setUndoStack(UndoStack); - m_lastActiveDock = w; - m_dockedWidgets.append(w); - - connect(m_dockedWidgets.last(), SIGNAL(closing()), this, SLOT(closingTreeView())); - connect(m_dockedWidgets.last(), SIGNAL(visibilityChanged(bool)), m_dockedWidgets.last(), SLOT(checkVisibility(bool))); - - // If there is more than one form open - tabify the new form. If this is the first form open add it to the dock. - if(m_dockedWidgets.size() > 1) - { - m_mainDock->tabifyDockWidget(m_dockedWidgets.at(m_dockedWidgets.size() - 2), m_dockedWidgets.last()); - } - else - { - m_mainDock->addDockWidget(Qt::RightDockWidgetArea, m_dockedWidgets.last()); - } - - w->raise(); - + addGeorgesWidget( w ); } void GeorgesEditorForm::closingTreeView() diff --git a/code/studio/src/plugins/georges_editor/georges_editor_form.h b/code/studio/src/plugins/georges_editor/georges_editor_form.h index a1a1a46e7..adfaf2e59 100644 --- a/code/studio/src/plugins/georges_editor/georges_editor_form.h +++ b/code/studio/src/plugins/georges_editor/georges_editor_form.h @@ -61,6 +61,8 @@ private: void readSettings(); void writeSettings(); + void addGeorgesWidget( GeorgesDockWidget *w ); + GeorgesDockWidget* loadTypDialog(const QString &fileName); GeorgesDockWidget* loadDfnDialog(const QString &fileName); GeorgesDockWidget* loadFormDialog(const QString &fileName); 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 123aa0fd4..7e832ba26 100644 --- a/code/studio/src/plugins/georges_editor/georges_typ_dialog.cpp +++ b/code/studio/src/plugins/georges_editor/georges_typ_dialog.cpp @@ -105,6 +105,18 @@ void GeorgesTypDialog::write() setWindowTitle( windowTitle().remove( "*" ) ); } +void GeorgesTypDialog::newDocument( const QString &fileName ) +{ + m_pvt->typ = new NLGEORGES::CType(); + m_fileName = fileName; + + QFileInfo info( fileName ); + setWindowTitle( info.fileName() + "*" ); + setModified( true ); + + loadTyp(); +} + void GeorgesTypDialog::onAddClicked() { QString label = QInputDialog::getText( this, 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 eef2b86fc..b241c4c8d 100644 --- a/code/studio/src/plugins/georges_editor/georges_typ_dialog.h +++ b/code/studio/src/plugins/georges_editor/georges_typ_dialog.h @@ -33,6 +33,7 @@ public: bool load( const QString &fileName ); void write(); + void newDocument( const QString &fileName ); Q_SIGNALS: void modified();