void QgsComposerAttributeTableWidget::on_mAttributesPushButton_clicked() { if ( !mComposerTable ) { return; } //make deep copy of current columns, so we can restore them in case of cancellation QList<QgsComposerTableColumn*> currentColumns; QList<QgsComposerTableColumn*>::const_iterator it = mComposerTable->columns()->constBegin(); for ( ; it != mComposerTable->columns()->constEnd() ; ++it ) { QgsComposerTableColumn* copy = ( *it )->clone(); currentColumns.append( copy ); } QgsComposition* composition = mComposerTable->composition(); if ( composition ) { composition->beginMultiFrameCommand( mComposerTable, tr( "Table attribute settings" ) ); } //temporarily block updates for the window, to stop table trying to repaint under windows (#11462) window()->setUpdatesEnabled( false ); QgsAttributeSelectionDialog d( mComposerTable, mComposerTable->sourceLayer(), 0 ); if ( d.exec() == QDialog::Accepted ) { mComposerTable->refreshAttributes(); //safe to unblock updates window()->setUpdatesEnabled( true ); mComposerTable->update(); if ( composition ) { composition->endMultiFrameCommand(); } //clear currentColumns to free memory qDeleteAll( currentColumns ); currentColumns.clear(); } else { //undo changes mComposerTable->setColumns( currentColumns ); window()->setUpdatesEnabled( true ); if ( composition ) { composition->cancelMultiFrameCommand(); } } }
void QgsComposerAttributeTableWidget::on_mAttributesPushButton_clicked() { if ( !mComposerTable ) { return; } //make deep copy of current columns, so we can restore them in case of cancellation QList<QgsComposerTableColumn*> currentColumns; QList<QgsComposerTableColumn*>::const_iterator it = mComposerTable->columns()->constBegin(); for ( ; it != mComposerTable->columns()->constEnd() ; ++it ) { QgsComposerTableColumn* copy = ( *it )->clone(); currentColumns.append( copy ); } QgsComposition* composition = mComposerTable->composition(); if ( composition ) { composition->beginMultiFrameCommand( mComposerTable, tr( "Table attribute settings" ) ); } QgsAttributeSelectionDialog d( mComposerTable, mComposerTable->vectorLayer(), 0 ); if ( d.exec() == QDialog::Accepted ) { mComposerTable->refreshAttributes(); mComposerTable->update(); if ( composition ) { composition->endMultiFrameCommand(); } //clear currentColumns to free memory qDeleteAll( currentColumns ); currentColumns.clear(); } else { //undo changes mComposerTable->setColumns( currentColumns ); if ( composition ) { composition->cancelMultiFrameCommand(); } } }