Salome HOME
no message
[modules/gui.git] / src / Qtx / QtxActionToolMgr.h
1 // File:      QtxActionToolMgr.h
2 // Author:    Alexander SOLOVYEV, Sergey TELKOV
3
4 #ifndef QTXACTIONTOOLMGR_H
5 #define QTXACTIONTOOLMGR_H
6
7 #include "Qtx.h"
8
9 #include <qaction.h>
10
11 #include "QtxActionMgr.h"
12
13 class QToolBar;
14 class QMainWindow;
15
16 #ifdef WIN32
17 #pragma warning( disable:4251 )
18 #endif
19
20 class QTX_EXPORT QtxActionToolMgr : public QtxActionMgr
21 {
22   Q_OBJECT
23
24   class ToolNode
25   {
26   public:
27     ToolNode() : id( -1 ), visible( true ) {};
28
29     int       id;
30     bool      visible;
31   };
32
33   typedef QValueList<ToolNode> NodeList;
34
35 protected:
36   class ToolCreator;
37
38 public:
39   QtxActionToolMgr( QMainWindow* );
40   virtual ~QtxActionToolMgr();
41
42   QMainWindow*    mainWindow() const;
43
44   int             createToolBar( const QString&, int = -1 );
45   void            removeToolBar( const QString& );
46   void            removeToolBar( const int );
47
48   int             insert( const int, const int, const int = -1 );
49   int             insert( QAction*, const int, const int = -1 );
50   int             insert( const int, const QString&, const int = -1 );
51   int             insert( QAction*, const QString&, const int = -1 );
52
53   int             append( const int, const int );
54   int             append( QAction*, const int );
55   int             append( const int, const QString& );
56   int             append( QAction*, const QString& );
57
58   int             prepend( const int, const int );
59   int             prepend( QAction*, const int );
60   int             prepend( const int, const QString& );
61   int             prepend( QAction*, const QString& );
62
63   virtual bool    isVisible( const int, const int ) const;
64   virtual void    setVisible( const int, const int, const bool );
65
66   void            show( const int );
67   void            hide( const int );
68   bool            isShown( const int ) const;
69   void            setShown( const int, const bool );
70
71   void            remove( const int, const int );
72   void            remove( const int, const QString& );
73
74   QToolBar*       toolBar( const int ) const;
75   QToolBar*       toolBar( const QString& ) const;
76   
77   bool            hasToolBar( const int ) const;
78   bool            hasToolBar( const QString& ) const;
79
80   virtual bool    load( const QString&, QtxActionMgr::Reader& );
81
82 protected slots:
83   void            onToolBarDestroyed();
84
85 protected:
86   int             find( QToolBar* ) const;  
87   int             find( const QString& ) const;
88   QToolBar*       find( const QString&, QMainWindow* ) const;
89
90   virtual void    internalUpdate();
91   void            updateToolBar( const int );
92
93 private:
94   void            simplifySeparators( QToolBar* );
95
96 private:
97   typedef struct { NodeList nodes; QToolBar* toolBar; } ToolBarInfo;
98   typedef QMap<int, ToolBarInfo>                        ToolBarMap;
99
100 private:
101   ToolBarMap      myToolBars;
102   QMainWindow*    myMainWindow;
103 };
104
105 class QtxActionToolMgr::ToolCreator : public QtxActionMgr::Creator
106 {
107 public:
108   ToolCreator( QtxActionMgr::Reader*, QtxActionToolMgr* );
109   virtual ~ToolCreator();
110
111   virtual int append( const QString&, const bool,
112                       const ItemAttributes&, const int );
113
114 private:
115   QtxActionToolMgr* myMgr;
116 };
117
118 #endif