diff --git a/doc/api_break.dox b/doc/api_break.dox index 190f1b947fc..ce1a1aad4d0 100644 --- a/doc/api_break.dox +++ b/doc/api_break.dox @@ -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} --------- diff --git a/python/gui/qgsfieldcombobox.sip b/python/gui/qgsfieldcombobox.sip index 57c26f089fb..195168a6a16 100644 --- a/python/gui/qgsfieldcombobox.sip +++ b/python/gui/qgsfieldcombobox.sip @@ -42,7 +42,10 @@ 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: @@ -50,10 +53,12 @@ class QgsFieldComboBox : QComboBox 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 diff --git a/python/gui/qgsfieldexpressionwidget.sip b/python/gui/qgsfieldexpressionwidget.sip index 7b9f1fdc8dd..4c2f92cb266 100644 --- a/python/gui/qgsfieldexpressionwidget.sip +++ b/python/gui/qgsfieldexpressionwidget.sip @@ -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 diff --git a/src/app/composer/qgsatlascompositionwidget.cpp b/src/app/composer/qgsatlascompositionwidget.cpp index 4b0a9509169..445429484ee 100644 --- a/src/app/composer/qgsatlascompositionwidget.cpp +++ b/src/app/composer/qgsatlascompositionwidget.cpp @@ -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 ) ) ); diff --git a/src/app/qgsjoindialog.cpp b/src/app/qgsjoindialog.cpp index 7c9e5ffb47b..4c52f3a4778 100644 --- a/src/app/qgsjoindialog.cpp +++ b/src/app/qgsjoindialog.cpp @@ -43,8 +43,8 @@ QgsJoinDialog::QgsJoinDialog( QgsVectorLayer* layer, QList 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 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() ) ); diff --git a/src/app/qgslayerstylingwidget.cpp b/src/app/qgslayerstylingwidget.cpp index c868bd051d0..fc59a6903cb 100644 --- a/src/app/qgslayerstylingwidget.cpp +++ b/src/app/qgslayerstylingwidget.cpp @@ -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 ); diff --git a/src/app/qgsrelationadddlg.cpp b/src/app/qgsrelationadddlg.cpp index 3b44e497393..aca91bc24e1 100644 --- a/src/app/qgsrelationadddlg.cpp +++ b/src/app/qgsrelationadddlg.cpp @@ -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() ); diff --git a/src/gui/editorwidgets/qgsvaluerelationconfigdlg.cpp b/src/gui/editorwidgets/qgsvaluerelationconfigdlg.cpp index 7bbe41d0a32..a32d5dc6151 100644 --- a/src/gui/editorwidgets/qgsvaluerelationconfigdlg.cpp +++ b/src/gui/editorwidgets/qgsvaluerelationconfigdlg.cpp @@ -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() ) ); diff --git a/src/gui/qgsfieldcombobox.cpp b/src/gui/qgsfieldcombobox.cpp index 79f635f54c1..675dd23fc87 100644 --- a/src/gui/qgsfieldcombobox.cpp +++ b/src/gui/qgsfieldcombobox.cpp @@ -45,16 +45,8 @@ bool QgsFieldComboBox::allowEmptyFieldName() const void QgsFieldComboBox::setLayer( QgsMapLayer *layer ) { - QgsVectorLayer* vl = dynamic_cast( layer ); - if ( vl ) - { - setLayer( vl ); - } -} - -void QgsFieldComboBox::setLayer( QgsVectorLayer *layer ) -{ - mFieldProxyModel->sourceFieldModel()->setLayer( layer ); + QgsVectorLayer* vl = qobject_cast( layer ); + mFieldProxyModel->sourceFieldModel()->setLayer( vl ); } QgsVectorLayer *QgsFieldComboBox::layer() const diff --git a/src/gui/qgsfieldcombobox.h b/src/gui/qgsfieldcombobox.h index 804309116ce..0b25395236c 100644 --- a/src/gui/qgsfieldcombobox.h +++ b/src/gui/qgsfieldcombobox.h @@ -68,7 +68,10 @@ 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: @@ -76,10 +79,12 @@ class GUI_EXPORT QgsFieldComboBox : public QComboBox 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 diff --git a/src/gui/qgsfieldexpressionwidget.cpp b/src/gui/qgsfieldexpressionwidget.cpp index 1984e2fae04..c2aa7e73281 100644 --- a/src/gui/qgsfieldexpressionwidget.cpp +++ b/src/gui/qgsfieldexpressionwidget.cpp @@ -154,24 +154,17 @@ void QgsFieldExpressionWidget::registerExpressionContextGenerator( const QgsExpr void QgsFieldExpressionWidget::setLayer( QgsMapLayer *layer ) { - QgsVectorLayer* vl = dynamic_cast( 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 ); diff --git a/src/gui/qgsfieldexpressionwidget.h b/src/gui/qgsfieldexpressionwidget.h index e7afdb43e40..480fa6e4a32 100644 --- a/src/gui/qgsfieldexpressionwidget.h +++ b/src/gui/qgsfieldexpressionwidget.h @@ -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 diff --git a/src/gui/qgsorderbydialog.cpp b/src/gui/qgsorderbydialog.cpp index 7c6b78cfaaf..330baef6c2c 100644 --- a/src/gui/qgsorderbydialog.cpp +++ b/src/gui/qgsorderbydialog.cpp @@ -18,6 +18,7 @@ #include "qgsexpressionbuilderdialog.h" #include "qgsfieldexpressionwidget.h" +#include "qgsvectorlayer.h" #include #include diff --git a/src/plugins/heatmap/heatmapgui.cpp b/src/plugins/heatmap/heatmapgui.cpp index 99a5e55e1b7..db72ff97cf0 100644 --- a/src/plugins/heatmap/heatmapgui.cpp +++ b/src/plugins/heatmap/heatmapgui.cpp @@ -71,8 +71,8 @@ HeatmapGui::HeatmapGui( QWidget* parent, Qt::WindowFlags fl, QMapsetFilters( 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() );