Salome HOME
Redesign SALOME documentation
[modules/gui.git] / src / STD / STD_Application.cxx
index 557371ac0b7cddb44354fc0b06445f6c3bba2d81..208115b83d0397b4d388bd9a2bb50414cdcdbf87 100755 (executable)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2015  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -111,7 +111,7 @@ void STD_Application::closeApplication()
     beforeCloseDoc( study );
 
     study->closeDocument();
-
+    emit appClosed();
     setActiveStudy( 0 );
     delete study;
 
@@ -203,7 +203,8 @@ void STD_Application::createActions()
   createAction( NewWindowId, tr( "TOT_DESK_NEWWINDOW" ), QIcon(),
                 tr( "MEN_DESK_NEWWINDOW" ), tr( "PRP_DESK_NEWWINDOW" ), 0, desk  );
 
-  createAction( HelpAboutId, tr( "TOT_DESK_HELP_ABOUT" ), QIcon(),
+  createAction( HelpAboutId, tr( "TOT_DESK_HELP_ABOUT" ),
+                resMgr->loadPixmap( "STD", tr( "ICON_DESK_ABOUT" ) ),
                 tr( "MEN_DESK_HELP_ABOUT" ), tr( "PRP_DESK_HELP_ABOUT" ),
                 Qt::ALT+Qt::SHIFT+Qt::Key_A, desk, false, this, SLOT( onHelpAbout() ) );
 
@@ -314,16 +315,19 @@ bool STD_Application::onNewDoc( const QString& name )
 void STD_Application::onOpenDoc()
 {
   // It is preferrable to use OS-specific file dialog box here !!!
-  QString aName = getFileName( true, QString(), getFileFilter(), QString(), 0 );
+  QString aName = getFileName( true, QString(), getFileFilter( true ), QString(), 0 );
   if ( aName.isNull() )
     return;
 
   onOpenDoc( aName );
 }
 
-/*! \retval true, if document was opened successful, else false.*/
+/*! \retval \c true, if document was opened successful, else \c false.*/
 bool STD_Application::onOpenDoc( const QString& aName )
 {
+  if ( !abortAllOperations() )
+    return false;
+
   QApplication::setOverrideCursor( Qt::WaitCursor );
 
   bool res = openAction( openChoice( aName ), aName );
@@ -454,7 +458,7 @@ bool STD_Application::closeActiveDoc( bool permanently )
 }
 
 /*!Check the application on closing.
- * \retval true if possible, else false
+ * \retval \c true if possible, else \c false
  */
 bool STD_Application::isPossibleToClose( bool& closePermanently )
 {
@@ -564,6 +568,9 @@ void STD_Application::onSaveDoc()
   if ( !activeStudy() )
     return;
 
+  if ( !abortAllOperations() )
+    return;
+
   bool isOk = false;
   if ( activeStudy()->isSaved() )
   {
@@ -592,17 +599,20 @@ void STD_Application::onSaveDoc()
     onSaveAsDoc();
 }
 
-/*! \retval TRUE, if doument saved successful, else FALSE.*/
+/*! \retval \c true, if document saved successfully, else \c false.*/
 bool STD_Application::onSaveAsDoc()
 {
   SUIT_Study* study = activeStudy();
   if ( !study )
     return false;
 
+  if ( !abortAllOperations() )
+    return false;
+
   bool isOk = false;
   while ( !isOk )
   {
-    QString aName = getFileName( false, study->studyName(), getFileFilter(), QString(), 0 );
+    QString aName = getFileName( false, study->studyName(), getFileFilter( false ), QString(), 0 );
     if ( aName.isNull() )
       return false;
 
@@ -660,7 +670,7 @@ void STD_Application::setEditEnabled( bool theEnable )
   }
 }
 
-/*!\retval true, if document opened successful, else false.*/
+/*!\retval \c true, if document opened successfully, else \c false.*/
 bool STD_Application::useFile(const QString& theFileName)
 {
   bool res = SUIT_Application::useFile( theFileName );
@@ -717,7 +727,7 @@ SUIT_ViewManager* STD_Application::viewManager( const QString& vmType ) const
   SUIT_ViewManager* vm = 0;
   for ( QList<SUIT_ViewManager*>::const_iterator it = myViewMgrs.begin(); it != myViewMgrs.end() && !vm; ++it )
   {
-    if ( (*it)->getType() == vmType )
+    if ( (*it)->getType() == vmType && !(*it)->getDetached())
       vm = *it;
   }
   return vm;
@@ -810,7 +820,7 @@ void STD_Application::clearViewManagers()
   }
 }
 
-/*!\retval TRUE, if view manager \a vm, already in view manager list (\a myViewMgrs).*/
+/*!\retval \c true, if view manager \a vm, already in view manager list (\a myViewMgrs).*/
 bool STD_Application::containsViewManager( SUIT_ViewManager* vm ) const
 {
   return myViewMgrs.contains( vm );
@@ -822,7 +832,7 @@ void STD_Application::onViewManagerActivated( SUIT_ViewManager* vm )
   setActiveViewManager( vm );
 }
 
-/*!Sets status bar show, if \on = true, else status bar hide.*/
+/*!Shows status bar, if on is \c true, else hides status bar.*/
 void STD_Application::onViewStatusBar( bool on )
 {
   if ( on )
@@ -875,6 +885,12 @@ void STD_Application::onConnectPopupRequest( SUIT_PopupClient* client, QContextM
   delete popup;
 }
 
+/*!\retval QString - return file extension(s).*/
+QString STD_Application::getFileFilter( bool /*open*/ ) const
+{
+  return QString();
+}
+
 /*!\retval QString - return file name from dialog.*/
 QString STD_Application::getFileName( bool open, const QString& initial, const QString& filters,
                                       const QString& caption, QWidget* parent )
@@ -1013,3 +1029,11 @@ int STD_Application::viewManagerId( const SUIT_ViewManager* theManager) const
   return myViewMgrs.indexOf(const_cast<SUIT_ViewManager*>(theManager));
 }
 
+/*!
+  \brief Abort active operations if there are any
+  \return \c false if some operation cannot be aborted
+*/
+bool STD_Application::abortAllOperations()
+{
+  return true;
+}