コード例 #1
0
ファイル: pActionsMenuBar.cpp プロジェクト: hlamer/fresh
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();
	}
}
コード例 #2
0
ファイル: pActionsModel.cpp プロジェクト: pasnox/fresh
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();
}