From cdc0394753ae5e64438aeebc5cd824c7fb3aef12 Mon Sep 17 00:00:00 2001 From: mzn Date: Mon, 20 Jun 2005 12:11:21 +0000 Subject: [PATCH] Fix for Bug IPAL8981(3.0.0: Add "Dump Study" into menu). --- src/SalomeApp/Makefile.in | 9 ++-- src/SalomeApp/SalomeApp_Application.cxx | 50 +++++++++++++++++---- src/SalomeApp/SalomeApp_Application.h | 5 ++- src/SalomeApp/SalomeApp_CheckFileDlg.cxx | 36 +++++++++++++++ src/SalomeApp/SalomeApp_CheckFileDlg.h | 26 +++++++++++ src/SalomeApp/resources/SalomeApp_msg_en.po | 22 +++++++-- 6 files changed, 131 insertions(+), 17 deletions(-) create mode 100644 src/SalomeApp/SalomeApp_CheckFileDlg.cxx create mode 100644 src/SalomeApp/SalomeApp_CheckFileDlg.h diff --git a/src/SalomeApp/Makefile.in b/src/SalomeApp/Makefile.in index fe2749c62..d1ba9fa88 100755 --- a/src/SalomeApp/Makefile.in +++ b/src/SalomeApp/Makefile.in @@ -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 \ diff --git a/src/SalomeApp/SalomeApp_Application.cxx b/src/SalomeApp/SalomeApp_Application.cxx index 56161bd59..719b2f8c1 100644 --- a/src/SalomeApp/SalomeApp_Application.cxx +++ b/src/SalomeApp/SalomeApp_Application.cxx @@ -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( 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( 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() ) { diff --git a/src/SalomeApp/SalomeApp_Application.h b/src/SalomeApp/SalomeApp_Application.h index 0da12339c..622095e45 100644 --- a/src/SalomeApp/SalomeApp_Application.h +++ b/src/SalomeApp/SalomeApp_Application.h @@ -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 index 000000000..32ebeea3b --- /dev/null +++ b/src/SalomeApp/SalomeApp_CheckFileDlg.cxx @@ -0,0 +1,36 @@ +#include "SalomeApp_CheckFileDlg.h" + +#include +#include +#include + +/*! +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 index 000000000..5b4a84a8e --- /dev/null +++ b/src/SalomeApp/SalomeApp_CheckFileDlg.h @@ -0,0 +1,26 @@ +#ifndef SALOMEAPP_CHECKFILEDIALOG_H +#define SALOMEAPP_CHECKFILEDIALOG_H + +#include + +#include + +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 diff --git a/src/SalomeApp/resources/SalomeApp_msg_en.po b/src/SalomeApp/resources/SalomeApp_msg_en.po index 64cbcf469..7828472ee 100644 --- a/src/SalomeApp/resources/SalomeApp_msg_en.po +++ b/src/SalomeApp/resources/SalomeApp_msg_en.po @@ -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" -- 2.39.2