17#include "moc_qgsrelationeditorwidget.cpp"
51 for (
const auto fid : layer->selectedFeatureIds() )
52 if ( mRequest.acceptFeature( layer->getFeature( fid ) ) )
53 mSelectedFeatureIds << fid;
58const QgsFeatureIds &QgsFilteredSelectionManager::selectedFeatureIds()
const
62 return mSelectedFeatureIds;
65int QgsFilteredSelectionManager::selectedFeatureCount()
67 return mSelectedFeatureIds.count();
70void QgsFilteredSelectionManager::onSelectionChanged(
const QgsFeatureIds &selected,
const QgsFeatureIds &deselected,
bool clearAndSelect )
75 mSelectedFeatureIds.clear();
79 for (
const auto fid : deselected )
80 mSelectedFeatureIds.remove( fid );
83 for (
const auto fid : selected )
84 if ( mRequest.acceptFeature( layer()->getFeature( fid ) ) )
85 mSelectedFeatureIds << fid;
87 lselected.remove( fid );
89 emit selectionChanged( lselected, deselected, clearAndSelect );
97 , mShowFirstFeature( config.value( QStringLiteral(
"show_first_feature" ), true ).toBool() )
98 , mAllowAddChildFeatureWithNoGeometry( config.value( QStringLiteral(
"allow_add_child_feature_with_no_geometry" ), false ).toBool() )
99 , mFilterExpression( config.value( QStringLiteral(
"filter_expression" ) ).toString() )
101 QVBoxLayout *rootLayout =
new QVBoxLayout(
this );
102 rootLayout->setContentsMargins( 0, 9, 0, 0 );
105 QHBoxLayout *buttonLayout =
new QHBoxLayout();
106 buttonLayout->setContentsMargins( 0, 0, 0, 0 );
108 mToggleEditingButton =
new QToolButton(
this );
109 mToggleEditingButton->setObjectName( QStringLiteral(
"mToggleEditingButton" ) );
111 mToggleEditingButton->setText( tr(
"Toggle Editing" ) );
112 mToggleEditingButton->setEnabled(
false );
113 mToggleEditingButton->setCheckable(
true );
114 mToggleEditingButton->setToolTip( tr(
"Toggle editing mode for child layer" ) );
115 buttonLayout->addWidget( mToggleEditingButton );
117 mSaveEditsButton =
new QToolButton(
this );
119 mSaveEditsButton->setText( tr(
"Save Child Layer Edits" ) );
120 mSaveEditsButton->setToolTip( tr(
"Save child layer edits" ) );
121 mSaveEditsButton->setEnabled(
true );
122 buttonLayout->addWidget( mSaveEditsButton );
124 mAddFeatureGeometryButton =
new QToolButton(
this );
125 mAddFeatureGeometryButton->setObjectName( QStringLiteral(
"mAddFeatureGeometryButton" ) );
126 buttonLayout->addWidget( mAddFeatureGeometryButton );
128 mAddFeatureButton =
new QToolButton(
this );
130 mAddFeatureButton->setText( tr(
"Add Child Feature" ) );
131 mAddFeatureButton->setToolTip( tr(
"Add child feature" ) );
132 mAddFeatureButton->setObjectName( QStringLiteral(
"mAddFeatureButton" ) );
133 buttonLayout->addWidget( mAddFeatureButton );
135 mDuplicateFeatureButton =
new QToolButton(
this );
137 mDuplicateFeatureButton->setText( tr(
"Duplicate Child Feature(s)" ) );
138 mDuplicateFeatureButton->setToolTip( tr(
"Duplicate selected child feature(s)" ) );
139 mDuplicateFeatureButton->setObjectName( QStringLiteral(
"mDuplicateFeatureButton" ) );
140 buttonLayout->addWidget( mDuplicateFeatureButton );
142 mDeleteFeatureButton =
new QToolButton(
this );
144 mDeleteFeatureButton->setText( tr(
"Delete Child Feature(s)" ) );
145 mDeleteFeatureButton->setToolTip( tr(
"Delete selected child feature(s)" ) );
146 mDeleteFeatureButton->setObjectName( QStringLiteral(
"mDeleteFeatureButton" ) );
147 buttonLayout->addWidget( mDeleteFeatureButton );
149 mLinkFeatureButton =
new QToolButton(
this );
151 mLinkFeatureButton->setText( tr(
"Link Existing Feature(s)" ) );
152 mLinkFeatureButton->setToolTip( tr(
"Link existing child feature(s)" ) );
153 mLinkFeatureButton->setObjectName( QStringLiteral(
"mLinkFeatureButton" ) );
154 buttonLayout->addWidget( mLinkFeatureButton );
156 mUnlinkFeatureButton =
new QToolButton(
this );
158 mUnlinkFeatureButton->setText( tr(
"Unlink Feature(s)" ) );
159 mUnlinkFeatureButton->setToolTip( tr(
"Unlink selected child feature(s)" ) );
160 mUnlinkFeatureButton->setObjectName( QStringLiteral(
"mUnlinkFeatureButton" ) );
161 buttonLayout->addWidget( mUnlinkFeatureButton );
163 mZoomToFeatureButton =
new QToolButton(
this );
165 mZoomToFeatureButton->setText( tr(
"Zoom To Feature(s)" ) );
166 mZoomToFeatureButton->setToolTip( tr(
"Zoom to selected child feature(s)" ) );
167 mZoomToFeatureButton->setObjectName( QStringLiteral(
"mZoomToFeatureButton" ) );
168 buttonLayout->addWidget( mZoomToFeatureButton );
170 buttonLayout->addItem(
new QSpacerItem( 0, 0, QSizePolicy::Expanding ) );
172 mFormViewButton =
new QToolButton(
this );
173 mFormViewButton->setText( tr(
"Form View" ) );
174 mFormViewButton->setToolTip( tr(
"Switch to form view" ) );
176 mFormViewButton->setCheckable(
true );
178 buttonLayout->addWidget( mFormViewButton );
180 mTableViewButton =
new QToolButton(
this );
181 mTableViewButton->setText( tr(
"Table View" ) );
182 mTableViewButton->setToolTip( tr(
"Switch to table view" ) );
184 mTableViewButton->setCheckable(
true );
186 buttonLayout->addWidget( mTableViewButton );
188 mViewModeButtonGroup =
new QButtonGroup(
this );
192 mMultiEditInfoLabel =
new QLabel(
this );
193 buttonLayout->addWidget( mMultiEditInfoLabel );
196 rootLayout->addLayout( buttonLayout );
199 mStackedWidget =
new QStackedWidget(
this );
203 mDualView->
setView( mViewMode );
207 mMultiEditStackedWidgetPage =
new QWidget(
this );
209 QVBoxLayout *vBoxLayout =
new QVBoxLayout();
210 vBoxLayout->setContentsMargins( 0, 0, 0, 0 );
212 mMultiEditTreeWidget =
new QTreeWidget(
this );
213 mMultiEditTreeWidget->setHeaderHidden(
true );
214 mMultiEditTreeWidget->setSelectionMode( QTreeWidget::ExtendedSelection );
215 vBoxLayout->addWidget( mMultiEditTreeWidget );
217 mMultiEditStackedWidgetPage->setLayout( vBoxLayout );
219 mStackedWidget->addWidget( mMultiEditStackedWidgetPage );
221 mStackedWidget->addWidget( mDualView );
223 rootLayout->addWidget( mStackedWidget );
226 connect( mToggleEditingButton, &QAbstractButton::clicked,
this, &QgsRelationEditorWidget::toggleEditing );
228 connect( mAddFeatureButton, &QAbstractButton::clicked,
this, &QgsRelationEditorWidget::addFeature );
229 connect( mAddFeatureGeometryButton, &QAbstractButton::clicked,
this, &QgsRelationEditorWidget::addFeatureGeometry );
232 connect( mLinkFeatureButton, &QAbstractButton::clicked,
this, &QgsRelationEditorWidget::linkFeature );
235 connect( mMultiEditTreeWidget, &QTreeWidget::itemSelectionChanged,
this, &QgsRelationEditorWidget::multiEditItemSelectionChanged );
240 setLayout( rootLayout );
254 mFeatureSelectionMgr =
new QgsFilteredSelectionManager( layer, request, mDualView );
264 text = tr(
"Add Point Child Feature" );
269 text = tr(
"Add Line Child Feature" );
274 text = tr(
"Add Polygon Child Feature" );
277 mAddFeatureGeometryButton->setIcon( icon );
278 mAddFeatureGeometryButton->setText( text );
279 mAddFeatureGeometryButton->setToolTip( text );
291 mMapToolDigitize->
setButton( mAddFeatureGeometryButton );
303void QgsRelationEditorWidget::updateButtons()
305 bool toggleEditingButtonEnabled =
false;
307 bool canAddGeometry =
false;
308 bool canRemove =
false;
309 bool canEdit =
false;
310 bool canLink =
false;
311 bool canUnlink =
false;
312 bool spatial =
false;
336 const bool selectionNotEmpty = mFeatureSelectionMgr ? mFeatureSelectionMgr->
selectedFeatureCount() :
false;
339 const bool multieditLinkedChildSelected = !selectedChildFeatureIds().isEmpty();
341 canAddGeometry =
false;
343 canRemove = canRemove && multieditLinkedChildSelected;
347 canUnlink = canUnlink && multieditLinkedChildSelected;
351 canRemove = canRemove && selectionNotEmpty;
352 canUnlink = canUnlink && selectionNotEmpty;
355 mToggleEditingButton->setEnabled( toggleEditingButtonEnabled );
356 mAddFeatureButton->setEnabled( canAdd );
357 mAddFeatureGeometryButton->setEnabled( canAddGeometry );
358 mDuplicateFeatureButton->setEnabled( canEdit && selectionNotEmpty );
359 mLinkFeatureButton->setEnabled( canLink );
360 mDeleteFeatureButton->setEnabled( canRemove );
361 mUnlinkFeatureButton->setEnabled( canUnlink );
362 mZoomToFeatureButton->setEnabled( selectionNotEmpty );
363 mToggleEditingButton->setChecked( canEdit );
364 mSaveEditsButton->setEnabled( canEdit || canLink || canUnlink );
378void QgsRelationEditorWidget::addFeature()
385 mMultiEditTreeWidget->blockSignals(
true );
386 mMultiEdit1NJustAddedIds = addedFeatures;
387 QTreeWidgetItemIterator treeWidgetItemIterator( mMultiEditTreeWidget );
388 while ( *treeWidgetItemIterator )
390 if ( ( *treeWidgetItemIterator )->data( 0,
static_cast<int>( MultiEditTreeWidgetRole::FeatureType ) ).toInt() !=
static_cast<int>( MultiEditFeatureType::Child ) )
392 ++treeWidgetItemIterator;
396 if ( addedFeatures.contains( ( *treeWidgetItemIterator )->data( 0,
static_cast<int>( MultiEditTreeWidgetRole::FeatureId ) ).toInt() ) )
397 ( *treeWidgetItemIterator )->setSelected(
true );
399 ++treeWidgetItemIterator;
401 mMultiEditTreeWidget->blockSignals(
false );
407void QgsRelationEditorWidget::addFeatureGeometry()
411 QgsLogger::warning( tr(
"Adding a geometry feature is not supported in multiple edit mode" ) );
421 mMapToolDigitize->
setLayer( layer );
424 if ( window()->objectName() != QLatin1String(
"QgisApp" ) )
426 window()->setVisible(
false );
428 setMapTool( mMapToolDigitize );
439 const QString msg = tr(
"Digitize the geometry for the new feature on layer %1. Press <ESC> to cancel." )
440 .arg( layer->
name() );
442 lMainMessageBar->pushItem( mMessageBarItem );
446void QgsRelationEditorWidget::onDigitizingCompleted(
const QgsFeature &feature )
449 digitizingFinished();
452void QgsRelationEditorWidget::multiEditItemSelectionChanged()
454 const QList<QTreeWidgetItem *> selectedItems = mMultiEditTreeWidget->selectedItems();
458 if ( selectedItems.size() == 1
459 && mMultiEditPreviousSelectedItems.size() <= 1 )
461 if ( selectedItems.first()->data( 0,
static_cast<int>( MultiEditTreeWidgetRole::FeatureType ) ).toInt() ==
static_cast<int>( MultiEditFeatureType::Child ) )
463 mMultiEditTreeWidget->blockSignals(
true );
465 const QgsFeatureId featureIdSelectedItem = selectedItems.first()->data( 0,
static_cast<int>( MultiEditTreeWidgetRole::FeatureId ) ).toInt();
467 QTreeWidgetItemIterator treeWidgetItemIterator( mMultiEditTreeWidget );
468 while ( *treeWidgetItemIterator )
470 if ( ( *treeWidgetItemIterator )->data( 0,
static_cast<int>( MultiEditTreeWidgetRole::FeatureType ) ).toInt() !=
static_cast<int>( MultiEditFeatureType::Child ) )
472 ++treeWidgetItemIterator;
476 const QgsFeatureId featureIdCurrentItem = ( *treeWidgetItemIterator )->data( 0,
static_cast<int>( MultiEditTreeWidgetRole::FeatureId ) ).toInt();
479 if ( featureIdSelectedItem == featureIdCurrentItem )
480 ( *treeWidgetItemIterator )->setSelected(
true );
484 if ( !mMultiEdit1NJustAddedIds.contains( featureIdSelectedItem ) )
487 if ( mMultiEdit1NJustAddedIds.contains( featureIdCurrentItem ) )
488 ( *treeWidgetItemIterator )->setSelected(
true );
491 ++treeWidgetItemIterator;
493 mMultiEditTreeWidget->blockSignals(
false );
496 mMultiEditPreviousSelectedItems = selectedItems;
500void QgsRelationEditorWidget::linkFeature()
505void QgsRelationEditorWidget::toggleEditing(
bool state )
523 updateUiSingleEdit();
528 mButtonsVisibility = buttons;
535 if ( mLinkFeatureButton->isVisible() )
537 if ( mUnlinkFeatureButton->isVisible() )
539 if ( mSaveEditsButton->isVisible() )
541 if ( mAddFeatureButton->isVisible() )
543 if ( mDuplicateFeatureButton->isVisible() )
545 if ( mDeleteFeatureButton->isVisible() )
547 if ( mZoomToFeatureButton->isVisible() )
561 QAction *qAction =
nullptr;
566 connect( qAction, &QAction::triggered,
this, [
this, fid]() {
deleteFeature( fid ); } );
572 connect( qAction, &QAction::triggered,
this, [
this, fid]() {
unlinkFeature( fid ); } );
577void QgsRelationEditorWidget::setMapTool(
QgsMapTool *mapTool )
582 mapCanvas->window()->raise();
583 mapCanvas->activateWindow();
584 mapCanvas->setFocus();
588void QgsRelationEditorWidget::unsetMapTool()
598QgsFeatureIds QgsRelationEditorWidget::selectedChildFeatureIds()
const
603 for ( QTreeWidgetItem *treeWidgetItem : mMultiEditTreeWidget->selectedItems() )
605 if (
static_cast<MultiEditFeatureType
>( treeWidgetItem->data( 0,
static_cast<int>( MultiEditTreeWidgetRole::FeatureType ) ).toInt() ) != MultiEditFeatureType::Child )
608 featureIds.insert( treeWidgetItem->data( 0,
static_cast<int>( MultiEditTreeWidgetRole::FeatureId ) ).toLongLong() );
616void QgsRelationEditorWidget::updateUiSingleEdit()
618 mFormViewButton->setVisible(
true );
619 mTableViewButton->setVisible(
true );
620 mMultiEditInfoLabel->setVisible(
false );
622 mStackedWidget->setCurrentWidget( mDualView );
637 filters << filter.prepend(
'(' ).append(
')' );
640 QString reducedExpression;
664 initDualView( layer, request );
668 mFeatureSelectionMgr =
new QgsFilteredSelectionManager( layer, request, mDualView );
679void QgsRelationEditorWidget::updateUiMultiEdit()
681 mFormViewButton->setVisible(
false );
682 mTableViewButton->setVisible(
false );
683 mMultiEditInfoLabel->setVisible(
true );
685 mStackedWidget->setCurrentWidget( mMultiEditStackedWidgetPage );
687 QList<QTreeWidgetItem *> parentTreeWidgetItems;
690 QMultiMap<QTreeWidgetItem *, QgsFeatureId> multimapChildFeatures;
692 mMultiEditTreeWidget->clear();
695 QTreeWidgetItem *treeWidgetItem = createMultiEditTreeWidgetItem( featureParent,
mRelation.
referencedLayer(), MultiEditFeatureType::Parent );
698 treeWidgetItem->setFlags( Qt::ItemIsEnabled );
700 parentTreeWidgetItems.append( treeWidgetItem );
706 while ( featureIterator.
nextFeature( featureChild ) )
713 while ( featureIteratorFinalChild.
nextFeature( featureChildChild ) )
715 QTreeWidgetItem *treeWidgetItemChild = createMultiEditTreeWidgetItem( featureChildChild,
mNmRelation.
referencedLayer(), MultiEditFeatureType::Child );
717 treeWidgetItem->addChild( treeWidgetItemChild );
719 featureIdsMixedValues.insert( featureChildChild.
id() );
720 multimapChildFeatures.insert( treeWidgetItem, featureChildChild.
id() );
725 QTreeWidgetItem *treeWidgetItemChild = createMultiEditTreeWidgetItem( featureChild,
mRelation.
referencingLayer(), MultiEditFeatureType::Child );
726 treeWidgetItem->addChild( treeWidgetItemChild );
728 featureIdsMixedValues.insert( featureChild.
id() );
732 mMultiEditTreeWidget->addTopLevelItem( treeWidgetItem );
733 treeWidgetItem->setExpanded(
true );
749 QgsFeatureIds::iterator iterator = featureIdsMixedValues.begin();
750 while ( iterator != featureIdsMixedValues.end() )
752 bool mixedValues =
false;
753 for ( QTreeWidgetItem *parentTreeWidgetItem : parentTreeWidgetItems )
755 if ( !multimapChildFeatures.values( parentTreeWidgetItem ).contains( *iterator ) )
764 iterator = featureIdsMixedValues.erase( iterator );
773 if ( featureIdsMixedValues.isEmpty() )
776 mMultiEditInfoLabel->setPixmap( icon.pixmap( mMultiEditInfoLabel->height(), mMultiEditInfoLabel->height() ) );
777 mMultiEditInfoLabel->setToolTip( tr(
"All features in selection have equal relations" ) );
782 mMultiEditInfoLabel->setPixmap( icon.pixmap( mMultiEditInfoLabel->height(), mMultiEditInfoLabel->height() ) );
783 mMultiEditInfoLabel->setToolTip( tr(
"Some features in selection have different relations" ) );
786 QFont fontItalic = mMultiEditTreeWidget->font();
787 fontItalic.setItalic(
true );
788 for ( QTreeWidgetItem *parentTreeWidgetItem : parentTreeWidgetItems )
790 for (
int childIndex = 0; childIndex < parentTreeWidgetItem->childCount(); ++childIndex )
792 QTreeWidgetItem *childItem = parentTreeWidgetItem->child( childIndex );
793 const QgsFeatureId featureIdCurrentItem = childItem->data( 0,
static_cast<int>( MultiEditTreeWidgetRole::FeatureId ) ).toInt();
794 if ( featureIdsMixedValues.contains( featureIdCurrentItem ) )
795 childItem->setFont( 0, fontItalic );
801QTreeWidgetItem *QgsRelationEditorWidget::createMultiEditTreeWidgetItem(
const QgsFeature &feature,
QgsVectorLayer *layer, MultiEditFeatureType type )
803 QTreeWidgetItem *treeWidgetItem =
new QTreeWidgetItem();
806 treeWidgetItem->setData( 0,
static_cast<int>( MultiEditTreeWidgetRole::FeatureType ),
static_cast<int>( type ) );
807 treeWidgetItem->setData( 0,
static_cast<int>( MultiEditTreeWidgetRole::FeatureId ),
feature.
id() );
808 return treeWidgetItem;
811void QgsRelationEditorWidget::onDigitizingCanceled()
813 digitizingFinished();
816void QgsRelationEditorWidget::digitizingFinished()
818 window()->setVisible(
true );
820 window()->activateWindow();
824void QgsRelationEditorWidget::mapToolDeactivated()
830 mMessageBarItem =
nullptr;
835 return QVariantMap( { {
"buttons",
qgsFlagValueToKeys(
visibleButtons() ) }, {
"show_first_feature", mShowFirstFeature }, {
"allow_add_child_feature_with_no_geometry", mAllowAddChildFeatureWithNoGeometry }, {
"filter_expression", mFilterExpression } } );
841 mShowFirstFeature =
config.value( QStringLiteral(
"show_first_feature" ),
true ).toBool();
842 mAllowAddChildFeatureWithNoGeometry =
config.value( QStringLiteral(
"allow_add_child_feature_with_no_geometry" ),
false ).toBool();
843 mFilterExpression =
config.value( QStringLiteral(
"filter_expression" ) ).toString();
849 Q_UNUSED( newRelation );
850 Q_UNUSED( newFeature );
879 Q_UNUSED( newRelation );
880 Q_UNUSED( newNmRelation );
914 return mFeatureSelectionMgr;
919 const QgsFeatureIds selectedFids = selectedChildFeatureIds();
935 const QgsFeatureIds selectedFids = selectedChildFeatureIds();
961 filterExpressionLabel->setEnabled( mRelationShowLinkCheckBox->isChecked() );
962 mEditExpression->setEnabled( mRelationShowLinkCheckBox->isChecked() );
963 mFilterExpression->setEnabled( mRelationShowLinkCheckBox->isChecked() );
964 connect( mRelationShowLinkCheckBox, &QCheckBox::toggled, filterExpressionLabel, &QLabel::setEnabled );
965 connect( mRelationShowLinkCheckBox, &QCheckBox::toggled, mEditExpression, &QToolButton::setEnabled );
966 connect( mRelationShowLinkCheckBox, &QCheckBox::toggled, mFilterExpression, &QTextEdit::setEnabled );
969 mAllowAddChildFeatureWithNoGeometry->setEnabled( mRelationShowAddChildCheckBox->isChecked() );
970 connect( mRelationShowAddChildCheckBox, &QCheckBox::toggled, mAllowAddChildFeatureWithNoGeometry, &QCheckBox::setEnabled );
989 dlg.setWindowTitle( tr(
"Edit Filter Expression of Target Layer" ) );
991 if ( dlg.exec() == QDialog::Accepted )
1010 {
"show_first_feature", mShowFirstFeature->isChecked() },
1011 {
"allow_add_child_feature_with_no_geometry", mAllowAddChildFeatureWithNoGeometry->isChecked() },
1012 {
"filter_expression", mFilterExpression->toPlainText() }
1028 mShowFirstFeature->setChecked(
config.value( QStringLiteral(
"show_first_feature" ),
true ).toBool() );
1029 mAllowAddChildFeatureWithNoGeometry->setChecked(
config.value( QStringLiteral(
"allow_add_child_feature_with_no_geometry" ),
false ).toBool() );
1030 mFilterExpression->setPlainText(
config.value( QStringLiteral(
"filter_expression" ) ).toString() );
1044 return QStringLiteral(
"relation_editor" );
1049 return QObject::tr(
"Relation Editor" );
void reset(T *p=nullptr)
Will reset the managed pointer to p.
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
This class contains context information for attribute editor widgets.
QgsMapCanvas * mapCanvas() const
Returns the associated map canvas (e.g.
QgsAdvancedDigitizingDockWidget * cadDockWidget() const
Returns the associated CAD dock widget (e.g.
void setParentFormFeature(const QgsFeature &feature)
Sets the feature of the currently edited parent form.
QgsMessageBar * mainMessageBar()
Returns the main message bar.
QgsVectorLayer * layer() const
Returns the layer this model uses as backend.
virtual void loadLayer()
Loads the layer into the model Preferably to be called, before using this model as source for any oth...
This widget is used to show the attributes of a set of features of a QgsVectorLayer.
void showContextMenuExternally(QgsActionMenu *menu, QgsFeatureId fid)
Emitted when selecting context menu on the feature list to create the context menu individually.
ViewMode
The view modes, in which this widget can present information.
@ AttributeTable
Shows the features and attributes in a table layout.
@ AttributeEditor
Show a list of the features, where one can be chosen and the according attribute dialog will be prese...
void setFeatureSelectionManager(QgsIFeatureSelectionManager *featureSelectionManager)
Set the feature selection model.
void init(QgsVectorLayer *layer, QgsMapCanvas *mapCanvas, const QgsFeatureRequest &request=QgsFeatureRequest(), const QgsAttributeEditorContext &context=QgsAttributeEditorContext(), bool loadFeatures=true, bool showFirstFeature=true)
Has to be called to initialize the dual view.
void setRequest(const QgsFeatureRequest &request)
Set the request.
void parentFormValueChanged(const QString &attribute, const QVariant &value)
Called in embedded forms when an attribute value in the parent form has changed.
QgsAttributeTableModel * masterModel() const
Returns the model which has the information about all features (not only filtered)
void setView(ViewMode view)
Change the current view mode.
A generic dialog for building expression strings.
QgsExpressionBuilderWidget * expressionBuilder()
The builder widget that is used by the dialog.
static QList< QgsExpressionContextScope * > globalProjectLayerScopes(const QgsMapLayer *layer)
Creates a list of three scopes: global, layer's project and layer.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
QString expression() const
Returns the original, unmodified expression string.
static bool attemptReduceToInClause(const QStringList &expressions, QString &result)
Attempts to reduce a list of expressions to a single "field IN (val1, val2, ... )" type expression.
Wrapper for iterator of features from vector data provider or vector layer.
bool nextFeature(QgsFeature &f)
Fetch next feature and stores in f, returns true on success.
This class wraps a request for features to a vector layer (or directly its vector data provider).
QgsExpression * filterExpression() const
Returns the filter expression (if set).
QgsFeatureRequest & setFilterExpression(const QString &expression)
Set the filter expression.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Is an interface class to abstract feature selection handling.
void selectionChanged(const QgsFeatureIds &selected, const QgsFeatureIds &deselected, bool clearAndSelect)
Emitted when selection was changed.
static QIcon iconForLayer(const QgsMapLayer *layer)
Returns the icon corresponding to a specified map layer.
static void warning(const QString &msg)
Goes to qWarning.
Map canvas is a class for displaying all GIS data types on a canvas.
void unsetMapTool(QgsMapTool *mapTool)
Unset the current map tool or last non zoom tool.
void setMapTool(QgsMapTool *mapTool, bool clean=false)
Sets the map tool currently being used on the canvas.
void zoomToFeatureIds(QgsVectorLayer *layer, const QgsFeatureIds &ids)
Set canvas extent to the bounding box of a set of features.
void editingStopped()
Emitted when edited changes have been successfully written to the data provider.
void editingStarted()
Emitted when editing on this layer has started.
bool popWidget(QgsMessageBarItem *item)
Remove the specified item from the bar, and display the next most recent one in the stack.
static QgsMessageBarItem * createMessage(const QString &text, QWidget *parent=nullptr)
Creates message bar item widget containing a message text to be displayed on the bar.
Represents a relationship between two vector layers.
QgsFeatureRequest getReferencedFeatureRequest(const QgsAttributes &attributes) const
Creates a request to return the feature on the referenced (parent) layer which is referenced by the p...
QgsVectorLayer * referencedLayer
QgsVectorLayer * referencingLayer
QgsFeatureRequest getRelatedFeaturesRequest(const QgsFeature &feature) const
Creates a request to return all the features on the referencing (child) layer which have a foreign ke...
int selectedFeatureCount() override
Returns the number of features that are selected in this layer.
const QgsFeatureIds & selectedFeatureIds() const override
Returns reference to identifiers of selected features.
static QString getFeatureDisplayString(const QgsVectorLayer *layer, const QgsFeature &feature)
Represents a vector layer which manages a vector based data sets.
bool isSpatial() const FINAL
Returns true if this is a geometry layer and false in case of NoGeometry (table only) or UnknownGeome...
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const FINAL
Queries the layer for features specified in request.
bool isEditable() const FINAL
Returns true if the provider is in editing mode.
Q_INVOKABLE Qgis::GeometryType geometryType() const
Returns point, line or polygon.
void selectionChanged(const QgsFeatureIds &selected, const QgsFeatureIds &deselected, bool clearAndSelect)
Emitted when selection was changed.
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
QString qgsFlagValueToKeys(const T &value, bool *returnOk=nullptr)
Returns the value for the given keys of a flag.
T qgsFlagKeysToValue(const QString &keys, const T &defaultValue, bool tryValueAsKey=true, bool *returnOk=nullptr)
Returns the value corresponding to the given keys of a flag.
QSet< QgsFeatureId > QgsFeatureIds
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features