Skip to content
Permalink
Browse files

Return to previous state of vector joins if the vector props dialog w…

…as cancelled
  • Loading branch information
wonder-sk committed Sep 15, 2014
1 parent 8cd5e59 commit f73b0b61e59a3708c3627bb785616542ff6c0cf4
Showing with 26 additions and 0 deletions.
  1. +20 −0 src/app/qgsvectorlayerproperties.cpp
  2. +6 −0 src/app/qgsvectorlayerproperties.h
@@ -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*/

0 comments on commit f73b0b6

Please sign in to comment.
You can’t perform that action at this time.