Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef QTXACTIONTOOLMGR_H
00027 #define QTXACTIONTOOLMGR_H
00028
00029 #include "Qtx.h"
00030 #include "QtxActionMgr.h"
00031
00032 #include <QMap>
00033 #include <QList>
00034
00035 class QToolBar;
00036 class QMainWindow;
00037 class QAction;
00038
00039 #ifdef WIN32
00040 #pragma warning( disable:4251 )
00041 #endif
00042
00043 class QTX_EXPORT QtxActionToolMgr : public QtxActionMgr
00044 {
00045 Q_OBJECT
00046
00047 class ToolNode
00048 {
00049 public:
00050 ToolNode() : id( -1 ), visible( true ) {};
00051 ToolNode( const int _id ) : id( _id ), visible( true ) {};
00052
00053 int id;
00054 bool visible;
00055 };
00056
00057 typedef QList<ToolNode> NodeList;
00058
00059 protected:
00060 class ToolCreator;
00061
00062 public:
00063 QtxActionToolMgr( QMainWindow* );
00064 virtual ~QtxActionToolMgr();
00065
00066 QMainWindow* mainWindow() const;
00067
00068 int createToolBar( const QString&, int = -1, QMainWindow* = 0, bool = true );
00069 int createToolBar( const QString&, bool, Qt::ToolBarAreas = Qt::AllToolBarAreas,
00070 int = -1, QMainWindow* = 0, bool = true );
00071 void removeToolBar( const QString& );
00072 void removeToolBar( const int );
00073
00074 int insert( const int, const int, const int = -1 );
00075 int insert( QAction*, const int, const int = -1 );
00076 int insert( const int, const QString&, const int = -1 );
00077 int insert( QAction*, const QString&, const int = -1 );
00078
00079 int append( const int, const int );
00080 int append( QAction*, const int );
00081 int append( const int, const QString& );
00082 int append( QAction*, const QString& );
00083
00084 int prepend( const int, const int );
00085 int prepend( QAction*, const int );
00086 int prepend( const int, const QString& );
00087 int prepend( QAction*, const QString& );
00088
00089 virtual bool isVisible( const int, const int ) const;
00090 virtual void setVisible( const int, const int, const bool );
00091
00092 void show( const int );
00093 void hide( const int );
00094 bool isShown( const int ) const;
00095 void setShown( const int, const bool );
00096
00097 void remove( const int, const int );
00098 void remove( const int, const QString& );
00099
00100 QToolBar* toolBar( const int ) const;
00101 QToolBar* toolBar( const QString& ) const;
00102 QIntList toolBarsIds() const;
00103
00104 bool hasToolBar( const int ) const;
00105 bool hasToolBar( const QString& ) const;
00106
00107 bool containsAction( const int, const int = -1 ) const;
00108 int index( const int, const int ) const;
00109
00110 virtual bool load( const QString&, QtxActionMgr::Reader& );
00111
00112 int find( QToolBar* ) const;
00113
00114 protected slots:
00115 void onToolBarDestroyed();
00116
00117 protected:
00118 int find( const QString& ) const;
00119 QToolBar* find( const QString&, QMainWindow* ) const;
00120
00121 virtual void internalUpdate();
00122 void updateToolBar( const int );
00123
00124 virtual void updateContent();
00125
00126 private:
00127 void simplifySeparators( QToolBar* );
00128 void triggerUpdate( const int );
00129
00130 private:
00131 typedef struct { NodeList nodes; QToolBar* toolBar; } ToolBarInfo;
00132 typedef QMap<int, ToolBarInfo> ToolBarMap;
00133
00134 private:
00135 ToolBarMap myToolBars;
00136 QMainWindow* myMainWindow;
00137 QMap<int,int> myUpdateIds;
00138 };
00139
00140 class QtxActionToolMgr::ToolCreator : public QtxActionMgr::Creator
00141 {
00142 public:
00143 ToolCreator( QtxActionMgr::Reader*, QtxActionToolMgr* );
00144 virtual ~ToolCreator();
00145
00146 virtual int append( const QString&, const bool,
00147 const ItemAttributes&, const int );
00148
00149 private:
00150 QtxActionToolMgr* myMgr;
00151 };
00152
00153 #endif