]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Fix for Bug IPAL8981(3.0.0: Add "Dump Study" into menu).
authormzn <mzn@opencascade.com>
Mon, 20 Jun 2005 12:11:21 +0000 (12:11 +0000)
committermzn <mzn@opencascade.com>
Mon, 20 Jun 2005 12:11:21 +0000 (12:11 +0000)
src/SalomeApp/Makefile.in
src/SalomeApp/SalomeApp_Application.cxx
src/SalomeApp/SalomeApp_Application.h
src/SalomeApp/SalomeApp_CheckFileDlg.cxx [new file with mode: 0644]
src/SalomeApp/SalomeApp_CheckFileDlg.h [new file with mode: 0644]
src/SalomeApp/resources/SalomeApp_msg_en.po

index fe2749c620e38d87f89e87b3c824b72677f8f310..d1ba9fa88075bcdbc93c308090998122d5c1bbbb 100755 (executable)
@@ -39,7 +39,8 @@ EXPORT_HEADERS= SalomeApp.h \
                SalomeApp_Filter.h \
                SalomeApp_TypeFilter.h \
                SalomeApp_OBFilter.h \
-               SalomeApp_StudyPropertiesDlg.h
+               SalomeApp_StudyPropertiesDlg.h \
+               SalomeApp_CheckFileDlg.h
 
 # .po files to transform in .qm
 PO_FILES = SalomeApp_images.po \
@@ -76,7 +77,8 @@ LIB_SRC= SalomeApp_AboutDlg.cxx \
         SalomeApp_TypeFilter.cxx \
         SalomeApp_OBFilter.cxx \
         SalomeApp_StudyPropertiesDlg.cxx \
-        SalomeApp_ListView.cxx
+        SalomeApp_ListView.cxx \
+        SalomeApp_CheckFileDlg.cxx
 
 LIB_MOC = SalomeApp_AboutDlg.h \
           SalomeApp_Application.h \
@@ -94,7 +96,8 @@ LIB_MOC = SalomeApp_AboutDlg.h \
          SalomeApp_NameDlg.h \
          SalomeApp_ModuleDlg.h \
          SalomeApp_StudyPropertiesDlg.h \
-         SalomeApp_ListView.h
+         SalomeApp_ListView.h \
+         SalomeApp_CheckFileDlg.h
 
 LIB_CLIENT_IDL = SALOMEDS.idl \
                 SALOME_Exception.idl \
index 56161bd59abd3ff9040805184deb9dbc86822df9..719b2f8c1ea6621701e715acf428bcfc477c5a33 100644 (file)
@@ -20,6 +20,7 @@
 #include "SalomeApp_Preferences.h"
 #include "SalomeApp_PreferencesDlg.h"
 #include "SalomeApp_StudyPropertiesDlg.h"
+#include "SalomeApp_CheckFileDlg.h"
 
 #include "SalomeApp_GLSelector.h"
 #include "SalomeApp_OBSelector.h"
@@ -265,10 +266,15 @@ void SalomeApp_Application::createActions()
 
   SUIT_Desktop* desk = desktop();
   SUIT_ResourceMgr* resMgr = resourceMgr();
-
+  
+  // Dump study
+  createAction( DumpStudyId, tr( "TOT_DESK_FILE_DUMP_STUDY" ), QIconSet(),
+               tr( "MEN_DESK_FILE_DUMP_STUDY" ), tr( "PRP_DESK_FILE_DUMP_STUDY" ),
+               0, desk, false, this, SLOT( onDumpStudy() ) );
+    
   // Load script
-  createAction( LoadScriptId, tr( "TOT_DESK_LOADSCRIPT" ), QIconSet(),
-               tr( "MEN_DESK_LOADSCRIPT" ), tr( "PRP_DESK_LOADSCRIPT" ),
+  createAction( LoadScriptId, tr( "TOT_DESK_FILE_LOAD_SCRIPT" ), QIconSet(),
+               tr( "MEN_DESK_FILE_LOAD_SCRIPT" ), tr( "PRP_DESK_FILE_LOAD_SCRIPT" ),
                0, desk, false, this, SLOT( onLoadScript() ) );
 
   // Properties
@@ -367,12 +373,11 @@ void SalomeApp_Application::createActions()
   }
   connect( modGroup, SIGNAL( selected( QAction* ) ), this, SLOT( onModuleActivation( QAction* ) ) );
 
