Skip to content
Permalink
Browse files

field model only works with vector layer, add convenience slots for Q…

…gsMapLayer in QgsFieldExpressionWidget and QgsFieldComboBox
  • Loading branch information
3nids committed May 2, 2014
1 parent 41cc509 commit 31d52d960f187dfcc519009293404a678b9f1e54
@@ -27,6 +27,15 @@ QgsFieldComboBox::QgsFieldComboBox( QWidget *parent ) :
}

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

void QgsFieldComboBox::setLayer( QgsVectorLayer *layer )
{
mFieldModel->setLayer( layer );
}
@@ -51,6 +51,9 @@ class GUI_EXPORT QgsFieldComboBox : public QComboBox

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

//! convenience slot to connect QgsMapLayerComboBox layer signal
void setLayer( QgsMapLayer* layer );

//! setField sets the currently selected field
@@ -86,6 +86,15 @@ QgsVectorLayer *QgsFieldExpressionWidget::layer()
return mFieldModel->layer();
}

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

void QgsFieldExpressionWidget::setLayer( QgsVectorLayer *layer )
{
mFieldModel->setLayer( layer );
@@ -61,6 +61,9 @@ class GUI_EXPORT QgsFieldExpressionWidget : public QWidget
//! set the layer used to display the fields and expression
void setLayer( QgsVectorLayer* layer );

//! convenience slot to connect QgsMapLayerComboBox layer signal
void setLayer( QgsMapLayer* layer );

//! sets the current field or expression in the widget
void setField( QString fieldName );

@@ -49,7 +49,7 @@ QModelIndex QgsFieldModel::indexFromName( QString fieldName )
return QModelIndex();
}

void QgsFieldModel::setLayer( QgsMapLayer *layer )
void QgsFieldModel::setLayer( QgsVectorLayer *layer )
{
if ( mLayer )
{
@@ -63,15 +63,8 @@ void QgsFieldModel::setLayer( QgsMapLayer *layer )
updateModel();
return;
}
QgsVectorLayer* vl = dynamic_cast<QgsVectorLayer*>( layer );
if ( !vl )
{
mLayer = 0;
updateModel();
return;
}

mLayer = vl;
mLayer = layer;
connect( mLayer, SIGNAL( updatedFields() ), this, SLOT( updateModel() ) );
connect( mLayer, SIGNAL( layerDeleted() ), this, SLOT( layerDeleted() ) );
updateModel();
@@ -69,7 +69,7 @@ class GUI_EXPORT QgsFieldModel : public QAbstractItemModel

public slots:
//! set the layer of whch fields are displayed
void setLayer( QgsMapLayer *layer );
void setLayer( QgsVectorLayer *layer );

protected slots:
virtual void updateModel();

0 comments on commit 31d52d9

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