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 )
39 class QTX_EXPORT QtxActionMgr : public QObject
43 class SeparatorAction;
53 QtxActionMgr( QObject* parent );
54 virtual ~QtxActionMgr();
56 virtual int registerAction( QAction*, const int = -1 );
57 virtual void unRegisterAction( const int );
59 QAction* action( const int ) const;
60 int actionId( const QAction* ) const;
61 bool contains( const int ) const;
65 void idList( QIntList& ) const;
67 bool isUpdatesEnabled() const;
68 virtual void setUpdatesEnabled( const bool );
70 virtual bool isVisible( const int, const int ) const;
71 virtual void setVisible( const int, const int, const bool );
75 virtual bool isEnabled( const int ) const;
76 virtual void setEnabled( const int, const bool );
78 static QAction* separator( const bool = false );
81 virtual void internalUpdate();
82 int generateId() const;
85 typedef QGuardedPtr<QAction> ActionPtr;
86 typedef QMap<int, ActionPtr> ActionMap;
94 QTX_EXPORT typedef QMap<QString, QString> ItemAttributes;
96 class QtxActionMgr::Creator
99 Creator( QtxActionMgr::Reader* );
102 Reader* reader() const;
104 virtual int append( const QString&, const bool,
105 const ItemAttributes&, const int ) = 0;
106 virtual void connect( QAction* ) const;
108 virtual bool loadPixmap( const QString&, QPixmap& ) const;
111 static int intValue( const ItemAttributes&, const QString&, const int );
112 static QString strValue( const ItemAttributes&, const QString&,
113 const QString& = QString::null );
115 QtxActionMgr::Reader* myReader;
118 class QtxActionMgr::Reader
122 QTX_EXPORT virtual ~Reader();
124 QTX_EXPORT QStringList options() const;
125 QTX_EXPORT QString option( const QString&, const QString& = QString::null ) const;
126 QTX_EXPORT void setOption( const QString&, const QString& );
128 QTX_EXPORT virtual bool read( const QString&, Creator& ) const = 0;
131 QMap< QString, QString > myOptions;
134 class QtxActionMgr::XMLReader : public Reader
137 QTX_EXPORT XMLReader( const QString&, const QString&, const QString& );
138 QTX_EXPORT virtual ~XMLReader();
140 QTX_EXPORT virtual bool read( const QString&, Creator& ) const;
143 QTX_EXPORT virtual void read( const QDomNode&, const int, Creator& ) const;
144 QTX_EXPORT virtual bool isNodeSimilar( const QDomNode&, const QString& ) const;