]> SALOME platform Git repositories - modules/gui.git/blobdiff - src/Qtx/QtxPopupMgr.cxx
Salome HOME
Join modifications from branch OCC_debug_for_3_2_0b1
[modules/gui.git] / src / Qtx / QtxPopupMgr.cxx
index f01716c165350c93755c30802de8718e746d4f84..37d0cbbc1421fcd2484c899a7dcd0ecb7d5b7909 100644 (file)
 #include <qpopupmenu.h>
 #include <qdatetime.h>
 
-//================================================================
-// Function : 
-// Purpose  : 
-//================================================================
+
+/*!
+  \return value of global parameter (depending on whole selection, but not dependending on one object of selection)
+  \param str - name of parameter
+
+  By default, it returns count of selected objects ("selcount") and list of parameters ("$<name>")
+*/
 QtxValue QtxPopupMgr::Selection::globalParam( const QString& str ) const
 {
   if( str==selCountParam() )
@@ -54,37 +57,33 @@ QtxValue QtxPopupMgr::Selection::globalParam( const QString& str ) const
     return QtxValue();
 }
 
-//================================================================
-// Function : 
-// Purpose  : 
-//================================================================
+/*!
+  \return symbole to detect name of parameter list
+*/
 QChar QtxPopupMgr::Selection::equality() const
 {
   return defEquality();
 }
 
-//================================================================
-// Function : 
-// Purpose  : 
-//================================================================
+/*!
+  \return name of parameter for count of selected objects
+*/
 QString QtxPopupMgr::Selection::selCountParam() const
 {
   return defSelCountParam();
 }
 
-//================================================================
-// Function : 
-// Purpose  : 
-//================================================================
+/*!
+  \return default symbole to detect name of parameter list
+*/
 QChar QtxPopupMgr::Selection::defEquality()
 {
     return '$';
 }
 
-//================================================================
-// Function : 
-// Purpose  : 
-//================================================================
+/*!
+  \return default name of parameter for count of selected objects
+*/
 QString QtxPopupMgr::Selection::defSelCountParam()
 {
     return "selcount";
@@ -92,12 +91,15 @@ QString QtxPopupMgr::Selection::defSelCountParam()
 
 
 
+/*!
+  \class QtxCacheSelection
 
+  Special selection class, that caches parameter values.
+  Every parameter during popup building is calculated only one time,
+  although it may be included to many rules. After calculation
+  it is stored in internal map
+*/
 
-//================================================================
-// Class : 
-// Purpose  : 
-//================================================================
 class QtxCacheSelection : public QtxPopupMgr::Selection
 {
 public:
@@ -115,36 +117,37 @@ private:
   CacheMap                   myParamCache;
 };
 
-//================================================================
-// Function : 
-// Purpose  : 
-//================================================================
+/*!
+  Constructor
+  \param sel - base selection used for parameter calculation
+*/
 QtxCacheSelection::QtxCacheSelection( QtxPopupMgr::Selection* sel )
 : mySel( sel )
 {
 }
 
-//================================================================
-// Function : 
-// Purpose  : 
-//================================================================
+/*!
+  Destructor
+*/
 QtxCacheSelection::~QtxCacheSelection()
 {
 }
 
-//================================================================
-// Function : 
-// Purpose  : 
-//================================================================
+/*!
+  \return count of selected objects
+*/
 int QtxCacheSelection::count() const
 {
   return mySel ? mySel->count() : 0;
 }
 
-//================================================================
-// Function : 
-// Purpose  : 
-//================================================================
+/*!
+  Calculates and caches parameters.
+  Already calculated parameters are returned without calculation
+  \return parameter value
+  \param i - index of selected object
+  \param name - name of parameter
+*/
 QtxValue QtxCacheSelection::param( const int i, const QString& name ) const
 {
   QString param_name = name + "#####" + QString::number( i );
@@ -161,10 +164,12 @@ QtxValue QtxCacheSelection::param( const int i, const QString& name ) const
   }
 }
 