-
-
   int fileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1 );
 
+  createMenu( DumpStudyId, fileMenu, 10, -1 );
   createMenu( separator(), fileMenu, -1, 15, -1 );
-  createMenu( LoadScriptId, fileMenu, 15, -1 );
+  createMenu( LoadScriptId, fileMenu, 10, -1 );
   createMenu( separator(), fileMenu, -1, 15, -1 );
   createMenu( PropertiesId, fileMenu, 10, -1 );
   createMenu( separator(), fileMenu, -1, 15, -1 );
@@ -616,8 +621,13 @@ void SalomeApp_Application::updateCommandsStatus()
       a->setEnabled( activeStudy() );
   }
 
+  // Dump study menu
+  QAction* a = action( DumpStudyId );
+  if ( a )
+    a->setEnabled( activeStudy() );
+
   // Load script menu
-  QAction* a = action( LoadScriptId );
+  a = action( LoadScriptId );
   if ( a )
     a->setEnabled( activeStudy() );
   
@@ -901,6 +911,30 @@ void SalomeApp_Application::onStudyClosed( SUIT_Study* )
   saveWindowsGeometry();
 }
 
+void SalomeApp_Application::onDumpStudy( )
+{
+  SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( activeStudy() );
+  if ( !appStudy ) return;
+  _PTR(Study) aStudy = appStudy->studyDS();
+
+  QStringList aFilters;
+  aFilters.append(tr("PYTHON_FILES_FILTER"));
+
+  SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg( desktop(), false, tr("PUBLISH_IN_STUDY"), true, true);
+  fd->setCaption(tr("TOT_DESK_FILE_DUMP_STUDY"));
+  fd->setFilters( aFilters );  
+  fd->SetChecked(true);
+  fd->exec();
+  QString aFileName = fd->selectedFile();
+  bool toPublish = fd->IsChecked();
+  delete fd;
+
+  if(!aFileName.isEmpty()) {
+    QFileInfo aFileInfo(aFileName);
+    aStudy->DumpStudy(aFileInfo.dirPath(true), aFileInfo.baseName(), toPublish);
+  }
+}
+
 void SalomeApp_Application::onLoadScript( )
 {
   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( activeStudy() );
@@ -919,7 +953,7 @@ void SalomeApp_Application::onLoadScript( )
   filtersList.append(tr("PYTHON_FILES_FILTER"));
   filtersList.append(tr("ALL_FILES_FILTER"));
 
-  QString aFile = SUIT_FileDlg::getFileName( desktop(), "", filtersList, tr( "TOT_DESK_LOADSCRIPT" ), true, true );
+  QString aFile = SUIT_FileDlg::getFileName( desktop(), "", filtersList, tr( "TOT_DESK_FILE_LOAD_SCRIPT" ), true, true );
 
   if ( !aFile.isEmpty() )
   {
index 0da12339c6046a926c46f167ae720950190a4eb2..622095e45729139e85b2ce169adbee23b373373a 100644 (file)
@@ -52,8 +52,8 @@ public:
   typedef enum { WT_ObjectBrowser, WT_PyConsole, WT_LogWindow, WT_User } WindowTypes;
 
   enum { ModulesListId = STD_Application::UserID, NewGLViewId,
-         NewPlot2dId, NewOCCViewId, NewVTKViewId, LoadScriptId,
-         PropertiesId, PreferencesId, MRUId, UserID };
+         NewPlot2dId, NewOCCViewId, NewVTKViewId, DumpStudyId,
+        LoadScriptId,PropertiesId, PreferencesId, MRUId, UserID };
 
 public:
   SalomeApp_Application();
@@ -154,6 +154,7 @@ private slots:
   void                                onStudyClosed( SUIT_Study* );
   
   void                                onProperties();
+  void                                onDumpStudy();
   void                                onLoadScript(); 
 
   void                                onPreferences();
diff --git a/src/SalomeApp/SalomeApp_CheckFileDlg.cxx b/src/SalomeApp/SalomeApp_CheckFileDlg.cxx
new file mode 100644 (file)
index 0000000..32ebeea
--- /dev/null
@@ -0,0 +1,36 @@
+#include "SalomeApp_CheckFileDlg.h"
+
+#include <qcheckbox.h>
+#include <qlabel.h>
+#include <qpushbutton.h>
+
+/*!
+Constructor
+*/
+SalomeApp_CheckFileDlg::SalomeApp_CheckFileDlg( QWidget* parent, bool open, const QString& theCheckBoxName, bool showQuickDir, bool modal) :
+SUIT_FileDlg( parent, open, showQuickDir, modal )
+{    
+  myCheckBox = new QCheckBox( theCheckBoxName, this );
+  QLabel* label = new QLabel("", this);
+  QPushButton* pb = new QPushButton(this);               
+  addWidgets( label, myCheckBox, pb );
+  pb->hide();
+}
+
+/*!
+Destructor
+*/
+SalomeApp_CheckFileDlg::~SalomeApp_CheckFileDlg() 
+{
+
+}
+
+void SalomeApp_CheckFileDlg::SetChecked( bool check )
+{
+  myCheckBox->setChecked(check);
+}
+
+bool SalomeApp_CheckFileDlg::IsChecked() const
+{
+  return myCheckBox->isChecked();
+}
diff --git a/src/SalomeApp/SalomeApp_CheckFileDlg.h b/src/SalomeApp/SalomeApp_CheckFileDlg.h
new file mode 100644 (file)
index 0000000..5b4a84a
--- /dev/null
@@ -0,0 +1,26 @@
+#ifndef SALOMEAPP_CHECKFILEDIALOG_H
+#define SALOMEAPP_CHECKFILEDIALOG_H
+
+#include <SalomeApp.h>
+
+#include <SUIT_FileDlg.h>
+
+class QCheckBox;
+
+class SALOMEAPP_EXPORT SalomeApp_CheckFileDlg : public SUIT_FileDlg
+{
+  Q_OBJECT
+    
+public:
+  SalomeApp_CheckFileDlg( QWidget*, bool open, const QString& theCheckBoxName, bool showQuickDir = true, bool modal = true );
+  virtual ~SalomeApp_CheckFileDlg();
+
+public:
+  void SetChecked( bool check );
+  bool IsChecked() const;
+
+protected:
+  QCheckBox* myCheckBox;
+};
+
+#endif
index 64cbcf4694f0629510dd5d8de430994b0cd76b59..7828472ee70e292c8b0cd9cf86cd31052b7982cd 100644 (file)
@@ -71,16 +71,25 @@ msgstr "OCC view"
 msgid "SalomeApp_Application::NEW_WINDOW_3"
 msgstr "VTK view"
 
-msgid "SalomeApp_Application::TOT_DESK_LOADSCRIPT"
+msgid "SalomeApp_Application::TOT_DESK_FILE_DUMP_STUDY"
+msgstr "Dump study"
+
+msgid "SalomeApp_Application::MEN_DESK_FILE_DUMP_STUDY"
+msgstr "Dump study..."
+
+msgid "SalomeApp_Application::PRP_DESK_FILE_DUMP_STUDY"
+msgstr "Dumps study to the python script"
+
+msgid "SalomeApp_Application::TOT_DESK_FILE_LOAD_SCRIPT"
 msgstr "Load python script"
 
-msgid "SalomeApp_Application::MEN_DESK_LOADSCRIPT"
+msgid "SalomeApp_Application::MEN_DESK_FILE_LOAD_SCRIPT"
 msgstr "Load script..."
 
-msgid "SalomeApp_Application::PRP_DESK_LOADSCRIPT"
+msgid "SalomeApp_Application::PRP_DESK_FILE_LOAD_SCRIPT"
 msgstr "Loads python script from file"
 
-msgid "SalomeApp_Application::TOT_DESK_PREFERENCES"
+msgid "SalomeApp_Application::TOT_FILE_DESK_PREFERENCES"
 msgstr "Preferences"
 
 msgid "SalomeApp_Application::MEN_DESK_PREFERENCES"
@@ -241,3 +250,8 @@ msgstr "MODIFIED"
 
 msgid "SalomeApp_StudyPropertiesDlg::PRP_MODIFICATIONS"
 msgstr "Modifications"
+
+//=======================================================================================
+
+msgid "SalomeApp_Application::PUBLISH_IN_STUDY"
+msgstr "Publish in study"