1 // Copyright (C) 2007-2014 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, or (at your option) any later version.
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
23 // File: QtxPopupMgr.h
24 // Author: Alexander SOLOVYOV, Sergey TELKOV
29 #include "QtxActionMenuMgr.h"
36 class QtxPopupSelection;
38 class QTX_EXPORT QtxPopupMgr : public QtxActionMenuMgr
43 //! Menu item rule type
45 VisibleRule, //!< menu item visibility state
46 EnableRule, //!< menu item enable state
47 ToggleRule //!< menu item toggle state
54 QtxPopupMgr( QObject* = 0 );
55 QtxPopupMgr( QMenu*, QObject* = 0 );
56 virtual ~QtxPopupMgr();
58 int insertAction( const int, const int, const QString&, const RuleType = VisibleRule );
59 int insertAction( QAction*, const int, const QString&, const RuleType = VisibleRule );
61 virtual int registerAction( QAction*, const int, const QString& rule,
62 const RuleType = VisibleRule );
63 virtual void unRegisterAction( const int );
65 virtual bool isVisible( const int actId, const int place ) const;
67 QString rule( QAction*, const RuleType = VisibleRule ) const;
68 QString rule( const int, const RuleType = VisibleRule ) const;
70 void setRule( QAction*, const QString&, const RuleType = VisibleRule );
71 void setRule( const int, const QString&, const RuleType = VisibleRule );
73 bool hasRule( QAction*, const RuleType = VisibleRule ) const;
74 bool hasRule( const int, const RuleType = VisibleRule ) const;
76 QtxPopupSelection* selection() const;
77 void setSelection( QtxPopupSelection* );
80 void setMenu( QMenu* );
84 virtual bool load( const QString&, QtxActionMgr::Reader& );
87 virtual void internalUpdate();
88 void setParameters( QtxEvalParser*, QStringList& ) const;
89 virtual bool isSatisfied( QAction*, const RuleType = VisibleRule ) const;
90 QtxEvalExpr* expression( QAction*, const RuleType = VisibleRule, const bool = false ) const;
93 bool result( QtxEvalParser* p ) const;
94 QVariant parameter( const QString&, const int = -1 ) const;
97 void onSelectionDestroyed( QObject* );
100 typedef QMap<RuleType, QtxEvalExpr*> ExprMap;
101 typedef QMap<QAction*, ExprMap> RuleMap;
102 typedef QMap<QString, QVariant> CacheMap;
107 QtxPopupSelection* mySelection;
109 friend class QtxPopupSelection;
112 class QTX_EXPORT QtxPopupSelection : public QObject
118 virtual ~QtxPopupSelection();
120 virtual int count() const = 0;
121 virtual QVariant parameter( const QString& ) const;
122 virtual QVariant parameter( const int, const QString& ) const = 0;
124 QString option( const QString& ) const;
125 void setOption( const QString&, const QString& );
127 QtxPopupMgr* popupMgr() const;
128 void setPopupMgr( QtxPopupMgr* );
131 QString equalityParam() const;
132 QString selCountParam() const;
135 typedef QMap<QString, QString> OptionsMap;
136 typedef QPointer<QtxPopupMgr> PopupMgrPtr;
139 OptionsMap myOptions;
140 PopupMgrPtr myPopupMgr;
143 #endif // QTXPOPUPMGR_H