Salome HOME
Copyright update 2022
[modules/gui.git] / src / Qtx / QtxDockAction.h
old mode 100755 (executable)
new mode 100644 (file)
index 8e443be..9e1b031
@@ -1,20 +1,40 @@
+// Copyright (C) 2007-2022  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 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
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
 // File:      QtxDockAction.h
 // Author:    Sergey TELKOV
-
-#ifndef QTX_DOCKACTION_H
-#define QTX_DOCKACTION_H
+//
+#ifndef QTXDOCKACTION_H
+#define QTXDOCKACTION_H
 
 #include "QtxAction.h"
 
-#include <qevent.h>
-#include <qptrlist.h>
-#include <qpopupmenu.h>
+#include <QList>
 
-class QAction;
-class QDockArea;
-class QDockWindow;
+class QIcon;
+class QString;
+class QToolBar;
+class QDockWidget;
 class QMainWindow;
-class QtxResourceMgr;
 
 #ifdef WIN32
 #pragma warning( disable:4251 )
@@ -24,118 +44,47 @@ class QTX_EXPORT QtxDockAction : public QtxAction
 {
   Q_OBJECT
 
-  Q_PROPERTY( bool autoAdd   READ isAutoAdd   WRITE setAutoAdd )
-  Q_PROPERTY( bool autoPlace READ isAutoPlace WRITE setAutoPlace )
-  Q_PROPERTY( bool separate  READ isSeparate  WRITE setSeparate )
+public:
+  //! Dock windows type.
+  enum { ToolBar,      //!< list toolbars only
+         DockWidget,   //!< list dockable windows only
+         Both          //!< list toolbars and dockable windows
+  } DockType;
 
 public:
-  QtxDockAction( QMainWindow*, const char* = 0 );
-  QtxDockAction( const QString&, const QString&, QMainWindow*, const char* = 0 );
-  QtxDockAction( const QString&, const QIconSet&, const QString&, QMainWindow*, const char* = 0 );
+  QtxDockAction( QMainWindow* );
+  QtxDockAction( const QString&, const QString&, QMainWindow* );
+  QtxDockAction( const QString&, const QIcon&, const QString&, QMainWindow* );
   virtual ~QtxDockAction();
 
-  QMainWindow* mainWindow() const;
-
-  bool         isAutoAdd() const;
-  void         setAutoAdd( const bool );
-
-  bool         isAutoPlace() const;
-  void         setAutoPlace( const bool );
+  void         update();
 
-  bool         isSeparate() const;
-  void         setSeparate( const bool );
+  int          dockType() const;
+  void         setDockType( const int );
 
-  virtual bool addTo( QWidget* );
-  virtual bool addTo( QWidget*, const int );
-  virtual bool removeFrom( QWidget* );
-
-  bool         addDockWindow( QDockWindow* );
-  bool         removeDockWindow( QDockWindow* );
-
-  virtual bool eventFilter( QObject*, QEvent* );
-
-  virtual void storeGeometry( QDockWindow* = 0 );
-  virtual void restoreGeometry( QDockWindow* = 0 ) const;
-
-  virtual void loadGeometry( QtxResourceMgr*, const QString&, const bool = true );
-  virtual void saveGeometry( QtxResourceMgr*, const QString&, const bool = true ) const;
+  QMainWindow* mainWindow() const;
 
 private slots:
   void         onAboutToShow();
-  void         onToggled( bool );
-  void         onVisibilityChanged( bool );
-  void         onPopupDestroyed( QObject* );
-  void         onWindowDestroyed( QObject* );
-  void         onDockWindowPositionChanged( QDockWindow* );
 
 protected:
-  virtual bool event( QEvent* );
-
-private:
-  QAction*     action( QDockWindow* ) const;
-  QDockWindow* dockWindow( const QAction* ) const;
-
-  void         checkPopup( QPopupMenu* );
-  void         fillPopup( QPopupMenu* ) const;
-  int          findId( QPopupMenu*, QPopupMenu* ) const;
-
-  void         initialize( QMainWindow* );
-  void         updateInfo( QDockWindow* );
-  bool         isToolBar( QDockWindow* ) const;
-  void         dockWindows( QPtrList<QDockWindow>&, QMainWindow* = 0 ) const;
-
-  QString      windowName( QDockWindow* ) const;
-  void         savePlaceInfo( QDockWindow* );
-  void         loadPlaceInfo( QDockWindow* ) const;
-  void         loadPlaceInfo() const;
-
-  bool         autoAddDockWindow( QDockWindow* );
-  void         autoLoadPlaceInfo( QDockWindow* );
-
-  void         splitMenuText( QString&, QString& ) const;
-  QStringList  splitText( const QString&, const QString& ) const;
-
-  QDockArea*   dockArea( const int ) const;
-  int          dockPlace( const QString& ) const;
-
-  void         collectNames( const int, QStringList& ) const;
+  virtual void addedTo( QWidget* );
+  virtual void removedFrom( QWidget* );
 
 private:
-  enum { AutoAdd = QEvent::User, LoadArea };
-
-  typedef struct { bool vis, newLine;
-                   int place, index, offset;
-                   int x, y, w, h, fixW, fixH; } GeomInfo;
-  typedef struct { QString name; QAction* a; }   DockInfo;
-  typedef struct { QPopupMenu *dock, *tool; }    MenuInfo;
+  void         initialize();
+  void         updateMenu();
 
-  typedef QMap<QDockWindow*, DockInfo>   InfoMap;
-  typedef QMap<QString, GeomInfo>        GeomMap;
-  typedef QMap<QPopupMenu*, MenuInfo>    MenuMap;
+  void         toolBars( QList<QToolBar*>& ) const;
+  void         dockWidgets( QList<QDockWidget*>& ) const;
 
 private:
-  bool         loadGeometry( QtxResourceMgr*, const QString&,
-                             const QString&, GeomInfo& ) const;
-  bool         saveGeometry( QtxResourceMgr*, const QString&,
-                             const QString&, const GeomInfo& ) const;
-  void         loadPlaceArea( const int, QMainWindow*, QDockArea*,
-                              const QPtrList<QDockWindow>&,
-                              const QMap<QDockWindow*, GeomInfo*>& ) const;
-
-private:
-  InfoMap      myInfo;
-  MenuMap      myMenu;
-  GeomMap      myGeom;
-  QMainWindow* myMain;
-  QStringList  myNames;
-
-  bool         myAutoAdd;
-  bool         mySeparate;
-  bool         myAutoPlace;
+  int          myType;   //!< dock action type
+  QMainWindow* myMain;   //!< parent main window
 };
 
 #ifdef WIN32
 #pragma warning( default:4251 )
 #endif
 
-#endif
+#endif // QTXDOCKACTION_H