18 #include <QPushButton> 20 #include <QHBoxLayout> 54 for (
int i = 0; i < list.size(); ++i )
56 if ( !list.at( i ).isNull() )
66 mTopLayout =
new QVBoxLayout(
this );
67 mTopLayout->setContentsMargins( 0, 0, 0, 0 );
69 setSizePolicy( sizePolicy().horizontalPolicy(), QSizePolicy::Fixed );
71 setLayout( mTopLayout );
73 QHBoxLayout *editLayout =
new QHBoxLayout();
74 editLayout->setContentsMargins( 0, 0, 0, 0 );
75 editLayout->setSpacing( 2 );
78 mChooserContainer =
new QWidget;
79 editLayout->addWidget( mChooserContainer );
80 QHBoxLayout *chooserLayout =
new QHBoxLayout;
81 chooserLayout->setContentsMargins( 0, 0, 0, 0 );
82 mFilterLayout =
new QHBoxLayout;
83 mFilterLayout->setContentsMargins( 0, 0, 0, 0 );
84 mFilterContainer =
new QWidget;
85 mFilterContainer->setLayout( mFilterLayout );
86 mChooserContainer->setLayout( chooserLayout );
87 chooserLayout->addWidget( mFilterContainer );
90 mChooserContainer->layout()->addWidget( mComboBox );
93 mLineEdit =
new QLineEdit();
94 mLineEdit->setReadOnly(
true );
95 editLayout->addWidget( mLineEdit );
98 mOpenFormButton =
new QToolButton();
100 mOpenFormButton->setText( tr(
"Open Related Feature Form" ) );
101 editLayout->addWidget( mOpenFormButton );
103 mAddEntryButton =
new QToolButton();
105 mAddEntryButton->setText( tr(
"Add New Entry" ) );
106 editLayout->addWidget( mAddEntryButton );
109 mHighlightFeatureButton =
new QToolButton(
this );
110 mHighlightFeatureButton->setPopupMode( QToolButton::MenuButtonPopup );
111 mHighlightFeatureAction =
new QAction(
QgsApplication::getThemeIcon( QStringLiteral(
"/mActionHighlightFeature.svg" ) ), tr(
"Highlight feature" ),
this );
112 mScaleHighlightFeatureAction =
new QAction(
QgsApplication::getThemeIcon( QStringLiteral(
"/mActionScaleHighlightFeature.svg" ) ), tr(
"Scale and highlight feature" ),
this );
113 mPanHighlightFeatureAction =
new QAction(
QgsApplication::getThemeIcon( QStringLiteral(
"/mActionPanHighlightFeature.svg" ) ), tr(
"Pan and highlight feature" ),
this );
114 mHighlightFeatureButton->addAction( mHighlightFeatureAction );
115 mHighlightFeatureButton->addAction( mScaleHighlightFeatureAction );
116 mHighlightFeatureButton->addAction( mPanHighlightFeatureAction );
117 mHighlightFeatureButton->setDefaultAction( mHighlightFeatureAction );
118 editLayout->addWidget( mHighlightFeatureButton );
121 mMapIdentificationButton =
new QToolButton(
this );
123 mMapIdentificationButton->setText( tr(
"Select on Map" ) );
124 mMapIdentificationButton->setCheckable(
true );
125 editLayout->addWidget( mMapIdentificationButton );
128 mRemoveFKButton =
new QToolButton(
this );
130 mRemoveFKButton->setText( tr(
"No Selection" ) );
131 editLayout->addWidget( mRemoveFKButton );
134 mTopLayout->addLayout( editLayout );
138 mAttributeEditorLayout =
new QVBoxLayout( mAttributeEditorFrame );
139 mAttributeEditorFrame->setLayout( mAttributeEditorLayout );
140 mAttributeEditorFrame->setSizePolicy( mAttributeEditorFrame->sizePolicy().horizontalPolicy(), QSizePolicy::Expanding );
141 mTopLayout->addWidget( mAttributeEditorFrame );
144 mInvalidLabel =
new QLabel( tr(
"The relation is not valid. Please make sure your relation definitions are OK." ) );
145 mInvalidLabel->setWordWrap(
true );
146 QFont font = mInvalidLabel->font();
147 font.setItalic(
true );
148 mInvalidLabel->setStyleSheet( QStringLiteral(
"QLabel { color: red; } " ) );
149 mInvalidLabel->setFont( font );
150 mTopLayout->addWidget( mInvalidLabel );
154 mMapIdentificationButton->hide();
155 mHighlightFeatureButton->hide();
156 mAttributeEditorFrame->hide();
157 mInvalidLabel->hide();
161 connect( mHighlightFeatureButton, &QToolButton::triggered,
this, &QgsRelationReferenceWidget::highlightActionTriggered );
164 connect( mAddEntryButton, &QAbstractButton::clicked,
this, &QgsRelationReferenceWidget::addEntry );
165 connect( mComboBox, &QComboBox::editTextChanged,
this, &QgsRelationReferenceWidget::updateAddEntryButton );
175 void QgsRelationReferenceWidget::updateIndex()
177 if ( mChainFilters && mComboBox->count() > 0 )
182 if ( ! mFilterComboBoxes.isEmpty()
183 && mFilterComboBoxes[0]->currentIndex() == 0 && mAllowNull )
187 else if ( mComboBox->count() > mComboBox->
nullIndex() )
191 else if ( mAllowNull )
200 if ( mComboBox->count() > index )
202 mComboBox->setCurrentIndex( index );
209 mAllowNull = allowNullValue;
210 mRemoveFKButton->setVisible( allowNullValue && mReadOnlySelector );
214 mInvalidLabel->hide();
219 const QList<QgsRelation::FieldPair> fieldPairs = relation.
fieldPairs();
222 mReferencedFields << fieldPair.referencedField();
229 mAttributeEditorFrame->setObjectName( QStringLiteral(
"referencing/" ) + relation.
name() );
234 mAttributeEditorFrame->setTitle( mReferencedLayer->
name() );
236 mAttributeEditorLayout->addWidget( mReferencedAttributeForm );
241 updateAddEntryButton();
245 mInvalidLabel->show();
248 if ( mShown && isVisible() )
261 mFilterContainer->setEnabled( editable );
262 mComboBox->setEnabled( editable );
263 mComboBox->setEditable(
true );
264 mMapIdentificationButton->setEnabled( editable );
265 mRemoveFKButton->setEnabled( editable );
266 mIsEditable = editable;
276 if ( values.isEmpty() )
286 if ( !mReferencedLayer )
289 if ( mReadOnlySelector )
295 const QList<QgsRelation::FieldPair> fieldPairs = mRelation.
fieldPairs();
296 int fieldCount = std::min( fieldPairs.count(), values.count() );
297 for (
int i = 0; i < fieldCount; i++ )
299 int idx = mReferencingLayer->
fields().
lookupField( fieldPairs.at( i ).referencingField() );
300 attrs[idx] = values.at( i );
312 mForeignKeys.clear();
313 for (
const QString &fieldName : qgis::as_const( mReferencedFields ) )
314 mForeignKeys << mFeature.
attribute( fieldName );
318 context.setFeature( mFeature );
319 QString title = expr.evaluate( &context ).toString();
320 if ( expr.hasEvalError() )
322 QStringList titleFields;
323 for (
const QString &fieldName : qgis::as_const( mReferencedFields ) )
324 titleFields << mFeature.
attribute( fieldName ).toString();
325 title = titleFields.join( QStringLiteral(
" " ) );
327 mLineEdit->setText( title );
341 const int count = std::min( mFilterComboBoxes.size(), mFilterFields.size() );
342 for (
int i = 0; i < count; i++ )
344 QVariant v = mFeature.
attribute( mFilterFields[i] );
345 QString f = v.isNull() ? nullValue.toString() : v.toString();
346 mFilterComboBoxes.at( i )->setCurrentIndex( mFilterComboBoxes.at( i )->findText( f ) );
351 mRemoveFKButton->setEnabled( mIsEditable );
352 highlightFeature( mFeature );
353 updateAttributeEditorFrame( mFeature );
361 if ( mChainFilters && !mFilterComboBoxes.isEmpty() )
363 QComboBox *cb = mFilterComboBoxes.first();
364 cb->setCurrentIndex( 0 );
365 disableChainedComboBoxes( cb );
368 if ( mReadOnlySelector )
375 nullText = tr(
"%1 (no selection)" ).arg( nullValue );
377 mLineEdit->setText( nullText );
378 QVariantList nullAttributes;
379 for (
const QString &fieldName : qgis::as_const( mReferencedFields ) )
381 Q_UNUSED( fieldName );
382 nullAttributes << QVariant( QVariant::Int );
384 mForeignKeys = nullAttributes;
391 mRemoveFKButton->setEnabled(
false );
400 if ( mReferencedLayer )
403 if ( mReadOnlySelector )
418 if ( mReadOnlySelector )
426 mRemoveFKButton->setEnabled(
false );
433 if ( fkeys.isEmpty() )
434 return QVariant( QVariant::Int );
436 return fkeys.at( 0 );
441 if ( mReadOnlySelector )
453 mEditorContext = context;
455 mMessageBar = messageBar;
458 mMapToolIdentify->
setButton( mMapIdentificationButton );
461 mMapToolDigitize->
setButton( mAddEntryButton );
468 setSizePolicy( sizePolicy().horizontalPolicy(), QSizePolicy::MinimumExpanding );
469 mTopLayout->setAlignment( Qt::AlignTop );
472 mAttributeEditorFrame->setVisible( display );
473 mEmbedForm = display;
478 mChooserContainer->setHidden( readOnly );
479 mLineEdit->setVisible( readOnly );
480 mRemoveFKButton->setVisible( mAllowNull && readOnly );
481 mReadOnlySelector = readOnly;
486 mHighlightFeatureButton->setVisible( allowMapIdentification );
487 mMapIdentificationButton->setVisible( allowMapIdentification );
498 mFilterFields = filterFields;
503 mOpenFormButton->setVisible( openFormButtonVisible );
523 if ( !mReadOnlySelector && mReferencedLayer )
525 QApplication::setOverrideCursor( Qt::WaitCursor );
527 QSet<QString> requestedAttrs;
529 if ( !mFilterFields.isEmpty() )
531 for (
const QString &fieldName : qgis::as_const( mFilterFields ) )
538 QComboBox *cb =
new QComboBox();
539 cb->setProperty(
"Field", fieldName );
541 mFilterComboBoxes << cb;
542 QVariantList uniqueValues = mReferencedLayer->
uniqueValues( idx ).toList();
545 cb->addItem( nullValue.toString(), QVariant( mReferencedLayer->
fields().
at( idx ).
type() ) );
548 const auto constUniqueValues = uniqueValues;
549 for (
const QVariant &v : constUniqueValues )
551 cb->addItem( v.toString(), v );
554 connect( cb,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsRelationReferenceWidget::filterChanged );
557 requestedAttrs << fieldName;
559 mFilterLayout->addWidget( cb );
570 const int count = std::min( mFilterComboBoxes.count(), mFilterFields.count() );
571 for (
int i = 0; i < count - 1; i++ )
573 QVariant cv = ft.
attribute( mFilterFields.at( i ) );
574 QVariant nv = ft.
attribute( mFilterFields.at( i + 1 ) );
575 QString cf = cv.isNull() ? nullValue.toString() : cv.toString();
576 QString nf = nv.isNull() ? nullValue.toString() : nv.toString();
577 mFilterCache[mFilterFields[i]][cf] << nf;
581 if ( !mFilterComboBoxes.isEmpty() )
583 QComboBox *cb = mFilterComboBoxes.first();
584 cb->setCurrentIndex( 0 );
585 disableChainedComboBoxes( cb );
591 mFilterContainer->hide();
601 if ( mChainFilters && mFeature.
isValid() )
603 for (
int i = 0; i < mFilterFields.size(); i++ )
605 QVariant v = mFeature.
attribute( mFilterFields[i] );
606 QString f = v.isNull() ? nullValue.toString() : v.toString();
607 mFilterComboBoxes.at( i )->setCurrentIndex( mFilterComboBoxes.at( i )->findText( f ) );
612 connect( mComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsRelationReferenceWidget::comboReferenceChanged );
614 emit mComboBox->currentIndexChanged( mComboBox->currentIndex() );
616 QApplication::restoreOverrideCursor();
622 void QgsRelationReferenceWidget::highlightActionTriggered( QAction *action )
624 if ( action == mHighlightFeatureAction )
628 else if ( action == mScaleHighlightFeatureAction )
632 else if ( action == mPanHighlightFeatureAction )
647 attributeDialog.exec();
670 if ( canvasExtent ==
Scale )
683 else if ( canvasExtent ==
Pan )
693 mHighlight =
new QgsHighlight( mCanvas, f, mReferencedLayer );
697 QTimer *timer =
new QTimer(
this );
698 timer->setSingleShot(
true );
699 connect( timer, &QTimer::timeout,
this, &QgsRelationReferenceWidget::deleteHighlight );
700 timer->start( 3000 );
703 void QgsRelationReferenceWidget::deleteHighlight()
710 mHighlight =
nullptr;
715 if ( !mAllowMapIdentification || !mReferencedLayer )
724 mMapToolIdentify->
setLayer( mReferencedLayer );
725 setMapTool( mMapToolIdentify );
731 QString title = tr(
"Relation %1 for %2." ).arg( mRelation.
name(), mReferencingLayer->
name() );
732 QString msg = tr(
"Identify a feature of %1 to be associated. Press <ESC> to cancel." ).arg( mReferencedLayer->
name() );
734 mMessageBar->
pushItem( mMessageBarItem );
738 void QgsRelationReferenceWidget::comboReferenceChanged(
int index )
742 highlightFeature( mFeature );
743 updateAttributeEditorFrame( mFeature );
748 void QgsRelationReferenceWidget::updateAttributeEditorFrame(
const QgsFeature &feature )
750 mOpenFormButton->setEnabled( feature.
isValid() );
752 if ( mAttributeEditorFrame && mReferencedAttributeForm )
754 mReferencedAttributeForm->
setFeature( feature );
760 return mAllowAddFeatures;
766 updateAddEntryButton();
774 void QgsRelationReferenceWidget::featureIdentified(
const QgsFeature &feature )
776 if ( mReadOnlySelector )
780 context.setFeature( feature );
781 QString title = expr.evaluate( &context ).toString();
782 if ( expr.hasEvalError() )
784 QStringList titleFields;
785 for (
const QString &fieldName : qgis::as_const( mReferencedFields ) )
786 titleFields << mFeature.
attribute( fieldName ).toString();
787 title = titleFields.join( QStringLiteral(
" " ) );
789 mLineEdit->setText( title );
790 mForeignKeys.clear();
791 for (
const QString &fieldName : qgis::as_const( mReferencedFields ) )
792 mForeignKeys << mFeature.
attribute( fieldName );
801 mRemoveFKButton->setEnabled( mIsEditable );
802 highlightFeature( feature );
803 updateAttributeEditorFrame( feature );
809 void QgsRelationReferenceWidget::setMapTool(
QgsMapTool *mapTool )
811 mCurrentMapTool = mapTool;
814 mWindowWidget = window();
816 mCanvas->window()->raise();
817 mCanvas->activateWindow();
822 void QgsRelationReferenceWidget::unsetMapTool()
825 if ( mCurrentMapTool )
830 if ( mCurrentMapTool == mMapToolDigitize )
842 void QgsRelationReferenceWidget::onKeyPressed( QKeyEvent *e )
844 if ( e->key() == Qt::Key_Escape )
850 void QgsRelationReferenceWidget::mapToolDeactivated()
854 mWindowWidget->raise();
855 mWindowWidget->activateWindow();
858 if ( mMessageBar && mMessageBarItem )
860 mMessageBar->
popWidget( mMessageBarItem );
862 mMessageBarItem =
nullptr;
865 void QgsRelationReferenceWidget::filterChanged()
869 QMap<QString, QString> filters;
872 QComboBox *scb = qobject_cast<QComboBox *>( sender() );
878 QString filterExpression;
882 disableChainedComboBoxes( scb );
885 const auto constMFilterComboBoxes = mFilterComboBoxes;
886 for ( QComboBox *cb : constMFilterComboBoxes )
888 if ( cb->currentIndex() != 0 )
890 const QString fieldName = cb->property(
"Field" ).toString();
892 if ( cb->currentText() == nullValue.toString() )
894 filters[fieldName] = QStringLiteral(
"\"%1\" IS NULL" ).arg( fieldName );
906 QComboBox *ccb =
nullptr;
907 const auto constMFilterComboBoxes = mFilterComboBoxes;
908 for ( QComboBox *cb : constMFilterComboBoxes )
918 if ( ccb->currentIndex() != 0 )
920 const QString fieldName = cb->property(
"Field" ).toString();
922 cb->blockSignals(
true );
924 cb->addItem( cb->property(
"FieldAlias" ).toString() );
929 const auto txts { mFilterCache[ccb->property(
"Field" ).toString()][ccb->currentText()] };
930 for (
const QString &txt : txts )
932 QMap<QString, QString> filtersAttrs = filters;
934 QString expression = filtersAttrs.values().join( QStringLiteral(
" AND " ) );
942 while ( it.nextFeature( f ) )
944 if ( !featureIds.contains( f.
id() ) )
945 featureIds << f.
id();
956 cb->addItems( texts );
958 cb->setEnabled(
true );
959 cb->blockSignals(
false );
965 filterExpression = filters.values().join( QStringLiteral(
" AND " ) );
969 void QgsRelationReferenceWidget::addEntry()
971 if ( !mReferencedLayer )
988 mMapToolDigitize->
setLayer( mReferencedLayer );
989 setMapTool( mMapToolDigitize );
996 QString title = tr(
"Relation %1 for %2." ).arg( mRelation.
name(), mReferencingLayer->
name() );
1004 exp.prepare( &context );
1005 QString displayString = exp.evaluate( &context ).toString();
1007 QString msg = tr(
"Link feature to %1 \"%2\" : Digitize the geometry for the new feature on layer %3. Press <ESC> to cancel." )
1008 .arg( mReferencingLayer->
name(), displayString, mReferencedLayer->
name() );
1010 mMessageBar->
pushItem( mMessageBarItem );
1015 void QgsRelationReferenceWidget::entryAdded(
const QgsFeature &feat )
1021 if ( mComboBox->itemText( mComboBox->currentIndex() ) != mComboBox->currentText() )
1025 if ( fieldIdx != -1 )
1027 attributes.insert( fieldIdx, mComboBox->currentText() );
1034 for (
const QString &fieldName : qgis::as_const( mReferencedFields ) )
1039 mAddEntryButton->setEnabled(
false );
1045 void QgsRelationReferenceWidget::updateAddEntryButton()
1047 mAddEntryButton->setVisible( mAllowAddFeatures );
1048 mAddEntryButton->setEnabled( mReferencedLayer && mReferencedLayer->
isEditable() );
1051 void QgsRelationReferenceWidget::disableChainedComboBoxes(
const QComboBox *scb )
1053 QComboBox *ccb =
nullptr;
1054 const auto constMFilterComboBoxes = mFilterComboBoxes;
1055 for ( QComboBox *cb : constMFilterComboBoxes )
1067 cb->setCurrentIndex( 0 );
1068 if ( ccb->currentIndex() == 0 )
1070 cb->setEnabled(
false );
1077 void QgsRelationReferenceWidget::emitForeignKeysChanged(
const QVariantList &
foreignKeys,
bool force )
1079 if (
foreignKeys == mForeignKeys && force ==
false )
1091 mFormFeature = formFeature;
void unsetMapTool(QgsMapTool *mapTool)
Unset the current map tool or last non zoom tool.
int lookupField(const QString &fieldName) const
Looks up field's index from the field name.
When showing a single feature (e.g. district information when looking at the form of a house) ...
bool isValid() const
Returns the validity of this feature.
Class for parsing and evaluation of expressions (formerly called "search strings").
const QgsVectorLayerTools * vectorLayerTools() const
Returns the associated vector layer tools.
Wrapper for iterator of features from vector data provider or vector layer.
bool contains(const QgsRectangle &rect) const
Returns true when rectangle contains other rectangle.
This offers a combobox with autocompleter that allows selecting features from a layer.
A rectangle specified with double values.
QgsFeatureRequest currentFeatureRequest() const
Shorthand for getting a feature request to query the currently selected feature.
QSet< QgsFeatureId > QgsFeatureIds
int nullIndex() const
Returns the current index of the NULL value, or -1 if NULL values are not allowed.
void setIdentifierValues(const QVariantList &identifierValues)
The identifier values of the currently selected feature.
A form was opened as a new dialog.
A groupbox that collapses/expands when toggled and can save its collapsed and checked states...
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.
This class contains context information for attribute editor widgets.
A class to represent a 2D point.
void scale(double scaleFactor, const QgsPointXY *c=nullptr)
Scale the rectangle around its center point.
void setIdentifierFields(const QStringList &identifierFields)
Field name that will be used to uniquely identify the current feature.
QgsVectorLayer referencingLayer
#define Q_NOWARN_DEPRECATED_PUSH
A bar for displaying non-blocking messages to the user.
QgsWkbTypes::GeometryType geometryType() const
Returns point, line or polygon.
void refresh()
Repaints the canvas map.
A geometry is the spatial representation of a feature.
static QIcon getThemeIcon(const QString &name)
Helper to get a theme icon.
QgsGeometry centroid() const
Returns the center of mass of a geometry.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
void setSourceLayer(QgsVectorLayer *sourceLayer)
The layer from which features should be listed.
bool hasGeometry() const
Returns true if the feature has an associated geometry.
int count() const
Returns number of items.
Map canvas is a class for displaying all GIS data types on a canvas.
void reset(T *p=nullptr)
Will reset the managed pointer to p.
bool qgsVariantLessThan(const QVariant &lhs, const QVariant &rhs)
Compares two QVariant values and returns whether the first is less than the second.
QgsField at(int i) const
Gets field at particular index (must be in range 0..N-1)
bool isEditable() const FINAL
Returns true if the provider is in editing mode.
QgsFeatureRequest & setFilterFid(QgsFeatureId fid)
Sets feature ID that should be fetched.
static QgsMessageBarItem * createMessage(const QString &text, QWidget *parent=nullptr)
make out a widget containing a message to be displayed on the bar
void setMapTool(QgsMapTool *mapTool, bool clean=false)
Sets the map tool currently being used on the canvas.
QgsFeatureRequest getReferencedFeatureRequest(const QgsAttributes &attributes) const
Creates a request to return the feature on the referenced (parent) layer which is referenced by the p...
QgsFields fields() const FINAL
Returns the list of fields of this layer.
Defines a relation between matching fields of the two involved tables of a relation.
void setIdentifierValuesToNull()
Sets the identifier values of the currently selected feature to NULL value(s).
bool popWidget(QgsMessageBarItem *item)
Remove the passed widget from the bar (if previously added), then display the next one in the stack i...
void setAllowNull(bool allowNull)
Determines if a NULL value should be available in the list.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
QMap< int, QVariant > QgsAttributeMap
QgsRectangle extent() const
Returns the current zoom extent of the map canvas.
void editingStopped()
Emitted when edited changes have been successfully written to the data provider.
A class for highlight features on the map.
This class wraps a request for features to a vector layer (or directly its vector data provider)...
static QString nullRepresentation()
This string is used to represent the value NULL throughout QGIS.
QgsVectorLayer referencedLayer
static QList< QgsExpressionContextScope * > globalProjectLayerScopes(const QgsMapLayer *layer)
Creates a list of three scopes: global, layer's project and layer.
void editingStarted()
Emitted when editing on this layer has started.
static QString createFieldEqualityExpression(const QString &fieldName, const QVariant &value)
Create an expression allowing to evaluate if a field is equal to a value.
QString displayExpression
void keyPressed(QKeyEvent *e)
Emit key press event.
QgsAdvancedDigitizingDockWidget * cadDockWidget() const
Returns the associated CAD dock widget (e.g.
void zoomByFactor(double scaleFactor, const QgsPointXY *center=nullptr)
Zoom with the factor supplied.
QList< QgsRelation::FieldPair > fieldPairs() const
Returns the field pairs which form this relation The first element of each pair are the field names o...
void setCurrentFeature(const QgsFeature &feature)
Sets the current index by using the given feature.
const QgsMapSettings & mapSettings() const
Gets access to properties used for map rendering.
void combineExtentWith(const QgsRectangle &rect)
Expands the rectangle so that it covers both the original rectangle and the given rectangle...
#define Q_NOWARN_DEPRECATED_POP
void setFilterExpression(const QString &filterExpression)
An additional expression to further restrict the available features.
void setValid(bool validity)
Sets the validity of the feature.
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.
static QgsExpressionContextScope * mapSettingsScope(const QgsMapSettings &mapSettings)
Creates a new scope which contains variables and functions relating to a QgsMapSettings object...
void pushItem(QgsMessageBarItem *item)
Display a message item on the bar after hiding the currently visible one and putting it in a stack...
QgsPointXY asPoint() const
Returns the contents of the geometry as a 2-dimensional point.
QSet< QVariant > uniqueValues(int fieldIndex, int limit=-1) const FINAL
Calculates a list of unique values contained within an attribute in the layer.
QgsPointXY layerToMapCoordinates(const QgsMapLayer *layer, QgsPointXY point) const
transform point coordinates from layer's CRS to output CRS
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
QgsRectangle boundingBox() const
Returns the bounding box of the geometry.
void setExtent(const QgsRectangle &r, bool magnified=false)
Sets the extent of the map canvas.
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const FINAL
Queries the layer for features specified in request.
QVariantList identifierValues
QList< int > QgsAttributeList
bool nextFeature(QgsFeature &f)
void setDisplayExpression(const QString &displayExpression)
The display expression will be used to display features as well as the value to match the typed text ...
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
QString attributeDisplayName(int index) const
Convenience function that returns the attribute alias if defined or the field name else...
void modelUpdated()
The underlying model has been updated.
A form was embedded as a widget on another form.