-//================================================================
-// Function : 
-// Purpose  : 
-//================================================================
+/*!
+  Calculates and caches global parameters.
+  Already calculated parameters are returned without calculation
+  \return parameter value
+  \param name - name of parameter
+*/
 QtxValue QtxCacheSelection::globalParam( const QString& name ) const
 {
   if( myParamCache.contains( name ) )
@@ -183,11 +188,10 @@ QtxValue QtxCacheSelection::globalParam( const QString& name ) const
 
 
 
-
-//================================================================
-// Function : 
-// Purpose  : 
-//================================================================
+/*!
+  Constructor
+  \param mgr - popup manager
+*/
 QtxPopupMgr::Operations::Operations( QtxPopupMgr* mgr )
 : QtxStrings(),
   myPopupMgr( mgr )
@@ -201,19 +205,19 @@ QtxPopupMgr::Operations::Operations( QtxPopupMgr* mgr )
     myParser = new QtxParser( mgr->myOperations );
 }
 
-//================================================================
-// Function : 
-// Purpose  : 
-//================================================================
+/*!
+  Destructor
+  Deletes internal parser
+*/
 QtxPopupMgr::Operations::~Operations()
 {
     delete myParser;
 }
 
-//================================================================
-// Function : 
-// Purpose  : 
-//================================================================
+/*!
+    \return priority of popup operation 'op'.
+    \param isBin indicate whether the operation is binary
+*/
 int QtxPopupMgr::Operations::prior( const QString& op, bool isBin ) const
 {
     if( !isBin && ( op=="every" || op=="any" || op=="onlyone" ) )
@@ -223,10 +227,13 @@ int QtxPopupMgr::Operations::prior( const QString& op, bool isBin ) const
 
 }
 
-//================================================================
-// Function : 
-// Purpose  : 
-//================================================================
+/*!
+    Calculates result of operation
+    \return one of error states
+    \param op - name of operation
+    \param v1 - first operation argument (must be used also to store result)
+    \param v2 - second operation argument
+*/
 QtxParser::Error QtxPopupMgr::Operations::calculate
     ( const QString& op, QtxValue& v1, QtxValue& v2 ) const
 {
@@ -299,10 +306,9 @@ QtxParser::Error QtxPopupMgr::Operations::calculate
         return QtxStrings::calculate( op, v1, v2 );
 }
 
-//================================================================
-// Function : 
-// Purpose  : 
-//================================================================
+/*!
+  Clears internal map of values
+*/
 void QtxPopupMgr::Operations::clear()
 {
     myValues.clear();
@@ -315,11 +321,9 @@ void QtxPopupMgr::Operations::clear()
 
 
 
-
-//================================================================
-// Function : 
-// Purpose  : 
-//================================================================
+/*!
+  Constructor
+*/
 QtxPopupMgr::QtxPopupMgr( QPopupMenu* popup, QObject* parent )
 : QtxActionMenuMgr( popup, parent ),
   myCurrentSelection( 0 )
@@ -327,18 +331,16 @@ QtxPopupMgr::QtxPopupMgr( QPopupMenu* popup, QObject* parent )
     createOperations();
 }
 
-//================================================================
-// Function : 
-// Purpose  : 
-//================================================================
+/*!
+  Destructor
+*/
 QtxPopupMgr::~QtxPopupMgr()
 {
 }
 
-//================================================================
-// Function : 
-// Purpose  : 
-//================================================================
+/*!
+  Creates popup operations instance
+*/
 void QtxPopupMgr::createOperations()
 {
     myOperations = new QtxListOfOperations;
@@ -349,10 +351,13 @@ void QtxPopupMgr::createOperations()
     myOperations->append( "custom",  new Operations( this ), 200 );
 }
 
