Skip to content
Permalink
Browse files

QgsField::ConfigurationFlags: add column in source fields table (vect…

…or layer properties)
  • Loading branch information
3nids committed Sep 11, 2020
1 parent 59ff516 commit 4544c9614fa54548373fd6b3212642e370df9b2c
@@ -2117,14 +2117,14 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte

/**
* Sets the configuration flags of the field at given index
* \see QgsField::ConfigurationFlags
* \see QgsField::ConfigurationFlag
* \since QGIS 3.16
*/
void setFieldConfigurationFlags( int index, QgsField::ConfigurationFlags flags ) SIP_SKIP;

/**
* Returns the configuration flags of the field at given index
* \see QgsField::ConfigurationFlags
* \see QgsField::ConfigurationFlag
* \since QGIS 3.16
*/
QgsField::ConfigurationFlags fieldConfigurationFlags( int index ) const SIP_SKIP;
@@ -70,6 +70,9 @@ QgsSourceFieldsProperties::QgsSourceFieldsProperties( QgsVectorLayer *layer, QWi
const auto wfsWi = new QTableWidgetItem( QStringLiteral( "WFS" ) );
wfsWi->setToolTip( tr( "Defines if this field is available in QGIS Server WFS (and OAPIF) service" ) );
mFieldsList->setHorizontalHeaderItem( AttrWFSCol, wfsWi );
const auto searchableWi = new QTableWidgetItem( QStringLiteral( "Searchable" ) );
searchableWi->setToolTip( tr( "Defines if this field is searchable (active layer locator filter))" ) );
mFieldsList->setHorizontalHeaderItem( AttrSearchableCol, searchableWi );
mFieldsList->setHorizontalHeaderItem( AttrAliasCol, new QTableWidgetItem( tr( "Alias" ) ) );

mFieldsList->setSortingEnabled( true );
@@ -278,6 +281,10 @@ void QgsSourceFieldsProperties::setRow( int row, int idx, const QgsField &field
wfsAttrItem->setCheckState( mLayer->excludeAttributesWfs().contains( field.name() ) ? Qt::Unchecked : Qt::Checked );
wfsAttrItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable );
mFieldsList->setItem( row, AttrWFSCol, wfsAttrItem );
QTableWidgetItem *searchableAttrItem = new QTableWidgetItem();
searchableAttrItem->setCheckState( mLayer->fieldConfigurationFlags( idx ).testFlag( QgsField::ConfigurationFlag::Searchable ) ? Qt::Checked : Qt::Unchecked );
searchableAttrItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable );
mFieldsList->setItem( row, AttrSearchableCol, searchableAttrItem );

}

@@ -312,6 +319,18 @@ void QgsSourceFieldsProperties::apply()
{
excludeAttributesWFS.insert( mFieldsList->item( i, AttrNameCol )->text() );
}

int idx = mFieldsList->item( i, AttrIdCol )->data( Qt::DisplayRole ).toInt();
QgsField::ConfigurationFlags flags = mLayer->fieldConfigurationFlags( idx );
if ( mFieldsList->item( i, AttrSearchableCol )->checkState() == Qt::Checked )
{
flags.setFlag( QgsField::ConfigurationFlag::Searchable, true );
}
else
{
flags.setFlag( QgsField::ConfigurationFlag::Searchable, false );
}
mLayer->setFieldConfigurationFlags( idx, flags );
}

mLayer->setExcludeAttributesWms( excludeAttributesWMS );
@@ -82,6 +82,7 @@ class GUI_EXPORT QgsSourceFieldsProperties : public QWidget, private Ui_QgsSourc
AttrCommentCol,
AttrWMSCol,
AttrWFSCol,
AttrSearchableCol,
AttrColCount,
};

0 comments on commit 4544c96

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