57 if ( mRequest.acceptFeature( layer->
getFeature( fid ) ) )
58 mSelectedFeatureIds << fid;
63const QgsFeatureIds &QgsFilteredSelectionManager::selectedFeatureIds()
const
67 return mSelectedFeatureIds;
70int QgsFilteredSelectionManager::selectedFeatureCount()
72 return mSelectedFeatureIds.count();
75void QgsFilteredSelectionManager::onSelectionChanged(
const QgsFeatureIds &selected,
const QgsFeatureIds &deselected,
bool clearAndSelect )
80 mSelectedFeatureIds.clear();
84 for (
const auto fid : deselected )
85 mSelectedFeatureIds.remove( fid );
88 for (
const auto fid : selected )
89 if ( mRequest.acceptFeature( layer()->getFeature( fid ) ) )
90 mSelectedFeatureIds << fid;
92 lselected.remove( fid );
94 emit selectionChanged( lselected, deselected, clearAndSelect );
102 , mShowFirstFeature( config.value( QStringLiteral(
"show_first_feature" ), true ).toBool() )
103 , mAllowAddChildFeatureWithNoGeometry( config.value( QStringLiteral(
"allow_add_child_feature_with_no_geometry" ), false ).toBool() )
105 QVBoxLayout *rootLayout =
new QVBoxLayout(
this );
106 rootLayout->setContentsMargins( 0, 9, 0, 0 );
109 QHBoxLayout *buttonLayout =
new QHBoxLayout();
110 buttonLayout->setContentsMargins( 0, 0, 0, 0 );
112 mToggleEditingButton =
new QToolButton(
this );
113 mToggleEditingButton->setObjectName( QStringLiteral(
"mToggleEditingButton" ) );
115 mToggleEditingButton->setText( tr(
"Toggle Editing" ) );
116 mToggleEditingButton->setEnabled(
false );
117 mToggleEditingButton->setCheckable(
true );
118 mToggleEditingButton->setToolTip( tr(
"Toggle editing mode for child layer" ) );
119 buttonLayout->addWidget( mToggleEditingButton );
121 mSaveEditsButton =
new QToolButton(
this );
123 mSaveEditsButton->setText( tr(
"Save Child Layer Edits" ) );
124 mSaveEditsButton->setToolTip( tr(
"Save child layer edits" ) );
125 mSaveEditsButton->setEnabled(
true );
126 buttonLayout->addWidget( mSaveEditsButton );
128 mAddFeatureGeometryButton =
new QToolButton(
this );
129 mAddFeatureGeometryButton->setObjectName( QStringLiteral(
"mAddFeatureGeometryButton" ) );
130 buttonLayout->addWidget( mAddFeatureGeometryButton );
132 mAddFeatureButton =
new QToolButton(
this );
134 mAddFeatureButton->setText( tr(
"Add Child Feature" ) );
135 mAddFeatureButton->setToolTip( tr(
"Add child feature" ) );
136 mAddFeatureButton->setObjectName( QStringLiteral(
"mAddFeatureButton" ) );
137 buttonLayout->addWidget( mAddFeatureButton );
139 mDuplicateFeatureButton =
new QToolButton(
this );
141 mDuplicateFeatureButton->setText( tr(
"Duplicate Child Feature(s)" ) );
142 mDuplicateFeatureButton->setToolTip( tr(
"Duplicate selected child feature(s)" ) );
143 mDuplicateFeatureButton->setObjectName( QStringLiteral(
"mDuplicateFeatureButton" ) );
144 buttonLayout->addWidget( mDuplicateFeatureButton );
146 mDeleteFeatureButton =
new QToolButton(
this );
148 mDeleteFeatureButton->setText( tr(
"Delete Child Feature(s)" ) );
149 mDeleteFeatureButton->setToolTip( tr(
"Delete selected child feature(s)" ) );
150 mDeleteFeatureButton->setObjectName( QStringLiteral(
"mDeleteFeatureButton" ) );
151 buttonLayout->addWidget( mDeleteFeatureButton );
153 mLinkFeatureButton =
new QToolButton(
this );
155 mLinkFeatureButton->setText( tr(
"Link Existing Feature(s)" ) );
156 mLinkFeatureButton->setToolTip( tr(
"Link existing child feature(s)" ) );
157 mLinkFeatureButton->setObjectName( QStringLiteral(
"mLinkFeatureButton" ) );
158 buttonLayout->addWidget( mLinkFeatureButton );
160 mUnlinkFeatureButton =
new QToolButton(
this );
162 mUnlinkFeatureButton->setText( tr(
"Unlink Feature(s)" ) );
163 mUnlinkFeatureButton->setToolTip( tr(
"Unlink selected child feature(s)" ) );
164 mUnlinkFeatureButton->setObjectName( QStringLiteral(
"mUnlinkFeatureButton" ) );
165 buttonLayout->addWidget( mUnlinkFeatureButton );
167 mZoomToFeatureButton =
new QToolButton(
this );
169 mZoomToFeatureButton->setText( tr(
"Zoom To Feature(s)" ) );
170 mZoomToFeatureButton->setToolTip( tr(
"Zoom to selected child feature(s)" ) );
171 mZoomToFeatureButton->setObjectName( QStringLiteral(
"mZoomToFeatureButton" ) );
172 buttonLayout->addWidget( mZoomToFeatureButton );
174 buttonLayout->addItem(
new QSpacerItem( 0, 0, QSizePolicy::Expanding ) );
176 mFormViewButton =
new QToolButton(
this );
177 mFormViewButton->setText( tr(
"Form View" ) );
178 mFormViewButton->setToolTip( tr(
"Switch to form view" ) );
180 mFormViewButton->setCheckable(
true );
182 buttonLayout->addWidget( mFormViewButton );
184 mTableViewButton =
new QToolButton(
this );
185 mTableViewButton->setText( tr(
"Table View" ) );
186 mTableViewButton->setToolTip( tr(
"Switch to table view" ) );
188 mTableViewButton->setCheckable(
true );
190 buttonLayout->addWidget( mTableViewButton );
192 mViewModeButtonGroup =
new QButtonGroup(
this );
196 mMultiEditInfoLabel =
new QLabel(
this );
197 buttonLayout->addWidget( mMultiEditInfoLabel );
200 rootLayout->addLayout( buttonLayout );
203 mStackedWidget =
new QStackedWidget(
this );
207 mDualView->
setView( mViewMode );
211 mMultiEditStackedWidgetPage =
new QWidget(
this );
213 QVBoxLayout *vBoxLayout =
new QVBoxLayout();
214 vBoxLayout->setContentsMargins( 0, 0, 0, 0 );
216 mMultiEditTreeWidget =
new QTreeWidget(
this );
217 mMultiEditTreeWidget->setHeaderHidden(
true );
218 mMultiEditTreeWidget->setSelectionMode( QTreeWidget::ExtendedSelection );
219 vBoxLayout->addWidget( mMultiEditTreeWidget );
221 mMultiEditStackedWidgetPage->setLayout( vBoxLayout );
223 mStackedWidget->addWidget( mMultiEditStackedWidgetPage );
225 mStackedWidget->addWidget( mDualView );
227 rootLayout->addWidget( mStackedWidget );
229#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
230 connect( mViewModeButtonGroup,
static_cast<void ( QButtonGroup::* )(
int )
>( &QButtonGroup::buttonClicked ),
233 connect( mViewModeButtonGroup, &QButtonGroup::idClicked,
236 connect( mToggleEditingButton, &QAbstractButton::clicked,
this, &QgsRelationEditorWidget::toggleEditing );
238 connect( mAddFeatureButton, &QAbstractButton::clicked,
this, &QgsRelationEditorWidget::addFeature );
239 connect( mAddFeatureGeometryButton, &QAbstractButton::clicked,
this, &QgsRelationEditorWidget::addFeatureGeometry );
245 connect( mMultiEditTreeWidget, &QTreeWidget::itemSelectionChanged,
this, &QgsRelationEditorWidget::multiEditItemSelectionChanged );
250 setLayout( rootLayout );
264 mFeatureSelectionMgr =
new QgsFilteredSelectionManager( layer, request, mDualView );
274 text = tr(
"Add Point Child Feature" );
279 text = tr(
"Add Line Child Feature" );
284 text = tr(
"Add Polygon Child Feature" );
287 mAddFeatureGeometryButton->setIcon( icon );
288 mAddFeatureGeometryButton->setText( text );
289 mAddFeatureGeometryButton->setToolTip( text );
301 mMapToolDigitize->
setButton( mAddFeatureGeometryButton );
313void QgsRelationEditorWidget::updateButtons()
315 bool toggleEditingButtonEnabled =
false;
317 bool canAddGeometry =
false;
318 bool canRemove =
false;
319 bool canEdit =
false;
320 bool canLink =
false;
321 bool canUnlink =
false;
322 bool spatial =
false;
346 const bool selectionNotEmpty = mFeatureSelectionMgr ? mFeatureSelectionMgr->
selectedFeatureCount() :
false;
349 const bool multieditLinkedChildSelected = ! selectedChildFeatureIds().isEmpty();
351 canAddGeometry =
false;
353 canRemove = canRemove && multieditLinkedChildSelected;
357 canUnlink = canUnlink && multieditLinkedChildSelected;
361 canRemove = canRemove && selectionNotEmpty;
362 canUnlink = canUnlink && selectionNotEmpty;
365 mToggleEditingButton->setEnabled( toggleEditingButtonEnabled );
366 mAddFeatureButton->setEnabled( canAdd );
367 mAddFeatureGeometryButton->setEnabled( canAddGeometry );
368 mDuplicateFeatureButton->setEnabled( canEdit && selectionNotEmpty );
369 mLinkFeatureButton->setEnabled( canLink );
370 mDeleteFeatureButton->setEnabled( canRemove );
371 mUnlinkFeatureButton->setEnabled( canUnlink );
372 mZoomToFeatureButton->setEnabled( selectionNotEmpty );
373 mToggleEditingButton->setChecked( canEdit );
374 mSaveEditsButton->setEnabled( canEdit || canLink || canUnlink );
378 mLinkFeatureButton->setVisible( mButtonsVisibility.testFlag( QgsRelationEditorWidget::Button::Link ) );
379 mUnlinkFeatureButton->setVisible( mButtonsVisibility.testFlag( QgsRelationEditorWidget::Button::Unlink ) );
380 mSaveEditsButton->setVisible( mButtonsVisibility.testFlag( QgsRelationEditorWidget::Button::SaveChildEdits ) && !
mLayerInSameTransactionGroup );
381 mAddFeatureButton->setVisible( mButtonsVisibility.testFlag( QgsRelationEditorWidget::Button::AddChildFeature ) && !( spatial && !mAllowAddChildFeatureWithNoGeometry ) );
383 mDuplicateFeatureButton->setVisible( mButtonsVisibility.testFlag( QgsRelationEditorWidget::Button::DuplicateChildFeature ) );
384 mDeleteFeatureButton->setVisible( mButtonsVisibility.testFlag( QgsRelationEditorWidget::Button::DeleteChildFeature ) );
385 mZoomToFeatureButton->setVisible( mButtonsVisibility.testFlag( QgsRelationEditorWidget::Button::ZoomToChildFeature ) &&
mEditorContext.
mapCanvas() && spatial );
388void QgsRelationEditorWidget::addFeature()
395 mMultiEditTreeWidget->blockSignals(
true );
396 mMultiEdit1NJustAddedIds = addedFeatures;
397 QTreeWidgetItemIterator treeWidgetItemIterator( mMultiEditTreeWidget );
398 while ( *treeWidgetItemIterator )
400 if ( ( *treeWidgetItemIterator )->data( 0,
static_cast<int>( MultiEditTreeWidgetRole::FeatureType ) ).toInt() !=
static_cast<int>( MultiEditFeatureType::Child ) )
402 ++treeWidgetItemIterator;
406 if ( addedFeatures.contains( ( *treeWidgetItemIterator )->data( 0,
static_cast<int>( MultiEditTreeWidgetRole::FeatureId ) ).toInt() ) )
407 ( *treeWidgetItemIterator )->setSelected(
true );
409 ++treeWidgetItemIterator;
411 mMultiEditTreeWidget->blockSignals(
false );
417void QgsRelationEditorWidget::addFeatureGeometry()
421 QgsLogger::warning( tr(
"Adding a geometry feature is not supported in multiple edit mode" ) );
431 mMapToolDigitize->
setLayer( layer );
434 if ( window()->objectName() != QLatin1String(
"QgisApp" ) )
436 window()->setVisible(
false );
438 setMapTool( mMapToolDigitize );
449 const QString msg = tr(
"Digitize the geometry for the new feature on layer %1. Press <ESC> to cancel." )
450 .arg( layer->
name() );
452 lMainMessageBar->pushItem( mMessageBarItem );
456void QgsRelationEditorWidget::onDigitizingCompleted(
const QgsFeature &feature )
459 digitizingFinished();
462void QgsRelationEditorWidget::multiEditItemSelectionChanged()
464 const QList<QTreeWidgetItem *> selectedItems = mMultiEditTreeWidget->selectedItems();
468 if ( selectedItems.size() == 1
469 && mMultiEditPreviousSelectedItems.size() <= 1 )
471 if ( selectedItems.first()->data( 0,
static_cast<int>( MultiEditTreeWidgetRole::FeatureType ) ).toInt() ==
static_cast<int>( MultiEditFeatureType::Child ) )
473 mMultiEditTreeWidget->blockSignals(
true );
475 const QgsFeatureId featureIdSelectedItem = selectedItems.first()->data( 0,
static_cast<int>( MultiEditTreeWidgetRole::FeatureId ) ).toInt();
477 QTreeWidgetItemIterator treeWidgetItemIterator( mMultiEditTreeWidget );
478 while ( *treeWidgetItemIterator )
480 if ( ( *treeWidgetItemIterator )->data( 0,
static_cast<int>( MultiEditTreeWidgetRole::FeatureType ) ).toInt() !=
static_cast<int>( MultiEditFeatureType::Child ) )
482 ++treeWidgetItemIterator;
486 const QgsFeatureId featureIdCurrentItem = ( *treeWidgetItemIterator )->data( 0,
static_cast<int>( MultiEditTreeWidgetRole::FeatureId ) ).toInt();
489 if ( featureIdSelectedItem == featureIdCurrentItem )
490 ( *treeWidgetItemIterator )->setSelected(
true );
494 if ( ! mMultiEdit1NJustAddedIds.contains( featureIdSelectedItem ) )
497 if ( mMultiEdit1NJustAddedIds.contains( featureIdCurrentItem ) )
498 ( *treeWidgetItemIterator )->setSelected(
true );
501 ++treeWidgetItemIterator;
503 mMultiEditTreeWidget->blockSignals(
false );
506 mMultiEditPreviousSelectedItems = selectedItems;
510void QgsRelationEditorWidget::toggleEditing(
bool state )
528 updateUiSingleEdit();
533 mButtonsVisibility = buttons;
540 if ( mLinkFeatureButton->isVisible() )
541 buttons |= Button::Link;
542 if ( mUnlinkFeatureButton->isVisible() )
543 buttons |= Button::Unlink;
544 if ( mSaveEditsButton->isVisible() )
545 buttons |= Button::SaveChildEdits;
546 if ( mAddFeatureButton->isVisible() )
547 buttons |= Button::AddChildFeature;
548 if ( mDuplicateFeatureButton->isVisible() )
549 buttons |= Button::DuplicateChildFeature;
550 if ( mDeleteFeatureButton->isVisible() )
551 buttons |= Button::DeleteChildFeature;
552 if ( mZoomToFeatureButton->isVisible() )
553 buttons |= Button::ZoomToChildFeature;
566 QAction *qAction =
nullptr;
568 if ( mButtonsVisibility.testFlag( QgsRelationEditorWidget::Button::DeleteChildFeature ) )
571 connect( qAction, &QAction::triggered,
this, [
this, fid]() {
deleteFeature( fid ); } );
574 if ( mButtonsVisibility.testFlag( QgsRelationEditorWidget::Button::Unlink ) )
577 connect( qAction, &QAction::triggered,
this, [
this, fid]() {
unlinkFeature( fid ); } );
582void QgsRelationEditorWidget::setMapTool(
QgsMapTool *mapTool )
587 mapCanvas->window()->raise();
588 mapCanvas->activateWindow();
589 mapCanvas->setFocus();
593void QgsRelationEditorWidget::unsetMapTool()
603QgsFeatureIds QgsRelationEditorWidget::selectedChildFeatureIds()
const
608 for ( QTreeWidgetItem *treeWidgetItem : mMultiEditTreeWidget->selectedItems() )
610 if (
static_cast<MultiEditFeatureType
>( treeWidgetItem->data( 0,
static_cast<int>( MultiEditTreeWidgetRole::FeatureType ) ).toInt() ) != MultiEditFeatureType::Child )
613 featureIds.insert( treeWidgetItem->data( 0,
static_cast<int>( MultiEditTreeWidgetRole::FeatureId ) ).toLongLong() );
621void QgsRelationEditorWidget::updateUiSingleEdit()
623 mFormViewButton->setVisible(
true );
624 mTableViewButton->setVisible(
true );
625 mMultiEditInfoLabel->setVisible(
false );
627 mStackedWidget->setCurrentWidget( mDualView );
640 filters << filter.prepend(
'(' ).append(
')' );
654void QgsRelationEditorWidget::updateUiMultiEdit()
656 mFormViewButton->setVisible(
false );
657 mTableViewButton->setVisible(
false );
658 mMultiEditInfoLabel->setVisible(
true );
660 mStackedWidget->setCurrentWidget( mMultiEditStackedWidgetPage ) ;
662 QList<QTreeWidgetItem *> parentTreeWidgetItems;
665 QMultiMap<QTreeWidgetItem *, QgsFeatureId> multimapChildFeatures;
667 mMultiEditTreeWidget->clear();
670 QTreeWidgetItem *treeWidgetItem = createMultiEditTreeWidgetItem( featureParent,
mRelation.
referencedLayer(), MultiEditFeatureType::Parent );
673 treeWidgetItem->setFlags( Qt::ItemIsEnabled );
675 parentTreeWidgetItems.append( treeWidgetItem );
681 while ( featureIterator.
nextFeature( featureChild ) )
688 while ( featureIteratorFinalChild.
nextFeature( featureChildChild ) )
690 QTreeWidgetItem *treeWidgetItemChild = createMultiEditTreeWidgetItem( featureChildChild,
mNmRelation.
referencedLayer(), MultiEditFeatureType::Child );
692 treeWidgetItem->addChild( treeWidgetItemChild );
694 featureIdsMixedValues.insert( featureChildChild.
id() );
695 multimapChildFeatures.insert( treeWidgetItem, featureChildChild.
id() );
700 QTreeWidgetItem *treeWidgetItemChild = createMultiEditTreeWidgetItem( featureChild,
mRelation.
referencingLayer(), MultiEditFeatureType::Child );
701 treeWidgetItem->addChild( treeWidgetItemChild );
703 featureIdsMixedValues.insert( featureChild.
id() );
707 mMultiEditTreeWidget->addTopLevelItem( treeWidgetItem );
708 treeWidgetItem->setExpanded(
true );
724 QgsFeatureIds::iterator iterator = featureIdsMixedValues.begin();
725 while ( iterator != featureIdsMixedValues.end() )
727 bool mixedValues =
false;
728 for ( QTreeWidgetItem *parentTreeWidgetItem : parentTreeWidgetItems )
730 if ( ! multimapChildFeatures.values( parentTreeWidgetItem ).contains( *iterator ) )
739 iterator = featureIdsMixedValues.erase( iterator );
748 if ( featureIdsMixedValues.isEmpty() )
751 mMultiEditInfoLabel->setPixmap( icon.pixmap( mMultiEditInfoLabel->height(),
752 mMultiEditInfoLabel->height() ) );
753 mMultiEditInfoLabel->setToolTip( tr(
"All features in selection have equal relations" ) );
758 mMultiEditInfoLabel->setPixmap( icon.pixmap( mMultiEditInfoLabel->height(),
759 mMultiEditInfoLabel->height() ) );
760 mMultiEditInfoLabel->setToolTip( tr(
"Some features in selection have different relations" ) );
763 QFont fontItalic = mMultiEditTreeWidget->font();
764 fontItalic.setItalic(
true );
765 for ( QTreeWidgetItem *parentTreeWidgetItem : parentTreeWidgetItems )
767 for (
int childIndex = 0; childIndex < parentTreeWidgetItem->childCount(); ++childIndex )
769 QTreeWidgetItem *childItem = parentTreeWidgetItem->child( childIndex );
770 const QgsFeatureId featureIdCurrentItem = childItem->data( 0,
static_cast<int>( MultiEditTreeWidgetRole::FeatureId ) ).toInt();
771 if ( featureIdsMixedValues.contains( featureIdCurrentItem ) )
772 childItem->setFont( 0, fontItalic );
778QTreeWidgetItem *QgsRelationEditorWidget::createMultiEditTreeWidgetItem(
const QgsFeature &feature,
QgsVectorLayer *layer, MultiEditFeatureType type )
780 QTreeWidgetItem *treeWidgetItem =
new QTreeWidgetItem();
783 treeWidgetItem->setData( 0,
static_cast<int>( MultiEditTreeWidgetRole::FeatureType ),
static_cast<int>( type ) );
784 treeWidgetItem->setData( 0,
static_cast<int>( MultiEditTreeWidgetRole::FeatureId ),
feature.
id() );
785 return treeWidgetItem;
788void QgsRelationEditorWidget::onDigitizingCanceled( )
790 digitizingFinished();
793void QgsRelationEditorWidget::digitizingFinished( )
795 window()->setVisible(
true );
797 window()->activateWindow();
801void QgsRelationEditorWidget::mapToolDeactivated()
807 mMessageBarItem =
nullptr;
813 {
"show_first_feature", mShowFirstFeature},
814 {
"allow_add_child_feature_with_no_geometry", mAllowAddChildFeatureWithNoGeometry }} );
819 mButtonsVisibility =
qgsFlagKeysToValue(
config.value( QStringLiteral(
"buttons" ) ).toString(), QgsRelationEditorWidget::Button::AllButtons );
820 mShowFirstFeature =
config.value( QStringLiteral(
"show_first_feature" ),
true ).toBool();
821 mAllowAddChildFeatureWithNoGeometry =
config.value( QStringLiteral(
"allow_add_child_feature_with_no_geometry" ),
false ).toBool();
827 Q_UNUSED( newRelation );
828 Q_UNUSED( newFeature );
857 Q_UNUSED( newRelation );
858 Q_UNUSED( newNmRelation );
892 return mFeatureSelectionMgr;
897 const QgsFeatureIds selectedFids = selectedChildFeatureIds();
913 const QgsFeatureIds selectedFids = selectedChildFeatureIds();
940 QgsRelationEditorWidget::Buttons buttons;
941 buttons.setFlag( QgsRelationEditorWidget::Button::Link, mRelationShowLinkCheckBox->isChecked() );
942 buttons.setFlag( QgsRelationEditorWidget::Button::Unlink, mRelationShowUnlinkCheckBox->isChecked() );
943 buttons.setFlag( QgsRelationEditorWidget::Button::AddChildFeature, mRelationShowAddChildCheckBox->isChecked() );
944 buttons.setFlag( QgsRelationEditorWidget::Button::DuplicateChildFeature, mRelationShowDuplicateChildFeatureCheckBox->isChecked() );
945 buttons.setFlag( QgsRelationEditorWidget::Button::ZoomToChildFeature, mRelationShowZoomToFeatureCheckBox->isChecked() );
946 buttons.setFlag( QgsRelationEditorWidget::Button::DeleteChildFeature, mRelationDeleteChildFeatureCheckBox->isChecked() );
947 buttons.setFlag( QgsRelationEditorWidget::Button::SaveChildEdits, mRelationShowSaveChildEditsCheckBox->isChecked() );
952 {
"show_first_feature", mShowFirstFeature->isChecked()},
953 {
"allow_add_child_feature_with_no_geometry", mAllowAddChildFeatureWithNoGeometry->isChecked()}
959 const QgsRelationEditorWidget::Buttons buttons =
qgsFlagKeysToValue(
config.value( QStringLiteral(
"buttons" ) ).toString(), QgsRelationEditorWidget::Button::AllButtons );
961 mRelationShowLinkCheckBox->setChecked( buttons.testFlag( QgsRelationEditorWidget::Button::Link ) );
962 mRelationShowUnlinkCheckBox->setChecked( buttons.testFlag( QgsRelationEditorWidget::Button::Unlink ) );
963 mRelationShowAddChildCheckBox->setChecked( buttons.testFlag( QgsRelationEditorWidget::Button::AddChildFeature ) );
964 mRelationShowDuplicateChildFeatureCheckBox->setChecked( buttons.testFlag( QgsRelationEditorWidget::Button::DuplicateChildFeature ) );
965 mRelationShowZoomToFeatureCheckBox->setChecked( buttons.testFlag( QgsRelationEditorWidget::Button::ZoomToChildFeature ) );
966 mRelationDeleteChildFeatureCheckBox->setChecked( buttons.testFlag( QgsRelationEditorWidget::Button::DeleteChildFeature ) );
967 mRelationShowSaveChildEditsCheckBox->setChecked( buttons.testFlag( QgsRelationEditorWidget::Button::SaveChildEdits ) );
968 mShowFirstFeature->setChecked(
config.value( QStringLiteral(
"show_first_feature" ),
true ).toBool() );
969 mAllowAddChildFeatureWithNoGeometry->setChecked(
config.value( QStringLiteral(
"allow_add_child_feature_with_no_geometry" ),
false ).toBool() );
984 return QStringLiteral(
"relation_editor" );
989 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.
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 parentFormValueChanged(const QString &attribute, const QVariant &value)
Called in embedded forms when an attribute value in the parent form has changed.
void setView(ViewMode view)
Change the current view mode.
QString expression() const
Returns the original, unmodified expression string.
Wrapper for iterator of features from vector data provider or vector layer.
bool nextFeature(QgsFeature &f)
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 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.
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.
Q_INVOKABLE QgsWkbTypes::GeometryType geometryType() const
Returns point, line or polygon.
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.
Q_INVOKABLE const QgsFeatureIds & selectedFeatureIds() const
Returns a list of the selected features IDs in this layer.
bool isEditable() const FINAL
Returns true if the provider is in editing mode.
QgsFeature getFeature(QgsFeatureId fid) const
Queries the layer for the feature with the given id.
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