-//================================================================
-// Function : 
-// Purpose  : 
-//================================================================
+/*!
+  Additional version of registerAction
+  \param act - action to be registered
+  \param visible - rule for visibility state
+  \param toggle - rule for toggle on state
+  \param id - proposed id (if it is less than 0, then id will be generated automatically)
+*/
 int QtxPopupMgr::registerAction( QAction* act,
                                  const QString& visible,
                                  const QString& toggle,
@@ -364,10 +369,10 @@ int QtxPopupMgr::registerAction( QAction* act,
     return _id;
 }
 
-//================================================================
-// Function : 
-// Purpose  : 
-//================================================================
+/*!
+  Removes action from internal map
+  \param id - action id
+*/
 void QtxPopupMgr::unRegisterAction( const int id )
 {
     QAction* act = action( id );
@@ -379,28 +384,32 @@ void QtxPopupMgr::unRegisterAction( const int id )
     //QtxActionMenuMgr::unRegisterAction( id );
 }
 
-//================================================================
-// Function : 
-// Purpose  : 
-//================================================================
+/*!
+  \return true if manager has rule for action
+  \param act - action
+  \param visibility - if it is true, then rule for "visibility" is checked, otherwise - for "toggle"
+*/
 bool QtxPopupMgr::hasRule( QAction* act, bool visibility ) const
 {
     return map( visibility ).contains( act );
 }
 
-//================================================================
-// Function : 
-// Purpose  : 
-//================================================================
+/*!
+  \return true if manager has rule for action
+  \param id - action id
+  \param visibility - if it is true, then rule for "visibility" is checked, otherwise - for "toggle"
+*/
 bool QtxPopupMgr::hasRule( const int id, bool visibility ) const
 {
     return hasRule( action( id ), visibility );
 }
 
-//================================================================
-// Function : 
-// Purpose  : 
-//================================================================
+/*!
+  Sets new rule for action
+  \param act - action
+  \param rule - string expression of rule
+  \param visibility - if it is true, then rule for "visibility" will be set, otherwise - for "toggle"
+*/
 void QtxPopupMgr::setRule( QAction* act, const QString& rule, bool visibility )
 {
     if( !act || rule.isEmpty() )
@@ -423,19 +432,21 @@ void QtxPopupMgr::setRule( QAction* act, const QString& rule, bool visibility )
     }
 }
 
-//================================================================
-// Function : 
-// Purpose  : 
-//================================================================
+/*!
+  Sets new rule for action
+  \param id - action id
+  \param rule - string expression of rule
+  \param visibility - if it is true, then rule for "visibility" will be set, otherwise - for "toggle"
+*/
 void QtxPopupMgr::setRule( const int id, const QString& rule, bool visibility )
 {
     setRule( action( id ), rule, visibility );
 }
 
-//================================================================
-// Function : 
-// Purpose  : 
-//================================================================
+/*!
+  \return true if parser has finished work without errors
+  \param p - parser
+*/
 bool result( QtxParser* p )
 {
     bool res = false;
@@ -449,10 +460,11 @@ bool result( QtxParser* p )
     return res;
 }
 
-//================================================================
-// Function : 
-// Purpose  : 
-//================================================================
+/*!
+  Fills parser parameters with help of Selection::globalParam() method
+  \param p - parser
+  \param specific - list will be filled with names of parameters depending on selection objects (not global)
+*/
 void QtxPopupMgr::setParams( QtxParser* p, QStringList& specific ) const
 {
     if( !p || !myCurrentSelection )
@@ -473,6 +485,10 @@ void QtxPopupMgr::setParams( QtxParser* p, QStringList& specific ) const
     }
 }
 
+/*!
+  \return true if 'v1'<'v2'
+  This function can work with many types of values
+*/
 bool operator<( const QtxValue& v1, const QtxValue& v2 )
 {
   QVariant::Type t1 = v1.type(), t2 = v2.type();
@@ -512,10 +528,11 @@ bool operator<( const QtxValue& v1, const QtxValue& v2 )
     return t1<t2;
 }
 
-//================================================================
-// Function : 
-// Purpose  : 
-//================================================================
+/*!
+  \return true if rule of action is satisfied on current selection
+  \param act - action
+  \param visibility - what rule is checked: for visibility(true) or for toggle(false)
+*/
 bool QtxPopupMgr::isSatisfied( QAction* act, bool visibility ) const
 {
   QString menu = act->menuText();
@@ -580,10 +597,11 @@ bool QtxPopupMgr::isSatisfied( QAction* act, bool visibility ) const
   return res;
 }
 
