mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
Return to previous state of vector joins if the vector props dialog was cancelled
This commit is contained in:
parent
8cd5e59e89
commit
f73b0b61e5
@ -84,6 +84,7 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(
|
||||
|
||||
connect( buttonBox->button( QDialogButtonBox::Apply ), SIGNAL( clicked() ), this, SLOT( apply() ) );
|
||||
connect( this, SIGNAL( accepted() ), this, SLOT( apply() ) );
|
||||
connect( this, SIGNAL( rejected() ), this, SLOT( onCancel() ) );
|
||||
|
||||
connect( mOptionsStackedWidget, SIGNAL( currentChanged( int ) ), this, SLOT( mOptionsStackedWidget_CurrentChanged( int ) ) );
|
||||
|
||||
@ -214,6 +215,8 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(
|
||||
addJoinToTreeWidget( joins[i] );
|
||||
}
|
||||
|
||||
mOldJoins = layer->vectorJoins();
|
||||
|
||||
diagramPropertiesDialog = new QgsDiagramProperties( layer, mDiagramFrame );
|
||||
diagramPropertiesDialog->layout()->setMargin( 0 );
|
||||
mDiagramFrame->setLayout( new QVBoxLayout( mDiagramFrame ) );
|
||||
@ -571,6 +574,8 @@ void QgsVectorLayerProperties::apply()
|
||||
simplifyMethod.setMaximumScale( 1.0 / mSimplifyMaximumScaleComboBox->scale() );
|
||||
layer->setSimplifyMethod( simplifyMethod );
|
||||
|
||||
mOldJoins = layer->vectorJoins();
|
||||
|
||||
// update symbology
|
||||
emit refreshLegend( layer->id() );
|
||||
|
||||
@ -579,6 +584,21 @@ void QgsVectorLayerProperties::apply()
|
||||
QgsProject::instance()->dirty( true );
|
||||
}
|
||||
|
||||
void QgsVectorLayerProperties::onCancel()
|
||||
{
|
||||
if ( mOldJoins != layer->vectorJoins() )
|
||||
{
|
||||
// need to undo changes in vector layer joins - they are applied directly to the layer (not in apply())
|
||||
// so other parts of the properties dialog can use the fields from the joined layers
|
||||
|
||||
foreach ( const QgsVectorJoinInfo& info, layer->vectorJoins() )
|
||||
layer->removeJoin( info.joinLayerId );
|
||||
|
||||
foreach ( const QgsVectorJoinInfo& info, mOldJoins )
|
||||
layer->addJoin( info );
|
||||
}
|
||||
}
|
||||
|
||||
void QgsVectorLayerProperties::on_pbnQueryBuilder_clicked()
|
||||
{
|
||||
// launch the query builder
|
||||
|
@ -96,6 +96,9 @@ class APP_EXPORT QgsVectorLayerProperties : public QgsOptionsDialogBase, private
|
||||
/** Called when apply button is pressed or dialog is accepted */
|
||||
void apply();
|
||||
|
||||
/** Called when cancel button is pressed */
|
||||
void onCancel();
|
||||
|
||||
//
|
||||
//methods reimplemented from qt designer base class
|
||||
//
|
||||
@ -166,6 +169,9 @@ class APP_EXPORT QgsVectorLayerProperties : public QgsOptionsDialogBase, private
|
||||
/**Fields dialog. If apply is pressed, options are applied to vector's diagrams*/
|
||||
QgsFieldsProperties* mFieldsPropertiesDialog;
|
||||
|
||||
//! List of joins of a layer at the time of creation of the dialog. Used to return joins to previous state if dialog is cancelled
|
||||
QList< QgsVectorJoinInfo > mOldJoins;
|
||||
|
||||
void initDiagramTab();
|
||||
|
||||
/**Buffer pixmap which takes the picture of renderers before they are assigned to the vector layer*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user