Navigation Menu

Skip to content

Commit

Permalink
Remove redundant setLayer slots from QgsField(ComboBox|ExpressionWidget)
Browse files Browse the repository at this point in the history
and switch uses of remaining slot to new style connects
  • Loading branch information
nyalldawson committed Nov 21, 2016
1 parent 22dc096 commit 8c8be00
Show file tree
Hide file tree
Showing 14 changed files with 65 additions and 52 deletions.
12 changes: 12 additions & 0 deletions doc/api_break.dox
Expand Up @@ -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}
---------

Expand Down
13 changes: 9 additions & 4 deletions python/gui/qgsfieldcombobox.sip
Expand Up @@ -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
Expand Down
13 changes: 8 additions & 5 deletions python/gui/qgsfieldexpressionwidget.sip
Expand Up @@ -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;

/**
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/app/composer/qgsatlascompositionwidget.cpp
Expand Up @@ -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 ) ) );
Expand Down
6 changes: 3 additions & 3 deletions src/app/qgsjoindialog.cpp
Expand Up @@ -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 );

Expand All @@ -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() ) );

Expand Down
2 changes: 1 addition & 1 deletion src/app/qgslayerstylingwidget.cpp
Expand Up @@ -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 );
Expand Down
6 changes: 2 additions & 4 deletions src/app/qgsrelationadddlg.cpp
Expand Up @@ -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() );
Expand Down
4 changes: 2 additions & 2 deletions src/gui/editorwidgets/qgsvaluerelationconfigdlg.cpp
Expand Up @@ -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() ) );
Expand Down
12 changes: 2 additions & 10 deletions src/gui/qgsfieldcombobox.cpp
Expand Up @@ -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
Expand Down
13 changes: 9 additions & 4 deletions src/gui/qgsfieldcombobox.h
Expand Up @@ -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
Expand Down
15 changes: 4 additions & 11 deletions src/gui/qgsfieldexpressionwidget.cpp
Expand Up @@ -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 );
Expand Down
12 changes: 8 additions & 4 deletions src/gui/qgsfieldexpressionwidget.h
Expand Up @@ -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;

/**
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/gui/qgsorderbydialog.cpp
Expand Up @@ -18,6 +18,7 @@

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

#include <QTableWidget>
#include <QKeyEvent>
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/heatmap/heatmapgui.cpp
Expand Up @@ -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() );

Expand Down

0 comments on commit 8c8be00

Please sign in to comment.