Salome HOME
0023552: Unable to use the contextual menu of Object Browser window
[modules/gui.git] / src / Qtx / QtxWorkspace.cxx
index 90bef875b2d661216013c049289461e352577bf3..f59a60e4b1001a1980ce7f6fc2757f5a70341eae 100644 (file)
@@ -1,30 +1,28 @@
-//  Copyright (C) 2007-2008  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
+// 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
+// version 2.1 of the License, or (at your option) any later version.
 //
-//  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
-//  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
+// Lesser General Public License for more details.
 //
-//  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
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-//  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/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+
 // File:      QtxWorkspace.cxx
 // Author:    Sergey TELKOV
 //
 #include "QtxWorkspace.h"
 
-#include <QWidgetList>
+#include <QMdiSubWindow>
 
 /*!
   \class QtxWorkspace
@@ -40,7 +38,7 @@
   \param parent parent widget
 */
 QtxWorkspace::QtxWorkspace( QWidget* parent )
-: QWorkspace( parent )
+: QMdiArea( parent )
 {
 }
 
@@ -56,24 +54,24 @@ QtxWorkspace::~QtxWorkspace()
 */
 void QtxWorkspace::tileVertical()
 {
-  QWidgetList winList = windowList();
+  QList<QMdiSubWindow *> winList = subWindowList();
   if ( winList.isEmpty() )
     return;
   
   int count = 0;
-  for ( QWidgetList::const_iterator itr = winList.begin(); itr != winList.end(); ++itr )
+  for ( QList<QMdiSubWindow *>::const_iterator itr = winList.begin(); itr != winList.end(); ++itr )
     if ( !( (*itr)->windowState() & Qt::WindowMinimized ) )
       count++;
 
   if ( !count )
     return;
 
-  if ( activeWindow() && ( activeWindow()->windowState() & Qt::WindowMaximized ) )
-    activeWindow()->showNormal();
+  if ( activeSubWindow() && ( activeSubWindow()->windowState() & Qt::WindowMaximized ) )
+    activeSubWindow()->showNormal();
 
   int y = 0;
   int heightForEach = height() / count;
-  for ( QWidgetList::iterator it = winList.begin(); it != winList.end(); ++it )
+  for ( QList<QMdiSubWindow *>::iterator it = winList.begin(); it != winList.end(); ++it )
   {
     QWidget* win = *it;
     if ( win->windowState() & Qt::WindowMinimized )
@@ -100,24 +98,24 @@ void QtxWorkspace::tileVertical()
 */
 void QtxWorkspace::tileHorizontal()
 {
-  QWidgetList winList = windowList();
+  QList<QMdiSubWindow *> winList = subWindowList();
   if ( winList.isEmpty() )
     return;
 
   int count = 0;
-  for ( QWidgetList::const_iterator itr = winList.begin(); itr != winList.end(); ++itr )
+  for ( QList<QMdiSubWindow *>::const_iterator itr = winList.begin(); itr != winList.end(); ++itr )
     if ( !( (*itr)->windowState() & Qt::WindowMinimized ) )
       count++;
 
   if ( !count )
     return;
 
-  if ( activeWindow() && activeWindow()->windowState() & Qt::WindowMaximized )
-    activeWindow()->showNormal();
+  if ( activeSubWindow() && activeSubWindow()->windowState() & Qt::WindowMaximized )
+    activeSubWindow()->showNormal();
   
   int x = 0;
   int widthForEach = width() / count;
-  for ( QWidgetList::iterator it = winList.begin(); it != winList.end(); ++it )
+  for ( QList<QMdiSubWindow *>::iterator it = winList.begin(); it != winList.end(); ++it )
   {
     QWidget* win = *it;
     if ( win->windowState() & Qt::WindowMinimized )
@@ -138,3 +136,11 @@ void QtxWorkspace::tileHorizontal()
     x += actualW;
   }
 }
+
+void QtxWorkspace::onSubWindowActivated( QMdiSubWindow* subWindow )
+{
+  QWidget* w = 0;
+  if ( subWindow )
+    w = subWindow->widget();
+  emit windowActivated( w );
+}