From 609dc40dbf860f0e205c4f3b0642efb53310d0ec Mon Sep 17 00:00:00 2001 From: nds Date: Fri, 19 Dec 2014 10:00:33 +0300 Subject: [PATCH] Persistent correction in full Salome mode. Update the Salome application action buttons(especially 'Save') An improvement in the 'Save' method of model to put to result all files(even already loaded). Without this improvement, the saved file is not correcly opened in the full salome mode. --- src/Model/Model_Document.cpp | 1 + src/NewGeom/NewGeom_DataModel.cpp | 17 +++++++++++++++-- src/NewGeom/NewGeom_DataModel.h | 10 ++++++++++ src/NewGeom/NewGeom_Module.cpp | 9 +++++++++ src/NewGeom/NewGeom_Module.h | 2 ++ src/XGUI/XGUI_Workshop.cpp | 1 + src/XGUI/XGUI_Workshop.h | 2 ++ 7 files changed, 40 insertions(+), 2 deletions(-) diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index 0eca5e794..c4fb2e7aa 100644 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -226,6 +226,7 @@ bool Model_Document::save(const char* theFileName, std::list& theRe TCollection_AsciiString aDestinationDir(DocFileName(theFileName, aDocName)); OSD_Path aDestination(aDestinationDir); aFile.Copy(aDestination); + theResults.push_back(aDestinationDir.ToCString()); } else { Events_Error::send( std::string("Can not open file ") + aSubPath.ToCString() + " for saving"); diff --git a/src/NewGeom/NewGeom_DataModel.cpp b/src/NewGeom/NewGeom_DataModel.cpp index 34922cbbd..88e7db728 100644 --- a/src/NewGeom/NewGeom_DataModel.cpp +++ b/src/NewGeom/NewGeom_DataModel.cpp @@ -40,8 +40,6 @@ bool NewGeom_DataModel::open(const QString& thePath, CAM_Study* theStudy, QStrin // The following code creates a new tmp directory with a copy of files. QString aTmpDir = theFiles.first(); - //LightApp_Driver aDriver; - //QString aNewTmpDir = QString(aDriver.GetTmpDir("", false).c_str()); LightApp_Study* aStudy = dynamic_cast( myModule->application()->activeStudy() ); QString aNewTmpDir = aStudy->GetTmpDir("", false).c_str(); @@ -57,6 +55,13 @@ bool NewGeom_DataModel::open(const QString& thePath, CAM_Study* theStudy, QStrin if (!QFile::copy(aCurrentFile, aNewFile)) isDone = false; } + if (isDone) { + myTmpDirectory = aNewTmpDir; + } + else { + removeDirectory(aNewTmpDir); + myTmpDirectory = ""; + } SessionPtr aMgr = ModelAPI_Session::get(); aMgr->load(qPrintable(aNewTmpDir)); @@ -103,6 +108,8 @@ bool NewGeom_DataModel::saveAs(const QString& thePath, CAM_Study* theStudy, QStr bool NewGeom_DataModel::close() { myModule->workshop()->closeDocument(); + removeDirectory(myTmpDirectory); + myTmpDirectory = ""; return LightApp_DataModel::close(); } @@ -125,3 +132,9 @@ bool NewGeom_DataModel::isSaved() const void NewGeom_DataModel::update(LightApp_DataObject* theObj, LightApp_Study* theStudy) { } + +void NewGeom_DataModel::removeDirectory(const QString& theDirectoryName) +{ + Qtx::rmDir(theDirectoryName); +} + diff --git a/src/NewGeom/NewGeom_DataModel.h b/src/NewGeom/NewGeom_DataModel.h index 184038a7f..1024f275d 100644 --- a/src/NewGeom/NewGeom_DataModel.h +++ b/src/NewGeom/NewGeom_DataModel.h @@ -27,8 +27,18 @@ class NewGeom_EXPORT NewGeom_DataModel : public LightApp_DataModel virtual void update(LightApp_DataObject* theObj = 0, LightApp_Study* theStudy = 0); +protected: + /** + * Removes the directory with content if it exists + * \param theDirectoryName a directory name + */ + static void removeDirectory(const QString& theDirectoryName); + private: QString myStudyPath; + QString myTmpDirectory; /// a path to the temporary directory, created by opening a document file + /// it should be created because the files reading is postponed in the module. The directory + // should be removed after the model document is closed. NewGeom_Module* myModule; }; diff --git a/src/NewGeom/NewGeom_Module.cpp b/src/NewGeom/NewGeom_Module.cpp index b1a115e23..c9d875f13 100644 --- a/src/NewGeom/NewGeom_Module.cpp +++ b/src/NewGeom/NewGeom_Module.cpp @@ -84,6 +84,9 @@ NewGeom_Module::NewGeom_Module() mySelector(0), myIsOpened(0), myPopupMgr(0) { myWorkshop = new XGUI_Workshop(this); + connect(myWorkshop, SIGNAL(commandStatusUpdated()), + this, SLOT(onUpdateCommandStatus())); + myProxyViewer = new NewGeom_SalomeViewer(this); ModuleBase_Preferences::setResourceMgr(application()->resourceMgr()); @@ -236,6 +239,12 @@ void NewGeom_Module::onDefaultPreferences() pref->retrieve(); } +//****************************************************** +void NewGeom_Module::onUpdateCommandStatus() +{ + getApp()->updateActions(); +} + //****************************************************** NewGeom_OCCSelector* NewGeom_Module::createSelector(SUIT_ViewManager* theMgr) { diff --git a/src/NewGeom/NewGeom_Module.h b/src/NewGeom/NewGeom_Module.h index f1f3ec09c..800d6b168 100644 --- a/src/NewGeom/NewGeom_Module.h +++ b/src/NewGeom/NewGeom_Module.h @@ -99,6 +99,8 @@ Q_OBJECT protected slots: virtual void onViewManagerAdded(SUIT_ViewManager* theMgr); void onDefaultPreferences(); + // Obtains the current application and updates its actions + void onUpdateCommandStatus(); protected: CAM_DataModel* createDataModel(); diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 0157532e7..fa583caea 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -1070,6 +1070,7 @@ void XGUI_Workshop::updateCommandStatus() } } myActionsMgr->update(); + emit commandStatusUpdated(); } //****************************************************** diff --git a/src/XGUI/XGUI_Workshop.h b/src/XGUI/XGUI_Workshop.h index c35db675b..4db6052fe 100644 --- a/src/XGUI/XGUI_Workshop.h +++ b/src/XGUI/XGUI_Workshop.h @@ -192,6 +192,8 @@ Q_OBJECT signals: void salomeViewerSelection(); void errorOccurred(const QString&); + //! the signal about the workshop actions states are updated. + void commandStatusUpdated(); public slots: void updateCommandStatus(); -- 2.39.2