void pActionsMenuBar::setModel( pActionsModel* model ) { if ( mModel ) { disconnect( mModel, SIGNAL( actionInserted( QAction* ) ), this, SLOT( model_actionInserted( QAction* ) ) ); disconnect( mModel, SIGNAL( actionChanged( QAction* ) ), this, SLOT( model_actionChanged( QAction* ) ) ); disconnect( mModel, SIGNAL( actionRemoved( QAction* ) ), this, SLOT( model_actionRemoved( QAction* ) ) ); disconnect( mModel, SIGNAL( actionsCleared() ), this, SLOT( model_actionsCleared() ) ); clear(); mModel = 0; } mModel = model; if ( mModel ) { connect( mModel, SIGNAL( actionInserted( QAction* ) ), this, SLOT( model_actionInserted( QAction* ) ) ); connect( mModel, SIGNAL( actionChanged( QAction* ) ), this, SLOT( model_actionChanged( QAction* ) ) ); connect( mModel, SIGNAL( actionRemoved( QAction* ) ), this, SLOT( model_actionRemoved( QAction* ) ) ); connect( mModel, SIGNAL( actionsCleared() ), this, SLOT( model_actionsCleared() ) ); sync(); } }
void pActionsModel::clear() { const int count = rowCount(); if ( count == 0 ) { return; } beginRemoveRows( QModelIndex(), 0, count -1 ); qDeleteAll( mChildren.value( 0 ) ); mChildren.clear(); mActions.clear(); endRemoveRows(); emit actionsCleared(); }