1 // Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File: QtxActionToolMgr.h
24 // Author: Alexander SOLOVYOV, Sergey TELKOV
26 #ifndef QTXACTIONTOOLMGR_H
27 #define QTXACTIONTOOLMGR_H
30 #include "QtxActionMgr.h"
40 #pragma warning( disable:4251 )
43 class QTX_EXPORT QtxActionToolMgr : public QtxActionMgr
50 ToolNode() : id( -1 ), visible( true ) {};
51 ToolNode( const int _id ) : id( _id ), visible( true ) {};
53 int id; //!< tool node ID
54 bool visible; //!< visibility status
57 typedef QList<ToolNode> NodeList; //!< toolbar nodes list
63 QtxActionToolMgr( QMainWindow* );
64 virtual ~QtxActionToolMgr();
66 QMainWindow* mainWindow() const;
68 int createToolBar( const QString&, int = -1, QMainWindow* = 0, bool = true );
69 int createToolBar( const QString&, const QString&, int = -1, QMainWindow* = 0, bool = true );
70 int createToolBar( const QString&, bool, Qt::ToolBarAreas = Qt::AllToolBarAreas,
71 int = -1, QMainWindow* = 0, bool = true );
72 int createToolBar( const QString&, const QString&, bool, Qt::ToolBarAreas = Qt::AllToolBarAreas,
73 int = -1, QMainWindow* = 0, bool = true );
74 void removeToolBar( const QString& );
75 void removeToolBar( const int );
77 int insert( const int, const int, const int = -1 );
78 int insert( QAction*, const int, const int = -1 );
79 int insert( const int, const QString&, const int = -1 );
80 int insert( QAction*, const QString&, const int = -1 );
82 int append( const int, const int );
83 int append( QAction*, const int );
84 int append( const int, const QString& );
85 int append( QAction*, const QString& );
87 int prepend( const int, const int );
88 int prepend( QAction*, const int );
89 int prepend( const int, const QString& );
90 int prepend( QAction*, const QString& );
92 virtual bool isVisible( const int, const int ) const;
93 virtual void setVisible( const int, const int, const bool );
95 void show( const int );
96 void hide( const int );
97 bool isShown( const int ) const;
98 void setShown( const int, const bool );
100 void remove( const int, const int );
101 void remove( const int, const QString& );
102 void clear( const int );
103 void clear( const QString& );
105 QToolBar* toolBar( const int ) const;
106 QToolBar* toolBar( const QString& ) const;
107 QIntList toolBarsIds() const;
109 bool hasToolBar( const int ) const;
110 bool hasToolBar( const QString& ) const;
112 bool containsAction( const int, const int = -1 ) const;
113 int index( const int, const int ) const;
115 virtual bool load( const QString&, QtxActionMgr::Reader& );
117 int find( QToolBar* ) const;
120 void onToolBarDestroyed();
123 int find( const QString& ) const;
124 QToolBar* find( const QString&, QMainWindow* ) const;
126 virtual void internalUpdate();
127 void updateToolBar( const int );
129 virtual void updateContent();
132 void simplifySeparators( QToolBar* );
133 void triggerUpdate( const int );
136 typedef struct { NodeList nodes; QToolBar* toolBar; } ToolBarInfo; //!< toolbar info
137 typedef QMap<int, ToolBarInfo> ToolBarMap; //!< toolbars map
140 ToolBarMap myToolBars; //!< toobars map
141 QMainWindow* myMainWindow; //!< parent main window
142 QMap<int,int> myUpdateIds; //!< list of actions ID being updated
145 class QtxActionToolMgr::ToolCreator : public QtxActionMgr::Creator
148 ToolCreator( QtxActionMgr::Reader*, QtxActionToolMgr* );
149 virtual ~ToolCreator();
151 virtual int append( const QString&, const bool,
152 const ItemAttributes&, const int );
155 QtxActionToolMgr* myMgr; //!< toolbar manager