Salome HOME
PAL9883 - default value of "ascii_file" parameter must be false
[modules/gui.git] / src / LightApp / LightApp_Application.cxx
index d6c503e68dc741442b5ed53c0f8bd4d46043770b..d716f89ea11ce4004e56fbfd2a32a1fb43240d9f 100644 (file)
@@ -353,7 +353,8 @@ void LightApp_Application::createActions()
     id++;
   }
   // help for other existing modules
-  for ( QStringList::Iterator it = aModuleList.begin(); it != aModuleList.end(); ++it )
+  QStringList::Iterator it;
+  for ( it = aModuleList.begin(); it != aModuleList.end(); ++it )
   {
     if ( (*it).isEmpty() )
       continue;
@@ -408,7 +409,7 @@ void LightApp_Application::createActions()
   QStringList modList;
   modules( modList, false );
 
-  for ( QStringList::Iterator it = modList.begin(); it != modList.end(); ++it )
+  for ( it = modList.begin(); it != modList.end(); ++it )
   {
     if ( (*it).isEmpty() )
       continue;
@@ -445,7 +446,7 @@ void LightApp_Application::createActions()
   accelMap[NewOCCViewId] = ALT+Key_O;
   accelMap[NewVTKViewId] = ALT+Key_K;
 
-  for ( int id = NewGLViewId; id <= NewVTKViewId; id++ )
+  for ( id = NewGLViewId; id <= NewVTKViewId; id++ )
   {
     QAction* a = createAction( id, tr( QString( "NEW_WINDOW_%1" ).arg( id - NewGLViewId ) ), QIconSet(),
                               tr( QString( "NEW_WINDOW_%1" ).arg( id - NewGLViewId ) ),
@@ -770,13 +771,13 @@ void LightApp_Application::onHelpContentsModule()
   const QAction* obj = (QAction*) sender();
 
   QString aComponentName = obj->name();
-  QString aFileName = aComponentName.lower() + ".htm";
+  QString aFileName = aComponentName + "_index.html";
 
   QCString dir;
   QString root;
   QString homeDir;
   if (dir = getenv( aComponentName + "_ROOT_DIR")) {
-    root = Qtx::addSlash( Qtx::addSlash(dir) +  Qtx::addSlash("doc") +  Qtx::addSlash("salome")  +  Qtx::addSlash(aComponentName));
+    root = Qtx::addSlash( Qtx::addSlash(dir) +  Qtx::addSlash("doc") +  Qtx::addSlash("salome") );
     if ( QFileInfo( root + aFileName ).exists() ) {
       homeDir = root;
     } else {
@@ -849,7 +850,9 @@ void LightApp_Application::addWindow( QWidget* wid, const int flag, const int st
     QMap<int, int> winMap;
     currentWindows( winMap );
 
-    myWindows.insert( flag, new LightApp_WidgetContainer( flag, desktop() ) );
+    LightApp_WidgetContainer* newWC = new LightApp_WidgetContainer( flag, desktop() );
+    connect( newWC, SIGNAL(  destroyed ( QObject* ) ), this, SLOT( onWCDestroyed( QObject* ) ) );
+    myWindows.insert( flag, newWC );
     if ( winMap.contains( flag ) )
       desktop()->moveDockWindow( myWindows[flag], (Dock)winMap[flag] );
 
@@ -1147,11 +1150,10 @@ void LightApp_Application::onStudyClosed( SUIT_Study* )
 {
   emit studyClosed();
 
-  activateModule( "" );
+  // Bug 10396: clear selection
+  mySelMgr->clearSelected();
 
-  // Bug 10396: remove all selectors
-  delete mySelMgr;
-  mySelMgr = new LightApp_SelectionMgr( this );
+  activateModule( "" );
 
   saveWindowsGeometry();
 }
@@ -1606,7 +1608,11 @@ void LightApp_Application::preferencesChanged( const QString& sec, const QString
     int u = resMgr->integerValue( sec, "iso_number_u" );
     int v = resMgr->integerValue( sec, "iso_number_v" );
     for ( QPtrListIterator<SUIT_ViewManager> it( lst ); it.current(); ++it )
-      ((OCCViewer_Viewer*)it.current())->setIsos( u, v );
+    {
+      OCCViewer_ViewManager* mgr = dynamic_cast<OCCViewer_ViewManager*>( it.current() );
+      if( mgr && mgr->getOCCViewer() )
+       mgr->getOCCViewer()->setIsos( u, v );
+    }
   }
 
   if( sec=="ObjectBrowser" )
@@ -1837,3 +1843,27 @@ SUIT_Accel* LightApp_Application::accel() const
 {
   return myAccel;
 }
+
+/*! remove dead widget container from map */
+void LightApp_Application::onWCDestroyed( QObject* ob )
+{
+  // remove destroyed widget container from windows map
+  for ( WindowMap::ConstIterator itr = myWindows.begin(); itr != myWindows.end(); ++itr )
+  {
+    if ( itr.data() != ob )
+      continue;
+
+    int key = itr.key();
+    myWindows.remove( key );
+    break;
+  }
+}
+
+/*! redefined to remove view manager from memory */
+void LightApp_Application::removeViewManager( SUIT_ViewManager* vm )
+{
+  disconnect( vm, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
+           this, SLOT( onCloseView( SUIT_ViewManager* ) ) );
+  STD_Application::removeViewManager( vm );
+  delete vm;
+}