-//================================================================
-// Function : 
-// Purpose  : 
-//================================================================
+/*!
+  \return true if item corresponding to action is visible
+  \param actId - action id
+  \param place - index of place
+*/
 bool QtxPopupMgr::isVisible( const int actId, const int place ) const
 {
     bool res = QtxActionMenuMgr::isVisible( actId, place );
@@ -593,10 +611,11 @@ bool QtxPopupMgr::isVisible( const int actId, const int place ) const
     return res;
 }
 
-//================================================================
-// Function : 
-// Purpose  : 
-//================================================================
+/*!
+  Updates popup according to selection
+  \param p - popup menu
+  \param sel - selection
+*/
 void QtxPopupMgr::updatePopup( QPopupMenu* p, Selection* sel )
 {
   QTime t1 = QTime::currentTime();
@@ -620,19 +639,21 @@ void QtxPopupMgr::updatePopup( QPopupMenu* p, Selection* sel )
   delete myCurrentSelection;
 }
 
-//================================================================
-// Function : 
-// Purpose  : 
-//================================================================
+/*!
+  \return reference to map of rules
+  \param visibility - type of map: visibility of toggle
+*/
 QtxPopupMgr::RulesMap& QtxPopupMgr::map( bool visibility ) const
 {
     return ( RulesMap& )( visibility ? myVisibility : myToggle );
 }
 
-//================================================================
-// Function : 
-// Purpose  : 
-//================================================================
+/*!
+  Loads actions description from file
+  \param fname - name of file
+  \param r - reader of file
+  \return true on success
+*/
 bool QtxPopupMgr::load( const QString& fname, QtxActionMgr::Reader& r )
 {
   PopupCreator cr( &r, this );
@@ -642,10 +663,11 @@ bool QtxPopupMgr::load( const QString& fname, QtxActionMgr::Reader& r )
 
 
 
-//================================================================
-// Function : 
-// Purpose  : 
-//================================================================
+/*!
+  Constructor
+  \param r - menu reader
+  \param mgr - menu manager
+*/
 QtxPopupMgr::PopupCreator::PopupCreator( QtxActionMgr::Reader* r,
                                          QtxPopupMgr* mgr )
 : QtxActionMgr::Creator( r ),
@@ -653,18 +675,20 @@ QtxPopupMgr::PopupCreator::PopupCreator( QtxActionMgr::Reader* r,
 {
 }
 
-//================================================================
-// Function : 
-// Purpose  : 
-//================================================================
-QtxPopupMgr::PopupCreator::~PopupCreator()
+/*!
+  Destructor
+*/QtxPopupMgr::PopupCreator::~PopupCreator()
 {
 }
 
-//================================================================
-// Function : 
-// Purpose  : 
-//================================================================
+
+/*!
+  Appends new menu items
+  \param tag - tag of item
+  \param subMenu - it has submenu
+  \param attr - list of attributes
+  \param pId - id of action corresponding to parent item
+*/
 int QtxPopupMgr::PopupCreator::append( const QString& tag, const bool subMenu,
                                        const ItemAttributes& attr, const int pId )
 {
@@ -716,19 +740,19 @@ int QtxPopupMgr::PopupCreator::append( const QString& tag, const bool subMenu,
   return res;
 }
 
-//================================================================
-// Function : 
-// Purpose  : 
-//================================================================
+/*!
+  \return visibility rule by attributes
+  Default implementation is empty
+*/
 QString QtxPopupMgr::PopupCreator::visibleRule( const ItemAttributes& ) const
 {
   return QString::null;
 }
 
-//================================================================
-// Function : 
-// Purpose  : 
-//================================================================
+/*!
+  \return toggle rule by attributes
+  Default implementation is empty
+*/
 QString QtxPopupMgr::PopupCreator::toggleRule( const ItemAttributes& ) const
 {
   return QString::null;