1 // File: QtxActionMenuMgr.h
2 // Author: Alexander SOLOVYEV, Sergey TELKOV
4 #ifndef QTXACTIONMENUMGR_H
5 #define QTXACTIONMENUMGR_H
8 #include "QtxActionMgr.h"
11 #include <qstringlist.h>
17 #pragma warning( disable:4251 )
20 class QTX_EXPORT QtxActionMenuMgr : public QtxActionMgr
26 typedef QPtrList<MenuNode> NodeList;
27 typedef QPtrListIterator<MenuNode> NodeListIterator;
32 MenuNode() : parent( 0 ), visible( true ) { children.setAutoDelete( true ); };
33 MenuNode( MenuNode* p ) : parent( p ), visible( true ) { children.setAutoDelete( true ); };
48 QtxActionMenuMgr( QMainWindow* );
49 QtxActionMenuMgr( QWidget*, QObject* );
50 virtual ~QtxActionMenuMgr();
52 virtual bool isVisible( const int, const int ) const;
53 virtual void setVisible( const int, const int, const bool );
55 int insert( const int, const QString&, const int, const int = -1 );
56 int insert( QAction*, const QString&, const int, const int = -1 );
58 int insert( const int, const QStringList&, const int, const int = -1 );
59 int insert( QAction*, const QStringList&, const int, const int = -1 );
61 virtual int insert( const int, const int, const int, const int = -1 );
62 int insert( QAction*, const int, const int, const int = -1 );
64 int insert( const QString&, const QString&, const int, const int = -1 );
65 int insert( const QString&, const QStringList&, const int, const int = -1 );
66 virtual int insert( const QString&, const int, const int, const int = -1 );
68 int append( const int, const int, const int );
69 int append( QAction*, const int, const int );
70 int append( const QString&, const int, const int );
72 int prepend( const int, const int, const int );
73 int prepend( QAction*, const int, const int );
74 int prepend( const QString&, const int, const int );
76 void remove( const int );
77 void remove( const int, const int, const int = -1 );
79 void show( const int );
80 void hide( const int );
82 bool isShown( const int ) const;
83 void setShown( const int, const bool );
85 virtual bool load( const QString&, QtxActionMgr::Reader& );
88 void onDestroyed( QObject* );
91 void setWidget( QWidget* );
92 MenuNode* find( const int, const int ) const;
93 MenuNode* find( const int, MenuNode* = 0 ) const;
94 bool find( const int, NodeList&, MenuNode* = 0 ) const;
96 void removeMenu( const int, MenuNode* );
98 QAction* itemAction( const int ) const;
99 MenuAction* menuAction( const int ) const;
101 void updateMenu( MenuNode* = 0, const bool = true, const bool = true );
102 virtual void internalUpdate();
105 bool checkWidget( QWidget* ) const;
106 QWidget* menuWidget( MenuNode* ) const;
107 void simplifySeparators( QWidget* );
108 QString clearTitle( const QString& ) const;
109 int createMenu( const QStringList&, const int );
112 typedef QMap<int, MenuAction*> MenuMap;
120 class QtxActionMenuMgr::MenuCreator : public QtxActionMgr::Creator
123 MenuCreator( QtxActionMgr::Reader*, QtxActionMenuMgr* );
124 virtual ~MenuCreator();
126 virtual int append( const QString&, const bool,
127 const ItemAttributes&, const int );
130 QtxActionMenuMgr* myMgr;