+/*!
+ \brief Enable/disable empty menu
+ \param id menu item ID
+ \param enable if \c true, empty menu will be enabled, otherwise empty menu will be disabled
+*/
+void QtxActionMenuMgr::setEmptyEnabled( const int id, const bool enable )
+{
+ MenuNode* node = find( id );
+ if ( node && menuAction( id ) ) {
+ int old = node->emptyEnabled;
+ node->emptyEnabled += enable ? 1 : -1;
+ if ( ( old <= 0 && enable ) || ( old > 0 && !enable ) ) // update menu only if enabled state has been changed
+ updateMenu( node, true, true );
+ }
+}
+
+/*!
+ \brief Perform delayed menu update.
+ \param id menu item ID
+ \param rec if \c true, perform recursive update
+*/
+void QtxActionMenuMgr::triggerUpdate( const int id, const bool rec )
+{
+ bool isRec = rec;
+ if ( myUpdateIds.contains( id ) )
+ isRec = isRec || myUpdateIds[ id ];
+ myUpdateIds.insert( id, isRec );
+
+ QtxActionMgr::triggerUpdate();
+}
+
+/*!
+ \brief Called when action is changed.
+
+ Schedule delayed update for parent menu of changed action.
+*/
+void QtxActionMenuMgr::actionChanged( int id )
+{
+ NodeList aNodes;
+ find( id, aNodes );
+
+ for ( NodeList::iterator it = aNodes.begin(); it != aNodes.end(); ++it )
+ {
+ MenuNode* node = *it;
+ if ( node->visible ) {
+ triggerUpdate( node->parent ? node->parent->id : myRoot->id, false );
+ }
+ }
+}
+
+/*!
+ \brief Called when delayed content update is performed.
+
+ Customizes the content update operation.
+*/
+void QtxActionMenuMgr::updateContent()
+{
+ // Warning: For correct updating it is necessary to update the most enclosed submenu in first turn
+ // because not updated empty submenu will be skipped. Now the submenus are iterated in
+ // ascending order according to their identifiers. For a submenus with automatically generated
+ // identifiers this will work correctly since the uppermost submenus have the biggest number
+ // (identifiers are generated by decrementing 1 starting from -1). In general, if any submenu
+ // have positive identifiers this method might not work correctly. In this case it would be
+ // necessary to improve this method and to add preliminary sorting a submenus by depth of an
+ // enclosure.
+ for ( QMap<int, bool>::const_iterator it = myUpdateIds.constBegin(); it != myUpdateIds.constEnd(); ++it )
+ {
+ MenuNode* node = it.key() == -1 ? myRoot : find( it.key() );
+ if ( node )
+ updateMenu( node, it.value() );
+ }
+ myUpdateIds.clear();
+}
+
+/*!
+ \class QtxActionMenuMgr::MenuCreator
+ \brief Menu actions creator.
+
+ Used by Reader to create actions by reading descriptions from the file
+ and fill in the action manager with the actions.
+*/
+
+/*!
+ \brief Constructor.
+ \param r menu actions reader
+ \param mgr menu manager
+*/
+QtxActionMenuMgr::MenuCreator::MenuCreator( QtxActionMgr::Reader* r, QtxActionMenuMgr* mgr )