void QtxActionMenuMgr::remove( const int id, const int pId, const int group )
{
- MenuNode* pNode = find( pId );
+ MenuNode* pNode = pId == -1 ? &myRoot : find( pId );
if ( !pNode )
return;
}
if ( pid ) {
realId = findId( id, pid );
- if ( realId != -1 )
+ if ( realId != -1 ) {
+ bool updatesEnabled = isUpdatesEnabled();
+ setUpdatesEnabled( false );
emit menuHighlighted( pid, realId );
+ setUpdatesEnabled( updatesEnabled );
+ updateMenu( find( realId ) );
+ }
}
}
connect( myMenu, SIGNAL( destroyed( QObject* ) ), this, SLOT( onDestroyed( QObject* ) ) );
}
-QtxActionMenuMgr::MenuNode* QtxActionMenuMgr::find( const int actId, const int pId ) const
+QtxActionMenuMgr::MenuNode* QtxActionMenuMgr::find( const int actId, const int pId, const bool rec ) const
{
- return find( actId, find( pId ) );
+ return find( actId, find( pId ), rec );
}
-QtxActionMenuMgr::MenuNode* QtxActionMenuMgr::find( const int id, MenuNode* startNode ) const
+QtxActionMenuMgr::MenuNode* QtxActionMenuMgr::find( const int id, MenuNode* startNode, const bool rec ) const
{
MenuNode* node = 0;
MenuNode* start = startNode ? startNode : (MenuNode*)&myRoot;
{
if ( it.current()->id == id )
node = it.current();
- else
- node = find( id, it.current() );
+ else if ( rec )
+ node = find( id, it.current(), rec );
}
return node;
}
return !lst.isEmpty();
}
-QtxActionMenuMgr::MenuNode* QtxActionMenuMgr::find( const QString& title, const int id, const int pId ) const
+QtxActionMenuMgr::MenuNode* QtxActionMenuMgr::find( const QString& title, const int pId, const bool rec ) const
{
- return find( title, id, find( pId ) );
+ return find( title, find( pId ), rec );
}
-bool QtxActionMenuMgr::find( const QString& title, const int id, NodeList& lst, MenuNode* startNode ) const
+bool QtxActionMenuMgr::find( const QString& title, NodeList& lst, MenuNode* startNode ) const
{
MenuNode* start = startNode ? startNode : (MenuNode*)&myRoot;
for ( NodeListIterator it( start->children ); it.current(); ++it )
QAction* a = itemAction( it.current()->id );
if ( !a )
a = menuAction( it.current()->id );
- if ( a && clearTitle( a->text() ) == clearTitle( title ) &&
- ( it.current()->id == id || id == -1 ) )
+ if ( a && clearTitle( a->menuText() ) == clearTitle( title ) )
lst.prepend( it.current() );
- find( title, id, lst, it.current() );
+ find( title, lst, it.current() );
}
return !lst.isEmpty();
}
-QtxActionMenuMgr::MenuNode* QtxActionMenuMgr::find( const QString& title, const int id, MenuNode* startNode ) const
+QtxActionMenuMgr::MenuNode* QtxActionMenuMgr::find( const QString& title, MenuNode* startNode, const bool rec ) const
{
MenuNode* node = 0;
MenuNode* start = startNode ? startNode : (MenuNode*)&myRoot;
QAction* a = itemAction( it.current()->id );
if ( !a )
a = menuAction( it.current()->id );
- if ( a && clearTitle( a->text() ) == clearTitle( title ) &&
- ( it.current()->id == id || id == -1 ) )
+ if ( a && clearTitle( a->menuText() ) == clearTitle( title ) )
node = it.current();
- if ( !node )
- node = find( title, id, it.current() );
+ if ( !node && rec )
+ node = find( title, it.current(), rec );
}
return node;
}
return r.read( fname, cr );
}
-bool QtxActionMenuMgr::contains( const QString& title, const int id, const int pid ) const
+bool QtxActionMenuMgr::containsMenu( const QString& title, const int pid ) const
{
- return (bool)find( title, id, pid );
+ return (bool)find( title, pid, false );
}
-bool QtxActionMenuMgr::contains( const int id, const int pid ) const
+bool QtxActionMenuMgr::containsMenu( const int id, const int pid ) const
{
- return (bool)find( id, pid );
+ return (bool)find( id, pid, false );
}
/*!
virtual bool load( const QString&, QtxActionMgr::Reader& );
- bool contains( const QString&, const int, const int ) const;
- bool contains( const int, const int ) const;
+ bool containsMenu( const QString&, const int ) const;
+ bool containsMenu( const int, const int ) const;
private slots:
protected:
void setWidget( QWidget* );
- MenuNode* find( const int, const int ) const;
- MenuNode* find( const int, MenuNode* = 0 ) const;
+ MenuNode* find( const int, const int, const bool = true ) const;
+ MenuNode* find( const int, MenuNode* = 0, const bool = true ) const;
bool find( const int, NodeList&, MenuNode* = 0 ) const;
- MenuNode* find( const QString&, const int, const int ) const;
- MenuNode* find( const QString&, const int, MenuNode* = 0 ) const;
- bool find( const QString&, const int, NodeList&, MenuNode* = 0 ) const;
+ MenuNode* find( const QString&, const int, const bool = true ) const;
+ MenuNode* find( const QString&, MenuNode* = 0, const bool = true ) const;
+ bool find( const QString&, NodeList&, MenuNode* = 0 ) const;
int findId( const int, const int = -1 ) const;
void removeMenu( const int, MenuNode* );