]> Creatis software - cpPlugins.git/blobdiff - appli/cpPipelineEditor/cpPipelineEditor.cxx
More on graph editor
[cpPlugins.git] / appli / cpPipelineEditor / cpPipelineEditor.cxx
index 8d838b829e821b299014d71d70624a51b01ed203..872b4f4a33907f9f2cbf2539f16a4c07439b5fdb 100644 (file)
@@ -1,6 +1,8 @@
 #include "cpPipelineEditor.h"
 #include "ui_cpPipelineEditor.h"
 
+#include "QNodesEditor.h"
+
 #include <QFileDialog>
 #include <QMessageBox>
 #include <cpPlugins/Interface/Workspace.h>
@@ -32,6 +34,7 @@ cpPipelineEditor( QWidget* parent )
   cpPipelineEditor_ConnectButton( LoadPluginsFile );
   cpPipelineEditor_ConnectButton( LoadPluginsPath );
   cpPipelineEditor_ConnectAction( OpenWorkspace );
+  cpPipelineEditor_ConnectAction( SaveWorkspace );
 }
 
 // -------------------------------------------------------------------------
@@ -136,7 +139,7 @@ _ButtonLoadPluginsFile( )
       );
 
   // Update view
-  this->m_UI->Canvas->setWorkspace( this->m_Workspace );
+  this->m_UI->Canvas->editor( )->setWorkspace( this->m_Workspace );
   this->_UpdateLoadedPlugins( );
 }
 
@@ -164,7 +167,7 @@ _ButtonLoadPluginsPath( )
       );
 
   // Update view
-  this->m_UI->Canvas->setWorkspace( this->m_Workspace );
+  this->m_UI->Canvas->editor( )->setWorkspace( this->m_Workspace );
   this->_UpdateLoadedPlugins( );
 }
 
@@ -189,7 +192,7 @@ _ActionOpenWorkspace( )
   std::string err = this->m_Workspace->LoadWorkspace( fname );
   if( err == "" )
   {
-    this->m_UI->Canvas->setWorkspace( this->m_Workspace );
+    this->m_UI->Canvas->editor( )->setWorkspace( this->m_Workspace );
   }
   else
   {
@@ -204,4 +207,32 @@ _ActionOpenWorkspace( )
   } // fi
 }
 
+// -------------------------------------------------------------------------
+void cpPipelineEditor::
+_ActionSaveWorkspace( )
+{
+  if( this->m_Workspace == NULL )
+    return;
+
+  QFileDialog dlg( this );
+  dlg.setFileMode( QFileDialog::AnyFile );
+  dlg.setDirectory( "." );
+  dlg.setAcceptMode( QFileDialog::AcceptSave );
+  dlg.setNameFilter(
+    QFileDialog::tr( "Workspace file (*.xml);;All files (*)" )
+    );
+  dlg.setDefaultSuffix( QFileDialog::tr( "xml" ) );
+  if( !( dlg.exec( ) ) )
+    return;
+  std::string fname = dlg.selectedFiles( ).at( 0 ).toStdString( );
+
+  std::string err = this->m_Workspace->SaveWorkspace( fname );
+  if( err != "" )
+    QMessageBox::critical(
+      this,
+      QMessageBox::tr( "Error saving workspace" ),
+      QMessageBox::tr( err.c_str( ) )
+      );
+}
+
 // eof - $RCSfile$