18 #include <QPushButton> 20 #include <QHBoxLayout> 55 for (
int i = 0; i < list.size(); ++i )
57 if ( !list.at( i ).isNull() )
67 mTopLayout =
new QVBoxLayout(
this );
68 mTopLayout->setContentsMargins( 0, 0, 0, 0 );
70 setSizePolicy( sizePolicy().horizontalPolicy(), QSizePolicy::Fixed );
72 setLayout( mTopLayout );
74 QHBoxLayout *editLayout =
new QHBoxLayout();
75 editLayout->setContentsMargins( 0, 0, 0, 0 );
76 editLayout->setSpacing( 2 );
79 mChooserContainer =
new QWidget;
80 editLayout->addWidget( mChooserContainer );
81 QHBoxLayout *chooserLayout =
new QHBoxLayout;
82 chooserLayout->setContentsMargins( 0, 0, 0, 0 );
83 mFilterLayout =
new QHBoxLayout;
84 mFilterLayout->setContentsMargins( 0, 0, 0, 0 );
85 mFilterContainer =
new QWidget;
86 mFilterContainer->setLayout( mFilterLayout );
87 mChooserContainer->setLayout( chooserLayout );
88 chooserLayout->addWidget( mFilterContainer );
91 mChooserContainer->layout()->addWidget( mComboBox );
94 mLineEdit =
new QLineEdit();
95 mLineEdit->setReadOnly(
true );
96 editLayout->addWidget( mLineEdit );
99 mOpenFormButton =
new QToolButton();
101 mOpenFormButton->setText( tr(
"Open Related Feature Form" ) );
102 editLayout->addWidget( mOpenFormButton );
104 mAddEntryButton =
new QToolButton();
106 mAddEntryButton->setText( tr(
"Add New Entry" ) );
107 editLayout->addWidget( mAddEntryButton );
110 mHighlightFeatureButton =
new QToolButton(
this );
111 mHighlightFeatureButton->setPopupMode( QToolButton::MenuButtonPopup );
112 mHighlightFeatureAction =
new QAction(
QgsApplication::getThemeIcon( QStringLiteral(
"/mActionHighlightFeature.svg" ) ), tr(
"Highlight feature" ),
this );
113 mScaleHighlightFeatureAction =
new QAction(
QgsApplication::getThemeIcon( QStringLiteral(
"/mActionScaleHighlightFeature.svg" ) ), tr(
"Scale and highlight feature" ),
this );
114 mPanHighlightFeatureAction =
new QAction(
QgsApplication::getThemeIcon( QStringLiteral(
"/mActionPanHighlightFeature.svg" ) ), tr(
"Pan and highlight feature" ),
this );
115 mHighlightFeatureButton->addAction( mHighlightFeatureAction );
116 mHighlightFeatureButton->addAction( mScaleHighlightFeatureAction );
117 mHighlightFeatureButton->addAction( mPanHighlightFeatureAction );
118 mHighlightFeatureButton->setDefaultAction( mHighlightFeatureAction );
119 editLayout->addWidget( mHighlightFeatureButton );
122 mMapIdentificationButton =
new QToolButton(
this );
124 mMapIdentificationButton->setText( tr(
"Select on Map" ) );
125 mMapIdentificationButton->setCheckable(
true );
126 editLayout->addWidget( mMapIdentificationButton );
129 mRemoveFKButton =
new QToolButton(
this );
131 mRemoveFKButton->setText( tr(
"No Selection" ) );
132 editLayout->addWidget( mRemoveFKButton );
135 mTopLayout->addLayout( editLayout );
139 mAttributeEditorLayout =
new QVBoxLayout( mAttributeEditorFrame );
140 mAttributeEditorFrame->setLayout( mAttributeEditorLayout );
141 mAttributeEditorFrame->setSizePolicy( mAttributeEditorFrame->sizePolicy().horizontalPolicy(), QSizePolicy::Expanding );
142 mTopLayout->addWidget( mAttributeEditorFrame );
145 mInvalidLabel =
new QLabel( tr(
"The relation is not valid. Please make sure your relation definitions are OK." ) );
146 mInvalidLabel->setWordWrap(
true );
147 QFont font = mInvalidLabel->font();
148 font.setItalic(
true );
149 mInvalidLabel->setStyleSheet( QStringLiteral(
"QLabel { color: red; } " ) );
150 mInvalidLabel->setFont( font );
151 mTopLayout->addWidget( mInvalidLabel );
155 mMapIdentificationButton->hide();
156 mHighlightFeatureButton->hide();
157 mAttributeEditorFrame->hide();
158 mInvalidLabel->hide();
159 mAddEntryButton->hide();
163 connect( mHighlightFeatureButton, &QToolButton::triggered,
this, &QgsRelationReferenceWidget::highlightActionTriggered );
166 connect( mAddEntryButton, &QAbstractButton::clicked,
this, &QgsRelationReferenceWidget::addEntry );
167 connect( mComboBox, &QComboBox::editTextChanged,
this, &QgsRelationReferenceWidget::updateAddEntryButton );
177 void QgsRelationReferenceWidget::updateIndex()
179 if ( mChainFilters && mComboBox->count() > 0 )
184 if ( ! mFilterComboBoxes.isEmpty()
185 && mFilterComboBoxes[0]->currentIndex() == 0 && mAllowNull )
189 else if ( mComboBox->count() > mComboBox->
nullIndex() )
193 else if ( mAllowNull )
202 if ( mComboBox->count() > index )
204 mComboBox->setCurrentIndex( index );
211 mAllowNull = allowNullValue;
212 mRemoveFKButton->setVisible( allowNullValue && mReadOnlySelector );
220 mInvalidLabel->hide();
225 const QList<QgsRelation::FieldPair> fieldPairs = relation.
fieldPairs();
228 mReferencedFields << fieldPair.referencedField();
235 mAttributeEditorFrame->setObjectName( QStringLiteral(
"referencing/" ) + relation.
name() );
240 mAttributeEditorFrame->setTitle( mReferencedLayer->
name() );
242 mAttributeEditorLayout->addWidget( mReferencedAttributeForm );
247 updateAddEntryButton();
251 mInvalidLabel->show();
254 if ( mShown && isVisible() )
267 mFilterContainer->setEnabled( editable );
268 mComboBox->setEnabled( editable );
269 mComboBox->setEditable(
true );
270 mMapIdentificationButton->setEnabled( editable );
271 mRemoveFKButton->setEnabled( editable );
272 mIsEditable = editable;
282 if ( values.isEmpty() )
292 if ( !mReferencedLayer )
295 if ( mReadOnlySelector )
301 const QList<QgsRelation::FieldPair> fieldPairs = mRelation.
fieldPairs();
302 int fieldCount = std::min( fieldPairs.count(), values.count() );
303 for (
int i = 0; i < fieldCount; i++ )
305 int idx = mReferencingLayer->
fields().
lookupField( fieldPairs.at( i ).referencingField() );
306 attrs[idx] = values.at( i );
318 mForeignKeys.clear();
319 for (
const QString &fieldName : qgis::as_const( mReferencedFields ) )
320 mForeignKeys << mFeature.
attribute( fieldName );
324 context.setFeature( mFeature );
325 QString title = expr.evaluate( &context ).toString();
326 if ( expr.hasEvalError() )
328 QStringList titleFields;
329 for (
const QString &fieldName : qgis::as_const( mReferencedFields ) )
330 titleFields << mFeature.
attribute( fieldName ).toString();
331 title = titleFields.join( QStringLiteral(
" " ) );
333 mLineEdit->setText( title );
347 const int count = std::min( mFilterComboBoxes.size(), mFilterFields.size() );
348 for (
int i = 0; i < count; i++ )
350 QVariant v = mFeature.
attribute( mFilterFields[i] );
351 QString f = v.isNull() ? nullValue.toString() : v.toString();
352 mFilterComboBoxes.at( i )->setCurrentIndex( mFilterComboBoxes.at( i )->findText( f ) );
357 mRemoveFKButton->setEnabled( mIsEditable );
358 highlightFeature( mFeature );
359 updateAttributeEditorFrame( mFeature );
367 if ( mChainFilters && !mFilterComboBoxes.isEmpty() )
369 QComboBox *cb = mFilterComboBoxes.first();
370 cb->setCurrentIndex( 0 );
371 disableChainedComboBoxes( cb );
374 if ( mReadOnlySelector )
381 nullText = tr(
"%1 (no selection)" ).arg( nullValue );
383 mLineEdit->setText( nullText );
384 QVariantList nullAttributes;
385 for (
const QString &fieldName : qgis::as_const( mReferencedFields ) )
387 Q_UNUSED( fieldName );
388 nullAttributes << QVariant( QVariant::Int );
390 mForeignKeys = nullAttributes;
397 mRemoveFKButton->setEnabled(
false );
406 if ( mReferencedLayer )
409 if ( mReadOnlySelector )
424 if ( mReadOnlySelector )
432 mRemoveFKButton->setEnabled(
false );
439 if ( fkeys.isEmpty() )
440 return QVariant( QVariant::Int );
442 return fkeys.at( 0 );
447 if ( mReadOnlySelector )
459 mEditorContext = context;
461 mMessageBar = messageBar;
464 mMapToolIdentify->
setButton( mMapIdentificationButton );
469 mMapToolDigitize->
setButton( mAddEntryButton );
470 updateAddEntryButton();
478 setSizePolicy( sizePolicy().horizontalPolicy(), QSizePolicy::MinimumExpanding );
479 mTopLayout->setAlignment( Qt::AlignTop );
482 mAttributeEditorFrame->setVisible( display );
483 mEmbedForm = display;
488 mChooserContainer->setHidden( readOnly );
489 mLineEdit->setVisible( readOnly );
490 mRemoveFKButton->setVisible( mAllowNull && readOnly );
491 mReadOnlySelector = readOnly;
496 mHighlightFeatureButton->setVisible( allowMapIdentification );
497 mMapIdentificationButton->setVisible( allowMapIdentification );
508 mFilterFields = filterFields;
513 mOpenFormButton->setVisible( openFormButtonVisible );
533 if ( !mReadOnlySelector && mReferencedLayer )
535 QApplication::setOverrideCursor( Qt::WaitCursor );
537 QSet<QString> requestedAttrs;
539 if ( !mFilterFields.isEmpty() )
541 for (
const QString &fieldName : qgis::as_const( mFilterFields ) )
548 QComboBox *cb =
new QComboBox();
549 cb->setProperty(
"Field", fieldName );
551 mFilterComboBoxes << cb;
552 QVariantList uniqueValues = mReferencedLayer->
uniqueValues( idx ).toList();
555 cb->addItem( nullValue.toString(), QVariant( mReferencedLayer->
fields().
at( idx ).
type() ) );
558 const auto constUniqueValues = uniqueValues;
559 for (
const QVariant &v : constUniqueValues )
561 cb->addItem( v.toString(), v );
564 connect( cb,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsRelationReferenceWidget::filterChanged );
567 requestedAttrs << fieldName;
569 mFilterLayout->addWidget( cb );
580 const int count = std::min( mFilterComboBoxes.count(), mFilterFields.count() );
581 for (
int i = 0; i < count - 1; i++ )
583 QVariant cv = ft.
attribute( mFilterFields.at( i ) );
584 QVariant nv = ft.
attribute( mFilterFields.at( i + 1 ) );
585 QString cf = cv.isNull() ? nullValue.toString() : cv.toString();
586 QString nf = nv.isNull() ? nullValue.toString() : nv.toString();
587 mFilterCache[mFilterFields[i]][cf] << nf;
591 if ( !mFilterComboBoxes.isEmpty() )
593 QComboBox *cb = mFilterComboBoxes.first();
594 cb->setCurrentIndex( 0 );
595 disableChainedComboBoxes( cb );
601 mFilterContainer->hide();
611 if ( mChainFilters && mFeature.
isValid() )
613 for (
int i = 0; i < mFilterFields.size(); i++ )
615 QVariant v = mFeature.
attribute( mFilterFields[i] );
616 QString f = v.isNull() ? nullValue.toString() : v.toString();
617 mFilterComboBoxes.at( i )->setCurrentIndex( mFilterComboBoxes.at( i )->findText( f ) );
622 connect( mComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsRelationReferenceWidget::comboReferenceChanged );
624 emit mComboBox->currentIndexChanged( mComboBox->currentIndex() );
626 QApplication::restoreOverrideCursor();
632 void QgsRelationReferenceWidget::highlightActionTriggered( QAction *action )
634 if ( action == mHighlightFeatureAction )
638 else if ( action == mScaleHighlightFeatureAction )
642 else if ( action == mPanHighlightFeatureAction )
657 attributeDialog.exec();
680 if ( canvasExtent ==
Scale )
693 else if ( canvasExtent ==
Pan )
703 mHighlight =
new QgsHighlight( mCanvas, f, mReferencedLayer );
707 QTimer *timer =
new QTimer(
this );
708 timer->setSingleShot(
true );
709 connect( timer, &QTimer::timeout,
this, &QgsRelationReferenceWidget::deleteHighlight );
710 timer->start( 3000 );
713 void QgsRelationReferenceWidget::deleteHighlight()
720 mHighlight =
nullptr;
725 if ( !mAllowMapIdentification || !mReferencedLayer )
734 mMapToolIdentify->
setLayer( mReferencedLayer );
735 setMapTool( mMapToolIdentify );
741 QString title = tr(
"Relation %1 for %2." ).arg( mRelation.
name(), mReferencingLayer->
name() );
742 QString msg = tr(
"Identify a feature of %1 to be associated. Press <ESC> to cancel." ).arg( mReferencedLayer->
name() );
744 mMessageBar->
pushItem( mMessageBarItem );
748 void QgsRelationReferenceWidget::comboReferenceChanged(
int index )
752 highlightFeature( mFeature );
753 updateAttributeEditorFrame( mFeature );
758 void QgsRelationReferenceWidget::updateAttributeEditorFrame(
const QgsFeature &feature )
760 mOpenFormButton->setEnabled( feature.
isValid() );
762 if ( mAttributeEditorFrame && mReferencedAttributeForm )
764 mReferencedAttributeForm->
setFeature( feature );
770 return mAllowAddFeatures;
776 updateAddEntryButton();
784 void QgsRelationReferenceWidget::featureIdentified(
const QgsFeature &feature )
786 if ( mReadOnlySelector )
790 context.setFeature( feature );
791 QString title = expr.evaluate( &context ).toString();
792 if ( expr.hasEvalError() )
794 QStringList titleFields;
795 for (
const QString &fieldName : qgis::as_const( mReferencedFields ) )
796 titleFields << mFeature.
attribute( fieldName ).toString();
797 title = titleFields.join( QStringLiteral(
" " ) );
799 mLineEdit->setText( title );
800 mForeignKeys.clear();
802 for (
const QString &fieldName : qgis::as_const( mReferencedFields ) )
803 mForeignKeys << mFeature.
attribute( fieldName );
811 mRemoveFKButton->setEnabled( mIsEditable );
812 highlightFeature( feature );
813 updateAttributeEditorFrame( feature );
819 void QgsRelationReferenceWidget::setMapTool(
QgsMapTool *mapTool )
821 mCurrentMapTool = mapTool;
824 mWindowWidget = window();
826 mCanvas->window()->raise();
827 mCanvas->activateWindow();
832 void QgsRelationReferenceWidget::unsetMapTool()
835 if ( mCurrentMapTool )
840 if ( mCurrentMapTool == mMapToolDigitize )
852 void QgsRelationReferenceWidget::onKeyPressed( QKeyEvent *e )
854 if ( e->key() == Qt::Key_Escape )
860 void QgsRelationReferenceWidget::mapToolDeactivated()
864 mWindowWidget->raise();
865 mWindowWidget->activateWindow();
868 if ( mMessageBar && mMessageBarItem )
870 mMessageBar->
popWidget( mMessageBarItem );
872 mMessageBarItem =
nullptr;
875 void QgsRelationReferenceWidget::filterChanged()
879 QMap<QString, QString> filters;
882 QComboBox *scb = qobject_cast<QComboBox *>( sender() );
888 QString filterExpression;
892 disableChainedComboBoxes( scb );
895 const auto constMFilterComboBoxes = mFilterComboBoxes;
896 for ( QComboBox *cb : constMFilterComboBoxes )
898 if ( cb->currentIndex() != 0 )
900 const QString fieldName = cb->property(
"Field" ).toString();
902 if ( cb->currentText() == nullValue.toString() )
904 filters[fieldName] = QStringLiteral(
"\"%1\" IS NULL" ).arg( fieldName );
916 QComboBox *ccb =
nullptr;
917 const auto constMFilterComboBoxes = mFilterComboBoxes;
918 for ( QComboBox *cb : constMFilterComboBoxes )
928 if ( ccb->currentIndex() != 0 )
930 const QString fieldName = cb->property(
"Field" ).toString();
932 cb->blockSignals(
true );
934 cb->addItem( cb->property(
"FieldAlias" ).toString() );
939 const auto txts { mFilterCache[ccb->property(
"Field" ).toString()][ccb->currentText()] };
940 for (
const QString &txt : txts )
942 QMap<QString, QString> filtersAttrs = filters;
944 QString expression = filtersAttrs.values().join( QStringLiteral(
" AND " ) );
952 while ( it.nextFeature( f ) )
954 if ( !featureIds.contains( f.
id() ) )
955 featureIds << f.
id();
966 cb->addItems( texts );
968 cb->setEnabled(
true );
969 cb->blockSignals(
false );
975 filterExpression = filters.values().join( QStringLiteral(
" AND " ) );
979 void QgsRelationReferenceWidget::addEntry()
981 if ( !mReferencedLayer )
998 mMapToolDigitize->
setLayer( mReferencedLayer );
999 setMapTool( mMapToolDigitize );
1006 QString title = tr(
"Relation %1 for %2." ).arg( mRelation.
name(), mReferencingLayer->
name() );
1009 QString msg = tr(
"Link feature to %1 \"%2\" : Digitize the geometry for the new feature on layer %3. Press <ESC> to cancel." )
1010 .arg( mReferencingLayer->
name(), displayString, mReferencedLayer->
name() );
1012 mMessageBar->
pushItem( mMessageBarItem );
1017 void QgsRelationReferenceWidget::entryAdded(
const QgsFeature &feat )
1023 if ( mComboBox->itemText( mComboBox->currentIndex() ) != mComboBox->currentText() )
1027 if ( fieldIdx != -1 )
1029 attributes.insert( fieldIdx, mComboBox->currentText() );
1036 for (
const QString &fieldName : qgis::as_const( mReferencedFields ) )
1041 mAddEntryButton->setEnabled(
false );
1047 void QgsRelationReferenceWidget::updateAddEntryButton()
1049 mAddEntryButton->setVisible( mAllowAddFeatures && mMapToolDigitize );
1050 mAddEntryButton->setEnabled( mReferencedLayer && mReferencedLayer->
isEditable() );
1053 void QgsRelationReferenceWidget::disableChainedComboBoxes(
const QComboBox *scb )
1055 QComboBox *ccb =
nullptr;
1056 const auto constMFilterComboBoxes = mFilterComboBoxes;
1057 for ( QComboBox *cb : constMFilterComboBoxes )
1069 cb->setCurrentIndex( 0 );
1070 if ( ccb->currentIndex() == 0 )
1072 cb->setEnabled(
false );
1079 void QgsRelationReferenceWidget::emitForeignKeysChanged(
const QVariantList &
foreignKeys,
bool force )
1081 if (
foreignKeys == mForeignKeys && force ==
false )
1093 return mReferencedLayerName;
1098 mReferencedLayerName = relationLayerName;
1103 return mReferencedLayerId;
1108 mReferencedLayerId = relationLayerId;
1113 return mReferencedLayerProviderKey;
1118 mReferencedLayerProviderKey = relationProviderKey;
1123 return mReferencedLayerDataSource;
1129 mReferencedLayerDataSource = resolver.writePath( relationDataSource );
1134 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...
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.
QString providerType() const
Returns the provider type (provider key) for this layer.
QgsVectorLayer referencingLayer
#define Q_NOWARN_DEPRECATED_PUSH
A bar for displaying non-blocking messages to the user.
Q_INVOKABLE 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.
static QString getFeatureDisplayString(const QgsVectorLayer *layer, const QgsFeature &feature)
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).
QgsPathResolver pathResolver() const
Returns path resolver object with considering whether the project uses absolute or relative paths and...
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.
QString publicSource() const
Gets a version of the internal layer definition that has sensitive bits removed (for example...
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.
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
static QgsProject * instance()
Returns the QgsProject singleton instance.
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)
Resolves relative paths into absolute paths and vice versa.
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 referencedLayerId() const
Access the referenced (parent) layer's id.
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.