]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
bos #16517 Implement method canOpen() to check that study file is accessible and...
authorvsr <vsr@opencascade.com>
Mon, 30 Dec 2019 09:03:04 +0000 (12:03 +0300)
committervsr <vsr@opencascade.com>
Mon, 30 Dec 2019 09:03:04 +0000 (12:03 +0300)
src/LightApp/LightApp_Application.cxx
src/LightApp/LightApp_Application.h
src/SalomeApp/SalomeApp_Application.cxx
src/SalomeApp/SalomeApp_Application.h

index fb14f540ce122d0f956afb6c59c8c490b83f35f2..ba73f8d245b6fb3036c2430a13c18a735bca234f 100644 (file)
@@ -1024,7 +1024,6 @@ void LightApp_Application::onOpenDoc()
   if ( aName.isNull() ) //Cancel
     return;
   
-  closeDoc(false);
   onOpenDoc( aName );
   
   if ( !study ) // new study will be create in THIS application
@@ -1034,12 +1033,30 @@ void LightApp_Application::onOpenDoc()
   }
 }
 
+bool LightApp_Application::canOpenDoc( const QString& )
+{
+  return true;
+}
+
 /*!
   SLOT: Opens new document.
   \param aName - name of file
 */
 bool LightApp_Application::onOpenDoc( const QString& aName )
 {
+  if ( !canOpenDoc(aName)) {
+    bool showError = !property("open_study_from_command_line").isValid() ||
+      !property("open_study_from_command_line").toBool();
+
+    putInfo( tr("OPEN_DOCUMENT_PROBLEM") );
+    if ( showError )
+      SUIT_MessageBox::critical( desktop(), tr("ERR_ERROR"), tr("OPEN_DOCUMENT_PROBLEM"));
+
+    return false;
+  }
+
+  closeDoc(false);
+
   if ( !checkExistingDoc() )
     return false;
 
index 66a9032b3d7c799afaf0f3c7a4267bc0705ce109..6236e23b11fb78746b0f55e938fe0bbd1e26ffb0 100644 (file)
@@ -222,6 +222,8 @@ protected:
   virtual void                        setActiveStudy( SUIT_Study* );
   virtual void                        updateCommandsStatus();
 
+  virtual bool                        canOpenDoc( const QString& );
+
   virtual void                        beforeCloseDoc( SUIT_Study* );
   virtual void                        afterCloseDoc();
   virtual void                        moduleAdded( CAM_Module* );
index cf148a6571259e6a146446d0d4918565cd0e6c8f..d24daf3747f6e6daa43a4dcca55f478f4a4fa902 100644 (file)
@@ -2087,6 +2087,14 @@ void SalomeApp_Application::afterCloseDoc()
   LightApp_Application::afterCloseDoc();
 }
 
+bool SalomeApp_Application::canOpenDoc( const QString& url )
+{
+  _PTR(Study) aStudyDS = getStudy();
+  if ( aStudyDS )
+    return aStudyDS->CanOpen( url.toUtf8().data() );
+  return false;
+}
+
 /*
   Asks to close existing document.
 */
index ef34c4b26e3213f2252c1b6108fa6e3611a84ff8..e0bde79b7e8eae98c8a024b1a3d2db962d98e53c 100644 (file)
@@ -173,6 +173,7 @@ protected:
   virtual PyConsole_Interp*           createPyInterp();
 #endif
 
+  virtual bool                        canOpenDoc( const QString& );
   virtual void                        afterCloseDoc();
 
 private slots: