X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FQtx%2FQtxDockAction.h;h=59f83068aaed5d3d4e0ba0b967ede634bafbecd9;hb=389efae83b99d654509671e60af3eecf11b8278e;hp=48b79233e721dd7b6d0d1a5a154ddee8704d96c1;hpb=3e51c4c259f167b30aaf3c3d3e0bc6eb9cd93107;p=modules%2Fgui.git diff --git a/src/Qtx/QtxDockAction.h b/src/Qtx/QtxDockAction.h index 48b79233e..59f83068a 100755 --- a/src/Qtx/QtxDockAction.h +++ b/src/Qtx/QtxDockAction.h @@ -1,20 +1,40 @@ +// Copyright (C) 2007-2015 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 -#include -#include +#include -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&, 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 InfoMap; - typedef QMap GeomMap; - typedef QMap MenuMap; + void toolBars( QList& ) const; + void dockWidgets( QList& ) 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&, - const QMap& ) 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