Version: 9.12.0
QtxActionToolMgr.h
Go to the documentation of this file.
1 // Copyright (C) 2007-2023 CEA, EDF, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 
23 // File: QtxActionToolMgr.h
24 // Author: Alexander SOLOVYOV, Sergey TELKOV
25 //
26 #ifndef QTXACTIONTOOLMGR_H
27 #define QTXACTIONTOOLMGR_H
28 
29 #include "Qtx.h"
30 #include "QtxActionMgr.h"
31 
32 #include <QMap>
33 #include <QList>
34 
35 class QToolBar;
36 class QMainWindow;
37 class QAction;
38 
39 #ifdef WIN32
40 #pragma warning( disable:4251 )
41 #endif
42 
44 {
45  Q_OBJECT
46 
47  class ToolNode
48  {
49  public:
50  ToolNode() : id( -1 ), visible( true ) {};
51  ToolNode( const int _id ) : id( _id ), visible( true ) {};
52 
53  int id;
54  bool visible;
55  };
56 
58 
59 protected:
60  class ToolCreator;
61 
62 public:
64  virtual ~QtxActionToolMgr();
65 
66  QMainWindow* mainWindow() const;
67 
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 );
76 
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 );
81 
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& );
86 
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& );
91 
92  virtual bool isVisible( const int, const int ) const;
93  virtual void setVisible( const int, const int, const bool );
94 
95  void show( const int );
96  void hide( const int );
97  bool isShown( const int ) const;
98  void setShown( const int, const bool );
99 
100  void remove( const int, const int );
101  void remove( const int, const QString& );
102  void clear( const int );
103  void clear( const QString& );
104 
105  QToolBar* toolBar( const int ) const;
106  QToolBar* toolBar( const QString& ) const;
107  QIntList toolBarsIds() const;
108 
109  bool hasToolBar( const int ) const;
110  bool hasToolBar( const QString& ) const;
111 
112  bool containsAction( const int, const int = -1 ) const;
113  int index( const int, const int ) const;
114 
115  virtual bool load( const QString&, QtxActionMgr::Reader& );
116 
117  int find( QToolBar* ) const;
118 
119 protected slots:
120  void onToolBarDestroyed();
121 
122 protected:
123  int find( const QString& ) const;
124  QToolBar* find( const QString&, QMainWindow* ) const;
125 
126  virtual void internalUpdate();
127  void updateToolBar( const int );
128 
129  virtual void updateContent();
130 
131 private:
132  void simplifySeparators( QToolBar* );
133  void triggerUpdate( const int );
134 
135 private:
136  typedef struct { NodeList nodes; QToolBar* toolBar; } ToolBarInfo;
137  typedef QMap<int, ToolBarInfo> ToolBarMap;
138 
139 private:
142  QMap<int,int> myUpdateIds;
143 };
144 
146 {
147 public:
149  virtual ~ToolCreator();
150 
151  virtual int append( const QString&, const bool,
152  const ItemAttributes&, const int );
153 
154 private:
156 };
157 
158 #endif
QMap< QString, QString > ItemAttributes
attributes map
Definition: QtxActionMgr.h:108
QList< int > QIntList
list of int values
Definition: Qtx.h:55
#define QTX_EXPORT
Definition: Qtx.h:36
Generic actions creator class.
Definition: QtxActionMgr.h:111
Generic actions description files reader class.
Definition: QtxActionMgr.h:133
Manages a set of actions accessible by unique identifier.
Definition: QtxActionMgr.h:45
virtual bool isVisible(const int, const int) const
Check if an action with actId identifier is visible to the parent action with place identifier.
Definition: QtxActionMgr.cxx:284
virtual void internalUpdate()
Internal update.
Definition: QtxActionMgr.cxx:329
virtual void updateContent()
Internal content update operation.
Definition: QtxActionMgr.cxx:423
virtual void setVisible(const int, const int, const bool)
Set action's visibility flag.
Definition: QtxActionMgr.cxx:300
void triggerUpdate()
Perform delayed update.
Definition: QtxActionMgr.cxx:399
Toolbars creator.
Definition: QtxActionToolMgr.h:146
virtual int append(const QString &, const bool, const ItemAttributes &, const int)
Create and append to the action manager a new toolbar or toolbar action.
Definition: QtxActionToolMgr.cxx:854
ToolCreator(QtxActionMgr::Reader *, QtxActionToolMgr *)
Constructor.
Definition: QtxActionToolMgr.cxx:832
QtxActionToolMgr * myMgr
toolbar manager
Definition: QtxActionToolMgr.h:155
virtual ~ToolCreator()
Destructor.
Definition: QtxActionToolMgr.cxx:842
Represents a toolbutton inside toolbar structure.
Definition: QtxActionToolMgr.h:48
bool visible
visibility status
Definition: QtxActionToolMgr.h:54
ToolNode()
Default constructor.
Definition: QtxActionToolMgr.h:50
int id
tool node ID
Definition: QtxActionToolMgr.h:51
ToolNode(const int _id)
Constructor.
Definition: QtxActionToolMgr.h:51
Toolbar actions manager.
Definition: QtxActionToolMgr.h:44
QList< ToolNode > NodeList
toolbar nodes list
Definition: QtxActionToolMgr.h:57
QMainWindow * myMainWindow
parent main window
Definition: QtxActionToolMgr.h:141
QMap< int, ToolBarInfo > ToolBarMap
toolbars map
Definition: QtxActionToolMgr.h:137
ToolBarMap myToolBars
toobars map
Definition: QtxActionToolMgr.h:140
QMap< int, int > myUpdateIds
list of actions ID being updated
Definition: QtxActionToolMgr.h:142
Definition: QtxActionToolMgr.h:136
NodeList nodes
Definition: QtxActionToolMgr.h:136