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 );
225 connect( mViewModeButtonGroup, &QButtonGroup::idClicked,
227 connect( mToggleEditingButton, &QAbstractButton::clicked,
this, &QgsRelationEditorWidget::toggleEditing );
229 connect( mAddFeatureButton, &QAbstractButton::clicked,
this, &QgsRelationEditorWidget::addFeature );
230 connect( mAddFeatureGeometryButton, &QAbstractButton::clicked,
this, &QgsRelationEditorWidget::addFeatureGeometry );
233 connect( mLinkFeatureButton, &QAbstractButton::clicked,
this, &QgsRelationEditorWidget::linkFeature );
236 connect( mMultiEditTreeWidget, &QTreeWidget::itemSelectionChanged,
this, &QgsRelationEditorWidget::multiEditItemSelectionChanged );
241 setLayout( rootLayout );
255 mFeatureSelectionMgr =
new QgsFilteredSelectionManager( layer, request, mDualView );
265 text = tr(
"Add Point Child Feature" );
270 text = tr(
"Add Line Child Feature" );
275 text = tr(
"Add Polygon Child Feature" );
278 mAddFeatureGeometryButton->setIcon( icon );
279 mAddFeatureGeometryButton->setText( text );
280 mAddFeatureGeometryButton->setToolTip( text );
292 mMapToolDigitize->
setButton( mAddFeatureGeometryButton );
304void QgsRelationEditorWidget::updateButtons()
306 bool toggleEditingButtonEnabled =
false;
308 bool canAddGeometry =
false;
309 bool canRemove =
false;
310 bool canEdit =
false;
311 bool canLink =
false;
312 bool canUnlink =
false;
313 bool spatial =
false;
337 const bool selectionNotEmpty = mFeatureSelectionMgr ? mFeatureSelectionMgr->
selectedFeatureCount() :
false;
340 const bool multieditLinkedChildSelected = ! selectedChildFeatureIds().isEmpty();
342 canAddGeometry =
false;
344 canRemove = canRemove && multieditLinkedChildSelected;
348 canUnlink = canUnlink && multieditLinkedChildSelected;
352 canRemove = canRemove && selectionNotEmpty;
353 canUnlink = canUnlink && selectionNotEmpty;
356 mToggleEditingButton->setEnabled( toggleEditingButtonEnabled );
357 mAddFeatureButton->setEnabled( canAdd );
358 mAddFeatureGeometryButton->setEnabled( canAddGeometry );
359 mDuplicateFeatureButton->setEnabled( canEdit && selectionNotEmpty );
360 mLinkFeatureButton->setEnabled( canLink );
361 mDeleteFeatureButton->setEnabled( canRemove );
362 mUnlinkFeatureButton->setEnabled( canUnlink );
363 mZoomToFeatureButton->setEnabled( selectionNotEmpty );
364 mToggleEditingButton->setChecked( canEdit );
365 mSaveEditsButton->setEnabled( canEdit || canLink || canUnlink );
379void QgsRelationEditorWidget::addFeature()
386 mMultiEditTreeWidget->blockSignals(
true );
387 mMultiEdit1NJustAddedIds = addedFeatures;
388 QTreeWidgetItemIterator treeWidgetItemIterator( mMultiEditTreeWidget );
389 while ( *treeWidgetItemIterator )
391 if ( ( *treeWidgetItemIterator )->data( 0,
static_cast<int>( MultiEditTreeWidgetRole::FeatureType ) ).toInt() !=
static_cast<int>( MultiEditFeatureType::Child ) )
393 ++treeWidgetItemIterator;
397 if ( addedFeatures.contains( ( *treeWidgetItemIterator )->data( 0,
static_cast<int>( MultiEditTreeWidgetRole::FeatureId ) ).toInt() ) )
398 ( *treeWidgetItemIterator )->setSelected(
true );
400 ++treeWidgetItemIterator;
402 mMultiEditTreeWidget->blockSignals(
false );
408void QgsRelationEditorWidget::addFeatureGeometry()
412 QgsLogger::warning( tr(
"Adding a geometry feature is not supported in multiple edit mode" ) );
422 mMapToolDigitize->
setLayer( layer );
425 if ( window()->objectName() != QLatin1String(
"QgisApp" ) )
427 window()->setVisible(
false );
429 setMapTool( mMapToolDigitize );
440 const QString msg = tr(
"Digitize the geometry for the new feature on layer %1. Press <ESC> to cancel." )
441 .arg( layer->
name() );
443 lMainMessageBar->pushItem( mMessageBarItem );
447void QgsRelationEditorWidget::onDigitizingCompleted(
const QgsFeature &feature )
450 digitizingFinished();
453void QgsRelationEditorWidget::multiEditItemSelectionChanged()
455 const QList<QTreeWidgetItem *> selectedItems = mMultiEditTreeWidget->selectedItems();
459 if ( selectedItems.size() == 1
460 && mMultiEditPreviousSelectedItems.size() <= 1 )
462 if ( selectedItems.first()->data( 0,
static_cast<int>( MultiEditTreeWidgetRole::FeatureType ) ).toInt() ==
static_cast<int>( MultiEditFeatureType::Child ) )
464 mMultiEditTreeWidget->blockSignals(
true );
466 const QgsFeatureId featureIdSelectedItem = selectedItems.first()->data( 0,
static_cast<int>( MultiEditTreeWidgetRole::FeatureId ) ).toInt();
468 QTreeWidgetItemIterator treeWidgetItemIterator( mMultiEditTreeWidget );
469 while ( *treeWidgetItemIterator )
471 if ( ( *treeWidgetItemIterator )->data( 0,
static_cast<int>( MultiEditTreeWidgetRole::FeatureType ) ).toInt() !=
static_cast<int>( MultiEditFeatureType::Child ) )
473 ++treeWidgetItemIterator;
477 const QgsFeatureId featureIdCurrentItem = ( *treeWidgetItemIterator )->data( 0,
static_cast<int>( MultiEditTreeWidgetRole::FeatureId ) ).toInt();
480 if ( featureIdSelectedItem == featureIdCurrentItem )
481 ( *treeWidgetItemIterator )->setSelected(
true );
485 if ( ! mMultiEdit1NJustAddedIds.contains( featureIdSelectedItem ) )
488 if ( mMultiEdit1NJustAddedIds.contains( featureIdCurrentItem ) )
489 ( *treeWidgetItemIterator )->setSelected(
true );
492 ++treeWidgetItemIterator;
494 mMultiEditTreeWidget->blockSignals(
false );
497 mMultiEditPreviousSelectedItems = selectedItems;
501void QgsRelationEditorWidget::linkFeature()
506void QgsRelationEditorWidget::toggleEditing(
bool state )
524 updateUiSingleEdit();
529 mButtonsVisibility = buttons;
536 if ( mLinkFeatureButton->isVisible() )
538 if ( mUnlinkFeatureButton->isVisible() )
540 if ( mSaveEditsButton->isVisible() )
542 if ( mAddFeatureButton->isVisible() )
544 if ( mDuplicateFeatureButton->isVisible() )
546 if ( mDeleteFeatureButton->isVisible() )
548 if ( mZoomToFeatureButton->isVisible() )
562 QAction *qAction =
nullptr;
567 connect( qAction, &QAction::triggered,
this, [
this, fid]() {
deleteFeature( fid ); } );
573 connect( qAction, &QAction::triggered,
this, [
this, fid]() {
unlinkFeature( fid ); } );
578void QgsRelationEditorWidget::setMapTool(
QgsMapTool *mapTool )
583 mapCanvas->window()->raise();
584 mapCanvas->activateWindow();
585 mapCanvas->setFocus();
589void QgsRelationEditorWidget::unsetMapTool()
599QgsFeatureIds QgsRelationEditorWidget::selectedChildFeatureIds()
const
604 for ( QTreeWidgetItem *treeWidgetItem : mMultiEditTreeWidget->selectedItems() )
606 if (
static_cast<MultiEditFeatureType
>( treeWidgetItem->data( 0,
static_cast<int>( MultiEditTreeWidgetRole::FeatureType ) ).toInt() ) != MultiEditFeatureType::Child )
609 featureIds.insert( treeWidgetItem->data( 0,
static_cast<int>( MultiEditTreeWidgetRole::FeatureId ) ).toLongLong() );
617void QgsRelationEditorWidget::updateUiSingleEdit()
619 mFormViewButton->setVisible(
true );
620 mTableViewButton->setVisible(
true );
621 mMultiEditInfoLabel->setVisible(
false );
623 mStackedWidget->setCurrentWidget( mDualView );
638 filters << filter.prepend(
'(' ).append(
')' );
641 QString reducedExpression;
665 initDualView( layer, request );
669 mFeatureSelectionMgr =
new QgsFilteredSelectionManager( layer, request, mDualView );
681void QgsRelationEditorWidget::updateUiMultiEdit()
683 mFormViewButton->setVisible(
false );
684 mTableViewButton->setVisible(
false );
685 mMultiEditInfoLabel->setVisible(
true );
687 mStackedWidget->setCurrentWidget( mMultiEditStackedWidgetPage ) ;
689 QList<QTreeWidgetItem *> parentTreeWidgetItems;
692 QMultiMap<QTreeWidgetItem *, QgsFeatureId> multimapChildFeatures;
694 mMultiEditTreeWidget->clear();
697 QTreeWidgetItem *treeWidgetItem = createMultiEditTreeWidgetItem( featureParent,
mRelation.
referencedLayer(), MultiEditFeatureType::Parent );
700 treeWidgetItem->setFlags( Qt::ItemIsEnabled );
702 parentTreeWidgetItems.append( treeWidgetItem );
708 while ( featureIterator.
nextFeature( featureChild ) )
715 while ( featureIteratorFinalChild.
nextFeature( featureChildChild ) )
717 QTreeWidgetItem *treeWidgetItemChild = createMultiEditTreeWidgetItem( featureChildChild,
mNmRelation.
referencedLayer(), MultiEditFeatureType::Child );
719 treeWidgetItem->addChild( treeWidgetItemChild );
721 featureIdsMixedValues.insert( featureChildChild.
id() );
722 multimapChildFeatures.insert( treeWidgetItem, featureChildChild.
id() );
727 QTreeWidgetItem *treeWidgetItemChild = createMultiEditTreeWidgetItem( featureChild,
mRelation.
referencingLayer(), MultiEditFeatureType::Child );
728 treeWidgetItem->addChild( treeWidgetItemChild );
730 featureIdsMixedValues.insert( featureChild.
id() );
734 mMultiEditTreeWidget->addTopLevelItem( treeWidgetItem );
735 treeWidgetItem->setExpanded(
true );
751 QgsFeatureIds::iterator iterator = featureIdsMixedValues.begin();
752 while ( iterator != featureIdsMixedValues.end() )
754 bool mixedValues =
false;
755 for ( QTreeWidgetItem *parentTreeWidgetItem : parentTreeWidgetItems )
757 if ( ! multimapChildFeatures.values( parentTreeWidgetItem ).contains( *iterator ) )
766 iterator = featureIdsMixedValues.erase( iterator );
775 if ( featureIdsMixedValues.isEmpty() )
778 mMultiEditInfoLabel->setPixmap( icon.pixmap( mMultiEditInfoLabel->height(),
779 mMultiEditInfoLabel->height() ) );
780 mMultiEditInfoLabel->setToolTip( tr(
"All features in selection have equal relations" ) );
785 mMultiEditInfoLabel->setPixmap( icon.pixmap( mMultiEditInfoLabel->height(),
786 mMultiEditInfoLabel->height() ) );
787 mMultiEditInfoLabel->setToolTip( tr(
"Some features in selection have different relations" ) );
790 QFont fontItalic = mMultiEditTreeWidget->font();
791 fontItalic.setItalic(
true );
792 for ( QTreeWidgetItem *parentTreeWidgetItem : parentTreeWidgetItems )
794 for (
int childIndex = 0; childIndex < parentTreeWidgetItem->childCount(); ++childIndex )
796 QTreeWidgetItem *childItem = parentTreeWidgetItem->child( childIndex );
797 const QgsFeatureId featureIdCurrentItem = childItem->data( 0,
static_cast<int>( MultiEditTreeWidgetRole::FeatureId ) ).toInt();
798 if ( featureIdsMixedValues.contains( featureIdCurrentItem ) )
799 childItem->setFont( 0, fontItalic );
805QTreeWidgetItem *QgsRelationEditorWidget::createMultiEditTreeWidgetItem(
const QgsFeature &feature,
QgsVectorLayer *layer, MultiEditFeatureType type )
807 QTreeWidgetItem *treeWidgetItem =
new QTreeWidgetItem();
810 treeWidgetItem->setData( 0,
static_cast<int>( MultiEditTreeWidgetRole::FeatureType ),
static_cast<int>( type ) );
811 treeWidgetItem->setData( 0,
static_cast<int>( MultiEditTreeWidgetRole::FeatureId ),
feature.
id() );
812 return treeWidgetItem;
815void QgsRelationEditorWidget::onDigitizingCanceled( )
817 digitizingFinished();
820void QgsRelationEditorWidget::digitizingFinished( )
822 window()->setVisible(
true );
824 window()->activateWindow();
828void QgsRelationEditorWidget::mapToolDeactivated()
834 mMessageBarItem =
nullptr;
840 {
"show_first_feature", mShowFirstFeature},
841 {
"allow_add_child_feature_with_no_geometry", mAllowAddChildFeatureWithNoGeometry },
842 {
"filter_expression", mFilterExpression }
849 mShowFirstFeature =
config.value( QStringLiteral(
"show_first_feature" ),
true ).toBool();
850 mAllowAddChildFeatureWithNoGeometry =
config.value( QStringLiteral(
"allow_add_child_feature_with_no_geometry" ),
false ).toBool();
851 mFilterExpression =
config.value( QStringLiteral(
"filter_expression" ) ).toString();
857 Q_UNUSED( newRelation );
858 Q_UNUSED( newFeature );
887 Q_UNUSED( newRelation );
888 Q_UNUSED( newNmRelation );
922 return mFeatureSelectionMgr;
927 const QgsFeatureIds selectedFids = selectedChildFeatureIds();
943 const QgsFeatureIds selectedFids = selectedChildFeatureIds();
969 filterExpressionLabel->setEnabled( mRelationShowLinkCheckBox->isChecked() );
970 mEditExpression->setEnabled( mRelationShowLinkCheckBox->isChecked() );
971 mFilterExpression->setEnabled( mRelationShowLinkCheckBox->isChecked() );
972 connect( mRelationShowLinkCheckBox, &QCheckBox::toggled, filterExpressionLabel, &QLabel::setEnabled );
973 connect( mRelationShowLinkCheckBox, &QCheckBox::toggled, mEditExpression, &QToolButton::setEnabled );
974 connect( mRelationShowLinkCheckBox, &QCheckBox::toggled, mFilterExpression, &QTextEdit::setEnabled );
977 mAllowAddChildFeatureWithNoGeometry->setEnabled( mRelationShowAddChildCheckBox->isChecked() );
978 connect( mRelationShowAddChildCheckBox, &QCheckBox::toggled, mAllowAddChildFeatureWithNoGeometry, &QCheckBox::setEnabled );
997 dlg.setWindowTitle( tr(
"Edit Filter Expression of Target Layer" ) );
999 if ( dlg.exec() == QDialog::Accepted )
1019 {
"show_first_feature", mShowFirstFeature->isChecked()},
1020 {
"allow_add_child_feature_with_no_geometry", mAllowAddChildFeatureWithNoGeometry->isChecked()},
1021 {
"filter_expression", mFilterExpression->toPlainText()}
1036 mShowFirstFeature->setChecked(
config.value( QStringLiteral(
"show_first_feature" ),
true ).toBool() );
1037 mAllowAddChildFeatureWithNoGeometry->setChecked(
config.value( QStringLiteral(
"allow_add_child_feature_with_no_geometry" ),
false ).toBool() );
1038 mFilterExpression->setPlainText(
config.value( QStringLiteral(
"filter_expression" ) ).toString() );
1053 return QStringLiteral(
"relation_editor" );
1058 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