1 // Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/
19 // File: QtxActionMgr.h
20 // Author: Alexander SOLOVYEV, Sergey TELKOV
22 #ifndef QTXACTIONMGR_H
23 #define QTXACTIONMGR_H
29 #include <qguardedptr.h>
36 #pragma warning( disable:4251 )
42 Contains set of actions accessible by id.
43 Base class for menu, popup creators and other action containers.
45 class QTX_EXPORT QtxActionMgr : public QObject
49 class SeparatorAction;
59 QtxActionMgr( QObject* parent );
60 virtual ~QtxActionMgr();
62 virtual int registerAction( QAction*, const int = -1 );
63 virtual void unRegisterAction( const int );
65 QAction* action( const int ) const;
66 int actionId( const QAction* ) const;
67 bool contains( const int ) const;
71 void idList( QIntList& ) const;
73 bool isUpdatesEnabled() const;
74 virtual void setUpdatesEnabled( const bool );
76 virtual bool isVisible( const int, const int ) const;
77 virtual void setVisible( const int, const int, const bool );
81 virtual bool isEnabled( const int ) const;
82 virtual void setEnabled( const int, const bool );
84 static QAction* separator( const bool = false );
87 virtual void internalUpdate();
88 int generateId() const;
91 typedef QGuardedPtr<QAction> ActionPtr;
92 typedef QMap<int, ActionPtr> ActionMap;
100 QTX_EXPORT typedef QMap<QString, QString> ItemAttributes;
103 \class QtxActionMgr::Creator
104 Allows to fill automatically action manager with actions created by data from file
106 class QtxActionMgr::Creator
109 Creator( QtxActionMgr::Reader* );
112 Reader* reader() const;
114 virtual int append( const QString&, const bool,
115 const ItemAttributes&, const int ) = 0;
116 virtual void connect( QAction* ) const;
118 virtual bool loadPixmap( const QString&, QPixmap& ) const;
121 static int intValue( const ItemAttributes&, const QString&, const int );
122 static QString strValue( const ItemAttributes&, const QString&,
123 const QString& = QString::null );
125 QtxActionMgr::Reader* myReader;
129 \class QtxActionMgr::Reader
130 This class is used to read files of some format
131 to create actions and to fill action manager automatically
133 class QtxActionMgr::Reader
137 QTX_EXPORT virtual ~Reader();
139 QTX_EXPORT QStringList options() const;
140 QTX_EXPORT QString option( const QString&, const QString& = QString::null ) const;
141 QTX_EXPORT void setOption( const QString&, const QString& );
143 QTX_EXPORT virtual bool read( const QString&, Creator& ) const = 0;
146 QMap< QString, QString > myOptions;
150 \class QtxActionMgr::Reader
151 This class is used to read files of XML format
152 to create actions and to fill action manager automatically
154 class QtxActionMgr::XMLReader : public Reader
157 QTX_EXPORT XMLReader( const QString&, const QString&, const QString& );
158 QTX_EXPORT virtual ~XMLReader();
160 QTX_EXPORT virtual bool read( const QString&, Creator& ) const;
163 QTX_EXPORT virtual void read( const QDomNode&, const int, Creator& ) const;
164 QTX_EXPORT virtual bool isNodeSimilar( const QDomNode&, const QString& ) const;