Skip to content
Permalink
Browse files

Remove redundant setLayer slots from QgsField(ComboBox|ExpressionWidget)

and switch uses of remaining slot to new style connects
  • Loading branch information
nyalldawson committed Nov 21, 2016
1 parent 22dc096 commit 8c8be007b9d1da1b686309e4cf4d44e16738863d
@@ -842,6 +842,18 @@ QgsFeatureRendererV2 {#qgis_api_break_3_0_QgsFeatureRendererV2}
- copyPaintEffect() was removed. copyRendererData() should be used instead.


QgsFieldCombobox {#qgis_api_break_3_0_QgsFieldCombobox}
----------------

- The setLayer( QgsVectorlayer* ) slot has been removed. Use the setLayer( QgsMapLayer* ) slot instead.


QgsFieldExpressionWidget {#qgis_api_break_3_0_QgsFieldExpressionWidget}
------------------------

- The setLayer( QgsVectorlayer* ) slot has been removed. Use the setLayer( QgsMapLayer* ) slot instead.


QgsFields {#qgis_api_break_3_0_QgsFields}
---------

@@ -42,18 +42,23 @@ class QgsFieldComboBox : QComboBox
//! return the currently selected field
QString currentField() const;

//! Returns the currently used layer
/**
* Returns the layer currently associated with the combobox.
* @see setLayer()
*/
QgsVectorLayer* layer() const;

signals:
//! the signal is emitted when the currently selected field changes
void fieldChanged( const QString& fieldName );

public slots:
//! set the layer of which the fields are listed
void setLayer( QgsVectorLayer* layer );

//! convenience slot to connect QgsMapLayerComboBox layer signal
/**
* Sets the layer for which fields are listed in the combobox. If no layer is set
* or a non-vector layer is set then the combobox will be empty.
* @see layer()
*/
void setLayer( QgsMapLayer* layer );

//! setField sets the currently selected field
@@ -64,7 +64,10 @@ class QgsFieldExpressionWidget : QWidget
*/
QString expression() const;

//! Returns the currently used layer
/**
* Returns the layer currently associated with the widget.
* @see setLayer()
*/
QgsVectorLayer* layer() const;

/**
@@ -86,10 +89,10 @@ class QgsFieldExpressionWidget : QWidget
// void returnPressed();

public slots:
//! set the layer used to display the fields and expression
void setLayer( QgsVectorLayer* layer );

//! convenience slot to connect QgsMapLayerComboBox layer signal
/**
* Sets the layer used to display the fields and expression.
* @see layer()
*/
void setLayer( QgsMapLayer* layer );

//! sets the current row in the widget
@@ -33,8 +33,8 @@ QgsAtlasCompositionWidget::QgsAtlasCompositionWidget( QWidget* parent, QgsCompos

mAtlasCoverageLayerComboBox->setFilters( QgsMapLayerProxyModel::VectorLayer );

connect( mAtlasCoverageLayerComboBox, SIGNAL( layerChanged( QgsMapLayer* ) ), mAtlasSortFeatureKeyComboBox, SLOT( setLayer( QgsMapLayer* ) ) );
connect( mAtlasCoverageLayerComboBox, SIGNAL( layerChanged( QgsMapLayer* ) ), mPageNameWidget, SLOT( setLayer( QgsMapLayer* ) ) );
connect( mAtlasCoverageLayerComboBox, &QgsMapLayerComboBox::layerChanged, mAtlasSortFeatureKeyComboBox, &QgsFieldComboBox::setLayer );
connect( mAtlasCoverageLayerComboBox, &QgsMapLayerComboBox::layerChanged, mPageNameWidget, &QgsFieldExpressionWidget::setLayer );
connect( mAtlasCoverageLayerComboBox, SIGNAL( layerChanged( QgsMapLayer* ) ), this, SLOT( changeCoverageLayer( QgsMapLayer* ) ) );
connect( mAtlasSortFeatureKeyComboBox, SIGNAL( fieldChanged( QString ) ), this, SLOT( changesSortFeatureField( QString ) ) );
connect( mPageNameWidget, SIGNAL( fieldChanged( QString, bool ) ), this, SLOT( pageNameExpressionChanged( QString, bool ) ) );
@@ -43,8 +43,8 @@ QgsJoinDialog::QgsJoinDialog( QgsVectorLayer* layer, QList<QgsMapLayer*> already

mJoinLayerComboBox->setFilters( QgsMapLayerProxyModel::VectorLayer );
mJoinLayerComboBox->setExceptedLayerList( alreadyJoinedLayers );
connect( mJoinLayerComboBox, SIGNAL( layerChanged( QgsMapLayer* ) ), mJoinFieldComboBox, SLOT( setLayer( QgsMapLayer* ) ) );
connect( mJoinLayerComboBox, SIGNAL( layerChanged( QgsMapLayer* ) ), this, SLOT( joinedLayerChanged( QgsMapLayer* ) ) );
connect( mJoinLayerComboBox, &QgsMapLayerComboBox::layerChanged, mJoinFieldComboBox, &QgsFieldComboBox::setLayer );
connect( mJoinLayerComboBox, &QgsMapLayerComboBox::layerChanged, this, &QgsJoinDialog::joinedLayerChanged );

mCacheInMemoryCheckBox->setChecked( true );

@@ -55,7 +55,7 @@ QgsJoinDialog::QgsJoinDialog( QgsVectorLayer* layer, QList<QgsMapLayer*> already
joinedLayerChanged( joinLayer );
}

connect( mJoinLayerComboBox, SIGNAL( layerChanged( QgsMapLayer* ) ), this, SLOT( checkDefinitionValid() ) );
connect( mJoinLayerComboBox, &QgsMapLayerComboBox::layerChanged, this, &QgsJoinDialog::checkDefinitionValid );
connect( mJoinFieldComboBox, SIGNAL( fieldChanged( QString ) ), this, SLOT( checkDefinitionValid() ) );
connect( mTargetFieldComboBox, SIGNAL( fieldChanged( QString ) ), this, SLOT( checkDefinitionValid() ) );

@@ -83,7 +83,7 @@ QgsLayerStylingWidget::QgsLayerStylingWidget( QgsMapCanvas* canvas, const QList<

connect( mOptionsListWidget, SIGNAL( currentRowChanged( int ) ), this, SLOT( updateCurrentWidgetLayer() ) );
connect( mButtonBox->button( QDialogButtonBox::Apply ), SIGNAL( clicked() ), this, SLOT( apply() ) );
connect( mLayerCombo, SIGNAL( layerChanged( QgsMapLayer* ) ), this, SLOT( setLayer( QgsMapLayer* ) ) );
connect( mLayerCombo, &QgsMapLayerComboBox::layerChanged, this, &QgsLayerStylingWidget::setLayer );
connect( mLiveApplyCheck, SIGNAL( toggled( bool ) ), this, SLOT( liveApplyToggled( bool ) ) );

mStackedWidget->setCurrentIndex( 0 );
@@ -25,10 +25,8 @@ QgsRelationAddDlg::QgsRelationAddDlg( QWidget *parent )
{
setupUi( this );

connect( mCbxReferencingLayer, &QgsMapLayerComboBox::layerChanged, this, [=]( QgsMapLayer * layer ) { mCbxReferencingField->setLayer( layer ); }
);
connect( mCbxReferencedLayer, &QgsMapLayerComboBox::layerChanged, this, [=]( QgsMapLayer * layer ) { mCbxReferencedField->setLayer( layer ); }
);
connect( mCbxReferencingLayer, &QgsMapLayerComboBox::layerChanged, mCbxReferencingField, &QgsFieldComboBox::setLayer );
connect( mCbxReferencedLayer, &QgsMapLayerComboBox::layerChanged, mCbxReferencedField, &QgsFieldComboBox::setLayer );

mCbxReferencingLayer->setFilters( QgsMapLayerProxyModel::VectorLayer );
mCbxReferencingField->setLayer( mCbxReferencingLayer->currentLayer() );
@@ -23,8 +23,8 @@ QgsValueRelationConfigDlg::QgsValueRelationConfigDlg( QgsVectorLayer* vl, int fi
{
setupUi( this );
mLayerName->setFilters( QgsMapLayerProxyModel::VectorLayer );
connect( mLayerName, SIGNAL( layerChanged( QgsMapLayer* ) ), mKeyColumn, SLOT( setLayer( QgsMapLayer* ) ) );
connect( mLayerName, SIGNAL( layerChanged( QgsMapLayer* ) ), mValueColumn, SLOT( setLayer( QgsMapLayer* ) ) );
connect( mLayerName, &QgsMapLayerComboBox::layerChanged, mKeyColumn, &QgsFieldComboBox::setLayer );
connect( mLayerName, &QgsMapLayerComboBox::layerChanged, mValueColumn, &QgsFieldComboBox::setLayer );
connect( mEditExpression, SIGNAL( clicked() ), this, SLOT( editExpression() ) );

connect( mLayerName, SIGNAL( layerChanged( QgsMapLayer* ) ), this, SIGNAL( changed() ) );
@@ -45,16 +45,8 @@ bool QgsFieldComboBox::allowEmptyFieldName() const

void QgsFieldComboBox::setLayer( QgsMapLayer *layer )
{
QgsVectorLayer* vl = dynamic_cast<QgsVectorLayer*>( layer );
if ( vl )
{
setLayer( vl );
}
}

void QgsFieldComboBox::setLayer( QgsVectorLayer *layer )
{
mFieldProxyModel->sourceFieldModel()->setLayer( layer );
QgsVectorLayer* vl = qobject_cast<QgsVectorLayer*>( layer );
mFieldProxyModel->sourceFieldModel()->setLayer( vl );
}

QgsVectorLayer *QgsFieldComboBox::layer() const
@@ -68,18 +68,23 @@ class GUI_EXPORT QgsFieldComboBox : public QComboBox
//! return the currently selected field
QString currentField() const;

//! Returns the currently used layer
/**
* Returns the layer currently associated with the combobox.
* @see setLayer()
*/
QgsVectorLayer* layer() const;

signals:
//! the signal is emitted when the currently selected field changes
void fieldChanged( const QString& fieldName );

public slots:
//! set the layer of which the fields are listed
void setLayer( QgsVectorLayer* layer );

//! convenience slot to connect QgsMapLayerComboBox layer signal
/**
* Sets the layer for which fields are listed in the combobox. If no layer is set
* or a non-vector layer is set then the combobox will be empty.
* @see layer()
*/
void setLayer( QgsMapLayer* layer );

//! setField sets the currently selected field
@@ -154,24 +154,17 @@ void QgsFieldExpressionWidget::registerExpressionContextGenerator( const QgsExpr

void QgsFieldExpressionWidget::setLayer( QgsMapLayer *layer )
{
QgsVectorLayer* vl = dynamic_cast<QgsVectorLayer*>( layer );
if ( vl )
{
setLayer( vl );
}
}
QgsVectorLayer* vl = qobject_cast< QgsVectorLayer* >( layer );

void QgsFieldExpressionWidget::setLayer( QgsVectorLayer *layer )
{
if ( mFieldProxyModel->sourceFieldModel()->layer() )
disconnect( mFieldProxyModel->sourceFieldModel()->layer(), SIGNAL( updatedFields() ), this, SLOT( reloadLayer() ) );

if ( layer )
mExpressionContext = layer->createExpressionContext();
if ( vl )
mExpressionContext = vl->createExpressionContext();
else
mExpressionContext = QgsProject::instance()->createExpressionContext();

mFieldProxyModel->sourceFieldModel()->setLayer( layer );
mFieldProxyModel->sourceFieldModel()->setLayer( vl );

if ( mFieldProxyModel->sourceFieldModel()->layer() )
connect( mFieldProxyModel->sourceFieldModel()->layer(), SIGNAL( updatedFields() ), SLOT( reloadLayer() ), Qt::UniqueConnection );
@@ -111,7 +111,10 @@ class GUI_EXPORT QgsFieldExpressionWidget : public QWidget
*/
QString expression() const;

//! Returns the currently used layer
/**
* Returns the layer currently associated with the widget.
* @see setLayer()
*/
QgsVectorLayer* layer() const;

/**
@@ -133,10 +136,11 @@ class GUI_EXPORT QgsFieldExpressionWidget : public QWidget
// void returnPressed();

public slots:
//! set the layer used to display the fields and expression
void setLayer( QgsVectorLayer* layer );

//! convenience slot to connect QgsMapLayerComboBox layer signal
/**
* Sets the layer used to display the fields and expression.
* @see layer()
*/
void setLayer( QgsMapLayer* layer );

//! sets the current row in the widget
@@ -18,6 +18,7 @@

#include "qgsexpressionbuilderdialog.h"
#include "qgsfieldexpressionwidget.h"
#include "qgsvectorlayer.h"

#include <QTableWidget>
#include <QKeyEvent>
@@ -71,8 +71,8 @@ HeatmapGui::HeatmapGui( QWidget* parent, Qt::WindowFlags fl, QMap<QString, QVari

mRadiusFieldCombo->setFilters( QgsFieldProxyModel::Numeric );
mWeightFieldCombo->setFilters( QgsFieldProxyModel::Numeric );
connect( mInputLayerCombo, SIGNAL( layerChanged( QgsMapLayer* ) ), mRadiusFieldCombo, SLOT( setLayer( QgsMapLayer* ) ) );
connect( mInputLayerCombo, SIGNAL( layerChanged( QgsMapLayer* ) ), mWeightFieldCombo, SLOT( setLayer( QgsMapLayer* ) ) );
connect( mInputLayerCombo, &QgsMapLayerComboBox::layerChanged, mRadiusFieldCombo, &QgsFieldComboBox::setLayer );
connect( mInputLayerCombo, &QgsMapLayerComboBox::layerChanged, mWeightFieldCombo, &QgsFieldComboBox::setLayer );
mRadiusFieldCombo->setLayer( mInputLayerCombo->currentLayer() );
mWeightFieldCombo->setLayer( mInputLayerCombo->currentLayer() );

0 comments on commit 8c8be00

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