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/
20 #ifndef __QTX_POPUP_MGR_HEADER__
21 #define __QTX_POPUP_MGR_HEADER__
24 #include "QtxActionMenuMgr.h"
25 #include "QtxParser.h"
26 #include "QtxStdOperations.h"
30 class QtxListOfOperations;
32 //================================================================
35 //================================================================
36 class QTX_EXPORT QtxPopupMgr : public QtxActionMenuMgr
41 class QTX_EXPORT Selection
44 virtual int count() const = 0;
45 virtual QtxValue param( const int, const QString& ) const = 0;
46 virtual QtxValue globalParam( const QString& ) const;
48 virtual QChar equality() const;
49 virtual QString selCountParam() const;
51 static QChar defEquality();
52 static QString defSelCountParam();
56 class Operations : public QtxStrings
59 Operations( QtxPopupMgr* );
60 virtual ~Operations();
62 virtual int prior( const QString&, bool isBin ) const;
63 virtual QtxParser::Error calculate( const QString&, QtxValue&, QtxValue& ) const;
68 QtxPopupMgr* myPopupMgr;
70 QMap< QString, QtxValue > myValues;
73 friend class Operations;
79 QtxPopupMgr( QPopupMenu*, QObject* = 0 );
80 virtual ~QtxPopupMgr();
82 virtual int registerAction( QAction*,
83 const QString& visible,
84 const QString& toggle = QString::null,
86 virtual void unRegisterAction( const int );
88 virtual bool isVisible( const int actId, const int place ) const;
90 bool hasRule( QAction*, bool visibility ) const;
91 bool hasRule( const int, bool visibility ) const;
92 void setRule( QAction*, const QString&, bool visibility );
93 void setRule( const int, const QString&, bool visibility );
94 void updatePopup( QPopupMenu*, Selection* );
96 //return name of parameter corresponding to selected objects count
97 //it will be set automatically
99 virtual bool load( const QString&, QtxActionMgr::Reader& );
102 typedef QMap< QAction*, QtxParser* > RulesMap;
105 virtual bool isSatisfied( QAction*, bool visibility ) const;
106 void setParams( QtxParser*, QStringList& ) const;
107 RulesMap& map( bool visibility ) const;
109 void createOperations();
112 RulesMap myVisibility, myToggle;
113 Selection* myCurrentSelection;
114 QtxListOfOperations* myOperations;
119 class QtxPopupMgr::PopupCreator : public QtxActionMgr::Creator
122 PopupCreator( QtxActionMgr::Reader*, QtxPopupMgr* );
123 virtual ~PopupCreator();
125 virtual int append( const QString&, const bool,
126 const ItemAttributes&, const int );
128 virtual QString visibleRule( const ItemAttributes& ) const;
129 virtual QString toggleRule( const ItemAttributes& ) const;