39 #include <QHBoxLayout> 41 #include <QMessageBox> 42 #include <QPushButton> 51 if ( mRequest.acceptFeature( layer->
getFeature( fid ) ) )
52 mSelectedFeatureIds << fid;
57 const QgsFeatureIds &QgsFilteredSelectionManager::selectedFeatureIds()
const 59 return mSelectedFeatureIds;
62 int QgsFilteredSelectionManager::selectedFeatureCount()
64 return mSelectedFeatureIds.count();
67 void QgsFilteredSelectionManager::onSelectionChanged(
const QgsFeatureIds &selected,
const QgsFeatureIds &deselected,
bool clearAndSelect )
72 mSelectedFeatureIds.clear();
76 for (
auto fid : deselected )
77 mSelectedFeatureIds.remove( fid );
80 for (
auto fid : selected )
81 if ( mRequest.acceptFeature( layer()->getFeature( fid ) ) )
82 mSelectedFeatureIds << fid;
84 lselected.remove( fid );
86 emit selectionChanged( lselected, deselected, clearAndSelect );
94 QVBoxLayout *topLayout =
new QVBoxLayout(
this );
95 topLayout->setContentsMargins( 0, 9, 0, 0 );
96 setLayout( topLayout );
99 QHBoxLayout *buttonLayout =
new QHBoxLayout();
100 buttonLayout->setContentsMargins( 0, 0, 0, 0 );
102 mToggleEditingButton =
new QToolButton(
this );
103 mToggleEditingButton->setObjectName( QStringLiteral(
"mToggleEditingButton" ) );
105 mToggleEditingButton->setText( tr(
"Toggle Editing" ) );
106 mToggleEditingButton->setEnabled(
false );
107 mToggleEditingButton->setCheckable(
true );
108 mToggleEditingButton->setToolTip( tr(
"Toggle editing mode for child layer" ) );
109 buttonLayout->addWidget( mToggleEditingButton );
111 mSaveEditsButton =
new QToolButton(
this );
113 mSaveEditsButton->setText( tr(
"Save Child Layer Edits" ) );
114 mSaveEditsButton->setToolTip( tr(
"Save child layer edits" ) );
115 mSaveEditsButton->setEnabled(
true );
116 buttonLayout->addWidget( mSaveEditsButton );
118 mAddFeatureGeometryButton =
new QToolButton(
this );
119 mAddFeatureGeometryButton->setObjectName( QStringLiteral(
"mAddFeatureGeometryButton" ) );
120 buttonLayout->addWidget( mAddFeatureGeometryButton );
122 mAddFeatureButton =
new QToolButton(
this );
124 mAddFeatureButton->setText( tr(
"Add Child Feature" ) );
125 mAddFeatureButton->setToolTip( tr(
"Add child feature" ) );
126 mAddFeatureButton->setObjectName( QStringLiteral(
"mAddFeatureButton" ) );
127 buttonLayout->addWidget( mAddFeatureButton );
129 mDuplicateFeatureButton =
new QToolButton(
this );
131 mDuplicateFeatureButton->setText( tr(
"Duplicate Child Feature" ) );
132 mDuplicateFeatureButton->setToolTip( tr(
"Duplicate child feature" ) );
133 mDuplicateFeatureButton->setObjectName( QStringLiteral(
"mDuplicateFeatureButton" ) );
134 buttonLayout->addWidget( mDuplicateFeatureButton );
136 mDeleteFeatureButton =
new QToolButton(
this );
138 mDeleteFeatureButton->setText( tr(
"Delete Child Feature" ) );
139 mDeleteFeatureButton->setToolTip( tr(
"Delete child feature" ) );
140 mDeleteFeatureButton->setObjectName( QStringLiteral(
"mDeleteFeatureButton" ) );
141 buttonLayout->addWidget( mDeleteFeatureButton );
143 mLinkFeatureButton =
new QToolButton(
this );
145 mLinkFeatureButton->setText( tr(
"Link Existing Features" ) );
146 mLinkFeatureButton->setToolTip( tr(
"Link existing child features" ) );
147 mLinkFeatureButton->setObjectName( QStringLiteral(
"mLinkFeatureButton" ) );
148 buttonLayout->addWidget( mLinkFeatureButton );
150 mUnlinkFeatureButton =
new QToolButton(
this );
152 mUnlinkFeatureButton->setText( tr(
"Unlink Feature" ) );
153 mUnlinkFeatureButton->setToolTip( tr(
"Unlink child feature" ) );
154 mUnlinkFeatureButton->setObjectName( QStringLiteral(
"mUnlinkFeatureButton" ) );
155 buttonLayout->addWidget( mUnlinkFeatureButton );
157 mZoomToFeatureButton =
new QToolButton(
this );
159 mZoomToFeatureButton->setText( tr(
"Zoom To Feature" ) );
160 mZoomToFeatureButton->setToolTip( tr(
"Zoom to child feature" ) );
161 mZoomToFeatureButton->setObjectName( QStringLiteral(
"mZoomToFeatureButton" ) );
162 buttonLayout->addWidget( mZoomToFeatureButton );
164 buttonLayout->addItem(
new QSpacerItem( 0, 0, QSizePolicy::Expanding ) );
166 mFormViewButton =
new QToolButton(
this );
167 mFormViewButton->setText( tr(
"Form View" ) );
168 mFormViewButton->setToolTip( tr(
"Switch to form view" ) );
170 mFormViewButton->setCheckable(
true );
172 buttonLayout->addWidget( mFormViewButton );
174 mTableViewButton =
new QToolButton(
this );
175 mTableViewButton->setText( tr(
"Table View" ) );
176 mTableViewButton->setToolTip( tr(
"Switch to table view" ) );
178 mTableViewButton->setCheckable(
true );
180 buttonLayout->addWidget( mTableViewButton );
182 mViewModeButtonGroup =
new QButtonGroup(
this );
187 topLayout->addLayout( buttonLayout );
189 mRelationLayout =
new QGridLayout();
190 mRelationLayout->setContentsMargins( 0, 0, 0, 0 );
191 topLayout->addLayout( mRelationLayout );
194 mDualView->
setView( mViewMode );
196 mRelationLayout->addWidget( mDualView );
199 connect( mViewModeButtonGroup,
static_cast<void ( QButtonGroup::* )(
int )
>( &QButtonGroup::buttonClicked ),
201 connect( mToggleEditingButton, &QAbstractButton::clicked,
this, &QgsRelationEditorWidget::toggleEditing );
202 connect( mSaveEditsButton, &QAbstractButton::clicked,
this, &QgsRelationEditorWidget::saveEdits );
203 connect( mAddFeatureButton, &QAbstractButton::clicked,
this, [
this]() { addFeature(); } );
204 connect( mAddFeatureGeometryButton, &QAbstractButton::clicked,
this, &QgsRelationEditorWidget::addFeatureGeometry );
205 connect( mDuplicateFeatureButton, &QAbstractButton::clicked,
this, &QgsRelationEditorWidget::duplicateFeature );
206 connect( mDeleteFeatureButton, &QAbstractButton::clicked,
this, &QgsRelationEditorWidget::deleteSelectedFeatures );
207 connect( mLinkFeatureButton, &QAbstractButton::clicked,
this, &QgsRelationEditorWidget::linkFeature );
208 connect( mUnlinkFeatureButton, &QAbstractButton::clicked,
this, &QgsRelationEditorWidget::unlinkSelectedFeatures );
209 connect( mZoomToFeatureButton, &QAbstractButton::clicked,
this, &QgsRelationEditorWidget::zoomToSelectedFeatures );
225 mRelation = relation;
232 setTitle( relation.
name() );
237 if ( canChangeAttributes && !lyr->readOnly() )
239 mToggleEditingButton->setEnabled(
true );
244 mToggleEditingButton->setEnabled(
false );
247 setObjectName( QStringLiteral(
"referenced/" ) + mRelation.name() );
256 initDualView( mRelation.referencingLayer(), myRequest );
262 mDualView->
init( layer, mEditorContext.
mapCanvas(), request, mEditorContext );
263 mFeatureSelectionMgr =
new QgsFilteredSelectionManager( layer, request, mDualView );
272 text = tr(
"Add Point child Feature" );
277 text = tr(
"Add Line child Feature" );
282 text = tr(
"Add Polygon Feature" );
287 mAddFeatureGeometryButton->setVisible(
false );
291 mAddFeatureGeometryButton->setIcon( icon );
292 mAddFeatureGeometryButton->setText( text );
293 mAddFeatureGeometryButton->setToolTip( text );
313 mRelation = relation;
314 mNmRelation = nmrelation;
316 if ( !mRelation.isValid() )
319 mToggleEditingButton->setVisible(
true );
322 for (
auto it = transactionGroups.constBegin(); it != transactionGroups.constEnd(); ++it )
324 if ( it.value()->layers().contains( mRelation.referencingLayer() ) )
326 mToggleEditingButton->setVisible(
false );
327 mSaveEditsButton->setVisible(
false );
340 setTitle( relation.
name() );
345 if ( canChangeAttributes && !lyr->readOnly() )
347 mToggleEditingButton->setEnabled(
true );
352 mToggleEditingButton->setEnabled(
false );
358 mZoomToFeatureButton->setVisible( mRelation.referencingLayer()->isSpatial() );
360 setObjectName( QStringLiteral(
"referenced/" ) + mRelation.name() );
367 mEditorContext = context;
372 mMapToolDigitize->
setButton( mAddFeatureGeometryButton );
378 return mFeatureSelectionMgr;
394 void QgsRelationEditorWidget::updateButtons()
396 bool editable =
false;
397 bool linkable =
false;
398 bool selectionNotEmpty = mFeatureSelectionMgr ? mFeatureSelectionMgr->
selectedFeatureCount() :
false;
411 mAddFeatureButton->setEnabled( editable );
412 mAddFeatureGeometryButton->setEnabled( editable );
413 mDuplicateFeatureButton->setEnabled( editable && selectionNotEmpty );
414 mLinkFeatureButton->setEnabled( linkable );
415 mDeleteFeatureButton->setEnabled( editable && selectionNotEmpty );
416 mUnlinkFeatureButton->setEnabled( linkable && selectionNotEmpty );
418 mZoomToFeatureButton->setVisible(
434 mZoomToFeatureButton->setEnabled( selectionNotEmpty );
436 mToggleEditingButton->setChecked( editable );
437 mSaveEditsButton->setEnabled( editable );
440 void QgsRelationEditorWidget::addFeatureGeometry()
448 mMapToolDigitize->
setLayer( layer );
451 window()->setVisible(
false );
452 setMapTool( mMapToolDigitize );
461 QString title = tr(
"Create child feature for parent %1 \"%2\"" ).arg( mRelation.
referencedLayer()->
name(), displayString );
462 QString msg = tr(
"Digitize the geometry for the new feature on layer %1. Press <ESC> to cancel." )
463 .arg( layer->
name() );
470 void QgsRelationEditorWidget::addFeature(
const QgsGeometry &geometry )
490 const auto constFieldPairs = mRelation.
fieldPairs();
493 int index = fields.
indexOf( fieldPair.first );
494 linkAttributes.insert( index, mFeature.
attribute( fieldPair.second ) );
497 const auto constNmFieldPairs = mNmRelation.
fieldPairs();
500 int index = fields.
indexOf( fieldPair.first );
501 linkAttributes.insert( index, f.
attribute( fieldPair.second ) );
514 const auto constFieldPairs = mRelation.
fieldPairs();
517 keyAttrs.insert( fields.
indexFromName( fieldPair.referencingField() ), mFeature.
attribute( fieldPair.referencedField() ) );
524 void QgsRelationEditorWidget::onDigitizingCompleted(
const QgsFeature &feature )
531 void QgsRelationEditorWidget::linkFeature()
540 QgsFeatureSelectionDlg *selectionDlg =
new QgsFeatureSelectionDlg( layer, mEditorContext,
this );
541 selectionDlg->setAttribute( Qt::WA_DeleteOnClose );
544 selectionDlg->setWindowTitle( tr(
"Link existing child features for parent %1 \"%2\"" ).arg( mRelation.
referencedLayer()->
name(), displayString ) );
546 connect( selectionDlg, &QDialog::accepted,
this, &QgsRelationEditorWidget::onLinkFeatureDlgAccepted );
547 selectionDlg->show();
550 void QgsRelationEditorWidget::onLinkFeatureDlgAccepted()
552 QgsFeatureSelectionDlg *selectionDlg = qobject_cast<QgsFeatureSelectionDlg *>( sender() );
557 .setFilterFids( selectionDlg->selectedFeatures() )
571 const auto constFieldPairs = mRelation.
fieldPairs();
574 int index = fields.
indexOf( fieldPair.first );
575 linkAttributes.insert( index, mFeature.
attribute( fieldPair.second ) );
580 const auto constFieldPairs = mNmRelation.
fieldPairs();
583 int index = fields.
indexOf( fieldPair.first );
584 linkAttributes.insert( index, relatedFeature.
attribute( fieldPair.second ) );
588 newFeatures << linkFeature;
593 const auto constNewFeatures = newFeatures;
594 for (
const QgsFeature &f : constNewFeatures )
600 QMap<int, QVariant> keys;
601 const auto constFieldPairs = mRelation.
fieldPairs();
605 QVariant val = mFeature.
attribute( fieldPair.referencedField() );
606 keys.insert( idx, val );
609 const auto constSelectedFeatures = selectionDlg->selectedFeatures();
612 QMapIterator<int, QVariant> it( keys );
613 while ( it.hasNext() )
624 void QgsRelationEditorWidget::duplicateFeature()
637 void QgsRelationEditorWidget::deleteFeature(
const QgsFeatureId featureid )
642 void QgsRelationEditorWidget::deleteSelectedFeatures()
647 void QgsRelationEditorWidget::deleteFeatures(
const QgsFeatureIds &featureids )
649 bool deleteFeatures =
true;
670 QStringList deletedFeaturesPks;
681 QString linkingFeaturesRequestExpression;
682 if ( !deletedFeaturesPks.empty() )
689 int relatedLinkingFeaturesCount = 0;
690 while ( relatedLinkingFeatures.
nextFeature( feature ) )
692 relatedLinkingFeaturesCount++;
695 if ( deletedFeaturesPks.size() == 1 && relatedLinkingFeaturesCount > 1 )
697 QMessageBox messageBox( QMessageBox::Question, tr(
"Really delete entry?" ), tr(
"The entry on %1 is still linked to %2 features on %3. Do you want to delete it?" ).arg( mNmRelation.
referencedLayer()->
name(), QString::number( relatedLinkingFeaturesCount ), mRelation.
referencedLayer()->
name() ), QMessageBox::NoButton,
this );
698 messageBox.addButton( QMessageBox::Cancel );
699 QAbstractButton *deleteButton = messageBox.addButton( tr(
"Delete" ), QMessageBox::AcceptRole );
702 if ( messageBox.clickedButton() != deleteButton )
703 deleteFeatures =
false;
705 else if ( deletedFeaturesPks.size() > 1 && relatedLinkingFeaturesCount > deletedFeaturesPks.size() )
707 QMessageBox messageBox( QMessageBox::Question, tr(
"Really delete entries?" ), tr(
"The %1 entries on %2 are still linked to %3 features on %4. Do you want to delete them?" ).arg( QString::number( deletedFeaturesPks.size() ), mNmRelation.
referencedLayer()->
name(), QString::number( relatedLinkingFeaturesCount ), mRelation.
referencedLayer()->
name() ), QMessageBox::NoButton,
this );
708 messageBox.addButton( QMessageBox::Cancel );
709 QAbstractButton *deleteButton = messageBox.addButton( tr(
"Delete" ), QMessageBox::AcceptRole );
712 if ( messageBox.clickedButton() != deleteButton )
713 deleteFeatures =
false;
722 if ( deleteFeatures )
729 void QgsRelationEditorWidget::unlinkFeature(
const QgsFeatureId featureid )
734 void QgsRelationEditorWidget::unlinkSelectedFeatures()
739 void QgsRelationEditorWidget::zoomToSelectedFeatures()
751 void QgsRelationEditorWidget::unlinkFeatures(
const QgsFeatureIds &featureids )
757 .setFilterFids( featureids )
769 QString filter = QStringLiteral(
"(%1) AND (%2)" ).arg(
771 filters.join( QStringLiteral(
" OR " ) ) );
775 .setFilterExpression( filter ) );
791 QMap<int, QgsField> keyFields;
792 const auto constFieldPairs = mRelation.
fieldPairs();
798 QgsDebugMsg( QStringLiteral(
"referencing field %1 not found" ).arg( fieldPair.referencingField() ) );
802 keyFields.insert( idx, fld );
805 const auto constFeatureids = featureids;
808 QMapIterator<int, QgsField> it( keyFields );
809 while ( it.hasNext() )
818 void QgsRelationEditorWidget::toggleEditing(
bool state )
834 void QgsRelationEditorWidget::saveEdits()
841 void QgsRelationEditorWidget::onCollapsedStateChanged(
bool collapsed )
850 void QgsRelationEditorWidget::updateUi()
871 filters << filter.prepend(
'(' ).append(
')' );
889 return mLinkFeatureButton->isVisible();
894 mLinkFeatureButton->setVisible( showLinkButton );
899 return mUnlinkFeatureButton->isVisible();
904 mUnlinkFeatureButton->setVisible( showUnlinkButton );
916 if ( mShowLabel && mRelation.
isValid() )
917 setTitle( mRelation.
name() );
919 setTitle( QString() );
926 QAction *qAction =
nullptr;
929 connect( qAction, &QAction::triggered,
this, [
this, fid]() { deleteFeature( fid ); } );
932 connect( qAction, &QAction::triggered,
this, [
this, fid]() { unlinkFeature( fid ); } );
936 void QgsRelationEditorWidget::setMapTool(
QgsMapTool *mapTool )
941 mapCanvas->window()->raise();
942 mapCanvas->activateWindow();
943 mapCanvas->setFocus();
947 void QgsRelationEditorWidget::unsetMapTool()
958 void QgsRelationEditorWidget::onKeyPressed( QKeyEvent *e )
960 if ( e->key() == Qt::Key_Escape )
966 void QgsRelationEditorWidget::mapToolDeactivated()
968 window()->setVisible(
true );
970 window()->activateWindow();
976 mMessageBarItem =
nullptr;
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.
const QgsVectorLayerTools * vectorLayerTools() const
Returns the associated vector layer tools.
Wrapper for iterator of features from vector data provider or vector layer.
QgsVectorLayer * layer() const
Returns the layer this model uses as backend.
QSet< QgsFeatureId > QgsFeatureIds
void init(QgsVectorLayer *layer, QgsMapCanvas *mapCanvas, const QgsFeatureRequest &request=QgsFeatureRequest(), const QgsAttributeEditorContext &context=QgsAttributeEditorContext(), bool loadFeatures=true)
Has to be called to initialize the dual view.
bool collapsed
The collapsed state of this group box.
virtual QgsVectorDataProvider::Capabilities capabilities() const
Returns flags containing the supported capabilities.
static QString quotedColumnRef(QString name)
Returns a quoted column reference (in double quotes)
QgsAttributeTableModel * masterModel() const
Returns the model which has the information about all features (not only filtered) ...
void setFeatureSelectionManager(QgsIFeatureSelectionManager *featureSelectionManager)
Set the feature selection model.
A groupbox that collapses/expands when toggled and can save its collapsed and checked states...
Contains mainly the QMap with QgsVectorLayer and QgsFeatureIds do list all the duplicated features...
This class contains context information for attribute editor widgets.
QList< QgsFeature > QgsFeatureList
QgsFeature getFeature(QgsFeatureId fid) const
Queries the layer for the feature with the given id.
QgsVectorLayer referencingLayer
ViewMode
The view modes, in which this widget can present information.
void collapsedStateChanged(bool collapsed)
Signal emitted when groupbox collapsed/expanded state is changed, and when first shown.
QgsFeatureRequest & setSubsetOfAttributes(const QgsAttributeList &attrs)
Set a subset of attributes that will be fetched.
Q_INVOKABLE QgsWkbTypes::GeometryType geometryType() const
Returns point, line or polygon.
bool deleteFeatures(const QgsFeatureIds &fids)
Deletes a set of features from the layer (but does not commit it)
Container of fields for a vector layer.
A geometry is the spatial representation of a feature.
static QIcon getThemeIcon(const QString &name)
Helper to get a theme icon.
QgsMessageBar * mainMessageBar()
Returns the main message bar.
void selectionChanged(const QgsFeatureIds &selected, const QgsFeatureIds &deselected, bool clearAndSelect)
Emitted when selection was changed.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
const QgsFeatureIds & selectedFeatureIds() const override
Returns reference to identifiers of selected features.
static QString getFeatureDisplayString(const QgsVectorLayer *layer, const QgsFeature &feature)
bool isSpatial() const FINAL
Returns true if this is a geometry layer and false in case of NoGeometry (table only) or UnknownGeome...
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.
void setView(ViewMode view)
Change the current view mode.
QgsField at(int i) const
Gets field at particular index (must be in range 0..N-1)
QgsExpression * filterExpression() const
Returns the filter expression if set.
Show a list of the features, where one can be chosen and the according attribute dialog will be prese...
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
bool isEditable() const FINAL
Returns true if the provider is in editing mode.
static QgsMessageBarItem * createMessage(const QString &text, QWidget *parent=nullptr)
make out a widget containing a message to be displayed on the bar
QgsAttributeList referencedFields() const
Returns a list of attributes used to form the referenced fields (most likely primary key) on the refe...
QgsFeatureRequest & setFilterExpression(const QString &expression)
Set the filter expression.
void setMapTool(QgsMapTool *mapTool, bool clean=false)
Sets the map tool currently being used on the canvas.
int indexFromName(const QString &fieldName) const
Gets the field index from the field name.
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.
Q_INVOKABLE const QgsFeatureIds & selectedFeatureIds() const
Returns a list of the selected features IDs in this layer.
Defines a relation between matching fields of the two involved tables of a relation.
Shows the features and attributes in a table layout.
#define QgsDebugMsgLevel(str, level)
bool popWidget(QgsMessageBarItem *item)
Remove the passed widget from the bar (if previously added), then display the next one in the stack i...
QgsFeatureRequest & setNoAttributes()
Set that no attributes will be fetched.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
static QgsFeature createFeature(const QgsVectorLayer *layer, const QgsGeometry &geometry=QgsGeometry(), const QgsAttributeMap &attributes=QgsAttributeMap(), QgsExpressionContext *context=nullptr)
Creates a new feature ready for insertion into a layer.
QMap< int, QVariant > QgsAttributeMap
void editingStopped()
Emitted when edited changes have been successfully written to the data provider.
This class wraps a request for features to a vector layer (or directly its vector data provider)...
bool addFeatures(QgsFeatureList &features, QgsFeatureSink::Flags flags=nullptr) FINAL
Adds a list of features to the sink.
void selectionChanged(const QgsFeatureIds &selected, const QgsFeatureIds &deselected, bool clearAndSelect)
Emitted when selection was changed.
QgsVectorLayer referencedLayer
Encapsulate a field in an attribute table or data source.
QgsFeatureRequest getRelatedFeaturesRequest(const QgsFeature &feature) const
Creates a request to return all the features on the referencing (child) layer which have a foreign ke...
void editingStarted()
Emitted when editing on this layer has started.
QgsExpressionContext createExpressionContext() const FINAL
This method needs to be reimplemented in all classes which implement this interface and return an exp...
void keyPressed(QKeyEvent *e)
Emit key press event.
QgsAdvancedDigitizingDockWidget * cadDockWidget() const
Returns the associated CAD dock widget (e.g.
QList< QgsRelation::FieldPair > fieldPairs() const
Returns the field pairs which form this relation The first element of each pair are the field names o...
QString expression() const
Returns the original, unmodified expression string.
void showContextMenuExternally(QgsActionMenu *menu, QgsFeatureId fid)
Emitted when selecting context menu on the feature list to create the context menu individually...
void zoomToFeatureIds(QgsVectorLayer *layer, const QgsFeatureIds &ids)
Set canvas extent to the bounding box of a set of features.
void pushItem(QgsMessageBarItem *item)
Display a message item on the bar after hiding the currently visible one and putting it in a stack...
QgsFeatureRequest & setFilterFids(const QgsFeatureIds &fids)
Sets feature IDs that should be fetched.
#define FID_TO_STRING(fid)
int indexOf(const QString &fieldName) const
Gets the field index from the field name.
int selectedFeatureCount() override
Returns the number of features that are selected in this layer.
QMap< QPair< QString, QString >, QgsTransactionGroup * > transactionGroups()
Map of transaction groups.
static QgsFeature duplicateFeature(QgsVectorLayer *layer, const QgsFeature &feature, QgsProject *project, int depth, QgsDuplicateFeatureContext &duplicateFeatureContext)
Duplicates a feature and it's children (one level deep).
static QgsProject * instance()
Returns the QgsProject singleton instance.
Q_INVOKABLE void selectByIds(const QgsFeatureIds &ids, QgsVectorLayer::SelectBehavior behavior=QgsVectorLayer::SetSelection)
Selects matching features using a list of feature IDs.
bool addFeature(QgsFeature &feature, QgsFeatureSink::Flags flags=nullptr) FINAL
Adds a single feature to the sink.
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const FINAL
Queries the layer for features specified in request.
bool changeAttributeValue(QgsFeatureId fid, int field, const QVariant &newValue, const QVariant &oldValue=QVariant(), bool skipDefaultValues=false)
Changes an attribute value for a feature (but does not immediately commit the changes).
QgsVectorDataProvider * dataProvider() FINAL
Returns the layer's data provider, it may be nullptr.
QList< int > QgsAttributeList
bool nextFeature(QgsFeature &f)
static QString quotedValue(const QVariant &value)
Returns a string representation of a literal value, including appropriate quotations where required...
Geometry is not required. It may still be returned if e.g. required for a filter condition.
Is an interface class to abstract feature selection handling.
Represents a vector layer which manages a vector based data sets.
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
QgsMapCanvas * mapCanvas() const
Returns the associated map canvas (e.g.
Allows modification of attribute values.
This widget is used to show the attributes of a set of features of a QgsVectorLayer.
QgsFeatureRequest & setFlags(QgsFeatureRequest::Flags flags)
Sets flags that affect how features will be fetched.