1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File: QtxPopupMgr.h
23 // Author: Alexander SOLOVYOV, Sergey TELKOV
28 #include "QtxActionMenuMgr.h"
35 class QtxPopupSelection;
37 class QTX_EXPORT QtxPopupMgr : public QtxActionMenuMgr
42 //! Menu item rule type
44 VisibleRule, //!< menu item visibility state
45 EnableRule, //!< menu item enable state
46 ToggleRule //!< menu item toggle state
53 QtxPopupMgr( QObject* = 0 );
54 QtxPopupMgr( QMenu*, QObject* = 0 );
55 virtual ~QtxPopupMgr();
57 int insertAction( const int, const int, const QString&, const RuleType = VisibleRule );
58 int insertAction( QAction*, const int, const QString&, const RuleType = VisibleRule );
60 virtual int registerAction( QAction*, const int, const QString& rule,
61 const RuleType = VisibleRule );
62 virtual void unRegisterAction( const int );
64 virtual bool isVisible( const int actId, const int place ) const;
66 QString rule( QAction*, const RuleType = VisibleRule ) const;
67 QString rule( const int, const RuleType = VisibleRule ) const;
69 void setRule( QAction*, const QString&, const RuleType = VisibleRule );
70 void setRule( const int, const QString&, const RuleType = VisibleRule );
72 bool hasRule( QAction*, const RuleType = VisibleRule ) const;
73 bool hasRule( const int, const RuleType = VisibleRule ) const;
75 QtxPopupSelection* selection() const;
76 void setSelection( QtxPopupSelection* );
79 void setMenu( QMenu* );
83 virtual bool load( const QString&, QtxActionMgr::Reader& );
86 virtual void internalUpdate();
87 void setParameters( QtxEvalParser*, QStringList& ) const;
88 virtual bool isSatisfied( QAction*, const RuleType = VisibleRule ) const;
89 QtxEvalExpr* expression( QAction*, const RuleType = VisibleRule, const bool = false ) const;
92 bool result( QtxEvalParser* p ) const;
93 QVariant parameter( const QString&, const int = -1 ) const;
96 void onSelectionDestroyed( QObject* );
99 typedef QMap<RuleType, QtxEvalExpr*> ExprMap;
100 typedef QMap<QAction*, ExprMap> RuleMap;
101 typedef QMap<QString, QVariant> CacheMap;
106 QtxPopupSelection* mySelection;
109 class QTX_EXPORT QtxPopupSelection : public QObject
115 virtual ~QtxPopupSelection();
117 virtual int count() const = 0;
118 virtual QVariant parameter( const QString& ) const;
119 virtual QVariant parameter( const int, const QString& ) const = 0;
121 QString option( const QString& ) const;
122 void setOption( const QString&, const QString& );
125 QString equalityParam() const;
126 QString selCountParam() const;
129 typedef QMap<QString, QString> OptionsMap;
132 OptionsMap myOptions;
135 #endif // QTXPOPUPMGR_H