Salome HOME
Show "Rename" menu command for light modules in "distributed mode"
[modules/gui.git] / src / STD / STD_SDIDesktop.cxx
index a3a04ca5e8d4433055986c04e3ac856b866ccd10..53c5bdf1516c824b9f67b7a13d4cd35fdd30900a 100755 (executable)
@@ -1,35 +1,41 @@
-// Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-// 
+// Copyright (C) 2007-2013  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
+//
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either 
+// License as published by the Free Software Foundation; either
 // version 2.1 of the License.
-// 
-// This library is distributed in the hope that it will be useful 
-// but WITHOUT ANY WARRANTY; without even the implied warranty of 
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 // Lesser General Public License for more details.
 //
-// You should have received a copy of the GNU Lesser General Public  
-// License along with this library; if not, write to the Free Software 
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-// See http://www.salome-platform.org/
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+
 #include "STD_SDIDesktop.h"
 
 #include <SUIT_ViewWindow.h>
 
-#include <qvbox.h>
-#include <qmenubar.h>
-#include <qobjectlist.h>
+#include <QFrame>
+#include <QVBoxLayout>
 
 /*!Constructor. Create instance of QVBox*/
 STD_SDIDesktop::STD_SDIDesktop()
 : SUIT_Desktop()
 {
-  myMainWidget = new QVBox( this );
+  myMainWidget = new QFrame( this );
   myMainWidget->setFrameStyle( QFrame::Panel | QFrame::Sunken );
+  QVBoxLayout* main = new QVBoxLayout( myMainWidget );
+  main->setMargin( 0 );
 
   setCentralWidget( myMainWidget );
 }
@@ -42,40 +48,42 @@ STD_SDIDesktop::~STD_SDIDesktop()
 /*!\retval SUIT_ViewWindow - return const active window.*/
 SUIT_ViewWindow* STD_SDIDesktop::activeWindow() const
 {
-  const QObjectList* children = myMainWidget->children();
-  if ( !children )
-    return 0;
-
-  QPtrList<SUIT_ViewWindow> winList;
-  for ( QObjectListIt it( *children ); it.current(); ++it )
+  const QObjectList& lst = myMainWidget->children();
+  QList<SUIT_ViewWindow*> winList;
+  for ( QObjectList::const_iterator it = lst.begin(); it != lst.end(); ++it )
   {
-    if ( it.current()->inherits( "SUIT_ViewWindow" ) )
-      winList.append( (SUIT_ViewWindow*)it.current() );
+    SUIT_ViewWindow* vw = ::qobject_cast<SUIT_ViewWindow*>( *it );
+    if ( vw )
+      winList.append( vw );
   }
 
   SUIT_ViewWindow* win = 0;
-  for ( QPtrListIterator<SUIT_ViewWindow> itr( winList ); itr.current() && !win; ++itr )
+  for ( QList<SUIT_ViewWindow*>::iterator itr = winList.begin(); itr != winList.end() && !win; ++itr )
   {
-    if ( itr.current()->isActiveWindow() )
-      win = itr.current();
+    if ( (*itr)->isActiveWindow() )
+      win = *itr;
   }
 
   if ( !win && !winList.isEmpty() )
-    win = winList.getFirst();
+    win = winList.first();
 
   return win;
 }
 
 /*!\retval QPtrList<SUIT_ViewWindow> - return const active window list.*/
-QPtrList<SUIT_ViewWindow> STD_SDIDesktop::windows() const
+QList<SUIT_ViewWindow*> STD_SDIDesktop::windows() const
 {
-  QPtrList<SUIT_ViewWindow> winList;
-      winList.append( activeWindow() );
+  QList<SUIT_ViewWindow*> winList;
+  winList.append( activeWindow() );
   return winList;
 }
 
-/*!\retval QWidget - pointer to main window.*/
-QWidget* STD_SDIDesktop::parentArea() const
+/*! add new widget into desktop.*/
+void STD_SDIDesktop::addWindow( QWidget* w )
 {
-  return myMainWidget;
+  if ( !w || !centralWidget() || !centralWidget()->layout() )
+    return;
+
+  w->setParent( centralWidget() );
+  centralWidget()->layout()->addWidget( w );
 }